@fungi.computer/shed 0.7.7 → 0.7.9

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.
@@ -1732,7 +1732,7 @@ ${e.join(`
1732
1732
  `,exitCode:2,env:tK(this.state.env,l.env)});if(e instanceof RangeError)return s({stdout:``,stderr:`bash: ${kV(e.message)}
1733
1733
  `,exitCode:1,env:tK(this.state.env,l.env)});throw e}finally{p?.deactivate()}}catch(e){if(e instanceof eB)return s({stdout:e.stdout,stderr:e.stderr,exitCode:124,env:tK(this.state.env,l.env)});if(e instanceof H)return s({stdout:e.stdout,stderr:kV(e.stderr),exitCode:H.EXIT_CODE,internalOutputAccounting:e.internalOutputAccounting,env:tK(this.state.env,l.env)});throw e}finally{c.cleanup()}}async readFile(e){return this.fs.readFile(this.fs.resolvePath(this.state.cwd,e))}async writeFile(e,t){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,e),t)}getCwd(){return this.state.cwd}getEnv(){return eK(this.state.env)}registerTransformPlugin(e){this.transformPlugins.push(e)}transform(e){B7(e,this.limits.maxSourceBytes);let t=O4(H7(e),{maxHeredocSize:this.limits.maxHeredocSize}),n=Object.create(null);for(let e of this.transformPlugins){let r=e.transform({ast:t,metadata:n});t=r.ast,r.metadata&&(n=nK(n,r.metadata))}return{script:qAe(t),ast:t,metadata:n}}};function kIe(e,t){let n=t;for(let t=0;t<e.length;t++){let r=e[t];if(n===`single`)r===`'`&&(n=`none`);else if(n===`double`)r===`\\`?t++:r===`"`&&(n=`none`);else if(r===`'`)n=`single`;else if(r===`"`)n=`double`;else if(r===`\\`)t++;else if(r===`#`&&(t===0||/\s/.test(e[t-1])))break}return n}function H7(e){let t=e.split(`
1734
1734
  `),n=[],r=[],i=`none`;for(let e=0;e<t.length;e++){let a=t[e];if(r.length>0){let e=r[r.length-1];if((e.stripTabs?a.replace(/^\t+/,``):a)===e.delimiter){n.push(a.trimStart()),r.pop();continue}n.push(a);continue}let o=i,s=o===`none`?a.trimStart():a;if(n.push(s),i=kIe(a,o),o===`none`)for(let e of s.matchAll(/<<(-?)\s*(['"]?)([\w-]+)\2/g)){let t=e[1]===`-`,n=e[3];r.push({delimiter:n,stripTabs:t})}}return n.join(`
1735
- `)}var AIe=new TextDecoder(`utf-8`,{fatal:!0});function U7(e){if(!e)return e;let t=!1;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>255)return e;r>127&&(t=!0)}if(!t)return e;let n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);try{return AIe.decode(n)}catch{return e}}function jIe(e,t,n,r,i,a){if(e===void 0)return;let o=t===`bytes`?e.length:V(e);if(o>n||o>r)throw new H(`stdin size limit exceeded (${Math.min(n,r)} bytes)`,`string_length`);return a||i.consumeInput(o,`stdin`),t===`bytes`?e:jz(e)}var MIe=new Set([`sqlite3`,`html-to-markdown`]),W7=[...Dke().filter(e=>!MIe.has(e)),`cd`,`export`],G7=new Set(W7),K7;function NIe(){return K7??=new V7({commands:[]}),K7}function q7(e){let t=``;for(let n of e)if(n.type===`DoubleQuoted`){let e=q7(n.parts);if(e===null)return null;t+=e}else if(n.type===`Literal`||n.type===`SingleQuoted`||n.type===`Escaped`)t+=n.value;else return null;return t}function J7(e){for(let t of e){if(t.background)return{where:`full`,reason:`background job`};if(t.deferredError)return{where:`invalid`,message:t.deferredError.message};for(let e of t.pipelines)for(let t of e.commands){let e=Y7(t);if(e.where!==`light`)return e}}return{where:`light`}}function Y7(e){for(let t of e.redirections){if(t.target.type===`HereDoc`&&t.target.quoted)continue;let e=X7((t.target.type===`HereDoc`?t.target.content:t.target).parts);if(e.where!==`light`)return e}if(e.type===`SimpleCommand`){let t=e.name===null?null:q7(e.name.parts);if(t!==null&&!G7.has(t))return{where:`full`,reason:t};let n=[...e.name===null?[]:[e.name],...e.args,...e.assignments.flatMap(e=>[...e.value===null?[]:[e.value],...e.array??[]])];for(let e of n){let t=X7(e.parts);if(t.where!==`light`)return t}return{where:`light`}}if(e.type===`If`){for(let t of e.clauses){let e=J7([...t.condition,...t.body]);if(e.where!==`light`)return e}return J7(e.elseBody??[])}if(e.type===`While`||e.type===`Until`)return J7([...e.condition,...e.body]);if(e.type===`Subshell`||e.type===`Group`)return J7(e.body);if(e.type===`FunctionDef`)return Y7(e.body);if(e.type===`For`){for(let t of e.words??[]){let e=X7(t.parts);if(e.where!==`light`)return e}return J7(e.body)}if(e.type===`Case`){let t=X7(e.word.parts);if(t.where!==`light`)return t;for(let t of e.items){for(let e of t.patterns){let t=X7(e.parts);if(t.where!==`light`)return t}let e=J7(t.body);if(e.where!==`light`)return e}return{where:`light`}}return{where:`full`,reason:`shell expression`}}function X7(e){for(let t of e)if(t.type===`CommandSubstitution`||t.type===`ProcessSubstitution`){let e=J7(t.body.statements);if(e.where!==`light`)return e}else if(t.type===`DoubleQuoted`){let e=X7(t.parts);if(e.where!==`light`)return e}else if(t.type===`ArithmeticExpansion`){let e=Z7(t.expression.expression);if(e.where!==`light`)return e}else if(t.type===`ParameterExpansion`){let e=Q7(t.operation);if(e.where!==`light`)return e}return{where:`light`}}function Z7(e){if(e.type===`ArithCommandSubst`)return PIe(e.command);if(e.type===`ArithBracedExpansion`||e.type===`ArithDynamicBase`||e.type===`ArithDynamicNumber`)return{where:`full`,reason:`dynamic arithmetic`};let t=[...`left`in e?[e.left]:[],...`right`in e?[e.right]:[],...`operand`in e?[e.operand]:[],...`condition`in e?[e.condition]:[],...`consequent`in e?[e.consequent]:[],...`alternate`in e?[e.alternate]:[],...e.type===`ArithAssignment`||e.type===`ArithDynamicAssignment`?[e.value]:[],...`subscript`in e?[e.subscript]:[],...`target`in e?[e.target]:[],...`nameExpr`in e?[e.nameExpr]:[],...`index`in e?[e.index]:[],...`expression`in e?[e.expression]:[],...`parts`in e?e.parts:[]].filter(e=>e!==void 0);for(let e of t){let t=Z7(e);if(t.where!==`light`)return t}return{where:`light`}}function Q7(e){if(!e)return{where:`light`};let t=[...`word`in e&&e.word?[e.word]:[],...`pattern`in e&&e.pattern?[e.pattern]:[],...`replacement`in e&&e.replacement?[e.replacement]:[]];for(let e of t){let t=X7(e.parts);if(t.where!==`light`)return t}return`innerOp`in e?Q7(e.innerOp):{where:`light`}}function $7(e){try{return{kind:`parsed`,ast:NIe().transform(e).ast}}catch(e){return{kind:`invalid`,message:e instanceof Error?e.message:`Invalid shell syntax`}}}function PIe(e){let t=$7(e);return t.kind===`invalid`?{where:`invalid`,message:t.message}:J7(t.ast.statements)}var FIe=[`bun`,`cargo`,`curl`,`docker`,`git`,`go`,`make`,`nano`,`node`,`npm`,`npx`,`pnpm`,`python3`,`ssh`,`vim`,`wget`],IIe=[...new Set([...W7,...FIe])].sort();function LIe(e){let t=$7(e);if(t.kind===`invalid`)return t;let n=t.ast.statements.at(0);if(n===void 0||t.ast.statements.length!==1||n.background||n.deferredError||n.pipelines.length!==1)return null;let r=n.pipelines.at(0);if(r===void 0)return null;let i=r.commands.at(0);if(i===void 0||r.commands.length!==1||r.negated||r.timed||i.type!==`SimpleCommand`||i.assignments.length!==0||i.redirections.length!==0||i.args.length!==0||i.name===null)return null;let a=i.name.parts,o=a.at(0);return a.length!==1||o?.type!==`Literal`||o.value!==e?null:IIe.filter(t=>t.startsWith(e)).map(e=>({name:e,where:G7.has(e)?`light`:`full`}))}function RIe(e){let t=$7(e);if(t.kind===`invalid`)return null;let n=t.ast.statements.at(0);if(n===void 0||t.ast.statements.length!==1||n.background||n.deferredError||n.pipelines.length!==1)return null;let r=n.pipelines.at(0);if(r===void 0)return null;let i=r.commands.at(0);if(i===void 0||r.commands.length!==1||r.negated||r.timed||i.type!==`SimpleCommand`||i.redirections.length!==0)return null;let a=i.name===null?null:q7(i.name.parts);return a===`cd`||a===`export`?{name:a}:null}var zIe=Co([`ordinary`,`full`,`light`,`exit`]),e9;function BIe(){if(e9!==void 0)return e9;let e=new V7({commands:[]});return e.registerTransformPlugin({name:`fungi-shell-prompt`,transform:({ast:e})=>{let t=e.statements.at(0),n=t?.pipelines.at(0),r=n?.commands.at(0);if(r?.type!==`SimpleCommand`||r.assignments.length!==0)return{ast:e,metadata:{control:`ordinary`}};let i=r.name===null?null:q7(r.name.parts),a=e.statements.length===1&&t?.pipelines.length===1&&n?.commands.length===1&&!t.background&&r.redirections.length===0;if((i===`light`||i===`exit`)&&a&&r.args.length===0)return{ast:e,metadata:{control:i}};if(i!==`full`)return{ast:e,metadata:{control:`ordinary`}};let o=r.args.shift();return o===void 0?a?{ast:{...e,statements:[]},metadata:{control:`full`}}:{ast:e,metadata:{control:`ordinary`}}:(r.name=o,{ast:e,metadata:{control:`full`}})}}),e9=e,e}function t9(e){try{let t=BIe().transform(e),n=zIe.parse(t.metadata.control);if(n===`light`||n===`exit`)return{kind:n};let r=n===`full`?t.script:e,i=J7(t.ast.statements);return{kind:`command`,command:r,route:i.where===`invalid`?i:n===`full`?{where:`full`,reason:`explicit full`}:i}}catch(e){return{kind:`invalid`,message:e instanceof Error?e.message:`Invalid shell syntax`}}}var VIe=qo(()=>Sa().regex(/^(container|vm-[a-z0-9][a-z0-9-]{0,62}|local-[a-z2-7]{16})$/)),n9=new TextEncoder,r9=131072,i9=16384,HIe=65536,a9=Object.freeze({maximumTimeMs:6e5}),UIe=rs(),o9=qo(()=>Sa().min(1).max(128).regex(/^[A-Za-z][A-Za-z0-9_]*$/)),s9=qo(()=>Ka().int().min(1).max(65535));lo({port:s9}),qo(()=>lo({port:s9,exposed:Xa()})),qo(()=>lo({port:s9,removed:Xa()})),qo(()=>lo({ports:oo(s9).max(64)}));var c9=qo(()=>xo(Sa(),eo()).refine(e=>UIe.safeParse(e).success,`Capability schema must contain JSON values`));qo(()=>oo(lo({id:o9,name:o9,kind:Sa(),description:Sa(),parameters:c9,output:c9})));var l9=Sa().min(1).max(4096).startsWith(`/`).refine(e=>!e.includes(`\0`),`Path cannot contain null bytes`),u9=(e=0)=>Sa().min(e).refine(e=>n9.encode(e).byteLength<=r9,`Text exceeds the ${String(r9)}-byte Computer bound`);lo({path:l9}),qo(()=>lo({path:l9,content:u9()}));var WIe=lo({path:l9,byteOffset:Ka().int().nonnegative().optional(),byteLength:Ka().int().positive().max(r9).optional()});qo(()=>lo({path:WIe.shape.path,byteOffset:Ka().int().nonnegative(),content:Sa(),encoding:To(`base64`),truncated:Xa()})),qo(()=>lo({previewUrl:ka(),expiresAt:Ka().int().positive()}));var GIe=Ka().int().min(1).max(256).default(100),KIe=Ka().int().nonnegative().default(0);lo({path:l9.default(`/`),limit:GIe,offset:KIe});var qIe=qo(()=>lo({name:Sa(),size:Ka().int().nonnegative(),modifiedAt:Ka(),type:Co({file:`file`,directory:`directory`,symlink:`symlink`})}));qo(()=>lo({path:l9,entries:oo(qIe).max(256),nextOffset:Ka().int().nonnegative().nullable()}));var d9=qo(()=>Sa().refine(e=>n9.encode(e).byteLength<=r9,`File exceeds the Computer write bound`));lo({path:l9,content:d9}),qo(()=>lo({path:l9,bytes:Ka().int().nonnegative()})),lo({path:l9,expectedContent:d9.nullable(),content:d9}),qo(()=>lo({path:l9,pattern:Sa().min(1).max(512),limit:Ka().int().min(1).max(256).default(256)})),qo(()=>lo({path:l9,matches:oo(l9).max(256),truncated:Xa()})),qo(()=>lo({path:l9,pattern:Sa().min(1).max(512),regex:Xa().default(!1),ignoreCase:Xa().default(!1),include:Sa().min(1).max(512).optional(),limit:Ka().int().min(1).max(256).default(256)})),qo(()=>lo({path:l9,matches:oo(lo({path:l9,line:Ka().int().positive(),text:Sa()})).max(256),truncated:Xa()})),qo(()=>lo({path:l9,oldText:u9(1),newText:u9()})),qo(()=>lo({path:l9,bytes:Ka().int().nonnegative(),diff:Sa(),firstChangedLine:Ka().int().positive().nullable()})),qo(()=>lo({path:l9,recursive:Xa().default(!0)})),lo({path:l9}),lo({from:l9,to:l9,createParents:Xa().default(!1)}),lo({from:l9,to:l9});var f9=Da({version:`v7`});function p9(e){let t=e/6e4;if(Number.isInteger(t))return`${String(t)} minute${t===1?``:`s`}`;let n=Math.round(e/1e3);return`${String(n)} second${n===1?``:`s`}`}function JIe(e){return`A command can run for up to ${p9(e.maximumTimeMs)}. For longer work, start it in the background with start_process and check on it with wait_process.`}function m9(e,t=!0){let n=Ka().int().describe(`Milliseconds the command may run, at most ${String(e.maximumTimeMs)} (${p9(e.maximumTimeMs)}); ten seconds when omitted. Use start_process for longer work.`).min(1);return lo({command:Sa().min(1).max(i9),cwd:l9.optional(),backend:VIe.optional(),timeoutMs:(t?n.max(e.maximumTimeMs,JIe(e)):n).default(1e4)})}var YIe=m9(a9);m9(a9,!1);function XIe(e){return m9(e).extend({requestId:f9})}YIe.extend({requestId:f9});var ZIe=lo({stream:Co({stdout:`stdout`,stderr:`stderr`}),keptBytes:Ka().int().nonnegative(),totalBytes:Ka().int().positive()}),h9=lo({status:Co({completed:`completed`,failed:`failed`,cancelled:`cancelled`}),exitCode:Ka().int(),stdout:Sa(),stderr:Sa(),truncated:po([To(!1),oo(ZIe).min(1)])}),QIe=fce({family:`computer-process`,version:1,kinds:{process:{prefix:`computer_process`}}}).process,g9=qo(()=>Sa().refine(e=>QIe.is(e)));lo({requestId:Sa().min(1).max(256),requestScope:Sa().min(1).max(512),port:s9.optional(),command:Sa().min(1).max(i9),cwd:l9.optional()}).omit({requestId:!0,requestScope:!0}),lo({id:g9});var $Ie=Co({running:`running`,exited:`exited`,uncertain:`uncertain`}),eLe=Co({synced:`synced`,pending:`pending`,unknown:`unknown`}),_9=lo({id:g9,port:s9.nullable(),command:Sa(),cwd:Sa().nullable(),state:$Ie,exitCode:Ka().int().nullable(),sync:eLe,startedAt:Ka().int(),endedAt:Ka().int().nullable(),endedReason:To(`idle-sleep`).nullable()});lo({processes:oo(_9).max(64)});var tLe=2e3;lo({id:g9,lines:Ka().int().min(1).max(200).optional()});var nLe=lo({process:_9,lines:oo(Sa().max(tLe)).max(200),truncated:Xa()});lo({id:g9,timeoutMs:Ka().int().min(1).max(6e5).default(3e4)}),nLe.extend({timedOut:Xa()}),qo(()=>lo({process:_9,signalled:Xa()}));var v9=lo({requestId:f9,status:Co({accepted:`accepted`,running:`running`,succeeded:`succeeded`,failed:`failed`,unknown:`unknown`,expired:`expired`}),output:h9.nullable()});v9.omit({requestId:!0}),Co({"files.read":`files.read`,"files.readBytes":`files.readBytes`,"files.write":`files.write`,"files.writeBytes":`files.writeBytes`,"files.list":`files.list`,"files.glob":`files.glob`,"files.grep":`files.grep`,"files.edit":`files.edit`,"files.patch":`files.patch`,"files.move":`files.move`,mkdir:`mkdir`,bash:`bash`,exec:`exec`});function rLe({onlyFirst:e=!1}={}){return RegExp(`(?:\\u001B\\][^\\u0007\\u001B\\u009C]*(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`,e?void 0:`g`)}var iLe=rLe();function y9(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes(`\x1B`)&&!e.includes(`›`)?e:e.replace(iLe,``)}var aLe=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],oLe=[12288,12288,65281,65376,65504,65510],b9=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],x9=(e,t)=>{let n=0,r=Math.floor(e.length/2)-1;for(;n<=r;){let i=Math.floor((n+r)/2),a=i*2;if(t<e[a])r=i-1;else if(t>e[a+1])n=i+1;else return!0}return!1},S9=19968,[sLe,cLe]=lLe(b9);function lLe(e){let t=e[0],n=e[1];for(let r=0;r<e.length;r+=2){let i=e[r],a=e[r+1];if(S9>=i&&S9<=a)return[i,a];a-i>n-t&&(t=i,n=a)}return[t,n]}var uLe=e=>e<161||e>1114109?!1:x9(aLe,e),dLe=e=>e<12288||e>65510?!1:x9(oLe,e),fLe=e=>e>=sLe&&e<=cLe?!0:e<4352||e>262141?!1:x9(b9,e);function pLe(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function C9(e,{ambiguousAsWide:t=!1}={}){return pLe(e),dLe(e)||fLe(e)||t&&uLe(e)?2:1}var mLe=new Intl.Segmenter,w9=RegExp(`^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Format}|\\p{Nonspacing_Mark}|\\p{Enclosing_Mark}|\\p{Surrogate})+$`,`v`),hLe=RegExp(`^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Nonspacing_Mark}\\p{Enclosing_Mark}\\p{Surrogate}]+`,`v`),gLe=RegExp(`\\p{Spacing_Mark}`,`v`),_Le=RegExp(`^\\p{RGI_Emoji}$`,`v`),vLe=/^[\d#*]\u20E3$/,yLe=/\p{Extended_Pictographic}/gu;function bLe(e){if(e.length>50)return!1;if(vLe.test(e))return!0;if(e.includes(`‍`)){let t=e.match(yLe);return t!==null&&t.length>=2}return!1}function xLe(e){return e.replace(hLe,``)}function SLe(e){return w9.test(e)}function T9(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function E9(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function D9(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function CLe(e){return T9(e)||E9(e)||D9(e)}function wLe(e,t){let n=[];for(let t of e)w9.test(t)||n.push(t.codePointAt(0));if(n.length===0)return;let r=0;for(let e=0;e<n.length;e++){let i=n[e];if(!CLe(i)){if(r===0)return;for(let i=e;i<n.length;i++)r+=C9(n[i],t);return r}if(T9(i)&&E9(n[e+1])){r+=2,e+=D9(n[e+2])?2:1;continue}r+=C9(i,t)}return r}function TLe(e,t){let n=0,r=!0;for(let i of e){if(r){r=!1;continue}(gLe.test(i)||i>=`＀`&&i<=`￯`)&&(n+=C9(i.codePointAt(0),t))}return n}function O9(e,t={}){if(typeof e!=`string`||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t,i=e;if(!r&&(i.includes(`\x1B`)||i.includes(`›`))&&(i=y9(i)),i.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let a=0,o={ambiguousAsWide:!n};for(let{segment:e}of mLe.segment(i)){if(SLe(e))continue;if(_Le.test(e)||bLe(e)){a+=2;continue}let t=xLe(e),n=wLe(t,o);if(n!==void 0){a+=n;continue}let r=t.codePointAt(0);a+=C9(r,o),a+=TLe(t,o)}return a}var k9=class{#e=[];#t=null;#n=``;record(e){this.#e.push(e),this.#e.length>500&&this.#e.shift(),this.#t=null,this.#n=``}previous(e){return this.#e.length===0?null:(this.#t===null?(this.#n=e,this.#t=this.#e.length-1):this.#t=Math.max(0,this.#t-1),this.#e[this.#t]??null)}next(){return this.#t===null?null:this.#t===this.#e.length-1?(this.#t=null,this.#n):(this.#t+=1,this.#e[this.#t]??null)}suggest(e){if(e.length===0)return null;let t=[...this.#e].reverse().find(t=>t.startsWith(e));return t===void 0||t.length===e.length?null:t.slice(e.length)}search(e,t){for(let n=(this.#t??this.#e.length)-1;n>=0;--n){let r=this.#e[n];if(r.includes(e))return this.#t===null&&(this.#n=t),this.#t=n,r}return null}},A9=new Intl.Segmenter(void 0,{granularity:`grapheme`});function j9(e,t){if(t.type===`home`)return{...e,cursor:0};if(t.type===`end`)return{...e,cursor:e.text.length};if(t.type===`insert`)return{text:e.text.slice(0,e.cursor)+t.text+e.text.slice(e.cursor),cursor:e.cursor+t.text.length};if(t.type===`right`||t.type===`delete`){let n=[...A9.segment(e.text)].find(t=>t.index>e.cursor)?.index??e.text.length;return t.type===`right`?{...e,cursor:n}:{text:e.text.slice(0,e.cursor)+e.text.slice(n),cursor:e.cursor}}let n=[...A9.segment(e.text)].filter(t=>t.index<e.cursor).at(-1)?.index??0;return t.type===`left`?{...e,cursor:n}:{text:e.text.slice(0,n)+e.text.slice(e.cursor),cursor:n}}function ELe(e,t){if(t.altKey||t.metaKey)return null;if(t.ctrlKey)switch(t.key.toLowerCase()){case`a`:return j9(e,{type:`home`});case`e`:return j9(e,{type:`end`});case`b`:return j9(e,{type:`left`});case`f`:return j9(e,{type:`right`});case`h`:return j9(e,{type:`backspace`});case`d`:return j9(e,{type:`delete`});default:return null}switch(t.key){case`ArrowLeft`:return j9(e,{type:`left`});case`ArrowRight`:return j9(e,{type:`right`});case`Home`:return j9(e,{type:`home`});case`End`:return j9(e,{type:`end`});case`Backspace`:return j9(e,{type:`backspace`});case`Delete`:return j9(e,{type:`delete`});default:return null}}var M9=`\x1B`,DLe=`${M9}[!p${M9}[?1000l${M9}[?1002l${M9}[?1003l${M9}[?1006l${M9}[?2004l`,OLe=[`1049`,`1047`,`47`,`6`].flatMap(e=>[`${M9}[?${e}h`,`${M9}[?${e}l`]);function kLe(e){return OLe.reduce((e,t)=>e.split(t).join(``),e)}var N9=`${M9}[200~`,P9=`${M9}[201~`,ALe=`${M9}[2J${M9}[3J${M9}[H`,F9={kind:`none`},I9={consumed:!1,chunks:[],effect:F9,log:``},L9=(e,t)=>`${M9}[${e}m${t}${M9}[0m`,R9=e=>e.replace(/\r?\n/g,`\r
1735
+ `)}var AIe=new TextDecoder(`utf-8`,{fatal:!0});function U7(e){if(!e)return e;let t=!1;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r>255)return e;r>127&&(t=!0)}if(!t)return e;let n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);try{return AIe.decode(n)}catch{return e}}function jIe(e,t,n,r,i,a){if(e===void 0)return;let o=t===`bytes`?e.length:V(e);if(o>n||o>r)throw new H(`stdin size limit exceeded (${Math.min(n,r)} bytes)`,`string_length`);return a||i.consumeInput(o,`stdin`),t===`bytes`?e:jz(e)}var MIe=new Set([`sqlite3`,`html-to-markdown`]),W7=[...Dke().filter(e=>!MIe.has(e)),`cd`,`export`],G7=new Set(W7),K7;function NIe(){return K7??=new V7({commands:[]}),K7}function q7(e){let t=``;for(let n of e)if(n.type===`DoubleQuoted`){let e=q7(n.parts);if(e===null)return null;t+=e}else if(n.type===`Literal`||n.type===`SingleQuoted`||n.type===`Escaped`)t+=n.value;else return null;return t}function J7(e){for(let t of e){if(t.background)return{where:`full`,reason:`background job`};if(t.deferredError)return{where:`invalid`,message:t.deferredError.message};for(let e of t.pipelines)for(let t of e.commands){let e=Y7(t);if(e.where!==`light`)return e}}return{where:`light`}}function Y7(e){for(let t of e.redirections){if(t.target.type===`HereDoc`&&t.target.quoted)continue;let e=X7((t.target.type===`HereDoc`?t.target.content:t.target).parts);if(e.where!==`light`)return e}if(e.type===`SimpleCommand`){let t=e.name===null?null:q7(e.name.parts);if(t!==null&&!G7.has(t))return{where:`full`,reason:t};let n=[...e.name===null?[]:[e.name],...e.args,...e.assignments.flatMap(e=>[...e.value===null?[]:[e.value],...e.array??[]])];for(let e of n){let t=X7(e.parts);if(t.where!==`light`)return t}return{where:`light`}}if(e.type===`If`){for(let t of e.clauses){let e=J7([...t.condition,...t.body]);if(e.where!==`light`)return e}return J7(e.elseBody??[])}if(e.type===`While`||e.type===`Until`)return J7([...e.condition,...e.body]);if(e.type===`Subshell`||e.type===`Group`)return J7(e.body);if(e.type===`FunctionDef`)return Y7(e.body);if(e.type===`For`){for(let t of e.words??[]){let e=X7(t.parts);if(e.where!==`light`)return e}return J7(e.body)}if(e.type===`Case`){let t=X7(e.word.parts);if(t.where!==`light`)return t;for(let t of e.items){for(let e of t.patterns){let t=X7(e.parts);if(t.where!==`light`)return t}let e=J7(t.body);if(e.where!==`light`)return e}return{where:`light`}}return{where:`full`,reason:`shell expression`}}function X7(e){for(let t of e)if(t.type===`CommandSubstitution`||t.type===`ProcessSubstitution`){let e=J7(t.body.statements);if(e.where!==`light`)return e}else if(t.type===`DoubleQuoted`){let e=X7(t.parts);if(e.where!==`light`)return e}else if(t.type===`ArithmeticExpansion`){let e=Z7(t.expression.expression);if(e.where!==`light`)return e}else if(t.type===`ParameterExpansion`){let e=Q7(t.operation);if(e.where!==`light`)return e}return{where:`light`}}function Z7(e){if(e.type===`ArithCommandSubst`)return PIe(e.command);if(e.type===`ArithBracedExpansion`||e.type===`ArithDynamicBase`||e.type===`ArithDynamicNumber`)return{where:`full`,reason:`dynamic arithmetic`};let t=[...`left`in e?[e.left]:[],...`right`in e?[e.right]:[],...`operand`in e?[e.operand]:[],...`condition`in e?[e.condition]:[],...`consequent`in e?[e.consequent]:[],...`alternate`in e?[e.alternate]:[],...e.type===`ArithAssignment`||e.type===`ArithDynamicAssignment`?[e.value]:[],...`subscript`in e?[e.subscript]:[],...`target`in e?[e.target]:[],...`nameExpr`in e?[e.nameExpr]:[],...`index`in e?[e.index]:[],...`expression`in e?[e.expression]:[],...`parts`in e?e.parts:[]].filter(e=>e!==void 0);for(let e of t){let t=Z7(e);if(t.where!==`light`)return t}return{where:`light`}}function Q7(e){if(!e)return{where:`light`};let t=[...`word`in e&&e.word?[e.word]:[],...`pattern`in e&&e.pattern?[e.pattern]:[],...`replacement`in e&&e.replacement?[e.replacement]:[]];for(let e of t){let t=X7(e.parts);if(t.where!==`light`)return t}return`innerOp`in e?Q7(e.innerOp):{where:`light`}}function $7(e){try{return{kind:`parsed`,ast:NIe().transform(e).ast}}catch(e){return{kind:`invalid`,message:e instanceof Error?e.message:`Invalid shell syntax`}}}function PIe(e){let t=$7(e);return t.kind===`invalid`?{where:`invalid`,message:t.message}:J7(t.ast.statements)}var FIe=[`bun`,`cargo`,`curl`,`docker`,`git`,`go`,`make`,`nano`,`node`,`npm`,`npx`,`pnpm`,`python3`,`ssh`,`vim`,`wget`],IIe=[...new Set([...W7,...FIe])].sort();function LIe(e){let t=$7(e);if(t.kind===`invalid`)return t;let n=t.ast.statements.at(0);if(n===void 0||t.ast.statements.length!==1||n.background||n.deferredError||n.pipelines.length!==1)return null;let r=n.pipelines.at(0);if(r===void 0)return null;let i=r.commands.at(0);if(i===void 0||r.commands.length!==1||r.negated||r.timed||i.type!==`SimpleCommand`||i.assignments.length!==0||i.redirections.length!==0||i.args.length!==0||i.name===null)return null;let a=i.name.parts,o=a.at(0);return a.length!==1||o?.type!==`Literal`||o.value!==e?null:IIe.filter(t=>t.startsWith(e)).map(e=>({name:e,where:G7.has(e)?`light`:`full`}))}function RIe(e){let t=$7(e);if(t.kind===`invalid`)return null;let n=t.ast.statements.at(0);if(n===void 0||t.ast.statements.length!==1||n.background||n.deferredError||n.pipelines.length!==1)return null;let r=n.pipelines.at(0);if(r===void 0)return null;let i=r.commands.at(0);if(i===void 0||r.commands.length!==1||r.negated||r.timed||i.type!==`SimpleCommand`||i.redirections.length!==0)return null;let a=i.name===null?null:q7(i.name.parts);return a===`cd`||a===`export`?{name:a}:null}var zIe=Co([`ordinary`,`full`,`light`,`exit`]),e9;function BIe(){if(e9!==void 0)return e9;let e=new V7({commands:[]});return e.registerTransformPlugin({name:`fungi-shell-prompt`,transform:({ast:e})=>{let t=e.statements.at(0),n=t?.pipelines.at(0),r=n?.commands.at(0);if(r?.type!==`SimpleCommand`||r.assignments.length!==0)return{ast:e,metadata:{control:`ordinary`}};let i=r.name===null?null:q7(r.name.parts),a=e.statements.length===1&&t?.pipelines.length===1&&n?.commands.length===1&&!t.background&&r.redirections.length===0;if((i===`light`||i===`exit`)&&a&&r.args.length===0)return{ast:e,metadata:{control:i}};if(i!==`full`)return{ast:e,metadata:{control:`ordinary`}};let o=r.args.shift();return o===void 0?a?{ast:{...e,statements:[]},metadata:{control:`full`}}:{ast:e,metadata:{control:`ordinary`}}:(r.name=o,{ast:e,metadata:{control:`full`}})}}),e9=e,e}function t9(e){try{let t=BIe().transform(e),n=zIe.parse(t.metadata.control);if(n===`light`||n===`exit`)return{kind:n};let r=n===`full`?t.script:e,i=J7(t.ast.statements);return{kind:`command`,command:r,route:i.where===`invalid`?i:n===`full`?{where:`full`,reason:`explicit full`}:i}}catch(e){return{kind:`invalid`,message:e instanceof Error?e.message:`Invalid shell syntax`}}}var VIe=qo(()=>Sa().regex(/^(container|vm-[a-z0-9][a-z0-9-]{0,62}|local-[a-z2-7]{16})$/)),n9=new TextEncoder,r9=131072,i9=16384,HIe=65536,a9=Object.freeze({maximumTimeMs:6e5}),UIe=rs(),o9=qo(()=>Sa().min(1).max(128).regex(/^[A-Za-z][A-Za-z0-9_]*$/)),s9=qo(()=>Ka().int().min(1).max(65535));lo({port:s9}),qo(()=>lo({port:s9,exposed:Xa()})),qo(()=>lo({port:s9,removed:Xa()})),qo(()=>lo({ports:oo(s9).max(64)}));var c9=qo(()=>xo(Sa(),eo()).refine(e=>UIe.safeParse(e).success,`Capability schema must contain JSON values`));qo(()=>oo(lo({id:o9,name:o9,kind:Sa(),description:Sa(),parameters:c9,output:c9})));var l9=Sa().min(1).max(4096).startsWith(`/`).refine(e=>!e.includes(`\0`),`Path cannot contain null bytes`),u9=(e=0)=>Sa().min(e).refine(e=>n9.encode(e).byteLength<=r9,`Text exceeds the ${String(r9)}-byte Computer bound`);lo({path:l9}),qo(()=>lo({path:l9,content:u9()}));var WIe=lo({path:l9,byteOffset:Ka().int().nonnegative().optional(),byteLength:Ka().int().positive().max(r9).optional()});qo(()=>lo({path:WIe.shape.path,byteOffset:Ka().int().nonnegative(),content:Sa(),encoding:To(`base64`),truncated:Xa()})),qo(()=>lo({previewUrl:ka(),expiresAt:Ka().int().positive()}));var GIe=Ka().int().min(1).max(256).default(100),KIe=Ka().int().nonnegative().default(0);lo({path:l9.default(`/`),limit:GIe,offset:KIe});var qIe=qo(()=>lo({name:Sa(),size:Ka().int().nonnegative(),modifiedAt:Ka(),type:Co({file:`file`,directory:`directory`,symlink:`symlink`})}));qo(()=>lo({path:l9,entries:oo(qIe).max(256),nextOffset:Ka().int().nonnegative().nullable()}));var d9=qo(()=>Sa().refine(e=>n9.encode(e).byteLength<=r9,`File exceeds the Computer write bound`));lo({path:l9,content:d9}),qo(()=>lo({path:l9,bytes:Ka().int().nonnegative()})),lo({path:l9,expectedContent:d9.nullable(),content:d9}),qo(()=>lo({path:l9,pattern:Sa().min(1).max(512),limit:Ka().int().min(1).max(256).default(256)})),qo(()=>lo({path:l9,matches:oo(l9).max(256),truncated:Xa()})),qo(()=>lo({path:l9,pattern:Sa().min(1).max(512),regex:Xa().default(!1),ignoreCase:Xa().default(!1),include:Sa().min(1).max(512).optional(),limit:Ka().int().min(1).max(256).default(256)})),qo(()=>lo({path:l9,matches:oo(lo({path:l9,line:Ka().int().positive(),text:Sa()})).max(256),truncated:Xa()})),qo(()=>lo({path:l9,oldText:u9(1),newText:u9()})),qo(()=>lo({path:l9,bytes:Ka().int().nonnegative(),diff:Sa(),firstChangedLine:Ka().int().positive().nullable()})),qo(()=>lo({path:l9,recursive:Xa().default(!0)})),lo({path:l9}),lo({from:l9,to:l9,createParents:Xa().default(!1)}),lo({from:l9,to:l9}),lo({path:l9}),lo({path:l9});var f9=Da({version:`v7`});function p9(e){let t=e/6e4;if(Number.isInteger(t))return`${String(t)} minute${t===1?``:`s`}`;let n=Math.round(e/1e3);return`${String(n)} second${n===1?``:`s`}`}function JIe(e){return`A command can run for up to ${p9(e.maximumTimeMs)}. For longer work, start it in the background with start_process and check on it with wait_process.`}function m9(e,t=!0){let n=Ka().int().describe(`Milliseconds the command may run, at most ${String(e.maximumTimeMs)} (${p9(e.maximumTimeMs)}); ten seconds when omitted. Use start_process for longer work.`).min(1);return lo({command:Sa().min(1).max(i9),cwd:l9.optional(),backend:VIe.optional(),timeoutMs:(t?n.max(e.maximumTimeMs,JIe(e)):n).default(1e4)})}var YIe=m9(a9);m9(a9,!1);function XIe(e){return m9(e).extend({requestId:f9})}YIe.extend({requestId:f9});var ZIe=lo({stream:Co({stdout:`stdout`,stderr:`stderr`}),keptBytes:Ka().int().nonnegative(),totalBytes:Ka().int().positive()}),h9=lo({status:Co({completed:`completed`,failed:`failed`,cancelled:`cancelled`}),exitCode:Ka().int(),stdout:Sa(),stderr:Sa(),truncated:po([To(!1),oo(ZIe).min(1)])}),QIe=fce({family:`computer-process`,version:1,kinds:{process:{prefix:`computer_process`}}}).process,g9=qo(()=>Sa().refine(e=>QIe.is(e)));lo({requestId:Sa().min(1).max(256),requestScope:Sa().min(1).max(512),port:s9.optional(),command:Sa().min(1).max(i9),cwd:l9.optional()}).omit({requestId:!0,requestScope:!0}),lo({id:g9});var $Ie=Co({running:`running`,exited:`exited`,uncertain:`uncertain`}),eLe=Co({synced:`synced`,pending:`pending`,unknown:`unknown`}),_9=lo({id:g9,port:s9.nullable(),command:Sa(),cwd:Sa().nullable(),state:$Ie,exitCode:Ka().int().nullable(),sync:eLe,startedAt:Ka().int(),endedAt:Ka().int().nullable(),endedReason:To(`idle-sleep`).nullable()});lo({processes:oo(_9).max(64)});var tLe=2e3;lo({id:g9,lines:Ka().int().min(1).max(200).optional()});var nLe=lo({process:_9,lines:oo(Sa().max(tLe)).max(200),truncated:Xa()});lo({id:g9,timeoutMs:Ka().int().min(1).max(6e5).default(3e4)}),nLe.extend({timedOut:Xa()}),qo(()=>lo({process:_9,signalled:Xa()}));var v9=lo({requestId:f9,status:Co({accepted:`accepted`,running:`running`,succeeded:`succeeded`,failed:`failed`,unknown:`unknown`,expired:`expired`}),output:h9.nullable()});v9.omit({requestId:!0}),Co({"files.read":`files.read`,"files.readBytes":`files.readBytes`,"files.write":`files.write`,"files.writeBytes":`files.writeBytes`,"files.list":`files.list`,"files.glob":`files.glob`,"files.grep":`files.grep`,"files.edit":`files.edit`,"files.patch":`files.patch`,"files.move":`files.move`,"files.remove":`files.remove`,mkdir:`mkdir`,bash:`bash`,exec:`exec`});function rLe({onlyFirst:e=!1}={}){return RegExp(`(?:\\u001B\\][^\\u0007\\u001B\\u009C]*(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`,e?void 0:`g`)}var iLe=rLe();function y9(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes(`\x1B`)&&!e.includes(`›`)?e:e.replace(iLe,``)}var aLe=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],oLe=[12288,12288,65281,65376,65504,65510],b9=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],x9=(e,t)=>{let n=0,r=Math.floor(e.length/2)-1;for(;n<=r;){let i=Math.floor((n+r)/2),a=i*2;if(t<e[a])r=i-1;else if(t>e[a+1])n=i+1;else return!0}return!1},S9=19968,[sLe,cLe]=lLe(b9);function lLe(e){let t=e[0],n=e[1];for(let r=0;r<e.length;r+=2){let i=e[r],a=e[r+1];if(S9>=i&&S9<=a)return[i,a];a-i>n-t&&(t=i,n=a)}return[t,n]}var uLe=e=>e<161||e>1114109?!1:x9(aLe,e),dLe=e=>e<12288||e>65510?!1:x9(oLe,e),fLe=e=>e>=sLe&&e<=cLe?!0:e<4352||e>262141?!1:x9(b9,e);function pLe(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function C9(e,{ambiguousAsWide:t=!1}={}){return pLe(e),dLe(e)||fLe(e)||t&&uLe(e)?2:1}var mLe=new Intl.Segmenter,w9=RegExp(`^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Format}|\\p{Nonspacing_Mark}|\\p{Enclosing_Mark}|\\p{Surrogate})+$`,`v`),hLe=RegExp(`^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Nonspacing_Mark}\\p{Enclosing_Mark}\\p{Surrogate}]+`,`v`),gLe=RegExp(`\\p{Spacing_Mark}`,`v`),_Le=RegExp(`^\\p{RGI_Emoji}$`,`v`),vLe=/^[\d#*]\u20E3$/,yLe=/\p{Extended_Pictographic}/gu;function bLe(e){if(e.length>50)return!1;if(vLe.test(e))return!0;if(e.includes(`‍`)){let t=e.match(yLe);return t!==null&&t.length>=2}return!1}function xLe(e){return e.replace(hLe,``)}function SLe(e){return w9.test(e)}function T9(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function E9(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function D9(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function CLe(e){return T9(e)||E9(e)||D9(e)}function wLe(e,t){let n=[];for(let t of e)w9.test(t)||n.push(t.codePointAt(0));if(n.length===0)return;let r=0;for(let e=0;e<n.length;e++){let i=n[e];if(!CLe(i)){if(r===0)return;for(let i=e;i<n.length;i++)r+=C9(n[i],t);return r}if(T9(i)&&E9(n[e+1])){r+=2,e+=D9(n[e+2])?2:1;continue}r+=C9(i,t)}return r}function TLe(e,t){let n=0,r=!0;for(let i of e){if(r){r=!1;continue}(gLe.test(i)||i>=`＀`&&i<=`￯`)&&(n+=C9(i.codePointAt(0),t))}return n}function O9(e,t={}){if(typeof e!=`string`||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t,i=e;if(!r&&(i.includes(`\x1B`)||i.includes(`›`))&&(i=y9(i)),i.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let a=0,o={ambiguousAsWide:!n};for(let{segment:e}of mLe.segment(i)){if(SLe(e))continue;if(_Le.test(e)||bLe(e)){a+=2;continue}let t=xLe(e),n=wLe(t,o);if(n!==void 0){a+=n;continue}let r=t.codePointAt(0);a+=C9(r,o),a+=TLe(t,o)}return a}var k9=class{#e=[];#t=null;#n=``;record(e){this.#e.push(e),this.#e.length>500&&this.#e.shift(),this.#t=null,this.#n=``}previous(e){return this.#e.length===0?null:(this.#t===null?(this.#n=e,this.#t=this.#e.length-1):this.#t=Math.max(0,this.#t-1),this.#e[this.#t]??null)}next(){return this.#t===null?null:this.#t===this.#e.length-1?(this.#t=null,this.#n):(this.#t+=1,this.#e[this.#t]??null)}suggest(e){if(e.length===0)return null;let t=[...this.#e].reverse().find(t=>t.startsWith(e));return t===void 0||t.length===e.length?null:t.slice(e.length)}search(e,t){for(let n=(this.#t??this.#e.length)-1;n>=0;--n){let r=this.#e[n];if(r.includes(e))return this.#t===null&&(this.#n=t),this.#t=n,r}return null}},A9=new Intl.Segmenter(void 0,{granularity:`grapheme`});function j9(e,t){if(t.type===`home`)return{...e,cursor:0};if(t.type===`end`)return{...e,cursor:e.text.length};if(t.type===`insert`)return{text:e.text.slice(0,e.cursor)+t.text+e.text.slice(e.cursor),cursor:e.cursor+t.text.length};if(t.type===`right`||t.type===`delete`){let n=[...A9.segment(e.text)].find(t=>t.index>e.cursor)?.index??e.text.length;return t.type===`right`?{...e,cursor:n}:{text:e.text.slice(0,e.cursor)+e.text.slice(n),cursor:e.cursor}}let n=[...A9.segment(e.text)].filter(t=>t.index<e.cursor).at(-1)?.index??0;return t.type===`left`?{...e,cursor:n}:{text:e.text.slice(0,n)+e.text.slice(e.cursor),cursor:n}}function ELe(e,t){if(t.altKey||t.metaKey)return null;if(t.ctrlKey)switch(t.key.toLowerCase()){case`a`:return j9(e,{type:`home`});case`e`:return j9(e,{type:`end`});case`b`:return j9(e,{type:`left`});case`f`:return j9(e,{type:`right`});case`h`:return j9(e,{type:`backspace`});case`d`:return j9(e,{type:`delete`});default:return null}switch(t.key){case`ArrowLeft`:return j9(e,{type:`left`});case`ArrowRight`:return j9(e,{type:`right`});case`Home`:return j9(e,{type:`home`});case`End`:return j9(e,{type:`end`});case`Backspace`:return j9(e,{type:`backspace`});case`Delete`:return j9(e,{type:`delete`});default:return null}}var M9=`\x1B`,DLe=`${M9}[!p${M9}[?1000l${M9}[?1002l${M9}[?1003l${M9}[?1006l${M9}[?2004l`,OLe=[`1049`,`1047`,`47`,`6`].flatMap(e=>[`${M9}[?${e}h`,`${M9}[?${e}l`]);function kLe(e){return OLe.reduce((e,t)=>e.split(t).join(``),e)}var N9=`${M9}[200~`,P9=`${M9}[201~`,ALe=`${M9}[2J${M9}[3J${M9}[H`,F9={kind:`none`},I9={consumed:!1,chunks:[],effect:F9,log:``},L9=(e,t)=>`${M9}[${e}m${t}${M9}[0m`,R9=e=>e.replace(/\r?\n/g,`\r
1736
1736
  `),z9=e=>({text:e,record:!1}),B9=e=>({text:e,record:!0});function V9(e,t){return{row:Math.floor(e/t),col:e%t}}var jLe=class{#e=new k9;#t={text:``,cursor:0};#n=null;#r=`idle`;#i=null;#a=`/workspace`;#o={};#s=0;#c=0;#l;#u=!1;#d;constructor({computerName:e,columns:t}){this.#d=e,this.#l=Math.max(2,t)}get phase(){return this.#r}get route(){let e=t9(this.#t.text);return e.kind===`command`?e.route:e.kind===`invalid`?{where:`invalid`,message:e.message}:{where:`light`}}setColumns(e){this.#l=Math.max(2,e)}setFullReady(e){this.#u=e}draw(){return this.#c=0,z9(this.#T(!0))}redraw(){return z9(this.#S()+this.#T(!0))}returnFromFull(){return this.#r=`idle`,this.#p([B9(`\r
1737
1737
  `),this.draw()])}reopen(){return this.#r=`idle`,this.#p([this.draw()])}key(e){if(e.isComposing||this.#r===`full`)return I9;if(this.#r===`closed`)return this.#f();let t=e.ctrlKey&&!e.altKey&&!e.metaKey,n=t?e.key.toLowerCase():``;if(t&&!e.shiftKey&&n===`c`)return this.#_();if(this.#r===`busy`)return this.#f();if(this.#n!==null)return this.#v(e,n);if(e.altKey||e.metaKey)return I9;if(t){if(n===`r`)return this.#n=``,this.#m();if(n===`l`)return this.#c=0,this.#p([z9(ALe),this.draw()],{kind:`clear`})}else if(!e.shiftKey)switch(e.key){case`Enter`:return this.#x();case`Tab`:return this.#y();case`ArrowUp`:return this.#h(this.#e.previous(this.#t.text));case`ArrowDown`:return this.#h(this.#e.next());case`ArrowRight`:{let e=this.#g();if(e)return this.#i=null,this.#t=j9(this.#t,{type:`insert`,text:e}),this.#m();break}}if(e.shiftKey&&!t)return I9;let r=ELe(this.#t,e);return r?(this.#i=null,this.#t=r,this.#m()):I9}input(e){if(this.#r!==`idle`)return this.#f();let t=e.startsWith(N9)&&e.endsWith(P9)?e.slice(N9.length,-P9.length):e;if(t.startsWith(M9))return this.#f();let n=t.replace(/[\r\n]+$/,``);if(/[\r\n]/.test(n))return this.#b(`The light shell runs one line at a time; paste several lines into the full shell (full bash).`);let r=n.replace(/\p{Cc}/gu,``);if(r.length===0)return this.#f();if(this.#n!==null)return this.#n+=r,this.#m();let i=i9-this.#t.text.length;return i<=0?this.#f():(this.#i=null,this.#t=j9(this.#t,{type:`insert`,text:r.slice(0,i)}),this.#m())}finish(e){this.#r=`idle`,this.#a=e.cwd,this.#o=e.env,this.#s=e.exitCode;let t=kLe(e.stdout+e.stderr),n=e.exitCode===127?`light: command not found; use full to run it in the full shell.`:``,r=[t.replace(/\r?\n$/,``),n].filter(e=>e.length>0),i=r.map(e=>`${R9(e)}\r\n`).join(``);return this.#p([B9(i+DLe),this.draw()],F9,y9(r.join(`
1738
1738
  `)))}fail(e){this.#r=`idle`;let t=e===`full`?`The full shell could not start. Light commands still work.`:`The light shell could not run this command.`;return this.#p([B9(`${t}\r\n`),this.draw()],F9,t)}#f(){return{consumed:!0,chunks:[],effect:F9,log:``}}#p(e,t=F9,n=``){return{consumed:!0,chunks:e,effect:t,log:n}}#m(){return this.#p([this.redraw()])}#h(e){return e!==null&&(this.#i=null,this.#t={text:e,cursor:e.length}),this.#m()}#g(){return this.#t.cursor===this.#t.text.length?this.#e.suggest(this.#t.text):null}#_(){let e=this.#r===`busy`;if(this.#r=`idle`,this.#n=null,this.#i=null,e)return this.#p([B9(`^C\r
package/dist/index.html CHANGED
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>Shed</title>
7
- <script type="module" crossorigin src="./assets/index-Cw5TnvDT.js"></script>
7
+ <script type="module" crossorigin src="./assets/index-DExFKez2.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="./assets/index--PRmIQpI.css">
9
9
  </head>
10
10
  <body
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@fungi.computer/shed",
3
3
  "description": "Shed: a terminal on your Computer, with its ports and processes, for Oyster",
4
- "version": "0.7.7",
4
+ "version": "0.7.9",
5
5
  "author": "Levi <levi@technomancy.dev>",
6
6
  "type": "module",
7
7
  "dependencies": {
8
8
  "@fungi.computer/cairn": "0.1.0",
9
- "@fungi.computer/agar": "0.18.0",
9
+ "@fungi.computer/agar": "0.18.1",
10
10
  "@fungi.computer/caps": "0.11.7",
11
11
  "@fungi.computer/maosaico": "0.1.2",
12
12
  "@fungi.computer/sigils": "0.3.2",
@@ -22,9 +22,9 @@
22
22
  "@tanstack/react-query": "5.102.8",
23
23
  "effect": "4.0.2",
24
24
  "zod": "4.4.3",
25
- "@fungi.computer/braid": "0.4.19",
25
+ "@fungi.computer/braid": "0.4.20",
26
26
  "@fungi.computer/gills": "0.3.0",
27
- "@fungi.computer/computer-contract": "0.4.1"
27
+ "@fungi.computer/computer-contract": "0.5.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@ladle/react": "5.1.1",