palmier 0.6.8 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/agent.d.ts +2 -2
- package/dist/agents/aider.d.ts +1 -1
- package/dist/agents/aider.js +2 -5
- package/dist/agents/claude.d.ts +1 -1
- package/dist/agents/claude.js +2 -5
- package/dist/agents/cline.d.ts +1 -1
- package/dist/agents/cline.js +2 -5
- package/dist/agents/codex.d.ts +1 -1
- package/dist/agents/codex.js +2 -5
- package/dist/agents/copilot.d.ts +1 -1
- package/dist/agents/copilot.js +2 -5
- package/dist/agents/cursor.d.ts +1 -1
- package/dist/agents/cursor.js +2 -5
- package/dist/agents/deepagents.d.ts +1 -1
- package/dist/agents/deepagents.js +2 -5
- package/dist/agents/droid.d.ts +1 -1
- package/dist/agents/droid.js +2 -5
- package/dist/agents/gemini.d.ts +1 -1
- package/dist/agents/gemini.js +2 -5
- package/dist/agents/goose.d.ts +1 -1
- package/dist/agents/goose.js +2 -5
- package/dist/agents/hermes.d.ts +1 -1
- package/dist/agents/hermes.js +2 -5
- package/dist/agents/kimi.d.ts +1 -1
- package/dist/agents/kimi.js +2 -5
- package/dist/agents/kiro.d.ts +1 -1
- package/dist/agents/kiro.js +2 -5
- package/dist/agents/openclaw.d.ts +1 -1
- package/dist/agents/openclaw.js +2 -5
- package/dist/agents/opencode.d.ts +1 -1
- package/dist/agents/opencode.js +2 -5
- package/dist/agents/qoder.d.ts +1 -1
- package/dist/agents/qoder.js +2 -5
- package/dist/agents/qwen.d.ts +1 -1
- package/dist/agents/qwen.js +2 -5
- package/dist/agents/shared-prompt.js +1 -1
- package/dist/commands/run.js +1 -2
- package/dist/mcp-tools.d.ts +1 -1
- package/dist/mcp-tools.js +2 -2
- package/dist/pwa/assets/{index-C8vJwUNi.js → index-CZejk2al.js} +1 -1
- package/dist/pwa/assets/{web-NxTETXZK.js → web-C48txJFl.js} +1 -1
- package/dist/pwa/assets/{web-6UChJFov.js → web-zj8Blync.js} +1 -1
- package/dist/pwa/index.html +1 -1
- package/dist/pwa/service-worker.js +1 -1
- package/dist/rpc-handler.js +27 -67
- package/dist/task.js +2 -3
- package/dist/types.d.ts +0 -1
- package/package.json +2 -2
- package/palmier-server/pwa/src/constants.ts +1 -1
- package/src/agents/agent.ts +2 -2
- package/src/agents/aider.ts +2 -5
- package/src/agents/claude.ts +2 -5
- package/src/agents/cline.ts +2 -5
- package/src/agents/codex.ts +2 -5
- package/src/agents/copilot.ts +2 -5
- package/src/agents/cursor.ts +2 -5
- package/src/agents/deepagents.ts +2 -5
- package/src/agents/droid.ts +2 -5
- package/src/agents/gemini.ts +2 -5
- package/src/agents/goose.ts +2 -5
- package/src/agents/hermes.ts +2 -5
- package/src/agents/kimi.ts +2 -5
- package/src/agents/kiro.ts +2 -5
- package/src/agents/openclaw.ts +2 -5
- package/src/agents/opencode.ts +2 -5
- package/src/agents/qoder.ts +2 -5
- package/src/agents/qwen.ts +2 -5
- package/src/agents/shared-prompt.ts +1 -1
- package/src/commands/run.ts +1 -2
- package/src/mcp-tools.ts +2 -2
- package/src/rpc-handler.ts +29 -71
- package/src/task.ts +2 -3
- package/src/types.ts +0 -1
- package/test/agent-instructions.test.ts +84 -19
- package/test/agent-output-parsing.test.ts +1 -0
- package/test/task-parsing.test.ts +3 -3
- package/dist/commands/plan-generation.md +0 -22
- package/src/commands/plan-generation.md +0 -22
- package/test/fixtures/agent-instructions-snapshot.md +0 -58
|
@@ -115,4 +115,4 @@ ${f.stack}`),c.reject(d)):c.resolve(y))}});return m.requestSubject=n,this.protoc
|
|
|
115
115
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:c,tableCell:m,tableRow:f}};function c(x,k,L,B){return d(y(x,L,B),x.align)}function f(x,k,L,B){const D=g(x,L,B),$=d([D]);return $.slice(0,$.indexOf(`
|
|
116
116
|
`))}function m(x,k,L,B){const D=L.enter("tableCell"),$=L.enter("phrasing"),V=L.containerPhrasing(x,{...B,before:u,after:u});return $(),D(),V}function d(x,k){return _j(x,{align:k,alignDelimiters:a,padding:r,stringLength:l})}function y(x,k,L){const B=x.children;let D=-1;const $=[],V=k.enter("table");for(;++D<B.length;)$[D]=g(B[D],k,L);return V(),$}function g(x,k,L){const B=x.children;let D=-1;const $=[],V=k.enter("tableRow");for(;++D<B.length;)$[D]=m(B[D],x,k,L);return V(),$}function b(x,k,L){let B=ev.inlineCode(x,k,L);return L.stack.includes("tableCell")&&(B=B.replace(/\|/g,"\\$&")),B}}function cO(){return{exit:{taskListCheckValueChecked:ab,taskListCheckValueUnchecked:ab,paragraph:hO}}}function fO(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:dO}}}function ab(e){const n=this.stack[this.stack.length-2];n.type,n.checked=e.type==="taskListCheckValueChecked"}function hO(e){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const r=this.stack[this.stack.length-1];r.type;const a=r.children[0];if(a&&a.type==="text"){const l=n.children;let u=-1,c;for(;++u<l.length;){const f=l[u];if(f.type==="paragraph"){c=f;break}}c===r&&(a.value=a.value.slice(1),a.value.length===0?r.children.shift():r.position&&a.position&&typeof a.position.start.offset=="number"&&(a.position.start.column++,a.position.start.offset++,r.position.start=Object.assign({},a.position.start)))}}this.exit(e)}function dO(e,n,r,a){const l=e.children[0],u=typeof e.checked=="boolean"&&l&&l.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",f=r.createTracker(a);u&&f.move(c);let m=ev.listItem(e,n,r,{...a,...f.current()});return u&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),m;function d(y){return y+c}}function mO(){return[YT(),dj(),yj(),rO(),cO()]}function pO(e){return{extensions:[VT(),mj(e),bj(),uO(e),fO()]}}const gO={tokenize:SO,partial:!0},tv={tokenize:_O,partial:!0},nv={tokenize:EO,partial:!0},rv={tokenize:kO,partial:!0},yO={tokenize:AO,partial:!0},iv={name:"wwwAutolink",tokenize:xO,previous:sv},av={name:"protocolAutolink",tokenize:wO,previous:lv},Yr={name:"emailAutolink",tokenize:vO,previous:ov},vr={};function bO(){return{text:vr}}let Zi=48;for(;Zi<123;)vr[Zi]=Yr,Zi++,Zi===58?Zi=65:Zi===91&&(Zi=97);vr[43]=Yr;vr[45]=Yr;vr[46]=Yr;vr[95]=Yr;vr[72]=[Yr,av];vr[104]=[Yr,av];vr[87]=[Yr,iv];vr[119]=[Yr,iv];function vO(e,n,r){const a=this;let l,u;return c;function c(g){return!id(g)||!ov.call(a,a.previous)||Hd(a.events)?r(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(g))}function f(g){return id(g)?(e.consume(g),f):g===64?(e.consume(g),m):r(g)}function m(g){return g===46?e.check(yO,y,d)(g):g===45||g===95||tn(g)?(u=!0,e.consume(g),m):y(g)}function d(g){return e.consume(g),l=!0,m}function y(g){return u&&l&&un(a.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),n(g)):r(g)}}function xO(e,n,r){const a=this;return l;function l(c){return c!==87&&c!==119||!sv.call(a,a.previous)||Hd(a.events)?r(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(gO,e.attempt(tv,e.attempt(nv,u),r),r)(c))}function u(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),n(c)}}function wO(e,n,r){const a=this;let l="",u=!1;return c;function c(g){return(g===72||g===104)&&lv.call(a,a.previous)&&!Hd(a.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),l+=String.fromCodePoint(g),e.consume(g),f):r(g)}function f(g){if(un(g)&&l.length<5)return l+=String.fromCodePoint(g),e.consume(g),f;if(g===58){const b=l.toLowerCase();if(b==="http"||b==="https")return e.consume(g),m}return r(g)}function m(g){return g===47?(e.consume(g),u?d:(u=!0,m)):r(g)}function d(g){return g===null||Eu(g)||bt(g)||ea(g)||Du(g)?r(g):e.attempt(tv,e.attempt(nv,y),r)(g)}function y(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),n(g)}}function SO(e,n,r){let a=0;return l;function l(c){return(c===87||c===119)&&a<3?(a++,e.consume(c),l):c===46&&a===3?(e.consume(c),u):r(c)}function u(c){return c===null?r(c):n(c)}}function _O(e,n,r){let a,l,u;return c;function c(d){return d===46||d===95?e.check(rv,m,f)(d):d===null||bt(d)||ea(d)||d!==45&&Du(d)?m(d):(u=!0,e.consume(d),c)}function f(d){return d===95?a=!0:(l=a,a=void 0),e.consume(d),c}function m(d){return l||a||!u?r(d):n(d)}}function EO(e,n){let r=0,a=0;return l;function l(c){return c===40?(r++,e.consume(c),l):c===41&&a<r?u(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(rv,n,u)(c):c===null||bt(c)||ea(c)?n(c):(e.consume(c),l)}function u(c){return c===41&&a++,e.consume(c),l}}function kO(e,n,r){return a;function a(f){return f===33||f===34||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===63||f===95||f===126?(e.consume(f),a):f===38?(e.consume(f),u):f===93?(e.consume(f),l):f===60||f===null||bt(f)||ea(f)?n(f):r(f)}function l(f){return f===null||f===40||f===91||bt(f)||ea(f)?n(f):a(f)}function u(f){return un(f)?c(f):r(f)}function c(f){return f===59?(e.consume(f),a):un(f)?(e.consume(f),c):r(f)}}function AO(e,n,r){return a;function a(u){return e.consume(u),l}function l(u){return tn(u)?r(u):n(u)}}function sv(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||bt(e)}function lv(e){return!un(e)}function ov(e){return!(e===47||id(e))}function id(e){return e===43||e===45||e===46||e===95||tn(e)}function Hd(e){let n=e.length,r=!1;for(;n--;){const a=e[n][1];if((a.type==="labelLink"||a.type==="labelImage")&&!a._balanced){r=!0;break}if(a._gfmAutolinkLiteralWalkedInto){r=!1;break}}return e.length>0&&!r&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const CO={tokenize:zO,partial:!0};function TO(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:RO,continuation:{tokenize:MO},exit:DO}},text:{91:{name:"gfmFootnoteCall",tokenize:NO},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:jO,resolveTo:OO}}}}function jO(e,n,r){const a=this;let l=a.events.length;const u=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let c;for(;l--;){const m=a.events[l][1];if(m.type==="labelImage"){c=m;break}if(m.type==="gfmFootnoteCall"||m.type==="labelLink"||m.type==="label"||m.type==="image"||m.type==="link")break}return f;function f(m){if(!c||!c._balanced)return r(m);const d=sr(a.sliceSerialize({start:c.end,end:a.now()}));return d.codePointAt(0)!==94||!u.includes(d.slice(1))?r(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),n(m))}}function OO(e,n){let r=e.length;for(;r--;)if(e[r][1].type==="labelImage"&&e[r][0]==="enter"){e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";const a={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},l={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+3][1].end)};l.end.column++,l.end.offset++,l.end._bufferIndex++;const u={type:"gfmFootnoteCallString",start:Object.assign({},l.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},u.start),end:Object.assign({},u.end)},f=[e[r+1],e[r+2],["enter",a,n],e[r+3],e[r+4],["enter",l,n],["exit",l,n],["enter",u,n],["enter",c,n],["exit",c,n],["exit",u,n],e[e.length-2],e[e.length-1],["exit",a,n]];return e.splice(r,e.length-r+1,...f),e}function NO(e,n,r){const a=this,l=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let u=0,c;return f;function f(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),m}function m(g){return g!==94?r(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(g){if(u>999||g===93&&!c||g===null||g===91||bt(g))return r(g);if(g===93){e.exit("chunkString");const b=e.exit("gfmFootnoteCallString");return l.includes(sr(a.sliceSerialize(b)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),n):r(g)}return bt(g)||(c=!0),u++,e.consume(g),g===92?y:d}function y(g){return g===91||g===92||g===93?(e.consume(g),u++,d):d(g)}}function RO(e,n,r){const a=this,l=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let u,c=0,f;return m;function m(k){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(k){return k===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",y):r(k)}function y(k){if(c>999||k===93&&!f||k===null||k===91||bt(k))return r(k);if(k===93){e.exit("chunkString");const L=e.exit("gfmFootnoteDefinitionLabelString");return u=sr(a.sliceSerialize(L)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),b}return bt(k)||(f=!0),c++,e.consume(k),k===92?g:y}function g(k){return k===91||k===92||k===93?(e.consume(k),c++,y):y(k)}function b(k){return k===58?(e.enter("definitionMarker"),e.consume(k),e.exit("definitionMarker"),l.includes(u)||l.push(u),tt(e,x,"gfmFootnoteDefinitionWhitespace")):r(k)}function x(k){return n(k)}}function MO(e,n,r){return e.check(Dl,n,e.attempt(CO,n,r))}function DO(e){e.exit("gfmFootnoteDefinition")}function zO(e,n,r){const a=this;return tt(e,l,"gfmFootnoteDefinitionIndent",5);function l(u){const c=a.events[a.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?n(u):r(u)}}function LO(e){let r=(e||{}).singleTilde;const a={name:"strikethrough",tokenize:u,resolveAll:l};return r==null&&(r=!0),{text:{126:a},insideSpan:{null:[a]},attentionMarkers:{null:[126]}};function l(c,f){let m=-1;for(;++m<c.length;)if(c[m][0]==="enter"&&c[m][1].type==="strikethroughSequenceTemporary"&&c[m][1]._close){let d=m;for(;d--;)if(c[d][0]==="exit"&&c[d][1].type==="strikethroughSequenceTemporary"&&c[d][1]._open&&c[m][1].end.offset-c[m][1].start.offset===c[d][1].end.offset-c[d][1].start.offset){c[m][1].type="strikethroughSequence",c[d][1].type="strikethroughSequence";const y={type:"strikethrough",start:Object.assign({},c[d][1].start),end:Object.assign({},c[m][1].end)},g={type:"strikethroughText",start:Object.assign({},c[d][1].end),end:Object.assign({},c[m][1].start)},b=[["enter",y,f],["enter",c[d][1],f],["exit",c[d][1],f],["enter",g,f]],x=f.parser.constructs.insideSpan.null;x&&Rn(b,b.length,0,zu(x,c.slice(d+1,m),f)),Rn(b,b.length,0,[["exit",g,f],["enter",c[m][1],f],["exit",c[m][1],f],["exit",y,f]]),Rn(c,d-1,m-d+3,b),m=d+b.length-2;break}}for(m=-1;++m<c.length;)c[m][1].type==="strikethroughSequenceTemporary"&&(c[m][1].type="data");return c}function u(c,f,m){const d=this.previous,y=this.events;let g=0;return b;function b(k){return d===126&&y[y.length-1][1].type!=="characterEscape"?m(k):(c.enter("strikethroughSequenceTemporary"),x(k))}function x(k){const L=rs(d);if(k===126)return g>1?m(k):(c.consume(k),g++,x);if(g<2&&!r)return m(k);const B=c.exit("strikethroughSequenceTemporary"),D=rs(k);return B._open=!D||D===2&&!!L,B._close=!L||L===2&&!!D,f(k)}}}class UO{constructor(){this.map=[]}add(n,r,a){BO(this,n,r,a)}consume(n){if(this.map.sort(function(u,c){return u[0]-c[0]}),this.map.length===0)return;let r=this.map.length;const a=[];for(;r>0;)r-=1,a.push(n.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),n.length=this.map[r][0];a.push(n.slice()),n.length=0;let l=a.pop();for(;l;){for(const u of l)n.push(u);l=a.pop()}this.map.length=0}}function BO(e,n,r,a){let l=0;if(!(r===0&&a.length===0)){for(;l<e.map.length;){if(e.map[l][0]===n){e.map[l][1]+=r,e.map[l][2].push(...a);return}l+=1}e.map.push([n,r,a])}}function PO(e,n){let r=!1;const a=[];for(;n<e.length;){const l=e[n];if(r){if(l[0]==="enter")l[1].type==="tableContent"&&a.push(e[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(l[1].type==="tableContent"){if(e[n-1][1].type==="tableDelimiterMarker"){const u=a.length-1;a[u]=a[u]==="left"?"center":"right"}}else if(l[1].type==="tableDelimiterRow")break}else l[0]==="enter"&&l[1].type==="tableDelimiterRow"&&(r=!0);n+=1}return a}function qO(){return{flow:{null:{name:"table",tokenize:HO,resolveAll:IO}}}}function HO(e,n,r){const a=this;let l=0,u=0,c;return f;function f(T){let X=a.events.length-1;for(;X>-1;){const ue=a.events[X][1].type;if(ue==="lineEnding"||ue==="linePrefix")X--;else break}const K=X>-1?a.events[X][1].type:null,ye=K==="tableHead"||K==="tableRow"?R:m;return ye===R&&a.parser.lazy[a.now().line]?r(T):ye(T)}function m(T){return e.enter("tableHead"),e.enter("tableRow"),d(T)}function d(T){return T===124||(c=!0,u+=1),y(T)}function y(T){return T===null?r(T):Le(T)?u>1?(u=0,a.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),x):r(T):Ke(T)?tt(e,y,"whitespace")(T):(u+=1,c&&(c=!1,l+=1),T===124?(e.enter("tableCellDivider"),e.consume(T),e.exit("tableCellDivider"),c=!0,y):(e.enter("data"),g(T)))}function g(T){return T===null||T===124||bt(T)?(e.exit("data"),y(T)):(e.consume(T),T===92?b:g)}function b(T){return T===92||T===124?(e.consume(T),g):g(T)}function x(T){return a.interrupt=!1,a.parser.lazy[a.now().line]?r(T):(e.enter("tableDelimiterRow"),c=!1,Ke(T)?tt(e,k,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):k(T))}function k(T){return T===45||T===58?B(T):T===124?(c=!0,e.enter("tableCellDivider"),e.consume(T),e.exit("tableCellDivider"),L):N(T)}function L(T){return Ke(T)?tt(e,B,"whitespace")(T):B(T)}function B(T){return T===58?(u+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(T),e.exit("tableDelimiterMarker"),D):T===45?(u+=1,D(T)):T===null||Le(T)?se(T):N(T)}function D(T){return T===45?(e.enter("tableDelimiterFiller"),$(T)):N(T)}function $(T){return T===45?(e.consume(T),$):T===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(T),e.exit("tableDelimiterMarker"),V):(e.exit("tableDelimiterFiller"),V(T))}function V(T){return Ke(T)?tt(e,se,"whitespace")(T):se(T)}function se(T){return T===124?k(T):T===null||Le(T)?!c||l!==u?N(T):(e.exit("tableDelimiterRow"),e.exit("tableHead"),n(T)):N(T)}function N(T){return r(T)}function R(T){return e.enter("tableRow"),G(T)}function G(T){return T===124?(e.enter("tableCellDivider"),e.consume(T),e.exit("tableCellDivider"),G):T===null||Le(T)?(e.exit("tableRow"),n(T)):Ke(T)?tt(e,G,"whitespace")(T):(e.enter("data"),J(T))}function J(T){return T===null||T===124||bt(T)?(e.exit("data"),G(T)):(e.consume(T),T===92?Y:J)}function Y(T){return T===92||T===124?(e.consume(T),J):J(T)}}function IO(e,n){let r=-1,a=!0,l=0,u=[0,0,0,0],c=[0,0,0,0],f=!1,m=0,d,y,g;const b=new UO;for(;++r<e.length;){const x=e[r],k=x[1];x[0]==="enter"?k.type==="tableHead"?(f=!1,m!==0&&(sb(b,n,m,d,y),y=void 0,m=0),d={type:"table",start:Object.assign({},k.start),end:Object.assign({},k.end)},b.add(r,0,[["enter",d,n]])):k.type==="tableRow"||k.type==="tableDelimiterRow"?(a=!0,g=void 0,u=[0,0,0,0],c=[0,r+1,0,0],f&&(f=!1,y={type:"tableBody",start:Object.assign({},k.start),end:Object.assign({},k.end)},b.add(r,0,[["enter",y,n]])),l=k.type==="tableDelimiterRow"?2:y?3:1):l&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")?(a=!1,c[2]===0&&(u[1]!==0&&(c[0]=c[1],g=iu(b,n,u,l,void 0,g),u=[0,0,0,0]),c[2]=r)):k.type==="tableCellDivider"&&(a?a=!1:(u[1]!==0&&(c[0]=c[1],g=iu(b,n,u,l,void 0,g)),u=c,c=[u[1],r,0,0])):k.type==="tableHead"?(f=!0,m=r):k.type==="tableRow"||k.type==="tableDelimiterRow"?(m=r,u[1]!==0?(c[0]=c[1],g=iu(b,n,u,l,r,g)):c[1]!==0&&(g=iu(b,n,c,l,r,g)),l=0):l&&(k.type==="data"||k.type==="tableDelimiterMarker"||k.type==="tableDelimiterFiller")&&(c[3]=r)}for(m!==0&&sb(b,n,m,d,y),b.consume(n.events),r=-1;++r<n.events.length;){const x=n.events[r];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=PO(n.events,r))}return e}function iu(e,n,r,a,l,u){const c=a===1?"tableHeader":a===2?"tableDelimiter":"tableData",f="tableContent";r[0]!==0&&(u.end=Object.assign({},$a(n.events,r[0])),e.add(r[0],0,[["exit",u,n]]));const m=$a(n.events,r[1]);if(u={type:c,start:Object.assign({},m),end:Object.assign({},m)},e.add(r[1],0,[["enter",u,n]]),r[2]!==0){const d=$a(n.events,r[2]),y=$a(n.events,r[3]),g={type:f,start:Object.assign({},d),end:Object.assign({},y)};if(e.add(r[2],0,[["enter",g,n]]),a!==2){const b=n.events[r[2]],x=n.events[r[3]];if(b[1].end=Object.assign({},x[1].end),b[1].type="chunkText",b[1].contentType="text",r[3]>r[2]+1){const k=r[2]+1,L=r[3]-r[2]-1;e.add(k,L,[])}}e.add(r[3]+1,0,[["exit",g,n]])}return l!==void 0&&(u.end=Object.assign({},$a(n.events,l)),e.add(l,0,[["exit",u,n]]),u=void 0),u}function sb(e,n,r,a,l){const u=[],c=$a(n.events,r);l&&(l.end=Object.assign({},c),u.push(["exit",l,n])),a.end=Object.assign({},c),u.push(["exit",a,n]),e.add(r+1,0,u)}function $a(e,n){const r=e[n],a=r[0]==="enter"?"start":"end";return r[1][a]}const FO={name:"tasklistCheck",tokenize:GO};function $O(){return{text:{91:FO}}}function GO(e,n,r){const a=this;return l;function l(m){return a.previous!==null||!a._gfmTasklistFirstContentOfListItem?r(m):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),u)}function u(m){return bt(m)?(e.enter("taskListCheckValueUnchecked"),e.consume(m),e.exit("taskListCheckValueUnchecked"),c):m===88||m===120?(e.enter("taskListCheckValueChecked"),e.consume(m),e.exit("taskListCheckValueChecked"),c):r(m)}function c(m){return m===93?(e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):r(m)}function f(m){return Le(m)?n(m):Ke(m)?e.check({tokenize:YO},n,r)(m):r(m)}}function YO(e,n,r){return tt(e,a,"whitespace");function a(l){return l===null?r(l):n(l)}}function VO(e){return b1([bO(),TO(),LO(e),qO(),$O()])}const JO={};function ad(e){const n=this,r=e||JO,a=n.data(),l=a.micromarkExtensions||(a.micromarkExtensions=[]),u=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),c=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);l.push(VO(r)),u.push(mO()),c.push(pO(r))}function XO({body:e,permissions:n}){return w.jsxs("div",{className:"plan-dialog",children:[w.jsx("h2",{children:"Task Execution Plan"}),w.jsxs("div",{className:"plan-dialog-scroll",children:[e?w.jsx("div",{className:"plan-preview",children:w.jsx(rd,{remarkPlugins:[ad],children:e})}):w.jsx("p",{className:"plan-empty",children:"No execution plan generated for this task. Your task description will be used directly."}),n&&n.length>0&&w.jsxs("div",{className:"permissions-section",children:[w.jsx("h3",{children:"Granted Permissions"}),w.jsx("ul",{className:"permissions-list",children:n.map((r,a)=>w.jsxs("li",{className:"permission-item",children:[w.jsx("span",{className:"permission-tool",children:r.name}),w.jsx("span",{className:"permission-desc",children:r.description})]},a))})]})]}),w.jsx("div",{className:"plan-dialog-actions",children:w.jsx("button",{className:"btn btn-secondary",onClick:()=>history.back(),children:"Back"})})]})}const Ga=[];function QO(){const e=Ga.pop();e&&(e.pushed.current=!1,e.close())}let lb=!1;function KO(){lb||(lb=!0,window.addEventListener("popstate",QO))}function ZO(e,n){const r=U.useRef(!1),a=U.useRef(n);a.current=n;const l=U.useCallback(()=>a.current(),[]),u=U.useRef({close:l,pushed:r});u.current.close=l,U.useEffect(()=>{if(e&&!r.current)KO(),history.pushState({modal:!0},""),Ga.push(u.current),r.current=!0;else if(!e&&r.current){r.current=!1;const c=Ga.indexOf(u.current);c!==-1&&Ga.splice(c,1),history.back()}},[e,l]),U.useEffect(()=>{const c=u.current;return()=>{if(r.current){r.current=!1;const f=Ga.indexOf(c);f!==-1&&Ga.splice(f,1),history.back()}}},[])}const WO=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function _i(e="daily"){return{schedule:e,time:"00:00",dayOfWeek:"1",dayOfMonth:"1",onceDate:"",onceTime:"00:00"}}function eN(e){const n=e.split(" ");if(n.length!==5)return _i();const[r,a,l,,u]=n;if(a==="*")return _i("hourly");const c=`${a.padStart(2,"0")}:${r.padStart(2,"0")}`;return u!=="*"?{..._i("weekly"),time:c,dayOfWeek:u}:l!=="*"?{..._i("monthly"),time:c,dayOfMonth:l}:{..._i("daily"),time:c}}function ob(e){if(e.type==="once"){const[n,r]=e.value.split("T");return{..._i("once"),onceDate:n??"",onceTime:(r??"09:00").slice(0,5)}}return eN(e.value)}function tN(e){const[n,r]=e.time.split(":").map(Number);switch(e.schedule){case"hourly":return"0 * * * *";case"daily":return`${r} ${n} * * *`;case"weekly":return`${r} ${n} * * ${e.dayOfWeek}`;case"monthly":return`${r} ${n} ${e.dayOfMonth} * *`;default:return"0 * * * *"}}function nN(e){return e.schedule==="once"?e.onceDate?{type:"once",value:`${e.onceDate}T${e.onceTime}`}:null:{type:"cron",value:tN(e)}}function rN({initial:e,agents:n,hostPlatform:r,onSaved:a,onRun:l,onCancel:u}){var wr;const{request:c}=_d(),f=()=>{var Be;const Ee=localStorage.getItem("palmier:lastAgent"),Ie=n.map(jt=>jt.key);return Ee&&Ie.includes(Ee)?Ee:((Be=n[0])==null?void 0:Be.key)??""},[m,d]=U.useState((e==null?void 0:e.user_prompt)??""),[y,g]=U.useState((e==null?void 0:e.agent)??f()),[b]=U.useState((e==null?void 0:e.body)??""),x=!!e&&m!==(e.user_prompt??""),k=!!e&&y!==(e.agent??""),L=x||k,B=!!e&&(!!b||!!((wr=e.permissions)!=null&&wr.length))&&!L,[D,$]=U.useState(!1),V=U.useCallback(()=>$(!1),[]);ZO(D,V);const[se,N]=U.useState(null),[R,G]=U.useState(()=>((e==null?void 0:e.triggers)??[]).map(ob)),[J,Y]=U.useState(()=>{var Ee;return((Ee=((e==null?void 0:e.triggers)??[]).map(ob)[0])==null?void 0:Ee.schedule)??"daily"}),[T,X]=U.useState((e==null?void 0:e.triggers_enabled)??!1),[K,ye]=U.useState((e==null?void 0:e.requires_confirmation)??!1),[ue,q]=U.useState((e==null?void 0:e.yolo_mode)??!1),[I,ae]=U.useState((e==null?void 0:e.foreground_mode)??!1),[ge,_e]=U.useState(null),O=ge!==null,[M,W]=U.useState(!!(e!=null&&e.command)),[S,he]=U.useState((e==null?void 0:e.command)??""),fe=U.useRef(null),ve=!!e,Te=!ve||m!==((e==null?void 0:e.user_prompt)??"")||y!==((e==null?void 0:e.agent)??"")||T!==((e==null?void 0:e.triggers_enabled)??!0)||K!==((e==null?void 0:e.requires_confirmation)??!1)||ue!==((e==null?void 0:e.yolo_mode)??!1)||I!==((e==null?void 0:e.foreground_mode)??!1)||M!==!!(e!=null&&e.command)||M&&S!==((e==null?void 0:e.command)??"")||JSON.stringify(nt())!==JSON.stringify((e==null?void 0:e.triggers)??[]),ze=T&&R.some(Ee=>Ee.schedule==="once"&&(!Ee.onceDate||new Date(`${Ee.onceDate}T${Ee.onceTime}`)<=new Date)),ke=Te&&!!m.trim()&&!ze&&(!M||!!S.trim());function Me(Ee,Ie){G(Be=>Be.map((jt,Dn)=>Dn===Ee?{...jt,...Ie}:jt))}function wt(Ee){G(Ie=>{const Be=Ie.filter((jt,Dn)=>Dn!==Ee);return Be.length===0&&(X(!1),ye(!1)),Be})}function He(){G(Ee=>[...Ee,_i(J)])}function qe(Ee){Y(Ee),G([_i(Ee)])}function nt(){return R.flatMap(Ee=>{const Ie=nN(Ee);return Ie?[Ie]:[]})}function ft(){return ue?confirm(`Yolo mode is enabled. The agent will auto-approve all tool calls — it can read, write, delete files, run arbitrary commands, and access the network without asking for permission.
|
|
117
117
|
|
|
118
|
-
Are you sure you want to continue?`):!0}async function Mt(){_e("save"),N(null);try{const Ee=ve?"task.update":"task.create",Ie={user_prompt:m,agent:y,triggers:nt(),triggers_enabled:T,requires_confirmation:K,yolo_mode:ue,foreground_mode:I,command:M?S:""};ve&&(Ie.id=e.id);const Be=await c(Ee,Ie,{timeout:13e4});return Be.error?(N(Be.error),null):(ve||localStorage.setItem("palmier:lastAgent",y),a(Be),Be)}catch(Ee){return N(Ee instanceof Error?Ee.message:String(Ee)),null}finally{_e(null)}}async function xr(){_e("run"),N(null);try{const Ie=await c("task.run_oneoff",{user_prompt:m,agent:y,requires_confirmation:K,yolo_mode:ue,foreground_mode:I,command:M?S:""});if(Ie.error){N(Ie.error);return}localStorage.setItem("palmier:lastAgent",y),l(Ie.task_id,Ie.run_id),u()}catch(Ee){N(Ee instanceof Error?Ee.message:String(Ee))}finally{_e(null)}}return w.jsx("div",{className:"task-form-overlay",children:w.jsx("div",{className:"task-form",children:D?w.jsx(XO,{body:b,permissions:e==null?void 0:e.permissions}):w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"task-form-header",children:w.jsx("h2",{children:e?"Edit Task":"New Task"})}),se&&w.jsx("div",{className:"form-error",children:se}),w.jsx("textarea",{autoFocus:!e,className:"form-textarea",value:m,onChange:Ee=>d(Ee.target.value),placeholder:M?"If the input email contains an event, create a calendar entry for it.":"Research today's top AI news and write a summary.",rows:4,disabled:O}),w.jsxs("div",{className:"plan-actions",children:[B&&w.jsx("button",{className:"btn btn-link",onClick:()=>$(!0),children:"Execution Plan"}),w.jsxs("div",{className:"agent-picker-section-inline",style:{marginLeft:"auto"},children:[w.jsx("span",{className:"agent-picker-label",children:"Run with"}),w.jsx("select",{className:"form-select form-select-sm",value:y,onChange:Ee=>g(Ee.target.value),children:n.map(Ee=>w.jsx("option",{value:Ee.key,children:Ee.label},Ee.key))})]})]}),w.jsxs("div",{className:"toggles-group",children:[w.jsxs("div",{className:`command-section${M?" command-section-active":""}`,children:[w.jsxs("label",{className:"toggle-label",children:[w.jsx("input",{type:"checkbox",checked:M,onChange:Ee=>{W(Ee.target.checked),Ee.target.checked?setTimeout(()=>{var Ie;return(Ie=fe.current)==null?void 0:Ie.focus()},0):he("")},disabled:O}),"Reactive"]}),M&&w.jsxs(w.Fragment,{children:[w.jsx("p",{className:"command-help-text",children:"Runs a command and invokes the task for each line of output. Use “the input” in your task description to reference each line."}),w.jsx("input",{ref:fe,className:"form-input form-input-mono",type:"text",value:S,onChange:Ee=>he(Ee.target.value),placeholder:"gws gmail +watch --project my-project",disabled:O})]})]}),r==="win32"&&w.jsxs("label",{className:"toggle-label",children:[w.jsx("input",{type:"checkbox",checked:I,onChange:Ee=>ae(Ee.target.checked),disabled:O}),"Run in the foreground (host must login to Windows)"]}),w.jsxs("label",{className:"toggle-label",children:[w.jsx("input",{type:"checkbox",checked:ue,onChange:Ee=>q(Ee.target.checked),disabled:O}),"Yolo mode"]}),ue&&w.jsx("p",{className:"command-help-text",children:"The agent will auto-approve all tool calls without asking for permission."}),w.jsxs("div",{className:"triggers-section",children:[w.jsxs("label",{className:"toggle-label",children:[w.jsx("input",{type:"checkbox",checked:T,onChange:Ee=>{Ee.target.checked?(X(!0),R.length===0&&He()):(X(!1),ye(!1),G(Ie=>{const Be=Ie.filter(jt=>jt.schedule==="once"?jt.onceDate&&new Date(`${jt.onceDate}T${jt.onceTime}`)>new Date:!0);return Be.length===1&&Be[0].schedule==="daily"&&Be[0].time==="00:00"?[]:Be}))},disabled:O}),"Enable schedule"]}),w.jsxs("div",{className:`triggers-section-body${T?"":" disabled"}`,children:[R.length>0&&w.jsxs("select",{className:"form-select",value:J,disabled:!T,onChange:Ee=>qe(Ee.target.value),children:[w.jsx("option",{value:"once",children:"Specific Time"}),w.jsx("option",{value:"hourly",children:"Hourly"}),w.jsx("option",{value:"daily",children:"Daily"}),w.jsx("option",{value:"weekly",children:"Weekly"}),w.jsx("option",{value:"monthly",children:"Monthly"})]}),J!=="hourly"&&R.map((Ee,Ie)=>w.jsxs("div",{className:"trigger-row-card",children:[w.jsxs("div",{className:"trigger-row-content",children:[J==="daily"&&w.jsx("input",{className:"form-input",type:"time",value:Ee.time,disabled:!T,onChange:Be=>Me(Ie,{time:Be.target.value})}),J==="weekly"&&w.jsxs("div",{className:"trigger-row-top",children:[w.jsx("select",{className:"form-select",value:Ee.dayOfWeek,disabled:!T,onChange:Be=>Me(Ie,{dayOfWeek:Be.target.value}),children:WO.map((Be,jt)=>w.jsx("option",{value:String(jt),children:Be},jt))}),w.jsx("input",{className:"form-input",type:"time",value:Ee.time,disabled:!T,onChange:Be=>Me(Ie,{time:Be.target.value})})]}),J==="monthly"&&w.jsxs("div",{className:"trigger-row-top",children:[w.jsx("select",{className:"form-select",value:Ee.dayOfMonth,disabled:!T,onChange:Be=>Me(Ie,{dayOfMonth:Be.target.value}),children:Array.from({length:28},(Be,jt)=>jt+1).map(Be=>w.jsxs("option",{value:String(Be),children:["Day ",Be]},Be))}),w.jsx("input",{className:"form-input",type:"time",value:Ee.time,disabled:!T,onChange:Be=>Me(Ie,{time:Be.target.value})})]}),J==="once"&&w.jsxs("div",{className:"trigger-row-top",children:[w.jsx("input",{className:"form-input",type:"date",value:Ee.onceDate,min:new Date().toISOString().split("T")[0],disabled:!T,onChange:Be=>Me(Ie,{onceDate:Be.target.value})}),w.jsx("input",{className:"form-input",type:"time",value:Ee.onceTime,min:Ee.onceDate===new Date().toISOString().split("T")[0]?new Date().toTimeString().slice(0,5):void 0,disabled:!T,onChange:Be=>Me(Ie,{onceTime:Be.target.value})})]})]}),R.length>1&&w.jsx("button",{className:"trigger-remove-btn",onClick:()=>wt(Ie),disabled:!T,title:"Remove trigger",children:"×"})]},Ie)),R.length>0&&J!=="hourly"&&w.jsx("button",{className:"trigger-add-btn",onClick:He,disabled:!T,children:"+ Add"})]})]}),T&&R.length>0&&w.jsxs("label",{className:"toggle-label",children:[w.jsx("input",{type:"checkbox",checked:K,onChange:Ee=>ye(Ee.target.checked),disabled:O}),"Confirm before each run"]})]}),!ue&&(()=>{const Ee=n.find(Ie=>Ie.key===y);return(Ee==null?void 0:Ee.supportsPermissions)===!1&&w.jsxs("div",{className:"form-warning",children:["Palmier does not support runtime permission granting for ",Ee.label,". The task may fail if required permissions are not pre-configured."]})})(),w.jsxs("div",{className:"form-actions",children:[(()=>{const Ee=R.length>0,Ie=!!m.trim()&&(!M||!!S.trim());return ve?Te?w.jsxs("button",{className:"btn btn-primary",onClick:()=>ft()&&Mt(),disabled:!ke||O,children:[ge==="save"&&w.jsx("span",{className:"btn-spinner"}),"Save"]}):w.jsx("button",{className:"btn btn-primary",disabled:!0,children:"Save"}):Ee?w.jsxs("button",{className:"btn btn-primary",onClick:()=>ft()&&Mt(),disabled:!ke||O,children:[ge==="save"&&w.jsx("span",{className:"btn-spinner"}),"Schedule"]}):w.jsxs(w.Fragment,{children:[w.jsxs("button",{className:"btn btn-primary",onClick:()=>ft()&&xr(),disabled:!Ie||O,children:[ge==="run"&&w.jsx("span",{className:"btn-spinner"}),"Run"]}),w.jsx("button",{className:"btn btn-secondary",onClick:()=>ft()&&Mt(),disabled:!ke||O,children:"Save"})]})})(),w.jsx("button",{className:"btn btn-secondary",onClick:()=>{Te&&m.trim()&&!confirm("You have unsaved changes. Discard?")||u()},style:{marginLeft:"auto"},children:"Cancel"})]})]})})})}const iN="0.6.7";function aN(e,n){if(e.includes("-"))return!1;const r=e.split(".").map(Number),a=n.split(".").map(Number);for(let l=0;l<3;l++){if((r[l]??0)<(a[l]??0))return!0;if((r[l]??0)>(a[l]??0))return!1}return!1}function sN({connected:e,hostId:n,request:r,subscribeEvents:a,onViewRun:l,onUpdateRequired:u,onVersion:c,onLocationClientToken:f}){const[m,d]=U.useState([]),[y,g]=U.useState(!1),[b,x]=U.useState(null),[k,L]=U.useState(new Map),[B,D]=U.useState(new Map),[$,V]=U.useState(new Map),[se,N]=U.useState(new Map),[R,G]=U.useState(new Map),[J,Y]=U.useState(!1),[T,X]=U.useState(void 0),[K,ye]=U.useState([]),[ue,q]=U.useState(),I=U.useCallback(()=>{Y(!1),X(void 0)},[]),ae=U.useCallback(async()=>{var S,he;if(e){g(!0),x(null);try{const fe=await r("task.list"),ve=fe.tasks??[],Te=new Map,ze=new Map,ke=new Map,Me=new Map,wt=new Map;for(const qe of ve)qe.status&&(Te.set(qe.id,qe.status),(S=qe.status.pending_permission)!=null&&S.length&&ke.set(qe.id,qe.status.pending_permission),(he=qe.status.pending_input)!=null&&he.length&&(Me.set(qe.id,{questions:qe.status.pending_input}),wt.set(qe.id,new Array(qe.status.pending_input.length).fill(""))));L(Te),D(ze),V(ke),N(Me),G(wt),d(ve),ye(fe.agents??[]),q(fe.host_platform),k2(fe.agents??[]);const He=fe.version??null;c==null||c(He),f==null||f(fe.location_client_token??null),u==null||u(!!He&&aN(He,iN))}catch(fe){const ve=fe instanceof Error?fe.message:String(fe);ve==="Not connected"||ve.includes("503")||ve.toLowerCase().includes("no responders")?x(null):x(ve),d([])}finally{g(!1)}}},[e,n,r]);U.useEffect(()=>{e?ae():(d([]),g(!1))},[e,n,ae]),U.useEffect(()=>{if(!e||!n)return;const S={decode:fe=>new TextDecoder().decode(fe)};return a(n,async fe=>{var wt;const ve=fe.subject.split(".");if(ve.length<3)return;const Te=ve.slice(2).join(".");let ze={};try{ze=JSON.parse(S.decode(fe.data))}catch{return}const ke=ze.event_type,Me=ze.session_id;if(ke==="input-request"&&Me){const He=ze.input_questions,qe=ze.agent_name,nt=ze.description;He!=null&&He.length&&(N(ft=>{if(ft.has(Me))return ft;const Mt=new Map(ft);return Mt.set(Me,{questions:He,description:nt,agentName:qe}),Mt}),G(ft=>{if(ft.has(Me))return ft;const Mt=new Map(ft);return Mt.set(Me,new Array(He.length).fill("")),Mt}));return}if(ke==="input-resolved"&&Me){N(He=>{if(!He.has(Me))return He;const qe=new Map(He);return qe.delete(Me),qe}),G(He=>{const qe=new Map(He);return qe.delete(Me),qe});return}if(ke==="confirm-request"&&Me){const He=ze.description,qe=ze.agent_name;He&&D(nt=>{if(nt.has(Me))return nt;const ft=new Map(nt);return ft.set(Me,{description:He,agentName:qe}),ft});return}if(ke==="confirm-resolved"&&Me){D(He=>{if(!He.has(Me))return He;const qe=new Map(He);return qe.delete(Me),qe});return}if(ke==="permission-resolved"){V(He=>{if(!He.has(Te))return He;const qe=new Map(He);return qe.delete(Te),qe});return}try{const He=await r("task.status",{id:Te},{timeout:5e3});if(He.error)return;L(qe=>{const nt=new Map(qe);return nt.set(Te,He),nt}),(wt=He.pending_permission)!=null&&wt.length&&V(qe=>{if(qe.has(Te))return qe;const nt=new Map(qe);return nt.set(Te,He.pending_permission),nt})}catch{}})},[e,n,a,r]);async function ge(S,he){try{await r("task.user_input",{id:S,value:[he]})}catch(fe){console.error("[TaskListView] Failed to respond to confirmation:",fe)}}async function _e(S,he){try{await r("task.user_input",{id:S,value:[he]})}catch(fe){console.error("[TaskListView] Failed to respond to permission request:",fe)}}async function O(S,he){try{await r("task.user_input",{id:S,value:he})}catch(fe){console.error("[TaskListView] Failed to respond to input request:",fe)}}function M(S){d(he=>{const fe=he.findIndex(ve=>ve.id===S.id);if(fe>=0){const ve=[...he];return ve[fe]=S,ve}return[S,...he]}),Y(!1),X(void 0)}function W(S){d(he=>he.filter(fe=>fe.id!==S)),L(he=>{const fe=new Map(he);return fe.delete(S),fe}),N(he=>{const fe=new Map(he);return fe.delete(S),fe}),G(he=>{const fe=new Map(he);return fe.delete(S),fe})}return w.jsxs(w.Fragment,{children:[b&&w.jsxs("div",{className:"form-error",children:[b,b.toLowerCase().includes("failed to fetch")&&w.jsxs(w.Fragment,{children:[" ",w.jsx("a",{href:"#",onClick:S=>{S.preventDefault(),window.location.reload()},children:"Reload"})]})]}),w.jsx("div",{className:"new-task-input-card",onClick:()=>{X(void 0),Y(!0)},role:"button",tabIndex:0,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(X(void 0),Y(!0))},children:w.jsx("span",{className:"new-task-placeholder",children:"Describe your new task..."})}),y&&!m.length?w.jsx("div",{className:"task-list",children:[0,1,2].map(S=>w.jsxs("div",{className:"task-card",style:{pointerEvents:"none"},children:[w.jsx("div",{className:"task-card-header",children:w.jsxs("div",{className:"task-card-title-row",children:[w.jsx("div",{className:"skeleton-line",style:{width:10,height:10,borderRadius:"50%"}}),w.jsx("div",{className:"skeleton-line",style:{width:`${60+S*12}%`}})]})}),w.jsxs("div",{className:"task-card-meta",children:[w.jsx("div",{className:"skeleton-line",style:{width:"30%"}}),w.jsx("div",{className:"skeleton-line",style:{width:"25%"}})]})]},S))}):w.jsx("div",{className:"task-list",children:m.map(S=>w.jsx(C2,{task:S,lastEvent:k.get(S.id),onEdit:async he=>{try{const fe=await r("task.get",{id:he.id});X(fe.error?he:fe)}catch{X(he)}Y(!0)},onDelete:W,onViewRun:l},S.id))}),J&&w.jsx(rN,{initial:T,agents:K,hostPlatform:ue,onSaved:M,onRun:l,onCancel:I}),du.createPortal(w.jsxs(w.Fragment,{children:[[...B.entries()].map(([S,{description:he,agentName:fe}])=>{var Te;const ve=fe||((Te=m.find(ze=>ze.id===S))==null?void 0:Te.name);return w.jsx("div",{className:"confirm-modal-overlay",children:w.jsxs("div",{className:"confirm-modal",children:[w.jsx("h2",{className:"confirm-modal-title",children:"Confirmation Required"}),ve&&w.jsx("p",{className:"confirm-modal-subtitle",children:ve}),w.jsx("p",{className:"confirm-modal-message",children:he}),w.jsxs("div",{className:"confirm-modal-actions",children:[w.jsx("button",{className:"btn btn-primary",onClick:()=>ge(S,"confirmed"),children:"Confirm"}),w.jsx("button",{className:"btn btn-secondary",onClick:()=>ge(S,"aborted"),children:"Abort"})]})]})},S)}),[...$.entries()].map(([S,he])=>{const fe=m.find(ve=>ve.id===S);return w.jsx("div",{className:"confirm-modal-overlay",children:w.jsxs("div",{className:"confirm-modal permission-modal",children:[w.jsx("h2",{className:"confirm-modal-title",children:"Permission Required"}),w.jsx("p",{className:"confirm-modal-message",children:w.jsx("strong",{children:(fe==null?void 0:fe.name)||(fe==null?void 0:fe.user_prompt)||S})}),w.jsx("div",{className:"permission-list",children:he.map((ve,Te)=>w.jsxs("div",{className:"permission-item",children:[w.jsx("span",{className:"permission-name",children:ve.name}),ve.description&&w.jsx("span",{className:"permission-desc",children:ve.description})]},Te))}),w.jsxs("div",{className:"permission-actions",children:[w.jsx("button",{className:"btn btn-primary",onClick:()=>_e(S,"granted"),children:"Allow Once"}),w.jsx("button",{className:"btn btn-secondary",onClick:()=>_e(S,"granted_all"),children:"Allow Always"})]}),w.jsx("button",{className:"permission-abort-link",onClick:()=>_e(S,"aborted"),children:"Deny & Abort Task"})]})},S)}),[...se.entries()].map(([S,{questions:he,description:fe,agentName:ve}])=>{var ke;const Te=R.get(S)??new Array(he.length).fill(""),ze=ve||((ke=m.find(Me=>Me.id===S))==null?void 0:ke.name);return w.jsx("div",{className:"confirm-modal-overlay",children:w.jsxs("div",{className:"confirm-modal input-modal",children:[w.jsx("h2",{className:"confirm-modal-title",children:"Input Required"}),ze&&w.jsx("p",{className:"confirm-modal-subtitle",children:ze}),fe&&w.jsx("p",{className:"confirm-modal-message",children:fe}),w.jsx("div",{className:"input-list",children:he.map((Me,wt)=>w.jsxs("div",{className:"input-item",children:[w.jsx("label",{className:"input-label",children:Me}),w.jsx("input",{type:"text",className:"input-field",value:Te[wt]??"",onChange:He=>{G(qe=>{const nt=new Map(qe),ft=[...nt.get(S)??[]];return ft[wt]=He.target.value,nt.set(S,ft),nt})},autoFocus:wt===0})]},wt))}),w.jsx("div",{className:"input-actions",children:w.jsx("button",{className:"btn btn-primary",disabled:Te.some(Me=>!Me.trim()),onClick:()=>O(S,Te),children:"Submit"})}),w.jsx("button",{className:"permission-abort-link",onClick:()=>O(S,["aborted"]),children:"Cancel"})]})},S)})]}),document.body)]})}function lN(){const e=ta(),r=br().pathname.startsWith("/runs");return w.jsxs(w.Fragment,{children:[w.jsxs("button",{className:`tab-btn ${r?"":"tab-btn-active"}`,onClick:()=>e("/"),children:[w.jsxs("svg",{className:"tab-icon",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[w.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),w.jsx("path",{d:"M5.5 8L7 9.5L10.5 6"})]}),"Tasks"]}),w.jsxs("button",{className:`tab-btn ${r?"tab-btn-active":""}`,onClick:()=>e("/runs"),children:[w.jsx("svg",{className:"tab-icon",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:w.jsx("path",{d:"M2 8H4.5L6 4L8 12L10 6L11.5 8H14"})}),"Runs"]})]})}const oN="modulepreload",uN=function(e){return"/"+e},ub={},uv=function(n,r,a){let l=Promise.resolve();if(r&&r.length>0){let c=function(d){return Promise.all(d.map(y=>Promise.resolve(y).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),m=(f==null?void 0:f.nonce)||(f==null?void 0:f.getAttribute("nonce"));l=c(r.map(d=>{if(d=uN(d),d in ub)return;ub[d]=!0;const y=d.endsWith(".css"),g=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${g}`))return;const b=document.createElement("link");if(b.rel=y?"stylesheet":oN,y||(b.as="script"),b.crossOrigin="",b.href=d,m&&b.setAttribute("nonce",m),document.head.appendChild(b),y)return new Promise((x,k)=>{b.addEventListener("load",x),b.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${d}`)))})}))}function u(c){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=c,window.dispatchEvent(f),!f.defaultPrevented)throw c}return l.then(c=>{for(const f of c||[])f.status==="rejected"&&u(f.reason);return n().catch(u)})},cN=ls("App",{web:()=>uv(()=>import("./web-6UChJFov.js"),[]).then(e=>new e.AppWeb)}),cv=ls("Preferences",{web:()=>uv(()=>import("./web-NxTETXZK.js"),[]).then(e=>new e.PreferencesWeb)});function fv(e){const[n,r]=U.useState(()=>window.matchMedia(e).matches);return U.useEffect(()=>{const a=window.matchMedia(e),l=u=>r(u.matches);return a.addEventListener("change",l),r(a.matches),()=>a.removeEventListener("change",l)},[e]),n}const au=ji.isNativePlatform()?ls("LocationPermission"):null,cb=!!window.__PALMIER_SERVE__,fb=ji.isNativePlatform();function hb({daemonVersion:e,locationClientToken:n,activeClientToken:r,request:a,onLocationClientTokenChange:l}){var O;const{pairedHosts:u,activeHostId:c,setActiveHostId:f,removePairedHost:m,renamePairedHost:d}=Ol(),y=ta(),g=fv("(min-width: 768px)"),[b,x]=U.useState(!1),[k,L]=U.useState(!1),[B,D]=U.useState(null),[$,V]=U.useState(""),[se,N]=U.useState(null),[R,G]=U.useState(!1),J=!!(r&&n===r);U.useEffect(()=>{if(!fb||!au||!a)return;function M(){J&&au.check().then(({fine:S})=>{S||a("device.location.disable").then(()=>{l==null||l(null)}).catch(()=>{})})}M();const W=cN.addListener("resume",()=>{M()});return()=>{W.then(S=>S.remove())}},[J,r]);async function Y(){if(a){G(!0);try{if(J)await a("device.location.disable"),l==null||l(null);else{if(au&&!(await au.request()).fine)return;const{value:M}=await cv.get({key:"fcmToken"});if(!M){console.warn("No FCM token available");return}await a("device.location.enable",{fcmToken:M}),l==null||l(r??null)}}catch(M){console.error("Failed to toggle location:",M)}finally{G(!1)}}}const T=U.useRef(null),X=U.useRef(null),K=U.useCallback(()=>{L(!0)},[]);function ye(){k&&(x(!1),L(!1))}function ue(){L(!1),x(!0)}function q(M,W){D(M),V(W)}function I(){B&&$.trim()&&d(B,$.trim()),D(null),V("")}function ae(){D(null),V("")}U.useEffect(()=>{B&&X.current&&(X.current.focus(),X.current.select())},[B]),U.useEffect(()=>{if(!b||k)return;function M(W){W.key==="Escape"&&K()}return document.addEventListener("keydown",M),()=>{document.removeEventListener("keydown",M)}},[b,k,K]);const ge=w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"drawer-header",children:[w.jsx("span",{className:"drawer-title",children:"Palmier"}),!g&&w.jsx("button",{className:"drawer-close-btn",onClick:K,"aria-label":"Close menu",children:w.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:w.jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]}),!cb&&u.length>0&&w.jsxs("div",{className:"drawer-section",children:[w.jsx("h3",{className:"drawer-section-label",children:"Hosts"}),w.jsx("div",{className:"host-picker-inline",children:w.jsx("div",{className:"host-picker-list",role:"listbox",children:u.map(M=>{const W=M.hostId===c,S=B===M.hostId,he=M.name||M.hostId.slice(0,8);return w.jsx("div",{className:"host-picker-item-wrapper",children:w.jsxs("div",{className:`host-picker-item ${W?"host-picker-item-active":""}`,onClick:()=>{S||W||(f(M.hostId),g||K())},role:"option","aria-selected":W,children:[S?w.jsx("input",{ref:X,className:"form-input host-picker-rename-input",type:"text",value:$,onChange:fe=>V(fe.target.value),onKeyDown:fe=>{fe.key==="Enter"&&I(),fe.key==="Escape"&&ae()},onBlur:I,onClick:fe=>fe.stopPropagation()}):w.jsx("span",{className:"host-picker-item-name",children:he}),w.jsxs("div",{className:"host-picker-item-actions",children:[W&&!S&&w.jsx("button",{className:"host-picker-edit-btn",onClick:fe=>{fe.stopPropagation(),q(M.hostId,he)},"aria-label":"Rename host",children:w.jsx("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:w.jsx("path",{d:"M9.5 1.5L11.5 3.5M1.5 11.5L2 9L9 2L11 4L4 11L1.5 11.5Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}),!W&&w.jsx("button",{className:"host-picker-delete-btn",onClick:fe=>{fe.stopPropagation(),N(M.hostId)},"aria-label":`Unpair ${he}`,children:w.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:w.jsx("path",{d:"M4 5.5V11C4 11.2761 4.22386 11.5 4.5 11.5H9.5C9.77614 11.5 10 11.2761 10 11V5.5M3 4H11M5.5 4V3C5.5 2.72386 5.72386 2.5 6 2.5H8C8.27614 2.5 8.5 2.72386 8.5 3V4M6.5 6.5V9.5M7.5 6.5V9.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})},M.hostId)})})})]}),!cb&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"drawer-divider"}),w.jsx("div",{className:"drawer-section",children:w.jsx("button",{className:"btn btn-primary btn-full",onClick:()=>{y("/pair"),g||K()},children:"Pair New Host"})})]}),fb&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"drawer-divider"}),w.jsx("div",{className:"drawer-section",children:w.jsxs("label",{className:"drawer-toggle",children:[w.jsx("span",{className:"drawer-toggle-label",children:"Location Access"}),w.jsx("button",{className:`toggle-switch ${J?"toggle-switch-on":""}`,onClick:Y,disabled:R,role:"switch","aria-checked":J,children:w.jsx("span",{className:"toggle-switch-thumb"})})]})})]}),w.jsxs("div",{className:"drawer-footer",children:[e&&w.jsxs("div",{className:"drawer-version",children:["Palmier v",e]}),w.jsxs("div",{className:"drawer-legal",children:[w.jsx("a",{href:"https://www.palmier.me/terms",target:"_blank",rel:"noopener noreferrer",children:"Terms"}),w.jsx("span",{className:"drawer-legal-sep",children:"·"}),w.jsx("a",{href:"https://www.palmier.me/privacy",target:"_blank",rel:"noopener noreferrer",children:"Privacy"})]})]})]}),_e=se&&du.createPortal(w.jsx("div",{className:"confirm-modal-overlay",onClick:()=>N(null),children:w.jsxs("div",{className:"confirm-modal",onClick:M=>M.stopPropagation(),children:[w.jsx("h2",{className:"confirm-modal-title",children:"Delete host?"}),w.jsxs("p",{className:"confirm-modal-message",children:['"',((O=u.find(M=>M.hostId===se))==null?void 0:O.name)||se.slice(0,8),'" will be unpaired from this device.']}),w.jsxs("div",{className:"confirm-modal-actions",children:[w.jsx("button",{className:"btn btn-secondary",onClick:()=>N(null),children:"Cancel"}),w.jsx("button",{className:"btn btn-danger",onClick:()=>{m(se),N(null)},children:"Delete"})]})]})}),document.body);return g?w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"drawer-panel drawer-panel-desktop",ref:T,children:ge}),_e]}):w.jsxs(w.Fragment,{children:[w.jsx("button",{className:"hamburger-btn",onClick:ue,"aria-label":"Open menu",children:w.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:w.jsx("path",{d:"M3 5H17M3 10H17M3 15H17",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),b&&du.createPortal(w.jsx("div",{className:`drawer-overlay ${k?"drawer-overlay-closing":""}`,onClick:K,onAnimationEnd:ye,children:w.jsx("div",{className:`drawer-panel ${k?"drawer-panel-closing":""}`,ref:T,onClick:M=>M.stopPropagation(),children:ge})}),document.body),_e]})}const fN=10;function hN({connected:e,hostId:n,request:r,subscribeEvents:a,filterTaskId:l,onClearFilter:u}){const[c,f]=U.useState([]),[m,d]=U.useState(0),[y,g]=U.useState(!1),[b,x]=U.useState(!1),k=ta(),L=U.useRef(null),B=U.useCallback(N=>{const R={offset:N,limit:fN};return l&&(R.task_id=l),R},[l]),D=U.useCallback(async(N,R)=>{if(e){R?x(!0):g(!0);try{const G=await r("taskrun.list",B(N)),J=G.entries??[];d(G.total??0),f(R?Y=>{const T=new Set(Y.map(K=>`${K.task_id}:${K.run_id}`)),X=J.filter(K=>!T.has(`${K.task_id}:${K.run_id}`));return[...Y,...X]}:J)}catch(G){G instanceof Error&&G.message==="Not connected"||console.error("Failed to load runs:",G)}finally{g(!1),x(!1)}}},[e,r,B]);U.useEffect(()=>{e?(f([]),d(0),D(0,!1)):(f([]),d(0))},[e,n,D,l]),U.useEffect(()=>!e||!n?void 0:a(n,async R=>{try{const G=JSON.parse(new TextDecoder().decode(R.data));if(G.event_type==="running-state"&&G.running_state&&["monitoring","started","finished","failed","aborted"].includes(G.running_state)){const J=await r("taskrun.list",B(0)),Y=J.entries??[];d(J.total??0),f(T=>{const X=new Map(Y.map(q=>[`${q.task_id}:${q.run_id}`,q])),K=T.map(q=>{const I=`${q.task_id}:${q.run_id}`;return X.get(I)??q}),ye=new Set(K.map(q=>`${q.task_id}:${q.run_id}`));return[...Y.filter(q=>!ye.has(`${q.task_id}:${q.run_id}`)),...K]})}}catch{}}),[e,n,a,r]),U.useEffect(()=>{const N=L.current;if(!N)return;const R=new IntersectionObserver(G=>{G[0].isIntersecting&&!b&&c.length<m&&D(c.length,!0)},{threshold:.1});return R.observe(N),()=>R.disconnect()},[c.length,m,b,D]);function $(N,R){if(!N||!R)return"";const G=Math.round((R-N)/1e3);if(G<60)return`${G}s`;const J=Math.floor(G/60),Y=G%60;return`${J}m ${Y}s`}const V={monitoring:"Monitoring",started:"Running",finished:"Finished",failed:"Failed",aborted:"Aborted"};function se(N){if(N==="failed")return"var(--color-error)";if(N==="aborted")return"var(--color-warning, #d97706)"}return y&&c.length===0&&e?w.jsx("div",{className:"task-list",children:[0,1,2].map(N=>w.jsxs("div",{className:"task-card",style:{pointerEvents:"none"},children:[w.jsx("div",{className:"task-card-header",children:w.jsx("div",{className:"task-card-title-row",children:w.jsx("div",{className:"skeleton-line",style:{width:`${70+N*10}%`}})})}),w.jsx("div",{className:"task-card-meta",children:w.jsx("div",{className:"skeleton-line",style:{width:"45%"}})})]},N))}):!e||y&&c.length===0?w.jsx("div",{className:"runs-view",children:w.jsxs("div",{className:"empty-state",children:[w.jsx("p",{className:"empty-state-text",children:"Runs"}),w.jsx("p",{className:"empty-state-hint",children:"Run history will appear here"})]})}):c.length===0?w.jsxs(w.Fragment,{children:[l&&u&&w.jsx("div",{style:{marginBottom:"var(--space-sm)"},children:w.jsxs("span",{className:"runs-filter-chip",children:["Filtered by task",w.jsx("button",{onClick:u,"aria-label":"Clear filter",children:"×"})]})}),w.jsx("div",{className:"runs-view",children:w.jsxs("div",{className:"empty-state",children:[w.jsx("p",{className:"empty-state-text",children:"No runs yet"}),w.jsx("p",{className:"empty-state-hint",children:l?"This task hasn't been executed yet. Run it from the task menu or wait for its next trigger.":"Run history will appear here."})]})})]}):w.jsxs(w.Fragment,{children:[l&&u&&w.jsx("div",{style:{marginBottom:"var(--space-sm)"},children:w.jsxs("span",{className:"runs-filter-chip",children:["Filtered by task",w.jsx("button",{onClick:u,"aria-label":"Clear filter",children:"×"})]})}),w.jsxs("div",{className:"task-list",children:[c.map((N,R)=>w.jsxs("div",{className:"runs-card",onClick:()=>!N.error&&k(`/runs/${N.task_id}/${encodeURIComponent(N.run_id)}`),children:[w.jsxs("div",{className:"runs-card-body",children:[w.jsx("h3",{className:"runs-card-name",children:N.task_name||N.task_id}),w.jsxs("div",{className:"runs-card-meta",children:[w.jsx("span",{style:{color:se(N.running_state)},children:V[N.running_state??""]??N.running_state}),N.end_time&&w.jsx("span",{children:_u(N.end_time)}),N.start_time&&N.end_time&&w.jsx("span",{style:{color:"var(--color-muted)"},children:$(N.start_time,N.end_time)}),N.error&&w.jsx("span",{style:{color:"var(--color-muted)"},children:N.error})]})]}),w.jsx("span",{className:"runs-card-chevron",children:"›"})]},`${N.task_id}-${N.run_id}-${R}`)),w.jsx("div",{ref:L,style:{height:1}}),b&&w.jsx("div",{className:"loading-state",style:{padding:"var(--space-md)"},children:w.jsx("div",{className:"spinner"})})]})]})}function dN(e){P1(e,[/\r?\n|\r/g,mN])}function mN(){return{type:"break"}}function db(){return function(e){dN(e)}}function pN({connected:e,hostId:n,request:r,subscribeEvents:a,taskId:l,runId:u}){const c=ta(),[f,m]=U.useState(!0),[d,y]=U.useState([]),[g,b]=U.useState(),[x,k]=U.useState(),L=g==="started"||g==="monitoring",B=g==="followup",D=g==="started"||g==="followup",[$,V]=U.useState(null),[se,N]=U.useState(!1),[R,G]=U.useState(""),[J,Y]=U.useState(!1),T=U.useRef(null);async function X(){try{const q=await r("task.result",{id:l,run_id:u});if(q.error){console.error("No result:",q.error),c("/runs",{replace:!0});return}y(q.messages??[]),b(q.running_state),k(q.agent)}catch(q){console.error("Failed to load result:",q),c("/runs",{replace:!0})}finally{m(!1)}}async function K(q){var I;try{const ge=(I=(await r("task.reports",{id:l,run_id:u,report_files:[q]})).reports)==null?void 0:I[0];ge!=null&&ge.data_url?V({file:q,data_url:ge.data_url}):V({file:q,content:(ge==null?void 0:ge.content)??"Report not found."})}catch{V({file:q,content:"Failed to load report."})}}U.useEffect(()=>{e&&(m(!0),X())},[e,l,u]),U.useEffect(()=>!e||!n?void 0:a(n,async I=>{try{const ae=JSON.parse(new TextDecoder().decode(I.data));if(ae.event_type!=="running-state"&&ae.event_type!=="result-updated"||I.subject.split(".").pop()!==l||ae.event_type==="result-updated"&&ae.run_id&&ae.run_id!==u)return;X()}catch{}}),[e,n,l,a,r]),U.useEffect(()=>{T.current&&(T.current.scrollTop=T.current.scrollHeight)},[d]);function ye(q){if(q==="input")return"User Input";if(q==="permission")return"Permission";if(q==="confirmation")return"Confirmation"}function ue(q){return q==="started"?"Task started":q==="finished"?"Task finished":q==="failed"?"Task failed":q==="error"?"Command failed":q==="aborted"?"Task aborted":q==="confirmation"?"Task confirmed":q==="stopped"?"Follow-up stopped":q??""}return w.jsxs("div",{className:"run-detail",children:[w.jsxs("button",{className:"run-detail-back",onClick:()=>c(-1),children:[w.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:w.jsx("path",{d:"M15 18l-6-6 6-6"})}),"Back"]}),f?w.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)",padding:"var(--space-sm) 0"},children:[w.jsx("div",{className:"skeleton-line",style:{width:"40%"}}),w.jsx("div",{className:"skeleton-line",style:{width:"55%"}}),w.jsx("div",{className:"skeleton-line",style:{width:"100%",height:"8rem",marginTop:"var(--space-sm)"}})]}):w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"chat-thread",ref:T,children:[d.map((q,I)=>{const ae=D&&q.role==="assistant"&&!d.slice(I+1).some(ge=>ge.role==="assistant"||ge.role==="user");return q.role==="status"&&q.type==="monitoring"?null:q.role==="status"?w.jsxs("div",{className:`chat-status${q.type==="error"?" chat-status--error":""}`,children:[w.jsxs("div",{children:[ue(q.type),q.time>0&&w.jsx("span",{className:"chat-status-time",children:_u(q.time)})]}),q.content&&w.jsx("pre",{className:"chat-status-detail",children:q.content})]},I):w.jsxs("div",{className:`chat-message chat-message--${q.role}`,children:[q.role==="assistant"&&x&&w.jsx("div",{className:"chat-message-agent",children:Yh(x)}),w.jsxs("div",{className:"chat-message-content",children:[w.jsx(rd,{remarkPlugins:[ad,db],children:q.content}),ae&&w.jsxs("div",{className:"chat-typing-indicator",children:[w.jsx("span",{}),w.jsx("span",{}),w.jsx("span",{})]})]}),q.attachments&&q.attachments.length>0&&w.jsx("div",{className:"chat-message-attachments",children:q.attachments.map(ge=>w.jsx("button",{className:"chat-attachment-chip",onClick:()=>K(ge),children:ge},ge))}),w.jsxs("div",{className:"chat-message-meta",children:[ye(q.type)&&w.jsx("span",{className:"chat-message-type",children:ye(q.type)}),q.time>0&&w.jsx("span",{children:_u(q.time)})]})]},I)}),D&&(()=>{const q=d.filter(I=>I.role!=="status");return q.length===0||q[q.length-1].role!=="assistant"})()&&w.jsxs("div",{className:"chat-message chat-message--assistant",children:[x&&w.jsx("div",{className:"chat-message-agent",children:Yh(x)}),w.jsxs("div",{className:"chat-typing-indicator",children:[w.jsx("span",{}),w.jsx("span",{}),w.jsx("span",{})]})]}),g==="monitoring"&&w.jsxs("div",{className:"chat-monitoring-indicator",children:[w.jsx("span",{className:"chat-monitoring-dot"}),"Monitoring command output"]})]}),L?w.jsx("div",{className:"chat-abort-bar",children:w.jsx("button",{className:"btn btn-secondary chat-abort-btn",disabled:se,onClick:async()=>{if(confirm("Abort this task?")){N(!0);try{await r("task.abort",{id:l})}catch(q){console.error("Abort failed:",q)}finally{N(!1)}}},children:se?"Aborting...":"Abort Task"})}):B?w.jsx("div",{className:"chat-input-bar",children:w.jsx("button",{className:"btn btn-secondary chat-stop-btn",disabled:se,onClick:async()=>{N(!0);try{await r("task.stop_followup",{id:l,run_id:u})}catch(q){console.error("Stop failed:",q)}finally{N(!1)}},children:w.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:w.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})})}):w.jsxs("form",{className:"chat-input-bar",onSubmit:async q=>{q.preventDefault();const I=R.trim();if(!(!I||J)){Y(!0);try{await r("task.followup",{id:l,run_id:u,message:I}),G("")}catch(ae){console.error("Follow-up failed:",ae)}finally{Y(!1)}}},children:[w.jsx("input",{className:"chat-input",type:"text",placeholder:"Follow-up message",value:R,onChange:q=>G(q.target.value),disabled:J}),w.jsx("button",{className:"btn btn-primary chat-send-btn",type:"submit",disabled:!R.trim()||J,children:w.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[w.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),w.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]}),$&&w.jsx("div",{className:"report-dialog-overlay",onClick:()=>V(null),children:w.jsxs("div",{className:"report-dialog",onClick:q=>q.stopPropagation(),children:[w.jsxs("div",{className:"report-dialog-header",children:[w.jsx("span",{className:"report-dialog-title",children:$.file}),w.jsx("button",{className:"report-dialog-close",onClick:()=>V(null),"aria-label":"Close",children:w.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[w.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),w.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),w.jsx("div",{className:"report-dialog-body",children:$.data_url?w.jsx("img",{src:$.data_url,alt:$.file,style:{maxWidth:"100%",height:"auto"}}):w.jsx(rd,{remarkPlugins:[ad,db],components:{a:({...q})=>w.jsx("a",{...q,target:"_blank",rel:"noopener noreferrer"})},children:$.content??""})})]})})]})}function gN(){const{getActiveHost:e}=Ol(),n=e(),r=U.useRef(null);U.useEffect(()=>{if(ji.isNativePlatform()||!n||n.directUrl||r.current===n.hostId)return;async function a(){var l;try{if(!("serviceWorker"in navigator)||!("PushManager"in window)){console.warn("[Push] Push notifications not supported");return}const u=await navigator.serviceWorker.ready;(l=u.active)==null||l.postMessage({type:"set-host-id",hostId:n.hostId});let c=await u.pushManager.getSubscription();if(!c){const{publicKey:m}=await S2("/api/push/vapid-key");if(!m){console.warn("[Push] No VAPID public key configured on server");return}if(await Notification.requestPermission()!=="granted"){console.log("[Push] Permission denied");return}c=await u.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:m})}const f=c.toJSON();await w2("/api/push/subscribe",{hostId:n.hostId,endpoint:f.endpoint,keys:{p256dh:f.keys.p256dh,auth:f.keys.auth}}),r.current=n.hostId}catch(u){console.error("[Push] Subscription failed:",u)}}a()},[n])}function su(){var ge;const{pairedHosts:e,activeHostId:n,removePairedHost:r}=Ol(),{connected:a,request:l,subscribeEvents:u,unauthorized:c}=_d(),f=ta(),m=br(),d=hS(),y=fv("(min-width: 768px)"),g=m.pathname.startsWith("/runs"),b=d.runId?void 0:d.taskId,[x,k]=U.useState(null),L=d.runId,B=L==="latest";U.useEffect(()=>{if(!B||!d.taskId||!a){k(null);return}l("taskrun.list",{task_id:d.taskId,limit:1}).then(_e=>{var M,W;const O=(W=(M=_e.entries)==null?void 0:M[0])==null?void 0:W.run_id;k(O??null)}).catch(()=>k(null))},[B,d.taskId,a]);const D=B?x:L,$=!!(d.taskId&&D&&D!=="latest"),[V,se]=U.useState(!1),[N,R]=U.useState(!1),[G,J]=U.useState(null),[Y,T]=U.useState(null),[X,K]=U.useState(null);gN(),U.useEffect(()=>{window.scrollTo(0,0)},[n]);function ye(_e,O){f(O?`/runs/${encodeURIComponent(_e)}/${encodeURIComponent(O)}`:`/runs/${encodeURIComponent(_e)}`)}async function ue(){R(!0),J(null);try{const _e=await l("host.update");if(_e.error){J(_e.error),R(!1);return}}catch{}setTimeout(()=>window.location.reload(),1e4)}const q=e.length>0,I=q&&a&&n&&!c,ae=((ge=e.find(_e=>_e.hostId===n))==null?void 0:ge.clientToken)??null;return w.jsxs("div",{className:"dashboard",children:[y&&w.jsx(hb,{daemonVersion:Y,locationClientToken:X,activeClientToken:ae,request:l,onLocationClientTokenChange:K}),w.jsxs("div",{className:"dashboard-content",children:[w.jsxs("div",{className:"tab-bar",children:[!y&&w.jsx(hb,{daemonVersion:Y,locationClientToken:X,activeClientToken:ae,request:l,onLocationClientTokenChange:K}),w.jsx(lN,{})]}),w.jsx("main",{className:"dashboard-main",children:c?w.jsxs("div",{className:"revoked-state",children:[w.jsx("div",{className:"revoked-icon",children:w.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[w.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),w.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}),w.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"18"})]})}),w.jsx("h2",{className:"revoked-title",children:"Client Revoked"}),w.jsx("p",{className:"revoked-description",children:"This client was revoked by the host. To reconnect, generate a new pairing code on the host machine."}),w.jsx("div",{className:"revoked-command",children:w.jsx("code",{children:"palmier pair"})}),w.jsxs("div",{className:"revoked-actions",children:[w.jsx("button",{className:"btn btn-primary",onClick:()=>f("/pair"),children:"Re-pair Device"}),w.jsx("button",{className:"btn btn-secondary",onClick:()=>{n&&r(n)},children:"Remove Host"})]})]}):I?w.jsxs(w.Fragment,{children:[w.jsx("div",{style:{display:g?"none":"contents"},children:w.jsx(sN,{connected:a,hostId:n,request:l,subscribeEvents:u,onViewRun:ye,onUpdateRequired:se,onVersion:T,onLocationClientToken:K})}),$?w.jsx(pN,{connected:a,hostId:n,request:l,subscribeEvents:u,taskId:d.taskId,runId:decodeURIComponent(D)}):g?w.jsx(hN,{connected:a,hostId:n,request:l,subscribeEvents:u,filterTaskId:b,onClearFilter:()=>f("/runs")}):null]}):w.jsxs("div",{className:"empty-state",children:[w.jsx("p",{children:q?"Connecting to host...":"No hosts paired yet."}),!q&&w.jsx("button",{className:"btn btn-primary",onClick:()=>f("/pair"),children:"Pair Host"})]})}),V&&!N&&!G&&w.jsx("div",{className:"confirm-modal-overlay",children:w.jsxs("div",{className:"confirm-modal",children:[w.jsx("h2",{className:"confirm-modal-title",children:"Update Required"}),w.jsxs("p",{className:"confirm-modal-message",children:["Your Palmier host",Y?` (v${Y})`:""," is too old for this version of the app. Please update to continue."]}),w.jsx("div",{className:"confirm-modal-actions",children:w.jsx("button",{className:"btn btn-primary",onClick:ue,children:"Update Now"})})]})}),N&&w.jsx("div",{className:"confirm-modal-overlay",children:w.jsxs("div",{className:"confirm-modal",children:[w.jsx("h2",{className:"confirm-modal-title",children:"Updating..."}),w.jsx("p",{className:"confirm-modal-message",children:"Installing update and restarting daemon. Please wait..."})]})}),G&&w.jsx("div",{className:"confirm-modal-overlay",children:w.jsxs("div",{className:"confirm-modal",children:[w.jsx("h2",{className:"confirm-modal-title",children:"Update Failed"}),w.jsx("p",{className:"confirm-modal-message",style:{whiteSpace:"pre-line"},children:G}),w.jsx("div",{className:"confirm-modal-actions",children:w.jsx("button",{className:"btn btn-secondary",onClick:()=>{J(null)},children:"Retry"})})]})})]})]})}const cl=!!window.__PALMIER_SERVE__;function yN(){const[e,n]=U.useState(""),[r,a]=U.useState(!1),[l,u]=U.useState(null),{addPairedHost:c}=Ol(),f=ta();async function m(){const d=e.trim().toUpperCase();if(!d){u("Enter a pairing code.");return}a(!0),u(null);try{let y;if(cl){const b=await fetch("/pair",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:d,label:navigator.userAgent})});if(!b.ok){const x=await b.json().catch(()=>({error:"Connection failed"}));throw new Error(x.error||`HTTP ${b.status}`)}y=await b.json()}else{const b=await fetch(`${Sd}/api/config`);if(!b.ok)throw new Error("Failed to fetch server config");const x=await b.json();if(!x.natsWsUrl)throw new Error("Server has no NATS WebSocket URL configured");const k=await e1({servers:x.natsWsUrl,token:x.natsToken}),L=yu(),B=`pair.${d}`,D=await k.request(B,L.encode(JSON.stringify({label:navigator.userAgent})),{timeout:1e4});y=JSON.parse(L.decode(D.data)),await k.close()}const g={hostId:y.hostId,clientToken:y.clientToken,directUrl:cl?window.location.origin:void 0};c(g),ji.isNativePlatform()&&await cv.set({key:"hostId",value:y.hostId}),f("/")}catch(y){const g=y instanceof Error?y.message:String(y);g.includes("timeout")||g.includes("TIMEOUT")||g.includes("503")||g.toLowerCase().includes("no responders")?u("Code not found or expired. Check the code and try again."):u(g)}finally{a(!1)}}return w.jsx("div",{className:"pair-page",children:w.jsxs("div",{className:"pair-card",children:[w.jsxs("div",{className:"pair-header",children:[w.jsx("h1",{className:"pair-title",children:cl?"Pair":"Pair with Host"}),w.jsx("p",{className:"pair-subtitle",children:cl?"Enter the pairing code shown in your terminal.":"Connect this device to a Palmier host"})]}),!cl&&w.jsxs("div",{className:"pair-instructions",children:[w.jsxs("div",{className:"pair-instruction-block",children:[w.jsx("h3",{className:"pair-instruction-heading",children:"Setting up a new host?"}),w.jsxs("ol",{className:"pair-steps",children:[w.jsxs("li",{children:["Install at least one agent CLI (e.g., ",w.jsx("a",{href:"https://www.palmier.me/agents",target:"_blank",rel:"noopener noreferrer",children:"Claude Code, Gemini CLI, Codex CLI"}),")"]}),w.jsxs("li",{children:["Install Palmier on your host machine:",w.jsx("code",{className:"pair-command",children:"npm install -g palmier"})]}),w.jsxs("li",{children:["Run the setup wizard:",w.jsx("code",{className:"pair-command",children:"palmier init"})]}),w.jsx("li",{children:"A pairing code will display automatically"})]})]}),w.jsx("div",{className:"pair-instruction-divider"}),w.jsxs("div",{className:"pair-instruction-block",children:[w.jsx("h3",{className:"pair-instruction-heading",children:"Pairing an existing host?"}),w.jsxs("ol",{className:"pair-steps",children:[w.jsxs("li",{children:["Run ",w.jsx("code",{children:"palmier pair"})," on the host machine"]}),w.jsx("li",{children:"Enter the 6-character code below"})]})]})]}),w.jsxs("div",{className:"pair-form",children:[w.jsxs("label",{className:"form-label",htmlFor:"pair-code",children:["Pairing code",w.jsx("input",{id:"pair-code",type:"text",maxLength:6,value:e,onChange:d=>n(d.target.value.toUpperCase()),placeholder:"A7K9M2",className:"form-input form-input-mono pair-code-input",autoFocus:!0,autoComplete:"off",disabled:r})]}),l&&w.jsx("p",{className:"pair-error",children:l}),w.jsxs("button",{className:"btn btn-primary btn-full",onClick:m,disabled:r||!e.trim(),children:[r&&w.jsx("span",{className:"btn-spinner"}),r?"Pairing...":"Pair"]}),w.jsx("button",{className:"btn btn-secondary btn-full",onClick:()=>f("/"),disabled:r,children:"Cancel"}),w.jsxs("p",{className:"pair-consent",children:["By pairing, you agree to our"," ",w.jsx("a",{href:"https://www.palmier.me/terms",target:"_blank",rel:"noopener noreferrer",children:"Terms of Service"})," and"," ",w.jsx("a",{href:"https://www.palmier.me/privacy",target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"}),"."]})]})]})})}function bN(){return w.jsx(f_,{children:w.jsx(E2,{children:w.jsxs(CS,{children:[w.jsx(Fa,{path:"/",element:w.jsx(su,{})}),w.jsx(Fa,{path:"/runs",element:w.jsx(su,{})}),w.jsx(Fa,{path:"/runs/:taskId",element:w.jsx(su,{})}),w.jsx(Fa,{path:"/runs/:taskId/:runId",element:w.jsx(su,{})}),w.jsx(Fa,{path:"/pair",element:w.jsx(yN,{})})]})})})}jw.createRoot(document.getElementById("root")).render(w.jsx(U.StrictMode,{children:w.jsx(KS,{children:w.jsx(bN,{})})}));export{wd as W};
|
|
118
|
+
Are you sure you want to continue?`):!0}async function Mt(){_e("save"),N(null);try{const Ee=ve?"task.update":"task.create",Ie={user_prompt:m,agent:y,triggers:nt(),triggers_enabled:T,requires_confirmation:K,yolo_mode:ue,foreground_mode:I,command:M?S:""};ve&&(Ie.id=e.id);const Be=await c(Ee,Ie,{timeout:13e4});return Be.error?(N(Be.error),null):(ve||localStorage.setItem("palmier:lastAgent",y),a(Be),Be)}catch(Ee){return N(Ee instanceof Error?Ee.message:String(Ee)),null}finally{_e(null)}}async function xr(){_e("run"),N(null);try{const Ie=await c("task.run_oneoff",{user_prompt:m,agent:y,requires_confirmation:K,yolo_mode:ue,foreground_mode:I,command:M?S:""});if(Ie.error){N(Ie.error);return}localStorage.setItem("palmier:lastAgent",y),l(Ie.task_id,Ie.run_id),u()}catch(Ee){N(Ee instanceof Error?Ee.message:String(Ee))}finally{_e(null)}}return w.jsx("div",{className:"task-form-overlay",children:w.jsx("div",{className:"task-form",children:D?w.jsx(XO,{body:b,permissions:e==null?void 0:e.permissions}):w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"task-form-header",children:w.jsx("h2",{children:e?"Edit Task":"New Task"})}),se&&w.jsx("div",{className:"form-error",children:se}),w.jsx("textarea",{autoFocus:!e,className:"form-textarea",value:m,onChange:Ee=>d(Ee.target.value),placeholder:M?"If the input email contains an event, create a calendar entry for it.":"Research today's top AI news and write a summary.",rows:4,disabled:O}),w.jsxs("div",{className:"plan-actions",children:[B&&w.jsx("button",{className:"btn btn-link",onClick:()=>$(!0),children:"Execution Plan"}),w.jsxs("div",{className:"agent-picker-section-inline",style:{marginLeft:"auto"},children:[w.jsx("span",{className:"agent-picker-label",children:"Run with"}),w.jsx("select",{className:"form-select form-select-sm",value:y,onChange:Ee=>g(Ee.target.value),children:n.map(Ee=>w.jsx("option",{value:Ee.key,children:Ee.label},Ee.key))})]})]}),w.jsxs("div",{className:"toggles-group",children:[w.jsxs("div",{className:`command-section${M?" command-section-active":""}`,children:[w.jsxs("label",{className:"toggle-label",children:[w.jsx("input",{type:"checkbox",checked:M,onChange:Ee=>{W(Ee.target.checked),Ee.target.checked?setTimeout(()=>{var Ie;return(Ie=fe.current)==null?void 0:Ie.focus()},0):he("")},disabled:O}),"Reactive"]}),M&&w.jsxs(w.Fragment,{children:[w.jsx("p",{className:"command-help-text",children:"Runs a command and invokes the task for each line of output. Use “the input” in your task description to reference each line."}),w.jsx("input",{ref:fe,className:"form-input form-input-mono",type:"text",value:S,onChange:Ee=>he(Ee.target.value),placeholder:"gws gmail +watch --project my-project",disabled:O})]})]}),r==="win32"&&w.jsxs("label",{className:"toggle-label",children:[w.jsx("input",{type:"checkbox",checked:I,onChange:Ee=>ae(Ee.target.checked),disabled:O}),"Run in the foreground (host must login to Windows)"]}),w.jsxs("label",{className:"toggle-label",children:[w.jsx("input",{type:"checkbox",checked:ue,onChange:Ee=>q(Ee.target.checked),disabled:O}),"Yolo mode"]}),ue&&w.jsx("p",{className:"command-help-text",children:"The agent will auto-approve all tool calls without asking for permission."}),w.jsxs("div",{className:"triggers-section",children:[w.jsxs("label",{className:"toggle-label",children:[w.jsx("input",{type:"checkbox",checked:T,onChange:Ee=>{Ee.target.checked?(X(!0),R.length===0&&He()):(X(!1),ye(!1),G(Ie=>{const Be=Ie.filter(jt=>jt.schedule==="once"?jt.onceDate&&new Date(`${jt.onceDate}T${jt.onceTime}`)>new Date:!0);return Be.length===1&&Be[0].schedule==="daily"&&Be[0].time==="00:00"?[]:Be}))},disabled:O}),"Enable schedule"]}),w.jsxs("div",{className:`triggers-section-body${T?"":" disabled"}`,children:[R.length>0&&w.jsxs("select",{className:"form-select",value:J,disabled:!T,onChange:Ee=>qe(Ee.target.value),children:[w.jsx("option",{value:"once",children:"Specific Time"}),w.jsx("option",{value:"hourly",children:"Hourly"}),w.jsx("option",{value:"daily",children:"Daily"}),w.jsx("option",{value:"weekly",children:"Weekly"}),w.jsx("option",{value:"monthly",children:"Monthly"})]}),J!=="hourly"&&R.map((Ee,Ie)=>w.jsxs("div",{className:"trigger-row-card",children:[w.jsxs("div",{className:"trigger-row-content",children:[J==="daily"&&w.jsx("input",{className:"form-input",type:"time",value:Ee.time,disabled:!T,onChange:Be=>Me(Ie,{time:Be.target.value})}),J==="weekly"&&w.jsxs("div",{className:"trigger-row-top",children:[w.jsx("select",{className:"form-select",value:Ee.dayOfWeek,disabled:!T,onChange:Be=>Me(Ie,{dayOfWeek:Be.target.value}),children:WO.map((Be,jt)=>w.jsx("option",{value:String(jt),children:Be},jt))}),w.jsx("input",{className:"form-input",type:"time",value:Ee.time,disabled:!T,onChange:Be=>Me(Ie,{time:Be.target.value})})]}),J==="monthly"&&w.jsxs("div",{className:"trigger-row-top",children:[w.jsx("select",{className:"form-select",value:Ee.dayOfMonth,disabled:!T,onChange:Be=>Me(Ie,{dayOfMonth:Be.target.value}),children:Array.from({length:28},(Be,jt)=>jt+1).map(Be=>w.jsxs("option",{value:String(Be),children:["Day ",Be]},Be))}),w.jsx("input",{className:"form-input",type:"time",value:Ee.time,disabled:!T,onChange:Be=>Me(Ie,{time:Be.target.value})})]}),J==="once"&&w.jsxs("div",{className:"trigger-row-top",children:[w.jsx("input",{className:"form-input",type:"date",value:Ee.onceDate,min:new Date().toISOString().split("T")[0],disabled:!T,onChange:Be=>Me(Ie,{onceDate:Be.target.value})}),w.jsx("input",{className:"form-input",type:"time",value:Ee.onceTime,min:Ee.onceDate===new Date().toISOString().split("T")[0]?new Date().toTimeString().slice(0,5):void 0,disabled:!T,onChange:Be=>Me(Ie,{onceTime:Be.target.value})})]})]}),R.length>1&&w.jsx("button",{className:"trigger-remove-btn",onClick:()=>wt(Ie),disabled:!T,title:"Remove trigger",children:"×"})]},Ie)),R.length>0&&J!=="hourly"&&w.jsx("button",{className:"trigger-add-btn",onClick:He,disabled:!T,children:"+ Add"})]})]}),T&&R.length>0&&w.jsxs("label",{className:"toggle-label",children:[w.jsx("input",{type:"checkbox",checked:K,onChange:Ee=>ye(Ee.target.checked),disabled:O}),"Confirm before each run"]})]}),!ue&&(()=>{const Ee=n.find(Ie=>Ie.key===y);return(Ee==null?void 0:Ee.supportsPermissions)===!1&&w.jsxs("div",{className:"form-warning",children:["Palmier does not support runtime permission granting for ",Ee.label,". The task may fail if required permissions are not pre-configured."]})})(),w.jsxs("div",{className:"form-actions",children:[(()=>{const Ee=R.length>0,Ie=!!m.trim()&&(!M||!!S.trim());return ve?Te?w.jsxs("button",{className:"btn btn-primary",onClick:()=>ft()&&Mt(),disabled:!ke||O,children:[ge==="save"&&w.jsx("span",{className:"btn-spinner"}),"Save"]}):w.jsx("button",{className:"btn btn-primary",disabled:!0,children:"Save"}):Ee?w.jsxs("button",{className:"btn btn-primary",onClick:()=>ft()&&Mt(),disabled:!ke||O,children:[ge==="save"&&w.jsx("span",{className:"btn-spinner"}),"Schedule"]}):w.jsxs(w.Fragment,{children:[w.jsxs("button",{className:"btn btn-primary",onClick:()=>ft()&&xr(),disabled:!Ie||O,children:[ge==="run"&&w.jsx("span",{className:"btn-spinner"}),"Run"]}),w.jsx("button",{className:"btn btn-secondary",onClick:()=>ft()&&Mt(),disabled:!ke||O,children:"Save"})]})})(),w.jsx("button",{className:"btn btn-secondary",onClick:()=>{Te&&m.trim()&&!confirm("You have unsaved changes. Discard?")||u()},style:{marginLeft:"auto"},children:"Cancel"})]})]})})})}const iN="0.6.8";function aN(e,n){if(e.includes("-"))return!1;const r=e.split(".").map(Number),a=n.split(".").map(Number);for(let l=0;l<3;l++){if((r[l]??0)<(a[l]??0))return!0;if((r[l]??0)>(a[l]??0))return!1}return!1}function sN({connected:e,hostId:n,request:r,subscribeEvents:a,onViewRun:l,onUpdateRequired:u,onVersion:c,onLocationClientToken:f}){const[m,d]=U.useState([]),[y,g]=U.useState(!1),[b,x]=U.useState(null),[k,L]=U.useState(new Map),[B,D]=U.useState(new Map),[$,V]=U.useState(new Map),[se,N]=U.useState(new Map),[R,G]=U.useState(new Map),[J,Y]=U.useState(!1),[T,X]=U.useState(void 0),[K,ye]=U.useState([]),[ue,q]=U.useState(),I=U.useCallback(()=>{Y(!1),X(void 0)},[]),ae=U.useCallback(async()=>{var S,he;if(e){g(!0),x(null);try{const fe=await r("task.list"),ve=fe.tasks??[],Te=new Map,ze=new Map,ke=new Map,Me=new Map,wt=new Map;for(const qe of ve)qe.status&&(Te.set(qe.id,qe.status),(S=qe.status.pending_permission)!=null&&S.length&&ke.set(qe.id,qe.status.pending_permission),(he=qe.status.pending_input)!=null&&he.length&&(Me.set(qe.id,{questions:qe.status.pending_input}),wt.set(qe.id,new Array(qe.status.pending_input.length).fill(""))));L(Te),D(ze),V(ke),N(Me),G(wt),d(ve),ye(fe.agents??[]),q(fe.host_platform),k2(fe.agents??[]);const He=fe.version??null;c==null||c(He),f==null||f(fe.location_client_token??null),u==null||u(!!He&&aN(He,iN))}catch(fe){const ve=fe instanceof Error?fe.message:String(fe);ve==="Not connected"||ve.includes("503")||ve.toLowerCase().includes("no responders")?x(null):x(ve),d([])}finally{g(!1)}}},[e,n,r]);U.useEffect(()=>{e?ae():(d([]),g(!1))},[e,n,ae]),U.useEffect(()=>{if(!e||!n)return;const S={decode:fe=>new TextDecoder().decode(fe)};return a(n,async fe=>{var wt;const ve=fe.subject.split(".");if(ve.length<3)return;const Te=ve.slice(2).join(".");let ze={};try{ze=JSON.parse(S.decode(fe.data))}catch{return}const ke=ze.event_type,Me=ze.session_id;if(ke==="input-request"&&Me){const He=ze.input_questions,qe=ze.agent_name,nt=ze.description;He!=null&&He.length&&(N(ft=>{if(ft.has(Me))return ft;const Mt=new Map(ft);return Mt.set(Me,{questions:He,description:nt,agentName:qe}),Mt}),G(ft=>{if(ft.has(Me))return ft;const Mt=new Map(ft);return Mt.set(Me,new Array(He.length).fill("")),Mt}));return}if(ke==="input-resolved"&&Me){N(He=>{if(!He.has(Me))return He;const qe=new Map(He);return qe.delete(Me),qe}),G(He=>{const qe=new Map(He);return qe.delete(Me),qe});return}if(ke==="confirm-request"&&Me){const He=ze.description,qe=ze.agent_name;He&&D(nt=>{if(nt.has(Me))return nt;const ft=new Map(nt);return ft.set(Me,{description:He,agentName:qe}),ft});return}if(ke==="confirm-resolved"&&Me){D(He=>{if(!He.has(Me))return He;const qe=new Map(He);return qe.delete(Me),qe});return}if(ke==="permission-resolved"){V(He=>{if(!He.has(Te))return He;const qe=new Map(He);return qe.delete(Te),qe});return}try{const He=await r("task.status",{id:Te},{timeout:5e3});if(He.error)return;L(qe=>{const nt=new Map(qe);return nt.set(Te,He),nt}),(wt=He.pending_permission)!=null&&wt.length&&V(qe=>{if(qe.has(Te))return qe;const nt=new Map(qe);return nt.set(Te,He.pending_permission),nt})}catch{}})},[e,n,a,r]);async function ge(S,he){try{await r("task.user_input",{id:S,value:[he]})}catch(fe){console.error("[TaskListView] Failed to respond to confirmation:",fe)}}async function _e(S,he){try{await r("task.user_input",{id:S,value:[he]})}catch(fe){console.error("[TaskListView] Failed to respond to permission request:",fe)}}async function O(S,he){try{await r("task.user_input",{id:S,value:he})}catch(fe){console.error("[TaskListView] Failed to respond to input request:",fe)}}function M(S){d(he=>{const fe=he.findIndex(ve=>ve.id===S.id);if(fe>=0){const ve=[...he];return ve[fe]=S,ve}return[S,...he]}),Y(!1),X(void 0)}function W(S){d(he=>he.filter(fe=>fe.id!==S)),L(he=>{const fe=new Map(he);return fe.delete(S),fe}),N(he=>{const fe=new Map(he);return fe.delete(S),fe}),G(he=>{const fe=new Map(he);return fe.delete(S),fe})}return w.jsxs(w.Fragment,{children:[b&&w.jsxs("div",{className:"form-error",children:[b,b.toLowerCase().includes("failed to fetch")&&w.jsxs(w.Fragment,{children:[" ",w.jsx("a",{href:"#",onClick:S=>{S.preventDefault(),window.location.reload()},children:"Reload"})]})]}),w.jsx("div",{className:"new-task-input-card",onClick:()=>{X(void 0),Y(!0)},role:"button",tabIndex:0,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(X(void 0),Y(!0))},children:w.jsx("span",{className:"new-task-placeholder",children:"Describe your new task..."})}),y&&!m.length?w.jsx("div",{className:"task-list",children:[0,1,2].map(S=>w.jsxs("div",{className:"task-card",style:{pointerEvents:"none"},children:[w.jsx("div",{className:"task-card-header",children:w.jsxs("div",{className:"task-card-title-row",children:[w.jsx("div",{className:"skeleton-line",style:{width:10,height:10,borderRadius:"50%"}}),w.jsx("div",{className:"skeleton-line",style:{width:`${60+S*12}%`}})]})}),w.jsxs("div",{className:"task-card-meta",children:[w.jsx("div",{className:"skeleton-line",style:{width:"30%"}}),w.jsx("div",{className:"skeleton-line",style:{width:"25%"}})]})]},S))}):w.jsx("div",{className:"task-list",children:m.map(S=>w.jsx(C2,{task:S,lastEvent:k.get(S.id),onEdit:async he=>{try{const fe=await r("task.get",{id:he.id});X(fe.error?he:fe)}catch{X(he)}Y(!0)},onDelete:W,onViewRun:l},S.id))}),J&&w.jsx(rN,{initial:T,agents:K,hostPlatform:ue,onSaved:M,onRun:l,onCancel:I}),du.createPortal(w.jsxs(w.Fragment,{children:[[...B.entries()].map(([S,{description:he,agentName:fe}])=>{var Te;const ve=fe||((Te=m.find(ze=>ze.id===S))==null?void 0:Te.name);return w.jsx("div",{className:"confirm-modal-overlay",children:w.jsxs("div",{className:"confirm-modal",children:[w.jsx("h2",{className:"confirm-modal-title",children:"Confirmation Required"}),ve&&w.jsx("p",{className:"confirm-modal-subtitle",children:ve}),w.jsx("p",{className:"confirm-modal-message",children:he}),w.jsxs("div",{className:"confirm-modal-actions",children:[w.jsx("button",{className:"btn btn-primary",onClick:()=>ge(S,"confirmed"),children:"Confirm"}),w.jsx("button",{className:"btn btn-secondary",onClick:()=>ge(S,"aborted"),children:"Abort"})]})]})},S)}),[...$.entries()].map(([S,he])=>{const fe=m.find(ve=>ve.id===S);return w.jsx("div",{className:"confirm-modal-overlay",children:w.jsxs("div",{className:"confirm-modal permission-modal",children:[w.jsx("h2",{className:"confirm-modal-title",children:"Permission Required"}),w.jsx("p",{className:"confirm-modal-message",children:w.jsx("strong",{children:(fe==null?void 0:fe.name)||(fe==null?void 0:fe.user_prompt)||S})}),w.jsx("div",{className:"permission-list",children:he.map((ve,Te)=>w.jsxs("div",{className:"permission-item",children:[w.jsx("span",{className:"permission-name",children:ve.name}),ve.description&&w.jsx("span",{className:"permission-desc",children:ve.description})]},Te))}),w.jsxs("div",{className:"permission-actions",children:[w.jsx("button",{className:"btn btn-primary",onClick:()=>_e(S,"granted"),children:"Allow Once"}),w.jsx("button",{className:"btn btn-secondary",onClick:()=>_e(S,"granted_all"),children:"Allow Always"})]}),w.jsx("button",{className:"permission-abort-link",onClick:()=>_e(S,"aborted"),children:"Deny & Abort Task"})]})},S)}),[...se.entries()].map(([S,{questions:he,description:fe,agentName:ve}])=>{var ke;const Te=R.get(S)??new Array(he.length).fill(""),ze=ve||((ke=m.find(Me=>Me.id===S))==null?void 0:ke.name);return w.jsx("div",{className:"confirm-modal-overlay",children:w.jsxs("div",{className:"confirm-modal input-modal",children:[w.jsx("h2",{className:"confirm-modal-title",children:"Input Required"}),ze&&w.jsx("p",{className:"confirm-modal-subtitle",children:ze}),fe&&w.jsx("p",{className:"confirm-modal-message",children:fe}),w.jsx("div",{className:"input-list",children:he.map((Me,wt)=>w.jsxs("div",{className:"input-item",children:[w.jsx("label",{className:"input-label",children:Me}),w.jsx("input",{type:"text",className:"input-field",value:Te[wt]??"",onChange:He=>{G(qe=>{const nt=new Map(qe),ft=[...nt.get(S)??[]];return ft[wt]=He.target.value,nt.set(S,ft),nt})},autoFocus:wt===0})]},wt))}),w.jsx("div",{className:"input-actions",children:w.jsx("button",{className:"btn btn-primary",disabled:Te.some(Me=>!Me.trim()),onClick:()=>O(S,Te),children:"Submit"})}),w.jsx("button",{className:"permission-abort-link",onClick:()=>O(S,["aborted"]),children:"Cancel"})]})},S)})]}),document.body)]})}function lN(){const e=ta(),r=br().pathname.startsWith("/runs");return w.jsxs(w.Fragment,{children:[w.jsxs("button",{className:`tab-btn ${r?"":"tab-btn-active"}`,onClick:()=>e("/"),children:[w.jsxs("svg",{className:"tab-icon",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[w.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),w.jsx("path",{d:"M5.5 8L7 9.5L10.5 6"})]}),"Tasks"]}),w.jsxs("button",{className:`tab-btn ${r?"tab-btn-active":""}`,onClick:()=>e("/runs"),children:[w.jsx("svg",{className:"tab-icon",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:w.jsx("path",{d:"M2 8H4.5L6 4L8 12L10 6L11.5 8H14"})}),"Runs"]})]})}const oN="modulepreload",uN=function(e){return"/"+e},ub={},uv=function(n,r,a){let l=Promise.resolve();if(r&&r.length>0){let c=function(d){return Promise.all(d.map(y=>Promise.resolve(y).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),m=(f==null?void 0:f.nonce)||(f==null?void 0:f.getAttribute("nonce"));l=c(r.map(d=>{if(d=uN(d),d in ub)return;ub[d]=!0;const y=d.endsWith(".css"),g=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${g}`))return;const b=document.createElement("link");if(b.rel=y?"stylesheet":oN,y||(b.as="script"),b.crossOrigin="",b.href=d,m&&b.setAttribute("nonce",m),document.head.appendChild(b),y)return new Promise((x,k)=>{b.addEventListener("load",x),b.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${d}`)))})}))}function u(c){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=c,window.dispatchEvent(f),!f.defaultPrevented)throw c}return l.then(c=>{for(const f of c||[])f.status==="rejected"&&u(f.reason);return n().catch(u)})},cN=ls("App",{web:()=>uv(()=>import("./web-zj8Blync.js"),[]).then(e=>new e.AppWeb)}),cv=ls("Preferences",{web:()=>uv(()=>import("./web-C48txJFl.js"),[]).then(e=>new e.PreferencesWeb)});function fv(e){const[n,r]=U.useState(()=>window.matchMedia(e).matches);return U.useEffect(()=>{const a=window.matchMedia(e),l=u=>r(u.matches);return a.addEventListener("change",l),r(a.matches),()=>a.removeEventListener("change",l)},[e]),n}const au=ji.isNativePlatform()?ls("LocationPermission"):null,cb=!!window.__PALMIER_SERVE__,fb=ji.isNativePlatform();function hb({daemonVersion:e,locationClientToken:n,activeClientToken:r,request:a,onLocationClientTokenChange:l}){var O;const{pairedHosts:u,activeHostId:c,setActiveHostId:f,removePairedHost:m,renamePairedHost:d}=Ol(),y=ta(),g=fv("(min-width: 768px)"),[b,x]=U.useState(!1),[k,L]=U.useState(!1),[B,D]=U.useState(null),[$,V]=U.useState(""),[se,N]=U.useState(null),[R,G]=U.useState(!1),J=!!(r&&n===r);U.useEffect(()=>{if(!fb||!au||!a)return;function M(){J&&au.check().then(({fine:S})=>{S||a("device.location.disable").then(()=>{l==null||l(null)}).catch(()=>{})})}M();const W=cN.addListener("resume",()=>{M()});return()=>{W.then(S=>S.remove())}},[J,r]);async function Y(){if(a){G(!0);try{if(J)await a("device.location.disable"),l==null||l(null);else{if(au&&!(await au.request()).fine)return;const{value:M}=await cv.get({key:"fcmToken"});if(!M){console.warn("No FCM token available");return}await a("device.location.enable",{fcmToken:M}),l==null||l(r??null)}}catch(M){console.error("Failed to toggle location:",M)}finally{G(!1)}}}const T=U.useRef(null),X=U.useRef(null),K=U.useCallback(()=>{L(!0)},[]);function ye(){k&&(x(!1),L(!1))}function ue(){L(!1),x(!0)}function q(M,W){D(M),V(W)}function I(){B&&$.trim()&&d(B,$.trim()),D(null),V("")}function ae(){D(null),V("")}U.useEffect(()=>{B&&X.current&&(X.current.focus(),X.current.select())},[B]),U.useEffect(()=>{if(!b||k)return;function M(W){W.key==="Escape"&&K()}return document.addEventListener("keydown",M),()=>{document.removeEventListener("keydown",M)}},[b,k,K]);const ge=w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"drawer-header",children:[w.jsx("span",{className:"drawer-title",children:"Palmier"}),!g&&w.jsx("button",{className:"drawer-close-btn",onClick:K,"aria-label":"Close menu",children:w.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:w.jsx("path",{d:"M4 4L12 12M12 4L4 12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]}),!cb&&u.length>0&&w.jsxs("div",{className:"drawer-section",children:[w.jsx("h3",{className:"drawer-section-label",children:"Hosts"}),w.jsx("div",{className:"host-picker-inline",children:w.jsx("div",{className:"host-picker-list",role:"listbox",children:u.map(M=>{const W=M.hostId===c,S=B===M.hostId,he=M.name||M.hostId.slice(0,8);return w.jsx("div",{className:"host-picker-item-wrapper",children:w.jsxs("div",{className:`host-picker-item ${W?"host-picker-item-active":""}`,onClick:()=>{S||W||(f(M.hostId),g||K())},role:"option","aria-selected":W,children:[S?w.jsx("input",{ref:X,className:"form-input host-picker-rename-input",type:"text",value:$,onChange:fe=>V(fe.target.value),onKeyDown:fe=>{fe.key==="Enter"&&I(),fe.key==="Escape"&&ae()},onBlur:I,onClick:fe=>fe.stopPropagation()}):w.jsx("span",{className:"host-picker-item-name",children:he}),w.jsxs("div",{className:"host-picker-item-actions",children:[W&&!S&&w.jsx("button",{className:"host-picker-edit-btn",onClick:fe=>{fe.stopPropagation(),q(M.hostId,he)},"aria-label":"Rename host",children:w.jsx("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:w.jsx("path",{d:"M9.5 1.5L11.5 3.5M1.5 11.5L2 9L9 2L11 4L4 11L1.5 11.5Z",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}),!W&&w.jsx("button",{className:"host-picker-delete-btn",onClick:fe=>{fe.stopPropagation(),N(M.hostId)},"aria-label":`Unpair ${he}`,children:w.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:w.jsx("path",{d:"M4 5.5V11C4 11.2761 4.22386 11.5 4.5 11.5H9.5C9.77614 11.5 10 11.2761 10 11V5.5M3 4H11M5.5 4V3C5.5 2.72386 5.72386 2.5 6 2.5H8C8.27614 2.5 8.5 2.72386 8.5 3V4M6.5 6.5V9.5M7.5 6.5V9.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]})},M.hostId)})})})]}),!cb&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"drawer-divider"}),w.jsx("div",{className:"drawer-section",children:w.jsx("button",{className:"btn btn-primary btn-full",onClick:()=>{y("/pair"),g||K()},children:"Pair New Host"})})]}),fb&&w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"drawer-divider"}),w.jsx("div",{className:"drawer-section",children:w.jsxs("label",{className:"drawer-toggle",children:[w.jsx("span",{className:"drawer-toggle-label",children:"Location Access"}),w.jsx("button",{className:`toggle-switch ${J?"toggle-switch-on":""}`,onClick:Y,disabled:R,role:"switch","aria-checked":J,children:w.jsx("span",{className:"toggle-switch-thumb"})})]})})]}),w.jsxs("div",{className:"drawer-footer",children:[e&&w.jsxs("div",{className:"drawer-version",children:["Palmier v",e]}),w.jsxs("div",{className:"drawer-legal",children:[w.jsx("a",{href:"https://www.palmier.me/terms",target:"_blank",rel:"noopener noreferrer",children:"Terms"}),w.jsx("span",{className:"drawer-legal-sep",children:"·"}),w.jsx("a",{href:"https://www.palmier.me/privacy",target:"_blank",rel:"noopener noreferrer",children:"Privacy"})]})]})]}),_e=se&&du.createPortal(w.jsx("div",{className:"confirm-modal-overlay",onClick:()=>N(null),children:w.jsxs("div",{className:"confirm-modal",onClick:M=>M.stopPropagation(),children:[w.jsx("h2",{className:"confirm-modal-title",children:"Delete host?"}),w.jsxs("p",{className:"confirm-modal-message",children:['"',((O=u.find(M=>M.hostId===se))==null?void 0:O.name)||se.slice(0,8),'" will be unpaired from this device.']}),w.jsxs("div",{className:"confirm-modal-actions",children:[w.jsx("button",{className:"btn btn-secondary",onClick:()=>N(null),children:"Cancel"}),w.jsx("button",{className:"btn btn-danger",onClick:()=>{m(se),N(null)},children:"Delete"})]})]})}),document.body);return g?w.jsxs(w.Fragment,{children:[w.jsx("div",{className:"drawer-panel drawer-panel-desktop",ref:T,children:ge}),_e]}):w.jsxs(w.Fragment,{children:[w.jsx("button",{className:"hamburger-btn",onClick:ue,"aria-label":"Open menu",children:w.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:w.jsx("path",{d:"M3 5H17M3 10H17M3 15H17",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),b&&du.createPortal(w.jsx("div",{className:`drawer-overlay ${k?"drawer-overlay-closing":""}`,onClick:K,onAnimationEnd:ye,children:w.jsx("div",{className:`drawer-panel ${k?"drawer-panel-closing":""}`,ref:T,onClick:M=>M.stopPropagation(),children:ge})}),document.body),_e]})}const fN=10;function hN({connected:e,hostId:n,request:r,subscribeEvents:a,filterTaskId:l,onClearFilter:u}){const[c,f]=U.useState([]),[m,d]=U.useState(0),[y,g]=U.useState(!1),[b,x]=U.useState(!1),k=ta(),L=U.useRef(null),B=U.useCallback(N=>{const R={offset:N,limit:fN};return l&&(R.task_id=l),R},[l]),D=U.useCallback(async(N,R)=>{if(e){R?x(!0):g(!0);try{const G=await r("taskrun.list",B(N)),J=G.entries??[];d(G.total??0),f(R?Y=>{const T=new Set(Y.map(K=>`${K.task_id}:${K.run_id}`)),X=J.filter(K=>!T.has(`${K.task_id}:${K.run_id}`));return[...Y,...X]}:J)}catch(G){G instanceof Error&&G.message==="Not connected"||console.error("Failed to load runs:",G)}finally{g(!1),x(!1)}}},[e,r,B]);U.useEffect(()=>{e?(f([]),d(0),D(0,!1)):(f([]),d(0))},[e,n,D,l]),U.useEffect(()=>!e||!n?void 0:a(n,async R=>{try{const G=JSON.parse(new TextDecoder().decode(R.data));if(G.event_type==="running-state"&&G.running_state&&["monitoring","started","finished","failed","aborted"].includes(G.running_state)){const J=await r("taskrun.list",B(0)),Y=J.entries??[];d(J.total??0),f(T=>{const X=new Map(Y.map(q=>[`${q.task_id}:${q.run_id}`,q])),K=T.map(q=>{const I=`${q.task_id}:${q.run_id}`;return X.get(I)??q}),ye=new Set(K.map(q=>`${q.task_id}:${q.run_id}`));return[...Y.filter(q=>!ye.has(`${q.task_id}:${q.run_id}`)),...K]})}}catch{}}),[e,n,a,r]),U.useEffect(()=>{const N=L.current;if(!N)return;const R=new IntersectionObserver(G=>{G[0].isIntersecting&&!b&&c.length<m&&D(c.length,!0)},{threshold:.1});return R.observe(N),()=>R.disconnect()},[c.length,m,b,D]);function $(N,R){if(!N||!R)return"";const G=Math.round((R-N)/1e3);if(G<60)return`${G}s`;const J=Math.floor(G/60),Y=G%60;return`${J}m ${Y}s`}const V={monitoring:"Monitoring",started:"Running",finished:"Finished",failed:"Failed",aborted:"Aborted"};function se(N){if(N==="failed")return"var(--color-error)";if(N==="aborted")return"var(--color-warning, #d97706)"}return y&&c.length===0&&e?w.jsx("div",{className:"task-list",children:[0,1,2].map(N=>w.jsxs("div",{className:"task-card",style:{pointerEvents:"none"},children:[w.jsx("div",{className:"task-card-header",children:w.jsx("div",{className:"task-card-title-row",children:w.jsx("div",{className:"skeleton-line",style:{width:`${70+N*10}%`}})})}),w.jsx("div",{className:"task-card-meta",children:w.jsx("div",{className:"skeleton-line",style:{width:"45%"}})})]},N))}):!e||y&&c.length===0?w.jsx("div",{className:"runs-view",children:w.jsxs("div",{className:"empty-state",children:[w.jsx("p",{className:"empty-state-text",children:"Runs"}),w.jsx("p",{className:"empty-state-hint",children:"Run history will appear here"})]})}):c.length===0?w.jsxs(w.Fragment,{children:[l&&u&&w.jsx("div",{style:{marginBottom:"var(--space-sm)"},children:w.jsxs("span",{className:"runs-filter-chip",children:["Filtered by task",w.jsx("button",{onClick:u,"aria-label":"Clear filter",children:"×"})]})}),w.jsx("div",{className:"runs-view",children:w.jsxs("div",{className:"empty-state",children:[w.jsx("p",{className:"empty-state-text",children:"No runs yet"}),w.jsx("p",{className:"empty-state-hint",children:l?"This task hasn't been executed yet. Run it from the task menu or wait for its next trigger.":"Run history will appear here."})]})})]}):w.jsxs(w.Fragment,{children:[l&&u&&w.jsx("div",{style:{marginBottom:"var(--space-sm)"},children:w.jsxs("span",{className:"runs-filter-chip",children:["Filtered by task",w.jsx("button",{onClick:u,"aria-label":"Clear filter",children:"×"})]})}),w.jsxs("div",{className:"task-list",children:[c.map((N,R)=>w.jsxs("div",{className:"runs-card",onClick:()=>!N.error&&k(`/runs/${N.task_id}/${encodeURIComponent(N.run_id)}`),children:[w.jsxs("div",{className:"runs-card-body",children:[w.jsx("h3",{className:"runs-card-name",children:N.task_name||N.task_id}),w.jsxs("div",{className:"runs-card-meta",children:[w.jsx("span",{style:{color:se(N.running_state)},children:V[N.running_state??""]??N.running_state}),N.end_time&&w.jsx("span",{children:_u(N.end_time)}),N.start_time&&N.end_time&&w.jsx("span",{style:{color:"var(--color-muted)"},children:$(N.start_time,N.end_time)}),N.error&&w.jsx("span",{style:{color:"var(--color-muted)"},children:N.error})]})]}),w.jsx("span",{className:"runs-card-chevron",children:"›"})]},`${N.task_id}-${N.run_id}-${R}`)),w.jsx("div",{ref:L,style:{height:1}}),b&&w.jsx("div",{className:"loading-state",style:{padding:"var(--space-md)"},children:w.jsx("div",{className:"spinner"})})]})]})}function dN(e){P1(e,[/\r?\n|\r/g,mN])}function mN(){return{type:"break"}}function db(){return function(e){dN(e)}}function pN({connected:e,hostId:n,request:r,subscribeEvents:a,taskId:l,runId:u}){const c=ta(),[f,m]=U.useState(!0),[d,y]=U.useState([]),[g,b]=U.useState(),[x,k]=U.useState(),L=g==="started"||g==="monitoring",B=g==="followup",D=g==="started"||g==="followup",[$,V]=U.useState(null),[se,N]=U.useState(!1),[R,G]=U.useState(""),[J,Y]=U.useState(!1),T=U.useRef(null);async function X(){try{const q=await r("task.result",{id:l,run_id:u});if(q.error){console.error("No result:",q.error),c("/runs",{replace:!0});return}y(q.messages??[]),b(q.running_state),k(q.agent)}catch(q){console.error("Failed to load result:",q),c("/runs",{replace:!0})}finally{m(!1)}}async function K(q){var I;try{const ge=(I=(await r("task.reports",{id:l,run_id:u,report_files:[q]})).reports)==null?void 0:I[0];ge!=null&&ge.data_url?V({file:q,data_url:ge.data_url}):V({file:q,content:(ge==null?void 0:ge.content)??"Report not found."})}catch{V({file:q,content:"Failed to load report."})}}U.useEffect(()=>{e&&(m(!0),X())},[e,l,u]),U.useEffect(()=>!e||!n?void 0:a(n,async I=>{try{const ae=JSON.parse(new TextDecoder().decode(I.data));if(ae.event_type!=="running-state"&&ae.event_type!=="result-updated"||I.subject.split(".").pop()!==l||ae.event_type==="result-updated"&&ae.run_id&&ae.run_id!==u)return;X()}catch{}}),[e,n,l,a,r]),U.useEffect(()=>{T.current&&(T.current.scrollTop=T.current.scrollHeight)},[d]);function ye(q){if(q==="input")return"User Input";if(q==="permission")return"Permission";if(q==="confirmation")return"Confirmation"}function ue(q){return q==="started"?"Task started":q==="finished"?"Task finished":q==="failed"?"Task failed":q==="error"?"Command failed":q==="aborted"?"Task aborted":q==="confirmation"?"Task confirmed":q==="stopped"?"Follow-up stopped":q??""}return w.jsxs("div",{className:"run-detail",children:[w.jsxs("button",{className:"run-detail-back",onClick:()=>c(-1),children:[w.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:w.jsx("path",{d:"M15 18l-6-6 6-6"})}),"Back"]}),f?w.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)",padding:"var(--space-sm) 0"},children:[w.jsx("div",{className:"skeleton-line",style:{width:"40%"}}),w.jsx("div",{className:"skeleton-line",style:{width:"55%"}}),w.jsx("div",{className:"skeleton-line",style:{width:"100%",height:"8rem",marginTop:"var(--space-sm)"}})]}):w.jsxs(w.Fragment,{children:[w.jsxs("div",{className:"chat-thread",ref:T,children:[d.map((q,I)=>{const ae=D&&q.role==="assistant"&&!d.slice(I+1).some(ge=>ge.role==="assistant"||ge.role==="user");return q.role==="status"&&q.type==="monitoring"?null:q.role==="status"?w.jsxs("div",{className:`chat-status${q.type==="error"?" chat-status--error":""}`,children:[w.jsxs("div",{children:[ue(q.type),q.time>0&&w.jsx("span",{className:"chat-status-time",children:_u(q.time)})]}),q.content&&w.jsx("pre",{className:"chat-status-detail",children:q.content})]},I):w.jsxs("div",{className:`chat-message chat-message--${q.role}`,children:[q.role==="assistant"&&x&&w.jsx("div",{className:"chat-message-agent",children:Yh(x)}),w.jsxs("div",{className:"chat-message-content",children:[w.jsx(rd,{remarkPlugins:[ad,db],children:q.content}),ae&&w.jsxs("div",{className:"chat-typing-indicator",children:[w.jsx("span",{}),w.jsx("span",{}),w.jsx("span",{})]})]}),q.attachments&&q.attachments.length>0&&w.jsx("div",{className:"chat-message-attachments",children:q.attachments.map(ge=>w.jsx("button",{className:"chat-attachment-chip",onClick:()=>K(ge),children:ge},ge))}),w.jsxs("div",{className:"chat-message-meta",children:[ye(q.type)&&w.jsx("span",{className:"chat-message-type",children:ye(q.type)}),q.time>0&&w.jsx("span",{children:_u(q.time)})]})]},I)}),D&&(()=>{const q=d.filter(I=>I.role!=="status");return q.length===0||q[q.length-1].role!=="assistant"})()&&w.jsxs("div",{className:"chat-message chat-message--assistant",children:[x&&w.jsx("div",{className:"chat-message-agent",children:Yh(x)}),w.jsxs("div",{className:"chat-typing-indicator",children:[w.jsx("span",{}),w.jsx("span",{}),w.jsx("span",{})]})]}),g==="monitoring"&&w.jsxs("div",{className:"chat-monitoring-indicator",children:[w.jsx("span",{className:"chat-monitoring-dot"}),"Monitoring command output"]})]}),L?w.jsx("div",{className:"chat-abort-bar",children:w.jsx("button",{className:"btn btn-secondary chat-abort-btn",disabled:se,onClick:async()=>{if(confirm("Abort this task?")){N(!0);try{await r("task.abort",{id:l})}catch(q){console.error("Abort failed:",q)}finally{N(!1)}}},children:se?"Aborting...":"Abort Task"})}):B?w.jsx("div",{className:"chat-input-bar",children:w.jsx("button",{className:"btn btn-secondary chat-stop-btn",disabled:se,onClick:async()=>{N(!0);try{await r("task.stop_followup",{id:l,run_id:u})}catch(q){console.error("Stop failed:",q)}finally{N(!1)}},children:w.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:w.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})})}):w.jsxs("form",{className:"chat-input-bar",onSubmit:async q=>{q.preventDefault();const I=R.trim();if(!(!I||J)){Y(!0);try{await r("task.followup",{id:l,run_id:u,message:I}),G("")}catch(ae){console.error("Follow-up failed:",ae)}finally{Y(!1)}}},children:[w.jsx("input",{className:"chat-input",type:"text",placeholder:"Follow-up message",value:R,onChange:q=>G(q.target.value),disabled:J}),w.jsx("button",{className:"btn btn-primary chat-send-btn",type:"submit",disabled:!R.trim()||J,children:w.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[w.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),w.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]}),$&&w.jsx("div",{className:"report-dialog-overlay",onClick:()=>V(null),children:w.jsxs("div",{className:"report-dialog",onClick:q=>q.stopPropagation(),children:[w.jsxs("div",{className:"report-dialog-header",children:[w.jsx("span",{className:"report-dialog-title",children:$.file}),w.jsx("button",{className:"report-dialog-close",onClick:()=>V(null),"aria-label":"Close",children:w.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[w.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),w.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),w.jsx("div",{className:"report-dialog-body",children:$.data_url?w.jsx("img",{src:$.data_url,alt:$.file,style:{maxWidth:"100%",height:"auto"}}):w.jsx(rd,{remarkPlugins:[ad,db],components:{a:({...q})=>w.jsx("a",{...q,target:"_blank",rel:"noopener noreferrer"})},children:$.content??""})})]})})]})}function gN(){const{getActiveHost:e}=Ol(),n=e(),r=U.useRef(null);U.useEffect(()=>{if(ji.isNativePlatform()||!n||n.directUrl||r.current===n.hostId)return;async function a(){var l;try{if(!("serviceWorker"in navigator)||!("PushManager"in window)){console.warn("[Push] Push notifications not supported");return}const u=await navigator.serviceWorker.ready;(l=u.active)==null||l.postMessage({type:"set-host-id",hostId:n.hostId});let c=await u.pushManager.getSubscription();if(!c){const{publicKey:m}=await S2("/api/push/vapid-key");if(!m){console.warn("[Push] No VAPID public key configured on server");return}if(await Notification.requestPermission()!=="granted"){console.log("[Push] Permission denied");return}c=await u.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:m})}const f=c.toJSON();await w2("/api/push/subscribe",{hostId:n.hostId,endpoint:f.endpoint,keys:{p256dh:f.keys.p256dh,auth:f.keys.auth}}),r.current=n.hostId}catch(u){console.error("[Push] Subscription failed:",u)}}a()},[n])}function su(){var ge;const{pairedHosts:e,activeHostId:n,removePairedHost:r}=Ol(),{connected:a,request:l,subscribeEvents:u,unauthorized:c}=_d(),f=ta(),m=br(),d=hS(),y=fv("(min-width: 768px)"),g=m.pathname.startsWith("/runs"),b=d.runId?void 0:d.taskId,[x,k]=U.useState(null),L=d.runId,B=L==="latest";U.useEffect(()=>{if(!B||!d.taskId||!a){k(null);return}l("taskrun.list",{task_id:d.taskId,limit:1}).then(_e=>{var M,W;const O=(W=(M=_e.entries)==null?void 0:M[0])==null?void 0:W.run_id;k(O??null)}).catch(()=>k(null))},[B,d.taskId,a]);const D=B?x:L,$=!!(d.taskId&&D&&D!=="latest"),[V,se]=U.useState(!1),[N,R]=U.useState(!1),[G,J]=U.useState(null),[Y,T]=U.useState(null),[X,K]=U.useState(null);gN(),U.useEffect(()=>{window.scrollTo(0,0)},[n]);function ye(_e,O){f(O?`/runs/${encodeURIComponent(_e)}/${encodeURIComponent(O)}`:`/runs/${encodeURIComponent(_e)}`)}async function ue(){R(!0),J(null);try{const _e=await l("host.update");if(_e.error){J(_e.error),R(!1);return}}catch{}setTimeout(()=>window.location.reload(),1e4)}const q=e.length>0,I=q&&a&&n&&!c,ae=((ge=e.find(_e=>_e.hostId===n))==null?void 0:ge.clientToken)??null;return w.jsxs("div",{className:"dashboard",children:[y&&w.jsx(hb,{daemonVersion:Y,locationClientToken:X,activeClientToken:ae,request:l,onLocationClientTokenChange:K}),w.jsxs("div",{className:"dashboard-content",children:[w.jsxs("div",{className:"tab-bar",children:[!y&&w.jsx(hb,{daemonVersion:Y,locationClientToken:X,activeClientToken:ae,request:l,onLocationClientTokenChange:K}),w.jsx(lN,{})]}),w.jsx("main",{className:"dashboard-main",children:c?w.jsxs("div",{className:"revoked-state",children:[w.jsx("div",{className:"revoked-icon",children:w.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[w.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),w.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"}),w.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"18"})]})}),w.jsx("h2",{className:"revoked-title",children:"Client Revoked"}),w.jsx("p",{className:"revoked-description",children:"This client was revoked by the host. To reconnect, generate a new pairing code on the host machine."}),w.jsx("div",{className:"revoked-command",children:w.jsx("code",{children:"palmier pair"})}),w.jsxs("div",{className:"revoked-actions",children:[w.jsx("button",{className:"btn btn-primary",onClick:()=>f("/pair"),children:"Re-pair Device"}),w.jsx("button",{className:"btn btn-secondary",onClick:()=>{n&&r(n)},children:"Remove Host"})]})]}):I?w.jsxs(w.Fragment,{children:[w.jsx("div",{style:{display:g?"none":"contents"},children:w.jsx(sN,{connected:a,hostId:n,request:l,subscribeEvents:u,onViewRun:ye,onUpdateRequired:se,onVersion:T,onLocationClientToken:K})}),$?w.jsx(pN,{connected:a,hostId:n,request:l,subscribeEvents:u,taskId:d.taskId,runId:decodeURIComponent(D)}):g?w.jsx(hN,{connected:a,hostId:n,request:l,subscribeEvents:u,filterTaskId:b,onClearFilter:()=>f("/runs")}):null]}):w.jsxs("div",{className:"empty-state",children:[w.jsx("p",{children:q?"Connecting to host...":"No hosts paired yet."}),!q&&w.jsx("button",{className:"btn btn-primary",onClick:()=>f("/pair"),children:"Pair Host"})]})}),V&&!N&&!G&&w.jsx("div",{className:"confirm-modal-overlay",children:w.jsxs("div",{className:"confirm-modal",children:[w.jsx("h2",{className:"confirm-modal-title",children:"Update Required"}),w.jsxs("p",{className:"confirm-modal-message",children:["Your Palmier host",Y?` (v${Y})`:""," is too old for this version of the app. Please update to continue."]}),w.jsx("div",{className:"confirm-modal-actions",children:w.jsx("button",{className:"btn btn-primary",onClick:ue,children:"Update Now"})})]})}),N&&w.jsx("div",{className:"confirm-modal-overlay",children:w.jsxs("div",{className:"confirm-modal",children:[w.jsx("h2",{className:"confirm-modal-title",children:"Updating..."}),w.jsx("p",{className:"confirm-modal-message",children:"Installing update and restarting daemon. Please wait..."})]})}),G&&w.jsx("div",{className:"confirm-modal-overlay",children:w.jsxs("div",{className:"confirm-modal",children:[w.jsx("h2",{className:"confirm-modal-title",children:"Update Failed"}),w.jsx("p",{className:"confirm-modal-message",style:{whiteSpace:"pre-line"},children:G}),w.jsx("div",{className:"confirm-modal-actions",children:w.jsx("button",{className:"btn btn-secondary",onClick:()=>{J(null)},children:"Retry"})})]})})]})]})}const cl=!!window.__PALMIER_SERVE__;function yN(){const[e,n]=U.useState(""),[r,a]=U.useState(!1),[l,u]=U.useState(null),{addPairedHost:c}=Ol(),f=ta();async function m(){const d=e.trim().toUpperCase();if(!d){u("Enter a pairing code.");return}a(!0),u(null);try{let y;if(cl){const b=await fetch("/pair",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:d,label:navigator.userAgent})});if(!b.ok){const x=await b.json().catch(()=>({error:"Connection failed"}));throw new Error(x.error||`HTTP ${b.status}`)}y=await b.json()}else{const b=await fetch(`${Sd}/api/config`);if(!b.ok)throw new Error("Failed to fetch server config");const x=await b.json();if(!x.natsWsUrl)throw new Error("Server has no NATS WebSocket URL configured");const k=await e1({servers:x.natsWsUrl,token:x.natsToken}),L=yu(),B=`pair.${d}`,D=await k.request(B,L.encode(JSON.stringify({label:navigator.userAgent})),{timeout:1e4});y=JSON.parse(L.decode(D.data)),await k.close()}const g={hostId:y.hostId,clientToken:y.clientToken,directUrl:cl?window.location.origin:void 0};c(g),ji.isNativePlatform()&&await cv.set({key:"hostId",value:y.hostId}),f("/")}catch(y){const g=y instanceof Error?y.message:String(y);g.includes("timeout")||g.includes("TIMEOUT")||g.includes("503")||g.toLowerCase().includes("no responders")?u("Code not found or expired. Check the code and try again."):u(g)}finally{a(!1)}}return w.jsx("div",{className:"pair-page",children:w.jsxs("div",{className:"pair-card",children:[w.jsxs("div",{className:"pair-header",children:[w.jsx("h1",{className:"pair-title",children:cl?"Pair":"Pair with Host"}),w.jsx("p",{className:"pair-subtitle",children:cl?"Enter the pairing code shown in your terminal.":"Connect this device to a Palmier host"})]}),!cl&&w.jsxs("div",{className:"pair-instructions",children:[w.jsxs("div",{className:"pair-instruction-block",children:[w.jsx("h3",{className:"pair-instruction-heading",children:"Setting up a new host?"}),w.jsxs("ol",{className:"pair-steps",children:[w.jsxs("li",{children:["Install at least one agent CLI (e.g., ",w.jsx("a",{href:"https://www.palmier.me/agents",target:"_blank",rel:"noopener noreferrer",children:"Claude Code, Gemini CLI, Codex CLI"}),")"]}),w.jsxs("li",{children:["Install Palmier on your host machine:",w.jsx("code",{className:"pair-command",children:"npm install -g palmier"})]}),w.jsxs("li",{children:["Run the setup wizard:",w.jsx("code",{className:"pair-command",children:"palmier init"})]}),w.jsx("li",{children:"A pairing code will display automatically"})]})]}),w.jsx("div",{className:"pair-instruction-divider"}),w.jsxs("div",{className:"pair-instruction-block",children:[w.jsx("h3",{className:"pair-instruction-heading",children:"Pairing an existing host?"}),w.jsxs("ol",{className:"pair-steps",children:[w.jsxs("li",{children:["Run ",w.jsx("code",{children:"palmier pair"})," on the host machine"]}),w.jsx("li",{children:"Enter the 6-character code below"})]})]})]}),w.jsxs("div",{className:"pair-form",children:[w.jsxs("label",{className:"form-label",htmlFor:"pair-code",children:["Pairing code",w.jsx("input",{id:"pair-code",type:"text",maxLength:6,value:e,onChange:d=>n(d.target.value.toUpperCase()),placeholder:"A7K9M2",className:"form-input form-input-mono pair-code-input",autoFocus:!0,autoComplete:"off",disabled:r})]}),l&&w.jsx("p",{className:"pair-error",children:l}),w.jsxs("button",{className:"btn btn-primary btn-full",onClick:m,disabled:r||!e.trim(),children:[r&&w.jsx("span",{className:"btn-spinner"}),r?"Pairing...":"Pair"]}),w.jsx("button",{className:"btn btn-secondary btn-full",onClick:()=>f("/"),disabled:r,children:"Cancel"}),w.jsxs("p",{className:"pair-consent",children:["By pairing, you agree to our"," ",w.jsx("a",{href:"https://www.palmier.me/terms",target:"_blank",rel:"noopener noreferrer",children:"Terms of Service"})," and"," ",w.jsx("a",{href:"https://www.palmier.me/privacy",target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"}),"."]})]})]})})}function bN(){return w.jsx(f_,{children:w.jsx(E2,{children:w.jsxs(CS,{children:[w.jsx(Fa,{path:"/",element:w.jsx(su,{})}),w.jsx(Fa,{path:"/runs",element:w.jsx(su,{})}),w.jsx(Fa,{path:"/runs/:taskId",element:w.jsx(su,{})}),w.jsx(Fa,{path:"/runs/:taskId/:runId",element:w.jsx(su,{})}),w.jsx(Fa,{path:"/pair",element:w.jsx(yN,{})})]})})})}jw.createRoot(document.getElementById("root")).render(w.jsx(U.StrictMode,{children:w.jsx(KS,{children:w.jsx(bN,{})})}));export{wd as W};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{W as p}from"./index-
|
|
1
|
+
import{W as p}from"./index-CZejk2al.js";class f extends p{constructor(){super(...arguments),this.group="CapacitorStorage"}async configure({group:e}){typeof e=="string"&&(this.group=e)}async get(e){return{value:this.impl.getItem(this.applyPrefix(e.key))}}async set(e){this.impl.setItem(this.applyPrefix(e.key),e.value)}async remove(e){this.impl.removeItem(this.applyPrefix(e.key))}async keys(){return{keys:this.rawKeys().map(t=>t.substring(this.prefix.length))}}async clear(){for(const e of this.rawKeys())this.impl.removeItem(e)}async migrate(){var e;const t=[],s=[],n="_cap_",o=Object.keys(this.impl).filter(i=>i.indexOf(n)===0);for(const i of o){const r=i.substring(n.length),a=(e=this.impl.getItem(i))!==null&&e!==void 0?e:"",{value:l}=await this.get({key:r});typeof l=="string"?s.push(r):(await this.set({key:r,value:a}),t.push(r))}return{migrated:t,existing:s}}async removeOld(){const e="_cap_",t=Object.keys(this.impl).filter(s=>s.indexOf(e)===0);for(const s of t)this.impl.removeItem(s)}get impl(){return window.localStorage}get prefix(){return this.group==="NativeStorage"?"":`${this.group}.`}rawKeys(){return Object.keys(this.impl).filter(e=>e.indexOf(this.prefix)===0)}applyPrefix(e){return this.prefix+e}}export{f as PreferencesWeb};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{W as t}from"./index-
|
|
1
|
+
import{W as t}from"./index-CZejk2al.js";class s extends t{constructor(){super(),this.handleVisibilityChange=()=>{const e={isActive:document.hidden!==!0};this.notifyListeners("appStateChange",e),document.hidden?this.notifyListeners("pause",null):this.notifyListeners("resume",null)},document.addEventListener("visibilitychange",this.handleVisibilityChange,!1)}exitApp(){throw this.unimplemented("Not implemented on web.")}async getInfo(){throw this.unimplemented("Not implemented on web.")}async getLaunchUrl(){return{url:""}}async getState(){return{isActive:document.hidden!==!0}}async minimizeApp(){throw this.unimplemented("Not implemented on web.")}async toggleBackButtonHandler(){throw this.unimplemented("Not implemented on web.")}async getAppLanguage(){return{value:navigator.language.split("-")[0].toLowerCase()}}}export{s as AppWeb};
|
package/dist/pwa/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
|
9
9
|
<title>Palmier</title>
|
|
10
10
|
<meta name="description" content="Remote control for AI agents running on your own machine. Schedule tasks, approve permissions, and get push notifications." />
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-CZejk2al.js"></script>
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/index-C6Lz09EY.css">
|
|
13
13
|
<link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
|
|
14
14
|
<body>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
try{self["workbox:core:7.3.0"]&&_()}catch{}const N=(n,...e)=>{let t=n;return e.length>0&&(t+=` :: ${JSON.stringify(e)}`),t},E=N;class h extends Error{constructor(e,t){const s=E(e,t);super(s),this.name=e,this.details=t}}const f={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:typeof registration<"u"?registration.scope:""},U=n=>[f.prefix,n,f.suffix].filter(e=>e&&e.length>0).join("-"),O=n=>{for(const e of Object.keys(f))n(e)},L={updateDetails:n=>{O(e=>{typeof n[e]=="string"&&(f[e]=n[e])})},getGoogleAnalyticsName:n=>n||U(f.googleAnalytics),getPrecacheName:n=>n||U(f.precache),getPrefix:()=>f.prefix,getRuntimeName:n=>n||U(f.runtime),getSuffix:()=>f.suffix};function v(n,e){const t=e();return n.waitUntil(t),t}try{self["workbox:precaching:7.3.0"]&&_()}catch{}const A="__WB_REVISION__";function M(n){if(!n)throw new h("add-to-cache-list-unexpected-type",{entry:n});if(typeof n=="string"){const i=new URL(n,location.href);return{cacheKey:i.href,url:i.href}}const{revision:e,url:t}=n;if(!t)throw new h("add-to-cache-list-unexpected-type",{entry:n});if(!e){const i=new URL(t,location.href);return{cacheKey:i.href,url:i.href}}const s=new URL(t,location.href),a=new URL(t,location.href);return s.searchParams.set(A,e),{cacheKey:s.href,url:a.href}}class W{constructor(){this.updatedURLs=[],this.notUpdatedURLs=[],this.handlerWillStart=async({request:e,state:t})=>{t&&(t.originalRequest=e)},this.cachedResponseWillBeUsed=async({event:e,state:t,cachedResponse:s})=>{if(e.type==="install"&&t&&t.originalRequest&&t.originalRequest instanceof Request){const a=t.originalRequest.url;s?this.notUpdatedURLs.push(a):this.updatedURLs.push(a)}return s}}}class q{constructor({precacheController:e}){this.cacheKeyWillBeUsed=async({request:t,params:s})=>{const a=(s==null?void 0:s.cacheKey)||this._precacheController.getCacheKeyForURL(t.url);return a?new Request(a,{headers:t.headers}):t},this._precacheController=e}}let w;function S(){if(w===void 0){const n=new Response("");if("body"in n)try{new Response(n.body),w=!0}catch{w=!1}w=!1}return w}async function j(n,e){let t=null;if(n.url&&(t=new URL(n.url).origin),t!==self.location.origin)throw new h("cross-origin-copy-response",{origin:t});const s=n.clone(),i={headers:new Headers(s.headers),status:s.status,statusText:s.statusText},r=S()?s.body:await s.blob();return new Response(r,i)}const D=n=>new URL(String(n),location.href).href.replace(new RegExp(`^${location.origin}`),"");function T(n,e){const t=new URL(n);for(const s of e)t.searchParams.delete(s);return t.href}async function H(n,e,t,s){const a=T(e.url,t);if(e.url===a)return n.match(e,s);const i=Object.assign(Object.assign({},s),{ignoreSearch:!0}),r=await n.keys(e,i);for(const c of r){const o=T(c.url,t);if(a===o)return n.match(c,s)}}class F{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}const B=new Set;async function $(){for(const n of B)await n()}function V(n){return new Promise(e=>setTimeout(e,n))}try{self["workbox:strategies:7.3.0"]&&_()}catch{}function C(n){return typeof n=="string"?new Request(n):n}class G{constructor(e,t){this._cacheKeys={},Object.assign(this,t),this.event=t.event,this._strategy=e,this._handlerDeferred=new F,this._extendLifetimePromises=[],this._plugins=[...e.plugins],this._pluginStateMap=new Map;for(const s of this._plugins)this._pluginStateMap.set(s,{});this.event.waitUntil(this._handlerDeferred.promise)}async fetch(e){const{event:t}=this;let s=C(e);if(s.mode==="navigate"&&t instanceof FetchEvent&&t.preloadResponse){const r=await t.preloadResponse;if(r)return r}const a=this.hasCallback("fetchDidFail")?s.clone():null;try{for(const r of this.iterateCallbacks("requestWillFetch"))s=await r({request:s.clone(),event:t})}catch(r){if(r instanceof Error)throw new h("plugin-error-request-will-fetch",{thrownErrorMessage:r.message})}const i=s.clone();try{let r;r=await fetch(s,s.mode==="navigate"?void 0:this._strategy.fetchOptions);for(const c of this.iterateCallbacks("fetchDidSucceed"))r=await c({event:t,request:i,response:r});return r}catch(r){throw a&&await this.runCallbacks("fetchDidFail",{error:r,event:t,originalRequest:a.clone(),request:i.clone()}),r}}async fetchAndCachePut(e){const t=await this.fetch(e),s=t.clone();return this.waitUntil(this.cachePut(e,s)),t}async cacheMatch(e){const t=C(e);let s;const{cacheName:a,matchOptions:i}=this._strategy,r=await this.getCacheKey(t,"read"),c=Object.assign(Object.assign({},i),{cacheName:a});s=await caches.match(r,c);for(const o of this.iterateCallbacks("cachedResponseWillBeUsed"))s=await o({cacheName:a,matchOptions:i,cachedResponse:s,request:r,event:this.event})||void 0;return s}async cachePut(e,t){const s=C(e);await V(0);const a=await this.getCacheKey(s,"write");if(!t)throw new h("cache-put-with-no-response",{url:D(a.url)});const i=await this._ensureResponseSafeToCache(t);if(!i)return!1;const{cacheName:r,matchOptions:c}=this._strategy,o=await self.caches.open(r),l=this.hasCallback("cacheDidUpdate"),d=l?await H(o,a.clone(),["__WB_REVISION__"],c):null;try{await o.put(a,l?i.clone():i)}catch(u){if(u instanceof Error)throw u.name==="QuotaExceededError"&&await $(),u}for(const u of this.iterateCallbacks("cacheDidUpdate"))await u({cacheName:r,oldResponse:d,newResponse:i.clone(),request:a,event:this.event});return!0}async getCacheKey(e,t){const s=`${e.url} | ${t}`;if(!this._cacheKeys[s]){let a=e;for(const i of this.iterateCallbacks("cacheKeyWillBeUsed"))a=C(await i({mode:t,request:a,event:this.event,params:this.params}));this._cacheKeys[s]=a}return this._cacheKeys[s]}hasCallback(e){for(const t of this._strategy.plugins)if(e in t)return!0;return!1}async runCallbacks(e,t){for(const s of this.iterateCallbacks(e))await s(t)}*iterateCallbacks(e){for(const t of this._strategy.plugins)if(typeof t[e]=="function"){const s=this._pluginStateMap.get(t);yield i=>{const r=Object.assign(Object.assign({},i),{state:s});return t[e](r)}}}waitUntil(e){return this._extendLifetimePromises.push(e),e}async doneWaiting(){for(;this._extendLifetimePromises.length;){const e=this._extendLifetimePromises.splice(0),s=(await Promise.allSettled(e)).find(a=>a.status==="rejected");if(s)throw s.reason}}destroy(){this._handlerDeferred.resolve(null)}async _ensureResponseSafeToCache(e){let t=e,s=!1;for(const a of this.iterateCallbacks("cacheWillUpdate"))if(t=await a({request:this.request,response:t,event:this.event})||void 0,s=!0,!t)break;return s||t&&t.status!==200&&(t=void 0),t}}class J{constructor(e={}){this.cacheName=L.getRuntimeName(e.cacheName),this.plugins=e.plugins||[],this.fetchOptions=e.fetchOptions,this.matchOptions=e.matchOptions}handle(e){const[t]=this.handleAll(e);return t}handleAll(e){e instanceof FetchEvent&&(e={event:e,request:e.request});const t=e.event,s=typeof e.request=="string"?new Request(e.request):e.request,a="params"in e?e.params:void 0,i=new G(this,{event:t,request:s,params:a}),r=this._getResponse(i,s,t),c=this._awaitComplete(r,i,s,t);return[r,c]}async _getResponse(e,t,s){await e.runCallbacks("handlerWillStart",{event:s,request:t});let a;try{if(a=await this._handle(t,e),!a||a.type==="error")throw new h("no-response",{url:t.url})}catch(i){if(i instanceof Error){for(const r of e.iterateCallbacks("handlerDidError"))if(a=await r({error:i,event:s,request:t}),a)break}if(!a)throw i}for(const i of e.iterateCallbacks("handlerWillRespond"))a=await i({event:s,request:t,response:a});return a}async _awaitComplete(e,t,s,a){let i,r;try{i=await e}catch{}try{await t.runCallbacks("handlerDidRespond",{event:a,request:s,response:i}),await t.doneWaiting()}catch(c){c instanceof Error&&(r=c)}if(await t.runCallbacks("handlerDidComplete",{event:a,request:s,response:i,error:r}),t.destroy(),r)throw r}}class p extends J{constructor(e={}){e.cacheName=L.getPrecacheName(e.cacheName),super(e),this._fallbackToNetwork=e.fallbackToNetwork!==!1,this.plugins.push(p.copyRedirectedCacheableResponsesPlugin)}async _handle(e,t){const s=await t.cacheMatch(e);return s||(t.event&&t.event.type==="install"?await this._handleInstall(e,t):await this._handleFetch(e,t))}async _handleFetch(e,t){let s;const a=t.params||{};if(this._fallbackToNetwork){const i=a.integrity,r=e.integrity,c=!r||r===i;s=await t.fetch(new Request(e,{integrity:e.mode!=="no-cors"?r||i:void 0})),i&&c&&e.mode!=="no-cors"&&(this._useDefaultCacheabilityPluginIfNeeded(),await t.cachePut(e,s.clone()))}else throw new h("missing-precache-entry",{cacheName:this.cacheName,url:e.url});return s}async _handleInstall(e,t){this._useDefaultCacheabilityPluginIfNeeded();const s=await t.fetch(e);if(!await t.cachePut(e,s.clone()))throw new h("bad-precaching-response",{url:e.url,status:s.status});return s}_useDefaultCacheabilityPluginIfNeeded(){let e=null,t=0;for(const[s,a]of this.plugins.entries())a!==p.copyRedirectedCacheableResponsesPlugin&&(a===p.defaultPrecacheCacheabilityPlugin&&(e=s),a.cacheWillUpdate&&t++);t===0?this.plugins.push(p.defaultPrecacheCacheabilityPlugin):t>1&&e!==null&&this.plugins.splice(e,1)}}p.defaultPrecacheCacheabilityPlugin={async cacheWillUpdate({response:n}){return!n||n.status>=400?null:n}};p.copyRedirectedCacheableResponsesPlugin={async cacheWillUpdate({response:n}){return n.redirected?await j(n):n}};class Q{constructor({cacheName:e,plugins:t=[],fallbackToNetwork:s=!0}={}){this._urlsToCacheKeys=new Map,this._urlsToCacheModes=new Map,this._cacheKeysToIntegrities=new Map,this._strategy=new p({cacheName:L.getPrecacheName(e),plugins:[...t,new q({precacheController:this})],fallbackToNetwork:s}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this._strategy}precache(e){this.addToCacheList(e),this._installAndActiveListenersAdded||(self.addEventListener("install",this.install),self.addEventListener("activate",this.activate),this._installAndActiveListenersAdded=!0)}addToCacheList(e){const t=[];for(const s of e){typeof s=="string"?t.push(s):s&&s.revision===void 0&&t.push(s.url);const{cacheKey:a,url:i}=M(s),r=typeof s!="string"&&s.revision?"reload":"default";if(this._urlsToCacheKeys.has(i)&&this._urlsToCacheKeys.get(i)!==a)throw new h("add-to-cache-list-conflicting-entries",{firstEntry:this._urlsToCacheKeys.get(i),secondEntry:a});if(typeof s!="string"&&s.integrity){if(this._cacheKeysToIntegrities.has(a)&&this._cacheKeysToIntegrities.get(a)!==s.integrity)throw new h("add-to-cache-list-conflicting-integrities",{url:i});this._cacheKeysToIntegrities.set(a,s.integrity)}if(this._urlsToCacheKeys.set(i,a),this._urlsToCacheModes.set(i,r),t.length>0){const c=`Workbox is precaching URLs without revision info: ${t.join(", ")}
|
|
2
|
-
This is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(c)}}}install(e){return v(e,async()=>{const t=new W;this.strategy.plugins.push(t);for(const[i,r]of this._urlsToCacheKeys){const c=this._cacheKeysToIntegrities.get(r),o=this._urlsToCacheModes.get(i),l=new Request(i,{integrity:c,cache:o,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:r},request:l,event:e}))}const{updatedURLs:s,notUpdatedURLs:a}=t;return{updatedURLs:s,notUpdatedURLs:a}})}activate(e){return v(e,async()=>{const t=await self.caches.open(this.strategy.cacheName),s=await t.keys(),a=new Set(this._urlsToCacheKeys.values()),i=[];for(const r of s)a.has(r.url)||(await t.delete(r),i.push(r.url));return{deletedURLs:i}})}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){const t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){const t=e instanceof Request?e.url:e,s=this.getCacheKeyForURL(t);if(s)return(await self.caches.open(this.strategy.cacheName)).match(s)}createHandlerBoundToURL(e){const t=this.getCacheKeyForURL(e);if(!t)throw new h("non-precached-url",{url:e});return s=>(s.request=new Request(e),s.params=Object.assign({cacheKey:t},s.params),this.strategy.handle(s))}}let k;const x=()=>(k||(k=new Q),k);try{self["workbox:routing:7.3.0"]&&_()}catch{}const I="GET",b=n=>n&&typeof n=="object"?n:{handle:n};class R{constructor(e,t,s=I){this.handler=b(t),this.match=e,this.method=s}setCatchHandler(e){this.catchHandler=b(e)}}class z extends R{constructor(e,t,s){const a=({url:i})=>{const r=e.exec(i.href);if(r&&!(i.origin!==location.origin&&r.index!==0))return r.slice(1)};super(a,t,s)}}class X{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener("fetch",(e=>{const{request:t}=e,s=this.handleRequest({request:t,event:e});s&&e.respondWith(s)}))}addCacheListener(){self.addEventListener("message",(e=>{if(e.data&&e.data.type==="CACHE_URLS"){const{payload:t}=e.data,s=Promise.all(t.urlsToCache.map(a=>{typeof a=="string"&&(a=[a]);const i=new Request(...a);return this.handleRequest({request:i,event:e})}));e.waitUntil(s),e.ports&&e.ports[0]&&s.then(()=>e.ports[0].postMessage(!0))}}))}handleRequest({request:e,event:t}){const s=new URL(e.url,location.href);if(!s.protocol.startsWith("http"))return;const a=s.origin===location.origin,{params:i,route:r}=this.findMatchingRoute({event:t,request:e,sameOrigin:a,url:s});let c=r&&r.handler;const o=e.method;if(!c&&this._defaultHandlerMap.has(o)&&(c=this._defaultHandlerMap.get(o)),!c)return;let l;try{l=c.handle({url:s,request:e,event:t,params:i})}catch(u){l=Promise.reject(u)}const d=r&&r.catchHandler;return l instanceof Promise&&(this._catchHandler||d)&&(l=l.catch(async u=>{if(d)try{return await d.handle({url:s,request:e,event:t,params:i})}catch(g){g instanceof Error&&(u=g)}if(this._catchHandler)return this._catchHandler.handle({url:s,request:e,event:t});throw u})),l}findMatchingRoute({url:e,sameOrigin:t,request:s,event:a}){const i=this._routes.get(s.method)||[];for(const r of i){let c;const o=r.match({url:e,sameOrigin:t,request:s,event:a});if(o)return c=o,(Array.isArray(c)&&c.length===0||o.constructor===Object&&Object.keys(o).length===0||typeof o=="boolean")&&(c=void 0),{route:r,params:c}}return{}}setDefaultHandler(e,t=I){this._defaultHandlerMap.set(t,b(e))}setCatchHandler(e){this._catchHandler=b(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new h("unregister-route-but-not-found-with-method",{method:e.method});const t=this._routes.get(e.method).indexOf(e);if(t>-1)this._routes.get(e.method).splice(t,1);else throw new h("unregister-route-route-not-registered")}}let m;const Y=()=>(m||(m=new X,m.addFetchListener(),m.addCacheListener()),m);function Z(n,e,t){let s;if(typeof n=="string"){const i=new URL(n,location.href),r=({url:c})=>c.href===i.href;s=new R(r,e,t)}else if(n instanceof RegExp)s=new z(n,e,t);else if(typeof n=="function")s=new R(n,e,t);else if(n instanceof R)s=n;else throw new h("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});return Y().registerRoute(s),s}function ee(n,e=[]){for(const t of[...n.searchParams.keys()])e.some(s=>s.test(t))&&n.searchParams.delete(t);return n}function*te(n,{ignoreURLParametersMatching:e=[/^utm_/,/^fbclid$/],directoryIndex:t="index.html",cleanURLs:s=!0,urlManipulation:a}={}){const i=new URL(n,location.href);i.hash="",yield i.href;const r=ee(i,e);if(yield r.href,t&&r.pathname.endsWith("/")){const c=new URL(r.href);c.pathname+=t,yield c.href}if(s){const c=new URL(r.href);c.pathname+=".html",yield c.href}if(a){const c=a({url:i});for(const o of c)yield o.href}}class se extends R{constructor(e,t){const s=({request:a})=>{const i=e.getURLsToCacheKeys();for(const r of te(a.url,t)){const c=i.get(r);if(c){const o=e.getIntegrityForCacheKey(c);return{cacheKey:c,integrity:o}}}};super(s,e.strategy)}}function ne(n){const e=x(),t=new se(e,n);Z(t)}function ae(n){x().precache(n)}function ie(n,e){ae(n),ne(e)}ie([{"revision":"38013143dc2183340ede8bc1c5124507","url":"registerSW.js"},{"revision":"
|
|
2
|
+
This is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(c)}}}install(e){return v(e,async()=>{const t=new W;this.strategy.plugins.push(t);for(const[i,r]of this._urlsToCacheKeys){const c=this._cacheKeysToIntegrities.get(r),o=this._urlsToCacheModes.get(i),l=new Request(i,{integrity:c,cache:o,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:r},request:l,event:e}))}const{updatedURLs:s,notUpdatedURLs:a}=t;return{updatedURLs:s,notUpdatedURLs:a}})}activate(e){return v(e,async()=>{const t=await self.caches.open(this.strategy.cacheName),s=await t.keys(),a=new Set(this._urlsToCacheKeys.values()),i=[];for(const r of s)a.has(r.url)||(await t.delete(r),i.push(r.url));return{deletedURLs:i}})}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){const t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){const t=e instanceof Request?e.url:e,s=this.getCacheKeyForURL(t);if(s)return(await self.caches.open(this.strategy.cacheName)).match(s)}createHandlerBoundToURL(e){const t=this.getCacheKeyForURL(e);if(!t)throw new h("non-precached-url",{url:e});return s=>(s.request=new Request(e),s.params=Object.assign({cacheKey:t},s.params),this.strategy.handle(s))}}let k;const x=()=>(k||(k=new Q),k);try{self["workbox:routing:7.3.0"]&&_()}catch{}const I="GET",b=n=>n&&typeof n=="object"?n:{handle:n};class R{constructor(e,t,s=I){this.handler=b(t),this.match=e,this.method=s}setCatchHandler(e){this.catchHandler=b(e)}}class z extends R{constructor(e,t,s){const a=({url:i})=>{const r=e.exec(i.href);if(r&&!(i.origin!==location.origin&&r.index!==0))return r.slice(1)};super(a,t,s)}}class X{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener("fetch",(e=>{const{request:t}=e,s=this.handleRequest({request:t,event:e});s&&e.respondWith(s)}))}addCacheListener(){self.addEventListener("message",(e=>{if(e.data&&e.data.type==="CACHE_URLS"){const{payload:t}=e.data,s=Promise.all(t.urlsToCache.map(a=>{typeof a=="string"&&(a=[a]);const i=new Request(...a);return this.handleRequest({request:i,event:e})}));e.waitUntil(s),e.ports&&e.ports[0]&&s.then(()=>e.ports[0].postMessage(!0))}}))}handleRequest({request:e,event:t}){const s=new URL(e.url,location.href);if(!s.protocol.startsWith("http"))return;const a=s.origin===location.origin,{params:i,route:r}=this.findMatchingRoute({event:t,request:e,sameOrigin:a,url:s});let c=r&&r.handler;const o=e.method;if(!c&&this._defaultHandlerMap.has(o)&&(c=this._defaultHandlerMap.get(o)),!c)return;let l;try{l=c.handle({url:s,request:e,event:t,params:i})}catch(u){l=Promise.reject(u)}const d=r&&r.catchHandler;return l instanceof Promise&&(this._catchHandler||d)&&(l=l.catch(async u=>{if(d)try{return await d.handle({url:s,request:e,event:t,params:i})}catch(g){g instanceof Error&&(u=g)}if(this._catchHandler)return this._catchHandler.handle({url:s,request:e,event:t});throw u})),l}findMatchingRoute({url:e,sameOrigin:t,request:s,event:a}){const i=this._routes.get(s.method)||[];for(const r of i){let c;const o=r.match({url:e,sameOrigin:t,request:s,event:a});if(o)return c=o,(Array.isArray(c)&&c.length===0||o.constructor===Object&&Object.keys(o).length===0||typeof o=="boolean")&&(c=void 0),{route:r,params:c}}return{}}setDefaultHandler(e,t=I){this._defaultHandlerMap.set(t,b(e))}setCatchHandler(e){this._catchHandler=b(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new h("unregister-route-but-not-found-with-method",{method:e.method});const t=this._routes.get(e.method).indexOf(e);if(t>-1)this._routes.get(e.method).splice(t,1);else throw new h("unregister-route-route-not-registered")}}let m;const Y=()=>(m||(m=new X,m.addFetchListener(),m.addCacheListener()),m);function Z(n,e,t){let s;if(typeof n=="string"){const i=new URL(n,location.href),r=({url:c})=>c.href===i.href;s=new R(r,e,t)}else if(n instanceof RegExp)s=new z(n,e,t);else if(typeof n=="function")s=new R(n,e,t);else if(n instanceof R)s=n;else throw new h("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});return Y().registerRoute(s),s}function ee(n,e=[]){for(const t of[...n.searchParams.keys()])e.some(s=>s.test(t))&&n.searchParams.delete(t);return n}function*te(n,{ignoreURLParametersMatching:e=[/^utm_/,/^fbclid$/],directoryIndex:t="index.html",cleanURLs:s=!0,urlManipulation:a}={}){const i=new URL(n,location.href);i.hash="",yield i.href;const r=ee(i,e);if(yield r.href,t&&r.pathname.endsWith("/")){const c=new URL(r.href);c.pathname+=t,yield c.href}if(s){const c=new URL(r.href);c.pathname+=".html",yield c.href}if(a){const c=a({url:i});for(const o of c)yield o.href}}class se extends R{constructor(e,t){const s=({request:a})=>{const i=e.getURLsToCacheKeys();for(const r of te(a.url,t)){const c=i.get(r);if(c){const o=e.getIntegrityForCacheKey(c);return{cacheKey:c,integrity:o}}}};super(s,e.strategy)}}function ne(n){const e=x(),t=new se(e,n);Z(t)}function ae(n){x().precache(n)}function ie(n,e){ae(n),ne(e)}ie([{"revision":"38013143dc2183340ede8bc1c5124507","url":"registerSW.js"},{"revision":"7932c200bac35280617b0b0b6fdce381","url":"index.html"},{"revision":null,"url":"assets/web-zj8Blync.js"},{"revision":null,"url":"assets/web-C48txJFl.js"},{"revision":null,"url":"assets/index-CZejk2al.js"},{"revision":null,"url":"assets/index-C6Lz09EY.css"},{"revision":"fcc457fce855ad0df7178e0786c0d4ef","url":"apple-touch-icon.png"},{"revision":"276650c30bc4effc7d649ec66519aab6","url":"favicon.ico"},{"revision":"2e46512b835c05e17787059909305f22","url":"pwa-192x192.png"},{"revision":"ec5652b5834b4711337743e80e506a41","url":"pwa-512x512.png"},{"revision":"9f51698004b9cc4d787c75695b74de9d","url":"manifest.webmanifest"}]);const re="/api/push/respond";self.addEventListener("message",n=>{});self.addEventListener("push",n=>{var r;if(!n.data)return;let e;try{e=n.data.json()}catch{e={title:"Palmier",body:n.data.text()}}const t=e.type??((r=e.data)==null?void 0:r.type);if(t==="confirm-dismiss"||t==="permission-dismiss"||t==="input-dismiss"){const c=e.data??e,o=c.host_id,l=c.session_id,d=c.task_id;n.waitUntil(self.registration.getNotifications().then(u=>{var g,P,K;for(const y of u)if(((g=y.data)==null?void 0:g.host_id)===o){if(l&&((P=y.data)==null?void 0:P.session_id)===l){y.close();continue}d&&((K=y.data)==null?void 0:K.task_id)===d&&y.close()}}));return}const s=e.title??"Palmier";let a=e.body??"";!a&&t==="confirm"&&(a="A task requires confirmation to run."),!a&&t==="permission"&&(a="A task needs additional permissions to continue."),!a&&t==="input"&&(a="A task needs your input to continue.");const i={body:a,icon:"/pwa-192x192.png",badge:"/pwa-192x192.png",data:e.data??e,vibrate:[100,50,100]};t==="confirm"&&(i.actions=[{action:"confirm",title:"Confirm"},{action:"abort",title:"Abort"}]),n.waitUntil(self.registration.showNotification(s,i))});self.addEventListener("notificationclick",n=>{const e=n.notification;e.close();const t=e.data??{},s=n.action;if(s&&t.type==="confirm"&&t.session_id&&t.host_id){const a=s==="confirm"?"confirmed":"aborted";n.waitUntil(fetch(re,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:t.session_id,host_id:t.host_id,response:a})}).catch(i=>{console.error("Failed to send push response:",i)}))}else{const a=t.task_id,i=t.run_id,r=a&&i?`/runs/${encodeURIComponent(a)}/${encodeURIComponent(i)}`:a?`/runs/${encodeURIComponent(a)}/latest`:"/";n.waitUntil(self.clients.matchAll({type:"window",includeUncontrolled:!0}).then(c=>{for(const o of c)if(o.url.includes(self.location.origin)&&"focus"in o)return o.navigate(r),o.focus();return self.clients.openWindow(r)}))}});self.addEventListener("install",()=>{self.skipWaiting()});self.addEventListener("activate",n=>{n.waitUntil(self.clients.claim())});
|
package/dist/rpc-handler.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from "crypto";
|
|
2
2
|
import * as fs from "fs";
|
|
3
3
|
import * as path from "path";
|
|
4
|
-
import { fileURLToPath } from "url";
|
|
5
4
|
import { spawn } from "child_process";
|
|
6
|
-
import { parse as parseYaml } from "yaml";
|
|
7
5
|
import { listTasks, parseTaskFile, writeTaskFile, getTaskDir, readTaskStatus, writeTaskStatus, readHistory, deleteHistoryEntry, appendTaskList, removeFromTaskList, appendHistory, createRunDir, appendRunMessage, getRunDir } from "./task.js";
|
|
8
6
|
import { resolvePending, getPending } from "./pending-requests.js";
|
|
9
7
|
import { getPlatform } from "./platform/index.js";
|
|
@@ -15,8 +13,6 @@ import { publishHostEvent } from "./events.js";
|
|
|
15
13
|
import { getLocationDevice, setLocationDevice, clearLocationDevice } from "./location-device.js";
|
|
16
14
|
import { currentVersion, performUpdate } from "./update-checker.js";
|
|
17
15
|
import { parseReportFiles, parseTaskOutcome, stripPalmierMarkers } from "./commands/run.js";
|
|
18
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
19
|
-
const PLAN_GENERATION_PROMPT = fs.readFileSync(path.join(__dirname, "commands", "plan-generation.md"), "utf-8");
|
|
20
16
|
/**
|
|
21
17
|
* Parse RESULT frontmatter and conversation messages.
|
|
22
18
|
*/
|
|
@@ -98,34 +94,26 @@ function parseAttr(attrs, name) {
|
|
|
98
94
|
return match ? match[1] : undefined;
|
|
99
95
|
}
|
|
100
96
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
97
|
+
* Generate a concise task name from a user prompt using the given agent.
|
|
98
|
+
* Falls back to the raw prompt on failure.
|
|
103
99
|
*/
|
|
104
|
-
async function
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
const { command, args, stdin, env: agentEnv } =
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const fm = parseYaml(fmMatch[1]);
|
|
121
|
-
name = fm.task_name ?? "";
|
|
122
|
-
}
|
|
123
|
-
catch {
|
|
124
|
-
// If frontmatter parsing fails, treat entire output as body
|
|
125
|
-
}
|
|
126
|
-
body = fmMatch[2].trimStart();
|
|
100
|
+
async function generateName(projectRoot, userPrompt, agentName) {
|
|
101
|
+
const prompt = `Generate a concise 3-6 word name for this task. Reply with ONLY the name, nothing else.\n\nTask: ${userPrompt}`;
|
|
102
|
+
const agent = getAgent(agentName);
|
|
103
|
+
const { command, args, stdin, env: agentEnv } = agent.getPromptCommandLine(prompt);
|
|
104
|
+
try {
|
|
105
|
+
const { output } = await spawnCommand(command, args, {
|
|
106
|
+
cwd: projectRoot,
|
|
107
|
+
timeout: 30_000,
|
|
108
|
+
stdin,
|
|
109
|
+
...(agentEnv ? { env: agentEnv } : {}),
|
|
110
|
+
});
|
|
111
|
+
const name = output.trim().replace(/^["']|["']$/g, "").slice(0, 80);
|
|
112
|
+
return name || userPrompt;
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return userPrompt;
|
|
127
116
|
}
|
|
128
|
-
return { name, body };
|
|
129
117
|
}
|
|
130
118
|
/** Active follow-up child processes, keyed by "taskId:runId". */
|
|
131
119
|
const activeFollowups = new Map();
|
|
@@ -139,7 +127,6 @@ export function createRpcHandler(config, nc) {
|
|
|
139
127
|
const pending = getPending(task.frontmatter.id);
|
|
140
128
|
return {
|
|
141
129
|
...task.frontmatter,
|
|
142
|
-
body: task.body,
|
|
143
130
|
status: status ? {
|
|
144
131
|
...status,
|
|
145
132
|
...(pending?.type === "permission" ? { pending_permission: pending.params } : {}),
|
|
@@ -178,23 +165,9 @@ export function createRpcHandler(config, nc) {
|
|
|
178
165
|
}
|
|
179
166
|
case "task.create": {
|
|
180
167
|
const params = request.params;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
if (params.user_prompt.length <= 50) {
|
|
185
|
-
name = params.user_prompt;
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
try {
|
|
189
|
-
const plan = await generatePlan(config.projectRoot, params.user_prompt, params.agent);
|
|
190
|
-
name = plan.name;
|
|
191
|
-
body = plan.body;
|
|
192
|
-
}
|
|
193
|
-
catch (err) {
|
|
194
|
-
const error = err;
|
|
195
|
-
return { error: "plan generation failed", stdout: error.stdout, stderr: error.stderr };
|
|
196
|
-
}
|
|
197
|
-
}
|
|
168
|
+
const name = params.user_prompt.length <= 50
|
|
169
|
+
? params.user_prompt
|
|
170
|
+
: await generateName(config.projectRoot, params.user_prompt, params.agent);
|
|
198
171
|
const id = randomUUID();
|
|
199
172
|
const taskDir = getTaskDir(config.projectRoot, id);
|
|
200
173
|
const task = {
|
|
@@ -210,7 +183,6 @@ export function createRpcHandler(config, nc) {
|
|
|
210
183
|
...(params.foreground_mode ? { foreground_mode: true } : {}),
|
|
211
184
|
...(params.command ? { command: params.command } : {}),
|
|
212
185
|
},
|
|
213
|
-
body,
|
|
214
186
|
};
|
|
215
187
|
writeTaskFile(taskDir, task);
|
|
216
188
|
appendTaskList(config.projectRoot, id);
|
|
@@ -221,10 +193,9 @@ export function createRpcHandler(config, nc) {
|
|
|
221
193
|
const params = request.params;
|
|
222
194
|
const taskDir = getTaskDir(config.projectRoot, params.id);
|
|
223
195
|
const existing = parseTaskFile(taskDir);
|
|
224
|
-
// Detect whether
|
|
196
|
+
// Detect whether name needs regeneration
|
|
225
197
|
const promptChanged = params.user_prompt !== undefined && params.user_prompt !== existing.frontmatter.user_prompt;
|
|
226
198
|
const agentChanged = params.agent !== undefined && params.agent !== existing.frontmatter.agent;
|
|
227
|
-
const needsRegeneration = promptChanged || agentChanged || !existing.body;
|
|
228
199
|
// Merge updates
|
|
229
200
|
if (params.user_prompt !== undefined)
|
|
230
201
|
existing.frontmatter.user_prompt = params.user_prompt;
|
|
@@ -251,21 +222,11 @@ export function createRpcHandler(config, nc) {
|
|
|
251
222
|
delete existing.frontmatter.command;
|
|
252
223
|
}
|
|
253
224
|
}
|
|
254
|
-
// Regenerate
|
|
255
|
-
if (
|
|
256
|
-
existing.frontmatter.name = existing.frontmatter.user_prompt
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
else if (needsRegeneration) {
|
|
260
|
-
try {
|
|
261
|
-
const plan = await generatePlan(config.projectRoot, existing.frontmatter.user_prompt, existing.frontmatter.agent);
|
|
262
|
-
existing.frontmatter.name = plan.name;
|
|
263
|
-
existing.body = plan.body;
|
|
264
|
-
}
|
|
265
|
-
catch (err) {
|
|
266
|
-
const error = err;
|
|
267
|
-
return { error: "plan generation failed", stdout: error.stdout, stderr: error.stderr };
|
|
268
|
-
}
|
|
225
|
+
// Regenerate name when prompt or agent changes
|
|
226
|
+
if (promptChanged || agentChanged) {
|
|
227
|
+
existing.frontmatter.name = existing.frontmatter.user_prompt.length <= 50
|
|
228
|
+
? existing.frontmatter.user_prompt
|
|
229
|
+
: await generateName(config.projectRoot, existing.frontmatter.user_prompt, existing.frontmatter.agent);
|
|
269
230
|
}
|
|
270
231
|
writeTaskFile(taskDir, existing);
|
|
271
232
|
// Update timers — installTaskTimer overwrites in-place (schtasks /f,
|
|
@@ -297,7 +258,6 @@ export function createRpcHandler(config, nc) {
|
|
|
297
258
|
...(params.foreground_mode ? { foreground_mode: true } : {}),
|
|
298
259
|
...(params.command ? { command: params.command } : {}),
|
|
299
260
|
},
|
|
300
|
-
body: "",
|
|
301
261
|
};
|
|
302
262
|
writeTaskFile(taskDir, task);
|
|
303
263
|
// Do NOT append to tasks.jsonl — this is a one-off run
|