@tickernelz/paperclip-pro-server 2026.930.3 → 2026.930.5

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.
Files changed (27) hide show
  1. package/dist/build-info.json +1 -1
  2. package/dist/routes/issues.d.ts.map +1 -1
  3. package/dist/routes/issues.js +67 -2
  4. package/dist/routes/issues.js.map +1 -1
  5. package/dist/routes/openapi.d.ts.map +1 -1
  6. package/dist/routes/openapi.js +1 -0
  7. package/dist/routes/openapi.js.map +1 -1
  8. package/dist/services/agents.d.ts +10 -10
  9. package/dist/services/connectors/slack.d.ts +13 -13
  10. package/node_modules/remend/dist/index.d.ts +3 -2
  11. package/node_modules/remend/dist/index.js +23 -20
  12. package/node_modules/remend/package.json +3 -2
  13. package/package.json +21 -21
  14. package/skills/paperclip/SKILL.md +2 -0
  15. package/skills/paperclip/references/api-reference.md +2 -0
  16. package/ui-dist/assets/{Agents.production-VItybUXr.js → Agents.production-CznvSxPb.js} +2 -2
  17. package/ui-dist/assets/{CompanyActivity.production-CwZwgQQV.js → CompanyActivity.production-DGPmuiMK.js} +1 -1
  18. package/ui-dist/assets/{CompanyExport-DD7Rya_d.js → CompanyExport-B2_MyBAa.js} +1 -1
  19. package/ui-dist/assets/{CompanySkills.production-Bwg9FRuw.js → CompanySkills.production-CbLMWon3.js} +1 -1
  20. package/ui-dist/assets/{Costs.production-lULBU1r3.js → Costs.production-CXw68OcC.js} +1 -1
  21. package/ui-dist/assets/{OrgChart.production-C7exT9VZ.js → OrgChart.production-DO92Tc-H.js} +1 -1
  22. package/ui-dist/assets/{RoutineDetail.production-DsZSvOON.js → RoutineDetail.production-BGIyenmz.js} +1 -1
  23. package/ui-dist/assets/{Routines.production-BsmVAcGo.js → Routines.production-1FAJghn4.js} +1 -1
  24. package/ui-dist/assets/{definition-RMjpvqXu.js → definition-nDpkq-TP.js} +1 -1
  25. package/ui-dist/assets/{index-DU74KtHt.js → index-9OR5EiR3.js} +4 -4
  26. package/ui-dist/index.html +1 -1
  27. package/ui-dist/sw.js +1 -1
@@ -497,14 +497,14 @@ export declare function agentService(db: Db): {
497
497
  id: string;
498
498
  name: string;
499
499
  scope: {
500
+ kind: "standard";
501
+ } | {
500
502
  kind: "task_bridge";
501
503
  projectId?: string | null | undefined;
502
504
  projectIds?: string[] | undefined;
503
505
  parentIssueId?: string | null | undefined;
504
506
  parentIssueIds?: string[] | undefined;
505
507
  allowedAssigneeAgentIds?: string[] | undefined;
506
- } | {
507
- kind: "standard";
508
508
  } | {
509
509
  kind: "skill_test";
510
510
  issueId: string;
@@ -517,14 +517,14 @@ export declare function agentService(db: Db): {
517
517
  id: string;
518
518
  name: string;
519
519
  scope: {
520
+ kind: "standard";
521
+ } | {
520
522
  kind: "task_bridge";
521
523
  projectId?: string | null | undefined;
522
524
  projectIds?: string[] | undefined;
523
525
  parentIssueId?: string | null | undefined;
524
526
  parentIssueIds?: string[] | undefined;
525
527
  allowedAssigneeAgentIds?: string[] | undefined;
526
- } | {
527
- kind: "standard";
528
528
  } | {
529
529
  kind: "skill_test";
530
530
  issueId: string;
@@ -540,14 +540,14 @@ export declare function agentService(db: Db): {
540
540
  name: string;
541
541
  responsibleUserId: string | null;
542
542
  scopeConfig: {
543
+ kind: "standard";
544
+ } | {
543
545
  kind: "task_bridge";
544
546
  projectId?: string | null | undefined;
545
547
  projectIds?: string[] | undefined;
546
548
  parentIssueId?: string | null | undefined;
547
549
  parentIssueIds?: string[] | undefined;
548
550
  allowedAssigneeAgentIds?: string[] | undefined;
549
- } | {
550
- kind: "standard";
551
551
  } | {
552
552
  kind: "skill_test";
553
553
  issueId: string;
@@ -555,14 +555,14 @@ export declare function agentService(db: Db): {
555
555
  createdAt: Date;
556
556
  revokedAt: Date | null;
557
557
  scope: {
558
+ kind: "standard";
559
+ } | {
558
560
  kind: "task_bridge";
559
561
  projectId?: string | null | undefined;
560
562
  projectIds?: string[] | undefined;
561
563
  parentIssueId?: string | null | undefined;
562
564
  parentIssueIds?: string[] | undefined;
563
565
  allowedAssigneeAgentIds?: string[] | undefined;
564
- } | {
565
- kind: "standard";
566
566
  } | {
567
567
  kind: "skill_test";
568
568
  issueId: string;
@@ -576,14 +576,14 @@ export declare function agentService(db: Db): {
576
576
  keyHash: string;
577
577
  responsibleUserId: string | null;
578
578
  scopeConfig: {
579
+ kind: "standard";
580
+ } | {
579
581
  kind: "task_bridge";
580
582
  projectId?: string | null | undefined;
581
583
  projectIds?: string[] | undefined;
582
584
  parentIssueId?: string | null | undefined;
583
585
  parentIssueIds?: string[] | undefined;
584
586
  allowedAssigneeAgentIds?: string[] | undefined;
585
- } | {
586
- kind: "standard";
587
587
  } | {
588
588
  kind: "skill_test";
589
589
  issueId: string;
@@ -29,10 +29,10 @@ export declare function executeSlackTool(db: Db, binding: SlackTaskBinding, name
29
29
  state: string;
30
30
  instruction: string;
31
31
  } | {
32
- id?: undefined;
33
32
  channels: SlackObject[];
34
33
  nextCursor: string;
35
34
  coverage: string;
35
+ id?: undefined;
36
36
  name?: undefined;
37
37
  displayName?: undefined;
38
38
  realName?: undefined;
@@ -87,8 +87,8 @@ export declare function executeSlackTool(db: Db, binding: SlackTaskBinding, name
87
87
  pins?: undefined;
88
88
  bookmarks?: undefined;
89
89
  } | {
90
- id?: undefined;
91
90
  channels?: undefined;
91
+ id?: undefined;
92
92
  name?: undefined;
93
93
  displayName?: undefined;
94
94
  realName?: undefined;
@@ -116,8 +116,8 @@ export declare function executeSlackTool(db: Db, binding: SlackTaskBinding, name
116
116
  pins?: undefined;
117
117
  bookmarks?: undefined;
118
118
  } | {
119
- id?: undefined;
120
119
  channels?: undefined;
120
+ id?: undefined;
121
121
  name?: undefined;
122
122
  displayName?: undefined;
123
123
  realName?: undefined;
@@ -145,8 +145,8 @@ export declare function executeSlackTool(db: Db, binding: SlackTaskBinding, name
145
145
  pins?: undefined;
146
146
  bookmarks?: undefined;
147
147
  } | {
148
- id?: undefined;
149
148
  channels?: undefined;
149
+ id?: undefined;
150
150
  name?: undefined;
151
151
  displayName?: undefined;
152
152
  realName?: undefined;
@@ -182,8 +182,8 @@ export declare function executeSlackTool(db: Db, binding: SlackTaskBinding, name
182
182
  pins?: undefined;
183
183
  bookmarks?: undefined;
184
184
  } | {
185
- id?: undefined;
186
185
  channels?: undefined;
186
+ id?: undefined;
187
187
  name?: undefined;
188
188
  displayName?: undefined;
189
189
  realName?: undefined;
@@ -211,8 +211,8 @@ export declare function executeSlackTool(db: Db, binding: SlackTaskBinding, name
211
211
  pins?: undefined;
212
212
  bookmarks?: undefined;
213
213
  } | {
214
- id?: undefined;
215
214
  channels?: undefined;
215
+ id?: undefined;
216
216
  name?: undefined;
217
217
  displayName?: undefined;
218
218
  realName?: undefined;
@@ -254,8 +254,8 @@ export declare function executeSlackTool(db: Db, binding: SlackTaskBinding, name
254
254
  pins?: undefined;
255
255
  bookmarks?: undefined;
256
256
  } | {
257
- id?: undefined;
258
257
  channels?: undefined;
258
+ id?: undefined;
259
259
  name?: undefined;
260
260
  displayName?: undefined;
261
261
  realName?: undefined;
@@ -283,8 +283,8 @@ export declare function executeSlackTool(db: Db, binding: SlackTaskBinding, name
283
283
  pins?: undefined;
284
284
  bookmarks?: undefined;
285
285
  } | {
286
- id?: undefined;
287
286
  channels?: undefined;
287
+ id?: undefined;
288
288
  name?: undefined;
289
289
  displayName?: undefined;
290
290
  realName?: undefined;
@@ -312,8 +312,8 @@ export declare function executeSlackTool(db: Db, binding: SlackTaskBinding, name
312
312
  pins?: undefined;
313
313
  bookmarks?: undefined;
314
314
  } | {
315
- id?: undefined;
316
315
  channels?: undefined;
316
+ id?: undefined;
317
317
  name?: undefined;
318
318
  displayName?: undefined;
319
319
  realName?: undefined;
@@ -341,8 +341,8 @@ export declare function executeSlackTool(db: Db, binding: SlackTaskBinding, name
341
341
  pins?: undefined;
342
342
  bookmarks?: undefined;
343
343
  } | {
344
- id?: undefined;
345
344
  channels?: undefined;
345
+ id?: undefined;
346
346
  name?: undefined;
347
347
  displayName?: undefined;
348
348
  realName?: undefined;
@@ -377,8 +377,8 @@ export declare function executeSlackTool(db: Db, binding: SlackTaskBinding, name
377
377
  pins?: undefined;
378
378
  bookmarks?: undefined;
379
379
  } | {
380
- id?: undefined;
381
380
  channels?: undefined;
381
+ id?: undefined;
382
382
  name?: undefined;
383
383
  displayName?: undefined;
384
384
  realName?: undefined;
@@ -406,8 +406,8 @@ export declare function executeSlackTool(db: Db, binding: SlackTaskBinding, name
406
406
  pins?: undefined;
407
407
  bookmarks?: undefined;
408
408
  } | {
409
- id?: undefined;
410
409
  channels?: undefined;
410
+ id?: undefined;
411
411
  name?: undefined;
412
412
  displayName?: undefined;
413
413
  realName?: undefined;
@@ -452,8 +452,8 @@ export declare function executeSlackTool(db: Db, binding: SlackTaskBinding, name
452
452
  }[];
453
453
  bookmarks?: undefined;
454
454
  } | {
455
- id?: undefined;
456
455
  channels?: undefined;
456
+ id?: undefined;
457
457
  name?: undefined;
458
458
  displayName?: undefined;
459
459
  realName?: undefined;
@@ -1,4 +1,5 @@
1
1
  type LinkMode = "protocol" | "text-only";
2
+ declare const INCOMPLETE_IMAGE_PLACEHOLDER = "streamdown:incomplete-image";
2
3
 
3
4
  declare const isWordChar: (char: string) => boolean;
4
5
  declare const isWithinCodeBlock: (text: string, position: number) => boolean;
@@ -32,7 +33,7 @@ interface RemendOptions {
32
33
  handlers?: RemendHandler[];
33
34
  /** Strip incomplete HTML tags at end of streaming text (e.g., `text <custom` → `text`) */
34
35
  htmlTags?: boolean;
35
- /** Complete images (e.g., `![alt](url` → removed) */
36
+ /** Complete images (e.g., `![alt](url` → `![alt](streamdown:incomplete-image)`) */
36
37
  images?: boolean;
37
38
  /** Complete inline code formatting (e.g., `` `code `` → `` `code` ``) */
38
39
  inlineCode?: boolean;
@@ -62,4 +63,4 @@ interface RemendOptions {
62
63
  }
63
64
  declare const remend: (text: string, options?: RemendOptions) => string;
64
65
 
65
- export { type LinkMode, type RemendHandler, type RemendOptions, remend as default, isWithinCodeBlock, isWithinLinkOrImageUrl, isWithinMathBlock, isWordChar };
66
+ export { INCOMPLETE_IMAGE_PLACEHOLDER, type LinkMode, type RemendHandler, type RemendOptions, remend as default, isWithinCodeBlock, isWithinLinkOrImageUrl, isWithinMathBlock, isWordChar };
@@ -1,21 +1,24 @@
1
- var dn=Object.defineProperty,gn=Object.defineProperties;var hn=Object.getOwnPropertyDescriptors;var M=Object.getOwnPropertySymbols;var mn=Object.prototype.hasOwnProperty,pn=Object.prototype.propertyIsEnumerable;var P=(n,r,e)=>r in n?dn(n,r,{enumerable:true,configurable:true,writable:true,value:e}):n[r]=e,I=(n,r)=>{for(var e in r||(r={}))mn.call(r,e)&&P(n,e,r[e]);if(M)for(var e of M(r))pn.call(r,e)&&P(n,e,r[e]);return n},b=(n,r)=>gn(n,hn(r));var kn=n=>{let r=new Uint8Array(n.length+1),e=false,i=false,o=0;for(;o<n.length;){if(n[o]==="\\"&&o+1<n.length&&n[o+1]==="`"){let s=e||i?1:0;r[o+1]=s,r[o+2]=s,o+=2;continue}if(n.substring(o,o+3)==="```"){i=!i;let s=e||i?1:0,t=Math.min(o+3,n.length);for(let a=o+1;a<=t;a+=1)r[a]=s;o=t;continue}!i&&n[o]==="`"&&(e=!e),r[o+1]=e||i?1:0,o+=1;}return r},$=null,c=(n,r)=>{let e=$;return (e===null||e.text!==n)&&(e={text:n,lookup:kn(n)},$=e),e.lookup[Math.min(r,n.length)]===1},In=(n,r)=>{let e=n.substring(r,r+3)==="```",i=r>0&&n.substring(r-1,r+2)==="```",o=r>1&&n.substring(r-2,r+1)==="```";return e||i||o},E=n=>{let r=0;for(let e=0;e<n.length;e+=1){if(n[e]==="\\"&&e+1<n.length&&n[e+1]==="`"){e+=1;continue}n[e]==="`"&&!In(n,e)&&(r+=1);}return r},d=(n,r)=>{let e=false,i=false,o=-1;for(let s=0;s<n.length;s+=1){if(n[s]==="\\"&&s+1<n.length&&n[s+1]==="`"){s+=1;continue}if(n.substring(s,s+3)==="```"){i=!i,s+=2;continue}if(!i&&n[s]==="`")if(e){if(o<r&&r<s)return true;e=false,o=-1;}else e=true,o=s;}return false};var bn=/^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm,y=n=>!n||typeof n!="string"||!n.includes(">")?n:n.replace(bn,(r,e,i,o)=>c(n,o)?r:`${e}\\>${i}`);var N=/(\*\*)([^*]*\*?)$/,R=/(__)([^_]*?)$/,U=/(\*\*\*)([^*]*?)$/,W=/(\*)([^*]*?)$/,D=/(_)([^_]*?)$/,K=/(`)([^`]*?)$/,H=/(~~)([^~]*?)$/,g=/^[\s_~*`]*$/,C=/^[\s]*[-*+][\s]+$/,w=/[\p{L}\p{N}_]/u,G=/^```[^`\n]*```?$/,F=/^\*{4,}$/;var X=/(__)([^_]+)_$/,z=/(~~)([^~]+)~$/;var A=/~~/g;var f=n=>{if(!n)return false;let r=n.charCodeAt(0);return r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122||r===95?true:w.test(n)},Cn=(n,r)=>{let e=false;for(let i=0;i<r;i+=1)n[i]==="`"&&n[i+1]==="`"&&n[i+2]==="`"&&(e=!e,i+=2);return e},Y=(n,r)=>{let e=1;for(let i=r-1;i>=0;i-=1)if(n[i]==="]")e+=1;else if(n[i]==="["&&(e-=1,e===0))return i;return -1},T=(n,r)=>{let e=1;for(let i=r+1;i<n.length;i+=1)if(n[i]==="[")e+=1;else if(n[i]==="]"&&(e-=1,e===0))return i;return -1},An=n=>n==="inlineLatex"||n==="blockLatex",Tn=(n,r)=>r==="["&&n==="none"?"blockLatex":r==="]"&&n==="blockLatex"?"none":r==="("&&n==="none"?"inlineLatex":r===")"&&n==="inlineLatex"?"none":null,Ln=(n,r)=>r?n==="blockDollar"?"none":"blockDollar":n==="blockDollar"?n:n==="inlineDollar"?"none":"inlineDollar",h=(n,r)=>{let e="none";for(let i=0;i<n.length&&i<r;i+=1){if(n[i]==="\\"&&n[i+1]==="$"){i+=1;continue}if(n[i]==="\\"){let o=Tn(e,n[i+1]);if(o!==null){e=o,i+=1;continue}}if(n[i]==="$"&&!An(e)){let o=n[i+1]==="$";e=Ln(e,o),o&&(i+=1);}}return e!=="none"},Bn=(n,r)=>{for(let e=r;e<n.length;e+=1){if(n[e]===")")return true;if(n[e]===`
2
- `)return false}return false},m=(n,r)=>{for(let e=r-1;e>=0;e-=1){if(n[e]===")")return false;if(n[e]==="(")return e>0&&n[e-1]==="]"?Bn(n,r):false;if(n[e]===`
3
- `)return false}return false},j=(n,r)=>{for(let e=r-1;e>=0;e-=1){if(n[e]===">")return false;if(n[e]==="<"){let i=e+1<n.length?n[e+1]:"";return i>="a"&&i<="z"||i>="A"&&i<="Z"||i==="/"}if(n[e]===`
4
- `)return false}return false},p=(n,r,e)=>{let i=0;for(let l=r-1;l>=0;l-=1)if(n[l]===`
5
- `){i=l+1;break}let o=n.length;for(let l=r;l<n.length;l+=1)if(n[l]===`
6
- `){o=l;break}let s=n.substring(i,o),t=0,a=false;for(let l of s)if(l===e)t+=1;else if(l!==" "&&l!==" "){a=true;break}return t>=3&&!a};var Z=n=>n.includes("$")||n.includes("\\(")||n.includes("\\["),Sn=(n,r,e,i)=>e==="\\"||Z(n)&&h(n,r)?true:e!=="*"&&i==="*"?(r<n.length-2?n[r+2]:"")!=="*":e==="*"||(!e||e===" "||e===" "||e===`
7
- `)&&(!i||i===" "||i===" "||i===`
8
- `),k=n=>n===" "||n===" "||n===`
9
- `,On=(n,r)=>!!(n&&r&&f(n)&&f(r)),_n=(n,r,e,i)=>{let o=On(n,r),s=!!r&&!k(r),t=!!n&&!k(n);return o&&e%2===0&&!i?{count:false}:t&&e%2===1||s?{count:true,inWordAsteriskChain:o}:{count:false}},v=n=>{let r=0,e=false,i=false,o=n.length;for(let s=0;s<o;s+=1){if(n[s]==="`"&&s+2<o&&n[s+1]==="`"&&n[s+2]==="`"){e=!e,s+=2;continue}if(e)continue;if(n[s]!=="*"){f(n[s])||(i=false);continue}let t=s>0?n[s-1]:"",a=s<o-1?n[s+1]:"";if(Sn(n,s,t,a))continue;let l=_n(t,a,r,i);l.count&&(r+=1,i=l.inWordAsteriskChain);}return r},Mn=(n,r,e,i)=>!!(e==="\\"||Z(n)&&h(n,r)||m(n,r)||j(n,r)||e==="_"||i==="_"||e&&i&&f(e)&&f(i)),Pn=n=>{let r=0,e=false,i=n.length;for(let o=0;o<i;o+=1){if(n[o]==="`"&&o+2<i&&n[o+1]==="`"&&n[o+2]==="`"){e=!e,o+=2;continue}if(e||n[o]!=="_")continue;let s=o>0?n[o-1]:"",t=o<i-1?n[o+1]:"";Mn(n,o,s,t)||(r+=1);}return r},$n=n=>{let r=0,e=0,i=false;for(let o=0;o<n.length;o+=1){if(n[o]==="`"&&o+2<n.length&&n[o+1]==="`"&&n[o+2]==="`"){e>=3&&(r+=Math.floor(e/3)),e=0,i=!i,o+=2;continue}i||(n[o]==="*"?e+=1:(e>=3&&(r+=Math.floor(e/3)),e=0));}return e>=3&&(r+=Math.floor(e/3)),r},L=n=>{let r=0,e=false;for(let i=0;i<n.length;i+=1){if(n[i]==="`"&&i+2<n.length&&n[i+1]==="`"&&n[i+2]==="`"){e=!e,i+=2;continue}e||n[i]==="*"&&i+1<n.length&&n[i+1]==="*"&&(r+=1,i+=1);}return r},Q=n=>{let r=0,e=false;for(let i=0;i<n.length;i+=1){if(n[i]==="`"&&i+2<n.length&&n[i+1]==="`"&&n[i+2]==="`"){e=!e,i+=2;continue}e||n[i]==="_"&&i+1<n.length&&n[i+1]==="_"&&(r+=1,i+=1);}return r},En=(n,r,e)=>{if(!r||g.test(r))return true;let o=n.substring(0,e).lastIndexOf(`
10
- `),s=o===-1?0:o+1,t=n.substring(s,e);return C.test(t)&&r.includes(`
11
- `)?true:p(n,e,"*")},q=n=>{let r=n.match(N);if(!r)return n;let e=r[2],i=n.lastIndexOf(r[1]);return c(n,i)||d(n,i)||En(n,e,i)?n:L(n)%2===1?e.endsWith("*")?`${n}*`:`${n}**`:n},yn=(n,r,e)=>{if(!r||g.test(r))return true;let o=n.substring(0,e).lastIndexOf(`
12
- `),s=o===-1?0:o+1,t=n.substring(s,e);return C.test(t)&&r.includes(`
13
- `)?true:p(n,e,"_")},J=n=>{let r=n.match(R);if(!r){let s=n.match(X);if(s){let t=n.lastIndexOf(s[1]);if(!(c(n,t)||d(n,t))&&Q(n)%2===1)return `${n}_`}return n}let e=r[2],i=n.lastIndexOf(r[1]);return c(n,i)||d(n,i)||yn(n,e,i)?n:Q(n)%2===1?`${n}__`:n},Nn=n=>{let r=false;for(let e=0;e<n.length;e+=1){if(n[e]==="`"&&e+2<n.length&&n[e+1]==="`"&&n[e+2]==="`"){r=!r,e+=2;continue}if(!r&&n[e]==="*"&&n[e-1]!=="*"&&n[e+1]!=="*"&&n[e-1]!=="\\"&&!h(n,e)){let i=e>0?n[e-1]:"",o=e<n.length-1?n[e+1]:"",s=!i||k(i),t=!o||k(o);if(s&&t||i&&o&&f(i)&&f(o)||t)continue;return e}}return -1},V=n=>{if(!n.match(W))return n;let e=Nn(n);if(e===-1||c(n,e)||d(n,e))return n;let i=n.substring(e+1);return !i||g.test(i)?n:v(n)%2===1?`${n}*`:n},x=n=>{let r=false;for(let e=0;e<n.length;e+=1){if(n[e]==="`"&&e+2<n.length&&n[e+1]==="`"&&n[e+2]==="`"){r=!r,e+=2;continue}if(!r&&n[e]==="_"&&n[e-1]!=="_"&&n[e+1]!=="_"&&n[e-1]!=="\\"&&!h(n,e)&&!m(n,e)){let i=e>0?n[e-1]:"",o=e<n.length-1?n[e+1]:"";if(i&&o&&f(i)&&f(o))continue;return e}}return -1},Rn=n=>{let r=n.length;for(;r>0&&n[r-1]===`
14
- `;)r-=1;if(r<n.length){let e=n.slice(0,r),i=n.slice(r);return `${e}_${i}`}return `${n}_`},Un=n=>{if(!n.endsWith("**"))return null;let r=n.slice(0,-2);if(L(r)%2!==1)return null;let i=r.indexOf("**"),o=x(r);return i!==-1&&o!==-1&&i<o?`${r}_**`:null},nn=n=>{if(!n.match(D))return n;let e=x(n);if(e===-1)return n;let i=n.substring(e+1);if(!i||g.test(i)||c(n,e)||d(n,e))return n;if(Pn(n)%2===1){let s=Un(n);return s!==null?s:Rn(n)}return n},Wn=n=>{let r=L(n),e=v(n);return r%2===0&&e%2===0},Dn=(n,r,e)=>!r||g.test(r)||c(n,e)||d(n,e)?true:p(n,e,"*"),en=n=>{if(F.test(n))return n;let r=n.match(U);if(!r)return n;let e=r[2],i=n.lastIndexOf(r[1]);return Dn(n,e,i)?n:$n(n)%2===1?Wn(n)?n:`${n}***`:n};var Kn=/<[a-zA-Z/][^>]*$/,rn=n=>{let r=n.match(Kn);return !r||r.index===void 0||c(n,r.index)?n:n.substring(0,r.index).trimEnd()};var Hn=n=>!n.match(G)||n.includes(`
15
- `)?null:n.endsWith("``")&&!n.endsWith("```")?`${n}\``:n,wn=n=>(n.match(/```/g)||[]).length%2===1,on=n=>{let r=Hn(n);if(r!==null)return r;let e=n.match(K);if(e&&!wn(n)){let i=e[2];if(!i||g.test(i))return n;if(E(n)%2===1)return `${n}\``}return n};var sn=(n,r)=>r>=2&&n.substring(r-2,r+1)==="```"||r>=1&&n.substring(r-1,r+2)==="```"||r<=n.length-3&&n.substring(r,r+3)==="```",Gn=n=>{let r=0,e=false;for(let i=0;i<n.length-1;i+=1)n[i]==="`"&&!sn(n,i)&&(e=!e),!e&&n[i]==="$"&&n[i+1]==="$"&&(r+=1,i+=1);return r},Fn=n=>{let r=0,e=false;for(let i=0;i<n.length;i+=1){if(n[i]==="\\"){i+=1;continue}if(n[i]==="`"&&!sn(n,i)){e=!e;continue}!e&&n[i]==="$"&&(i+1<n.length&&n[i+1]==="$"?i+=1:r+=1);}return r},Xn=n=>{if(n.endsWith("$")&&!n.endsWith("$$"))return `${n}$`;let r=n.indexOf("$$");return r!==-1&&n.indexOf(`
16
- `,r)!==-1&&!n.endsWith(`
1
+ var En=Object.defineProperty,Sn=Object.defineProperties;var On=Object.getOwnPropertyDescriptors;var w=Object.getOwnPropertySymbols;var Tn=Object.prototype.hasOwnProperty,Mn=Object.prototype.propertyIsEnumerable;var F=(n,e,r)=>e in n?En(n,e,{enumerable:true,configurable:true,writable:true,value:r}):n[e]=r,L=(n,e)=>{for(var r in e||(e={}))Tn.call(e,r)&&F(n,r,e[r]);if(w)for(var r of w(e))Mn.call(e,r)&&F(n,r,e[r]);return n},P=(n,e)=>Sn(n,On(e));var c={PROSE:0,FENCE_MARKER:1,FENCE_INFO:2,FENCE_BODY:3,CODE_SPAN:4,CODE_SPAN_OPEN:5},Cn=/^(`{3,}|~{3,})(.*)$/,Ln=n=>n!==void 0&&n>="0"&&n<="9",Pn=(n,e)=>{let r=e;if(n[r]==="-"||n[r]==="*"||n[r]==="+")r+=1;else {for(;Ln(n[r])&&r-e<9;)r+=1;if(r===e||n[r]!=="."&&n[r]!==")")return -1;r+=1;}return n[r]===" "?r+1:-1},_n=(n,e,r)=>{let t=0,i=e,o=false,s=e;for(;;){for(;s<r&&n[s]===" ";)s+=1;if(n[s]===">"){t+=1,s+=n[s+1]===" "?2:1,i=s,o=false;continue}let l=s<r?Pn(n,s):-1;if(l===-1)return {contentStart:s,listIndent:o?s-i:0,quoteDepth:t};s=l,o=true;}},Rn=(n,e,r,t)=>{let i=e;for(let o=0;o<t;o+=1){for(;i<r&&n[i]===" ";)i+=1;if(n[i]!==">")return -1;i+=1,n[i]===" "&&(i+=1);}return i},Nn=(n,e,r,t,i)=>{let o=e+t;n.fill(c.FENCE_MARKER,o,o+i),n.fill(c.FENCE_INFO,o+i,Math.min(r+1,n.length));},yn=(n,e,r,t)=>{let i=e;for(;i<r&&n[i]===" ";)i+=1;let o=0;for(;i<r&&n[i]===t.char;)i+=1,o+=1;if(o<t.length)return false;for(;i<r;){if(n[i]!==" "&&n[i]!==" "&&n[i]!=="\r")return false;i+=1;}return true},$n=(n,e,r,t)=>{let i=t>r&&n[t-1]==="\r"?t-1:t,o=_n(n,r,i),s=n.slice(o.contentStart,i).match(Cn);if(!s)return null;let[,l,a]=s,u=l[0];return u==="`"&&a.includes("`")?null:(Nn(e,r,t,o.contentStart-r,l.length),{char:u,length:l.length,listIndent:o.listIndent,quoteDepth:o.quoteDepth})},Un=(n,e,r,t)=>{let i=Rn(n,e,r,t.quoteDepth);if(i===-1||t.listIndent===0)return i;let o=i;for(;o<r&&n[o]===" ";)o+=1;return o===r||n[o]==="\r"&&o+1===r||o-i>=t.listIndent?i:-1},Dn=(n,e)=>{let r=n.length,t=null,i=0;for(;i<r;){let o=n.indexOf(`
2
+ `,i);o===-1&&(o=r);let s=t?Un(n,i,o,t):-1;t&&s===-1&&(t=null),t?yn(n,s,o,t)?(e.fill(c.FENCE_MARKER,i,o),t=null):e.fill(c.FENCE_BODY,i,Math.min(o+1,r)):t=$n(n,e,i,o),i=o+1;}return t},W=(n,e)=>{let r=e+1;for(;r<n.length&&n[r]==="`";)r+=1;return r},Bn=(n,e)=>{let r=e+1;for(;r<n.length&&(n[r]===" "||n[r]===" "||n[r]==="\r");)r+=1;return r<n.length&&n[r]===`
3
+ `},wn=(n,e,r)=>{let t=r;for(;;){let i=n.indexOf("`",t);if(i===-1)return -1;let o=i>t&&n[i-1]==="\\"&&e[i-1]===c.PROSE;if(e[i]===c.PROSE&&!o)return i;t=i+1;}},Fn=(n,e)=>{let r=n.length,t=-1,i=0,o=0;for(;o<r;){if(t<0){if(o=wn(n,e,o),o===-1)break;let l=W(n,o);t=o,i=l-o,o=l;continue}if(e[o]!==c.PROSE){e.fill(c.CODE_SPAN_OPEN,t,o),t=-1,o+=1;continue}if(n[o]===`
4
+ `&&Bn(n,o)){t=-1,o+=1;continue}if(n[o]!=="`"){o+=1;continue}let s=W(n,o);s-o===i&&(e.fill(c.CODE_SPAN,t,s),t=-1),o=s;}return t>=0?(e.fill(c.CODE_SPAN_OPEN,t,r),{start:t,runLength:i}):null},Wn=n=>{let e=new Uint8Array(n.length),r=Dn(n,e),t=Fn(n,e);return {text:n,regions:e,openFence:r,openSpan:t,mathMask:null,linkUrlMask:null,htmlTagMask:null}},_=null,T=null,g=n=>{if(T!==null&&n===_)return T;let e=Wn(n);return _=n,T=e,e},K=()=>{_=null,T=null;},H=(n,e)=>e>=n.regions.length?n.openFence!==null||n.openSpan!==null:e<0?false:n.regions[e]!==c.PROSE,G=(n,e)=>{if(e>=n.regions.length)return n.openFence!==null;if(e<0)return false;let r=n.regions[e];return r===c.FENCE_MARKER||r===c.FENCE_INFO||r===c.FENCE_BODY},X=(n,e)=>n.regions[e]===c.CODE_SPAN,I=(n,e)=>{let r=g(n),t=e+e,i=0;for(let o=n.indexOf(t);o!==-1;o=n.indexOf(t,o))r.regions[o]===c.PROSE?(i+=1,o+=2):o+=1;return i},R=new Uint8Array(0),Kn=n=>n==="inlineLatex"||n==="blockLatex",Hn=(n,e)=>e==="["&&n==="none"?"blockLatex":e==="]"&&n==="blockLatex"?"none":e==="("&&n==="none"?"inlineLatex":e===")"&&n==="inlineLatex"?"none":null,Gn=(n,e)=>e?n==="blockDollar"?"none":"blockDollar":n==="blockDollar"?n:n==="inlineDollar"?"none":"inlineDollar",Xn=n=>n.includes("$")||n.includes("\\(")||n.includes("\\["),Yn=(n,e,r)=>{let t=n[e+1];if(n[e]==="\\"){if(t==="$")return {context:r,length:2};let i=Hn(r,t);return i===null?null:{context:i,length:2}}if(n[e]==="$"&&!Kn(r)){let i=t==="$";return {context:Gn(r,i),length:i?2:1}}return null},qn=n=>{let{text:e,regions:r}=n,t=e.length,i=new Uint8Array(t),o="none",s=0;for(;s<t;){i[s]=o==="none"?0:1;let l=r[s]===c.PROSE?Yn(e,s,o):null;if(l===null){s+=1;continue}o=l.context,l.length===2&&(i[s+1]=o==="none"?0:1),s+=l.length;}return i},k=(n,e)=>e<0||e>=n.text.length?false:(n.mathMask===null&&(n.mathMask=Xn(n.text)?qn(n):R),n.mathMask[e]===1),vn=(n,e,r,t)=>{let{text:i,regions:o}=n,s=new Uint8Array(r-e),l=0;for(let u=r-1;u>=e;u-=1)i[u]===")"&&o[u]===c.PROSE&&(l=1),s[u-e]=l;let a=false;for(let u=e;u<r;u+=1)a&&s[u-e]===1&&(t[u]=1),o[u]===c.PROSE&&(i[u]===")"?a=false:i[u]==="("&&(a=u>0&&i[u-1]==="]"));},zn=n=>{let{text:e}=n,r=e.length,t=new Uint8Array(r),i=0;for(;i<r;){let o=e.indexOf(`
5
+ `,i);o===-1&&(o=r),vn(n,i,o,t),i=o+1;}return t},A=(n,e)=>e<0||e>=n.text.length?false:(n.linkUrlMask===null&&(n.linkUrlMask=n.text.includes("](")?zn(n):R),n.linkUrlMask[e]===1),Qn=n=>{let{text:e,regions:r}=n,t=e.length,i=new Uint8Array(t),o=false;for(let s=0;s<t;s+=1){if(e[s]===`
6
+ `){o=false;continue}if(i[s]=o?1:0,r[s]===c.PROSE){if(e[s]===">")o=false;else if(e[s]==="<"){let l=e[s+1];o=l!==void 0&&(l>="a"&&l<="z"||l>="A"&&l<="Z"||l==="/");}}}return i},M=(n,e)=>e<0||e>=n.text.length?false:(n.htmlTagMask===null&&(n.htmlTagMask=n.text.includes("<")?Qn(n):R),n.htmlTagMask[e]===1);var f=(n,e)=>H(g(n),e),h=(n,e)=>X(g(n),e);var Zn=/^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm,Y=n=>!n||typeof n!="string"||!n.includes(">")?n:n.replace(Zn,(e,r,t,i)=>f(n,i)?e:`${r}\\>${t}`);var p=(n,{delimiter:e,markerLength:r,regex:t})=>{let i=n.lastIndexOf(e,n.length-2),o=i===-1?n.length-1:i;return n.slice(Math.max(0,o-r+1)).match(t)},q={delimiter:"*",markerLength:2,regex:/(\*\*)([^*]*\*?)$/},v={delimiter:"_",markerLength:2,regex:/(__)([^_]*?)$/},z={delimiter:"*",markerLength:3,regex:/(\*\*\*)([^*]*?)$/},Q={delimiter:"*",markerLength:1,regex:/(\*)([^*]*?)$/},Z={delimiter:"_",markerLength:1,regex:/(_)([^_]*?)$/},j={delimiter:"~",markerLength:2,regex:/(~~)([^~]*?)$/},J={delimiter:"_",markerLength:2,regex:/(__)([^_]+)_$/},V={delimiter:"~",markerLength:2,regex:/(~~)([^~]+)~$/},b=/^[\s_~*`]*$/,N=/^[\s]*[-*+][\s]+$/,x=/[\p{L}\p{N}_]/u,nn=/^\*{4,}$/;var m=n=>{if(!n)return false;let e=n.charCodeAt(0);return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95?true:x.test(n)},jn=(n,e)=>G(g(n),e),en=(n,e)=>{let r=1;for(let t=e-1;t>=0;t-=1)if(n[t]==="]")r+=1;else if(n[t]==="["&&(r-=1,r===0))return t;return -1},y=(n,e)=>{let r=1;for(let t=e+1;t<n.length;t+=1)if(n[t]==="[")r+=1;else if(n[t]==="]"&&(r-=1,r===0))return t;return -1},$=(n,e)=>k(g(n),e),Jn=(n,e)=>A(g(n),e);var O=(n,e,r)=>{let t=0;for(let a=e-1;a>=0;a-=1)if(n[a]===`
7
+ `){t=a+1;break}let i=n.length;for(let a=e;a<n.length;a+=1)if(n[a]===`
8
+ `){i=a;break}let o=n.substring(t,i),s=0,l=false;for(let a of o)if(a===r)s+=1;else if(a!==" "&&a!==" "){l=true;break}return s>=3&&!l};var Vn=(n,e,r,t)=>r==="\\"||k(n,e)?true:r!=="*"&&t==="*"?(e<n.text.length-2?n.text[e+2]:"")!=="*":r==="*"||(!r||r===" "||r===" "||r===`
9
+ `)&&(!t||t===" "||t===" "||t===`
10
+ `),C=n=>n===" "||n===" "||n===`
11
+ `,xn=(n,e)=>!!(n&&e&&m(n)&&m(e)),ne=(n,e,r,t)=>{let i=xn(n,e),o=!!e&&!C(e),s=!!n&&!C(n);return i&&r%2===0&&!t?{count:false}:s&&r%2===1||o?{count:true,inWordAsteriskChain:i}:{count:false}},on=n=>{let e=g(n),r=0,t=false,i=n.length;for(let o=0;o<i;o+=1){if(n[o]!=="*"||e.regions[o]!==c.PROSE){m(n[o])||(t=false);continue}let s=o>0?n[o-1]:"",l=o<i-1?n[o+1]:"";if(Vn(e,o,s,l))continue;let a=ne(s,l,r,t);a.count&&(r+=1,t=a.inWordAsteriskChain);}return r},ee=(n,e,r,t)=>!!(r==="\\"||k(n,e)||A(n,e)||M(n,e)||r==="_"||t==="_"||r&&t&&m(r)&&m(t)),re=n=>{let e=g(n),r=0,t=n.length;for(let i=0;i<t;i+=1){if(n[i]!=="_"||e.regions[i]!==c.PROSE)continue;let o=i>0?n[i-1]:"",s=i<t-1?n[i+1]:"";ee(e,i,o,s)||(r+=1);}return r},te=n=>{let e=g(n),r=0,t=0;for(let i=0;i<n.length;i+=1)n[i]==="*"&&e.regions[i]===c.PROSE?t+=1:(t>=3&&(r+=Math.floor(t/3)),t=0);return t>=3&&(r+=Math.floor(t/3)),r},U=n=>I(n,"*"),rn=n=>n===""||n===" "||n===" "||n===`
12
+ `,ie=(n,e,r,t,i)=>{if(!(rn(r)&&rn(t)))return false;if(e>i.lineEnd){let o=n.indexOf(`
13
+ `,e);i.lineEnd=o===-1?n.length:o,i.result=O(n,e,"_");}return i.result},oe=(n,e,r,t)=>{let i=n.text,o=e,s=false;o>0&&i[o-1]==="\\"&&(o+=1,s=true);let l=r-o;if(l<2)return false;let a=o>0?i[o-1]:"",u=s?"\\":a,S=r<i.length?i[r]:"";return m(u)&&m(S)||ie(i,o,u,S,t)||k(n,o)||A(n,o)||M(n,o)?false:Math.floor(l/2)%2===1},tn=n=>{let e=g(n),r=n.length,t={lineEnd:-1,result:false},i=false,o=0;for(;o<r;){if(n[o]!=="_"||e.regions[o]!==c.PROSE){o+=1;continue}let s=o,l=o+1;for(;l<r&&n[l]==="_"&&e.regions[l]===c.PROSE;)l+=1;o=l,oe(e,s,l,t)&&(i=!i);}return i},se=(n,e,r)=>{if(!e||b.test(e))return true;let i=n.substring(0,r).lastIndexOf(`
14
+ `),o=i===-1?0:i+1,s=n.substring(o,r);return N.test(s)&&e.includes(`
15
+ `)?true:O(n,r,"*")},sn=n=>{let e=p(n,q);if(!e)return n;let r=e[2],t=n.lastIndexOf(e[1]);return f(n,t)||h(n,t)||se(n,r,t)?n:U(n)%2===1?r.endsWith("*")?`${n}*`:`${n}**`:n},le=(n,e,r)=>{if(!e||b.test(e))return true;let i=n.substring(0,r).lastIndexOf(`
16
+ `),o=i===-1?0:i+1,s=n.substring(o,r);return N.test(s)&&e.includes(`
17
+ `)?true:O(n,r,"_")},ln=n=>{let e=p(n,v);if(!e){let i=p(n,J);if(i){let o=n.lastIndexOf(i[1]);if(!(f(n,o)||h(n,o))&&tn(n))return `${n}_`}return n}let r=e[2],t=n.lastIndexOf(e[1]);return f(n,t)||h(n,t)||le(n,r,t)?n:tn(n)?`${n}__`:n},ae=(n,e)=>{let{text:r}=n;return r[e]==="*"&&n.regions[e]===c.PROSE&&r[e-1]!=="*"&&r[e+1]!=="*"&&r[e-1]!=="\\"&&!k(n,e)},ce=n=>{let e=g(n);for(let r=n.indexOf("*");r!==-1;r=n.indexOf("*",r+1)){if(!ae(e,r))continue;let t=r>0?n[r-1]:"",i=r<n.length-1?n[r+1]:"",o=!t||C(t),s=!i||C(i);if(!(o&&s)&&!(t&&i&&m(t)&&m(i))&&!s)return r}return -1},an=n=>{if(!p(n,Q))return n;let r=ce(n);if(r===-1||f(n,r)||h(n,r))return n;let t=n.substring(r+1);return !t||b.test(t)?n:on(n)%2===1?`${n}*`:n},cn=n=>{let e=g(n);for(let r=n.indexOf("_");r!==-1;r=n.indexOf("_",r+1))if(e.regions[r]===c.PROSE&&n[r-1]!=="_"&&n[r+1]!=="_"&&n[r-1]!=="\\"&&!k(e,r)&&!A(e,r)){let t=r>0?n[r-1]:"",i=r<n.length-1?n[r+1]:"";if(t&&i&&m(t)&&m(i))continue;return r}return -1},ue=n=>{let e=n.length;for(;e>0&&n[e-1]===`
18
+ `;)e-=1;if(e<n.length){let r=n.slice(0,e),t=n.slice(e);return `${r}_${t}`}return `${n}_`},fe=n=>{if(!n.endsWith("**"))return null;let e=n.slice(0,-2);if(U(e)%2!==1)return null;let t=e.indexOf("**"),i=cn(e);return t!==-1&&i!==-1&&t<i?`${e}_**`:null},un=n=>{if(!p(n,Z))return n;let r=cn(n);if(r===-1)return n;let t=n.substring(r+1);if(!t||b.test(t)||f(n,r)||h(n,r))return n;if(re(n)%2===1){let o=fe(n);return o!==null?o:ue(n)}return n},ge=n=>{let e=U(n),r=on(n);return e%2===0&&r%2===0},de=(n,e,r)=>!e||b.test(e)||f(n,r)||h(n,r)?true:O(n,r,"*"),fn=n=>{if(nn.test(n))return n;let e=p(n,z);if(!e)return n;let r=e[2],t=n.lastIndexOf(e[1]);return de(n,r,t)?n:te(n)%2===1?ge(n)?n:`${n}***`:n};var me=/<[a-zA-Z/][^>]*$/,he=/[a-zA-Z/]/,pe=n=>n.includes("$")||n.includes("\\(")||n.includes("\\["),be=(n,e)=>{let r=n[e+1];return r!==void 0&&he.test(r)},gn=n=>{let e=n.match(me);if(!e||e.index===void 0)return n;let r=pe(n);for(let t=e.index;t<n.length;t+=1)if(!(n[t]!=="<"||!be(n,t))&&!f(n,t)&&!(r&&$(n,t)))return n.substring(0,t).trimEnd();return n};var dn=n=>{let e=g(n);if(e.openFence)return n;let r=e.openSpan;if(!r)return n;let t=n.slice(r.start+r.runLength);if(!t||b.test(t))return n;let i=0,o=n.length-1;for(;o>=0&&n[o]==="`";)i+=1,o-=1;return i>=r.runLength?n:n+"`".repeat(r.runLength-i)};var ke=n=>I(n,"$"),Ie=n=>{let e=g(n),r=0;for(let t=0;t<n.length;t+=1){if(n[t]==="\\"){t+=1;continue}e.regions[t]===c.PROSE&&n[t]==="$"&&(t+1<n.length&&n[t+1]==="$"?t+=1:r+=1);}return r},Ae=n=>{if(n.endsWith("$")&&!n.endsWith("$$"))return `${n}$`;let e=n.indexOf("$$");return e!==-1&&n.indexOf(`
19
+ `,e)!==-1&&!n.endsWith(`
17
20
  `)?`${n}
18
- $$`:`${n}$$`},tn=n=>Gn(n)%2===0?n:Xn(n),ln=n=>Fn(n)%2===1?`${n}$`:n;var zn=(n,r,e)=>{if(n.substring(r+2).includes(")"))return null;let o=Y(n,r);if(o===-1||c(n,o))return null;let s=o>0&&n[o-1]==="!",t=s?o-1:o,a=n.substring(0,t);if(s)return a;let l=n.substring(o+1,r);return e==="text-only"?`${a}${l}`:`${a}[${l}](streamdown:incomplete-link)`},an=(n,r)=>{for(let e=0;e<r;e++)if(n[e]==="["&&!c(n,e)){if(e>0&&n[e-1]==="!")continue;let i=T(n,e);if(i===-1)return e;if(i+1<n.length&&n[i+1]==="("){let o=n.indexOf(")",i+2);o!==-1&&(e=o);}}return r},Yn=(n,r,e)=>{let i=r>0&&n[r-1]==="!",o=i?r-1:r;if(!n.substring(r+1).includes("]")){let a=n.substring(0,o);if(i)return a;if(e==="text-only"){let l=an(n,r);return n.substring(0,l)+n.substring(l+1)}return `${n}](streamdown:incomplete-link)`}if(T(n,r)===-1){let a=n.substring(0,o);if(i)return a;if(e==="text-only"){let l=an(n,r);return n.substring(0,l)+n.substring(l+1)}return `${n}](streamdown:incomplete-link)`}return null},B=(n,r="protocol")=>{let e=n.lastIndexOf("](");if(e!==-1&&!c(n,e)){let i=zn(n,e,r);if(i!==null)return i}for(let i=n.length-1;i>=0;i-=1)if(n[i]==="["&&!c(n,i)){let o=Yn(n,i,r);if(o!==null)return o}return n};var jn=/^-{1,2}$/,Qn=/^[\s]*-{1,2}[\s]+$/,Zn=/^={1,2}$/,vn=/^[\s]*={1,2}[\s]+$/,cn=n=>{if(!n||typeof n!="string")return n;let r=n.lastIndexOf(`
19
- `);if(r===-1)return n;let e=n.substring(r+1),i=n.substring(0,r),o=e.trim();if(jn.test(o)&&!e.match(Qn)){let t=i.split(`
20
- `).at(-1);if(t&&t.trim().length>0)return `${n}\u200B`}if(Zn.test(o)&&!e.match(vn)){let t=i.split(`
21
- `).at(-1);if(t&&t.trim().length>0)return `${n}\u200B`}return n};var qn=/([\p{L}\p{N}_])~(?!~)(?=[\p{L}\p{N}_])/gu,un=n=>!n||typeof n!="string"||!n.includes("~")?n:n.replace(qn,(r,e,i)=>{let o=i+e.length;return c(n,o)?r:`${e}\\~`});var fn=n=>{var e,i;let r=n.match(H);if(r){let o=r[2];if(!o||g.test(o))return n;let s=n.lastIndexOf(r[1]);if(c(n,s)||d(n,s))return n;if(((e=n.match(A))==null?void 0:e.length)%2===1)return `${n}~~`}else {let o=n.match(z);if(o){let s=n.lastIndexOf(o[0].slice(0,2));if(c(n,s)||d(n,s))return n;if(((i=n.match(A))==null?void 0:i.length)%2===1)return `${n}~`}}return n};var S=n=>n!==false,Jn=n=>n===true,u={SINGLE_TILDE:0,COMPARISON_OPERATORS:5,HTML_TAGS:10,SETEXT_HEADINGS:15,LINKS:20,BOLD_ITALIC:30,BOLD:35,ITALIC_DOUBLE_UNDERSCORE:40,ITALIC_SINGLE_ASTERISK:41,ITALIC_SINGLE_UNDERSCORE:42,INLINE_CODE:50,STRIKETHROUGH:60,KATEX:70,INLINE_KATEX:75,DEFAULT:100},Vn=[{handler:{name:"singleTilde",handle:un,priority:u.SINGLE_TILDE},optionKey:"singleTilde"},{handler:{name:"comparisonOperators",handle:y,priority:u.COMPARISON_OPERATORS},optionKey:"comparisonOperators"},{handler:{name:"htmlTags",handle:rn,priority:u.HTML_TAGS},optionKey:"htmlTags"},{handler:{name:"setextHeadings",handle:cn,priority:u.SETEXT_HEADINGS},optionKey:"setextHeadings"},{handler:{name:"links",handle:B,priority:u.LINKS},optionKey:"links",earlyReturn:n=>n.endsWith("](streamdown:incomplete-link)")},{handler:{name:"boldItalic",handle:en,priority:u.BOLD_ITALIC},optionKey:"boldItalic"},{handler:{name:"bold",handle:q,priority:u.BOLD},optionKey:"bold"},{handler:{name:"italicDoubleUnderscore",handle:J,priority:u.ITALIC_DOUBLE_UNDERSCORE},optionKey:"italic"},{handler:{name:"italicSingleAsterisk",handle:V,priority:u.ITALIC_SINGLE_ASTERISK},optionKey:"italic"},{handler:{name:"italicSingleUnderscore",handle:nn,priority:u.ITALIC_SINGLE_UNDERSCORE},optionKey:"italic"},{handler:{name:"inlineCode",handle:on,priority:u.INLINE_CODE},optionKey:"inlineCode"},{handler:{name:"strikethrough",handle:fn,priority:u.STRIKETHROUGH},optionKey:"strikethrough"},{handler:{name:"katex",handle:tn,priority:u.KATEX},optionKey:"katex"},{handler:{name:"inlineKatex",handle:ln,priority:u.INLINE_KATEX},optionKey:"inlineKatex"}],xn=n=>{var e;let r=(e=n==null?void 0:n.linkMode)!=null?e:"protocol";return Vn.filter(({handler:i,optionKey:o})=>i.name==="links"?S(n==null?void 0:n.links)||S(n==null?void 0:n.images):i.name==="inlineKatex"?Jn(n==null?void 0:n.inlineKatex):S(n==null?void 0:n[o])).map(({handler:i,earlyReturn:o})=>i.name==="links"?{handler:b(I({},i),{handle:s=>B(s,r)}),earlyReturn:r==="protocol"?o:void 0}:{handler:i,earlyReturn:o})},ne=(n,r)=>{var t;if(!n||typeof n!="string")return n;let e=n.endsWith(" ")&&!n.endsWith(" ")?n.slice(0,-1):n,i=xn(r),o=((t=r==null?void 0:r.handlers)!=null?t:[]).map(a=>{var l;return {handler:b(I({},a),{priority:(l=a.priority)!=null?l:u.DEFAULT}),earlyReturn:void 0}}),s=[...i,...o].sort((a,l)=>{var O,_;return ((O=a.handler.priority)!=null?O:0)-((_=l.handler.priority)!=null?_:0)});for(let{handler:a,earlyReturn:l}of s)if(e=a.handle(e),l!=null&&l(e))return e;return e},We=ne;export{We as default,Cn as isWithinCodeBlock,m as isWithinLinkOrImageUrl,h as isWithinMathBlock,f as isWordChar};
21
+ $$`:`${n}$$`},mn=n=>ke(n)%2===0?n:Ae(n),hn=n=>Ie(n)%2===1?`${n}$`:n;var E="streamdown:incomplete-image",Ee=(n,e,r)=>{if(n.substring(e+2).includes(")"))return null;let i=en(n,e);if(i===-1||f(n,i))return null;let o=i>0&&n[i-1]==="!",s=o?i-1:i,l=n.substring(0,s),a=n.substring(i+1,e);return o?`${l}![${a}](${E})`:r==="text-only"?`${l}${a}`:`${l}[${a}](streamdown:incomplete-link)`},pn=(n,e)=>{for(let r=0;r<e;r++)if(n[r]==="["&&!f(n,r)){if(r>0&&n[r-1]==="!")continue;let t=y(n,r);if(t===-1)return r;if(t+1<n.length&&n[t+1]==="("){let i=n.indexOf(")",t+2);i!==-1&&(r=i);}}return e},Se=(n,e,r)=>{let t=e>0&&n[e-1]==="!",i=t?e-1:e;if(!n.substring(e+1).includes("]")){let l=n.substring(0,i);if(t){let a=n.substring(e+1);return `${l}![${a}](${E})`}if(r==="text-only"){let a=pn(n,e);return n.substring(0,a)+n.substring(a+1)}return `${n}](streamdown:incomplete-link)`}if(y(n,e)===-1){let l=n.substring(0,i);if(t){let a=n.substring(e+1);return `${l}![${a}](${E})`}if(r==="text-only"){let a=pn(n,e);return n.substring(0,a)+n.substring(a+1)}return `${n}](streamdown:incomplete-link)`}return null},Oe=(n,e)=>{let r=n.lastIndexOf("](");if(r!==-1&&!f(n,r)){let t=Ee(n,r,e);if(t!==null)return t}for(let t=n.lastIndexOf("[");t!==-1;t=t===0?-1:n.lastIndexOf("[",t-1))if(!f(n,t)){let i=Se(n,t,e);if(i!==null)return i}return n},Te=32,D=(n,e="protocol")=>{let r=n;for(let t=0;t<Te;t+=1){let i=Oe(r,e);if(i.length>=r.length)return i;r=i;}return r};var Me=/^-{1,2}$/,Ce=/^[\s]*-{1,2}[\s]+$/,Le=/^={1,2}$/,Pe=/^[\s]*={1,2}[\s]+$/,bn=n=>{if(!n||typeof n!="string")return n;let e=n.lastIndexOf(`
22
+ `);if(e===-1)return n;let r=n.substring(e+1),t=n.substring(0,e),i=r.trim();if(Me.test(i)&&!r.match(Ce)){let s=t.split(`
23
+ `).at(-1);if(s&&s.trim().length>0)return `${n}\u200B`}if(Le.test(i)&&!r.match(Pe)){let s=t.split(`
24
+ `).at(-1);if(s&&s.trim().length>0)return `${n}\u200B`}return n};var _e=/([\p{L}\p{N}_])~(?!~)(?=[\p{L}\p{N}_])/gu,kn=n=>!n||typeof n!="string"||!n.includes("~")?n:n.replace(_e,(e,r,t)=>{let i=t+r.length;return f(n,i)?e:`${r}\\~`});var In=n=>I(n,"~"),An=n=>{let e=p(n,j);if(e){let r=e[2];if(!r||b.test(r))return n;let t=n.lastIndexOf(e[1]);if(f(n,t)||h(n,t))return n;if(In(n)%2===1)return `${n}~~`}else {let r=p(n,V);if(r){let t=n.lastIndexOf(r[0].slice(0,2));if(f(n,t)||h(n,t))return n;if(In(n)%2===1)return `${n}~`}}return n};var B=n=>n!==false,Re=n=>n===true,d={SINGLE_TILDE:0,COMPARISON_OPERATORS:5,HTML_TAGS:10,SETEXT_HEADINGS:15,LINKS:20,BOLD_ITALIC:30,BOLD:35,ITALIC_DOUBLE_UNDERSCORE:40,ITALIC_SINGLE_ASTERISK:41,ITALIC_SINGLE_UNDERSCORE:42,INLINE_CODE:50,STRIKETHROUGH:60,KATEX:70,INLINE_KATEX:75,DEFAULT:100},Ne=[{handler:{name:"singleTilde",handle:kn,priority:d.SINGLE_TILDE},optionKey:"singleTilde"},{handler:{name:"comparisonOperators",handle:Y,priority:d.COMPARISON_OPERATORS},optionKey:"comparisonOperators"},{handler:{name:"htmlTags",handle:gn,priority:d.HTML_TAGS},optionKey:"htmlTags"},{handler:{name:"setextHeadings",handle:bn,priority:d.SETEXT_HEADINGS},optionKey:"setextHeadings"},{handler:{name:"links",handle:D,priority:d.LINKS},optionKey:"links",earlyReturn:n=>n.endsWith("](streamdown:incomplete-link)")||n.endsWith(`](${E})`)},{handler:{name:"boldItalic",handle:fn,priority:d.BOLD_ITALIC},optionKey:"boldItalic"},{handler:{name:"bold",handle:sn,priority:d.BOLD},optionKey:"bold"},{handler:{name:"italicDoubleUnderscore",handle:ln,priority:d.ITALIC_DOUBLE_UNDERSCORE},optionKey:"italic"},{handler:{name:"italicSingleAsterisk",handle:an,priority:d.ITALIC_SINGLE_ASTERISK},optionKey:"italic"},{handler:{name:"italicSingleUnderscore",handle:un,priority:d.ITALIC_SINGLE_UNDERSCORE},optionKey:"italic"},{handler:{name:"inlineCode",handle:dn,priority:d.INLINE_CODE},optionKey:"inlineCode"},{handler:{name:"strikethrough",handle:An,priority:d.STRIKETHROUGH},optionKey:"strikethrough"},{handler:{name:"katex",handle:mn,priority:d.KATEX},optionKey:"katex"},{handler:{name:"inlineKatex",handle:hn,priority:d.INLINE_KATEX},optionKey:"inlineKatex"}],ye=n=>{var r;let e=(r=n==null?void 0:n.linkMode)!=null?r:"protocol";return Ne.filter(({handler:t,optionKey:i})=>t.name==="links"?B(n==null?void 0:n.links)||B(n==null?void 0:n.images):t.name==="inlineKatex"?Re(n==null?void 0:n.inlineKatex):B(n==null?void 0:n[i])).map(({handler:t,earlyReturn:i})=>t.name==="links"?{handler:P(L({},t),{handle:o=>D(o,e)}),earlyReturn:e==="protocol"?i:void 0}:{handler:t,earlyReturn:i})},$e=(n,e)=>{var s;if(!n||typeof n!="string")return n;let r=n.endsWith(" ")&&!n.endsWith(" ")?n.slice(0,-1):n,t=ye(e),i=((s=e==null?void 0:e.handlers)!=null?s:[]).map(l=>{var a;return {handler:P(L({},l),{priority:(a=l.priority)!=null?a:d.DEFAULT}),earlyReturn:void 0}}),o=[...t,...i].sort((l,a)=>{var u,S;return ((u=l.handler.priority)!=null?u:0)-((S=a.handler.priority)!=null?S:0)});try{for(let{handler:l,earlyReturn:a}of o)if(r=l.handle(r),a!=null&&a(r))return r;return r.endsWith(" ")&&!r.endsWith(" ")?r.slice(0,-1):r}finally{K();}},Or=$e;export{E as INCOMPLETE_IMAGE_PLACEHOLDER,Or as default,jn as isWithinCodeBlock,Jn as isWithinLinkOrImageUrl,$ as isWithinMathBlock,m as isWordChar};
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remend",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "Self-healing markdown. Intelligently parses and styles incomplete Markdown blocks.",
5
5
  "homepage": "https://streamdown.ai/docs/termination",
6
6
  "repository": {
@@ -26,9 +26,10 @@
26
26
  ],
27
27
  "devDependencies": {
28
28
  "@vitest/coverage-v8": "^4.1.10",
29
+ "fast-check": "^4.9.0",
29
30
  "mdast-util-from-markdown": "^2.0.3",
30
31
  "tsup": "^8.5.1",
31
- "vitest": "^4.1.10"
32
+ "vitest": "^5.0.0"
32
33
  },
33
34
  "scripts": {
34
35
  "bench": "vitest bench --run > results.txt",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tickernelz/paperclip-pro-server",
3
- "version": "2026.930.3",
3
+ "version": "2026.930.5",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/tickernelz/paperclip-pro",
6
6
  "bugs": {
@@ -45,25 +45,25 @@
45
45
  "@discordjs/ws": "1.2.3",
46
46
  "@grpc/grpc-js": "1.14.4",
47
47
  "@opentelemetry/api": "^1.9.0",
48
- "@tickernelz/paperclip-pro-adapter-claude-local": "2026.930.3",
49
- "@tickernelz/paperclip-pro-adapter-codex-local": "2026.930.3",
50
- "@tickernelz/paperclip-pro-adapter-cursor-cloud": "2026.930.3",
51
- "@tickernelz/paperclip-pro-adapter-cursor-local": "2026.930.3",
52
- "@tickernelz/paperclip-pro-adapter-gemini-local": "2026.930.3",
53
- "@tickernelz/paperclip-pro-adapter-grok-local": "2026.930.3",
54
- "@tickernelz/paperclip-pro-adapter-kimi-local": "2026.930.3",
55
- "@tickernelz/paperclip-pro-adapter-openclaw-gateway": "2026.930.3",
56
- "@tickernelz/paperclip-pro-adapter-omp-local": "2026.930.3",
57
- "@tickernelz/paperclip-pro-adapter-opencode-local": "2026.930.3",
58
- "@tickernelz/paperclip-pro-adapter-pi-local": "2026.930.3",
59
- "@tickernelz/paperclip-pro-adapter-utils": "2026.930.3",
60
- "@tickernelz/paperclip-pro-db": "2026.930.3",
61
- "@tickernelz/paperclip-pro-hermes-paperclip-adapter": "2026.930.3",
62
- "@tickernelz/paperclip-pro-mcp-server": "2026.930.3",
63
- "@tickernelz/paperclip-pro-plugin-sdk": "2026.930.3",
64
- "@tickernelz/paperclip-pro-shared": "2026.930.3",
65
- "@tickernelz/paperclip-pro-teams-catalog": "2026.930.3",
66
- "@tickernelz/paperclip-pro-skills-catalog": "2026.930.3",
48
+ "@tickernelz/paperclip-pro-adapter-claude-local": "2026.930.5",
49
+ "@tickernelz/paperclip-pro-adapter-codex-local": "2026.930.5",
50
+ "@tickernelz/paperclip-pro-adapter-cursor-cloud": "2026.930.5",
51
+ "@tickernelz/paperclip-pro-adapter-cursor-local": "2026.930.5",
52
+ "@tickernelz/paperclip-pro-adapter-gemini-local": "2026.930.5",
53
+ "@tickernelz/paperclip-pro-adapter-grok-local": "2026.930.5",
54
+ "@tickernelz/paperclip-pro-adapter-kimi-local": "2026.930.5",
55
+ "@tickernelz/paperclip-pro-adapter-openclaw-gateway": "2026.930.5",
56
+ "@tickernelz/paperclip-pro-adapter-omp-local": "2026.930.5",
57
+ "@tickernelz/paperclip-pro-adapter-opencode-local": "2026.930.5",
58
+ "@tickernelz/paperclip-pro-adapter-pi-local": "2026.930.5",
59
+ "@tickernelz/paperclip-pro-adapter-utils": "2026.930.5",
60
+ "@tickernelz/paperclip-pro-db": "2026.930.5",
61
+ "@tickernelz/paperclip-pro-hermes-paperclip-adapter": "2026.930.5",
62
+ "@tickernelz/paperclip-pro-mcp-server": "2026.930.5",
63
+ "@tickernelz/paperclip-pro-plugin-sdk": "2026.930.5",
64
+ "@tickernelz/paperclip-pro-shared": "2026.930.5",
65
+ "@tickernelz/paperclip-pro-teams-catalog": "2026.930.5",
66
+ "@tickernelz/paperclip-pro-skills-catalog": "2026.930.5",
67
67
  "@photon-ai/advanced-imessage": "2.1.0",
68
68
  "@vercel/connect": "0.6.1",
69
69
  "acorn": "8.18.0",
@@ -113,7 +113,7 @@
113
113
  "acpx"
114
114
  ],
115
115
  "devDependencies": {
116
- "@tickernelz/paperclip-pro-paperclip-runner": "2026.930.3",
116
+ "@tickernelz/paperclip-pro-paperclip-runner": "2026.930.5",
117
117
  "@types/express": "^5.0.0",
118
118
  "@types/express-serve-static-core": "^5.1.3",
119
119
  "@types/jsdom": "^30.0.0",
@@ -244,6 +244,8 @@ Because of that, follow these rules:
244
244
 
245
245
  **Step 9 — Delegate if needed.** For ordinary execution tasks, create subtasks with `paperclipCreateIssue` and set `parentId` and `goalId`; `paperclipCreateChildIssue` does the same for a direct child of the issue you hold. For conversation tasks, use the project handoff above instead. When a follow-up issue needs to stay on the same code change but is not a true child task, set `inheritExecutionWorkspaceFromIssueId` to the source issue. Set `billingCode` for cross-team work.
246
246
 
247
+ **Parent rule.** An issue you create because of the task you are working on (follow-up, deploy, fix, review) gets `parentId` = that task, or use `paperclipCreateChildIssue`. Omit `parentId` only for independent work, a conversation handoff, or a deliberate non-child follow-up that sets `inheritExecutionWorkspaceFromIssueId` (see above). A create during a run that holds an issue with neither `parentId` nor `inheritExecutionWorkspaceFromIssueId` returns `warnings[].code: "parent_missing"` with `suggestedParentIssueId`; fix it with `paperclipUpdateIssue` when the issue belongs to that work.
248
+
247
249
  ### Delegating review tasks
248
250
 
249
251
  This is the only way an agent hands its own work to a reviewer: create the review subtask with `paperclipCreateChildIssue` assigned to the reviewer, add it to `blockedByIssueIds` on your issue, then set `status: "in_review"` — you keep the assignment and wake on the verdict. Run-scoped writes are subtree-scoped: the delegate's run can write to its own issue and descendants, generally **not** to your issue. Write review-task descriptions accordingly:
@@ -606,6 +606,8 @@ paperclipUpdateIssue { issueId: "issue-30", status: "done", comment: "Broke down
606
606
  paperclipDashboard {}
607
607
  ```
608
608
 
609
+ Parent rule: an issue created because of the task you are working on (follow-up, deploy, fix, review) gets `parentId` = that task, or use `paperclipCreateChildIssue`. Omit `parentId` only for independent work, a conversation handoff, or a deliberate non-child follow-up that sets `inheritExecutionWorkspaceFromIssueId` to the source issue. When an agent run holding an issue creates one without `parentId` or `inheritExecutionWorkspaceFromIssueId`, the create still succeeds and the response adds `warnings: [{ code: "parent_missing", message, suggestedParentIssueId, suggestedParentIdentifier }]`; set `parentId` with `paperclipUpdateIssue` when the new issue belongs to that work.
610
+
609
611
  ---
610
612
 
611
613
  ## Comments and @-mentions
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DU74KtHt.js","assets/rolldown-runtime-ZpX3ckPj.js","assets/createLucideIcon-r3v6fbGz.js","assets/preload-helper-CceJXRIF.js","assets/router-Bb8nJWyv.js","assets/zap-P-cXfK28.js","assets/agents-BlSzFh-1.js","assets/EmptyState-DPcc0zYh.js","assets/button-CAPbz11u.js","assets/RoutineRunVariablesDialog-DO1hY6dt.js","assets/mention-chips-DXumPrOR.js","assets/bot-DZDpMzjD.js","assets/MarkdownEditor-BN7aGwIv.js","assets/dist-D1zgkcBw.js","assets/dist-5v80Jc6A.js","assets/AgentAvatar-PT82VwmU.js","assets/dist-DCJXgQu0.js","assets/sheet-ASM5ba9D.js","assets/checkbox-D66RYMkN.js","assets/check-DDiXDm2i.js","assets/chevron-right-B9JUOr38.js","assets/label-BjzFqp93.js","assets/StatusIcon-DgMlA1TU.js","assets/clipboard-CYJ5Q78m.js","assets/loader-circle-BD9wx-lw.js","assets/octagon-alert-rGMwyrWA.js","assets/select-mS22eY6T.js","assets/chevron-down-F9aZv-V7.js","assets/heartbeats-CK_aXmx5.js","assets/useHiddenSettings-2JpxuJV7.js","assets/health-DeeeogeJ.js","assets/rotate-ccw-CRAQ3Xng.js","assets/triangle-alert-CgJcxSQX.js","assets/badge-Cf7ihb3q.js","assets/environments-BVeNFanj.js","assets/input-DpsS9it-.js","assets/company-members-BcZm1g8Q.js","assets/AgentIdentity-MCshmbhZ.js","assets/card-dmVcp3AX.js","assets/PageSkeleton-DHjTwRT3.js","assets/skeleton-CKir8TUW.js","assets/tabs-DWRZjksg.js","assets/use-adapter-capabilities-BiWYK4zJ.js","assets/save-DUnPDT6R.js","assets/external-link-0lrOvZWO.js","assets/MarkdownBody-NJwkQWmo.js","assets/file-text-C9vgFckt.js","assets/SidebarContext-D01pu4wh.js","assets/index-DLfVxJmv.css"])))=>i.map(i=>d[i]);
2
- var Pe=Object.defineProperty;var n=(e,a)=>Pe(e,"name",{value:a,configurable:!0});import{i as oe}from"./rolldown-runtime-ZpX3ckPj.js";import{En as ke,Fr as qe,Lr as Me,S as B,U as Fe,Y as j,_ as ce,g as U,nr as N,z as Re}from"./createLucideIcon-r3v6fbGz.js";import{t as $e}from"./preload-helper-CceJXRIF.js";import{it as Be,o as ze,t as de}from"./router-Bb8nJWyv.js";import{S as Ke}from"./zap-P-cXfK28.js";import{t as ue}from"./AgentAvatar-PT82VwmU.js";import{t as Oe}from"./tabs-DWRZjksg.js";import{t as ae}from"./agents-BlSzFh-1.js";import{r as De,t as re}from"./EmptyState-DPcc0zYh.js";import{t as ie}from"./bot-DZDpMzjD.js";import{k as Ue,t as V}from"./button-CAPbz11u.js";import{i as Ve,o as He,t as Ge}from"./heartbeats-CK_aXmx5.js";import{t as me}from"./triangle-alert-CgJcxSQX.js";import{n as Qe}from"./SidebarContext-D01pu4wh.js";import{n as Je,t as le}from"./environments-BVeNFanj.js";import{t as Ye}from"./PageSkeleton-DHjTwRT3.js";import{$t as We,It as Xe,Jt as Ze,Lt as pe,Wt as H,Yt as et,an as ge,cn as tt,dn as st,in as nt,nn as xe,on as G,rn as at,sn as rt,un as fe}from"./index-DU74KtHt.js";var g=oe(Me(),1),t=oe(qe(),1),he=ke,it=(0,g.lazy)(()=>$e(()=>import("./index-DU74KtHt.js").then(e=>e.wt).then(e=>({default:e.ConfigureBuiltInAgentModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48]))),lt=["all","active","paused","error","builtin"],ot=[{value:"all",label:"All"},{value:"active",label:"Active"},{value:"paused",label:"Paused"},{value:"error",label:"Error"},{value:"builtin",label:"Built-in"}];function ct(e){return lt.includes(e)}n(ct,"isFilterTab");var J={label:"Local",detail:"Paperclip host",title:"Local - Paperclip host"},ve={label:"—",detail:"Loading environment",title:"Loading environment"},be=new Set(["terminated","pending_approval"]);function je(e,a){return a==="all"?!0:a==="active"?e==="active"||e==="running"||e==="idle":a==="paused"?e==="paused":a==="error"?e==="error":!0}n(je,"matchesFilter");function dt(e,a,i){return e.filter(r=>be.has(r.status)?!1:a==="builtin"?i.has(r.id):je(r.status,a)).sort((r,o)=>r.name.localeCompare(o.name))}n(dt,"filterAgents");function ut(e){const a=e.adapterConfig?.model;if(typeof a!="string")return null;const i=a.trim();return i.length>0?i:null}n(ut,"getConfiguredModel");function mt(e){return e==="ssh"?"SSH":e.charAt(0).toUpperCase()+e.slice(1)}n(mt,"formatEnvironmentDriver");function pt(e,a){const i=typeof e.config.provider=="string"?e.config.provider.trim():"";return i?a?.sandboxProviders?.[i]?.displayName??i:"Sandbox"}n(pt,"getSandboxProviderLabel");function gt(e,a){const i=Ze(e)?"Managed by Paperclip":e.driver==="sandbox"?`${pt(e,a)} sandbox provider`:e.driver==="local"?"Paperclip host":mt(e.driver);return{label:e.name,detail:i,title:`${e.name} - ${i}`}}n(gt,"describeEnvironment");function xt(e){return{label:"Unknown environment",detail:e.slice(0,8),title:`Unknown environment - ${e}`}}n(xt,"describeMissingEnvironment");function ft(e,a,i,r){const o=e.defaultEnvironmentId??i;if(!o)return J;const x=a.get(o);return x?gt(x,r):xt(o)}n(ft,"resolveAgentEnvironment");function Ne(e,a,i){return e.reduce((r,o)=>{const x=Ne(o.reports,a,i);return be.has(o.status)?(r.push(...x),r):(((a==="builtin"?i.has(o.id):je(o.status,a))||x.length>0)&&r.push({...o,reports:x}),r)},[]).sort((r,o)=>r.name.localeCompare(o.name))}n(Ne,"filterOrgTree");function Mt(){const{selectedCompanyId:e}=Fe(),{openNewAgent:a}=Ve(),{setBreadcrumbs:i}=De(),r=ze(),o=Be(),{isMobile:x}=Qe(),C=o.pathname.split("/").pop()??"all",v=ct(C)?C:"all",[S,m]=(0,g.useState)("org"),A=x,p=A?"list":S,{data:l}=N({queryKey:j.instance.settings,queryFn:n(()=>Je.get(),"queryFn"),enabled:!!e}),u=l?.experimental.enableBuiltInAgents===!0,h=v==="builtin"&&!u?"all":v,z=(0,g.useMemo)(()=>ot.filter(s=>s.value!=="builtin"||u),[u]),{data:E}=N({queryKey:j.builtInAgents.list(e),queryFn:n(()=>st.list(e),"queryFn"),enabled:!!e&&u}),b=(0,g.useMemo)(()=>{const s=new Map;if(!u)return s;for(const c of E??[])c.agentId&&s.set(c.agentId,c);return s},[E,u]),k=(0,g.useMemo)(()=>new Set(b.keys()),[b]),[y,_]=(0,g.useState)(null),{data:d,isLoading:Ie,error:Y}=N({queryKey:j.agents.list(e),queryFn:n(()=>ae.list(e),"queryFn"),enabled:!!e}),{data:T}=N({queryKey:j.org(e),queryFn:n(()=>ae.org(e),"queryFn"),enabled:!!e&&p==="org"}),q=l?.experimental.enableEnvironments===!0,{data:L}=N({queryKey:j.environments.list(e),queryFn:n(()=>le.list(e),"queryFn"),enabled:!!e&&q}),{data:W}=N({queryKey:j.environments.capabilities(e),queryFn:n(()=>le.capabilities(e),"queryFn"),enabled:!!e&&q}),X=[...j.liveRuns(e),"agents-page"],K=nt({companyId:e,resourceKey:"live-runs:agents-page",queryKey:X,enabled:!!e,refetchInterval:15e3,leaderOnly:!0}),{data:O,dataUpdatedAt:Ce}=N({queryKey:X,queryFn:n(()=>Ge.liveRunsForCompany(e),"queryFn"),enabled:K.enabled,refetchInterval:K.refetchInterval});at(K,O,Ce);const M=tt(e),f=rt(e),F=(0,g.useMemo)(()=>{const s=new Map;for(const c of O??[]){if(c.status!=="running"&&c.status!=="queued")continue;const P=s.get(c.agentId);if(P){P.liveCount+=1;continue}s.set(c.agentId,{runId:c.id,liveCount:1})}return s},[O]),Se=(0,g.useMemo)(()=>{const s=new Map;for(const c of d??[])s.set(c.id,c);return s},[d]),Z=(0,g.useMemo)(()=>{const s=new Map;for(const c of L??[])s.set(c.id,c);return s},[L]),ee=(0,g.useMemo)(()=>{const s=new Map;for(const c of d??[])s.set(c.id,ft(c,Z,l?.defaultEnvironmentId??null,W));return s},[d,Z,W,l?.defaultEnvironmentId]);if((0,g.useEffect)(()=>{i([{label:"Agents"}])},[i]),(0,g.useEffect)(()=>{e&&v==="builtin"&&l&&!u&&r("/agents/all",{replace:!0})},[u,l,r,v,e]),!e)return(0,t.jsx)(re,{icon:ie,message:"Select a company to view agents."});if(Ie)return(0,t.jsx)(Ye,{variant:"list"});const w=dt(d??[],h,k),D=Ne(T??[],h,k),te=q&&L===void 0,se=q&&(L===void 0||L.length>1),Ae=n(s=>te?ve:ee.get(s)??J,"resolveRenderedEnvironment"),Ee=n(s=>{const c=s.orgChainHealth?.status==="invalid_org_chain",P=f.isPending&&f.variables?.resourceType==="agent"&&f.variables.resourceId===s.id,_e=P&&f.variables?.starred!==void 0,ne=P&&f.variables?.starred===void 0,Te=ge(M.data,"agent",s.id),I=b.get(s.id),Le=I?.status==="needs_setup"||I?.status==="pending_approval",R=I&&Le?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(fe,{status:I.status}),I.status==="needs_setup"&&(0,t.jsx)("span",{onClick:n($=>{$.preventDefault(),$.stopPropagation()},"onClick"),children:(0,t.jsx)(V,{size:"xs",variant:"outline",onClick:n(()=>_(I),"onClick"),children:"Set up"})})]}):null;return(0,t.jsx)(Xe,{title:s.name,titleClassName:"flex-1 xl:flex-none xl:w-56",titleTextClassName:"whitespace-normal break-words xl:truncate xl:whitespace-nowrap",subtitleClassName:"whitespace-normal break-words xl:truncate xl:whitespace-nowrap",subtitle:`${he[s.role]??s.role}${s.title?` - ${s.title}`:""}`,to:ce(s),className:B("group",s.pausedAt&&h!=="paused"?"opacity-50":"",G(M.data,"agent",s.id)==="left"?"sm:text-foreground/55":""),leading:c?(0,t.jsx)(me,{className:"h-3.5 w-3.5 text-amber-500","aria-label":"Invalid reporting chain"}):(0,t.jsx)(ue,{agent:s,size:32}),secondaryRow:R?(0,t.jsx)("div",{className:"xl:hidden flex flex-wrap items-center gap-1.5",children:R}):void 0,meta:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[R&&(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-1.5",children:R}),(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-3",children:(0,t.jsx)(we,{agent:s,environment:Ae(s.id),showEnvironment:se})})]}),metaSpacerClassName:"hidden xl:block",trailing:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("div",{className:"hidden sm:flex items-center gap-3",children:[F.has(s.id)&&(0,t.jsx)(Q,{agentRef:U(s),runId:F.get(s.id).runId,liveCount:F.get(s.id).liveCount}),(0,t.jsx)("span",{className:"w-20 flex justify-end",children:(0,t.jsx)(H,{status:s.status})}),(0,t.jsx)(xe,{size:"row",starred:Te,pending:_e,resourceName:s.name,onToggle:n($=>f.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,starred:$}),"onToggle")})]}),(0,t.jsx)(pe,{state:G(M.data,"agent",s.id),pending:ne,pendingState:ne?f.variables?.state??null:null,resourceName:s.name,onJoin:n(()=>f.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,state:"joined"}),"onJoin"),onLeave:n(()=>f.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,state:"left"}),"onLeave")})]})},s.id)},"renderAgentRow");return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsx)(Oe,{value:h,onValueChange:n(s=>r(`/agents/${s}`),"onValueChange"),children:(0,t.jsx)(We,{items:z,value:h,onValueChange:n(s=>r(`/agents/${s}`),"onValueChange")})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[!A&&(0,t.jsxs)("div",{className:"flex items-center border border-border",role:"group","aria-label":"View mode",children:[(0,t.jsx)("button",{className:B("p-1.5 transition-colors",p==="list"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),onClick:n(()=>m("list"),"onClick"),title:"List view","aria-label":"List view","aria-pressed":p==="list",children:(0,t.jsx)(He,{className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{className:B("p-1.5 transition-colors",p==="org"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),onClick:n(()=>m("org"),"onClick"),title:"Org chart view","aria-label":"Org chart view","aria-pressed":p==="org",children:(0,t.jsx)(Ke,{className:"h-3.5 w-3.5"})})]}),(0,t.jsxs)(V,{size:"sm",variant:"outline",onClick:a,children:[(0,t.jsx)(Ue,{className:"h-3.5 w-3.5 mr-1.5"}),"New Agent"]})]})]}),w.length>0&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[w.length," agent",w.length!==1?"s":""]}),Y&&(0,t.jsx)("p",{className:"text-sm text-destructive",children:Y.message}),d&&d.length===0&&(0,t.jsx)(re,{icon:ie,message:"Create your first agent to get started.",action:"New Agent",onAction:a}),p==="list"&&w.length>0&&(0,t.jsx)("div",{children:w.map(Ee)}),p==="list"&&d&&d.length>0&&w.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No agents match the selected status."}),p==="org"&&D.length>0&&(0,t.jsx)("div",{className:"py-1",children:D.map(s=>(0,t.jsx)(ye,{node:s,depth:0,agentMap:Se,liveRunByAgent:F,environmentByAgentId:ee,environmentDataLoading:te,showEnvironment:se,tab:h,memberships:M.data,membershipMutation:f,builtInByAgentId:b,onConfigureBuiltIn:_},s.id))}),p==="org"&&T&&T.length>0&&D.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No agents match the selected status."}),p==="org"&&T&&T.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No organizational hierarchy defined."}),y&&e&&(0,t.jsx)(g.Suspense,{fallback:null,children:(0,t.jsx)(it,{companyId:e,state:y,open:y!==null,onOpenChange:n(s=>{s||_(null)},"onOpenChange")})})]})}n(Mt,"Agents");function ye({node:e,depth:a,agentMap:i,liveRunByAgent:r,environmentByAgentId:o,environmentDataLoading:x,showEnvironment:C,tab:v,memberships:S,membershipMutation:m,builtInByAgentId:A,onConfigureBuiltIn:p}){const l=i.get(e.id),u=A.get(e.id),h=u?.status==="needs_setup"||u?.status==="pending_approval",z=!!(l&&l.orgChainHealth?.status==="invalid_org_chain"),E=G(S,"agent",e.id),b=m.isPending&&m.variables?.resourceType==="agent"&&m.variables.resourceId===e.id,k=b&&m.variables?.starred!==void 0,y=b&&m.variables?.starred===void 0,_=ge(S,"agent",e.id);return(0,t.jsxs)("div",{style:{paddingLeft:a*24},children:[(0,t.jsxs)(de,{to:l?ce(l):`/agents/${e.id}`,className:B("group flex items-center gap-3 rounded-lg px-3 py-2 hover:bg-accent/50 transition-colors w-full text-left no-underline text-inherit",l?.pausedAt&&v!=="paused"&&"opacity-50",E==="left"&&"sm:text-foreground/55"),children:[z?(0,t.jsx)(me,{className:"h-3.5 w-3.5 shrink-0 text-amber-500","aria-label":"Invalid reporting chain"}):(0,t.jsx)(ue,{agent:l??e,size:24}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("div",{className:"min-w-(--sz-7rem) truncate",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground ml-2",children:[he[e.role]??e.role,l?.title?` - ${l.title}`:""]})]}),u&&h&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,t.jsx)(fe,{status:u.status}),u.status==="needs_setup"&&(0,t.jsx)("span",{onClick:n(d=>{d.preventDefault(),d.stopPropagation()},"onClick"),children:(0,t.jsx)(V,{size:"xs",variant:"outline",onClick:n(()=>p(u),"onClick"),children:"Set up"})})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 shrink-0",children:[(0,t.jsx)("span",{className:"sm:hidden",children:r.has(e.id)?(0,t.jsx)(Q,{agentRef:l?U(l):e.id,runId:r.get(e.id).runId,liveCount:r.get(e.id).liveCount}):(0,t.jsx)(H,{status:e.status})}),(0,t.jsxs)("div",{className:"hidden sm:flex items-center gap-3",children:[r.has(e.id)&&(0,t.jsx)(Q,{agentRef:l?U(l):e.id,runId:r.get(e.id).runId,liveCount:r.get(e.id).liveCount}),l&&(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-3",children:(0,t.jsx)(we,{agent:l,environment:x?ve:o.get(l.id)??J,showEnvironment:C})}),(0,t.jsx)("span",{className:"w-20 flex justify-end",children:(0,t.jsx)(H,{status:e.status})})]}),(0,t.jsx)(pe,{state:E,pending:y,pendingState:y?m.variables?.state:null,resourceName:e.name,onJoin:n(()=>m.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,state:"joined"}),"onJoin"),onLeave:n(()=>m.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,state:"left"}),"onLeave")}),(0,t.jsx)("div",{className:"hidden sm:flex items-center gap-3",children:(0,t.jsx)(xe,{size:"row",starred:_,pending:k,resourceName:e.name,onToggle:n(d=>m.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,starred:d}),"onToggle")})})]})]}),e.reports&&e.reports.length>0&&(0,t.jsx)("div",{className:"border-l border-border ml-4",children:e.reports.map(d=>(0,t.jsx)(ye,{node:d,depth:a+1,agentMap:i,liveRunByAgent:r,environmentByAgentId:o,environmentDataLoading:x,showEnvironment:C,tab:v,memberships:S,membershipMutation:m,builtInByAgentId:A,onConfigureBuiltIn:p},d.id))})]})}n(ye,"OrgTreeNode");function we({agent:e,environment:a,showEnvironment:i}){const r=ut(e),o=et(e.adapterType);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"w-44 min-w-0 leading-tight",children:[(0,t.jsx)("div",{className:"truncate font-mono text-xs text-muted-foreground",title:r??void 0,children:r??"—"}),(0,t.jsx)("div",{className:"truncate font-mono text-(length:--text-micro) text-muted-foreground/70",title:o,children:o})]}),i&&(0,t.jsxs)("div",{className:"w-44 min-w-0 leading-tight",children:[(0,t.jsx)("div",{className:"truncate text-xs text-muted-foreground",title:a.title,children:a.label}),(0,t.jsx)("div",{className:"truncate text-(length:--text-micro) text-muted-foreground/70",children:a.detail})]}),(0,t.jsx)("span",{className:"w-24 whitespace-nowrap text-right text-xs text-muted-foreground",children:e.lastHeartbeatAt?Re(e.lastHeartbeatAt):"—"})]})}n(we,"AgentMetaColumns");function Q({agentRef:e,runId:a,liveCount:i}){return(0,t.jsxs)(de,{to:`/agents/${e}/runs/${a}`,className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-blue-500/10 hover:bg-blue-500/20 transition-colors no-underline",onClick:n(r=>r.stopPropagation(),"onClick"),children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}),(0,t.jsxs)("span",{className:"text-(length:--text-micro) font-medium text-blue-600 dark:text-blue-400",children:["Live",i>1?` (${i})`:""]})]})}n(Q,"LiveRunIndicator");export{Mt as Agents};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-9OR5EiR3.js","assets/rolldown-runtime-ZpX3ckPj.js","assets/createLucideIcon-r3v6fbGz.js","assets/preload-helper-CceJXRIF.js","assets/router-Bb8nJWyv.js","assets/zap-P-cXfK28.js","assets/agents-BlSzFh-1.js","assets/EmptyState-DPcc0zYh.js","assets/button-CAPbz11u.js","assets/RoutineRunVariablesDialog-DO1hY6dt.js","assets/mention-chips-DXumPrOR.js","assets/bot-DZDpMzjD.js","assets/MarkdownEditor-BN7aGwIv.js","assets/dist-D1zgkcBw.js","assets/dist-5v80Jc6A.js","assets/AgentAvatar-PT82VwmU.js","assets/dist-DCJXgQu0.js","assets/sheet-ASM5ba9D.js","assets/checkbox-D66RYMkN.js","assets/check-DDiXDm2i.js","assets/chevron-right-B9JUOr38.js","assets/label-BjzFqp93.js","assets/StatusIcon-DgMlA1TU.js","assets/clipboard-CYJ5Q78m.js","assets/loader-circle-BD9wx-lw.js","assets/octagon-alert-rGMwyrWA.js","assets/select-mS22eY6T.js","assets/chevron-down-F9aZv-V7.js","assets/heartbeats-CK_aXmx5.js","assets/useHiddenSettings-2JpxuJV7.js","assets/health-DeeeogeJ.js","assets/rotate-ccw-CRAQ3Xng.js","assets/triangle-alert-CgJcxSQX.js","assets/badge-Cf7ihb3q.js","assets/environments-BVeNFanj.js","assets/input-DpsS9it-.js","assets/company-members-BcZm1g8Q.js","assets/AgentIdentity-MCshmbhZ.js","assets/card-dmVcp3AX.js","assets/PageSkeleton-DHjTwRT3.js","assets/skeleton-CKir8TUW.js","assets/tabs-DWRZjksg.js","assets/use-adapter-capabilities-BiWYK4zJ.js","assets/save-DUnPDT6R.js","assets/external-link-0lrOvZWO.js","assets/MarkdownBody-NJwkQWmo.js","assets/file-text-C9vgFckt.js","assets/SidebarContext-D01pu4wh.js","assets/index-DLfVxJmv.css"])))=>i.map(i=>d[i]);
2
+ var Pe=Object.defineProperty;var n=(e,a)=>Pe(e,"name",{value:a,configurable:!0});import{i as oe}from"./rolldown-runtime-ZpX3ckPj.js";import{En as ke,Fr as qe,Lr as Me,S as B,U as Fe,Y as j,_ as ce,g as U,nr as N,z as Re}from"./createLucideIcon-r3v6fbGz.js";import{t as $e}from"./preload-helper-CceJXRIF.js";import{it as Be,o as ze,t as de}from"./router-Bb8nJWyv.js";import{S as Ke}from"./zap-P-cXfK28.js";import{t as ue}from"./AgentAvatar-PT82VwmU.js";import{t as Oe}from"./tabs-DWRZjksg.js";import{t as ae}from"./agents-BlSzFh-1.js";import{r as De,t as re}from"./EmptyState-DPcc0zYh.js";import{t as ie}from"./bot-DZDpMzjD.js";import{k as Ue,t as V}from"./button-CAPbz11u.js";import{i as Ve,o as He,t as Ge}from"./heartbeats-CK_aXmx5.js";import{t as me}from"./triangle-alert-CgJcxSQX.js";import{n as Qe}from"./SidebarContext-D01pu4wh.js";import{n as Je,t as le}from"./environments-BVeNFanj.js";import{t as Ye}from"./PageSkeleton-DHjTwRT3.js";import{$t as We,It as Xe,Jt as Ze,Lt as pe,Wt as H,Yt as et,an as ge,cn as tt,dn as st,in as nt,nn as xe,on as G,rn as at,sn as rt,un as fe}from"./index-9OR5EiR3.js";var g=oe(Me(),1),t=oe(qe(),1),he=ke,it=(0,g.lazy)(()=>$e(()=>import("./index-9OR5EiR3.js").then(e=>e.wt).then(e=>({default:e.ConfigureBuiltInAgentModal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48]))),lt=["all","active","paused","error","builtin"],ot=[{value:"all",label:"All"},{value:"active",label:"Active"},{value:"paused",label:"Paused"},{value:"error",label:"Error"},{value:"builtin",label:"Built-in"}];function ct(e){return lt.includes(e)}n(ct,"isFilterTab");var J={label:"Local",detail:"Paperclip host",title:"Local - Paperclip host"},ve={label:"—",detail:"Loading environment",title:"Loading environment"},be=new Set(["terminated","pending_approval"]);function je(e,a){return a==="all"?!0:a==="active"?e==="active"||e==="running"||e==="idle":a==="paused"?e==="paused":a==="error"?e==="error":!0}n(je,"matchesFilter");function dt(e,a,i){return e.filter(r=>be.has(r.status)?!1:a==="builtin"?i.has(r.id):je(r.status,a)).sort((r,o)=>r.name.localeCompare(o.name))}n(dt,"filterAgents");function ut(e){const a=e.adapterConfig?.model;if(typeof a!="string")return null;const i=a.trim();return i.length>0?i:null}n(ut,"getConfiguredModel");function mt(e){return e==="ssh"?"SSH":e.charAt(0).toUpperCase()+e.slice(1)}n(mt,"formatEnvironmentDriver");function pt(e,a){const i=typeof e.config.provider=="string"?e.config.provider.trim():"";return i?a?.sandboxProviders?.[i]?.displayName??i:"Sandbox"}n(pt,"getSandboxProviderLabel");function gt(e,a){const i=Ze(e)?"Managed by Paperclip":e.driver==="sandbox"?`${pt(e,a)} sandbox provider`:e.driver==="local"?"Paperclip host":mt(e.driver);return{label:e.name,detail:i,title:`${e.name} - ${i}`}}n(gt,"describeEnvironment");function xt(e){return{label:"Unknown environment",detail:e.slice(0,8),title:`Unknown environment - ${e}`}}n(xt,"describeMissingEnvironment");function ft(e,a,i,r){const o=e.defaultEnvironmentId??i;if(!o)return J;const x=a.get(o);return x?gt(x,r):xt(o)}n(ft,"resolveAgentEnvironment");function Ne(e,a,i){return e.reduce((r,o)=>{const x=Ne(o.reports,a,i);return be.has(o.status)?(r.push(...x),r):(((a==="builtin"?i.has(o.id):je(o.status,a))||x.length>0)&&r.push({...o,reports:x}),r)},[]).sort((r,o)=>r.name.localeCompare(o.name))}n(Ne,"filterOrgTree");function Mt(){const{selectedCompanyId:e}=Fe(),{openNewAgent:a}=Ve(),{setBreadcrumbs:i}=De(),r=ze(),o=Be(),{isMobile:x}=Qe(),C=o.pathname.split("/").pop()??"all",v=ct(C)?C:"all",[S,m]=(0,g.useState)("org"),A=x,p=A?"list":S,{data:l}=N({queryKey:j.instance.settings,queryFn:n(()=>Je.get(),"queryFn"),enabled:!!e}),u=l?.experimental.enableBuiltInAgents===!0,h=v==="builtin"&&!u?"all":v,z=(0,g.useMemo)(()=>ot.filter(s=>s.value!=="builtin"||u),[u]),{data:E}=N({queryKey:j.builtInAgents.list(e),queryFn:n(()=>st.list(e),"queryFn"),enabled:!!e&&u}),b=(0,g.useMemo)(()=>{const s=new Map;if(!u)return s;for(const c of E??[])c.agentId&&s.set(c.agentId,c);return s},[E,u]),k=(0,g.useMemo)(()=>new Set(b.keys()),[b]),[y,_]=(0,g.useState)(null),{data:d,isLoading:Ie,error:Y}=N({queryKey:j.agents.list(e),queryFn:n(()=>ae.list(e),"queryFn"),enabled:!!e}),{data:T}=N({queryKey:j.org(e),queryFn:n(()=>ae.org(e),"queryFn"),enabled:!!e&&p==="org"}),q=l?.experimental.enableEnvironments===!0,{data:L}=N({queryKey:j.environments.list(e),queryFn:n(()=>le.list(e),"queryFn"),enabled:!!e&&q}),{data:W}=N({queryKey:j.environments.capabilities(e),queryFn:n(()=>le.capabilities(e),"queryFn"),enabled:!!e&&q}),X=[...j.liveRuns(e),"agents-page"],K=nt({companyId:e,resourceKey:"live-runs:agents-page",queryKey:X,enabled:!!e,refetchInterval:15e3,leaderOnly:!0}),{data:O,dataUpdatedAt:Ce}=N({queryKey:X,queryFn:n(()=>Ge.liveRunsForCompany(e),"queryFn"),enabled:K.enabled,refetchInterval:K.refetchInterval});at(K,O,Ce);const M=tt(e),f=rt(e),F=(0,g.useMemo)(()=>{const s=new Map;for(const c of O??[]){if(c.status!=="running"&&c.status!=="queued")continue;const P=s.get(c.agentId);if(P){P.liveCount+=1;continue}s.set(c.agentId,{runId:c.id,liveCount:1})}return s},[O]),Se=(0,g.useMemo)(()=>{const s=new Map;for(const c of d??[])s.set(c.id,c);return s},[d]),Z=(0,g.useMemo)(()=>{const s=new Map;for(const c of L??[])s.set(c.id,c);return s},[L]),ee=(0,g.useMemo)(()=>{const s=new Map;for(const c of d??[])s.set(c.id,ft(c,Z,l?.defaultEnvironmentId??null,W));return s},[d,Z,W,l?.defaultEnvironmentId]);if((0,g.useEffect)(()=>{i([{label:"Agents"}])},[i]),(0,g.useEffect)(()=>{e&&v==="builtin"&&l&&!u&&r("/agents/all",{replace:!0})},[u,l,r,v,e]),!e)return(0,t.jsx)(re,{icon:ie,message:"Select a company to view agents."});if(Ie)return(0,t.jsx)(Ye,{variant:"list"});const w=dt(d??[],h,k),D=Ne(T??[],h,k),te=q&&L===void 0,se=q&&(L===void 0||L.length>1),Ae=n(s=>te?ve:ee.get(s)??J,"resolveRenderedEnvironment"),Ee=n(s=>{const c=s.orgChainHealth?.status==="invalid_org_chain",P=f.isPending&&f.variables?.resourceType==="agent"&&f.variables.resourceId===s.id,_e=P&&f.variables?.starred!==void 0,ne=P&&f.variables?.starred===void 0,Te=ge(M.data,"agent",s.id),I=b.get(s.id),Le=I?.status==="needs_setup"||I?.status==="pending_approval",R=I&&Le?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(fe,{status:I.status}),I.status==="needs_setup"&&(0,t.jsx)("span",{onClick:n($=>{$.preventDefault(),$.stopPropagation()},"onClick"),children:(0,t.jsx)(V,{size:"xs",variant:"outline",onClick:n(()=>_(I),"onClick"),children:"Set up"})})]}):null;return(0,t.jsx)(Xe,{title:s.name,titleClassName:"flex-1 xl:flex-none xl:w-56",titleTextClassName:"whitespace-normal break-words xl:truncate xl:whitespace-nowrap",subtitleClassName:"whitespace-normal break-words xl:truncate xl:whitespace-nowrap",subtitle:`${he[s.role]??s.role}${s.title?` - ${s.title}`:""}`,to:ce(s),className:B("group",s.pausedAt&&h!=="paused"?"opacity-50":"",G(M.data,"agent",s.id)==="left"?"sm:text-foreground/55":""),leading:c?(0,t.jsx)(me,{className:"h-3.5 w-3.5 text-amber-500","aria-label":"Invalid reporting chain"}):(0,t.jsx)(ue,{agent:s,size:32}),secondaryRow:R?(0,t.jsx)("div",{className:"xl:hidden flex flex-wrap items-center gap-1.5",children:R}):void 0,meta:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[R&&(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-1.5",children:R}),(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-3",children:(0,t.jsx)(we,{agent:s,environment:Ae(s.id),showEnvironment:se})})]}),metaSpacerClassName:"hidden xl:block",trailing:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("div",{className:"hidden sm:flex items-center gap-3",children:[F.has(s.id)&&(0,t.jsx)(Q,{agentRef:U(s),runId:F.get(s.id).runId,liveCount:F.get(s.id).liveCount}),(0,t.jsx)("span",{className:"w-20 flex justify-end",children:(0,t.jsx)(H,{status:s.status})}),(0,t.jsx)(xe,{size:"row",starred:Te,pending:_e,resourceName:s.name,onToggle:n($=>f.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,starred:$}),"onToggle")})]}),(0,t.jsx)(pe,{state:G(M.data,"agent",s.id),pending:ne,pendingState:ne?f.variables?.state??null:null,resourceName:s.name,onJoin:n(()=>f.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,state:"joined"}),"onJoin"),onLeave:n(()=>f.mutate({resourceType:"agent",resourceId:s.id,resourceName:s.name,state:"left"}),"onLeave")})]})},s.id)},"renderAgentRow");return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsx)(Oe,{value:h,onValueChange:n(s=>r(`/agents/${s}`),"onValueChange"),children:(0,t.jsx)(We,{items:z,value:h,onValueChange:n(s=>r(`/agents/${s}`),"onValueChange")})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[!A&&(0,t.jsxs)("div",{className:"flex items-center border border-border",role:"group","aria-label":"View mode",children:[(0,t.jsx)("button",{className:B("p-1.5 transition-colors",p==="list"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),onClick:n(()=>m("list"),"onClick"),title:"List view","aria-label":"List view","aria-pressed":p==="list",children:(0,t.jsx)(He,{className:"h-3.5 w-3.5"})}),(0,t.jsx)("button",{className:B("p-1.5 transition-colors",p==="org"?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50"),onClick:n(()=>m("org"),"onClick"),title:"Org chart view","aria-label":"Org chart view","aria-pressed":p==="org",children:(0,t.jsx)(Ke,{className:"h-3.5 w-3.5"})})]}),(0,t.jsxs)(V,{size:"sm",variant:"outline",onClick:a,children:[(0,t.jsx)(Ue,{className:"h-3.5 w-3.5 mr-1.5"}),"New Agent"]})]})]}),w.length>0&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[w.length," agent",w.length!==1?"s":""]}),Y&&(0,t.jsx)("p",{className:"text-sm text-destructive",children:Y.message}),d&&d.length===0&&(0,t.jsx)(re,{icon:ie,message:"Create your first agent to get started.",action:"New Agent",onAction:a}),p==="list"&&w.length>0&&(0,t.jsx)("div",{children:w.map(Ee)}),p==="list"&&d&&d.length>0&&w.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No agents match the selected status."}),p==="org"&&D.length>0&&(0,t.jsx)("div",{className:"py-1",children:D.map(s=>(0,t.jsx)(ye,{node:s,depth:0,agentMap:Se,liveRunByAgent:F,environmentByAgentId:ee,environmentDataLoading:te,showEnvironment:se,tab:h,memberships:M.data,membershipMutation:f,builtInByAgentId:b,onConfigureBuiltIn:_},s.id))}),p==="org"&&T&&T.length>0&&D.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No agents match the selected status."}),p==="org"&&T&&T.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No organizational hierarchy defined."}),y&&e&&(0,t.jsx)(g.Suspense,{fallback:null,children:(0,t.jsx)(it,{companyId:e,state:y,open:y!==null,onOpenChange:n(s=>{s||_(null)},"onOpenChange")})})]})}n(Mt,"Agents");function ye({node:e,depth:a,agentMap:i,liveRunByAgent:r,environmentByAgentId:o,environmentDataLoading:x,showEnvironment:C,tab:v,memberships:S,membershipMutation:m,builtInByAgentId:A,onConfigureBuiltIn:p}){const l=i.get(e.id),u=A.get(e.id),h=u?.status==="needs_setup"||u?.status==="pending_approval",z=!!(l&&l.orgChainHealth?.status==="invalid_org_chain"),E=G(S,"agent",e.id),b=m.isPending&&m.variables?.resourceType==="agent"&&m.variables.resourceId===e.id,k=b&&m.variables?.starred!==void 0,y=b&&m.variables?.starred===void 0,_=ge(S,"agent",e.id);return(0,t.jsxs)("div",{style:{paddingLeft:a*24},children:[(0,t.jsxs)(de,{to:l?ce(l):`/agents/${e.id}`,className:B("group flex items-center gap-3 rounded-lg px-3 py-2 hover:bg-accent/50 transition-colors w-full text-left no-underline text-inherit",l?.pausedAt&&v!=="paused"&&"opacity-50",E==="left"&&"sm:text-foreground/55"),children:[z?(0,t.jsx)(me,{className:"h-3.5 w-3.5 shrink-0 text-amber-500","aria-label":"Invalid reporting chain"}):(0,t.jsx)(ue,{agent:l??e,size:24}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("div",{className:"min-w-(--sz-7rem) truncate",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground ml-2",children:[he[e.role]??e.role,l?.title?` - ${l.title}`:""]})]}),u&&h&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 shrink-0",children:[(0,t.jsx)(fe,{status:u.status}),u.status==="needs_setup"&&(0,t.jsx)("span",{onClick:n(d=>{d.preventDefault(),d.stopPropagation()},"onClick"),children:(0,t.jsx)(V,{size:"xs",variant:"outline",onClick:n(()=>p(u),"onClick"),children:"Set up"})})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 shrink-0",children:[(0,t.jsx)("span",{className:"sm:hidden",children:r.has(e.id)?(0,t.jsx)(Q,{agentRef:l?U(l):e.id,runId:r.get(e.id).runId,liveCount:r.get(e.id).liveCount}):(0,t.jsx)(H,{status:e.status})}),(0,t.jsxs)("div",{className:"hidden sm:flex items-center gap-3",children:[r.has(e.id)&&(0,t.jsx)(Q,{agentRef:l?U(l):e.id,runId:r.get(e.id).runId,liveCount:r.get(e.id).liveCount}),l&&(0,t.jsx)("div",{className:"hidden xl:flex items-center gap-3",children:(0,t.jsx)(we,{agent:l,environment:x?ve:o.get(l.id)??J,showEnvironment:C})}),(0,t.jsx)("span",{className:"w-20 flex justify-end",children:(0,t.jsx)(H,{status:e.status})})]}),(0,t.jsx)(pe,{state:E,pending:y,pendingState:y?m.variables?.state:null,resourceName:e.name,onJoin:n(()=>m.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,state:"joined"}),"onJoin"),onLeave:n(()=>m.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,state:"left"}),"onLeave")}),(0,t.jsx)("div",{className:"hidden sm:flex items-center gap-3",children:(0,t.jsx)(xe,{size:"row",starred:_,pending:k,resourceName:e.name,onToggle:n(d=>m.mutate({resourceType:"agent",resourceId:e.id,resourceName:e.name,starred:d}),"onToggle")})})]})]}),e.reports&&e.reports.length>0&&(0,t.jsx)("div",{className:"border-l border-border ml-4",children:e.reports.map(d=>(0,t.jsx)(ye,{node:d,depth:a+1,agentMap:i,liveRunByAgent:r,environmentByAgentId:o,environmentDataLoading:x,showEnvironment:C,tab:v,memberships:S,membershipMutation:m,builtInByAgentId:A,onConfigureBuiltIn:p},d.id))})]})}n(ye,"OrgTreeNode");function we({agent:e,environment:a,showEnvironment:i}){const r=ut(e),o=et(e.adapterType);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"w-44 min-w-0 leading-tight",children:[(0,t.jsx)("div",{className:"truncate font-mono text-xs text-muted-foreground",title:r??void 0,children:r??"—"}),(0,t.jsx)("div",{className:"truncate font-mono text-(length:--text-micro) text-muted-foreground/70",title:o,children:o})]}),i&&(0,t.jsxs)("div",{className:"w-44 min-w-0 leading-tight",children:[(0,t.jsx)("div",{className:"truncate text-xs text-muted-foreground",title:a.title,children:a.label}),(0,t.jsx)("div",{className:"truncate text-(length:--text-micro) text-muted-foreground/70",children:a.detail})]}),(0,t.jsx)("span",{className:"w-24 whitespace-nowrap text-right text-xs text-muted-foreground",children:e.lastHeartbeatAt?Re(e.lastHeartbeatAt):"—"})]})}n(we,"AgentMetaColumns");function Q({agentRef:e,runId:a,liveCount:i}){return(0,t.jsxs)(de,{to:`/agents/${e}/runs/${a}`,className:"flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-blue-500/10 hover:bg-blue-500/20 transition-colors no-underline",onClick:n(r=>r.stopPropagation(),"onClick"),children:[(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"animate-pulse absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}),(0,t.jsxs)("span",{className:"text-(length:--text-micro) font-medium text-blue-600 dark:text-blue-400",children:["Live",i>1?` (${i})`:""]})]})}n(Q,"LiveRunIndicator");export{Mt as Agents};