botmux 2.112.0 → 2.114.0

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 (122) hide show
  1. package/dist/bot-registry.d.ts +31 -0
  2. package/dist/bot-registry.d.ts.map +1 -1
  3. package/dist/bot-registry.js +8 -0
  4. package/dist/bot-registry.js.map +1 -1
  5. package/dist/cli.d.ts.map +1 -1
  6. package/dist/cli.js +12 -6
  7. package/dist/cli.js.map +1 -1
  8. package/dist/core/ask-broker.d.ts +1 -1
  9. package/dist/core/ask-broker.d.ts.map +1 -1
  10. package/dist/core/ask-broker.js +2 -1
  11. package/dist/core/ask-broker.js.map +1 -1
  12. package/dist/core/ask-types.d.ts +5 -0
  13. package/dist/core/ask-types.d.ts.map +1 -1
  14. package/dist/core/ask-types.js.map +1 -1
  15. package/dist/core/dashboard-ipc-server.d.ts +10 -0
  16. package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
  17. package/dist/core/dashboard-ipc-server.js +73 -2
  18. package/dist/core/dashboard-ipc-server.js.map +1 -1
  19. package/dist/core/reply-target.d.ts +30 -1
  20. package/dist/core/reply-target.d.ts.map +1 -1
  21. package/dist/core/reply-target.js +70 -7
  22. package/dist/core/reply-target.js.map +1 -1
  23. package/dist/core/types.d.ts +8 -0
  24. package/dist/core/types.d.ts.map +1 -1
  25. package/dist/core/types.js.map +1 -1
  26. package/dist/core/worker-pool.d.ts +18 -1
  27. package/dist/core/worker-pool.d.ts.map +1 -1
  28. package/dist/core/worker-pool.js +67 -11
  29. package/dist/core/worker-pool.js.map +1 -1
  30. package/dist/daemon.d.ts +1 -1
  31. package/dist/daemon.d.ts.map +1 -1
  32. package/dist/daemon.js +85 -16
  33. package/dist/daemon.js.map +1 -1
  34. package/dist/dashboard/web/bot-defaults-page.d.ts +8 -1
  35. package/dist/dashboard/web/bot-defaults-page.d.ts.map +1 -1
  36. package/dist/dashboard/web/bot-defaults-page.js +238 -21
  37. package/dist/dashboard/web/bot-defaults-page.js.map +1 -1
  38. package/dist/dashboard/web/bot-defaults.d.ts +23 -0
  39. package/dist/dashboard/web/bot-defaults.d.ts.map +1 -1
  40. package/dist/dashboard/web/bot-defaults.js +17 -0
  41. package/dist/dashboard/web/bot-defaults.js.map +1 -1
  42. package/dist/dashboard/web/i18n.d.ts.map +1 -1
  43. package/dist/dashboard/web/i18n.js +54 -2
  44. package/dist/dashboard/web/i18n.js.map +1 -1
  45. package/dist/dashboard/web/ui.d.ts +4 -0
  46. package/dist/dashboard/web/ui.d.ts.map +1 -1
  47. package/dist/dashboard/web/ui.js +11 -0
  48. package/dist/dashboard/web/ui.js.map +1 -1
  49. package/dist/dashboard-web/app.js +1 -1
  50. package/dist/dashboard-web/chunks/bot-defaults-page-SRCBF7Z3.js +5 -0
  51. package/dist/dashboard-web/chunks/{chunk-NYZHARIU.js → chunk-3H6MVXXU.js} +8 -6
  52. package/dist/dashboard-web/chunks/{chunk-YBOHL7T7.js → chunk-77KD4TK2.js} +1 -1
  53. package/dist/dashboard-web/chunks/{chunk-CMDPZOPK.js → chunk-D2I5F4MY.js} +1 -1
  54. package/dist/dashboard-web/chunks/{chunk-YWCPDL4S.js → chunk-NGRUZCXP.js} +1 -1
  55. package/dist/dashboard-web/chunks/{connectors-page-DAMP7TTV.js → connectors-page-RM3BJVMV.js} +1 -1
  56. package/dist/dashboard-web/chunks/{groups-page-BPFA356N.js → groups-page-3D4YSYLA.js} +1 -1
  57. package/dist/dashboard-web/chunks/{insights-page-SHOPHTWY.js → insights-page-CRFJKA54.js} +1 -1
  58. package/dist/dashboard-web/chunks/{monitor-room-PXPJGZCN.js → monitor-room-HLK3XDT2.js} +1 -1
  59. package/dist/dashboard-web/chunks/{monitoring-page-4DF54M5Y.js → monitoring-page-E3SNZFFN.js} +1 -1
  60. package/dist/dashboard-web/chunks/{office-page-6OHU6KMZ.js → office-page-MKQ2TENK.js} +1 -1
  61. package/dist/dashboard-web/chunks/overview-page-ICFKKRLV.js +1 -0
  62. package/dist/dashboard-web/chunks/{roles-page-JYTBYKEF.js → roles-page-2DFJ7YRU.js} +1 -1
  63. package/dist/dashboard-web/chunks/{schedules-page-WJ72T7KV.js → schedules-page-S4WDIXH5.js} +1 -1
  64. package/dist/dashboard-web/chunks/{sessions-page-QC56OIAI.js → sessions-page-4XWGUGB5.js} +1 -1
  65. package/dist/dashboard-web/chunks/{settings-page-TCKWEXTN.js → settings-page-OBTE4LYP.js} +1 -1
  66. package/dist/dashboard-web/chunks/{skills-page-RJJNIECW.js → skills-page-CTRQJR47.js} +1 -1
  67. package/dist/dashboard-web/chunks/{team-federation-page-ZMDX3E7K.js → team-federation-page-GICLDKJP.js} +1 -1
  68. package/dist/dashboard-web/chunks/{v3-page-VLLAUQ33.js → v3-page-DI55IRL5.js} +1 -1
  69. package/dist/dashboard-web/chunks/{whiteboards-page-NAO53CKM.js → whiteboards-page-7KFWMILV.js} +1 -1
  70. package/dist/dashboard-web/style.css +113 -1
  71. package/dist/dashboard.js +48 -0
  72. package/dist/dashboard.js.map +1 -1
  73. package/dist/i18n/en.d.ts.map +1 -1
  74. package/dist/i18n/en.js +3 -2
  75. package/dist/i18n/en.js.map +1 -1
  76. package/dist/i18n/zh.d.ts.map +1 -1
  77. package/dist/i18n/zh.js +3 -2
  78. package/dist/i18n/zh.js.map +1 -1
  79. package/dist/im/lark/card-handler.d.ts.map +1 -1
  80. package/dist/im/lark/card-handler.js +9 -2
  81. package/dist/im/lark/card-handler.js.map +1 -1
  82. package/dist/im/lark/client.d.ts +30 -0
  83. package/dist/im/lark/client.d.ts.map +1 -1
  84. package/dist/im/lark/client.js +63 -13
  85. package/dist/im/lark/client.js.map +1 -1
  86. package/dist/im/lark/event-dispatcher.d.ts +7 -3
  87. package/dist/im/lark/event-dispatcher.d.ts.map +1 -1
  88. package/dist/im/lark/event-dispatcher.js +66 -15
  89. package/dist/im/lark/event-dispatcher.js.map +1 -1
  90. package/dist/im/lark/substitute-command.d.ts.map +1 -1
  91. package/dist/im/lark/substitute-command.js +10 -1
  92. package/dist/im/lark/substitute-command.js.map +1 -1
  93. package/dist/services/oncall-store.d.ts +8 -0
  94. package/dist/services/oncall-store.d.ts.map +1 -1
  95. package/dist/services/oncall-store.js +48 -2
  96. package/dist/services/oncall-store.js.map +1 -1
  97. package/dist/services/open-platform-rename.d.ts +31 -3
  98. package/dist/services/open-platform-rename.d.ts.map +1 -1
  99. package/dist/services/open-platform-rename.js +262 -48
  100. package/dist/services/open-platform-rename.js.map +1 -1
  101. package/dist/services/substitute-mode-normalize.d.ts.map +1 -1
  102. package/dist/services/substitute-mode-normalize.js +17 -1
  103. package/dist/services/substitute-mode-normalize.js.map +1 -1
  104. package/dist/services/substitute-mode-store.d.ts +24 -5
  105. package/dist/services/substitute-mode-store.d.ts.map +1 -1
  106. package/dist/services/substitute-mode-store.js +36 -16
  107. package/dist/services/substitute-mode-store.js.map +1 -1
  108. package/dist/skills/definitions.d.ts +1 -1
  109. package/dist/skills/definitions.d.ts.map +1 -1
  110. package/dist/skills/definitions.js +15 -3
  111. package/dist/skills/definitions.js.map +1 -1
  112. package/dist/types.d.ts +22 -0
  113. package/dist/types.d.ts.map +1 -1
  114. package/dist/utils/bot-routing.d.ts +1 -0
  115. package/dist/utils/bot-routing.d.ts.map +1 -1
  116. package/dist/utils/bot-routing.js +1 -1
  117. package/dist/utils/bot-routing.js.map +1 -1
  118. package/dist/workflows/migration/v2-run-archive-schema.d.ts +2 -2
  119. package/dist/workflows/v3/run-envelope.d.ts +16 -16
  120. package/package.json +1 -1
  121. package/dist/dashboard-web/chunks/bot-defaults-page-RYBL4ZYE.js +0 -4
  122. package/dist/dashboard-web/chunks/overview-page-IHIZ6F5M.js +0 -1
@@ -145,9 +145,9 @@ export declare const V3RunEnvelopeSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
145
145
  kind: "ad_hoc";
146
146
  grillStatePath: "grill.state.json";
147
147
  };
148
+ createdAt: string;
148
149
  runId: string;
149
150
  schemaVersion: 1;
150
- createdAt: string;
151
151
  artifacts: {
152
152
  spec: {
153
153
  sha256: `sha256:${string}`;
@@ -183,9 +183,9 @@ export declare const V3RunEnvelopeSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
183
183
  kind: "ad_hoc";
184
184
  grillStatePath: "grill.state.json";
185
185
  };
186
+ createdAt: string;
186
187
  runId: string;
187
188
  schemaVersion: 1;
188
- createdAt: string;
189
189
  artifacts: {
190
190
  spec: {
191
191
  sha256: string;
@@ -385,9 +385,9 @@ export declare const V3RunEnvelopeSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
385
385
  revisionId: string;
386
386
  humanVersion: number;
387
387
  };
388
+ createdAt: string;
388
389
  runId: string;
389
390
  schemaVersion: 1;
390
- createdAt: string;
391
391
  artifacts: {
392
392
  spec: {
393
393
  sha256: `sha256:${string}`;
@@ -435,9 +435,9 @@ export declare const V3RunEnvelopeSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
435
435
  revisionId: string;
436
436
  humanVersion: number;
437
437
  };
438
+ createdAt: string;
438
439
  runId: string;
439
440
  schemaVersion: 1;
440
- createdAt: string;
441
441
  artifacts: {
442
442
  spec: {
443
443
  sha256: string;
@@ -569,9 +569,9 @@ export declare const V3RunEnvelopeSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
569
569
  source: {
570
570
  kind: "manual_cli";
571
571
  };
572
+ createdAt: string;
572
573
  runId: string;
573
574
  schemaVersion: 1;
574
- createdAt: string;
575
575
  artifacts: {
576
576
  dag: {
577
577
  sha256: `sha256:${string}`;
@@ -600,9 +600,9 @@ export declare const V3RunEnvelopeSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
600
600
  source: {
601
601
  kind: "manual_cli";
602
602
  };
603
+ createdAt: string;
603
604
  runId: string;
604
605
  schemaVersion: 1;
605
- createdAt: string;
606
606
  artifacts: {
607
607
  dag: {
608
608
  sha256: string;
@@ -749,9 +749,9 @@ export declare const V3RunEnvelopeSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
749
749
  kind: "legacy_v3";
750
750
  original: "manual_cli" | "grill";
751
751
  };
752
+ createdAt: string;
752
753
  runId: string;
753
754
  schemaVersion: 1;
754
- createdAt: string;
755
755
  artifacts: {
756
756
  dag: {
757
757
  sha256: `sha256:${string}`;
@@ -788,9 +788,9 @@ export declare const V3RunEnvelopeSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
788
788
  kind: "legacy_v3";
789
789
  original: "manual_cli" | "grill";
790
790
  };
791
+ createdAt: string;
791
792
  runId: string;
792
793
  schemaVersion: 1;
793
- createdAt: string;
794
794
  artifacts: {
795
795
  dag: {
796
796
  sha256: string;
@@ -827,9 +827,9 @@ export declare const V3RunEnvelopeSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
827
827
  kind: "ad_hoc";
828
828
  grillStatePath: "grill.state.json";
829
829
  };
830
+ createdAt: string;
830
831
  runId: string;
831
832
  schemaVersion: 1;
832
- createdAt: string;
833
833
  artifacts: {
834
834
  spec: {
835
835
  sha256: `sha256:${string}`;
@@ -867,9 +867,9 @@ export declare const V3RunEnvelopeSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
867
867
  revisionId: string;
868
868
  humanVersion: number;
869
869
  };
870
+ createdAt: string;
870
871
  runId: string;
871
872
  schemaVersion: 1;
872
- createdAt: string;
873
873
  artifacts: {
874
874
  spec: {
875
875
  sha256: `sha256:${string}`;
@@ -914,9 +914,9 @@ export declare const V3RunEnvelopeSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
914
914
  source: {
915
915
  kind: "manual_cli";
916
916
  };
917
+ createdAt: string;
917
918
  runId: string;
918
919
  schemaVersion: 1;
919
- createdAt: string;
920
920
  artifacts: {
921
921
  dag: {
922
922
  sha256: `sha256:${string}`;
@@ -946,9 +946,9 @@ export declare const V3RunEnvelopeSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
946
946
  kind: "legacy_v3";
947
947
  original: "manual_cli" | "grill";
948
948
  };
949
+ createdAt: string;
949
950
  runId: string;
950
951
  schemaVersion: 1;
951
- createdAt: string;
952
952
  artifacts: {
953
953
  dag: {
954
954
  sha256: `sha256:${string}`;
@@ -985,9 +985,9 @@ export declare const V3RunEnvelopeSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
985
985
  kind: "ad_hoc";
986
986
  grillStatePath: "grill.state.json";
987
987
  };
988
+ createdAt: string;
988
989
  runId: string;
989
990
  schemaVersion: 1;
990
- createdAt: string;
991
991
  artifacts: {
992
992
  spec: {
993
993
  sha256: string;
@@ -1025,9 +1025,9 @@ export declare const V3RunEnvelopeSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
1025
1025
  revisionId: string;
1026
1026
  humanVersion: number;
1027
1027
  };
1028
+ createdAt: string;
1028
1029
  runId: string;
1029
1030
  schemaVersion: 1;
1030
- createdAt: string;
1031
1031
  artifacts: {
1032
1032
  spec: {
1033
1033
  sha256: string;
@@ -1072,9 +1072,9 @@ export declare const V3RunEnvelopeSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
1072
1072
  source: {
1073
1073
  kind: "manual_cli";
1074
1074
  };
1075
+ createdAt: string;
1075
1076
  runId: string;
1076
1077
  schemaVersion: 1;
1077
- createdAt: string;
1078
1078
  artifacts: {
1079
1079
  dag: {
1080
1080
  sha256: string;
@@ -1104,9 +1104,9 @@ export declare const V3RunEnvelopeSchema: z.ZodEffects<z.ZodUnion<[z.ZodObject<{
1104
1104
  kind: "legacy_v3";
1105
1105
  original: "manual_cli" | "grill";
1106
1106
  };
1107
+ createdAt: string;
1107
1108
  runId: string;
1108
1109
  schemaVersion: 1;
1109
- createdAt: string;
1110
1110
  artifacts: {
1111
1111
  dag: {
1112
1112
  sha256: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "botmux",
3
- "version": "2.112.0",
3
+ "version": "2.114.0",
4
4
  "description": "Bridge between IM platforms and AI coding CLIs — one topic, one CLI session with live streaming",
5
5
  "type": "module",
6
6
  "main": "dist/index-daemon.js",
@@ -1,4 +0,0 @@
1
- import{b as mt}from"./chunk-YWCPDL4S.js";import{b as R}from"./chunk-CMDPZOPK.js";import{a as dt,b as Q,c as V,g as ct,h as bt,i as ft,p as pt}from"./chunk-I35DXGM4.js";import{a as nt,r as lt,w as K,z as it}from"./chunk-NYZHARIU.js";import{a as rt}from"./chunk-SYC6D5XU.js";import{a as xt,d as ut}from"./chunk-5THX4DI2.js";import{c as Y}from"./chunk-7SZRL6FY.js";var s=Y(xt(),1);var gt=[{id:"claude-code",label:"Claude"},{id:"codex",label:"Codex"},{id:"traex",label:"traex"}],q={options:gt,ttadkModelDefault:"glm-5.1",ttadkModelSuggestions:[]};function _(a,e){return typeof a?.cliId=="string"&&a.cliId?a.cliId:e}function Z(a){let e=null;for(let o of nt.sessions.values())o.larkAppId!==a||!o.cliId||(!e||Number(o.lastMessageAt??0)>Number(e.lastMessageAt??0))&&(e=o);return e?.cliId??""}function X(a,e){let o=typeof a.agentSelectionKey=="string"&&a.agentSelectionKey?a.agentSelectionKey:"";return o||_(a,e)||"claude-code"}function tt(a,e){return a.find(o=>o.id===e)}function yt(a,e){return a?.gateway==="ttadk"&&a.acceptsModel!==!1?e.ttadkModelSuggestions:[]}async function vt(){try{let a=await fetch("/api/bots"),e=await a.json().catch(()=>({}));if(!a.ok){let o=e?.error?`HTTP ${a.status}: ${e.error}${e.path?` (${e.path})`:""}`:`HTTP ${a.status}`;return{bots:[],error:o}}return!e||!Array.isArray(e.bots)?{bots:[],error:"unexpected response shape (no `bots` array)"}:{bots:e.bots,error:null}}catch(a){return{bots:[],error:a?.message??String(a)}}}async function ht(){try{let a=await fetch("/api/cli-options"),e=await a.json().catch(()=>({}));if(!a.ok||!Array.isArray(e?.options))return q;let o=e.options.filter(l=>l&&typeof l.id=="string"&&typeof l.label=="string"),u=typeof e.ttadkModelDefault=="string"&&e.ttadkModelDefault.trim()?e.ttadkModelDefault.trim():q.ttadkModelDefault,i=Array.isArray(e.ttadkModelSuggestions)?e.ttadkModelSuggestions.filter(l=>typeof l=="string"):[];return{options:o.length?o:gt,ttadkModelDefault:u,ttadkModelSuggestions:i}}catch{return q}}function kt(a){if(!a)return"\u2014";let e=new Date(a);return Number.isNaN(e.getTime())?"\u2014":e.toLocaleString()}var t=Y(ut(),1);function wt(a,e=""){let o=a?` ${a.ok?"hint-ok":"hint-warn-inline"}`:"";return`oncall-status${e?` ${e}`:""}${o}`}function $(a){return(0,t.jsx)("span",{className:wt(a.status),...a.attr??{},children:a.status?.text??""})}function Bt(a){let e=typeof a.children=="string"?a.children:void 0;return(0,t.jsx)(ft,{className:"bd-info-tip",label:e,children:a.children})}function A(a){return(0,t.jsxs)("span",{className:"bd-field-title",children:[(0,t.jsx)("span",{className:"bd-field-title-text",children:a.children}),a.help?(0,t.jsx)(Bt,{children:a.help}):null]})}function U(a){let e=R();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(pt,{id:`bd-menu-${a.dataInput}`,className:["bd-field-menu",a.className].filter(Boolean).join(" "),ariaLabel:a.ariaLabel,disabled:a.disabled,label:dt(a.options,a.value),value:a.value,options:a.options,searchable:a.searchable,searchPlaceholder:a.searchable?e("common.dropdownSearch"):void 0,searchEmptyLabel:a.searchable?e("common.dropdownSearchEmpty"):void 0,onChange:a.onChange}),(0,t.jsx)("input",{type:"hidden","data-input":a.dataInput,value:a.value,readOnly:!0})]})}function G(a){return(0,t.jsxs)("label",{className:"toggle-row",children:[(0,t.jsx)("input",{type:"checkbox","data-action":a.dataAction,checked:a.checked,disabled:a.disabled,onChange:e=>a.onChange(e.currentTarget.checked)}),(0,t.jsx)("span",{className:"switch","aria-hidden":"true"}),(0,t.jsx)("span",{className:"toggle-tx",children:(0,t.jsx)("strong",{children:(0,t.jsx)(A,{help:a.help,children:a.title})})})]})}async function O(a,e,o){let u=await fetch(e,{method:a,headers:{"content-type":"application/json"},body:o===void 0?void 0:JSON.stringify(o)}),i=await u.json().catch(()=>({}));return{ok:u.ok&&i?.ok!==!1,status:u.status,body:i}}function L(a){let e=typeof a.body?.reason=="string"?a.body.reason:"",o=typeof a.body?.manualCommand=="string"?a.body.manualCommand:"";return e&&o?`${e}\uFF08${o}\uFF09`:String(e||a.body?.error||a.status)}function M(a){return a?.message??String(a)}function Tt(a){let e=a.trim();return e?/^[1-9]\d*$/.test(e)?Number(e):"invalid":null}function Dt(a,e){let o=a.trim();return o===""?e:/^(0|[1-9]\d*)$/.test(o)?Number(o):null}var at=["email","openId","userId","unionId"];function Pt(a){return at.find(e=>a?.[e]?.trim())??"email"}function Rt(a){let e=a.idValue.trim();if(!e)return null;let o={...a.persisted};if(a.persisted[a.idField]!==e||a.originalIdField!=null&&a.originalIdField!==a.idField)for(let l of at)delete o[l];o[a.idField]=e;let i=a.name.trim();return i?o.name=i:delete o.name,o}function Mt(a,e){return a==null?e("botDefaults.brandStateDefault"):a.trim()===""?e("botDefaults.brandStateOff"):e("botDefaults.brandStateCustom")}function At(a,e){return a==null?e("botDefaults.quotaStateOff"):e("botDefaults.quotaStateOn",{count:a})}function $t(a,e){return a==null?e("botDefaults.maxLiveWorkersStateDefault"):e("botDefaults.maxLiveWorkersStateOn",{count:a})}function Lt(a,e){return{...a,disableStreamingCard:e.disableStreamingCard,silentTurnReactions:e.silentTurnReactions,codexAppCleanInput:e.codexAppCleanInput,writableTerminalLinkInCard:e.writableTerminalLinkInCard,privateCard:e.privateCard,botToBotSameDir:e.botToBotSameDir,autoStartOnGroupJoin:e.autoStartOnGroupJoin,autoStartOnGroupJoinPrompt:e.autoStartOnGroupJoinPrompt,autoStartOnNewTopic:e.autoStartOnNewTopic,regularGroupReplyMode:e.regularGroupReplyMode,regularGroupMentionMode:e.regularGroupMentionMode,docSubscribeDefaultMode:e.docSubscribeDefaultMode}}function Ot(){let a=R(),e=(0,s.useRef)(!0),[o,u]=(0,s.useState)([]),[i,l]=(0,s.useState)(q),[r,d]=(0,s.useState)(null),[p,n]=(0,s.useState)(!0),[m,g]=(0,s.useState)(!1),[c,b]=(0,s.useState)(""),[k,D]=(0,s.useState)(null),[v,y]=(0,s.useState)(0),[,N]=(0,s.useState)(0),[h,f]=(0,s.useState)(!1),C=(0,s.useCallback)(async(w=!1)=>{w&&y(B=>B+1),n(!0);try{let[B,F]=await Promise.all([vt(),ht()]);if(!e.current)return;u(B.bots),d(B.error),l(F)}finally{e.current&&n(!1)}},[]);(0,s.useEffect)(()=>(e.current=!0,C(),it().then(()=>{e.current&&N(w=>w+1)}),()=>{e.current=!1}),[C]);let S=(0,s.useMemo)(()=>{let w=c.trim().toLowerCase();return o.filter(B=>!w||(B.botName??"").toLowerCase().includes(w)||(B.larkAppId??"").toLowerCase().includes(w))},[o,c]);(0,s.useEffect)(()=>{if(!(r||p)){if(S.length===0){k!==null&&D(null);return}(!k||!S.some(w=>w.larkAppId===k))&&D(S[0].larkAppId)}},[S,r,p,k]);let x=k?S.find(w=>w.larkAppId===k)??null:null,P=(0,s.useCallback)((w,B)=>{u(F=>F.map(j=>j.larkAppId!==w?j:typeof B=="function"?B(j):{...j,...B}))},[]),W=async()=>{g(!0);try{await C(!0)}finally{e.current&&g(!1)}},T;return p?T=(0,t.jsx)(V,{label:a("common.loading")}):r?T=(0,t.jsxs)("p",{className:"hint-warn",children:["\u65E0\u6CD5\u52A0\u8F7D bot \u5217\u8868\uFF1A",r,(0,t.jsx)("br",{}),"\u5E38\u89C1\u539F\u56E0\uFF1Adashboard / daemon \u8FDB\u7A0B\u8FD8\u5728\u8DD1\u65E7\u4EE3\u7801\uFF0C\u6267\u884C ",(0,t.jsx)("code",{children:"botmux restart"})," \u540E\u5237\u65B0\u3002"]}):S.length===0?T=(0,t.jsx)("p",{className:"empty",children:a("botDefaults.empty")}):x?T=(0,t.jsx)(Gt,{bot:x,cliState:i,patchBot:P},`${x.larkAppId}:${v}`):T=null,(0,t.jsxs)("section",{className:"page bot-defaults-page",children:[(0,t.jsxs)("div",{className:"page-heading",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"eyebrow",children:a("nav.botDefaults")}),(0,t.jsx)("h1",{children:a("botDefaults.title")})]}),(0,t.jsxs)("div",{className:"page-heading-actions",children:[(0,t.jsx)(bt,{id:"bd-refresh",label:a("botDefaults.refresh"),busy:m,disabled:m,onClick:()=>{W()}}),lt.authed?(0,t.jsx)(ct,{className:"page-primary-action add-bot-btn",disabled:h,onClick:()=>{f(!0),mt().finally(()=>f(!1))},children:a("botOnboarding.add")}):null]})]}),(0,t.jsxs)("div",{className:"bd-layout",children:[(0,t.jsxs)("aside",{id:"bd-roster",className:"bd-roster",children:[(0,t.jsx)("form",{id:"bd-filters",className:"filters dashboard-toolbar",onSubmit:w=>w.preventDefault(),children:(0,t.jsx)("input",{type:"search",name:"q",placeholder:a("botDefaults.search"),value:c,onChange:w=>b(w.currentTarget.value)})}),(0,t.jsx)("div",{className:"bd-roster-list",children:!r&&S.map(w=>(0,t.jsx)(Ft,{bot:w,selected:w.larkAppId===k,onSelect:()=>D(w.larkAppId)},w.larkAppId))})]}),(0,t.jsx)("div",{id:"bd-list",className:"bd-detail",children:T})]})]})}function Ft(a){let{bot:e}=a,o=e.botName??e.larkAppId,u=_(e,Z(e.larkAppId));return(0,t.jsxs)("div",{className:`bd-roster-item${a.selected?" on":""}`,"data-appid":e.larkAppId,role:"button",tabIndex:0,onClick:a.onSelect,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),a.onSelect())},children:[(0,t.jsx)(Q,{html:K({name:o,larkAppId:e.larkAppId,size:"sm"})}),(0,t.jsxs)("div",{className:"bd-roster-tx",children:[(0,t.jsx)("b",{children:o}),(0,t.jsx)("span",{children:u||e.larkAppId.slice(0,14)})]}),e.defaultOncall?.enabled?(0,t.jsx)("span",{className:"bd-roster-flag",children:"oncall"}):null]})}function Gt(a){let e=R(),{bot:o,cliState:u,patchBot:i}=a,l=o.botName??o.larkAppId,r=_(o,Z(o.larkAppId)),d=(0,s.useCallback)(async n=>{let m=await O("PUT",`/api/bots/${encodeURIComponent(o.larkAppId)}/card-prefs`,n);return m.ok&&i(o.larkAppId,g=>Lt(g,m.body)),m},[o.larkAppId,i]);if(o.error)return(0,t.jsxs)("article",{className:"bd-card bd-profile","data-appid":o.larkAppId,children:[(0,t.jsxs)("header",{className:"bd-profile-head",children:[(0,t.jsx)(Q,{html:K({name:l,larkAppId:o.larkAppId})}),(0,t.jsxs)("div",{className:"bd-profile-id",children:[(0,t.jsx)("strong",{children:l}),(0,t.jsx)("code",{children:o.larkAppId})]})]}),(0,t.jsxs)("p",{className:"hint-warn-inline",children:["\u67E5\u8BE2\u5931\u8D25\uFF1A",o.error]})]});let p=o.defaultOncall??{enabled:!1,workingDir:"",since:0};return(0,t.jsxs)("article",{className:"bd-card bd-profile","data-appid":o.larkAppId,children:[(0,t.jsxs)("header",{className:"bd-profile-head",children:[(0,t.jsx)("div",{className:"bd-profile-avatar",children:(0,t.jsx)(Q,{html:K({name:l,larkAppId:o.larkAppId,dot:"ok"})})}),(0,t.jsx)("div",{className:"bd-profile-main",children:(0,t.jsx)(Ht,{bot:o,cli:r,patchBot:i,meta:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("small",{className:"bd-meta-ok",children:["\u25CF ",e("botDefaults.metaOnline")]}),(0,t.jsxs)("small",{"data-oncall-since":!0,children:[e("botDefaults.lastEnabled"),": ",kt(p.since??0)]}),(0,t.jsx)("small",{children:e("botDefaults.autobound",{count:o.autoboundChatCount??0})})]})})})]}),(0,t.jsxs)("div",{className:"bd-body bd-grid",children:[(0,t.jsxs)("div",{className:"bd-column",children:[(0,t.jsxs)("section",{className:"bd-tile",children:[(0,t.jsx)(Wt,{bot:o,sessionFallback:r,cliState:u,patchBot:i}),(0,t.jsx)(Et,{bot:o,patchBot:i,putCardPref:d}),o.cliId!=="riff"&&(0,t.jsx)(qt,{bot:o,patchBot:i}),o.cliId!=="riff"&&(0,t.jsx)(Qt,{bot:o,patchBot:i})]}),(0,t.jsx)("section",{className:"bd-tile",children:(0,t.jsx)(jt,{bot:o,patchBot:i})}),(0,t.jsx)("section",{className:"bd-tile",children:(0,t.jsx)(ue,{bot:o,patchBot:i})})]}),(0,t.jsxs)("div",{className:"bd-column",children:[(0,t.jsxs)("section",{className:"bd-tile",children:[(0,t.jsx)(te,{bot:o,patchBot:i,putCardPref:d}),(0,t.jsx)(ee,{bot:o,patchBot:i}),(0,t.jsx)(Zt,{bot:o,putCardPref:d}),(0,t.jsx)(ae,{bot:o,patchBot:i})]}),(0,t.jsxs)("section",{className:"bd-tile",children:[(0,t.jsx)(zt,{bot:o,putCardPref:d}),(0,t.jsx)(Yt,{bot:o,putCardPref:d}),(0,t.jsx)(Xt,{bot:o,patchBot:i}),(0,t.jsx)(re,{bot:o,patchBot:i})]}),(0,t.jsx)("section",{className:"bd-tile",children:(0,t.jsx)(Vt,{bot:o,patchBot:i})})]})]})]})}function jt(a){let e=R();return(0,t.jsxs)("section",{className:"bd-section bd-runtime-env",children:[(0,t.jsx)("h3",{className:"bd-section-title",children:e("botDefaults.sectionRuntimeEnv")}),(0,t.jsx)(oe,{bot:a.bot,patchBot:a.patchBot}),(0,t.jsx)(se,{bot:a.bot,patchBot:a.patchBot}),(0,t.jsx)(ne,{bot:a.bot,patchBot:a.patchBot})]})}function Ht(a){let e=R(),{bot:o,cli:u,patchBot:i}=a,l=o.botName??o.larkAppId,[r,d]=(0,s.useState)(!1),[p,n]=(0,s.useState)(l),[m,g]=(0,s.useState)(!1),[c,b]=(0,s.useState)(null),[k,D]=(0,s.useState)(!1),[v,y]=(0,s.useState)(!1);(0,s.useEffect)(()=>{r||n(l)},[r,l]);function N(C){d(C),C&&(n(l),b(null),D(!1))}function h(C,S){let P=["no_session","session_expired","no_access","unsupported_brand"].includes(C)?e(`botDefaults.renameWarn.${C}`):S||C;return e("botDefaults.renameLocalOnly",{reason:P})}let f=(0,s.useCallback)(async()=>{let C=p.trim();if(!C){b({text:`\u2717 ${e("botDefaults.renameEmpty")}`});return}g(!0),b({text:`\u23F3 ${e("botDefaults.renaming")}`,ok:!0});try{let S=await O("PUT",`/api/bots/${encodeURIComponent(o.larkAppId)}/rename`,{name:C});if(S.ok&&S.body.ok){let x=typeof S.body.botName=="string"&&S.body.botName?S.body.botName:C;i(o.larkAppId,P=>({...P,botName:x,larkBotName:S.body.mode==="feishu"?C:P.larkBotName,displayName:S.body.mode==="feishu"?null:C})),N(!1),S.body.mode==="feishu"?(b({text:`\u2713 ${e("botDefaults.renameOkFeishu")}`,ok:!0}),D(!1)):(b({text:`\u26A0 ${h(String(S.body.warning??""),S.body.message)}`}),D(S.body.warning==="no_session"||S.body.warning==="session_expired"))}else b({text:`\u2717 ${e("botDefaults.renameFailed",{error:L(S)})}`})}catch(S){b({text:`\u2717 ${e("botDefaults.renameFailed",{error:M(S)})}`})}finally{g(!1)}},[o.larkAppId,p,i,e]);return(0,t.jsxs)("div",{className:"bd-profile-id",children:[r?(0,t.jsxs)("span",{className:"bd-name-editor","data-name-editor":!0,children:[(0,t.jsx)("input",{type:"text",className:"bd-name-input","data-input":"botRename",maxLength:64,value:p,disabled:m,autoFocus:!0,onChange:C=>n(C.currentTarget.value),onKeyDown:C=>{C.key==="Enter"?(C.preventDefault(),f()):C.key==="Escape"&&N(!1)}}),(0,t.jsx)("button",{type:"button",className:"primary","data-action":"save-bot-name",disabled:m,onClick:()=>{f()},children:e("botDefaults.renameSave")}),(0,t.jsx)("button",{type:"button","data-action":"cancel-bot-name",disabled:m,onClick:()=>N(!1),children:e("botDefaults.renameCancel")})]}):(0,t.jsxs)("div",{className:"bd-profile-title-row","data-name-row":!0,children:[(0,t.jsxs)("div",{className:"bd-profile-title-content",children:[(0,t.jsx)("strong",{"data-bot-name":!0,children:l}),u?(0,t.jsx)("span",{className:"mate-role bd-profile-cli-tag",children:u}):null,a.meta?(0,t.jsx)("span",{className:"bd-profile-meta bd-meta",children:a.meta}):null]}),(0,t.jsx)("button",{type:"button",className:"bd-name-edit","data-action":"edit-bot-name",title:e("botDefaults.renameTitle"),"aria-label":e("botDefaults.renameTitle"),onClick:()=>N(!0),children:e("botDefaults.renameAction")})]}),(0,t.jsx)("code",{children:o.larkAppId}),(0,t.jsx)("small",{className:wt(c,"bd-name-status"),"data-name-status":!0,children:c?.text??""}),(0,t.jsx)("button",{type:"button",className:"bd-feishu-login","data-action":"feishu-login",hidden:!k,onClick:()=>y(!0),children:e("feishuLogin.entry")}),v?(0,t.jsx)(Ut,{onClose:()=>y(!1),onSuccess:()=>{D(!1),y(!1),f()}}):null]})}function Ut(a){let e=R(),{onClose:o,onSuccess:u}=a,i=(0,s.useRef)(null),l=(0,s.useRef)(null),[r,d]=(0,s.useState)(e("feishuLogin.starting")),[p,n]=(0,s.useState)(null),[m,g]=(0,s.useState)(!1),c=(0,s.useCallback)(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]),b=(0,s.useCallback)(v=>v?v.status==="awaiting_scan"&&v.qrDataUrl?(n(v.qrDataUrl),d(v.message||e("feishuLogin.scanHint")),g(!1),"active"):v.status==="starting"?(d(v.message||e("feishuLogin.starting")),n(null),g(!1),"active"):v.status==="success"?(c(),n(null),g(!1),d(e("feishuLogin.success")),l.current=window.setTimeout(()=>u(),900),"done"):(c(),n(null),d(e("feishuLogin.failed",{reason:v.message||v.reason||""})),g(!0),"done"):"active",[u,c,e]),k=(0,s.useCallback)(async()=>{try{let y=await(await fetch("/api/feishu-login/status")).json().catch(()=>({}));b(y.login)}catch{}},[b]),D=(0,s.useCallback)(async()=>{c(),d(e("feishuLogin.starting")),n(null),g(!1);let v="active";try{let N=await(await fetch("/api/feishu-login/start",{method:"POST"})).json().catch(()=>({}));v=b(N.login)}catch(y){d(e("feishuLogin.failed",{reason:M(y)})),g(!0);return}v==="active"&&i.current===null&&(i.current=window.setInterval(()=>{k()},1500))},[k,b,c,e]);return(0,s.useEffect)(()=>(D(),()=>{c(),l.current!==null&&window.clearTimeout(l.current)}),[D,c]),(0,t.jsx)("div",{className:"feishu-login-overlay",onClick:v=>{v.currentTarget===v.target&&o()},children:(0,t.jsxs)("div",{className:"feishu-login-modal",role:"dialog","aria-modal":"true",children:[(0,t.jsx)("button",{type:"button",className:"feishu-login-close","data-close":!0,"aria-label":e("feishuLogin.close"),onClick:o,children:"x"}),(0,t.jsx)("h3",{className:"feishu-login-title",children:e("feishuLogin.title")}),(0,t.jsx)("p",{className:"feishu-login-hint","data-hint":!0,children:r}),(0,t.jsx)("div",{className:"feishu-login-qr","data-qr":!0,children:p?(0,t.jsx)("img",{className:"qr-image",src:p,alt:e("feishuLogin.qrAlt")}):null}),(0,t.jsx)("div",{className:"feishu-login-actions",children:(0,t.jsx)("button",{type:"button",className:"primary","data-retry":!0,hidden:!m,onClick:()=>{D()},children:e("feishuLogin.retry")})})]})})}function Wt(a){let e=R(),{bot:o,cliState:u,patchBot:i}=a,l=X(o,a.sessionFallback),[r,d]=(0,s.useState)(l),[p,n]=(0,s.useState)(typeof o.model=="string"?o.model:""),[m,g]=(0,s.useState)(null),[c,b]=(0,s.useState)(!1),[k,D]=(0,s.useState)(St(o)),[v,y]=(0,s.useState)(null),[N,h]=(0,s.useState)(!1);(0,s.useEffect)(()=>{d(X(o,a.sessionFallback)),n(typeof o.model=="string"?o.model:""),D(St(o))},[o.agentSelectionKey,o.cliId,o.larkAppId,o.model,o.skillInjection,o.skillInjectionDefault,a.sessionFallback]);let f=tt(u.options,r),C=yt(f,u),S=f?.gateway==="ttadk"&&f.acceptsModel===!1,x=S?e("botOnboarding.modelTtadkCocoPlaceholder"):f?.gateway==="ttadk"?e("botOnboarding.modelTtadkPlaceholder").replace("{model}",u.ttadkModelDefault):e("botDefaults.agentModelPlaceholder");function P(I){d(I);let H=tt(u.options,I),ot=H?.gateway==="ttadk",st=ot&&H.acceptsModel!==!1;n(ot&&!st?"":st?J=>J.trim()?J:u.ttadkModelDefault:J=>J.trim()===u.ttadkModelDefault?"":J)}async function W(){g(null),b(!0);try{let I=await O("PUT",`/api/bots/${encodeURIComponent(o.larkAppId)}/agent`,{cliId:r,model:p});I.ok&&I.body.ok?(g(I.body.availabilityWarning?{text:`\u26A0\uFE0F ${I.body.availabilityWarning}`}:{text:`\u2713 ${e("botDefaults.agentSaved")}`,ok:!0}),i(o.larkAppId,{cliId:I.body.cliId,wrapperCli:I.body.wrapperCli??null,model:I.body.model??"",agentSelectionKey:I.body.selectionKey??r})):g({text:`\u2717 ${L(I)}`})}catch(I){g({text:`\u2717 ${M(I)}`})}finally{b(!1)}}async function T(){if(o.cliId==="riff")return!0;try{let I=await O("PUT",`/api/bots/${encodeURIComponent(o.larkAppId)}/agent`,{cliId:"riff",model:""});return I.ok&&I.body.ok?(i(o.larkAppId,{cliId:I.body.cliId,wrapperCli:I.body.wrapperCli??null,model:I.body.model??"",agentSelectionKey:I.body.selectionKey??"riff"}),!0):(g({text:`\u2717 ${L(I)}`}),!1)}catch(I){return g({text:`\u2717 ${M(I)}`}),!1}}async function w(I){D(I),y(null),h(!0);try{let H=await O("PUT",`/api/bots/${encodeURIComponent(o.larkAppId)}/skill-injection`,{skillInjection:I});H.ok&&H.body.ok?(y({text:`\u2713 ${e("botDefaults.cardPrefSaved")}`,ok:!0}),i(o.larkAppId,{skillInjection:H.body.skillInjection??null})):y({text:`\u2717 ${L(H)}`})}catch(H){y({text:`\u2717 ${M(H)}`})}finally{h(!1)}}let B=o.skillInjectionSupport==="dynamic"?"dynamic":o.skillInjectionSupport==="global"?"global":"none",F=[...u.options].sort((I,H)=>I.label.localeCompare(H.label,"en",{sensitivity:"base"})).map(I=>({value:I.id,label:I.available===!1?e("botDefaults.agentMissingOption",{label:I.label,command:I.command??I.id}):`${I.label}\uFF08${I.id}\uFF09`})),j=[{value:"dynamic",label:e("botDefaults.skillInjectionDynamic")}],z=[{value:"dynamic",label:e("botDefaults.skillInjectionDynamicUnsupported"),disabled:!0},{value:"prompt",label:e("botDefaults.skillInjectionPrompt")},{value:"global",label:e("botDefaults.skillInjectionGlobal")},{value:"off",label:e("botDefaults.skillInjectionOff")}],E=r==="riff";return(0,t.jsxs)("section",{className:"bd-section",children:[(0,t.jsx)("h3",{className:"bd-section-title",children:e("botDefaults.sectionAgent")}),(0,t.jsx)("div",{className:"bd-row",children:(0,t.jsxs)("div",{className:"bd-field",children:[(0,t.jsx)("span",{children:e("botDefaults.agentCli")}),(0,t.jsx)(U,{dataInput:"agentCliId",ariaLabel:e("botDefaults.agentCli"),value:r,disabled:c,options:F,searchable:!0,onChange:P}),f?.available===!1?(0,t.jsx)("small",{className:"hint-warn",children:e("botDefaults.agentMissingHint",{command:f.command??r})}):null]})}),!E&&(0,t.jsx)("div",{className:"bd-row",children:(0,t.jsxs)("label",{children:[(0,t.jsx)(A,{help:e("botDefaults.agentHelp"),children:e("botDefaults.agentModel")}),(0,t.jsx)("input",{type:"text","data-input":"agentModel",list:`agent-model-suggestions-${o.larkAppId}`,placeholder:x,value:p,disabled:c||S,onChange:I=>n(I.currentTarget.value)}),(0,t.jsx)("datalist",{id:`agent-model-suggestions-${o.larkAppId}`,children:C.map(I=>(0,t.jsx)("option",{value:I},I))})]})}),E&&(0,t.jsx)(ie,{bot:o,patchBot:i,persistCliSelection:T}),!E&&B==="dynamic"?(0,t.jsx)("div",{className:"bd-row",children:(0,t.jsxs)("div",{className:"bd-field",children:[(0,t.jsx)(A,{help:e("botDefaults.skillInjectionHelpDynamic"),children:e("botDefaults.skillInjection")}),(0,t.jsx)(U,{dataInput:"skillInjection",ariaLabel:e("botDefaults.skillInjection"),value:"dynamic",disabled:!0,options:j,onChange:()=>{}})]})}):!E&&B==="global"?(0,t.jsxs)("div",{className:"bd-row",children:[(0,t.jsxs)("div",{className:"bd-field",children:[(0,t.jsx)(A,{help:e("botDefaults.skillInjectionHelp"),children:e("botDefaults.skillInjection")}),(0,t.jsx)(U,{dataInput:"skillInjection",ariaLabel:e("botDefaults.skillInjection"),value:k,disabled:N,options:z,onChange:I=>{w(I)}})]}),(0,t.jsx)("div",{className:"actions",children:(0,t.jsx)($,{status:v,attr:{"data-skill-injection-status":""}})})]}):null,!E&&(0,t.jsxs)("div",{className:"actions bd-section-actions",children:[(0,t.jsx)("button",{type:"button",className:"primary","data-action":"save-agent",disabled:c,onClick:()=>{W()},children:e("botDefaults.agentSave")}),(0,t.jsx)($,{status:m,attr:{"data-agent-status":""}})]})]})}function St(a){let e=a.skillInjection==="global"||a.skillInjection==="prompt"||a.skillInjection==="off"?a.skillInjection:"",o=a.skillInjectionDefault==="global"||a.skillInjectionDefault==="off"?a.skillInjectionDefault:"prompt";return e||o}function Et(a){let e=R(),{bot:o,patchBot:u}=a,i=Ct(o),[l,r]=(0,s.useState)(i.mode),[d,p]=(0,s.useState)(i.workingDir),[n,m]=(0,s.useState)(o.defaultWorkingDirAutoWorktree===!0),[g,c]=(0,s.useState)(null),[b,k]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let y=Ct(o);r(y.mode),p(y.workingDir),m(o.defaultWorkingDirAutoWorktree===!0)},[o.defaultOncall?.enabled,o.defaultOncall?.workingDir,o.defaultWorkingDir,o.defaultWorkingDirAutoWorktree]);async function D(){c(null);let y=d.trim();if(l!=="off"&&!y){c({text:e("botDefaults.required")});return}let N=l==="default"&&n;k(!0);try{let h=await O("PUT",`/api/bots/${encodeURIComponent(o.larkAppId)}/working-dir-mode`,{mode:l,workingDir:y,autoWorktree:N});if(h.ok&&h.body.ok){let f=h.body.resolvedPath?` \u2192 ${h.body.resolvedPath}`:"";c({text:`\u2713 ${e("botDefaults.workingDirSaved")}${f}`,ok:!0}),u(o.larkAppId,{defaultOncall:h.body.defaultOncall??o.defaultOncall,defaultWorkingDir:h.body.defaultWorkingDir??null,defaultWorkingDirAutoWorktree:h.body.defaultWorkingDirAutoWorktree===!0})}else c({text:`\u2717 ${L(h)}`})}catch(h){c({text:`\u2717 ${M(h)}`})}finally{k(!1)}}let v=[{value:"off",label:e("botDefaults.workingDirModeOff")},{value:"default",label:e("botDefaults.workingDirModeDefault")},{value:"oncall",label:e("botDefaults.workingDirModeOncall")}];return(0,t.jsxs)("section",{className:"bd-section",children:[(0,t.jsx)("h3",{className:"bd-section-title",children:e("botDefaults.sectionWorkingDir")}),(0,t.jsx)("div",{className:"bd-row",children:(0,t.jsxs)("div",{className:"bd-field",children:[(0,t.jsx)(A,{help:e("botDefaults.workingDirModeHelp"),children:e("botDefaults.workingDirMode")}),(0,t.jsx)(U,{dataInput:"workingDirMode",ariaLabel:e("botDefaults.workingDirMode"),value:l,disabled:b,options:v,onChange:y=>r(y)})]})}),(0,t.jsx)("div",{className:"bd-row","data-wd-dir-row":!0,hidden:l==="off",children:(0,t.jsxs)("label",{children:[(0,t.jsx)("span",{children:e("botDefaults.workingDirField")}),(0,t.jsx)("input",{type:"text","data-input":"workingDir",placeholder:"e.g. /root/iserver/botmux",value:d,disabled:b,onChange:y=>p(y.currentTarget.value)})]})}),(0,t.jsxs)("label",{className:"toggle-row","data-wd-worktree-row":!0,hidden:l!=="default",children:[(0,t.jsx)("input",{type:"checkbox","data-input":"autoWorktree",checked:n,disabled:b,onChange:y=>m(y.currentTarget.checked)}),(0,t.jsx)("span",{className:"switch","aria-hidden":"true"}),(0,t.jsx)("span",{className:"toggle-tx",children:(0,t.jsx)("strong",{children:(0,t.jsx)(A,{help:e("botDefaults.autoWorktreeHelp"),children:e("botDefaults.autoWorktree")})})})]}),(0,t.jsxs)("div",{className:"actions",children:[(0,t.jsx)("button",{type:"button",className:"primary","data-action":"save-working-dir",disabled:b,onClick:()=>{D()},children:e("botDefaults.save")}),(0,t.jsx)($,{status:g,attr:{"data-status":""}})]}),(0,t.jsx)(Jt,{bot:o,putCardPref:a.putCardPref})]})}function Ct(a){let e=a.defaultOncall??{enabled:!1,workingDir:""};return{mode:e.enabled?"oncall":a.defaultWorkingDir?"default":"off",workingDir:a.defaultWorkingDir||e.workingDir||""}}function Jt(a){let e=R(),{bot:o,putCardPref:u}=a,[i,l]=(0,s.useState)(o.autoStartOnGroupJoin===!0),[r,d]=(0,s.useState)(o.autoStartOnNewTopic===!0),[p,n]=(0,s.useState)(typeof o.autoStartOnGroupJoinPrompt=="string"?o.autoStartOnGroupJoinPrompt:""),[m,g]=(0,s.useState)(null),[c,b]=(0,s.useState)(null);(0,s.useEffect)(()=>{l(o.autoStartOnGroupJoin===!0),d(o.autoStartOnNewTopic===!0),n(typeof o.autoStartOnGroupJoinPrompt=="string"?o.autoStartOnGroupJoinPrompt:"")},[o.autoStartOnGroupJoin,o.autoStartOnGroupJoinPrompt,o.autoStartOnNewTopic]);async function k(D,v){b(v),g(null);try{let y=await u(D);g(y.ok?{text:`\u2713 ${e("botDefaults.cardPrefSaved")}`,ok:!0}:{text:`\u2717 ${L(y)}`})}catch(y){g({text:`\u2717 ${M(y)}`})}finally{b(null)}}return(0,t.jsxs)("div",{className:"bd-subsection",children:[(0,t.jsx)("h4",{className:"bd-subsection-title",children:e("botDefaults.sectionAutoStart")}),(0,t.jsx)(G,{checked:i,disabled:c==="join",dataAction:"toggle-auto-join",title:e("botDefaults.autoStartJoin"),help:e("botDefaults.autoStartJoinHelp"),onChange:D=>{l(D),k({autoStartOnGroupJoin:D},"join")}}),(0,t.jsx)("div",{className:"bd-row",children:(0,t.jsxs)("label",{children:[(0,t.jsx)("span",{children:e("botDefaults.autoStartJoinPrompt")}),(0,t.jsx)("textarea",{"data-input":"autoJoinPrompt",rows:3,placeholder:e("botDefaults.autoStartJoinPromptPlaceholder"),value:p,onChange:D=>n(D.currentTarget.value)})]})}),(0,t.jsx)(G,{checked:r,disabled:c==="topic",dataAction:"toggle-auto-topic",title:e("botDefaults.autoStartTopic"),help:e("botDefaults.autoStartTopicHelp"),onChange:D=>{d(D),k({autoStartOnNewTopic:D},"topic")}}),(0,t.jsxs)("div",{className:"actions",children:[(0,t.jsx)("button",{type:"button",className:"primary","data-action":"save-auto-join-prompt",disabled:c==="prompt",onClick:()=>{k({autoStartOnGroupJoinPrompt:p},"prompt")},children:e("botDefaults.autoStartJoinPromptSave")}),(0,t.jsx)($,{status:m,attr:{"data-auto-start-status":""}})]})]})}function qt(a){let e=R(),{bot:o,patchBot:u}=a,[i,l]=(0,s.useState)(o.sandbox===!0),[r,d]=(0,s.useState)(null),[p,n]=(0,s.useState)(!1);(0,s.useEffect)(()=>l(o.sandbox===!0),[o.sandbox]);async function m(c){l(c),d(null),n(!0);try{let b=await O("PUT",`/api/bots/${encodeURIComponent(o.larkAppId)}/sandbox`,{enabled:c});b.ok&&b.body.ok?(d({text:`\u2713 ${e("botDefaults.sandboxSaved")}`,ok:!0}),u(o.larkAppId,{sandbox:b.body.sandbox===!0})):(d({text:`\u2717 ${L(b)}`}),l(!c))}catch(b){d({text:`\u2717 ${M(b)}`}),l(!c)}finally{n(!1)}}let g=o.readIsolationSupported===!0;return(0,t.jsxs)("section",{className:"bd-section",children:[(0,t.jsx)("h3",{className:"bd-section-title",children:e("botDefaults.sectionSandbox")}),(0,t.jsx)(G,{checked:i,disabled:p,dataAction:"toggle-sandbox",title:e("botDefaults.sandboxToggle"),help:e("botDefaults.sandboxHelp"),onChange:c=>{m(c)}}),(0,t.jsx)("p",{className:"bd-section-note","data-read-iso-capability":g?"yes":"no",children:g?`\uFF0B ${e("botDefaults.sandboxReadIsoOn")}`:e("botDefaults.sandboxReadIsoOff")}),(0,t.jsx)("div",{className:"actions",children:(0,t.jsx)($,{status:r,attr:{"data-sandbox-status":""}})})]})}var Kt=[{value:"",labelKey:"botDefaults.backendAuto"},{value:"tmux",labelKey:"botDefaults.backendTmux"},{value:"herdr",labelKey:"botDefaults.backendHerdr"},{value:"zellij",labelKey:"botDefaults.backendZellij"},{value:"pty",labelKey:"botDefaults.backendPty"}];function Qt(a){let e=R(),{bot:o,patchBot:u}=a,[i,l]=(0,s.useState)(typeof o.backendType=="string"?o.backendType:""),[r,d]=(0,s.useState)(null),[p,n]=(0,s.useState)(!1);(0,s.useEffect)(()=>l(typeof o.backendType=="string"?o.backendType:""),[o.backendType]);let m=(0,s.useMemo)(()=>Kt.map(c=>({value:c.value,label:e(c.labelKey)})),[e]);async function g(c){let b=i;l(c),d(null),n(!0);try{let k=await O("PUT",`/api/bots/${encodeURIComponent(o.larkAppId)}/backend-type`,{backendType:c});k.ok&&k.body.ok?(d({text:`\u2713 ${e("botDefaults.backendSaved")}`,ok:!0}),u(o.larkAppId,{backendType:typeof k.body.backendType=="string"?k.body.backendType:null})):(d({text:`\u2717 ${L(k)}`}),l(b))}catch(k){d({text:`\u2717 ${M(k)}`}),l(b)}finally{n(!1)}}return(0,t.jsxs)("section",{className:"bd-section",children:[(0,t.jsx)("h3",{className:"bd-section-title",children:e("botDefaults.sectionBackend")}),(0,t.jsxs)("div",{className:"bd-row",children:[(0,t.jsxs)("div",{className:"bd-field",children:[(0,t.jsx)(A,{help:e("botDefaults.backendHelp"),children:e("botDefaults.backendLabel")}),(0,t.jsx)(U,{dataInput:"backendType",ariaLabel:e("botDefaults.backendLabel"),value:i,disabled:p,options:m,onChange:c=>{g(c)}})]}),(0,t.jsx)("div",{className:"actions",children:(0,t.jsx)($,{status:r,attr:{"data-backend-status":""}})})]})]})}function Vt(a){let e=R(),{bot:o,patchBot:u}=a,[i,l]=(0,s.useState)(typeof o.teamRole=="string"),[r,d]=(0,s.useState)(typeof o.teamRole=="string"?o.teamRole:""),[p,n]=(0,s.useState)(null),[m,g]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let b=!0,k=`/api/team/local-bots/${encodeURIComponent(o.larkAppId)}/role`;return typeof o.teamRole=="string"?(l(!0),d(o.teamRole),()=>{b=!1}):(n(null),l(!1),d(""),(async()=>{try{let D=await fetch(k),v=await D.json().catch(()=>({}));if(!b)return;if(D.ok&&v.ok){let y=v.role??"";d(y),l(!0),u(o.larkAppId,{teamRole:y})}else n({text:`\u2717 ${e("botDefaults.roleLoadErr")}: ${v.error??D.status}`})}catch(D){b&&n({text:`\u2717 ${e("botDefaults.roleLoadErr")}: ${M(D)}`})}})(),()=>{b=!1})},[o.larkAppId,o.teamRole,u,e]);async function c(b,k){if(i){n(null),g(!0);try{let D=await O("PUT",`/api/team/local-bots/${encodeURIComponent(o.larkAppId)}/role`,{role:b});if(D.ok&&D.body.ok){let v=b.trim();d(v),u(o.larkAppId,{teamRole:v}),n({text:`\u2713 ${e(k?"botDefaults.roleDeleted":"botDefaults.roleSaved")}`,ok:!0})}else n({text:`\u2717 ${L(D)}`})}catch(D){n({text:`\u2717 ${M(D)}`})}finally{g(!1)}}}return(0,t.jsxs)("section",{className:"bd-section",children:[(0,t.jsx)("h3",{className:"bd-section-title",children:(0,t.jsx)(A,{help:e("botDefaults.roleHelp"),children:e("botDefaults.sectionRole")})}),(0,t.jsx)("textarea",{"data-input":"teamRole",rows:6,placeholder:e("botDefaults.rolePlaceholder"),disabled:!i||m,value:r,onChange:b=>d(b.currentTarget.value)}),(0,t.jsxs)("div",{className:"actions",children:[(0,t.jsx)("button",{type:"button",className:"primary","data-action":"save-role",disabled:!i||m,onClick:()=>{c(r,r.trim()==="")},children:e("botDefaults.roleSave")}),(0,t.jsx)($,{status:p,attr:{"data-role-status":""}})]}),(0,t.jsx)(_t,{appId:o.larkAppId})]})}function _t(a){let e=R(),[o,u]=(0,s.useState)({loaded:!1,loading:!0,items:[]});(0,s.useEffect)(()=>{let r=!0;return u({loaded:!1,loading:!0,items:[]}),(async()=>{try{let d=await fetch("/api/role-profiles"),p=await d.json().catch(()=>({}));if(!r)return;if(!d.ok)throw new Error(p?.error??String(d.status));let m=(Array.isArray(p.profiles)?p.profiles:[]).filter(g=>(g.botEntries??[]).some(c=>c?.larkAppId===a.appId&&c?.hasEntry)).map(g=>({profileId:String(g.profileId)}));u({loaded:!0,loading:!1,items:m})}catch(d){r&&u({loaded:!0,loading:!1,error:M(d),items:[]})}})(),()=>{r=!1}},[a.appId]);async function i(r){let d=o.items.find(p=>p.profileId===r);if(!(!d||d.loaded||d.loading)){u(p=>({...p,items:p.items.map(n=>n.profileId===r?{...n,loading:!0}:n)}));try{let p=await fetch(`/api/role-profiles/${encodeURIComponent(r)}/${encodeURIComponent(a.appId)}`),n=await p.json().catch(()=>({}));if(!p.ok)throw new Error(n?.error??String(p.status));u(m=>({...m,items:m.items.map(g=>g.profileId===r?{...g,loading:!1,loaded:!0,content:n?.hasEntry?String(n.content??""):""}:g)}))}catch(p){u(n=>({...n,items:n.items.map(m=>m.profileId===r?{...m,loading:!1,error:M(p)}:m)}))}}}let l;return o.loading?l=(0,t.jsx)(V,{label:e("common.loading"),compact:!0}):o.error?l=(0,t.jsx)("p",{className:"hint-warn-inline",children:e("botDefaults.profileRolesLoadFailed",{error:o.error})}):o.items.length===0?l=(0,t.jsx)("p",{className:"empty",children:e("botDefaults.profileRolesEmpty")}):l=o.items.map(r=>(0,t.jsxs)("details",{className:"bd-profile-role-entry","data-profile-id":r.profileId,onToggle:d=>{d.currentTarget.open&&i(r.profileId)},children:[(0,t.jsx)("summary",{children:(0,t.jsx)("span",{className:"bd-profile-role-id",children:r.profileId})}),(0,t.jsx)("div",{className:"bd-profile-role-content","data-profile-role-body":r.profileId,children:r.loading?(0,t.jsx)(V,{label:e("common.loading"),compact:!0}):r.error?(0,t.jsx)("p",{className:"hint-warn-inline",children:e("botDefaults.profileRoleDetailLoadFailed",{error:r.error})}):r.loaded?(0,t.jsx)("pre",{children:r.content??""}):(0,t.jsx)("p",{className:"empty",children:e("botDefaults.profileRoleClickToLoad")})})]},r.profileId)),(0,t.jsxs)("div",{className:"bd-profile-roles","data-profile-roles":!0,children:[(0,t.jsx)("h4",{className:"bd-subsection-title",children:(0,t.jsx)(A,{help:e("botDefaults.profileRolesHelp"),children:e("botDefaults.profileRoles")})}),(0,t.jsx)("div",{className:"bd-profile-role-list","data-profile-role-list":!0,children:l})]})}function zt(a){let e=R(),{bot:o,putCardPref:u}=a,[i,l]=(0,s.useState)(o.disableStreamingCard===!0),[r,d]=(0,s.useState)(o.silentTurnReactions===!0),[p,n]=(0,s.useState)(o.writableTerminalLinkInCard===!0),[m,g]=(0,s.useState)(o.privateCard===!0),[c,b]=(0,s.useState)(null),[k,D]=(0,s.useState)(null);(0,s.useEffect)(()=>{l(o.disableStreamingCard===!0),d(o.silentTurnReactions===!0),n(o.writableTerminalLinkInCard===!0),g(o.privateCard===!0)},[o.disableStreamingCard,o.privateCard,o.silentTurnReactions,o.writableTerminalLinkInCard]);async function v(y,N){D(N),b(null);try{let h=await u(y);b(h.ok?{text:`\u2713 ${e("botDefaults.cardPrefSaved")}`,ok:!0}:{text:`\u2717 ${L(h)}`})}catch(h){b({text:`\u2717 ${M(h)}`})}finally{D(null)}}return(0,t.jsxs)("section",{className:"bd-section",children:[(0,t.jsx)("h3",{className:"bd-section-title",children:e("botDefaults.sectionCard")}),(0,t.jsxs)("div",{className:"bd-toggle-grid bd-card-behavior-grid",children:[(0,t.jsx)(G,{checked:i,disabled:k==="streaming",dataAction:"toggle-disable-streaming",title:e("botDefaults.disableStreaming"),help:e("botDefaults.disableStreamingHelp"),onChange:y=>{l(y),v({disableStreamingCard:y},"streaming")}}),(0,t.jsx)(G,{checked:r,disabled:!i||k==="silent",dataAction:"toggle-silent-reactions",title:e("botDefaults.silentTurnReactions"),help:e("botDefaults.silentTurnReactionsHelp"),onChange:y=>{d(y),v({silentTurnReactions:y},"silent")}}),(0,t.jsx)(G,{checked:p,disabled:i||k==="writable",dataAction:"toggle-writable-link",title:e("botDefaults.writableLink"),help:e("botDefaults.writableLinkHelp"),onChange:y=>{n(y),v({writableTerminalLinkInCard:y},"writable")}}),(0,t.jsx)(G,{checked:m,disabled:k==="private",dataAction:"toggle-private-card",title:e("botDefaults.privateCard"),help:e("botDefaults.privateCardHelp"),onChange:y=>{g(y),v({privateCard:y},"private")}})]}),(0,t.jsxs)("div",{className:"actions",children:[(0,t.jsx)("small",{"data-card-pref-moot":!0,className:"hint-warn-inline",hidden:!i,children:e("botDefaults.writableLinkMoot")}),(0,t.jsx)($,{status:c,attr:{"data-card-pref-status":""}})]})]})}function Yt(a){let e=R(),[o,u]=(0,s.useState)(a.bot.codexAppCleanInput===!0),[i,l]=(0,s.useState)(null),[r,d]=(0,s.useState)(!1);(0,s.useEffect)(()=>u(a.bot.codexAppCleanInput===!0),[a.bot.codexAppCleanInput]);async function p(n){let m=o;u(n),d(!0),l(null);try{let g=await a.putCardPref({codexAppCleanInput:n});g.ok?l({text:`\u2713 ${e("botDefaults.cardPrefSaved")}`,ok:!0}):(u(m),l({text:`\u2717 ${L(g)}`}))}catch(g){u(m),l({text:`\u2717 ${M(g)}`})}finally{d(!1)}}return(0,t.jsxs)("section",{className:"bd-section","data-codex-app-display":!0,children:[(0,t.jsx)("h3",{className:"bd-section-title",children:e("botDefaults.sectionCodexAppDisplay")}),(0,t.jsx)(G,{checked:o,disabled:r,dataAction:"toggle-codex-app-clean-input",title:e("botDefaults.codexAppCleanInput"),help:e("botDefaults.codexAppCleanInputHelp"),onChange:n=>{p(n)}}),(0,t.jsx)("small",{className:"bd-section-note",children:e("botDefaults.codexAppCleanInputCompat")}),(0,t.jsx)("div",{className:"actions",children:(0,t.jsx)($,{status:i,attr:{"data-codex-app-clean-input-status":""}})})]})}function Zt(a){let e=R(),[o,u]=(0,s.useState)(a.bot.botToBotSameDir!==!1),[i,l]=(0,s.useState)(null),[r,d]=(0,s.useState)(!1);(0,s.useEffect)(()=>u(a.bot.botToBotSameDir!==!1),[a.bot.botToBotSameDir]);async function p(n){u(n),d(!0),l(null);try{let m=await a.putCardPref({botToBotSameDir:n});l(m.ok?{text:`\u2713 ${e("botDefaults.cardPrefSaved")}`,ok:!0}:{text:`\u2717 ${L(m)}`})}catch(m){l({text:`\u2717 ${M(m)}`})}finally{d(!1)}}return(0,t.jsxs)("section",{className:"bd-section",children:[(0,t.jsx)("h3",{className:"bd-section-title",children:e("botDefaults.sectionCrossBot")}),(0,t.jsx)(G,{checked:o,disabled:r,dataAction:"toggle-cross-bot-samedir",title:e("botDefaults.botToBotSameDir"),help:e("botDefaults.botToBotSameDirHelp"),onChange:n=>{p(n)}}),(0,t.jsx)("div",{className:"actions",children:(0,t.jsx)($,{status:i,attr:{"data-crossbot-status":""}})})]})}function Xt(a){let e=R(),o=et(a.bot),[u,i]=(0,s.useState)(String(o.limit)),[l,r]=(0,s.useState)(String(o.sinceHours)),[d,p]=(0,s.useState)(null),[n,m]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let c=et(a.bot);i(String(c.limit)),r(String(c.sinceHours))},[a.bot.summaryRange?.limit,a.bot.summaryRange?.sinceHours]);async function g(){p(null);let c=Dt(u,50),b=Dt(l,24);if(c==null||b==null){p({text:`\u2717 ${e("botDefaults.summaryNumberInvalid")}`});return}m(!0);try{let k=await O("PUT",`/api/bots/${encodeURIComponent(a.bot.larkAppId)}/summary-range`,{limit:c,sinceHours:b});if(k.ok&&k.body.ok){let D=k.body.summaryRange??{limit:c,sinceHours:b},v=et({...a.bot,summaryRange:D});i(String(v.limit)),r(String(v.sinceHours)),a.patchBot(a.bot.larkAppId,{summaryRange:D}),p({text:`\u2713 ${e("botDefaults.cardPrefSaved")}`,ok:!0})}else p({text:`\u2717 ${L(k)}`})}catch(k){p({text:`\u2717 ${M(k)}`})}finally{m(!1)}}return(0,t.jsxs)("section",{className:"bd-section",children:[(0,t.jsx)("h3",{className:"bd-section-title",children:(0,t.jsx)(A,{help:e("botDefaults.summaryLimitHelp"),children:e("botDefaults.sectionSummaryTrigger")})}),(0,t.jsxs)("div",{className:"bd-row bd-summary-limits",children:[(0,t.jsxs)("label",{children:[(0,t.jsx)("span",{children:e("botDefaults.summaryLimit")}),(0,t.jsx)("input",{type:"number",min:0,step:1,"data-input":"summaryLimit",value:u,disabled:n,onChange:c=>i(c.currentTarget.value)})]}),(0,t.jsxs)("label",{children:[(0,t.jsx)("span",{children:e("botDefaults.summarySinceHours")}),(0,t.jsx)("input",{type:"number",min:0,step:1,"data-input":"summarySinceHours",value:l,disabled:n,onChange:c=>r(c.currentTarget.value)})]})]}),(0,t.jsxs)("div",{className:"actions",children:[(0,t.jsx)("button",{type:"button",className:"primary","data-action":"save-summary-trigger",disabled:n,onClick:()=>{g()},children:e("botDefaults.summarySave")}),(0,t.jsx)($,{status:d,attr:{"data-summary-trigger-status":""}})]})]})}function et(a){let e=a.summaryRange??{limit:50,sinceHours:24};return{limit:Number.isInteger(e.limit)&&Number(e.limit)>=0?Number(e.limit):50,sinceHours:Number.isInteger(e.sinceHours)&&Number(e.sinceHours)>=0?Number(e.sinceHours):24}}function te(a){let e=R(),[o,u]=(0,s.useState)(a.bot.p2pMode==="chat"?"chat":"thread"),[i,l]=(0,s.useState)(It(a.bot)),[r,d]=(0,s.useState)(Nt(a.bot)),[p,n]=(0,s.useState)(a.bot.docSubscribeDefaultMode==="all"?"all":"mention-only"),[m,g]=(0,s.useState)(null),[c,b]=(0,s.useState)(null),[k,D]=(0,s.useState)(null),[v,y]=(0,s.useState)(null),[N,h]=(0,s.useState)(null);(0,s.useEffect)(()=>{u(a.bot.p2pMode==="chat"?"chat":"thread"),l(It(a.bot)),d(Nt(a.bot)),n(a.bot.docSubscribeDefaultMode==="all"?"all":"mention-only")},[a.bot.docSubscribeDefaultMode,a.bot.p2pMode,a.bot.regularGroupMentionMode,a.bot.regularGroupReplyMode]);async function f(T){let w=T==="chat"?"chat":"thread";u(w),g("p2p"),b(null);try{let B=await O("PUT",`/api/bots/${encodeURIComponent(a.bot.larkAppId)}/p2p-mode`,{p2pMode:w});B.ok&&B.body.ok?(a.patchBot(a.bot.larkAppId,{p2pMode:B.body.p2pMode==="chat"?"chat":"thread"}),b({text:`\u2713 ${e("botDefaults.cardPrefSaved")}`,ok:!0})):b({text:`\u2717 ${L(B)}`})}catch(B){b({text:`\u2717 ${M(B)}`})}finally{g(null)}}async function C(T,w,B){g(T),B(null);try{let F=await a.putCardPref(w);B(F.ok?{text:`\u2713 ${e("botDefaults.cardPrefSaved")}`,ok:!0}:{text:`\u2717 ${L(F)}`})}catch(F){B({text:`\u2717 ${M(F)}`})}finally{g(null)}}let S=[{value:"thread",label:e("botDefaults.p2pThread")},{value:"chat",label:e("botDefaults.p2pChat")}],x=[{value:"chat",label:e("botDefaults.regularGroupModeChat")},{value:"chat-topic",label:e("botDefaults.regularGroupModeChatTopic")},{value:"new-topic",label:e("botDefaults.regularGroupModeNewTopic")},{value:"shared",label:e("botDefaults.regularGroupModeShared")}],P=[{value:"always",label:e("botDefaults.mentionModeAlways")},{value:"topic",label:e("botDefaults.mentionModeTopic")},{value:"never",label:e("botDefaults.mentionModeNever")},{value:"ambient",label:e("botDefaults.mentionModeAmbient")}],W=[{value:"mention-only",label:e("botDefaults.docSubscribeModeMention")},{value:"all",label:e("botDefaults.docSubscribeModeAll")}];return(0,t.jsxs)("section",{className:"bd-section",children:[(0,t.jsx)("h3",{className:"bd-section-title",children:e("botDefaults.sectionSessionMode")}),(0,t.jsxs)("div",{className:"bd-row",children:[(0,t.jsxs)("div",{className:"bd-field",children:[(0,t.jsx)(A,{help:e("botDefaults.p2pHelp"),children:e("botDefaults.p2pMode")}),(0,t.jsx)(U,{dataInput:"p2pMode",ariaLabel:e("botDefaults.p2pMode"),value:o,disabled:m==="p2p",options:S,onChange:T=>{f(T)}})]}),(0,t.jsx)("div",{className:"actions",children:(0,t.jsx)($,{status:c,attr:{"data-p2p-status":""}})})]}),(0,t.jsxs)("div",{className:"bd-row",children:[(0,t.jsxs)("div",{className:"bd-field",children:[(0,t.jsx)(A,{help:e("botDefaults.regularGroupModeHelp"),children:e("botDefaults.regularGroupMode")}),(0,t.jsx)(U,{dataInput:"regularGroupMode",ariaLabel:e("botDefaults.regularGroupMode"),value:i,disabled:m==="regular",options:x,onChange:T=>{l(T),C("regular",{regularGroupReplyMode:T},D)}})]}),(0,t.jsx)("div",{className:"actions",children:(0,t.jsx)($,{status:k,attr:{"data-regular-group-status":""}})})]}),(0,t.jsxs)("div",{className:"bd-row",children:[(0,t.jsxs)("div",{className:"bd-field",children:[(0,t.jsx)(A,{help:e("botDefaults.mentionModeHelp"),children:e("botDefaults.mentionMode")}),(0,t.jsx)(U,{dataInput:"regularGroupMentionMode",ariaLabel:e("botDefaults.mentionMode"),value:r,disabled:m==="mention",options:P,onChange:T=>{d(T),C("mention",{regularGroupMentionMode:T},y)}})]}),(0,t.jsx)("div",{className:"actions",children:(0,t.jsx)($,{status:v,attr:{"data-mention-mode-status":""}})})]}),(0,t.jsxs)("div",{className:"bd-row",children:[(0,t.jsxs)("div",{className:"bd-field",children:[(0,t.jsx)(A,{help:e("botDefaults.docSubscribeModeHelp"),children:e("botDefaults.docSubscribeMode")}),(0,t.jsx)(U,{dataInput:"docSubscribeDefaultMode",ariaLabel:e("botDefaults.docSubscribeMode"),value:p,disabled:m==="doc",options:W,onChange:T=>{n(T),C("doc",{docSubscribeDefaultMode:T},h)}})]}),(0,t.jsx)("div",{className:"actions",children:(0,t.jsx)($,{status:N,attr:{"data-doc-subscribe-mode-status":""}})})]})]})}function ee(a){let e=R(),o=a.bot.substituteMode??null,[u,i]=(0,s.useState)(o?.enabled===!0),[l,r]=(0,s.useState)(o?.disclosure==="none"?"none":"prefix"),[d,p]=(0,s.useState)(null),[n,m]=(0,s.useState)(!1),g=(0,s.useRef)(0),c=(0,s.useRef)(!1);function b(h){let f=Pt(h);return{key:++g.current,idField:f,idValue:h?.[f]??"",name:h?.name??"",persisted:h?{...h}:{},originalIdField:h?f:void 0}}let[k,D]=(0,s.useState)(()=>{let h=o?.targets??[];return h.length?h.map(f=>b(f)):[b()]});(0,s.useEffect)(()=>{if(c.current){c.current=!1;return}let h=a.bot.substituteMode??null;i(h?.enabled===!0),r(h?.disclosure==="none"?"none":"prefix");let f=h?.targets??[];D(f.length?f.map(C=>b(C)):[b()])},[a.bot.larkAppId,a.bot.substituteMode]);async function v(h){m(!0),p(null);try{let f=await O("PUT",`/api/bots/${encodeURIComponent(a.bot.larkAppId)}/substitute-mode`,h);if(f.ok&&f.body.ok){let C=f.body.substituteMode&&typeof f.body.substituteMode=="object"?f.body.substituteMode:null,S=Array.isArray(f.body?.resolution)?f.body.resolution:[],x=S.filter(P=>P?.ok===!1).map(P=>String(P.input??"").trim()).filter(Boolean);if(i(C?.enabled===!0),r(C?.disclosure==="none"?"none":"prefix"),S.length)c.current=!0,D(P=>{let W=[...S];return P.map(T=>{let w=T.idValue.trim(),B=W.findIndex(z=>String(z.input??"").trim()===w);if(B<0)return T;let F=W.splice(B,1)[0];if(F?.ok!==!0)return T;let j={...T.persisted};return F.openId&&(j.openId=F.openId),T.idField==="email"&&(j.email=w),F.name&&(j.name=F.name),{...T,name:F.name??T.name,persisted:j}})});else{let P=C?.targets??[];D(P.length?P.map(W=>b(W)):[b()])}a.patchBot(a.bot.larkAppId,{substituteMode:C}),p(x.length?{text:`\u2717 ${e("botDefaults.substituteTargetsInvalid")}: ${x.join(", ")}`}:{text:`\u2713 ${e("botDefaults.cardPrefSaved")}`,ok:!0})}else{let C=Array.isArray(f.body?.resolution)?f.body.resolution.filter(S=>S?.ok===!1).map(S=>String(S.input??"").trim()).filter(Boolean):[];p({text:C.length?`\u2717 ${e("botDefaults.substituteTargetsInvalid")}: ${C.join(", ")}`:`\u2717 ${L(f)}`})}}catch(f){p({text:`\u2717 ${M(f)}`})}finally{m(!1)}}function y(){let h=[],f=!1;for(let C of k){let S=Rt(C);if(!S){f||=!!C.name.trim();continue}h.push(S)}if(f||u&&h.length===0){p({text:`\u2717 ${e("botDefaults.substituteTargetsInvalid")}`});return}v({enabled:u,targets:h,disclosure:l})}let N=[{value:"prefix",label:e("botDefaults.substituteDisclosurePrefix")},{value:"none",label:e("botDefaults.substituteDisclosureNone")}];return(0,t.jsxs)("section",{className:"bd-section bd-substitute-section",children:[(0,t.jsx)("h3",{className:"bd-section-title",children:e("botDefaults.sectionSubstitute")}),(0,t.jsx)(G,{checked:u,disabled:n,dataAction:"toggle-substitute-mode",title:e("botDefaults.substituteEnabled"),help:e("botDefaults.substituteHelp"),onChange:i}),(0,t.jsx)("div",{className:"bd-row",children:(0,t.jsxs)("div",{className:"bd-field",children:[(0,t.jsx)(A,{children:e("botDefaults.substituteDisclosure")}),(0,t.jsx)(U,{dataInput:"substituteDisclosure",ariaLabel:e("botDefaults.substituteDisclosure"),value:l,disabled:n,options:N,onChange:h=>r(h)})]})}),(0,t.jsxs)("div",{className:"bd-row bd-substitute-targets",children:[(0,t.jsx)(A,{help:e("botDefaults.substituteTargetsHelp"),children:e("botDefaults.substituteTargets")}),(0,t.jsxs)("div",{className:"bd-substitute-target-list","data-input":"substituteTargets",children:[k.map((h,f)=>(0,t.jsxs)("div",{className:"bd-substitute-target-row",children:[(0,t.jsx)(U,{dataInput:`substituteTargetType-${h.key}`,className:"bd-substitute-target-type",ariaLabel:`${e("botDefaults.substituteTargetType")} ${f+1}`,value:h.idField,disabled:n,options:at.map(C=>({value:C,label:e(`botDefaults.substituteTarget${C[0].toUpperCase()}${C.slice(1)}`)})),onChange:C=>{D(S=>S.map(x=>x.key===h.key?{...x,idField:C,idValue:x.persisted[C]??""}:x))}}),(0,t.jsx)("input",{className:"bd-substitute-target-id",type:"text","data-input":`substituteTargetId-${h.key}`,"aria-label":`${e("botDefaults.substituteTargetType")} ${f+1}`,placeholder:e("botDefaults.substituteTargetIdPlaceholder"),value:h.idValue,disabled:n,onChange:C=>{let S=C.currentTarget.value;D(x=>x.map(P=>P.key===h.key?{...P,idValue:S}:P))}}),(0,t.jsx)("input",{className:"bd-substitute-target-name",type:"text","data-input":`substituteTargetName-${h.key}`,"aria-label":`${e("botDefaults.substituteTargetName")} ${f+1}`,placeholder:e("botDefaults.substituteTargetNamePlaceholder"),value:h.name,disabled:n,onChange:C=>{let S=C.currentTarget.value;D(x=>x.map(P=>P.key===h.key?{...P,name:S}:P))}}),(0,t.jsx)("button",{type:"button",className:"bd-substitute-target-remove","data-action":"remove-substitute-target",title:e("botDefaults.substituteTargetRemove"),"aria-label":e("botDefaults.substituteTargetRemove"),disabled:n,onClick:()=>{D(C=>{let S=C.filter(x=>x.key!==h.key);return S.length?S:[b()]})},children:(0,t.jsx)("span",{"aria-hidden":"true",children:"\xD7"})})]},h.key)),(0,t.jsx)("button",{type:"button",className:"bd-substitute-target-add","data-action":"add-substitute-target",title:e("botDefaults.substituteTargetAdd"),"aria-label":e("botDefaults.substituteTargetAdd"),disabled:n,onClick:()=>D(h=>[...h,b()]),children:(0,t.jsx)("span",{"aria-hidden":"true",children:"+"})})]})]}),(0,t.jsxs)("div",{className:"actions",children:[(0,t.jsx)("button",{type:"button",className:"primary","data-action":"save-substitute-mode",disabled:n,onClick:y,children:e("botDefaults.substituteSave")}),(0,t.jsx)("button",{type:"button","data-action":"off-substitute-mode",disabled:n,onClick:()=>{v({enabled:!1,targets:[]})},children:e("botDefaults.substituteOff")}),(0,t.jsx)($,{status:d,attr:{"data-substitute-status":""}})]})]})}function It(a){return a.regularGroupReplyMode==="new-topic"||a.regularGroupReplyMode==="shared"||a.regularGroupReplyMode==="chat-topic"?a.regularGroupReplyMode:"chat"}function Nt(a){return a.regularGroupMentionMode==="topic"||a.regularGroupMentionMode==="never"||a.regularGroupMentionMode==="ambient"?a.regularGroupMentionMode:"always"}function ae(a){let e=R(),o=typeof a.bot.maxLiveWorkers=="number"?a.bot.maxLiveWorkers:null,u=Number.isFinite(a.bot.logicalSessionCount)?Number(a.bot.logicalSessionCount):0,i=Number.isFinite(a.bot.residentSessionCount)?Number(a.bot.residentSessionCount):0,l=Number.isFinite(a.bot.dormantSessionCount)?Number(a.bot.dormantSessionCount):0,[r,d]=(0,s.useState)(o),p=r??30,[n,m]=(0,s.useState)(o==null?"":String(o)),[g,c]=(0,s.useState)(null),[b,k]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let y=typeof a.bot.maxLiveWorkers=="number"?a.bot.maxLiveWorkers:null;d(y),m(y==null?"":String(y))},[a.bot.maxLiveWorkers]);async function D(y){c(null),k(!0);try{let N=await O("PUT",`/api/bots/${encodeURIComponent(a.bot.larkAppId)}/max-live-workers`,{maxLiveWorkers:y});if(N.ok&&N.body.ok){let h=typeof N.body.maxLiveWorkers=="number"?N.body.maxLiveWorkers:null;d(h),m(h==null?"":String(h)),a.patchBot(a.bot.larkAppId,{maxLiveWorkers:h}),c({text:`\u2713 ${e("botDefaults.cardPrefSaved")}`,ok:!0})}else c({text:`\u2717 ${L(N)}`})}catch(N){c({text:`\u2717 ${M(N)}`})}finally{k(!1)}}function v(){let y=Tt(n);if(y==="invalid"){c({text:`\u2717 ${e("botDefaults.maxLiveWorkersInvalid")}`});return}D(y)}return(0,t.jsxs)("div",{className:"bd-subsection",children:[(0,t.jsx)("h4",{className:"bd-subsection-title",children:e("botDefaults.sectionSessionCap")}),(0,t.jsxs)("div",{className:"bd-row bd-quota",children:[(0,t.jsxs)("label",{children:[(0,t.jsx)(A,{help:e("botDefaults.maxLiveWorkersHelp"),children:e("botDefaults.maxLiveWorkers")}),(0,t.jsx)("input",{type:"number",min:1,step:1,"data-input":"maxLiveWorkers",placeholder:e("botDefaults.maxLiveWorkersPlaceholder"),value:n,disabled:b,onChange:y=>m(y.currentTarget.value)})]}),(0,t.jsx)("small",{"data-session-cap-state":!0,children:$t(r,e)}),(0,t.jsx)("small",{className:"bd-help bd-session-residency",children:e("botDefaults.maxLiveWorkersUsage",{resident:i,cap:p,dormant:l,logical:u})})]}),(0,t.jsxs)("div",{className:"actions",children:[(0,t.jsx)("button",{type:"button",className:"primary","data-action":"save-session-cap",disabled:b,onClick:v,children:e("botDefaults.maxLiveWorkersSave")}),(0,t.jsx)("button",{type:"button","data-action":"off-session-cap",disabled:b,onClick:()=>{m(""),D(null)},children:e("botDefaults.maxLiveWorkersOff")}),(0,t.jsx)($,{status:g,attr:{"data-session-cap-status":""}})]})]})}function oe(a){let e=R(),[o,u]=(0,s.useState)(typeof a.bot.startupCommands=="string"?a.bot.startupCommands:""),[i,l]=(0,s.useState)(null),[r,d]=(0,s.useState)(!1);(0,s.useEffect)(()=>u(typeof a.bot.startupCommands=="string"?a.bot.startupCommands:""),[a.bot.startupCommands]);async function p(){l(null),d(!0);try{let n=await O("PUT",`/api/bots/${encodeURIComponent(a.bot.larkAppId)}/startup-commands`,{startupCommands:o});if(n.ok&&n.body.ok){let m=typeof n.body.startupCommands=="string"?n.body.startupCommands:"";u(m),a.patchBot(a.bot.larkAppId,{startupCommands:m}),l({text:`\u2713 ${e("botDefaults.cardPrefSaved")}`,ok:!0})}else l({text:`\u2717 ${L(n)}`})}catch(n){l({text:`\u2717 ${M(n)}`})}finally{d(!1)}}return(0,t.jsxs)("div",{className:"bd-subsection",children:[(0,t.jsx)("h4",{className:"bd-subsection-title",children:(0,t.jsx)(A,{help:e("botDefaults.startupCommandsHelp"),children:e("botDefaults.sectionStartupCommands")})}),(0,t.jsx)("textarea",{"data-input":"startupCommands",rows:3,placeholder:e("botDefaults.startupCommandsPlaceholder"),value:o,disabled:r,onChange:n=>u(n.currentTarget.value)}),(0,t.jsxs)("div",{className:"actions",children:[(0,t.jsx)("button",{type:"button",className:"primary","data-action":"save-startup-commands",disabled:r,onClick:()=>{p()},children:e("botDefaults.startupCommandsSave")}),(0,t.jsx)($,{status:i,attr:{"data-startup-commands-status":""}})]})]})}function se(a){let e=R(),[o,u]=(0,s.useState)(typeof a.bot.launchShell=="string"?a.bot.launchShell:""),[i,l]=(0,s.useState)(null),[r,d]=(0,s.useState)(!1);(0,s.useEffect)(()=>u(typeof a.bot.launchShell=="string"?a.bot.launchShell:""),[a.bot.launchShell]);async function p(){l(null),d(!0);try{let n=await O("PUT",`/api/bots/${encodeURIComponent(a.bot.larkAppId)}/launch-shell`,{launchShell:o});if(n.ok&&n.body.ok){let m=typeof n.body.launchShell=="string"?n.body.launchShell:"";u(m),a.patchBot(a.bot.larkAppId,{launchShell:m}),l({text:`\u2713 ${e("botDefaults.cardPrefSaved")}`,ok:!0})}else l({text:`\u2717 ${L(n)}`})}catch(n){l({text:`\u2717 ${M(n)}`})}finally{d(!1)}}return(0,t.jsxs)("div",{className:"bd-subsection",children:[(0,t.jsx)("h4",{className:"bd-subsection-title",children:(0,t.jsx)(A,{help:e("botDefaults.launchShellHelp"),children:e("botDefaults.sectionLaunchShell")})}),(0,t.jsx)("input",{type:"text","data-input":"launchShell",placeholder:e("botDefaults.launchShellPlaceholder"),value:o,disabled:r,onChange:n=>u(n.currentTarget.value)}),(0,t.jsxs)("div",{className:"actions",children:[(0,t.jsx)("button",{type:"button",className:"primary","data-action":"save-launch-shell",disabled:r,onClick:()=>{p()},children:e("botDefaults.launchShellSave")}),(0,t.jsx)($,{status:i,attr:{"data-launch-shell-status":""}})]})]})}function ne(a){let e=R(),[o,u]=(0,s.useState)(typeof a.bot.env=="string"?a.bot.env:""),[i,l]=(0,s.useState)(null),[r,d]=(0,s.useState)(!1);(0,s.useEffect)(()=>u(typeof a.bot.env=="string"?a.bot.env:""),[a.bot.env]);async function p(){l(null),d(!0);try{let n=await O("PUT",`/api/bots/${encodeURIComponent(a.bot.larkAppId)}/env`,{env:o});if(n.ok&&n.body.ok){let m=typeof n.body.env=="string"?n.body.env:"";u(m),a.patchBot(a.bot.larkAppId,{env:m}),l({text:`\u2713 ${e("botDefaults.cardPrefSaved")}`,ok:!0})}else l({text:`\u2717 ${L(n)}`})}catch(n){l({text:`\u2717 ${M(n)}`})}finally{d(!1)}}return(0,t.jsxs)("div",{className:"bd-subsection",children:[(0,t.jsx)("h4",{className:"bd-subsection-title",children:(0,t.jsx)(A,{help:e("botDefaults.envHelp"),children:e("botDefaults.sectionEnv")})}),(0,t.jsx)("textarea",{"data-input":"env",rows:5,placeholder:e("botDefaults.envPlaceholder"),value:o,disabled:r,onChange:n=>u(n.currentTarget.value)}),(0,t.jsxs)("div",{className:"actions",children:[(0,t.jsx)("button",{type:"button",className:"primary","data-action":"save-env",disabled:r,onClick:()=>{p()},children:e("botDefaults.envSave")}),(0,t.jsx)($,{status:i,attr:{"data-env-status":""}})]})]})}var le=["codex","aiden","aiden-claude","opencode"];function ie(a){let e=R(),o=a.bot.riff&&typeof a.bot.riff=="object"?a.bot.riff:{},[u,i]=(0,s.useState)(typeof o.baseUrl=="string"?o.baseUrl:""),[l,r]=(0,s.useState)(typeof o.agent=="string"?o.agent:""),[d,p]=(0,s.useState)(typeof o.model=="string"?o.model:""),[n,m]=(0,s.useState)(typeof o.jwtEnv=="string"?o.jwtEnv:""),[g,c]=(0,s.useState)(typeof o.systemPrompt=="string"?o.systemPrompt:""),[b,k]=(0,s.useState)(Array.isArray(o.setupCommands)?o.setupCommands.join(`
2
- `):""),[D,v]=(0,s.useState)(null),[y,N]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let f=a.bot.riff&&typeof a.bot.riff=="object"?a.bot.riff:{};i(typeof f.baseUrl=="string"?f.baseUrl:""),r(typeof f.agent=="string"?f.agent:""),p(typeof f.model=="string"?f.model:""),m(typeof f.jwtEnv=="string"?f.jwtEnv:""),c(typeof f.systemPrompt=="string"?f.systemPrompt:""),k(Array.isArray(f.setupCommands)?f.setupCommands.join(`
3
- `):"")},[a.bot.riff]);async function h(){v(null),N(!0);try{let f={};u.trim()&&(f.baseUrl=u.trim()),l.trim()&&(f.agent=l.trim()),d.trim()&&(f.model=d.trim()),n.trim()&&(f.jwtEnv=n.trim()),g.trim()&&(f.systemPrompt=g.trim()),b.trim()&&(f.setupCommands=b.split(`
4
- `).map(x=>x.trim()).filter(Boolean));let C=Object.keys(f).length?JSON.stringify(f):"",S=await O("PUT",`/api/bots/${encodeURIComponent(a.bot.larkAppId)}/riff`,{riff:C});if(S.ok&&S.body.ok){let x=typeof S.body.riff=="string"&&S.body.riff?JSON.parse(S.body.riff):null;if(a.patchBot(a.bot.larkAppId,{riff:x}),a.persistCliSelection&&!await a.persistCliSelection()){v({text:`\u2717 ${e("botDefaults.riffCliPersistFailed")}`});return}v({text:`\u2713 ${e("botDefaults.cardPrefSaved")}`,ok:!0})}else v({text:`\u2717 ${L(S)}`})}catch(f){v({text:`\u2717 ${M(f)}`})}finally{N(!1)}}return(0,t.jsxs)("div",{className:"bd-subsection",children:[(0,t.jsx)("h4",{className:"bd-subsection-title",children:(0,t.jsx)(A,{help:e("botDefaults.riffHelp"),children:e("botDefaults.sectionRiff")})}),(0,t.jsx)("div",{className:"bd-row",children:(0,t.jsxs)("label",{children:[(0,t.jsx)("span",{children:e("botDefaults.riffBaseUrl")}),(0,t.jsx)("input",{type:"text","data-input":"riff-base-url",placeholder:e("botDefaults.riffBaseUrlPlaceholder"),value:u,disabled:y,onChange:f=>i(f.currentTarget.value)})]})}),(0,t.jsx)("div",{className:"bd-row",children:(0,t.jsxs)("label",{children:[(0,t.jsx)("span",{children:(0,t.jsx)(A,{help:e("botDefaults.riffAgentHelp"),children:e("botDefaults.riffAgent")})}),(0,t.jsx)("input",{type:"text","data-input":"riff-agent",list:`riff-agent-suggestions-${a.bot.larkAppId}`,placeholder:e("botDefaults.riffAgentPlaceholder"),value:l,disabled:y,onChange:f=>r(f.currentTarget.value)}),(0,t.jsx)("datalist",{id:`riff-agent-suggestions-${a.bot.larkAppId}`,children:le.map(f=>(0,t.jsx)("option",{value:f},f))})]})}),(0,t.jsx)("div",{className:"bd-row",children:(0,t.jsxs)("label",{children:[(0,t.jsx)("span",{children:(0,t.jsx)(A,{help:e("botDefaults.riffModelHelp"),children:e("botDefaults.riffModel")})}),(0,t.jsx)("input",{type:"text","data-input":"riff-model",placeholder:e("botDefaults.riffModelPlaceholder"),value:d,disabled:y,onChange:f=>p(f.currentTarget.value)})]})}),(0,t.jsx)("div",{className:"bd-row",children:(0,t.jsxs)("label",{children:[(0,t.jsx)("span",{children:(0,t.jsx)(A,{help:e("botDefaults.riffJwtEnvHelp"),children:e("botDefaults.riffJwtEnv")})}),(0,t.jsx)("input",{type:"text","data-input":"riff-jwt-env",placeholder:e("botDefaults.riffJwtEnvPlaceholder"),value:n,disabled:y,onChange:f=>m(f.currentTarget.value)})]})}),(0,t.jsx)("div",{className:"bd-row",children:(0,t.jsxs)("label",{children:[(0,t.jsx)("span",{children:e("botDefaults.riffSystemPrompt")}),(0,t.jsx)("textarea",{"data-input":"riff-system-prompt",placeholder:e("botDefaults.riffSystemPromptPlaceholder"),value:g,disabled:y,onChange:f=>c(f.currentTarget.value),rows:4})]})}),(0,t.jsx)("div",{className:"bd-row",children:(0,t.jsxs)("label",{children:[(0,t.jsx)("span",{children:e("botDefaults.riffSetupCommands")}),(0,t.jsx)("textarea",{"data-input":"riff-setup-commands",placeholder:e("botDefaults.riffSetupCommandsPlaceholder"),value:b,disabled:y,onChange:f=>k(f.currentTarget.value),rows:3})]})}),(0,t.jsxs)("div",{className:"actions",children:[(0,t.jsx)("button",{type:"button",className:"primary","data-action":"save-riff",disabled:y,onClick:()=>{h()},children:e("botDefaults.riffSave")}),(0,t.jsx)($,{status:D,attr:{"data-riff-status":""}})]})]})}function re(a){let e=R(),o=a.bot.brandLabel??null,[u,i]=(0,s.useState)(o),[l,r]=(0,s.useState)(o??""),[d,p]=(0,s.useState)(null),[n,m]=(0,s.useState)(!1);(0,s.useEffect)(()=>{let c=a.bot.brandLabel??null;i(c),r(c??"")},[a.bot.brandLabel]);async function g(c){p(null),m(!0);try{let b=await O("PUT",`/api/bots/${encodeURIComponent(a.bot.larkAppId)}/brand-label`,{brandLabel:c});if(b.ok&&b.body.ok){let k=b.body.brandLabel??null;i(k),r(k??""),a.patchBot(a.bot.larkAppId,{brandLabel:k}),p({text:"\u2713",ok:!0})}else p({text:`\u2717 ${L(b)}`})}catch(b){p({text:`\u2717 ${M(b)}`})}finally{m(!1)}}return(0,t.jsxs)("section",{className:"bd-section",children:[(0,t.jsx)("h3",{className:"bd-section-title",children:e("botDefaults.sectionBrand")}),(0,t.jsxs)("div",{className:"bd-row bd-brand",children:[(0,t.jsxs)("label",{children:[(0,t.jsx)(A,{help:e("botDefaults.brandLabelHelp"),children:e("botDefaults.brandLabel")}),(0,t.jsx)("input",{type:"text","data-input":"brandLabel",placeholder:e("botDefaults.brandLabelPlaceholder"),value:l,disabled:n,onChange:c=>r(c.currentTarget.value)})]}),(0,t.jsx)("small",{"data-brand-state":!0,children:Mt(u,e)})]}),(0,t.jsxs)("div",{className:"actions",children:[(0,t.jsx)("button",{type:"button",className:"primary","data-action":"save-brand",disabled:n,onClick:()=>{g(l)},children:e("botDefaults.brandSave")}),(0,t.jsx)("button",{type:"button","data-action":"reset-brand",disabled:n,onClick:()=>{g(null)},children:e("botDefaults.brandReset")}),(0,t.jsx)($,{status:d,attr:{"data-brand-status":""}})]})]})}function ue(a){let e=R(),[o,u]=(0,s.useState)(a.bot.autoGrantRequestCards!==!1),[i,l]=(0,s.useState)(a.bot.restrictGrantCommands===!0),[r,d]=(0,s.useState)(typeof a.bot.messageQuotaDefaultLimit=="number"?a.bot.messageQuotaDefaultLimit:null),[p,n]=(0,s.useState)(typeof a.bot.messageQuotaDefaultLimit=="number"?String(a.bot.messageQuotaDefaultLimit):""),[m,g]=(0,s.useState)(null),[c,b]=(0,s.useState)(null);(0,s.useEffect)(()=>{u(a.bot.autoGrantRequestCards!==!1),l(a.bot.restrictGrantCommands===!0);let v=typeof a.bot.messageQuotaDefaultLimit=="number"?a.bot.messageQuotaDefaultLimit:null;d(v),n(v==null?"":String(v))},[a.bot.autoGrantRequestCards,a.bot.messageQuotaDefaultLimit,a.bot.restrictGrantCommands]);async function k(v,y){b(y),g(null);try{let N=await O("PUT",`/api/bots/${encodeURIComponent(a.bot.larkAppId)}/grant-prefs`,v);if(N.ok&&N.body.ok){let h=typeof N.body.messageQuotaDefaultLimit=="number"?N.body.messageQuotaDefaultLimit:null;u(N.body.autoGrantRequestCards!==!1),l(N.body.restrictGrantCommands===!0),d(h),"messageQuotaDefaultLimit"in v&&n(h==null?"":String(h)),a.patchBot(a.bot.larkAppId,{autoGrantRequestCards:N.body.autoGrantRequestCards!==!1,restrictGrantCommands:N.body.restrictGrantCommands===!0,messageQuotaDefaultLimit:h}),g({text:`\u2713 ${e("botDefaults.cardPrefSaved")}`,ok:!0})}else g({text:`\u2717 ${L(N)}`})}catch(N){g({text:`\u2717 ${M(N)}`})}finally{b(null)}}function D(){let v=Tt(p);if(v==="invalid"){g({text:`\u2717 ${e("botDefaults.quotaInvalid")}`});return}k({messageQuotaDefaultLimit:v},"quota")}return(0,t.jsxs)("section",{className:"bd-section",children:[(0,t.jsx)("h3",{className:"bd-section-title",children:e("botDefaults.sectionGrant")}),(0,t.jsxs)("div",{className:"bd-toggle-grid bd-grant-toggle-grid",children:[(0,t.jsx)(G,{checked:o,disabled:c==="autoGrant",dataAction:"toggle-auto-grant-card",title:e("botDefaults.autoGrantCard"),help:e("botDefaults.autoGrantCardHelp"),onChange:v=>{u(v),k({autoGrantRequestCards:v},"autoGrant")}}),(0,t.jsx)(G,{checked:i,disabled:c==="restrict",dataAction:"toggle-restrict-grant",title:e("botDefaults.restrictGrant"),help:e("botDefaults.restrictGrantHelp"),onChange:v=>{l(v),k({restrictGrantCommands:v},"restrict")}})]}),(0,t.jsxs)("div",{className:"bd-row bd-quota",children:[(0,t.jsxs)("label",{children:[(0,t.jsx)(A,{help:e("botDefaults.quotaHelp"),children:e("botDefaults.quotaDefault")}),(0,t.jsx)("input",{type:"number",min:1,step:1,"data-input":"quotaLimit",placeholder:e("botDefaults.quotaPlaceholder"),value:p,disabled:c==="quota",onChange:v=>n(v.currentTarget.value)})]}),(0,t.jsx)("small",{"data-quota-state":!0,children:At(r,e)})]}),(0,t.jsxs)("div",{className:"actions",children:[(0,t.jsx)("button",{type:"button",className:"primary","data-action":"save-quota",disabled:c==="quota",onClick:D,children:e("botDefaults.quotaSave")}),(0,t.jsx)($,{status:m,attr:{"data-grant-status":""}})]})]})}function ve(a){return rt(a,(0,t.jsx)(Ot,{}))}export{Wt as BotAgentSection,Yt as CodexAppDisplaySection,Rt as buildSubstituteTarget,ve as renderBotDefaultsPage};
@@ -1 +0,0 @@
1
- import{a as Q,b as j}from"./chunk-YBOHL7T7.js";import{a as J,b as A}from"./chunk-CMDPZOPK.js";import{b as H,d as M,e as T,f as O,j as W,l as x,m as I,n as P,o as X,q as G}from"./chunk-I35DXGM4.js";import{B as C,C as q,D as y,E as f,F as h,u as L,w as k,z as $}from"./chunk-NYZHARIU.js";import{a as V}from"./chunk-SYC6D5XU.js";import{a as ae,d as K}from"./chunk-5THX4DI2.js";import{c as R}from"./chunk-7SZRL6FY.js";var r=R(ae(),1);var t=R(K(),1),re=new Set(["working","analyzing","active","starting"]),le=new Set(["idle","dormant"]),ee="botmux.overview.teamExpanded",te="botmux.overview.activeSort",_=5,z=1,ce=260;function ve(){try{return window.localStorage.getItem(ee)==="1"}catch{return!1}}function de(e){try{window.localStorage.setItem(ee,e?"1":"0")}catch{}}function me(e){return e==="attention"?"attention":"time"}function ue(){try{return me(window.localStorage.getItem(te))}catch{return"time"}}function we(e){try{window.localStorage.setItem(te,e)}catch{}}function pe(e,s){let o=(i,a)=>Number(a.lastMessageAt??0)-Number(i.lastMessageAt??0);return s==="attention"?[...e].sort((i,a)=>{let m=f(i)?0:1,l=f(a)?0:1;if(m!==l)return m-l;if(m===0){let p=h(i)-h(a);if(p!==0)return p}return o(i,a)}):[...e].sort(o)}function fe(e){return String(e??"unknown").toLowerCase().replace(/[^a-z0-9_-]/g,"-")}function ge(e,s){let o=String(e??"unknown"),i=`sessions.status.${o}`,a=s(i);return a===i?o:a}function Se(e){if(!e)return z*_;let s=window.getComputedStyle(e).gridTemplateColumns.split(/\s+/).filter(i=>Number.parseFloat(i)>0);return Math.max(1,s.length||_)*z}function be(e,s){if(!e)return;let o=document.querySelector(".sidebar");if(!o||window.matchMedia("(max-width: 980px)").matches){e.style.removeProperty(s);return}let i=o.getBoundingClientRect().bottom,a=e.getBoundingClientRect().top,l=`${Math.max(ce,Math.round(i-a))}px`;e.style.getPropertyValue(s)!==l&&e.style.setProperty(s,l)}function he({card:e}){let s=A(),o=!e.online&&e.active.length===0,i=e.attention.length>0,a=e.busy.length>0,m=i?"warn":a?"busy":o?"off":"ok",l;if(i){let v=[...e.attention].sort((g,S)=>h(g)-h(S))[0];l=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:(y(v.title)||v.sessionId).slice(0,60)})," \xB7 ",f(v)??""]})}else if(a){let v=[...e.busy].sort((g,S)=>Number(S.lastMessageAt??0)-Number(g.lastMessageAt??0))[0];l=(0,t.jsx)("b",{children:(y(v.title)||v.sessionId).slice(0,60)})}else o?l=s("overview.botOffline"):l=s("overview.botIdle");let p=i?(0,t.jsx)("span",{className:"tag tag-warn",children:s("overview.botNeedsYou")}):a?(0,t.jsx)("span",{className:"tag tag-run",children:s("overview.botBusy",{count:e.busy.length})}):o?(0,t.jsx)("span",{className:"tag tag-off",children:s("overview.botOff")}):(0,t.jsx)("span",{className:"tag tag-ok",children:s("overview.botReady")});return(0,t.jsxs)("article",{className:`mate${i?" mate-attn":""}${o?" mate-off":""}`,children:[(0,t.jsxs)("div",{className:"mate-top",children:[(0,t.jsx)(H,{html:k({name:e.botName,larkAppId:e.larkAppId,avatarUrl:e.botAvatarUrl,dot:m})}),(0,t.jsxs)("div",{className:"mate-id",children:[(0,t.jsx)("b",{children:e.botName}),(0,t.jsx)("span",{className:"mate-role",children:e.cliId})]})]}),(0,t.jsx)("div",{className:"mate-task",children:l}),(0,t.jsxs)("div",{className:"mate-foot",children:[p,(0,t.jsx)("span",{children:e.lastActiveAt?s("overview.lastActive",{time:L(e.lastActiveAt)}):s("common.never")})]})]})}function Ae({session:e}){let s=A(),o=C(e),i=String(e.status??"unknown"),a=f(e);return(0,t.jsxs)(I,{kind:"session",children:[(0,t.jsx)(H,{html:k({name:o,larkAppId:e.larkAppId,size:"sm"})}),(0,t.jsxs)(P,{children:[(0,t.jsx)("b",{children:(y(e.title)||e.sessionId).slice(0,64)}),(0,t.jsxs)("span",{children:[o," \xB7 ",q(e)??e.cliId??"unknown"," \xB7 ",L(e.lastMessageAt)]})]}),(0,t.jsx)(X,{children:a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("a",{className:"overview-list-action",href:"#/sessions",children:s("strip.handle")}),(0,t.jsx)("span",{className:"status overview-list-status status-attention",children:a})]}):(0,t.jsx)("span",{className:`status overview-list-status status-${fe(i)}`,children:ge(i,s)})})]})}function Ne({schedule:e,timeZone:s}){let o=e.nextRunAt?new Date(e.nextRunAt).toLocaleString(void 0,s?{timeZone:s,timeZoneName:"short"}:void 0):"-";return(0,t.jsxs)(I,{kind:"schedule",children:[(0,t.jsxs)(P,{children:[(0,t.jsx)("strong",{children:e.name??e.id}),(0,t.jsxs)("span",{children:[C(e)," \xB7 ",e.parsed?.display??""]})]}),(0,t.jsx)("span",{className:"overview-list-meta",children:(0,t.jsx)(W,{text:o,showPopover:!1,durationMs:2600})})]})}function ye({mode:e,onModeChange:s}){let o=A(),i=o(e==="attention"?"overview.sortAttentionFirst":"overview.sortByTime");return(0,t.jsx)(G,{className:"overview-active-sort-menu",label:i,value:e,options:[{value:"time",label:o("overview.sortByTime")},{value:"attention",label:o("overview.sortAttentionFirst")}],onChange:s})}function Me(){let e=A(),s=(0,r.useRef)(null),o=(0,r.useRef)(null),i=(0,r.useRef)(null),[a,m]=(0,r.useState)(ve),[l,p]=(0,r.useState)(ue),[v,g]=(0,r.useState)(z*_),[S,D]=(0,r.useState)(0),{sessions:N,schedules:B,scheduleTimeZone:ne}=J(n=>({sessions:[...n.sessions.values()],schedules:[...n.schedules.values()],scheduleTimeZone:n.scheduleTimeZone}));(0,r.useEffect)(()=>{let n=0,d=()=>{window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{let w=Se(s.current);g(c=>c===w?c:w)})};d();let u=typeof ResizeObserver>"u"||!s.current?null:new ResizeObserver(d);return u&&s.current&&u.observe(s.current),window.addEventListener("resize",d),()=>{window.cancelAnimationFrame(n),u?.disconnect(),window.removeEventListener("resize",d)}},[]),(0,r.useEffect)(()=>{Q().then(()=>D(n=>n+1)),$().then(()=>D(n=>n+1))},[]);let F=(0,r.useMemo)(()=>N.filter(n=>n.status!=="closed"),[N]),b=(0,r.useMemo)(()=>j(N),[N,S]),U=a?b:b.slice(0,v),Y=(0,r.useMemo)(()=>pe(F.filter(n=>f(n)||re.has(n.status)||le.has(n.status)),l).slice(0,7),[F,l]),E=(0,r.useMemo)(()=>B.filter(n=>n.nextRunAt).sort((n,d)=>Date.parse(n.nextRunAt)-Date.parse(d.nextRunAt)).slice(0,5),[B]);(0,r.useEffect)(()=>{let n=[{el:o.current,propertyName:"--active-sessions-min-height"},{el:i.current,propertyName:"--schedules-panel-min-height"}].filter(c=>!!c.el);if(!n.length)return;let d=0,u=()=>{window.cancelAnimationFrame(d),d=window.requestAnimationFrame(()=>{for(let c of n)be(c.el,c.propertyName)})};u();let w=typeof ResizeObserver>"u"?null:new ResizeObserver(u);if(w){for(let ie of n)w.observe(ie.el);let c=document.querySelector(".sidebar"),Z=n[0].el.closest(".page");c&&w.observe(c),Z&&w.observe(Z)}return window.addEventListener("resize",u),()=>{window.cancelAnimationFrame(d),w?.disconnect(),window.removeEventListener("resize",u);for(let c of n)c.el.style.removeProperty(c.propertyName)}},[a,v,b.length,E.length]);let se=()=>{m(n=>(de(!n),!n))},oe=n=>{p(n),we(n)};return(0,t.jsxs)("section",{className:"page hero-page",children:[(0,t.jsx)("div",{className:"page-heading",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"eyebrow",children:e("app.subtitle")}),(0,t.jsx)("h1",{children:e("overview.title")})]})}),(0,t.jsxs)("div",{className:"overview-layout",children:[(0,t.jsxs)("div",{className:"overview-main",children:[(0,t.jsxs)("section",{className:"overview-block team-section",children:[(0,t.jsx)(M,{title:e("overview.team"),count:e("overview.teamCount",{count:b.length}),hint:e("overview.teamHint"),children:(0,t.jsx)(O,{children:(0,t.jsx)(T,{href:"#/bot-defaults",children:e("overview.viewAllPlain")})})}),(0,t.jsx)("div",{className:"team-grid",id:"team-grid",ref:s,children:U.length?U.map(n=>(0,t.jsx)(he,{card:n},n.larkAppId??n.botName)):(0,t.jsx)("div",{className:"empty",children:e("overview.noSessions")})}),b.length>v?(0,t.jsx)("button",{type:"button",className:"team-toggle",id:"team-toggle",onClick:se,children:e(a?"overview.teamCollapse":"overview.teamExpand")}):null]}),(0,t.jsxs)("section",{className:"overview-block",children:[(0,t.jsx)(M,{title:e("overview.activeSessions"),children:(0,t.jsxs)(O,{children:[(0,t.jsx)(ye,{mode:l,onModeChange:oe}),(0,t.jsx)(T,{href:"#/sessions",children:e("overview.viewAllPlain")})]})}),(0,t.jsx)("section",{className:"panel active-sessions-panel",ref:o,children:(0,t.jsx)(x,{id:"recent-sessions",children:Y.length?Y.map(n=>(0,t.jsx)(Ae,{session:n},n.sessionId)):(0,t.jsx)("li",{className:"empty",children:e("overview.noSessions")})})})]})]}),(0,t.jsx)("aside",{className:"overview-side",children:(0,t.jsxs)("section",{className:"overview-block",children:[(0,t.jsx)(M,{title:e("overview.nextSchedules"),children:(0,t.jsx)(T,{href:"#/schedules",children:e("overview.viewAllPlain")})}),(0,t.jsx)("section",{className:"panel schedules-panel",ref:i,children:(0,t.jsx)(x,{id:"next-schedules",children:E.length?E.map(n=>(0,t.jsx)(Ne,{schedule:n,timeZone:ne},n.id)):(0,t.jsx)("li",{className:"empty",children:e("overview.noSchedules")})})})]})})]})]})}function Ce(e){e.classList.add("overview-root");let s=V(e,(0,t.jsx)(Me,{}));return()=>{s(),e.classList.remove("overview-root")}}export{Ce as renderOverviewPage};