castle-web-cli 0.4.79 → 0.4.80
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.
package/dist/agent.js
CHANGED
|
@@ -38,8 +38,8 @@ const DEFAULT_SETTINGS = {
|
|
|
38
38
|
// sonnet's cost/speed wins by default; the conductor stays on opus.
|
|
39
39
|
tasksClaudeModel: "sonnet",
|
|
40
40
|
// Free-form -- change to any OpenRouter slug.
|
|
41
|
-
routerOpenrouterModel: "
|
|
42
|
-
tasksOpenrouterModel: "
|
|
41
|
+
routerOpenrouterModel: "openai/gpt-5.6-sol",
|
|
42
|
+
tasksOpenrouterModel: "openai/gpt-5.6-terra",
|
|
43
43
|
};
|
|
44
44
|
function normalizeBackend(value) {
|
|
45
45
|
return value === "cursor" || value === "claude" || value === "smith"
|
package/dist/native/tools.js
CHANGED
|
@@ -366,6 +366,61 @@ function grepRun(args, ctx) {
|
|
|
366
366
|
output: results.join("\n") + (truncated ? `\n... (capped at ${GREP_MAX_RESULTS} matches)` : ""),
|
|
367
367
|
};
|
|
368
368
|
}
|
|
369
|
+
// -- bash filesTouched heuristic ---------------------------------------------
|
|
370
|
+
// Mirrors shellTouchedCandidates/drawingPathForDrawArg/looksLikeTouchedPath in
|
|
371
|
+
// agent.ts's CLI stream parser, so a smith task's bash-redirect writes are
|
|
372
|
+
// tracked the same way a cursor/claude task's shell-tool writes are. Before
|
|
373
|
+
// this, bash had NO filesTouched signal at all here -- a smith task that
|
|
374
|
+
// wrote its result via a shell redirect (heredoc, `>`, `npm run draw --`,
|
|
375
|
+
// etc.) instead of write_file/edit_file still landed with an empty
|
|
376
|
+
// filesTouched and tripped the false "no changes" caution despite genuinely
|
|
377
|
+
// writing to disk. (This is the gap agent-prompts.ts's renderTasks used to
|
|
378
|
+
// paper over with a "bash side effects aren't tracked" caveat.)
|
|
379
|
+
const SHELL_REDIRECT_RE = /(?:^|[\s;|])(?:\d*)>>?\s*(?!&)(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))/g;
|
|
380
|
+
const DRAW_RE = /npm\s+run\s+draw\s+--\s+([^\s;&|]+)/g;
|
|
381
|
+
function drawingPathForDrawArg(raw) {
|
|
382
|
+
const name = raw.replace(/^['"]|['"]$/g, "").trim();
|
|
383
|
+
if (!name || name.startsWith("-") || name.includes("\n"))
|
|
384
|
+
return null;
|
|
385
|
+
if (name.startsWith("drawings/")) {
|
|
386
|
+
return name.endsWith(".pxart") ? name : `${name}.pxart`;
|
|
387
|
+
}
|
|
388
|
+
return `drawings/${name.endsWith(".pxart") ? name : `${name}.pxart`}`;
|
|
389
|
+
}
|
|
390
|
+
// Guards every redirect candidate against junk that isn't plausibly a path --
|
|
391
|
+
// the redirect regex treats any `>`-plus-token as a write target, so e.g. a
|
|
392
|
+
// numeric comparison inside a quoted inline script (`>=5`) false-matches.
|
|
393
|
+
function looksLikeTouchedPath(raw) {
|
|
394
|
+
return /[a-zA-Z0-9]/.test(raw) && raw[0] !== "-" && raw[0] !== "=";
|
|
395
|
+
}
|
|
396
|
+
function shellTouchedCandidates(command) {
|
|
397
|
+
const out = [];
|
|
398
|
+
for (const match of command.matchAll(SHELL_REDIRECT_RE)) {
|
|
399
|
+
const target = match[1] ?? match[2] ?? match[3];
|
|
400
|
+
if (target)
|
|
401
|
+
out.push(target);
|
|
402
|
+
}
|
|
403
|
+
for (const match of command.matchAll(DRAW_RE)) {
|
|
404
|
+
const drawing = drawingPathForDrawArg(match[1] ?? "");
|
|
405
|
+
if (drawing)
|
|
406
|
+
out.push(drawing);
|
|
407
|
+
}
|
|
408
|
+
return out;
|
|
409
|
+
}
|
|
410
|
+
// Resolves each shell-redirect candidate against the deck dir the same way
|
|
411
|
+
// write_file/edit_file do (path escapes rejected, .castle/ and the progress
|
|
412
|
+
// file excluded) -- see resolveInDeck/isTrackedTouch above.
|
|
413
|
+
function bashFilesTouched(deckDir, command) {
|
|
414
|
+
const out = [];
|
|
415
|
+
for (const candidate of shellTouchedCandidates(command)) {
|
|
416
|
+
if (!looksLikeTouchedPath(candidate) || candidate.includes("\n"))
|
|
417
|
+
continue;
|
|
418
|
+
const resolved = resolveInDeck(deckDir, candidate);
|
|
419
|
+
if (resolved && isTrackedTouch(resolved.rel))
|
|
420
|
+
out.push(resolved.rel);
|
|
421
|
+
}
|
|
422
|
+
return out;
|
|
423
|
+
}
|
|
369
424
|
// -- bash -------------------------------------------------------------------
|
|
370
425
|
// Full shell, trusted -- matches today's --force trust level for task agents
|
|
371
426
|
// (ratified; not revisited here). cwd is always the deck dir; per-call
|
|
@@ -425,9 +480,14 @@ function bashRun(args, ctx) {
|
|
|
425
480
|
// the assistant's own tool_call (which, unlike this result, is never
|
|
426
481
|
// evicted from context -- see evictOldToolResults in loop.ts), so
|
|
427
482
|
// repeating it would just be the same bytes twice on every later turn.
|
|
483
|
+
// filesTouched is derived from the command text itself (not gated on
|
|
484
|
+
// `ok`): a shell redirect creates/truncates its target as soon as the
|
|
485
|
+
// shell sets it up, before the command even runs, so the write already
|
|
486
|
+
// landed even if the command that followed the redirect then failed.
|
|
428
487
|
resolve({
|
|
429
488
|
ok,
|
|
430
489
|
output: `(exit ${code ?? "null"})\n${capped}${timedOutNote}`,
|
|
490
|
+
filesTouched: bashFilesTouched(ctx.deckDir, command),
|
|
431
491
|
});
|
|
432
492
|
});
|
|
433
493
|
});
|
|
@@ -70,7 +70,7 @@ ${e}</tr>
|
|
|
70
70
|
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Bi(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Vi(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+Bi(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Vi(e);if(i===null)return Bi(n);e=i;let a=`<img src="${e}" alt="${Bi(n)}"`;return t&&(a+=` title="${Bi(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Bi(e.text)}},Qi=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},$i=class e{options;renderer;textRenderer;constructor(e){this.options=e||Dr,this.options.renderer=this.options.renderer||new Zi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Qi}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},ea=class{options;block;constructor(e){this.options=e||Dr}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Xi.lex:Xi.lexInline}provideParser(e=this.block){return e?$i.parse:$i.parseInline}},ta=new class{defaults=Er();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=$i;Renderer=Zi;TextRenderer=Qi;Lexer=Xi;Tokenizer=Yi;Hooks=ea;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Zi(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Yi(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new ea;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];ea.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&ea.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Xi.lex(e,t??this.defaults)}parser(e,t){return $i.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?Xi.lex:Xi.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?$i.parse:$i.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?Xi.lex:Xi.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?$i.parse:$i.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
71
71
|
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Bi(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function F(e,t){return ta.parse(e,t)}F.options=F.setOptions=function(e){return ta.setOptions(e),F.defaults=ta.defaults,Or(F.defaults),F},F.getDefaults=Er,F.defaults=Dr,F.use=function(...e){return ta.use(...e),F.defaults=ta.defaults,Or(F.defaults),F},F.walkTokens=function(e,t){return ta.walkTokens(e,t)},F.parseInline=ta.parseInline,F.Parser=$i,F.parser=$i.parse,F.Renderer=Zi,F.TextRenderer=Qi,F.Lexer=Xi,F.lexer=Xi.lex,F.Tokenizer=Yi,F.Hooks=ea,F.parse=F,F.options,F.setOptions,F.use,F.walkTokens,F.parseInline,$i.parse,Xi.lex;var na=o((e=>{var t=u(),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.Fragment=r,e.jsx=s,e.jsxs=s})),I=o(((e,t)=>{t.exports=na()}))(),ra=/```ask[ \t]*\n([\s\S]*?)```/g;function ia(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||!Array.isArray(t.questions))return null;let n=[];return t.questions.forEach((e,t)=>{let r=e;if(!r||typeof r.q!=`string`||!Array.isArray(r.options))return;let i=r.options.filter(e=>typeof e==`string`&&e.trim()!==``);if(i.length===0)return;let a=typeof r.id==`string`&&r.id.trim()?r.id.trim():`q${t}`;n.push({id:a,q:r.q,options:i,multi:r.multi===!0})}),n.length===0?null:{questions:n}}function aa(e){let t=!1;if((e.split("```").length-1)%2==1){let n=e.lastIndexOf("```"),r=e.slice(n+3),i=r.indexOf(`
|
|
72
72
|
`),a=(i===-1?r:r.slice(0,i)).trim();i===-1?a===``?e=e.slice(0,n):`ask`.startsWith(a)&&(e=e.slice(0,n),t=!0):a===`ask`&&(e=e.slice(0,n),t=!0)}let n=[],r=0,i;for(ra.lastIndex=0;(i=ra.exec(e))!==null;){let t=ia(i[1]);t&&(i.index>r&&n.push({kind:`md`,text:e.slice(r,i.index)}),n.push({kind:`ask`,spec:t}),r=i.index+i[0].length)}return r<e.length&&n.push({kind:`md`,text:e.slice(r)}),n.length===0&&!t&&n.push({kind:`md`,text:e}),t&&n.push({kind:`ask-pending`}),n}function oa(e,t){let n=[];for(let r of e.questions){let e=(t[r.id]??[]).filter(e=>r.options.includes(e));e.length!==0&&n.push(`- ${r.q} \u2192 ${e.join(`, `)}`)}return n.length?`Here's what I picked:\n${n.join(`
|
|
73
|
-
`)}`:``}var sa=`/__castle/agent/attachments/`,ca={lightbulb:{w:352,d:`M96.06 454.35c.01 6.29 1.87 12.45 5.36 17.69l17.09 25.69a31.99 31.99 0 0 0 26.64 14.28h61.71a31.99 31.99 0 0 0 26.64-14.28l17.09-25.69a31.989 31.989 0 0 0 5.36-17.69l.04-38.35H96.01l.05 38.35zM0 176c0 44.37 16.45 84.85 43.56 115.78 16.52 18.85 42.36 58.23 52.21 91.45.04.26.07.52.11.78h160.24c.04-.26.07-.51.11-.78 9.85-33.22 35.69-72.6 52.21-91.45C335.55 260.85 352 220.37 352 176 352 78.61 272.91-.3 175.45 0 73.44.31 0 82.97 0 176zm176-80c-44.11 0-80 35.89-80 80 0 8.84-7.16 16-16 16s-16-7.16-16-16c0-61.76 50.24-112 112-112 8.84 0 16 7.16 16 16s-7.16 16-16 16z`},book:{w:448,d:`M448 360V24c0-13.3-10.7-24-24-24H96C43 0 0 43 0 96v320c0 53 43 96 96 96h328c13.3 0 24-10.7 24-24v-16c0-7.5-3.5-14.3-8.9-18.7-4.2-15.4-4.2-59.3 0-74.7 5.4-4.3 8.9-11.1 8.9-18.6zM128 134c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm0 64c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm253.4 250H96c-17.7 0-32-14.3-32-32 0-17.6 14.4-32 32-32h285.4c-1.9 17.1-1.9 46.9 0 64z`},hammer:{w:576,d:`M571.31 193.94l-22.63-22.63c-6.25-6.25-16.38-6.25-22.63 0l-11.31 11.31-28.9-28.9c5.63-21.31.36-44.9-16.35-61.61l-45.25-45.25c-62.48-62.48-163.79-62.48-226.28 0l90.51 45.25v18.75c0 16.97 6.74 33.25 18.75 45.25l49.14 49.14c16.71 16.71 40.3 21.98 61.61 16.35l28.9 28.9-11.31 11.31c-6.25 6.25-6.25 16.38 0 22.63l22.63 22.63c6.25 6.25 16.38 6.25 22.63 0l90.51-90.51c6.23-6.24 6.23-16.37-.02-22.62zm-286.72-15.2c-3.7-3.7-6.84-7.79-9.85-11.95L19.64 404.96c-25.57 23.88-26.26 64.19-1.53 88.93s65.05 24.05 88.93-1.53l238.13-255.07c-3.96-2.91-7.9-5.87-11.44-9.41l-49.14-49.14z`},pencil:{w:512,d:`M497.9 142.1l-46.1 46.1c-4.7 4.7-12.3 4.7-17 0l-111-111c-4.7-4.7-4.7-12.3 0-17l46.1-46.1c18.7-18.7 49.1-18.7 67.9 0l60.1 60.1c18.8 18.7 18.8 49.1 0 67.9zM284.2 99.8L21.6 362.4.4 483.9c-2.9 16.4 11.4 30.6 27.8 27.8l121.5-21.3 262.6-262.6c4.7-4.7 4.7-12.3 0-17l-111-111c-4.8-4.7-12.4-4.7-17.1 0zM124.1 339.9c-5.5-5.5-5.5-14.3 0-19.8l154-154c5.5-5.5 14.3-5.5 19.8 0s5.5 14.3 0 19.8l-154 154c-5.5 5.5-14.3 5.5-19.8 0zM88 424h48v36.3l-64.5 11.3-31.1-31.1L51.7 376H88v48z`},gamepad:{w:640,d:`M480.07 96H160a160 160 0 1 0 114.24 272h91.52A160 160 0 1 0 480.07 96zM248 268a12 12 0 0 1-12 12h-52v52a12 12 0 0 1-12 12h-24a12 12 0 0 1-12-12v-52H84a12 12 0 0 1-12-12v-24a12 12 0 0 1 12-12h52v-52a12 12 0 0 1 12-12h24a12 12 0 0 1 12 12v52h52a12 12 0 0 1 12 12zm216 76a40 40 0 1 1 40-40 40 40 0 0 1-40 40zm64-96a40 40 0 1 1 40-40 40 40 0 0 1-40 40z`},check:{w:512,d:`M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z`},times:{w:352,d:`M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z`},stop:{w:448,d:`M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z`}};function la({glyph:e}){return(0,I.jsx)(`svg`,{className:`avatar-icon`,viewBox:`0 0 ${e.w} 512`,fill:`currentColor`,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{d:e.d})})}var ua={thinking:(0,I.jsx)(la,{glyph:ca.lightbulb}),reading:(0,I.jsx)(la,{glyph:ca.book}),building:(0,I.jsx)(la,{glyph:ca.hammer}),painting:(0,I.jsx)(la,{glyph:ca.pencil}),playing:(0,I.jsx)(la,{glyph:ca.gamepad})},da={thinking:`Thinking`,reading:`Reading files`,building:`Editing logic`,painting:`Editing art`,playing:`Playtesting`},fa={thinking:`#FFC826`,reading:`#FFC826`,building:`#FFEB57`,painting:`#FFEB57`,playing:`#D3FC7E`};function pa(e){if(e.status===`done`)return{icon:(0,I.jsx)(la,{glyph:ca.check}),color:e.suspectNoChanges?`#F5A623`:`#5AC54F`};if(e.status===`failed`)return{icon:(0,I.jsx)(la,{glyph:ca.times}),color:`#F5545D`};if(e.status===`interrupted`)return{icon:(0,I.jsx)(la,{glyph:ca.stop}),color:`#B4B4B4`};if(e.status===`blocked`)return{icon:(0,I.jsx)(la,{glyph:ca.stop}),color:`#F5A623`};let t=e.avatar&&ua[e.avatar]?e.avatar:`thinking`;return{icon:ua[t],color:fa[t]}}function ma(e){let t=Math.max(1,Math.round((e??0)/1e3));if(t<60)return`Thought for ${t}s`;let n=Math.floor(t/60),r=t%60;return r===0?`Thought for ${n}m`:`Thought for ${n}m ${r}s`}function ha(e){try{return{__html:F.parse(e,{breaks:!0,async:!1})}}catch{return{__html:``}}}var ga=(0,I.jsx)(`svg`,{viewBox:`0 0 512 512`,width:12,height:12,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{d:`M470.3 271.15 43.16 447.31a7.83 7.83 0 0 1-11.16-7V327a8 8 0 0 1 6.51-7.86l247.62-47c17.36-3.29 17.36-28.15 0-31.44l-247.63-47a8 8 0 0 1-6.5-7.85V72.59c0-5.74 5.88-10.26 11.16-8L470.3 241.76a16 16 0 0 1 0 29.39`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:32})}),_a=(0,I.jsx)(`svg`,{viewBox:`0 0 512 512`,width:12,height:12,"aria-hidden":`true`,children:(0,I.jsx)(`rect`,{x:128,y:128,width:256,height:256,rx:36,fill:`currentColor`})}),va=(0,I.jsx)(`svg`,{viewBox:`0 0 24 24`,width:10,height:10,fill:`none`,stroke:`currentColor`,strokeWidth:2.4,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`mode-caret`,children:(0,I.jsx)(`path`,{d:`M6 9l6 6 6-6`})}),ya=(0,I.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:18,height:18,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,I.jsx)(`rect`,{x:3,y:4,width:18,height:16,rx:2}),(0,I.jsx)(`line`,{x1:14,y1:4,x2:14,y2:20})]}),ba=(0,I.jsx)(`svg`,{viewBox:`0 0 512 512`,width:20,height:20,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{d:`M408 64H104a56.16 56.16 0 0 0-56 56v192a56.16 56.16 0 0 0 56 56h40v80l93.72-78.14a8 8 0 0 1 5.13-1.86H408a56.16 56.16 0 0 0 56-56V120a56.16 56.16 0 0 0-56-56z`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:32})}),xa=[{value:`claude`,label:`Claude`},{value:`cursor`,label:`Cursor`},{value:`smith`,label:`Smith`}],Sa=[{value:`opus`,label:`Opus`},{value:`sonnet`,label:`Sonnet`},{value:`fable`,label:`Fable`},{value:`openrouter`,label:`OpenRouter`}];function Ca(e,t){return e===`smith`||e===`claude`&&t===`openrouter`}var wa=[{type:`enum`,key:`router`,label:`Conductor`,options:xa},{type:`enum`,key:`routerClaudeModel`,label:`Model`,options:Sa,showWhen:e=>e.router===`claude`},{type:`text`,key:`routerOpenrouterModel`,label:`OpenRouter model`,placeholder:`google/gemini-3.5-flash`,showWhen:e=>Ca(e.router,e.routerClaudeModel)},{type:`enum`,key:`tasks`,label:`Tasks`,options:xa},{type:`enum`,key:`tasksClaudeModel`,label:`Model`,options:Sa,showWhen:e=>e.tasks===`claude`},{type:`text`,key:`tasksOpenrouterModel`,label:`OpenRouter model`,placeholder:`google/gemini-3.5-flash`,showWhen:e=>Ca(e.tasks,e.tasksClaudeModel)}];function Ta(e){let{label:t,placeholder:n,value:r,onCommit:i}=e,[a,o]=g.useState(r);g.useEffect(()=>o(r),[r]);let s=()=>{let e=a.trim();e&&e!==r?i(e):o(r)};return(0,I.jsxs)(`div`,{className:`settings-row`,children:[(0,I.jsx)(`span`,{className:`settings-label`,children:t}),(0,I.jsx)(`input`,{type:`text`,className:`settings-text`,value:a,placeholder:n,onChange:e=>o(e.target.value),onBlur:s,onKeyDown:e=>{e.key===`Enter`&&(s(),e.target.blur())}})]})}function Ea(e){let{settings:t,onSetSetting:n,onClose:r}=e,i=g.useRef(null);return g.useEffect(()=>{let e=e=>{i.current&&!i.current.contains(e.target)&&r()},t=e=>{e.key===`Escape`&&r()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]),(0,I.jsx)(`div`,{className:`settings-popover`,ref:i,onMouseDown:e=>e.stopPropagation(),children:wa.filter(e=>!e.showWhen||e.showWhen(t)).map(e=>{if(e.type===`text`)return(0,I.jsx)(Ta,{label:e.label,placeholder:e.placeholder,value:t[e.key]??``,onCommit:t=>n(e.key,t)},e.key);let r=t[e.key];return(0,I.jsxs)(`div`,{className:`settings-row`,children:[(0,I.jsx)(`span`,{className:`settings-label`,children:e.label}),(0,I.jsx)(`div`,{className:`settings-seg`,children:e.options.map(t=>(0,I.jsx)(`button`,{type:`button`,tabIndex:-1,className:`settings-opt`+(r===t.value?` active`:``),onClick:()=>n(e.key,t.value),children:t.label},t.value))})]},e.key)})})}function Da(e){let{spec:t,interactive:n,answers:r,onSubmit:i}=e,[a,o]=g.useState({}),s=n?a:r??{},c=(e,t,r)=>{n&&o(n=>{let i=n[e]??[];if(r){let r=i.includes(t)?i.filter(e=>e!==t):[...i,t];return{...n,[e]:r}}return{...n,[e]:i[0]===t?[]:[t]}})};return(0,I.jsxs)(`div`,{className:`picker${n?``:` picker-locked`}`,children:[t.questions.map(e=>(0,I.jsxs)(`fieldset`,{className:`picker-q`,disabled:!n,children:[(0,I.jsx)(`legend`,{className:`picker-q-label`,children:e.q}),(0,I.jsx)(`div`,{className:`picker-options`,children:e.options.map(t=>{let r=(s[e.id]??[]).includes(t);return(0,I.jsxs)(`label`,{className:`picker-option${r?` is-checked`:``}`,children:[(0,I.jsx)(`input`,{type:e.multi?`checkbox`:`radio`,name:e.id,checked:r,disabled:!n,onChange:()=>c(e.id,t,e.multi)}),(0,I.jsx)(`span`,{children:t})]},t)})})]},e.id)),n?(0,I.jsx)(`div`,{className:`picker-actions`,children:(0,I.jsx)(`button`,{className:`picker-submit`,type:`button`,onClick:()=>{let e=oa(t,a);e&&i(a,e)},children:`Submit`})}):null]})}function Oa(){return(0,I.jsxs)(`div`,{className:`picker picker-skeleton`,"aria-hidden":`true`,children:[(0,I.jsx)(`span`,{className:`picker-skeleton-hint`,children:`preparing options…`}),(0,I.jsxs)(`div`,{className:`picker-q`,children:[(0,I.jsx)(`div`,{className:`picker-skeleton-line picker-skeleton-label`}),(0,I.jsxs)(`div`,{className:`picker-options`,children:[(0,I.jsx)(`span`,{className:`picker-skeleton-chip`,style:{width:84}}),(0,I.jsx)(`span`,{className:`picker-skeleton-chip`,style:{width:116}}),(0,I.jsx)(`span`,{className:`picker-skeleton-chip`,style:{width:72}})]})]})]})}function ka(e){let t=/^\[Editing (.+)\]$/,n=/^\[Reading (.+)\]$/,r=new Set;for(let n of e){let e=t.exec(n.trim());if(e)for(let t of e[1].split(`, `))r.add(t)}let i=[];for(let t of e){let e=n.exec(t.trim());if(e){let t=e[1].split(`, `).filter(e=>!r.has(e));if(t.length===0)continue;i.push(`[Reading ${t.join(`, `)}]`);continue}i.push(t)}return i}function Aa(e){let t=/^\[([A-Za-z]+)\s+(.+)\]$/,n=[];for(let r of e){let e=t.exec(r.trim());if(e){let r=n.length?t.exec(n[n.length-1].trim()):null;if(r&&r[1]===e[1]){r[2].split(`, `).includes(e[2])||(n[n.length-1]=`[${e[1]} ${r[2]}, ${e[2]}]`);continue}}n.push(r)}return n}function ja(e){let t=g.useRef(null);return g.useLayoutEffect(()=>{let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[e.lines]),(0,I.jsx)(`div`,{className:`task-feed`,ref:t,onClick:e=>e.stopPropagation(),children:Aa(ka(e.lines)).map((e,t)=>{let n=/^\[(.+)\]$/.exec(e.trim());return n?(0,I.jsx)(`div`,{className:`task-feed-tool`,children:n[1]},t):(0,I.jsx)(`div`,{className:`task-feed-msg`,dangerouslySetInnerHTML:ha(e)},t)})})}function Ma(e){let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n>0?`${n}m ${r}s`:`${r}s`}function Na(e){let{task:t,onAck:n}=e,r=e.onToggle!==void 0,[i,a]=g.useState(!1),o=r?e.open===!0:i,s=()=>{r?e.onToggle?.():a(e=>!e)},[c,l]=g.useState(()=>Date.now());g.useEffect(()=>{if(t.status!==`running`)return;let e=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(e)},[t.status]);let u=t.startedAt?Date.parse(t.startedAt):null,d=t.finishedAt?Date.parse(t.finishedAt):null,f=Cr.includes(t.status),p=t.status===`done`?100:f?t.progress:Math.min(t.progress,95),m=t.notes.trim()||t.resultSummary?.trim()||``,h=pa(t),_=t.status===`running`?t.phase?.trim()||da[t.avatar??``]||`Working`:t.status===`waiting`?`Queued`:t.status===`blocked`?`Blocked`:t.status===`done`?t.suspectNoChanges?`Done — No changes`:`Done`:t.status===`failed`?`Failed`:t.status===`interrupted`?`Interrupted`:t.status;return(0,I.jsx)(`div`,{className:`task${o?` open`:``}`,onClick:s,children:(0,I.jsxs)(`div`,{className:`task-row`,children:[(0,I.jsx)(`div`,{className:`pie`,style:{background:`conic-gradient(#fff ${p*3.6}deg, #333 0deg)`},children:(0,I.jsx)(`div`,{className:`avatar`,style:{background:h.color},children:(0,I.jsx)(`span`,{className:`avatar-icon-wrap`,"aria-hidden":`true`,children:h.icon})})}),(0,I.jsxs)(`div`,{className:`task-meta`,children:[(0,I.jsxs)(`div`,{className:`task-head`,children:[(0,I.jsxs)(`div`,{className:`task-text`,children:[(0,I.jsxs)(`div`,{className:`task-name`,children:[(0,I.jsx)(`span`,{className:`tn`,children:t.title}),`:`,` `,t.status===`done`&&t.suspectNoChanges?(0,I.jsx)(`span`,{className:`stage-caution`,children:_}):_]}),(0,I.jsx)(`div`,{className:`task-sub`,children:t.status===`running`&&u!=null?Ma(c-u):f&&u!=null&&d!=null?(0,I.jsxs)(I.Fragment,{children:[`Worked for `,Ma(d-u)]}):null})]}),f?(0,I.jsx)(`button`,{className:`task-dismiss`,type:`button`,onClick:e=>{e.stopPropagation(),n(t.id,!1)},children:`Dismiss`}):null]}),(0,I.jsxs)(`div`,{className:`task-body`,children:[o&&t.status===`running`&&e.feed&&e.feed.length>0?(0,I.jsx)(ja,{lines:e.feed}):null,o&&t.status!==`running`&&m?(0,I.jsx)(`div`,{className:`task-notes`,dangerouslySetInnerHTML:ha(m)}):null,o?(0,I.jsx)(Pa,{frames:t.playtestFrames}):null]})]})]})})}function Pa(e){let t=e.frames??[];return t.length===0?null:(0,I.jsxs)(`div`,{className:`task-playtest-frames`,children:[(0,I.jsxs)(`div`,{className:`task-playtest-frames-label`,children:[`Playtest frames (`,t.length,`)`]}),(0,I.jsx)(`div`,{className:`task-playtest-frames-row`,children:t.map(e=>(0,I.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:(0,I.jsx)(`img`,{className:`task-playtest-frame`,src:e,alt:`playtest frame`})},e))})]})}function Fa(e){return e.filter(e=>!(e.acknowledged&&Cr.includes(e.status)))}function Ia(e){let t=Fa(e.tasks);return t.length===0?null:(0,I.jsx)(`div`,{id:`task-board`,className:`task-stack`,children:t.map(t=>(0,I.jsx)(Na,{task:t,feed:e.feeds[t.id],onAck:e.onAck},t.id))})}function La(e){let{msg:t,onPickerSubmit:n,fading:r,interactive:i=!1}=e,a=r?` fading`:``;if(t.role===`log`)return(0,I.jsx)(`div`,{className:`msg toolline`,children:t.text});if(t.role===`user`)return(0,I.jsxs)(`div`,{className:`msg user`+a,children:[(t.attachments??[]).map(e=>(0,I.jsx)(`img`,{className:`msg-image`,src:`${sa}${e}`,alt:``},e)),t.text?(0,I.jsx)(`span`,{children:t.text}):null]});let o=t.status===`streaming`,s=aa(t.text),c=s.some(e=>e.kind===`ask`||e.kind===`ask-pending`||e.kind===`md`&&e.text.trim()!==``);if(!o&&!c)return null;let l=!o&&!t.pickerAnswers&&i,u=-1;s.forEach((e,t)=>{e.kind===`md`&&e.text.trim()!==``&&(u=t)});let d=s.some(e=>e.kind===`ask`||e.kind===`ask-pending`),f=o&&u===-1&&!d,p=!!(t.thinking&&t.thinking.trim());return(0,I.jsxs)(`div`,{className:`assistant-turn`+a,children:[s.map((e,r)=>{if(e.kind===`ask-pending`)return(0,I.jsx)(Oa,{},r);if(e.kind===`ask`)return(0,I.jsx)(Da,{spec:e.spec,interactive:l,answers:t.pickerAnswers,onSubmit:(e,r)=>n(t,e,r)},r);if(!e.text.trim())return null;let i=[`msg`,`assistant`,`md`];return o&&r===u&&i.push(`streaming`),t.status===`error`&&i.push(`errbubble`),(0,I.jsx)(`div`,{className:i.join(` `),dangerouslySetInnerHTML:ha(e.text)},r)}),p?(0,I.jsxs)(`details`,{className:`msg-thinking`,children:[(0,I.jsxs)(`summary`,{"aria-label":t.activity??`Thinking`,children:[(0,I.jsx)(`span`,{className:`thinking-caret`,"aria-hidden":`true`}),f?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`thinking-dots`,"aria-hidden":`true`,children:[(0,I.jsx)(`i`,{}),(0,I.jsx)(`i`,{}),(0,I.jsx)(`i`,{})]}),(0,I.jsx)(`span`,{className:`thinking-label`,children:t.activity??`Thinking`})]}):(0,I.jsx)(`span`,{className:`thinking-label`,children:ma(t.thinkingMs)})]}),(0,I.jsx)(`div`,{className:`msg-thinking-body`,dangerouslySetInnerHTML:ha(t.thinking??``)})]}):f?(0,I.jsxs)(`div`,{className:`msg-thinking`,"aria-label":t.activity??`thinking`,children:[(0,I.jsxs)(`span`,{className:`thinking-dots`,"aria-hidden":`true`,children:[(0,I.jsx)(`i`,{}),(0,I.jsx)(`i`,{}),(0,I.jsx)(`i`,{})]}),t.activity?(0,I.jsx)(`span`,{className:`thinking-label`,children:t.activity}):null]}):o&&t.activity?(0,I.jsxs)(`div`,{className:`msg-activity`,children:[t.activity,`...`]}):null,t.errorDetail&&!o?(0,I.jsxs)(`details`,{className:`msg-error-detail`,children:[(0,I.jsx)(`summary`,{children:`Details`}),(0,I.jsx)(`pre`,{children:t.errorDetail})]}):null,t.interrupted?(0,I.jsx)(`div`,{className:`msg-interrupted`,children:`interrupted by your next message`}):null]})}function Ra(e){let t=g.useRef(null),n=g.useRef(null),r=g.useRef(0),i=g.useRef(!0),a=g.useRef(0),[o,s]=g.useState(!1),c=g.useCallback(()=>{let e=t.current;e&&(e.scrollHeight-e.clientHeight-e.scrollTop<=1||(a.current=typeof performance<`u`?performance.now():Date.now(),e.scrollTop=e.scrollHeight))},[]),l=g.useCallback(()=>{c();let e=t.current;e&&e.clientHeight>0&&s(!0)},[c]);g.useLayoutEffect(()=>{if(!i.current)return;l();let e=requestAnimationFrame(l),t=window.setTimeout(l,250),n=window.setTimeout(()=>s(!0),500);return()=>{cancelAnimationFrame(e),clearTimeout(t),clearTimeout(n)}},[e.messages,l]),g.useEffect(()=>{let e=t.current;if(!e)return;let a=new ResizeObserver(()=>{i.current?l():e.scrollTop=e.scrollHeight-e.clientHeight-r.current});return a.observe(e),n.current&&a.observe(n.current,{box:`border-box`}),()=>a.disconnect()},[l]);let u=()=>{let e=t.current;e&&((typeof performance<`u`?performance.now():Date.now())-a.current<200||(r.current=e.scrollHeight-e.scrollTop-e.clientHeight,i.current=r.current<48))},d=Ga(e.messages);return(0,I.jsx)(`div`,{id:`chat-messages`,className:`chat-scroll`,ref:t,onScroll:u,children:(0,I.jsxs)(`div`,{className:`chat-thread`+(o?` ready`:``),ref:n,children:[e.messages.length===0?(0,I.jsx)(`div`,{id:`chat-empty`,children:`Tell the agent what you want to make.`}):null,e.messages.map(t=>(0,I.jsx)(La,{msg:t,interactive:t.id===d,onPickerSubmit:e.onPickerSubmit},t.id))]})})}var za=550,Ba=4;function Va(e){let t=1500+e.trim().length/18*1e3;return Math.min(12e3,Math.max(2500,t))}function Ha(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Ua(e){return e.role===`user`?(e.text??``).trim()!==``||(e.attachments?.length??0)>0:e.role===`assistant`?e.status===`streaming`?!0:aa(e.text).some(e=>e.kind===`ask`||e.kind===`ask-pending`||e.kind===`md`&&e.text.trim()!==``):!1}function Wa(e){return e.role!==`assistant`||e.pickerAnswers?!1:aa(e.text).some(e=>e.kind===`ask`)}function Ga(e){for(let t=e.length-1;t>=0;t--)if(Wa(e[t]))return e[t].id;return null}function Ka(e,t){let n=e.map((e,t)=>({msg:e,idx:t})).filter(e=>Ua(e.msg)),r=n.filter(e=>e.idx>=t),i=new Set(r.slice(-Ba).map(e=>e.idx));return n.filter(e=>i.has(e.idx)||Wa(e.msg))}function qa(e){let{messages:t,running:n,composerActive:r,booted:i,onPickerSubmit:a}=e,o=g.useRef(null),s=g.useRef(null);s.current===null&&i&&(s.current=t.length);let c=s.current??t.length,[l,u]=g.useState(!1),[d,f]=g.useState(()=>new Set),[p,m]=g.useState(()=>new Set),h=g.useRef(new Map),_=Ka(t,c),v=_.filter(e=>Wa(e.msg)||!p.has(e.msg.id)),y=l||r||n,b=g.useCallback(e=>{if(Ha()){h.current.delete(e),m(t=>new Set(t).add(e));return}f(t=>new Set(t).add(e)),h.current.set(e,setTimeout(()=>{h.current.delete(e),m(t=>new Set(t).add(e)),f(t=>{let n=new Set(t);return n.delete(e),n})},za))},[]),x=t.length-1,S=_.map(e=>e.msg.id).join(`,`),C=_.filter(e=>e.msg.role===`assistant`?!(e.idx===x&&e.msg.status===`streaming`):!0).map(e=>e.msg.id).join(`,`),w=_.filter(e=>Wa(e.msg)).map(e=>e.msg.id).join(`,`);g.useEffect(()=>{let e=Ka(t,c),n=new Set(e.map(e=>e.msg.id));for(let e of[...h.current.keys()])n.has(e)||(clearTimeout(h.current.get(e)),h.current.delete(e));if(y){for(let e of h.current.values())clearTimeout(e);h.current.clear(),f(e=>e.size?new Set:e);return}let r=t.length-1;for(let t of e)Wa(t.msg)||p.has(t.msg.id)||d.has(t.msg.id)||h.current.has(t.msg.id)||(t.msg.role!==`assistant`||!(t.idx===r&&t.msg.status===`streaming`))&&h.current.set(t.msg.id,setTimeout(()=>b(t.msg.id),Va(t.msg.text??``)))},[S,C,w,y,p,d,n,b]),g.useEffect(()=>()=>{for(let e of h.current.values())clearTimeout(e);h.current.clear()},[]),g.useEffect(()=>{let e=o.current;e&&(e.scrollTop=e.scrollHeight)},[t.length,n,v.length]);let ee=Ga(t);return(0,I.jsx)(`div`,{id:`chat-messages`,className:`chat-scroll`,ref:o,children:(0,I.jsx)(`div`,{className:`chat-bubbles`,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),children:v.map(e=>(0,I.jsx)(La,{msg:e.msg,fading:d.has(e.msg.id),interactive:Wa(e.msg)&&e.msg.id===ee,onPickerSubmit:a},e.msg.id))})})}function Ja(e,t){for(let n of Array.from(e)){if(!n.type.startsWith(`image/`))continue;let e=new FileReader;e.onload=()=>{typeof e.result==`string`&&t({name:n.name,dataUrl:e.result})},e.readAsDataURL(n)}}function Ya(e){return e.pending.length===0?null:(0,I.jsx)(`div`,{id:`chat-pending`,children:e.pending.map((t,n)=>(0,I.jsx)(`img`,{src:t.dataUrl,alt:t.name,title:`remove`,onClick:()=>e.onRemove(n)},`${t.name}-${n}`))})}function Xa(e){return e.queued.length===0?null:(0,I.jsx)(`div`,{className:`chat-queue`,onMouseDown:e=>e.preventDefault(),children:e.queued.map((t,n)=>(0,I.jsxs)(`div`,{className:`queue-row`,children:[(0,I.jsx)(`span`,{className:`queue-snippet`,children:t.length>60?`${t.slice(0,60)}\u2026`:t}),(0,I.jsx)(`button`,{className:`queue-send-now`,type:`button`,tabIndex:-1,title:`Send now — interrupts the turn`,onClick:e.onInterrupt,children:`send now`}),(0,I.jsx)(`button`,{className:`queue-remove`,type:`button`,tabIndex:-1,title:`Remove from queue`,onClick:()=>e.onCancelQueued(n),children:`✕`})]},n))})}function Za(e){let{running:t,queued:n,floating:r,expanded:i,revealed:a}=e,[o,s]=g.useState(``),[c,l]=g.useState(!1),[u,d]=g.useState([]),[f,p]=g.useState(!1);g.useEffect(()=>{t||p(!1)},[t]);let m=g.useRef(null),h=g.useRef(null),_=r&&!i,v=g.useCallback(()=>{let e=m.current;if(!e)return;e.style.height=`auto`;let t=Number.parseFloat(window.getComputedStyle(e).lineHeight),n=Number.isFinite(t)?Math.ceil(t):21,r=o.length===0?n:Math.min(e.scrollHeight,120);e.style.height=r>0?`${r}px`:``},[o]);g.useLayoutEffect(v,[v]),g.useLayoutEffect(()=>{_||(v(),requestAnimationFrame(()=>{v(),r&&i&&m.current?.focus()}))},[v,_,r,i]),g.useLayoutEffect(()=>{let e=h.current,t=e?.closest(`.shell-root`)??null;if(!e||!t)return;if(r){t.style.removeProperty(`--composer-reserve`);return}let n=()=>{t.style.setProperty(`--composer-reserve`,`${e.offsetHeight+7}px`)};n();let i=new ResizeObserver(n);return i.observe(e),()=>{i.disconnect(),t.style.removeProperty(`--composer-reserve`)}},[r]);let y=e=>{d(t=>t.length>=6?t:[...t,e])},b=()=>{let t=o.trim();!t&&u.length===0||(e.onSend(t,u),s(``),d([]))},x=o.trim().length>0||u.length>0,S=()=>{_&&e.onExpand()},C=()=>{r&&setTimeout(()=>{h.current?.contains(document.activeElement)||o.trim().length===0&&u.length===0&&e.onCollapse()},0)},w=t&&!x;return(0,I.jsxs)(g.Fragment,{children:[(0,I.jsx)(Ya,{pending:u,onRemove:e=>d(t=>t.filter((t,n)=>n!==e))}),(0,I.jsxs)(`div`,{className:`chat-input`+(_?` collapsed`:``)+(a?` revealed`:``),ref:h,onMouseEnter:r?e.onHoverEnter:void 0,onMouseLeave:r?e.onHoverLeave:void 0,children:[(0,I.jsx)(Xa,{queued:n,onInterrupt:e.onInterrupt,onCancelQueued:e.onCancelQueued}),(0,I.jsxs)(`div`,{className:`ta`,onClick:S,children:[(0,I.jsx)(`span`,{className:`collapse-icon`,"aria-hidden":`true`,children:ba}),(0,I.jsx)(`textarea`,{id:`chat-input`,className:`ta-text`,ref:m,rows:1,placeholder:t?`Queue a message…`:`Message the conductor`,value:o,onBlur:C,onChange:e=>s(e.target.value),onPaste:e=>{let t=e.clipboardData?.files;t&&t.length>0&&(e.preventDefault(),Ja(t,y))},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),b())}}),(0,I.jsxs)(`div`,{className:`ta-bottom`,onMouseDown:e=>e.preventDefault(),children:[(0,I.jsxs)(`div`,{className:`composer-settings`,children:[(0,I.jsxs)(`button`,{className:`composer-pill`+(c?` active`:``),type:`button`,tabIndex:-1,title:`Settings`,"aria-label":`Settings`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:()=>l(e=>!e),children:[(0,I.jsx)(`span`,{className:`composer-pill-label`,children:`Settings`}),va]}),c?(0,I.jsx)(Ea,{settings:e.settings,onSetSetting:e.onSetSetting,onClose:()=>l(!1)}):null]}),(0,I.jsx)(`button`,{id:`chat-send`,className:`send${w?` stop`:``}`,type:`button`,tabIndex:-1,title:w?f?`Stopping…`:`Stop`:`Send`,disabled:!w&&!x||w&&f,onClick:()=>{w?(p(!0),e.onInterrupt()):b()},children:w?_a:ga})]})]})]})]})}function Qa(e){let t=Fa(e.tasks);return t.length===0?null:(0,I.jsx)(`div`,{className:`conductor-gutter`,onMouseEnter:e.onHoverEnter,onMouseLeave:e.onHoverLeave,children:(0,I.jsx)(`div`,{className:`task-stack`,children:t.map(t=>(0,I.jsx)(Na,{task:t,feed:e.feeds[t.id],onAck:e.onAck,open:e.openTasks.has(t.id),onToggle:()=>e.onToggleTask(t.id)},t.id))})})}function $a(e){let t=g.useRef(null),n=g.useCallback(()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},[]),r=g.useCallback(()=>{n(),e(!0)},[n,e]),i=g.useCallback(()=>{n(),t.current=window.setTimeout(()=>e(!1),300)},[n,e]);return g.useEffect(()=>()=>n(),[n]),{revealEnter:r,revealLeave:i}}var eo=100;function to(e,t,n){return g.useCallback(r=>{r.preventDefault();let i=r.currentTarget,a=r.pointerId;try{i.setPointerCapture(a)}catch{}let o=new AbortController,s=()=>{o.abort();try{i.releasePointerCapture(a)}catch{}document.body.classList.remove(`conductor-resizing`)};i.addEventListener(`pointermove`,r=>{if(r.clientX<t){s(),n();return}e(r.clientX)},{signal:o.signal}),i.addEventListener(`pointerup`,s,{signal:o.signal}),i.addEventListener(`pointercancel`,s,{signal:o.signal}),document.body.classList.add(`conductor-resizing`)},[e,t,n])}function no(e){let{floating:t}=e;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`conductor-avatar`+(e.hasActiveTasks?` active`:``),type:`button`,tabIndex:-1,title:t?`Dock the chat panel`:`Float the chat panel`,"aria-label":`Toggle chat layout`,onClick:()=>e.setFloating(!t),onMouseEnter:t?e.onHoverEnter:void 0,onMouseLeave:t?e.onHoverLeave:void 0,children:ya}),t?null:(0,I.jsx)(`div`,{className:`conductor-resize`,role:`separator`,"aria-label":`Resize chat panel`,"aria-orientation":`vertical`,"aria-valuenow":e.columnWidth,"aria-valuemin":e.minWidth,"aria-valuemax":e.maxWidth,onPointerDown:e.onStartResize})]})}function ro(e){let{agent:t,floating:n,setFloating:r,columnWidth:i,setColumnWidth:a,minWidth:o,maxWidth:s}=e,{messages:c,tasks:l,feeds:u,settings:d,running:f,queued:p,booted:m}=t,[h,_]=g.useState(!1),[v,y]=g.useState(!1),[b,x]=g.useState(!1),[S,C]=g.useState(()=>new Set);g.useEffect(()=>{n&&(_(!1),y(!1),x(!1),C(new Set))},[n]);let w=b||S.size>0,{revealEnter:ee,revealLeave:te}=$a(y),T=g.useCallback(e=>{C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ne=g.useCallback(()=>{_(!0),C(new Set)},[]),E=g.useCallback(()=>r(!0),[r]),D=to(a,o-eo,E),O=(e,n,r)=>{t.submitPicker(e.id,n,r)},re=l.some(e=>e.status===`running`);return(0,I.jsxs)(`div`,{id:`chat-host`,className:[n&&w?`rail-engaged`:``,n&&h?`chat-expanded`:``].filter(Boolean).join(` `),children:[n?(0,I.jsx)(qa,{messages:c,running:f,composerActive:h,booted:m,onPickerSubmit:O}):(0,I.jsxs)(`div`,{className:`conductor-inset`,children:[(0,I.jsx)(Ia,{tasks:l,feeds:u,onAck:t.ackTask}),Fa(l).length>0?(0,I.jsx)(`div`,{className:`chat-divider`,"aria-hidden":`true`}):null,(0,I.jsx)(Ra,{messages:c,onPickerSubmit:O})]}),(0,I.jsx)(Za,{running:f,queued:p,onSend:t.sendUserMessage,onInterrupt:t.interrupt,onCancelQueued:t.cancelQueued,floating:n,expanded:h,revealed:v,onExpand:ne,onCollapse:()=>_(!1),onHoverEnter:ee,onHoverLeave:te,settings:d,onSetSetting:t.setSetting}),n?(0,I.jsx)(Qa,{tasks:l,feeds:u,openTasks:S,onToggleTask:T,onAck:t.ackTask,onHoverEnter:()=>x(!0),onHoverLeave:()=>x(!1)}):null,(0,I.jsx)(no,{floating:n,setFloating:r,hasActiveTasks:re,onHoverEnter:ee,onHoverLeave:te,columnWidth:i,minWidth:o,maxWidth:s,onStartResize:D})]})}var io=Object.defineProperty,ao=Object.getOwnPropertyDescriptor,oo=(e,t)=>{for(var n in t)io(e,n,{get:t[n],enumerable:!0})},so=(e,t,n,r)=>{for(var i=r>1?void 0:r?ao(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&io(t,n,i),i},L=(e,t)=>(n,r)=>t(n,r,e),co=`Terminal input`,lo={get:()=>co,set:e=>co=e},uo=`Too much output to announce, navigate to rows manually to read`,fo={get:()=>uo,set:e=>uo=e};function po(e){return e.replace(/\r?\n/g,`\r`)}function mo(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function ho(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function go(e,t,n,r){e.stopPropagation(),e.clipboardData&&_o(e.clipboardData.getData(`text/plain`),t,n,r)}function _o(e,t,n,r){e=po(e),e=mo(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function vo(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function yo(e,t,n,r,i){vo(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function bo(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function xo(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var So=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},Co=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},wo=``,To=` `,Eo=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Do}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Do=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Oo=class e extends Eo{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Do,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?bo(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ko=`di$target`,Ao=`di$dependencies`,jo=new Map;function Mo(e){return e[Ao]||[]}function No(e){if(jo.has(e))return jo.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Po(t,e,r)};return t._id=e,jo.set(e,t),t}function Po(e,t,n){t[ko]===t?t[Ao].push({id:e,index:n}):(t[Ao]=[{id:e,index:n}],t[ko]=t)}var Fo=No(`BufferService`),Io=No(`CoreMouseService`),Lo=No(`CoreService`),Ro=No(`CharsetService`),zo=No(`InstantiationService`),Bo=No(`LogService`),Vo=No(`OptionsService`),Ho=No(`OscLinkService`),Uo=No(`UnicodeService`),Wo=No(`DecorationService`),Go=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new Oo,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+(!l&&t===o-1?1:0),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Ko(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Go=so([L(0,Fo),L(1,Vo),L(2,Ho)],Go);function Ko(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
73
|
+
`)}`:``}var sa=`/__castle/agent/attachments/`,ca={lightbulb:{w:352,d:`M96.06 454.35c.01 6.29 1.87 12.45 5.36 17.69l17.09 25.69a31.99 31.99 0 0 0 26.64 14.28h61.71a31.99 31.99 0 0 0 26.64-14.28l17.09-25.69a31.989 31.989 0 0 0 5.36-17.69l.04-38.35H96.01l.05 38.35zM0 176c0 44.37 16.45 84.85 43.56 115.78 16.52 18.85 42.36 58.23 52.21 91.45.04.26.07.52.11.78h160.24c.04-.26.07-.51.11-.78 9.85-33.22 35.69-72.6 52.21-91.45C335.55 260.85 352 220.37 352 176 352 78.61 272.91-.3 175.45 0 73.44.31 0 82.97 0 176zm176-80c-44.11 0-80 35.89-80 80 0 8.84-7.16 16-16 16s-16-7.16-16-16c0-61.76 50.24-112 112-112 8.84 0 16 7.16 16 16s-7.16 16-16 16z`},book:{w:448,d:`M448 360V24c0-13.3-10.7-24-24-24H96C43 0 0 43 0 96v320c0 53 43 96 96 96h328c13.3 0 24-10.7 24-24v-16c0-7.5-3.5-14.3-8.9-18.7-4.2-15.4-4.2-59.3 0-74.7 5.4-4.3 8.9-11.1 8.9-18.6zM128 134c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm0 64c0-3.3 2.7-6 6-6h212c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H134c-3.3 0-6-2.7-6-6v-20zm253.4 250H96c-17.7 0-32-14.3-32-32 0-17.6 14.4-32 32-32h285.4c-1.9 17.1-1.9 46.9 0 64z`},hammer:{w:576,d:`M571.31 193.94l-22.63-22.63c-6.25-6.25-16.38-6.25-22.63 0l-11.31 11.31-28.9-28.9c5.63-21.31.36-44.9-16.35-61.61l-45.25-45.25c-62.48-62.48-163.79-62.48-226.28 0l90.51 45.25v18.75c0 16.97 6.74 33.25 18.75 45.25l49.14 49.14c16.71 16.71 40.3 21.98 61.61 16.35l28.9 28.9-11.31 11.31c-6.25 6.25-6.25 16.38 0 22.63l22.63 22.63c6.25 6.25 16.38 6.25 22.63 0l90.51-90.51c6.23-6.24 6.23-16.37-.02-22.62zm-286.72-15.2c-3.7-3.7-6.84-7.79-9.85-11.95L19.64 404.96c-25.57 23.88-26.26 64.19-1.53 88.93s65.05 24.05 88.93-1.53l238.13-255.07c-3.96-2.91-7.9-5.87-11.44-9.41l-49.14-49.14z`},pencil:{w:512,d:`M497.9 142.1l-46.1 46.1c-4.7 4.7-12.3 4.7-17 0l-111-111c-4.7-4.7-4.7-12.3 0-17l46.1-46.1c18.7-18.7 49.1-18.7 67.9 0l60.1 60.1c18.8 18.7 18.8 49.1 0 67.9zM284.2 99.8L21.6 362.4.4 483.9c-2.9 16.4 11.4 30.6 27.8 27.8l121.5-21.3 262.6-262.6c4.7-4.7 4.7-12.3 0-17l-111-111c-4.8-4.7-12.4-4.7-17.1 0zM124.1 339.9c-5.5-5.5-5.5-14.3 0-19.8l154-154c5.5-5.5 14.3-5.5 19.8 0s5.5 14.3 0 19.8l-154 154c-5.5 5.5-14.3 5.5-19.8 0zM88 424h48v36.3l-64.5 11.3-31.1-31.1L51.7 376H88v48z`},gamepad:{w:640,d:`M480.07 96H160a160 160 0 1 0 114.24 272h91.52A160 160 0 1 0 480.07 96zM248 268a12 12 0 0 1-12 12h-52v52a12 12 0 0 1-12 12h-24a12 12 0 0 1-12-12v-52H84a12 12 0 0 1-12-12v-24a12 12 0 0 1 12-12h52v-52a12 12 0 0 1 12-12h24a12 12 0 0 1 12 12v52h52a12 12 0 0 1 12 12zm216 76a40 40 0 1 1 40-40 40 40 0 0 1-40 40zm64-96a40 40 0 1 1 40-40 40 40 0 0 1-40 40z`},check:{w:512,d:`M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z`},times:{w:352,d:`M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z`},stop:{w:448,d:`M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z`}};function la({glyph:e}){return(0,I.jsx)(`svg`,{className:`avatar-icon`,viewBox:`0 0 ${e.w} 512`,fill:`currentColor`,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{d:e.d})})}var ua={thinking:(0,I.jsx)(la,{glyph:ca.lightbulb}),reading:(0,I.jsx)(la,{glyph:ca.book}),building:(0,I.jsx)(la,{glyph:ca.hammer}),painting:(0,I.jsx)(la,{glyph:ca.pencil}),playing:(0,I.jsx)(la,{glyph:ca.gamepad})},da={thinking:`Thinking`,reading:`Reading files`,building:`Editing logic`,painting:`Editing art`,playing:`Playtesting`},fa={thinking:`#FFC826`,reading:`#FFC826`,building:`#FFEB57`,painting:`#FFEB57`,playing:`#D3FC7E`};function pa(e){if(e.status===`done`)return{icon:(0,I.jsx)(la,{glyph:ca.check}),color:e.suspectNoChanges?`#F5A623`:`#5AC54F`};if(e.status===`failed`)return{icon:(0,I.jsx)(la,{glyph:ca.times}),color:`#F5545D`};if(e.status===`interrupted`)return{icon:(0,I.jsx)(la,{glyph:ca.stop}),color:`#B4B4B4`};if(e.status===`blocked`)return{icon:(0,I.jsx)(la,{glyph:ca.stop}),color:`#F5A623`};let t=e.avatar&&ua[e.avatar]?e.avatar:`thinking`;return{icon:ua[t],color:fa[t]}}function ma(e){let t=Math.max(1,Math.round((e??0)/1e3));if(t<60)return`Thought for ${t}s`;let n=Math.floor(t/60),r=t%60;return r===0?`Thought for ${n}m`:`Thought for ${n}m ${r}s`}function ha(e){try{return{__html:F.parse(e,{breaks:!0,async:!1})}}catch{return{__html:``}}}var ga=(0,I.jsx)(`svg`,{viewBox:`0 0 512 512`,width:12,height:12,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{d:`M470.3 271.15 43.16 447.31a7.83 7.83 0 0 1-11.16-7V327a8 8 0 0 1 6.51-7.86l247.62-47c17.36-3.29 17.36-28.15 0-31.44l-247.63-47a8 8 0 0 1-6.5-7.85V72.59c0-5.74 5.88-10.26 11.16-8L470.3 241.76a16 16 0 0 1 0 29.39`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:32})}),_a=(0,I.jsx)(`svg`,{viewBox:`0 0 512 512`,width:12,height:12,"aria-hidden":`true`,children:(0,I.jsx)(`rect`,{x:128,y:128,width:256,height:256,rx:36,fill:`currentColor`})}),va=(0,I.jsx)(`svg`,{viewBox:`0 0 24 24`,width:10,height:10,fill:`none`,stroke:`currentColor`,strokeWidth:2.4,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:`mode-caret`,children:(0,I.jsx)(`path`,{d:`M6 9l6 6 6-6`})}),ya=(0,I.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:18,height:18,fill:`none`,stroke:`currentColor`,strokeWidth:1.8,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,I.jsx)(`rect`,{x:3,y:4,width:18,height:16,rx:2}),(0,I.jsx)(`line`,{x1:14,y1:4,x2:14,y2:20})]}),ba=(0,I.jsx)(`svg`,{viewBox:`0 0 512 512`,width:20,height:20,"aria-hidden":`true`,children:(0,I.jsx)(`path`,{d:`M408 64H104a56.16 56.16 0 0 0-56 56v192a56.16 56.16 0 0 0 56 56h40v80l93.72-78.14a8 8 0 0 1 5.13-1.86H408a56.16 56.16 0 0 0 56-56V120a56.16 56.16 0 0 0-56-56z`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:32})}),xa=[{value:`claude`,label:`Claude`},{value:`cursor`,label:`Cursor`},{value:`smith`,label:`Smith`}],Sa=[{value:`opus`,label:`Opus`},{value:`sonnet`,label:`Sonnet`},{value:`fable`,label:`Fable`},{value:`openrouter`,label:`OpenRouter`}];function Ca(e,t){return e===`smith`||e===`claude`&&t===`openrouter`}var wa=[{type:`enum`,key:`router`,label:`Conductor`,options:xa},{type:`enum`,key:`routerClaudeModel`,label:`Model`,options:Sa,showWhen:e=>e.router===`claude`},{type:`text`,key:`routerOpenrouterModel`,label:`OpenRouter model`,placeholder:`openai/gpt-5.6-sol`,showWhen:e=>Ca(e.router,e.routerClaudeModel)},{type:`enum`,key:`tasks`,label:`Tasks`,options:xa},{type:`enum`,key:`tasksClaudeModel`,label:`Model`,options:Sa,showWhen:e=>e.tasks===`claude`},{type:`text`,key:`tasksOpenrouterModel`,label:`OpenRouter model`,placeholder:`openai/gpt-5.6-terra`,showWhen:e=>Ca(e.tasks,e.tasksClaudeModel)}];function Ta(e){let{label:t,placeholder:n,value:r,onCommit:i}=e,[a,o]=g.useState(r);g.useEffect(()=>o(r),[r]);let s=()=>{let e=a.trim();e&&e!==r?i(e):o(r)};return(0,I.jsxs)(`div`,{className:`settings-row`,children:[(0,I.jsx)(`span`,{className:`settings-label`,children:t}),(0,I.jsx)(`input`,{type:`text`,className:`settings-text`,value:a,placeholder:n,onChange:e=>o(e.target.value),onBlur:s,onKeyDown:e=>{e.key===`Enter`&&(s(),e.target.blur())}})]})}function Ea(e){let{settings:t,onSetSetting:n,onClose:r}=e,i=g.useRef(null);return g.useEffect(()=>{let e=e=>{i.current&&!i.current.contains(e.target)&&r()},t=e=>{e.key===`Escape`&&r()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]),(0,I.jsx)(`div`,{className:`settings-popover`,ref:i,onMouseDown:e=>e.stopPropagation(),children:wa.filter(e=>!e.showWhen||e.showWhen(t)).map(e=>{if(e.type===`text`)return(0,I.jsx)(Ta,{label:e.label,placeholder:e.placeholder,value:t[e.key]??``,onCommit:t=>n(e.key,t)},e.key);let r=t[e.key];return(0,I.jsxs)(`div`,{className:`settings-row`,children:[(0,I.jsx)(`span`,{className:`settings-label`,children:e.label}),(0,I.jsx)(`div`,{className:`settings-seg`,children:e.options.map(t=>(0,I.jsx)(`button`,{type:`button`,tabIndex:-1,className:`settings-opt`+(r===t.value?` active`:``),onClick:()=>n(e.key,t.value),children:t.label},t.value))})]},e.key)})})}function Da(e){let{spec:t,interactive:n,answers:r,onSubmit:i}=e,[a,o]=g.useState({}),s=n?a:r??{},c=(e,t,r)=>{n&&o(n=>{let i=n[e]??[];if(r){let r=i.includes(t)?i.filter(e=>e!==t):[...i,t];return{...n,[e]:r}}return{...n,[e]:i[0]===t?[]:[t]}})};return(0,I.jsxs)(`div`,{className:`picker${n?``:` picker-locked`}`,children:[t.questions.map(e=>(0,I.jsxs)(`fieldset`,{className:`picker-q`,disabled:!n,children:[(0,I.jsx)(`legend`,{className:`picker-q-label`,children:e.q}),(0,I.jsx)(`div`,{className:`picker-options`,children:e.options.map(t=>{let r=(s[e.id]??[]).includes(t);return(0,I.jsxs)(`label`,{className:`picker-option${r?` is-checked`:``}`,children:[(0,I.jsx)(`input`,{type:e.multi?`checkbox`:`radio`,name:e.id,checked:r,disabled:!n,onChange:()=>c(e.id,t,e.multi)}),(0,I.jsx)(`span`,{children:t})]},t)})})]},e.id)),n?(0,I.jsx)(`div`,{className:`picker-actions`,children:(0,I.jsx)(`button`,{className:`picker-submit`,type:`button`,onClick:()=>{let e=oa(t,a);e&&i(a,e)},children:`Submit`})}):null]})}function Oa(){return(0,I.jsxs)(`div`,{className:`picker picker-skeleton`,"aria-hidden":`true`,children:[(0,I.jsx)(`span`,{className:`picker-skeleton-hint`,children:`preparing options…`}),(0,I.jsxs)(`div`,{className:`picker-q`,children:[(0,I.jsx)(`div`,{className:`picker-skeleton-line picker-skeleton-label`}),(0,I.jsxs)(`div`,{className:`picker-options`,children:[(0,I.jsx)(`span`,{className:`picker-skeleton-chip`,style:{width:84}}),(0,I.jsx)(`span`,{className:`picker-skeleton-chip`,style:{width:116}}),(0,I.jsx)(`span`,{className:`picker-skeleton-chip`,style:{width:72}})]})]})]})}function ka(e){let t=/^\[Editing (.+)\]$/,n=/^\[Reading (.+)\]$/,r=new Set;for(let n of e){let e=t.exec(n.trim());if(e)for(let t of e[1].split(`, `))r.add(t)}let i=[];for(let t of e){let e=n.exec(t.trim());if(e){let t=e[1].split(`, `).filter(e=>!r.has(e));if(t.length===0)continue;i.push(`[Reading ${t.join(`, `)}]`);continue}i.push(t)}return i}function Aa(e){let t=/^\[([A-Za-z]+)\s+(.+)\]$/,n=[];for(let r of e){let e=t.exec(r.trim());if(e){let r=n.length?t.exec(n[n.length-1].trim()):null;if(r&&r[1]===e[1]){r[2].split(`, `).includes(e[2])||(n[n.length-1]=`[${e[1]} ${r[2]}, ${e[2]}]`);continue}}n.push(r)}return n}function ja(e){let t=g.useRef(null);return g.useLayoutEffect(()=>{let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[e.lines]),(0,I.jsx)(`div`,{className:`task-feed`,ref:t,onClick:e=>e.stopPropagation(),children:Aa(ka(e.lines)).map((e,t)=>{let n=/^\[(.+)\]$/.exec(e.trim());return n?(0,I.jsx)(`div`,{className:`task-feed-tool`,children:n[1]},t):(0,I.jsx)(`div`,{className:`task-feed-msg`,dangerouslySetInnerHTML:ha(e)},t)})})}function Ma(e){let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n>0?`${n}m ${r}s`:`${r}s`}function Na(e){let{task:t,onAck:n}=e,r=e.onToggle!==void 0,[i,a]=g.useState(!1),o=r?e.open===!0:i,s=()=>{r?e.onToggle?.():a(e=>!e)},[c,l]=g.useState(()=>Date.now());g.useEffect(()=>{if(t.status!==`running`)return;let e=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(e)},[t.status]);let u=t.startedAt?Date.parse(t.startedAt):null,d=t.finishedAt?Date.parse(t.finishedAt):null,f=Cr.includes(t.status),p=t.status===`done`?100:f?t.progress:Math.min(t.progress,95),m=t.notes.trim()||t.resultSummary?.trim()||``,h=pa(t),_=t.status===`running`?t.phase?.trim()||da[t.avatar??``]||`Working`:t.status===`waiting`?`Queued`:t.status===`blocked`?`Blocked`:t.status===`done`?t.suspectNoChanges?`Done — No changes`:`Done`:t.status===`failed`?`Failed`:t.status===`interrupted`?`Interrupted`:t.status;return(0,I.jsx)(`div`,{className:`task${o?` open`:``}`,onClick:s,children:(0,I.jsxs)(`div`,{className:`task-row`,children:[(0,I.jsx)(`div`,{className:`pie`,style:{background:`conic-gradient(#fff ${p*3.6}deg, #333 0deg)`},children:(0,I.jsx)(`div`,{className:`avatar`,style:{background:h.color},children:(0,I.jsx)(`span`,{className:`avatar-icon-wrap`,"aria-hidden":`true`,children:h.icon})})}),(0,I.jsxs)(`div`,{className:`task-meta`,children:[(0,I.jsxs)(`div`,{className:`task-head`,children:[(0,I.jsxs)(`div`,{className:`task-text`,children:[(0,I.jsxs)(`div`,{className:`task-name`,children:[(0,I.jsx)(`span`,{className:`tn`,children:t.title}),`:`,` `,t.status===`done`&&t.suspectNoChanges?(0,I.jsx)(`span`,{className:`stage-caution`,children:_}):_]}),(0,I.jsx)(`div`,{className:`task-sub`,children:t.status===`running`&&u!=null?Ma(c-u):f&&u!=null&&d!=null?(0,I.jsxs)(I.Fragment,{children:[`Worked for `,Ma(d-u)]}):null})]}),f?(0,I.jsx)(`button`,{className:`task-dismiss`,type:`button`,onClick:e=>{e.stopPropagation(),n(t.id,!1)},children:`Dismiss`}):null]}),(0,I.jsxs)(`div`,{className:`task-body`,children:[o&&t.status===`running`&&e.feed&&e.feed.length>0?(0,I.jsx)(ja,{lines:e.feed}):null,o&&t.status!==`running`&&m?(0,I.jsx)(`div`,{className:`task-notes`,dangerouslySetInnerHTML:ha(m)}):null,o?(0,I.jsx)(Pa,{frames:t.playtestFrames}):null]})]})]})})}function Pa(e){let t=e.frames??[];return t.length===0?null:(0,I.jsxs)(`div`,{className:`task-playtest-frames`,children:[(0,I.jsxs)(`div`,{className:`task-playtest-frames-label`,children:[`Playtest frames (`,t.length,`)`]}),(0,I.jsx)(`div`,{className:`task-playtest-frames-row`,children:t.map(e=>(0,I.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),children:(0,I.jsx)(`img`,{className:`task-playtest-frame`,src:e,alt:`playtest frame`})},e))})]})}function Fa(e){return e.filter(e=>!(e.acknowledged&&Cr.includes(e.status)))}function Ia(e){let t=Fa(e.tasks);return t.length===0?null:(0,I.jsx)(`div`,{id:`task-board`,className:`task-stack`,children:t.map(t=>(0,I.jsx)(Na,{task:t,feed:e.feeds[t.id],onAck:e.onAck},t.id))})}function La(e){let{msg:t,onPickerSubmit:n,fading:r,interactive:i=!1}=e,a=r?` fading`:``;if(t.role===`log`)return(0,I.jsx)(`div`,{className:`msg toolline`,children:t.text});if(t.role===`user`)return(0,I.jsxs)(`div`,{className:`msg user`+a,children:[(t.attachments??[]).map(e=>(0,I.jsx)(`img`,{className:`msg-image`,src:`${sa}${e}`,alt:``},e)),t.text?(0,I.jsx)(`span`,{children:t.text}):null]});let o=t.status===`streaming`,s=aa(t.text),c=s.some(e=>e.kind===`ask`||e.kind===`ask-pending`||e.kind===`md`&&e.text.trim()!==``);if(!o&&!c)return null;let l=!o&&!t.pickerAnswers&&i,u=-1;s.forEach((e,t)=>{e.kind===`md`&&e.text.trim()!==``&&(u=t)});let d=s.some(e=>e.kind===`ask`||e.kind===`ask-pending`),f=o&&u===-1&&!d,p=!!(t.thinking&&t.thinking.trim());return(0,I.jsxs)(`div`,{className:`assistant-turn`+a,children:[s.map((e,r)=>{if(e.kind===`ask-pending`)return(0,I.jsx)(Oa,{},r);if(e.kind===`ask`)return(0,I.jsx)(Da,{spec:e.spec,interactive:l,answers:t.pickerAnswers,onSubmit:(e,r)=>n(t,e,r)},r);if(!e.text.trim())return null;let i=[`msg`,`assistant`,`md`];return o&&r===u&&i.push(`streaming`),t.status===`error`&&i.push(`errbubble`),(0,I.jsx)(`div`,{className:i.join(` `),dangerouslySetInnerHTML:ha(e.text)},r)}),p?(0,I.jsxs)(`details`,{className:`msg-thinking`,children:[(0,I.jsxs)(`summary`,{"aria-label":t.activity??`Thinking`,children:[(0,I.jsx)(`span`,{className:`thinking-caret`,"aria-hidden":`true`}),f?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`thinking-dots`,"aria-hidden":`true`,children:[(0,I.jsx)(`i`,{}),(0,I.jsx)(`i`,{}),(0,I.jsx)(`i`,{})]}),(0,I.jsx)(`span`,{className:`thinking-label`,children:t.activity??`Thinking`})]}):(0,I.jsx)(`span`,{className:`thinking-label`,children:ma(t.thinkingMs)})]}),(0,I.jsx)(`div`,{className:`msg-thinking-body`,dangerouslySetInnerHTML:ha(t.thinking??``)})]}):f?(0,I.jsxs)(`div`,{className:`msg-thinking`,"aria-label":t.activity??`thinking`,children:[(0,I.jsxs)(`span`,{className:`thinking-dots`,"aria-hidden":`true`,children:[(0,I.jsx)(`i`,{}),(0,I.jsx)(`i`,{}),(0,I.jsx)(`i`,{})]}),t.activity?(0,I.jsx)(`span`,{className:`thinking-label`,children:t.activity}):null]}):o&&t.activity?(0,I.jsxs)(`div`,{className:`msg-activity`,children:[t.activity,`...`]}):null,t.errorDetail&&!o?(0,I.jsxs)(`details`,{className:`msg-error-detail`,children:[(0,I.jsx)(`summary`,{children:`Details`}),(0,I.jsx)(`pre`,{children:t.errorDetail})]}):null,t.interrupted?(0,I.jsx)(`div`,{className:`msg-interrupted`,children:`interrupted by your next message`}):null]})}function Ra(e){let t=g.useRef(null),n=g.useRef(null),r=g.useRef(0),i=g.useRef(!0),a=g.useRef(0),[o,s]=g.useState(!1),c=g.useCallback(()=>{let e=t.current;e&&(e.scrollHeight-e.clientHeight-e.scrollTop<=1||(a.current=typeof performance<`u`?performance.now():Date.now(),e.scrollTop=e.scrollHeight))},[]),l=g.useCallback(()=>{c();let e=t.current;e&&e.clientHeight>0&&s(!0)},[c]);g.useLayoutEffect(()=>{if(!i.current)return;l();let e=requestAnimationFrame(l),t=window.setTimeout(l,250),n=window.setTimeout(()=>s(!0),500);return()=>{cancelAnimationFrame(e),clearTimeout(t),clearTimeout(n)}},[e.messages,l]),g.useEffect(()=>{let e=t.current;if(!e)return;let a=new ResizeObserver(()=>{i.current?l():e.scrollTop=e.scrollHeight-e.clientHeight-r.current});return a.observe(e),n.current&&a.observe(n.current,{box:`border-box`}),()=>a.disconnect()},[l]);let u=()=>{let e=t.current;e&&((typeof performance<`u`?performance.now():Date.now())-a.current<200||(r.current=e.scrollHeight-e.scrollTop-e.clientHeight,i.current=r.current<48))},d=Ga(e.messages);return(0,I.jsx)(`div`,{id:`chat-messages`,className:`chat-scroll`,ref:t,onScroll:u,children:(0,I.jsxs)(`div`,{className:`chat-thread`+(o?` ready`:``),ref:n,children:[e.messages.length===0?(0,I.jsx)(`div`,{id:`chat-empty`,children:`Tell the agent what you want to make.`}):null,e.messages.map(t=>(0,I.jsx)(La,{msg:t,interactive:t.id===d,onPickerSubmit:e.onPickerSubmit},t.id))]})})}var za=550,Ba=4;function Va(e){let t=1500+e.trim().length/18*1e3;return Math.min(12e3,Math.max(2500,t))}function Ha(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Ua(e){return e.role===`user`?(e.text??``).trim()!==``||(e.attachments?.length??0)>0:e.role===`assistant`?e.status===`streaming`?!0:aa(e.text).some(e=>e.kind===`ask`||e.kind===`ask-pending`||e.kind===`md`&&e.text.trim()!==``):!1}function Wa(e){return e.role!==`assistant`||e.pickerAnswers?!1:aa(e.text).some(e=>e.kind===`ask`)}function Ga(e){for(let t=e.length-1;t>=0;t--)if(Wa(e[t]))return e[t].id;return null}function Ka(e,t){let n=e.map((e,t)=>({msg:e,idx:t})).filter(e=>Ua(e.msg)),r=n.filter(e=>e.idx>=t),i=new Set(r.slice(-Ba).map(e=>e.idx));return n.filter(e=>i.has(e.idx)||Wa(e.msg))}function qa(e){let{messages:t,running:n,composerActive:r,booted:i,onPickerSubmit:a}=e,o=g.useRef(null),s=g.useRef(null);s.current===null&&i&&(s.current=t.length);let c=s.current??t.length,[l,u]=g.useState(!1),[d,f]=g.useState(()=>new Set),[p,m]=g.useState(()=>new Set),h=g.useRef(new Map),_=Ka(t,c),v=_.filter(e=>Wa(e.msg)||!p.has(e.msg.id)),y=l||r||n,b=g.useCallback(e=>{if(Ha()){h.current.delete(e),m(t=>new Set(t).add(e));return}f(t=>new Set(t).add(e)),h.current.set(e,setTimeout(()=>{h.current.delete(e),m(t=>new Set(t).add(e)),f(t=>{let n=new Set(t);return n.delete(e),n})},za))},[]),x=t.length-1,S=_.map(e=>e.msg.id).join(`,`),C=_.filter(e=>e.msg.role===`assistant`?!(e.idx===x&&e.msg.status===`streaming`):!0).map(e=>e.msg.id).join(`,`),w=_.filter(e=>Wa(e.msg)).map(e=>e.msg.id).join(`,`);g.useEffect(()=>{let e=Ka(t,c),n=new Set(e.map(e=>e.msg.id));for(let e of[...h.current.keys()])n.has(e)||(clearTimeout(h.current.get(e)),h.current.delete(e));if(y){for(let e of h.current.values())clearTimeout(e);h.current.clear(),f(e=>e.size?new Set:e);return}let r=t.length-1;for(let t of e)Wa(t.msg)||p.has(t.msg.id)||d.has(t.msg.id)||h.current.has(t.msg.id)||(t.msg.role!==`assistant`||!(t.idx===r&&t.msg.status===`streaming`))&&h.current.set(t.msg.id,setTimeout(()=>b(t.msg.id),Va(t.msg.text??``)))},[S,C,w,y,p,d,n,b]),g.useEffect(()=>()=>{for(let e of h.current.values())clearTimeout(e);h.current.clear()},[]),g.useEffect(()=>{let e=o.current;e&&(e.scrollTop=e.scrollHeight)},[t.length,n,v.length]);let ee=Ga(t);return(0,I.jsx)(`div`,{id:`chat-messages`,className:`chat-scroll`,ref:o,children:(0,I.jsx)(`div`,{className:`chat-bubbles`,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),children:v.map(e=>(0,I.jsx)(La,{msg:e.msg,fading:d.has(e.msg.id),interactive:Wa(e.msg)&&e.msg.id===ee,onPickerSubmit:a},e.msg.id))})})}function Ja(e,t){for(let n of Array.from(e)){if(!n.type.startsWith(`image/`))continue;let e=new FileReader;e.onload=()=>{typeof e.result==`string`&&t({name:n.name,dataUrl:e.result})},e.readAsDataURL(n)}}function Ya(e){return e.pending.length===0?null:(0,I.jsx)(`div`,{id:`chat-pending`,children:e.pending.map((t,n)=>(0,I.jsx)(`img`,{src:t.dataUrl,alt:t.name,title:`remove`,onClick:()=>e.onRemove(n)},`${t.name}-${n}`))})}function Xa(e){return e.queued.length===0?null:(0,I.jsx)(`div`,{className:`chat-queue`,onMouseDown:e=>e.preventDefault(),children:e.queued.map((t,n)=>(0,I.jsxs)(`div`,{className:`queue-row`,children:[(0,I.jsx)(`span`,{className:`queue-snippet`,children:t.length>60?`${t.slice(0,60)}\u2026`:t}),(0,I.jsx)(`button`,{className:`queue-send-now`,type:`button`,tabIndex:-1,title:`Send now — interrupts the turn`,onClick:e.onInterrupt,children:`send now`}),(0,I.jsx)(`button`,{className:`queue-remove`,type:`button`,tabIndex:-1,title:`Remove from queue`,onClick:()=>e.onCancelQueued(n),children:`✕`})]},n))})}function Za(e){let{running:t,queued:n,floating:r,expanded:i,revealed:a}=e,[o,s]=g.useState(``),[c,l]=g.useState(!1),[u,d]=g.useState([]),[f,p]=g.useState(!1);g.useEffect(()=>{t||p(!1)},[t]);let m=g.useRef(null),h=g.useRef(null),_=r&&!i,v=g.useCallback(()=>{let e=m.current;if(!e)return;e.style.height=`auto`;let t=Number.parseFloat(window.getComputedStyle(e).lineHeight),n=Number.isFinite(t)?Math.ceil(t):21,r=o.length===0?n:Math.min(e.scrollHeight,120);e.style.height=r>0?`${r}px`:``},[o]);g.useLayoutEffect(v,[v]),g.useLayoutEffect(()=>{_||(v(),requestAnimationFrame(()=>{v(),r&&i&&m.current?.focus()}))},[v,_,r,i]),g.useLayoutEffect(()=>{let e=h.current,t=e?.closest(`.shell-root`)??null;if(!e||!t)return;if(r){t.style.removeProperty(`--composer-reserve`);return}let n=()=>{t.style.setProperty(`--composer-reserve`,`${e.offsetHeight+7}px`)};n();let i=new ResizeObserver(n);return i.observe(e),()=>{i.disconnect(),t.style.removeProperty(`--composer-reserve`)}},[r]);let y=e=>{d(t=>t.length>=6?t:[...t,e])},b=()=>{let t=o.trim();!t&&u.length===0||(e.onSend(t,u),s(``),d([]))},x=o.trim().length>0||u.length>0,S=()=>{_&&e.onExpand()},C=()=>{r&&setTimeout(()=>{h.current?.contains(document.activeElement)||o.trim().length===0&&u.length===0&&e.onCollapse()},0)},w=t&&!x;return(0,I.jsxs)(g.Fragment,{children:[(0,I.jsx)(Ya,{pending:u,onRemove:e=>d(t=>t.filter((t,n)=>n!==e))}),(0,I.jsxs)(`div`,{className:`chat-input`+(_?` collapsed`:``)+(a?` revealed`:``),ref:h,onMouseEnter:r?e.onHoverEnter:void 0,onMouseLeave:r?e.onHoverLeave:void 0,children:[(0,I.jsx)(Xa,{queued:n,onInterrupt:e.onInterrupt,onCancelQueued:e.onCancelQueued}),(0,I.jsxs)(`div`,{className:`ta`,onClick:S,children:[(0,I.jsx)(`span`,{className:`collapse-icon`,"aria-hidden":`true`,children:ba}),(0,I.jsx)(`textarea`,{id:`chat-input`,className:`ta-text`,ref:m,rows:1,placeholder:t?`Queue a message…`:`Message the conductor`,value:o,onBlur:C,onChange:e=>s(e.target.value),onPaste:e=>{let t=e.clipboardData?.files;t&&t.length>0&&(e.preventDefault(),Ja(t,y))},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.metaKey&&!e.altKey&&(e.preventDefault(),b())}}),(0,I.jsxs)(`div`,{className:`ta-bottom`,onMouseDown:e=>e.preventDefault(),children:[(0,I.jsxs)(`div`,{className:`composer-settings`,children:[(0,I.jsxs)(`button`,{className:`composer-pill`+(c?` active`:``),type:`button`,tabIndex:-1,title:`Settings`,"aria-label":`Settings`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:()=>l(e=>!e),children:[(0,I.jsx)(`span`,{className:`composer-pill-label`,children:`Settings`}),va]}),c?(0,I.jsx)(Ea,{settings:e.settings,onSetSetting:e.onSetSetting,onClose:()=>l(!1)}):null]}),(0,I.jsx)(`button`,{id:`chat-send`,className:`send${w?` stop`:``}`,type:`button`,tabIndex:-1,title:w?f?`Stopping…`:`Stop`:`Send`,disabled:!w&&!x||w&&f,onClick:()=>{w?(p(!0),e.onInterrupt()):b()},children:w?_a:ga})]})]})]})]})}function Qa(e){let t=Fa(e.tasks);return t.length===0?null:(0,I.jsx)(`div`,{className:`conductor-gutter`,onMouseEnter:e.onHoverEnter,onMouseLeave:e.onHoverLeave,children:(0,I.jsx)(`div`,{className:`task-stack`,children:t.map(t=>(0,I.jsx)(Na,{task:t,feed:e.feeds[t.id],onAck:e.onAck,open:e.openTasks.has(t.id),onToggle:()=>e.onToggleTask(t.id)},t.id))})})}function $a(e){let t=g.useRef(null),n=g.useCallback(()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},[]),r=g.useCallback(()=>{n(),e(!0)},[n,e]),i=g.useCallback(()=>{n(),t.current=window.setTimeout(()=>e(!1),300)},[n,e]);return g.useEffect(()=>()=>n(),[n]),{revealEnter:r,revealLeave:i}}var eo=100;function to(e,t,n){return g.useCallback(r=>{r.preventDefault();let i=r.currentTarget,a=r.pointerId;try{i.setPointerCapture(a)}catch{}let o=new AbortController,s=()=>{o.abort();try{i.releasePointerCapture(a)}catch{}document.body.classList.remove(`conductor-resizing`)};i.addEventListener(`pointermove`,r=>{if(r.clientX<t){s(),n();return}e(r.clientX)},{signal:o.signal}),i.addEventListener(`pointerup`,s,{signal:o.signal}),i.addEventListener(`pointercancel`,s,{signal:o.signal}),document.body.classList.add(`conductor-resizing`)},[e,t,n])}function no(e){let{floating:t}=e;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{className:`conductor-avatar`+(e.hasActiveTasks?` active`:``),type:`button`,tabIndex:-1,title:t?`Dock the chat panel`:`Float the chat panel`,"aria-label":`Toggle chat layout`,onClick:()=>e.setFloating(!t),onMouseEnter:t?e.onHoverEnter:void 0,onMouseLeave:t?e.onHoverLeave:void 0,children:ya}),t?null:(0,I.jsx)(`div`,{className:`conductor-resize`,role:`separator`,"aria-label":`Resize chat panel`,"aria-orientation":`vertical`,"aria-valuenow":e.columnWidth,"aria-valuemin":e.minWidth,"aria-valuemax":e.maxWidth,onPointerDown:e.onStartResize})]})}function ro(e){let{agent:t,floating:n,setFloating:r,columnWidth:i,setColumnWidth:a,minWidth:o,maxWidth:s}=e,{messages:c,tasks:l,feeds:u,settings:d,running:f,queued:p,booted:m}=t,[h,_]=g.useState(!1),[v,y]=g.useState(!1),[b,x]=g.useState(!1),[S,C]=g.useState(()=>new Set);g.useEffect(()=>{n&&(_(!1),y(!1),x(!1),C(new Set))},[n]);let w=b||S.size>0,{revealEnter:ee,revealLeave:te}=$a(y),T=g.useCallback(e=>{C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ne=g.useCallback(()=>{_(!0),C(new Set)},[]),E=g.useCallback(()=>r(!0),[r]),D=to(a,o-eo,E),O=(e,n,r)=>{t.submitPicker(e.id,n,r)},re=l.some(e=>e.status===`running`);return(0,I.jsxs)(`div`,{id:`chat-host`,className:[n&&w?`rail-engaged`:``,n&&h?`chat-expanded`:``].filter(Boolean).join(` `),children:[n?(0,I.jsx)(qa,{messages:c,running:f,composerActive:h,booted:m,onPickerSubmit:O}):(0,I.jsxs)(`div`,{className:`conductor-inset`,children:[(0,I.jsx)(Ia,{tasks:l,feeds:u,onAck:t.ackTask}),Fa(l).length>0?(0,I.jsx)(`div`,{className:`chat-divider`,"aria-hidden":`true`}):null,(0,I.jsx)(Ra,{messages:c,onPickerSubmit:O})]}),(0,I.jsx)(Za,{running:f,queued:p,onSend:t.sendUserMessage,onInterrupt:t.interrupt,onCancelQueued:t.cancelQueued,floating:n,expanded:h,revealed:v,onExpand:ne,onCollapse:()=>_(!1),onHoverEnter:ee,onHoverLeave:te,settings:d,onSetSetting:t.setSetting}),n?(0,I.jsx)(Qa,{tasks:l,feeds:u,openTasks:S,onToggleTask:T,onAck:t.ackTask,onHoverEnter:()=>x(!0),onHoverLeave:()=>x(!1)}):null,(0,I.jsx)(no,{floating:n,setFloating:r,hasActiveTasks:re,onHoverEnter:ee,onHoverLeave:te,columnWidth:i,minWidth:o,maxWidth:s,onStartResize:D})]})}var io=Object.defineProperty,ao=Object.getOwnPropertyDescriptor,oo=(e,t)=>{for(var n in t)io(e,n,{get:t[n],enumerable:!0})},so=(e,t,n,r)=>{for(var i=r>1?void 0:r?ao(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&io(t,n,i),i},L=(e,t)=>(n,r)=>t(n,r,e),co=`Terminal input`,lo={get:()=>co,set:e=>co=e},uo=`Too much output to announce, navigate to rows manually to read`,fo={get:()=>uo,set:e=>uo=e};function po(e){return e.replace(/\r?\n/g,`\r`)}function mo(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function ho(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function go(e,t,n,r){e.stopPropagation(),e.clipboardData&&_o(e.clipboardData.getData(`text/plain`),t,n,r)}function _o(e,t,n,r){e=po(e),e=mo(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function vo(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function yo(e,t,n,r,i){vo(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function bo(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function xo(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var So=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},Co=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},wo=``,To=` `,Eo=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Do}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Do=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Oo=class e extends Eo{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Do,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?bo(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ko=`di$target`,Ao=`di$dependencies`,jo=new Map;function Mo(e){return e[Ao]||[]}function No(e){if(jo.has(e))return jo.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Po(t,e,r)};return t._id=e,jo.set(e,t),t}function Po(e,t,n){t[ko]===t?t[Ao].push({id:e,index:n}):(t[Ao]=[{id:e,index:n}],t[ko]=t)}var Fo=No(`BufferService`),Io=No(`CoreMouseService`),Lo=No(`CoreService`),Ro=No(`CharsetService`),zo=No(`InstantiationService`),Bo=No(`LogService`),Vo=No(`OptionsService`),Ho=No(`OscLinkService`),Uo=No(`UnicodeService`),Wo=No(`DecorationService`),Go=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new Oo,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+(!l&&t===o-1?1:0),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Ko(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Go=so([L(0,Fo),L(1,Vo),L(2,Ho)],Go);function Ko(e,t){if(confirm(`Do you want to navigate to ${t}?
|
|
74
74
|
|
|
75
75
|
WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var qo=No(`CharSizeService`),Jo=No(`CoreBrowserService`),Yo=No(`MouseService`),Xo=No(`RenderService`),Zo=No(`SelectionService`),Qo=No(`CharacterJoinerService`),$o=No(`ThemeService`),es=No(`LinkProviderService`),ts=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ss.isErrorNoTelemetry(e)?new ss(e.message+`
|
|
76
76
|
|
package/dist/shell/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>Castle Editor</title>
|
|
7
|
-
<script type="module" crossorigin src="/__castle/ide/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/__castle/ide/assets/index-D3unT7do.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/__castle/ide/assets/index-RZrw5gQ2.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|