@fungi.computer/shed 0.6.0 → 0.6.1
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:rK(this.state.env,l.env)});if(e instanceof RangeError)return s({stdout:``,stderr:`bash: ${AV(e.message)}
|
|
1733
1733
|
`,exitCode:1,env:rK(this.state.env,l.env)});throw e}finally{p?.deactivate()}}catch(e){if(e instanceof tB)return s({stdout:e.stdout,stderr:e.stderr,exitCode:124,env:rK(this.state.env,l.env)});if(e instanceof H)return s({stdout:e.stdout,stderr:AV(e.stderr),exitCode:H.EXIT_CODE,internalOutputAccounting:e.internalOutputAccounting,env:rK(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 nK(this.state.env)}registerTransformPlugin(e){this.transformPlugins.push(e)}transform(e){H7(e,this.limits.maxSourceBytes);let t=k4(W7(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=iK(n,r.metadata))}return{script:RAe(t),ast:t,metadata:n}}};function yIe(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 W7(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=yIe(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 bIe=new TextDecoder(`utf-8`,{fatal:!0});function G7(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 bIe.decode(n)}catch{return e}}function xIe(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:Mz(e)}var SIe=new Set([`sqlite3`,`html-to-markdown`]),K7=[...vke().filter(e=>!SIe.has(e)),`cd`,`export`],q7=new Set(K7),J7;function CIe(){return J7??=new U7({commands:[]}),J7}function Y7(e){let t=``;for(let n of e)if(n.type===`DoubleQuoted`){let e=Y7(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 X7(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=Z7(t);if(e.where!==`light`)return e}}return{where:`light`}}function Z7(e){for(let t of e.redirections){if(t.target.type===`HereDoc`&&t.target.quoted)continue;let e=Q7((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:Y7(e.name.parts);if(t!==null&&!q7.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=Q7(e.parts);if(t.where!==`light`)return t}return{where:`light`}}if(e.type===`If`){for(let t of e.clauses){let e=X7([...t.condition,...t.body]);if(e.where!==`light`)return e}return X7(e.elseBody??[])}if(e.type===`While`||e.type===`Until`)return X7([...e.condition,...e.body]);if(e.type===`Subshell`||e.type===`Group`)return X7(e.body);if(e.type===`FunctionDef`)return Z7(e.body);if(e.type===`For`){for(let t of e.words??[]){let e=Q7(t.parts);if(e.where!==`light`)return e}return X7(e.body)}if(e.type===`Case`){let t=Q7(e.word.parts);if(t.where!==`light`)return t;for(let t of e.items){for(let e of t.patterns){let t=Q7(e.parts);if(t.where!==`light`)return t}let e=X7(t.body);if(e.where!==`light`)return e}return{where:`light`}}return{where:`full`,reason:`shell expression`}}function Q7(e){for(let t of e)if(t.type===`CommandSubstitution`||t.type===`ProcessSubstitution`){let e=X7(t.body.statements);if(e.where!==`light`)return e}else if(t.type===`DoubleQuoted`){let e=Q7(t.parts);if(e.where!==`light`)return e}else if(t.type===`ArithmeticExpansion`){let e=$7(t.expression.expression);if(e.where!==`light`)return e}else if(t.type===`ParameterExpansion`){let e=e9(t.operation);if(e.where!==`light`)return e}return{where:`light`}}function $7(e){if(e.type===`ArithCommandSubst`)return wIe(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=$7(e);if(t.where!==`light`)return t}return{where:`light`}}function e9(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=Q7(e.parts);if(t.where!==`light`)return t}return`innerOp`in e?e9(e.innerOp):{where:`light`}}function t9(e){try{return{kind:`parsed`,ast:CIe().transform(e).ast}}catch(e){return{kind:`invalid`,message:e instanceof Error?e.message:`Invalid shell syntax`}}}function wIe(e){let t=t9(e);return t.kind===`invalid`?{where:`invalid`,message:t.message}:X7(t.ast.statements)}var TIe=[`bun`,`cargo`,`curl`,`docker`,`git`,`go`,`make`,`nano`,`node`,`npm`,`npx`,`pnpm`,`python3`,`ssh`,`vim`,`wget`],EIe=[...new Set([...K7,...TIe])].sort();function DIe(e){let t=t9(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:EIe.filter(t=>t.startsWith(e)).map(e=>({name:e,where:q7.has(e)?`light`:`full`}))}function OIe(e){let t=t9(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:Y7(i.name.parts);return a===`cd`||a===`export`?{name:a}:null}var kIe=So([`ordinary`,`full`,`light`,`exit`]),n9;function AIe(){if(n9!==void 0)return n9;let e=new U7({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:Y7(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`}})}}),n9=e,e}function r9(e){try{let t=AIe().transform(e),n=kIe.parse(t.metadata.control);if(n===`light`||n===`exit`)return{kind:n};let r=n===`full`?t.script:e,i=X7(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 jIe=Ko(()=>Sa().regex(/^(container|vm-[a-z0-9][a-z0-9-]{0,62}|local-[a-z2-7]{16})$/)),i9=new TextEncoder,a9=131072,o9=16384,MIe=65536,NIe=Object.freeze({maximumTimeMs:12e4}),PIe=ns(),s9=Ko(()=>Sa().min(1).max(128).regex(/^[A-Za-z][A-Za-z0-9_]*$/)),c9=Ko(()=>Ka().int().min(1).max(65535));lo({port:c9}),Ko(()=>lo({port:c9,exposed:Xa()})),Ko(()=>lo({port:c9,removed:Xa()})),Ko(()=>lo({ports:oo(c9).max(64)}));var l9=Ko(()=>bo(Sa(),eo()).refine(e=>PIe.safeParse(e).success,`Capability schema must contain JSON values`));Ko(()=>oo(lo({id:s9,name:s9,kind:Sa(),description:Sa(),parameters:l9,output:l9})));var u9=Sa().min(1).max(4096).startsWith(`/`).refine(e=>!e.includes(`\0`),`Path cannot contain null bytes`),d9=(e=0)=>Sa().min(e).refine(e=>i9.encode(e).byteLength<=a9,`Text exceeds the ${String(a9)}-byte Computer bound`);lo({path:u9}),Ko(()=>lo({path:u9,content:d9()}));var FIe=lo({path:u9,byteOffset:Ka().int().nonnegative().optional(),byteLength:Ka().int().positive().max(a9).optional()});Ko(()=>lo({path:FIe.shape.path,byteOffset:Ka().int().nonnegative(),content:Sa(),encoding:wo(`base64`),truncated:Xa()})),Ko(()=>lo({previewUrl:ka(),expiresAt:Ka().int().positive()}));var IIe=Ka().int().min(1).max(256).default(100),LIe=Ka().int().nonnegative().default(0);lo({path:u9.default(`/`),limit:IIe,offset:LIe});var RIe=Ko(()=>lo({name:Sa(),size:Ka().int().nonnegative(),modifiedAt:Ka(),type:So({file:`file`,directory:`directory`,symlink:`symlink`})}));Ko(()=>lo({path:u9,entries:oo(RIe).max(256),nextOffset:Ka().int().nonnegative().nullable()}));var f9=Ko(()=>Sa().refine(e=>i9.encode(e).byteLength<=a9,`File exceeds the Computer write bound`));lo({path:u9,content:f9}),Ko(()=>lo({path:u9,bytes:Ka().int().nonnegative()})),lo({path:u9,expectedContent:f9,content:f9}),Ko(()=>lo({path:u9,pattern:Sa().min(1).max(512),limit:Ka().int().min(1).max(256).default(256)})),Ko(()=>lo({path:u9,matches:oo(u9).max(256),truncated:Xa()})),Ko(()=>lo({path:u9,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)})),Ko(()=>lo({path:u9,matches:oo(lo({path:u9,line:Ka().int().positive(),text:Sa()})).max(256),truncated:Xa()})),Ko(()=>lo({path:u9,oldText:d9(1),newText:d9()})),Ko(()=>lo({path:u9,bytes:Ka().int().nonnegative(),diff:Sa(),firstChangedLine:Ka().int().positive().nullable()})),Ko(()=>lo({path:u9,recursive:Xa().default(!0)})),lo({path:u9});var p9=Da({version:`v7`});function m9(e){return lo({command:Sa().min(1).max(o9),cwd:u9.optional(),backend:jIe.optional(),timeoutMs:Ka().int().min(1).max(e.maximumTimeMs).default(1e4)})}var zIe=m9(NIe);function BIe(e){return m9(e).extend({requestId:p9})}zIe.extend({requestId:p9});var VIe=lo({stream:So({stdout:`stdout`,stderr:`stderr`}),keptBytes:Ka().int().nonnegative(),totalBytes:Ka().int().positive()}),h9=lo({status:So({completed:`completed`,failed:`failed`,cancelled:`cancelled`}),exitCode:Ka().int(),stdout:Sa(),stderr:Sa(),truncated:fo([wo(!1),oo(VIe).min(1)])}),HIe=sce({family:`computer-process`,version:1,kinds:{process:{prefix:`computer_process`}}}).process,g9=Ko(()=>Sa().refine(e=>HIe.is(e)));lo({requestId:Sa().min(1).max(256),requestScope:Sa().min(1).max(512),port:c9.optional(),command:Sa().min(1).max(o9),cwd:u9.optional()}).omit({requestId:!0,requestScope:!0}),lo({id:g9});var UIe=So({running:`running`,exited:`exited`,uncertain:`uncertain`}),WIe=So({synced:`synced`,pending:`pending`,unknown:`unknown`}),_9=lo({id:g9,port:c9.nullable(),command:Sa(),cwd:Sa().nullable(),state:UIe,exitCode:Ka().int().nullable(),sync:WIe,startedAt:Ka().int(),endedAt:Ka().int().nullable(),endedReason:wo(`idle-sleep`).nullable()});lo({processes:oo(_9).max(64)}),lo({id:g9,lines:Ka().int().min(1).max(200).optional()}),lo({process:_9,lines:oo(Sa().max(2e3)).max(200),truncated:Xa()}),Ko(()=>lo({process:_9,signalled:Xa()}));var v9=lo({requestId:p9,status:So({accepted:`accepted`,running:`running`,succeeded:`succeeded`,failed:`failed`,unknown:`unknown`,expired:`expired`}),output:h9.nullable()});v9.omit({requestId:!0}),So({"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`,mkdir:`mkdir`,bash:`bash`,exec:`exec`});function GIe({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 KIe=GIe();function y9(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes(`\x1B`)&&!e.includes(``)?e:e.replace(KIe,``)}var qIe=[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],JIe=[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,[YIe,XIe]=ZIe(b9);function ZIe(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 QIe=e=>e<161||e>1114109?!1:x9(qIe,e),$Ie=e=>e<12288||e>65510?!1:x9(JIe,e),eLe=e=>e>=YIe&&e<=XIe?!0:e<4352||e>262141?!1:x9(b9,e);function tLe(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function C9(e,{ambiguousAsWide:t=!1}={}){return tLe(e),$Ie(e)||eLe(e)||t&&QIe(e)?2:1}var nLe=new Intl.Segmenter,w9=RegExp(`^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Format}|\\p{Nonspacing_Mark}|\\p{Enclosing_Mark}|\\p{Surrogate})+$`,`v`),rLe=RegExp(`^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Nonspacing_Mark}\\p{Enclosing_Mark}\\p{Surrogate}]+`,`v`),iLe=RegExp(`\\p{Spacing_Mark}`,`v`),aLe=RegExp(`^\\p{RGI_Emoji}$`,`v`),oLe=/^[\d#*]\u20E3$/,sLe=/\p{Extended_Pictographic}/gu;function cLe(e){if(e.length>50)return!1;if(oLe.test(e))return!0;if(e.includes(``)){let t=e.match(sLe);return t!==null&&t.length>=2}return!1}function lLe(e){return e.replace(rLe,``)}function uLe(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 dLe(e){return T9(e)||E9(e)||D9(e)}function fLe(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(!dLe(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 pLe(e,t){let n=0,r=!0;for(let i of e){if(r){r=!1;continue}(iLe.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 nLe.segment(i)){if(uLe(e))continue;if(aLe.test(e)||cLe(e)){a+=2;continue}let t=lLe(e),n=fLe(t,o);if(n!==void 0){a+=n;continue}let r=t.codePointAt(0);a+=C9(r,o),a+=pLe(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 mLe(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`,hLe=`${M9}[!p${M9}[?1000l${M9}[?1002l${M9}[?1003l${M9}[?1006l${M9}[?2004l`,gLe=[`1049`,`1047`,`47`,`6`].flatMap(e=>[`${M9}[?${e}h`,`${M9}[?${e}l`]);function _Le(e){return gLe.reduce((e,t)=>e.split(t).join(``),e)}var N9=`${M9}[200~`,P9=`${M9}[201~`,vLe=`${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 bIe=new TextDecoder(`utf-8`,{fatal:!0});function G7(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 bIe.decode(n)}catch{return e}}function xIe(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:Mz(e)}var SIe=new Set([`sqlite3`,`html-to-markdown`]),K7=[...vke().filter(e=>!SIe.has(e)),`cd`,`export`],q7=new Set(K7),J7;function CIe(){return J7??=new U7({commands:[]}),J7}function Y7(e){let t=``;for(let n of e)if(n.type===`DoubleQuoted`){let e=Y7(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 X7(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=Z7(t);if(e.where!==`light`)return e}}return{where:`light`}}function Z7(e){for(let t of e.redirections){if(t.target.type===`HereDoc`&&t.target.quoted)continue;let e=Q7((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:Y7(e.name.parts);if(t!==null&&!q7.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=Q7(e.parts);if(t.where!==`light`)return t}return{where:`light`}}if(e.type===`If`){for(let t of e.clauses){let e=X7([...t.condition,...t.body]);if(e.where!==`light`)return e}return X7(e.elseBody??[])}if(e.type===`While`||e.type===`Until`)return X7([...e.condition,...e.body]);if(e.type===`Subshell`||e.type===`Group`)return X7(e.body);if(e.type===`FunctionDef`)return Z7(e.body);if(e.type===`For`){for(let t of e.words??[]){let e=Q7(t.parts);if(e.where!==`light`)return e}return X7(e.body)}if(e.type===`Case`){let t=Q7(e.word.parts);if(t.where!==`light`)return t;for(let t of e.items){for(let e of t.patterns){let t=Q7(e.parts);if(t.where!==`light`)return t}let e=X7(t.body);if(e.where!==`light`)return e}return{where:`light`}}return{where:`full`,reason:`shell expression`}}function Q7(e){for(let t of e)if(t.type===`CommandSubstitution`||t.type===`ProcessSubstitution`){let e=X7(t.body.statements);if(e.where!==`light`)return e}else if(t.type===`DoubleQuoted`){let e=Q7(t.parts);if(e.where!==`light`)return e}else if(t.type===`ArithmeticExpansion`){let e=$7(t.expression.expression);if(e.where!==`light`)return e}else if(t.type===`ParameterExpansion`){let e=e9(t.operation);if(e.where!==`light`)return e}return{where:`light`}}function $7(e){if(e.type===`ArithCommandSubst`)return wIe(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=$7(e);if(t.where!==`light`)return t}return{where:`light`}}function e9(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=Q7(e.parts);if(t.where!==`light`)return t}return`innerOp`in e?e9(e.innerOp):{where:`light`}}function t9(e){try{return{kind:`parsed`,ast:CIe().transform(e).ast}}catch(e){return{kind:`invalid`,message:e instanceof Error?e.message:`Invalid shell syntax`}}}function wIe(e){let t=t9(e);return t.kind===`invalid`?{where:`invalid`,message:t.message}:X7(t.ast.statements)}var TIe=[`bun`,`cargo`,`curl`,`docker`,`git`,`go`,`make`,`nano`,`node`,`npm`,`npx`,`pnpm`,`python3`,`ssh`,`vim`,`wget`],EIe=[...new Set([...K7,...TIe])].sort();function DIe(e){let t=t9(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:EIe.filter(t=>t.startsWith(e)).map(e=>({name:e,where:q7.has(e)?`light`:`full`}))}function OIe(e){let t=t9(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:Y7(i.name.parts);return a===`cd`||a===`export`?{name:a}:null}var kIe=So([`ordinary`,`full`,`light`,`exit`]),n9;function AIe(){if(n9!==void 0)return n9;let e=new U7({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:Y7(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`}})}}),n9=e,e}function r9(e){try{let t=AIe().transform(e),n=kIe.parse(t.metadata.control);if(n===`light`||n===`exit`)return{kind:n};let r=n===`full`?t.script:e,i=X7(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 jIe=Ko(()=>Sa().regex(/^(container|vm-[a-z0-9][a-z0-9-]{0,62}|local-[a-z2-7]{16})$/)),i9=new TextEncoder,a9=131072,o9=16384,MIe=65536,NIe=Object.freeze({maximumTimeMs:12e4}),PIe=ns(),s9=Ko(()=>Sa().min(1).max(128).regex(/^[A-Za-z][A-Za-z0-9_]*$/)),c9=Ko(()=>Ka().int().min(1).max(65535));lo({port:c9}),Ko(()=>lo({port:c9,exposed:Xa()})),Ko(()=>lo({port:c9,removed:Xa()})),Ko(()=>lo({ports:oo(c9).max(64)}));var l9=Ko(()=>bo(Sa(),eo()).refine(e=>PIe.safeParse(e).success,`Capability schema must contain JSON values`));Ko(()=>oo(lo({id:s9,name:s9,kind:Sa(),description:Sa(),parameters:l9,output:l9})));var u9=Sa().min(1).max(4096).startsWith(`/`).refine(e=>!e.includes(`\0`),`Path cannot contain null bytes`),d9=(e=0)=>Sa().min(e).refine(e=>i9.encode(e).byteLength<=a9,`Text exceeds the ${String(a9)}-byte Computer bound`);lo({path:u9}),Ko(()=>lo({path:u9,content:d9()}));var FIe=lo({path:u9,byteOffset:Ka().int().nonnegative().optional(),byteLength:Ka().int().positive().max(a9).optional()});Ko(()=>lo({path:FIe.shape.path,byteOffset:Ka().int().nonnegative(),content:Sa(),encoding:wo(`base64`),truncated:Xa()})),Ko(()=>lo({previewUrl:ka(),expiresAt:Ka().int().positive()}));var IIe=Ka().int().min(1).max(256).default(100),LIe=Ka().int().nonnegative().default(0);lo({path:u9.default(`/`),limit:IIe,offset:LIe});var RIe=Ko(()=>lo({name:Sa(),size:Ka().int().nonnegative(),modifiedAt:Ka(),type:So({file:`file`,directory:`directory`,symlink:`symlink`})}));Ko(()=>lo({path:u9,entries:oo(RIe).max(256),nextOffset:Ka().int().nonnegative().nullable()}));var f9=Ko(()=>Sa().refine(e=>i9.encode(e).byteLength<=a9,`File exceeds the Computer write bound`));lo({path:u9,content:f9}),Ko(()=>lo({path:u9,bytes:Ka().int().nonnegative()})),lo({path:u9,expectedContent:f9,content:f9}),Ko(()=>lo({path:u9,pattern:Sa().min(1).max(512),limit:Ka().int().min(1).max(256).default(256)})),Ko(()=>lo({path:u9,matches:oo(u9).max(256),truncated:Xa()})),Ko(()=>lo({path:u9,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)})),Ko(()=>lo({path:u9,matches:oo(lo({path:u9,line:Ka().int().positive(),text:Sa()})).max(256),truncated:Xa()})),Ko(()=>lo({path:u9,oldText:d9(1),newText:d9()})),Ko(()=>lo({path:u9,bytes:Ka().int().nonnegative(),diff:Sa(),firstChangedLine:Ka().int().positive().nullable()})),Ko(()=>lo({path:u9,recursive:Xa().default(!0)})),lo({path:u9}),lo({from:u9,to:u9,createParents:Xa().default(!1)}),lo({from:u9,to:u9});var p9=Da({version:`v7`});function m9(e){return lo({command:Sa().min(1).max(o9),cwd:u9.optional(),backend:jIe.optional(),timeoutMs:Ka().int().min(1).max(e.maximumTimeMs).default(1e4)})}var zIe=m9(NIe);function BIe(e){return m9(e).extend({requestId:p9})}zIe.extend({requestId:p9});var VIe=lo({stream:So({stdout:`stdout`,stderr:`stderr`}),keptBytes:Ka().int().nonnegative(),totalBytes:Ka().int().positive()}),h9=lo({status:So({completed:`completed`,failed:`failed`,cancelled:`cancelled`}),exitCode:Ka().int(),stdout:Sa(),stderr:Sa(),truncated:fo([wo(!1),oo(VIe).min(1)])}),HIe=sce({family:`computer-process`,version:1,kinds:{process:{prefix:`computer_process`}}}).process,g9=Ko(()=>Sa().refine(e=>HIe.is(e)));lo({requestId:Sa().min(1).max(256),requestScope:Sa().min(1).max(512),port:c9.optional(),command:Sa().min(1).max(o9),cwd:u9.optional()}).omit({requestId:!0,requestScope:!0}),lo({id:g9});var UIe=So({running:`running`,exited:`exited`,uncertain:`uncertain`}),WIe=So({synced:`synced`,pending:`pending`,unknown:`unknown`}),_9=lo({id:g9,port:c9.nullable(),command:Sa(),cwd:Sa().nullable(),state:UIe,exitCode:Ka().int().nullable(),sync:WIe,startedAt:Ka().int(),endedAt:Ka().int().nullable(),endedReason:wo(`idle-sleep`).nullable()});lo({processes:oo(_9).max(64)}),lo({id:g9,lines:Ka().int().min(1).max(200).optional()}),lo({process:_9,lines:oo(Sa().max(2e3)).max(200),truncated:Xa()}),Ko(()=>lo({process:_9,signalled:Xa()}));var v9=lo({requestId:p9,status:So({accepted:`accepted`,running:`running`,succeeded:`succeeded`,failed:`failed`,unknown:`unknown`,expired:`expired`}),output:h9.nullable()});v9.omit({requestId:!0}),So({"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 GIe({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 KIe=GIe();function y9(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes(`\x1B`)&&!e.includes(``)?e:e.replace(KIe,``)}var qIe=[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],JIe=[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,[YIe,XIe]=ZIe(b9);function ZIe(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 QIe=e=>e<161||e>1114109?!1:x9(qIe,e),$Ie=e=>e<12288||e>65510?!1:x9(JIe,e),eLe=e=>e>=YIe&&e<=XIe?!0:e<4352||e>262141?!1:x9(b9,e);function tLe(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function C9(e,{ambiguousAsWide:t=!1}={}){return tLe(e),$Ie(e)||eLe(e)||t&&QIe(e)?2:1}var nLe=new Intl.Segmenter,w9=RegExp(`^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Format}|\\p{Nonspacing_Mark}|\\p{Enclosing_Mark}|\\p{Surrogate})+$`,`v`),rLe=RegExp(`^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Nonspacing_Mark}\\p{Enclosing_Mark}\\p{Surrogate}]+`,`v`),iLe=RegExp(`\\p{Spacing_Mark}`,`v`),aLe=RegExp(`^\\p{RGI_Emoji}$`,`v`),oLe=/^[\d#*]\u20E3$/,sLe=/\p{Extended_Pictographic}/gu;function cLe(e){if(e.length>50)return!1;if(oLe.test(e))return!0;if(e.includes(``)){let t=e.match(sLe);return t!==null&&t.length>=2}return!1}function lLe(e){return e.replace(rLe,``)}function uLe(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 dLe(e){return T9(e)||E9(e)||D9(e)}function fLe(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(!dLe(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 pLe(e,t){let n=0,r=!0;for(let i of e){if(r){r=!1;continue}(iLe.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 nLe.segment(i)){if(uLe(e))continue;if(aLe.test(e)||cLe(e)){a+=2;continue}let t=lLe(e),n=fLe(t,o);if(n!==void 0){a+=n;continue}let r=t.codePointAt(0);a+=C9(r,o),a+=pLe(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 mLe(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`,hLe=`${M9}[!p${M9}[?1000l${M9}[?1002l${M9}[?1003l${M9}[?1006l${M9}[?2004l`,gLe=[`1049`,`1047`,`47`,`6`].flatMap(e=>[`${M9}[?${e}h`,`${M9}[?${e}l`]);function _Le(e){return gLe.reduce((e,t)=>e.split(t).join(``),e)}var N9=`${M9}[200~`,P9=`${M9}[201~`,vLe=`${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 yLe=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=r9(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(vLe),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=mLe(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=o9-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=_Le(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+hLe),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-
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-BDLaiWtD.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="./assets/index-CTyctzEI.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.6.
|
|
4
|
+
"version": "0.6.1",
|
|
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.
|
|
9
|
+
"@fungi.computer/agar": "0.12.0",
|
|
10
10
|
"@fungi.computer/caps": "0.11.3",
|
|
11
11
|
"@fungi.computer/maosaico": "0.1.2",
|
|
12
12
|
"@fungi.computer/sigils": "0.3.1",
|
|
@@ -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.
|
|
25
|
+
"@fungi.computer/braid": "0.4.12",
|
|
26
26
|
"@fungi.computer/gills": "0.3.0",
|
|
27
|
-
"@fungi.computer/computer-contract": "0.
|
|
27
|
+
"@fungi.computer/computer-contract": "0.3.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@ladle/react": "5.1.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"vitest": "4.1.11",
|
|
40
40
|
"playwright": "1.62.1",
|
|
41
41
|
"@cloudflare/workers-types": "5.20260828.1",
|
|
42
|
-
"@fungi.computer/puffball": "0.
|
|
42
|
+
"@fungi.computer/puffball": "0.6.0",
|
|
43
43
|
"esbuild": "0.28.2",
|
|
44
44
|
"eslint": "10.9.1",
|
|
45
45
|
"tsx": "4.23.12",
|