@truefoundry/trueforge 0.1.0-rc.0 → 0.1.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 (156) hide show
  1. package/dist/_frontend/assets/ConnectorSettings-H37ZFC6Z-BoDzRBt-.js +1 -0
  2. package/dist/_frontend/assets/ConnectorSettings-H37ZFC6Z-BoDzRBt-.js.br +0 -0
  3. package/dist/_frontend/assets/ConnectorSettings-H37ZFC6Z-BoDzRBt-.js.gz +0 -0
  4. package/dist/_frontend/assets/{DockLayout-WRF7EQLD-BRAhcSNV.js → DockLayout-KEMFRWIR-2H2_fGVk.js} +1 -1
  5. package/dist/_frontend/assets/{DrawerLayout-X2UXYTOS-D60ziyi9.js → DrawerLayout-ZVWCKEIS-DFGUqK6q.js} +2 -2
  6. package/dist/_frontend/assets/DrawerLayout-ZVWCKEIS-DFGUqK6q.js.br +0 -0
  7. package/dist/_frontend/assets/DrawerLayout-ZVWCKEIS-DFGUqK6q.js.gz +0 -0
  8. package/dist/_frontend/assets/ModelSettings-QJMYHCMD-DaR_pzAb.js +1 -0
  9. package/dist/_frontend/assets/ModelSettings-QJMYHCMD-DaR_pzAb.js.br +0 -0
  10. package/dist/_frontend/assets/ModelSettings-QJMYHCMD-DaR_pzAb.js.gz +0 -0
  11. package/dist/_frontend/assets/SandboxSettings-BUBMLW7Q-ChiNe2Y8.js +1 -0
  12. package/dist/_frontend/assets/SandboxSettings-BUBMLW7Q-ChiNe2Y8.js.br +0 -0
  13. package/dist/_frontend/assets/SandboxSettings-BUBMLW7Q-ChiNe2Y8.js.gz +0 -0
  14. package/dist/_frontend/assets/SettingsBuilder-26XSGIHK-DmgjXL0m.js +2 -0
  15. package/dist/_frontend/assets/SettingsBuilder-26XSGIHK-DmgjXL0m.js.br +0 -0
  16. package/dist/_frontend/assets/SettingsBuilder-26XSGIHK-DmgjXL0m.js.gz +0 -0
  17. package/dist/_frontend/assets/{SidebarLayout-M7HEOZVK-owseAySg.js → SidebarLayout-F3XFXW7B-BQV8bkzL.js} +2 -2
  18. package/dist/_frontend/assets/SidebarLayout-F3XFXW7B-BQV8bkzL.js.br +0 -0
  19. package/dist/_frontend/assets/SidebarLayout-F3XFXW7B-BQV8bkzL.js.gz +0 -0
  20. package/dist/_frontend/assets/{SkillSettings-MXK4ZEI7-CrK7D1D-.js → SkillSettings-IRMGDFRG-ChKre3S8.js} +1 -1
  21. package/dist/_frontend/assets/SkillSettings-IRMGDFRG-ChKre3S8.js.br +0 -0
  22. package/dist/_frontend/assets/SkillSettings-IRMGDFRG-ChKre3S8.js.gz +0 -0
  23. package/dist/_frontend/assets/{WidgetLayout-7MDOKLHU-OdQcbsJk.js → WidgetLayout-SZMABKIR-BRKArpEm.js} +1 -1
  24. package/dist/_frontend/assets/WidgetLayout-SZMABKIR-BRKArpEm.js.br +0 -0
  25. package/dist/_frontend/assets/WidgetLayout-SZMABKIR-BRKArpEm.js.gz +0 -0
  26. package/dist/_frontend/assets/{chunk-NBMP2XNL-DdVXEaJy.js → chunk-7EEOWDLE-BIwInB6G.js} +2 -2
  27. package/dist/_frontend/assets/chunk-7EEOWDLE-BIwInB6G.js.br +0 -0
  28. package/dist/_frontend/assets/chunk-7EEOWDLE-BIwInB6G.js.gz +0 -0
  29. package/dist/_frontend/assets/{chunk-WFC3W4C3-DXFwnpmH.js → chunk-LRQHHZDX-eb14Z2nA.js} +1 -1
  30. package/dist/_frontend/assets/chunk-LRQHHZDX-eb14Z2nA.js.br +0 -0
  31. package/dist/_frontend/assets/chunk-LRQHHZDX-eb14Z2nA.js.gz +0 -0
  32. package/dist/_frontend/assets/{cssMode-BIIwADkQ.js → cssMode-Bb1lR8Ti.js} +1 -1
  33. package/dist/_frontend/assets/cssMode-Bb1lR8Ti.js.br +0 -0
  34. package/dist/_frontend/assets/cssMode-Bb1lR8Ti.js.gz +0 -0
  35. package/dist/_frontend/assets/{freemarker2-DWtRl63b.js → freemarker2-BrrF7mKG.js} +1 -1
  36. package/dist/_frontend/assets/freemarker2-BrrF7mKG.js.br +0 -0
  37. package/dist/_frontend/assets/freemarker2-BrrF7mKG.js.gz +0 -0
  38. package/dist/_frontend/assets/{handlebars-CJJYL_TE.js → handlebars-WQ7HMT1b.js} +1 -1
  39. package/dist/_frontend/assets/handlebars-WQ7HMT1b.js.br +0 -0
  40. package/dist/_frontend/assets/handlebars-WQ7HMT1b.js.gz +0 -0
  41. package/dist/_frontend/assets/{html-CIyPQjdd.js → html-CoOPnhCb.js} +1 -1
  42. package/dist/_frontend/assets/html-CoOPnhCb.js.br +0 -0
  43. package/dist/_frontend/assets/html-CoOPnhCb.js.gz +0 -0
  44. package/dist/_frontend/assets/{htmlMode-CDsupPvj.js → htmlMode-BW7taYty.js} +1 -1
  45. package/dist/_frontend/assets/htmlMode-BW7taYty.js.br +0 -0
  46. package/dist/_frontend/assets/htmlMode-BW7taYty.js.gz +0 -0
  47. package/dist/_frontend/assets/{index-B8NomNE2.js → index-ChCGltYc.js} +242 -232
  48. package/dist/_frontend/assets/index-ChCGltYc.js.br +0 -0
  49. package/dist/_frontend/assets/index-ChCGltYc.js.gz +0 -0
  50. package/dist/_frontend/assets/{index-CKMEtdQA.js → index-DFQqb6R1.js} +3 -3
  51. package/dist/_frontend/assets/index-DFQqb6R1.js.br +0 -0
  52. package/dist/_frontend/assets/index-DFQqb6R1.js.gz +0 -0
  53. package/dist/_frontend/assets/{javascript-CPSnXnaS.js → javascript-CPINtbIt.js} +1 -1
  54. package/dist/_frontend/assets/{jsonMode-DRy4DQT3.js → jsonMode-C8qDzOfb.js} +1 -1
  55. package/dist/_frontend/assets/jsonMode-C8qDzOfb.js.br +0 -0
  56. package/dist/_frontend/assets/jsonMode-C8qDzOfb.js.gz +0 -0
  57. package/dist/_frontend/assets/{liquid-a-xIf2lN.js → liquid-zGC9H1Dt.js} +1 -1
  58. package/dist/_frontend/assets/liquid-zGC9H1Dt.js.br +0 -0
  59. package/dist/_frontend/assets/liquid-zGC9H1Dt.js.gz +0 -0
  60. package/dist/_frontend/assets/{lspLanguageFeatures-Tavpp1a0.js → lspLanguageFeatures-B6VPH2Sv.js} +1 -1
  61. package/dist/_frontend/assets/lspLanguageFeatures-B6VPH2Sv.js.br +0 -0
  62. package/dist/_frontend/assets/lspLanguageFeatures-B6VPH2Sv.js.gz +0 -0
  63. package/dist/_frontend/assets/{mdx-D3wOHh0p.js → mdx-BrQrGCP9.js} +1 -1
  64. package/dist/_frontend/assets/mdx-BrQrGCP9.js.br +0 -0
  65. package/dist/_frontend/assets/mdx-BrQrGCP9.js.gz +0 -0
  66. package/dist/_frontend/assets/{python-8zlVof3q.js → python-zKGpYLwR.js} +1 -1
  67. package/dist/_frontend/assets/python-zKGpYLwR.js.br +0 -0
  68. package/dist/_frontend/assets/python-zKGpYLwR.js.gz +0 -0
  69. package/dist/_frontend/assets/{razor-q_HfjjpC.js → razor-BJ38lYsd.js} +1 -1
  70. package/dist/_frontend/assets/razor-BJ38lYsd.js.br +0 -0
  71. package/dist/_frontend/assets/razor-BJ38lYsd.js.gz +0 -0
  72. package/dist/_frontend/assets/{tsMode-DOOZolwq.js → tsMode-dPLqGMg8.js} +1 -1
  73. package/dist/_frontend/assets/tsMode-dPLqGMg8.js.br +0 -0
  74. package/dist/_frontend/assets/tsMode-dPLqGMg8.js.gz +0 -0
  75. package/dist/_frontend/assets/{typescript-CmhvHmNu.js → typescript-BJlivWry.js} +1 -1
  76. package/dist/_frontend/assets/typescript-BJlivWry.js.br +0 -0
  77. package/dist/_frontend/assets/typescript-BJlivWry.js.gz +0 -0
  78. package/dist/_frontend/assets/{workers-CfU2h0GU.js → workers-fMwav4jB.js} +1 -1
  79. package/dist/_frontend/assets/workers-fMwav4jB.js.br +0 -0
  80. package/dist/_frontend/assets/workers-fMwav4jB.js.gz +0 -0
  81. package/dist/_frontend/assets/{xml-D3jhgOra.js → xml-DZW470wi.js} +1 -1
  82. package/dist/_frontend/assets/xml-DZW470wi.js.br +0 -0
  83. package/dist/_frontend/assets/xml-DZW470wi.js.gz +0 -0
  84. package/dist/_frontend/assets/{yaml-B-q42846.js → yaml-Bs1DumYp.js} +1 -1
  85. package/dist/_frontend/assets/yaml-Bs1DumYp.js.br +0 -0
  86. package/dist/_frontend/assets/yaml-Bs1DumYp.js.gz +0 -0
  87. package/dist/_frontend/index.html +1 -1
  88. package/dist/_frontend/index.html.br +0 -0
  89. package/dist/_frontend/index.html.gz +0 -0
  90. package/dist/main.js +120 -79
  91. package/dist/main.js.map +1 -1
  92. package/dist/postgres/migrations/20260815_000002_mcp_server_description.js +23 -0
  93. package/dist/postgres/migrations/20260815_000002_mcp_server_description.js.map +1 -0
  94. package/dist/sqlite/migrations/20260815_000002_mcp_server_description.js +21 -0
  95. package/dist/sqlite/migrations/20260815_000002_mcp_server_description.js.map +1 -0
  96. package/package.json +2 -2
  97. package/dist/_frontend/assets/ConnectorSettings-CLBEWGQJ-BjMXOS3R.js +0 -1
  98. package/dist/_frontend/assets/ConnectorSettings-CLBEWGQJ-BjMXOS3R.js.br +0 -0
  99. package/dist/_frontend/assets/ConnectorSettings-CLBEWGQJ-BjMXOS3R.js.gz +0 -0
  100. package/dist/_frontend/assets/DrawerLayout-X2UXYTOS-D60ziyi9.js.br +0 -0
  101. package/dist/_frontend/assets/DrawerLayout-X2UXYTOS-D60ziyi9.js.gz +0 -0
  102. package/dist/_frontend/assets/ModelSettings-IJ55QJQO-BFV2nfxB.js +0 -1
  103. package/dist/_frontend/assets/ModelSettings-IJ55QJQO-BFV2nfxB.js.br +0 -0
  104. package/dist/_frontend/assets/ModelSettings-IJ55QJQO-BFV2nfxB.js.gz +0 -0
  105. package/dist/_frontend/assets/SandboxSettings-S5XGZWOL-BUQpWdqg.js +0 -1
  106. package/dist/_frontend/assets/SandboxSettings-S5XGZWOL-BUQpWdqg.js.br +0 -0
  107. package/dist/_frontend/assets/SandboxSettings-S5XGZWOL-BUQpWdqg.js.gz +0 -0
  108. package/dist/_frontend/assets/SettingsBuilder-64Y33NP3-BQNwNwxh.js +0 -2
  109. package/dist/_frontend/assets/SettingsBuilder-64Y33NP3-BQNwNwxh.js.br +0 -0
  110. package/dist/_frontend/assets/SettingsBuilder-64Y33NP3-BQNwNwxh.js.gz +0 -0
  111. package/dist/_frontend/assets/SidebarLayout-M7HEOZVK-owseAySg.js.br +0 -0
  112. package/dist/_frontend/assets/SidebarLayout-M7HEOZVK-owseAySg.js.gz +0 -0
  113. package/dist/_frontend/assets/SkillSettings-MXK4ZEI7-CrK7D1D-.js.br +0 -0
  114. package/dist/_frontend/assets/SkillSettings-MXK4ZEI7-CrK7D1D-.js.gz +0 -0
  115. package/dist/_frontend/assets/WidgetLayout-7MDOKLHU-OdQcbsJk.js.br +0 -0
  116. package/dist/_frontend/assets/WidgetLayout-7MDOKLHU-OdQcbsJk.js.gz +0 -0
  117. package/dist/_frontend/assets/chunk-NBMP2XNL-DdVXEaJy.js.br +0 -2
  118. package/dist/_frontend/assets/chunk-NBMP2XNL-DdVXEaJy.js.gz +0 -0
  119. package/dist/_frontend/assets/chunk-WFC3W4C3-DXFwnpmH.js.br +0 -0
  120. package/dist/_frontend/assets/chunk-WFC3W4C3-DXFwnpmH.js.gz +0 -0
  121. package/dist/_frontend/assets/cssMode-BIIwADkQ.js.br +0 -0
  122. package/dist/_frontend/assets/cssMode-BIIwADkQ.js.gz +0 -0
  123. package/dist/_frontend/assets/freemarker2-DWtRl63b.js.br +0 -0
  124. package/dist/_frontend/assets/freemarker2-DWtRl63b.js.gz +0 -0
  125. package/dist/_frontend/assets/handlebars-CJJYL_TE.js.br +0 -0
  126. package/dist/_frontend/assets/handlebars-CJJYL_TE.js.gz +0 -0
  127. package/dist/_frontend/assets/html-CIyPQjdd.js.br +0 -0
  128. package/dist/_frontend/assets/html-CIyPQjdd.js.gz +0 -0
  129. package/dist/_frontend/assets/htmlMode-CDsupPvj.js.br +0 -0
  130. package/dist/_frontend/assets/htmlMode-CDsupPvj.js.gz +0 -0
  131. package/dist/_frontend/assets/index-B8NomNE2.js.br +0 -0
  132. package/dist/_frontend/assets/index-B8NomNE2.js.gz +0 -0
  133. package/dist/_frontend/assets/index-CKMEtdQA.js.br +0 -0
  134. package/dist/_frontend/assets/index-CKMEtdQA.js.gz +0 -0
  135. package/dist/_frontend/assets/jsonMode-DRy4DQT3.js.br +0 -0
  136. package/dist/_frontend/assets/jsonMode-DRy4DQT3.js.gz +0 -0
  137. package/dist/_frontend/assets/liquid-a-xIf2lN.js.br +0 -0
  138. package/dist/_frontend/assets/liquid-a-xIf2lN.js.gz +0 -0
  139. package/dist/_frontend/assets/lspLanguageFeatures-Tavpp1a0.js.br +0 -0
  140. package/dist/_frontend/assets/lspLanguageFeatures-Tavpp1a0.js.gz +0 -0
  141. package/dist/_frontend/assets/mdx-D3wOHh0p.js.br +0 -0
  142. package/dist/_frontend/assets/mdx-D3wOHh0p.js.gz +0 -0
  143. package/dist/_frontend/assets/python-8zlVof3q.js.br +0 -0
  144. package/dist/_frontend/assets/python-8zlVof3q.js.gz +0 -0
  145. package/dist/_frontend/assets/razor-q_HfjjpC.js.br +0 -0
  146. package/dist/_frontend/assets/razor-q_HfjjpC.js.gz +0 -0
  147. package/dist/_frontend/assets/tsMode-DOOZolwq.js.br +0 -0
  148. package/dist/_frontend/assets/tsMode-DOOZolwq.js.gz +0 -0
  149. package/dist/_frontend/assets/typescript-CmhvHmNu.js.br +0 -0
  150. package/dist/_frontend/assets/typescript-CmhvHmNu.js.gz +0 -0
  151. package/dist/_frontend/assets/workers-CfU2h0GU.js.br +0 -0
  152. package/dist/_frontend/assets/workers-CfU2h0GU.js.gz +0 -0
  153. package/dist/_frontend/assets/xml-D3jhgOra.js.br +0 -0
  154. package/dist/_frontend/assets/xml-D3jhgOra.js.gz +0 -0
  155. package/dist/_frontend/assets/yaml-B-q42846.js.br +0 -0
  156. package/dist/_frontend/assets/yaml-B-q42846.js.gz +0 -0
@@ -0,0 +1,23 @@
1
+ // src/db/postgres/migrations/20260815_000002_mcp_server_description.ts
2
+ import { sql } from "kysely";
3
+ async function up(db) {
4
+ await sql`SET LOCAL lock_timeout = '5s'`.execute(db);
5
+ await sql`
6
+ UPDATE mcp_server
7
+ SET manifest = manifest || jsonb_build_object('description', name || ' MCP Server')
8
+ WHERE btrim(coalesce(manifest->>'description', '')) = ''
9
+ `.execute(db);
10
+ }
11
+ async function down(db) {
12
+ await sql`SET LOCAL lock_timeout = '5s'`.execute(db);
13
+ await sql`
14
+ UPDATE mcp_server
15
+ SET manifest = manifest - 'description'
16
+ WHERE manifest->>'description' = name || ' MCP Server'
17
+ `.execute(db);
18
+ }
19
+ export {
20
+ down,
21
+ up
22
+ };
23
+ //# sourceMappingURL=20260815_000002_mcp_server_description.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/db/postgres/migrations/20260815_000002_mcp_server_description.ts"],"sourcesContent":["import { sql, type Kysely } from 'kysely';\n\n/**\n * Required `description` on `mcp_server.manifest`. Backfill `{name} MCP Server`\n * when the key is missing or blank so existing rows satisfy McpServerManifestSchema.\n */\nexport async function up(db: Kysely<unknown>): Promise<void> {\n await sql`SET LOCAL lock_timeout = '5s'`.execute(db);\n await sql`\n UPDATE mcp_server\n SET manifest = manifest || jsonb_build_object('description', name || ' MCP Server')\n WHERE btrim(coalesce(manifest->>'description', '')) = ''\n `.execute(db);\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await sql`SET LOCAL lock_timeout = '5s'`.execute(db);\n await sql`\n UPDATE mcp_server\n SET manifest = manifest - 'description'\n WHERE manifest->>'description' = name || ' MCP Server'\n `.execute(db);\n}\n"],"mappings":";AAAA,SAAS,WAAwB;AAMjC,eAAsB,GAAG,IAAoC;AAC3D,QAAM,mCAAmC,QAAQ,EAAE;AACnD,QAAM;AAAA;AAAA;AAAA;AAAA,IAIJ,QAAQ,EAAE;AACd;AAEA,eAAsB,KAAK,IAAoC;AAC7D,QAAM,mCAAmC,QAAQ,EAAE;AACnD,QAAM;AAAA;AAAA;AAAA;AAAA,IAIJ,QAAQ,EAAE;AACd;","names":[]}
@@ -0,0 +1,21 @@
1
+ // src/db/sqlite/migrations/20260815_000002_mcp_server_description.ts
2
+ import { sql } from "kysely";
3
+ async function up(db) {
4
+ await sql`
5
+ UPDATE mcp_server
6
+ SET manifest = jsonb_set(manifest, '$.description', jsonb(json_quote(name || ' MCP Server')))
7
+ WHERE trim(coalesce(json_extract(manifest, '$.description'), '')) = ''
8
+ `.execute(db);
9
+ }
10
+ async function down(db) {
11
+ await sql`
12
+ UPDATE mcp_server
13
+ SET manifest = jsonb_remove(manifest, '$.description')
14
+ WHERE json_extract(manifest, '$.description') = name || ' MCP Server'
15
+ `.execute(db);
16
+ }
17
+ export {
18
+ down,
19
+ up
20
+ };
21
+ //# sourceMappingURL=20260815_000002_mcp_server_description.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/db/sqlite/migrations/20260815_000002_mcp_server_description.ts"],"sourcesContent":["import { type Kysely, sql } from 'kysely';\n\n/**\n * Required `description` on `mcp_server.manifest`. Backfill `{name} MCP Server`\n * when the key is missing or blank so existing rows satisfy McpServerManifestSchema.\n * Mirrors db/postgres/migrations/20260815_000002_mcp_server_description.ts.\n */\nexport async function up(db: Kysely<unknown>): Promise<void> {\n await sql`\n UPDATE mcp_server\n SET manifest = jsonb_set(manifest, '$.description', jsonb(json_quote(name || ' MCP Server')))\n WHERE trim(coalesce(json_extract(manifest, '$.description'), '')) = ''\n `.execute(db);\n}\n\nexport async function down(db: Kysely<unknown>): Promise<void> {\n await sql`\n UPDATE mcp_server\n SET manifest = jsonb_remove(manifest, '$.description')\n WHERE json_extract(manifest, '$.description') = name || ' MCP Server'\n `.execute(db);\n}\n"],"mappings":";AAAA,SAAsB,WAAW;AAOjC,eAAsB,GAAG,IAAoC;AAC3D,QAAM;AAAA;AAAA;AAAA;AAAA,IAIJ,QAAQ,EAAE;AACd;AAEA,eAAsB,KAAK,IAAoC;AAC7D,QAAM;AAAA;AAAA;AAAA;AAAA,IAIJ,QAAQ,EAAE;AACd;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truefoundry/trueforge",
3
- "version": "0.1.0-rc.0",
3
+ "version": "0.1.0",
4
4
  "description": "TrueForge agent server + UI (npx @truefoundry/trueforge)",
5
5
  "author": "TrueFoundry",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "winston": "^3.13.0",
41
41
  "yaml": "^2.9.0",
42
42
  "zod": "^4.4.3",
43
- "@truefoundry/trueforge-core": "0.1.0-rc.0"
43
+ "@truefoundry/trueforge-core": "0.1.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@swc/core": "^1.11.0",
@@ -1 +0,0 @@
1
- import{p as G,q as ie,r,s as H,j as e,t as oe,B as k,I as N,w as J,z as X,D as ce,e as B,v as Y}from"./index-B8NomNE2.js";var me=[{value:"dcr",label:"OAuth"},{value:"none",label:"None"},{value:"header",label:"API Key"}],q=X("h-11 shadow-sm"),$=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),ue=({open:n,onOpenChange:x,onAdd:m,busy:j=!1,error:i})=>{const[f,y]=r.useState(""),[p,h]=r.useState(""),[c,w]=r.useState("dcr"),[u,b]=r.useState(""),[v,A]=r.useState(""),z=()=>{y(""),h(""),w("dcr"),b(""),A("")},M=l=>{l||z(),x(l)},S=!!f.trim()&&!!p.trim()&&(c!=="header"||!!u.trim()),a=async l=>{if(l.preventDefault(),!S||j)return;const F=c==="header"?{type:"header",apiKey:u.trim(),...v.trim()?{headerName:v.trim()}:{}}:{type:c};try{await m({name:f.trim(),url:p.trim(),auth:F}),z(),x(!1)}catch{}};return e.jsx(J,{open:n,onOpenChange:M,title:"Add MCP server",description:"Point at a remote MCP endpoint. It then behaves like any other connector.",contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(N,{name:"mcp-server",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:l=>void a(l),children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx($,{})]}),e.jsx("input",{id:"mcp-server-name",type:"text",required:!0,value:f,onChange:l=>{y(l.target.value)},placeholder:"analytics-postgres-mcp",autoFocus:!0,className:q})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["URL",e.jsx($,{})]}),e.jsx("input",{id:"mcp-server-url",type:"url",required:!0,value:p,onChange:l=>{h(l.target.value)},placeholder:"https://mcp.example.com/mcp",className:q})]}),e.jsxs("fieldset",{children:[e.jsxs("legend",{className:"mb-1.5 text-sm font-medium text-text-primary",children:["Auth type",e.jsx($,{})]}),e.jsx("div",{className:"flex w-full flex-row rounded-md border border-border bg-secondary-bg/40 p-1",children:me.map(l=>e.jsxs("label",{className:`flex h-8 flex-1 cursor-pointer items-center justify-center rounded-sm text-sm font-medium transition-colors ${c===l.value?"bg-dropdown-selected-item-bg text-dropdown-selected-item-text shadow-sm":"text-text-secondary hover:text-text-primary"}`,children:[e.jsx("input",{type:"radio",name:"mcp-auth-type",value:l.value,checked:c===l.value,onChange:()=>{w(l.value)},className:"sr-only"}),l.label]},l.value))})]}),c==="dcr"?e.jsxs("div",{className:"flex gap-1.5 bg-secondary-bg/40 p-2 rounded-md",children:[e.jsx(N,{name:"info",className:"size-3.5 mt-1 text-text-secondary"}),e.jsx("div",{className:"text-xs text-text-secondary leading-5.5",children:"Sign-in only — the server must support dynamic client registration. Manual OAuth (client ID / secret) isn't supported yet."})]}):null,c==="header"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",e.jsx($,{})]}),e.jsx("input",{id:"mcp-server-api-key",type:"password",required:!0,value:u,onChange:l=>{b(l.target.value)},placeholder:"Paste the server token",className:q})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"mcp-server-header-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Header name ",e.jsx("span",{className:"font-normal text-text-secondary",children:"(optional)"})]}),e.jsx("input",{id:"mcp-server-header-name",type:"text",value:v,onChange:l=>{A(l.target.value)},placeholder:"Authorization",className:q})]})]}):null]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[i?e.jsx("p",{className:"text-failure-bg text-sm",children:i}):null,e.jsx(k,{type:"submit",size:"lg",disabled:!S||j,className:"w-full shrink-0",children:"Add"})]})]})})},xe=ue,_={dcr:"OAuth2",header:"API Key",none:"No Auth"};function he({text:n}){const x=r.useRef(null),[m,j]=r.useState(!1),[i,f]=r.useState(!1),[y,p]=r.useState(16);return r.useLayoutEffect(()=>{j(!1),p(16)},[n]),r.useLayoutEffect(()=>{const h=x.current;if(!h)return;if(!m){p(16),f(h.scrollWidth>h.clientWidth+1);return}p(16);const c=requestAnimationFrame(()=>{p(h.scrollHeight)});return()=>cancelAnimationFrame(c)},[n,m]),n?e.jsxs("div",{className:"relative min-w-0",children:[e.jsxs("p",{ref:x,style:{maxHeight:y},className:B("mt-0.5 overflow-hidden font-mono text-xs leading-4 text-text-secondary transition-[max-height] duration-300 ease-in-out",!m&&"whitespace-nowrap",!m&&i&&"pr-[5.75rem]"),children:[n,m&&i?e.jsxs(e.Fragment,{children:[" ",e.jsx("button",{type:"button",className:"cursor-pointer font-mono text-xs font-medium text-text-primary/80 hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring","aria-expanded":!0,onClick:()=>j(!1),children:"Show less"})]}):null]}),!m&&i?e.jsxs("button",{type:"button",className:"absolute top-0.5 right-0 cursor-pointer bg-card-bg pl-1.5 font-mono text-xs font-medium leading-4 text-text-primary/80 hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring","aria-expanded":!1,onClick:()=>j(!0),children:[e.jsx("span",{"aria-hidden":!0,className:"text-text-secondary",children:"…"}),e.jsx("span",{className:"ml-1",children:"Read more"})]}):null]}):null}var pe=({connector:n,onBack:x,onConnectorRefreshed:m,onDisconnect:j,busy:i=!1})=>{const{connectorCatalog:f}=G(),{handleAuthorize:y,isOAuthLoading:p}=ce(),[h,c]=r.useState([]),[w,u]=r.useState(!0),[b,v]=r.useState(null),[A,z]=r.useState(!1);r.useEffect(()=>{let a=!1;return c([]),v(null),u(!0),f.getToolsByConnectorId({id:n.id}).then(l=>{a||c(l)}).catch(l=>{a||v(H(l,"Failed to load connector tools"))}).finally(()=>{a||u(!1)}),()=>{a=!0}},[n.authenticated,n.id,f]);const M=async()=>{z(!0),v(null);try{const a=await f.getConnector({id:n.id});m(a)}catch(a){v(H(a,"Failed to refresh connector details"))}finally{z(!1)}},S=p||A;return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:x,className:"mb-3 inline-flex w-fit items-center gap-1 rounded-md py-1 pr-2 text-sm text-text-secondary hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",children:[e.jsx(N,{name:"chevron-left",className:"size-3.5"}),"Connectors"]}),e.jsxs("div",{className:"flex flex-1 flex-col overflow-y-auto pb-1",children:[e.jsxs("header",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(N,{name:"mcp-server",className:"size-5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"text-lg font-semibold text-text-primary",children:n.name}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",children:[e.jsxs("span",{className:B("flex items-center gap-1.5 text-xs font-medium",n.authenticated?"text-success-bg":"text-text-primary"),children:[e.jsx("span",{className:B("h-1.5 w-1.5 rounded-full",n.authenticated?"bg-success-bg":"bg-primary-button-bg")}),n.authenticated?"Connected":"Not authenticated"]}),e.jsxs("span",{className:"text-text-secondary",children:["· ",n.description]})]}),e.jsx("span",{className:"mt-2 inline-flex items-center rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-text-secondary",children:_[n.auth.type]??_.none})]}),n.auth.type==="dcr"&&!n.authenticated?e.jsx(k,{variant:"outline",size:"sm",type:"button",disabled:i||S,onClick:()=>{y(n.id,a=>{a&&M()})},children:S?"Connecting…":"Connect"}):n.auth.type==="dcr"&&!n.requiresAuth?e.jsx(k,{variant:"outline",size:"sm",type:"button",disabled:i,onClick:j,children:"Disconnect"}):null]}),e.jsx("section",{className:"mt-6","aria-labelledby":"connector-tools-heading",children:w?e.jsx("div",{className:"rounded-xl border border-dashed border-border p-6 text-center text-sm text-text-secondary",children:"Loading tools…"}):b?e.jsxs("div",{className:"rounded-xl border border-failure-bg/30 bg-failure-bg/10 p-6 text-center text-sm text-failure-bg",children:[b,n.auth.type==="dcr"&&!n.authenticated&&e.jsx("div",{className:"font-bold mt-1",children:"Click Connect and authenticate successfully to view tools."})]}):h.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("h5",{id:"connector-tools-heading",className:"mb-2 text-[0.8125rem] font-semibold text-text-primary",children:["Tools ",e.jsxs("span",{className:"font-normal text-text-secondary",children:["· ",h.length]})]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:h.map(a=>e.jsx("article",{className:"flex min-h-12 items-start gap-3 border-b border-border px-3 py-2 last:border-b-0",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h6",{className:"text-sm font-medium text-text-primary",children:a.name}),e.jsx(he,{text:a.description})]})},a.id))})]}):e.jsx("div",{className:"rounded-xl border border-dashed border-border p-6 text-center text-sm text-text-secondary",children:"No tools reported for this connector."})})]})]})},fe=pe,be=()=>{const{connectorCatalog:n}=G(),x=ie(),[m,j]=r.useState(""),[i,f]=r.useState({ordered:[],authStatusById:new Map}),[y,p]=r.useState(!0),[h,c]=r.useState(null),[w,u]=r.useState(null),[b,v]=r.useState(!1),[A,z]=r.useState([]),[M,S]=r.useState(!1),[a,l]=r.useState(null),[F,I]=r.useState(null),[L,P]=r.useState(""),Q=r.useMemo(()=>(A??[]).reduce((t,s)=>(t[s.name]=s.logo??"",t),{}),[A]),K=r.useCallback(async()=>{p(!0),c(null);try{const[t,s]=await Promise.all([n.listConnectors(),n.getConnectorCatalog()]);z(s);const d=t??[],g=new Set(d.map(o=>o.id)),C=[...d.map(o=>({connector:o,isConfigured:!0})),...s.filter(o=>!g.has(o.id)).map(o=>({connector:o,isConfigured:!1}))];f({ordered:C,authStatusById:new Map(C.map(o=>[o.connector.id,o.isConfigured?o.connector.authenticated:!1]))}),I(o=>o?t.find(de=>de.id===o.id)??null:null)}catch(t){c(H(t,"Failed to load connectors"))}finally{p(!1)}},[n]);r.useEffect(()=>{K()},[K]);const E=m.trim().toLowerCase(),R=r.useMemo(()=>E?i.ordered.filter(({connector:t})=>{var s;return t.name.toLowerCase().includes(E)||(((s=t.description)==null?void 0:s.toLowerCase().includes(E))??!1)||t.url.toLowerCase().includes(E)}):i.ordered,[i.ordered,E]),T=r.useMemo(()=>{const t=[];for(const s of R)if(s.isConfigured){const d=i.authStatusById.get(s.connector.id)??s.connector.authenticated;t.push(d===s.connector.authenticated?s.connector:{...s.connector,authenticated:d})}return t},[i.authStatusById,R]),D=r.useMemo(()=>{const t=[];for(const s of R)s.isConfigured||t.push(s.connector);return t},[R]),O=async(t,s=c)=>{v(!0),c(null);try{await t(),await K()}catch(d){throw s(H(d,"Request failed")),d}finally{v(!1)}},U=()=>{l(null),P(""),u(null)},W=async(t,s)=>{const d=s??(t.auth.type==="header"?{type:"header",...t.auth.headerName?{headerName:t.auth.headerName}:{}}:t.auth.type==="dcr"?{type:"dcr"}:{type:"none"});await n.createConnector({name:t.name,url:t.url,auth:d})},Z=t=>{if(t.auth.type==="header"){P(""),u(null),l(t);return}O(async()=>{await W(t)}).catch(()=>{})},ee=t=>{if(t.preventDefault(),!a||!L.trim())return;const s=a;u(null),O(async()=>{const d={type:"header",apiKey:L.trim(),...s.auth.type==="header"&&s.auth.headerName?{headerName:s.auth.headerName}:{}},g=i.ordered.find(({connector:o})=>o.id===s.id),C=g!=null&&g.isConfigured?g.connector:void 0;C?await n.updateConnector({id:C.id,name:C.name,url:C.url,auth:d}):await W(s,d),U(),setTimeout(()=>{x==null||x.showSuccess({title:`${s.name} ${C?"updated":"connected"}`})},100)},u).catch(()=>{})},te=async t=>{u(null),await O(async()=>{await n.createConnector({name:t.name,url:t.url,auth:t.auth})},u),setTimeout(()=>{x==null||x.showSuccess({title:`${t.name} added`})},0)},se=t=>{O(async()=>{await n.disconnectConnector({id:t.id}),I(null)}).catch(()=>{})},ae=t=>{I(s=>(s==null?void 0:s.id)===t.id?t:s),f(s=>{const d=new Map(s.authStatusById);return d.set(t.id,t.authenticated),{ordered:s.ordered.map(g=>g.isConfigured&&g.connector.id===t.id?{connector:t,isConfigured:!0}:g),authStatusById:d}})},re=(t,s)=>{const d=Q[t.name],g=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:d?e.jsx(Y,{src:d,alt:t.name,className:"size-4.5"}):e.jsx(N,{name:"mcp-server",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate",children:t.description})]})]});return e.jsxs("article",{className:"flex min-h-16 w-full items-center gap-3 border-b border-border p-3 text-left last:border-b-0 cursor-pointer transition-colors hover:bg-ghost-button-hover/60",onClick:()=>{I(t)},children:[e.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:g}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:B("flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium",t.authenticated?"text-success-bg":"text-text-primary"),children:[e.jsx("span",{className:B("h-1.5 w-1.5 rounded-full",t.authenticated?"bg-success-bg":"bg-primary-button-bg")}),t.authenticated?"Connected":"Added"]})}),t.auth.type==="header"?e.jsxs(k,{variant:"secondary",size:"sm",type:"button",disabled:b,onClick:o=>{o.stopPropagation(),P(""),l(t)},children:[e.jsx(N,{name:"wrench",className:"size-3"}),"Replace Key"]}):null,e.jsx(N,{name:"chevron-right",className:"size-4"})]})]},t.id)},ne=t=>{const s=Q[t.name];return e.jsxs("article",{className:"flex min-h-16 w-full items-center gap-3 border-b border-border p-3 text-left last:border-b-0",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary-bg","aria-hidden":!0,children:s?e.jsx(Y,{src:s,alt:t.name,className:"size-4.5"}):e.jsx(N,{name:"mcp-server",className:"size-4.5 text-text-primary"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"mt-0.5 line-clamp-2 text-sm text-text-secondary sm:truncate",children:t.description??t.url})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx("span",{className:"hidden text-xs text-text-secondary sm:inline",children:_[t.auth.type]??_.none}),e.jsx(k,{variant:"secondary",size:"sm",type:"button",disabled:b,onClick:()=>{Z(t)},children:t.auth.type==="dcr"?"Add":"Connect"})]})]},t.id)},V=r.useMemo(()=>a!==null&&i.ordered.some(t=>t.isConfigured&&t.connector.id===a.id),[a,i.ordered]);if(F)return e.jsx(fe,{connector:F,busy:b,onBack:()=>{I(null)},onConnectorRefreshed:ae,onDisconnect:()=>{se(F)}});const le=T.length>0||D.length>0;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Connectors"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect tools your agents can use."}),h?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:h}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(oe,{query:m,setQuery:j,placeholder:"Search connectors"})}),e.jsxs(k,{variant:"secondary",type:"button",onClick:()=>{u(null),S(!0)},children:[e.jsx(N,{name:"plus",size:"1rem",className:"mr-1"}),"Add MCP Server"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto pb-1",children:[y?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!y&&T.length>0?e.jsxs("section",{"aria-labelledby":"connected-connectors-heading",children:[e.jsxs("h4",{id:"connected-connectors-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Configured · ",T.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:T.map(t=>re(t))})]}):null,!y&&D.length>0?e.jsxs("section",{"aria-labelledby":"available-connectors-heading",children:[e.jsxs("h4",{id:"available-connectors-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:["Available · ",D.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:D.map(t=>ne(t))})]}):null,!y&&!le?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:m.trim()?`No connectors match “${m.trim()}”.`:"No connectors yet."}):null]}),e.jsx(J,{open:a!==null,onOpenChange:t=>{t||U()},title:`${V?"Replace key for":"Connect"} ${(a==null?void 0:a.name)??"connector"}`,description:a==null?void 0:a.url,contentSized:!0,className:"md:max-w-xl",children:e.jsxs("form",{onSubmit:ee,children:[e.jsxs("div",{className:"space-y-5 px-5 py-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-xl border border-border bg-secondary-bg","aria-hidden":!0,children:e.jsx(N,{name:"mcp-server",className:"size-6 text-text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-text-primary",children:a==null?void 0:a.name}),e.jsx("p",{className:"truncate text-sm text-text-secondary",children:a==null?void 0:a.description})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"connector-api-key",className:"mb-2 block text-xs font-semibold uppercase tracking-wide text-text-secondary",children:"API key / token"}),e.jsx("input",{id:"connector-api-key",type:"password",value:L,onChange:t=>{P(t.target.value)},placeholder:`Paste the token from ${(a==null?void 0:a.name)??"the provider"}`,autoFocus:!0,required:!0,className:X("h-11")})]}),w?e.jsx("p",{className:"text-failure-bg text-sm",children:w}):null]}),e.jsxs("footer",{className:"flex justify-end gap-2 border-t border-border px-5 py-4",children:[e.jsx(k,{variant:"ghost",type:"button",onClick:U,disabled:b,children:"Cancel"}),e.jsx(k,{type:"submit",disabled:!L.trim()||b,children:V?"Replace Key":"Connect"})]})]})}),e.jsx(xe,{open:M,onOpenChange:t=>{S(t),t||u(null)},onAdd:te,busy:b,error:w})]})})]})},ye=be;export{ye as default};
@@ -1 +0,0 @@
1
- import{p as be,q as fe,r as o,s as Y,j as e,t as ge,B,I as L,v as ie,w as xe,A as ye,x as ve,e as P,y as je,z as Ne}from"./index-B8NomNE2.js";var me=Ne("h-11 shadow-sm"),we=({open:n,onOpenChange:l,onSave:b,title:k,description:p,initialBaseUrl:E="",baseUrlPlaceholder:d="https://api.openai.com/v1",requireApiKey:c=!0,submitLabel:S="Save",busy:O=!1,error:F})=>{const[M,$]=o.useState(""),[y,x]=o.useState(""),[w,A]=o.useState(!1),U=()=>{$(""),x(""),A(!1)};o.useEffect(()=>{n&&($(""),x(E),A(!1))},[n,E]);const X=i=>{i||U(),l(i)},T=M.trim(),G=!c||!!T,v=async i=>{if(i.preventDefault(),!(!G||O))try{await b({apiKey:T,baseUrl:y.trim()}),U(),l(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:X,title:k,description:p,contentSized:!0,children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:v,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"model-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",c?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"model-provider-api-key",type:"password",required:c,value:M,onChange:i=>{$(i.target.value)},placeholder:c?"Enter API key":"Enter a new key",autoFocus:!0,className:me}),c?null:e.jsx("p",{className:"mt-1.5 text-xs text-text-secondary",children:"Leave blank to keep the current key; enter a new one to replace it."})]}),e.jsxs(ye,{expanded:w,onChange:(i,K)=>A(K),className:"rounded-md border border-border",children:[e.jsx(ve,{className:"px-3 py-2.5",children:e.jsxs("span",{className:"flex w-full items-center justify-between text-sm font-medium text-text-primary",children:["Advanced · custom endpoint",e.jsx(L,{name:"chevron-down",className:P("size-4 shrink-0 text-text-secondary transition-transform duration-200",w?"rotate-0":"-rotate-90")})]})}),e.jsxs(je,{className:"space-y-1.5 border-t border-border px-3 pb-3 pt-4",children:[e.jsx("label",{htmlFor:"model-provider-base-url",className:"block text-sm font-medium text-text-primary",children:"Base URL"}),e.jsx("input",{id:"model-provider-base-url",type:"url",value:y,onChange:i=>{x(i.target.value)},placeholder:d,className:me}),e.jsx("p",{className:"text-xs text-text-secondary",children:"Leave blank unless you use a regional or proxy endpoint."})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[F?e.jsx("p",{className:"text-failure-bg text-sm",children:F}):null,e.jsx(B,{type:"submit",size:"lg",disabled:!G||O,className:"w-full shrink-0",children:S})]})]})})},Ce=we,ke="128000",Ee="4096",pe=()=>({id:"",name:"",advancedExpanded:!0,contextLength:"",maxOutputTokens:""}),ue=n=>(n==null?void 0:n.models.map(l=>{var b,k,p,E,d;return{id:l.id,name:l.name,advancedExpanded:!0,reasoningEfforts:(b=l.properties)==null?void 0:b.reasoningEfforts,contextLength:((p=(k=l.properties)==null?void 0:k.contextLength)==null?void 0:p.toString())??"",maxOutputTokens:((d=(E=l.properties)==null?void 0:E.maxOutputTokens)==null?void 0:d.toString())??"",nameDirty:!0}}))??[pe()],Q="h-11 w-full rounded-md border border-border/70 bg-secondary-bg px-3 text-sm text-text-primary outline-none transition-colors placeholder:text-text-secondary/70 focus-visible:border-focus-ring focus-visible:ring-2 focus-visible:ring-focus-ring/50",V="border-failure-bg focus-visible:border-failure-bg focus-visible:ring-failure-bg";function ce(n){const l=n.trim();if(l==="")return null;const b=Number(l);return Number.isInteger(b)&&b>0?b:null}function Se(n){return n.replace(/([a-zA-Z])(\d)/g,"$1-$2").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").slice(0,64).replace(/-+$/g,"")}var re=()=>e.jsx("span",{className:"ml-0.5 text-failure-bg","aria-hidden":!0,children:"*"}),ee=({children:n})=>e.jsx("p",{className:"mt-1 text-xs text-failure-bg",children:n}),ne=({children:n})=>e.jsx("p",{className:"mt-1 text-xs text-text-secondary",children:n}),Me=({open:n,onOpenChange:l,onSubmit:b,reasoningEffortOptions:k,busy:p=!1,error:E,isEditMode:d=!1,initialValues:c})=>{const[S,O]=o.useState((c==null?void 0:c.name)??""),[F,M]=o.useState((c==null?void 0:c.baseUrl)??""),[$,y]=o.useState(""),[x,w]=o.useState(()=>ue(c)),[A,U]=o.useState(!1),[X,T]=o.useState(!1),G=()=>{O((c==null?void 0:c.name)??""),M((c==null?void 0:c.baseUrl)??""),y(""),w(ue(c)),U(!1),T(!1)},v=s=>{s||G(),l(s)},i=(s,r)=>{w(g=>g.map((u,j)=>j===s?{...u,...r}:u))},K=()=>{U(!0),T(!0),w(s=>s.map(r=>({...r,idTouched:!0,contextTouched:!0,maxTouched:!0})))},f=S.trim(),D=f?null:"Name is required.",_=F.trim();let h=null;if(!_)h="Base URL is required.";else try{new URL(_)}catch{h="Enter a valid URL."}const W=s=>s.id.trim()?null:"Model ID is required.",te=s=>s.name.trim()?null:"Model name is required.",q=s=>ce(s.contextLength)==null?"Set the model's context window.":null,Z=s=>ce(s.maxOutputTokens)==null?"Set the max output tokens.":null,oe=!D&&!h&&x.every(s=>!W(s)&&!te(s)),se=A&&D,H=X&&h,I=async()=>{if(K(),!oe||p)return;const s=x.findIndex(r=>q(r)||Z(r));if(s!==-1){i(s,{advancedExpanded:!0});const r=x[s],g=r&&q(r)?"context-length":"max-output-tokens";setTimeout(()=>{var j;const u=document.getElementById(`custom-provider-model-${s}-${g}`);(j=u==null?void 0:u.scrollIntoView)==null||j.call(u,{block:"center",behavior:"smooth"}),u==null||u.focus()},0);return}try{await b({name:f,baseUrl:_,apiKey:$.trim(),models:x.map(r=>{var R;const g={};(R=r.reasoningEfforts)!=null&&R.length&&(g.reasoningEfforts=r.reasoningEfforts);const u=ce(r.contextLength);u!=null&&(g.contextLength=u);const j=ce(r.maxOutputTokens);return j!=null&&(g.maxOutputTokens=j),{id:r.id.trim(),name:r.name.trim(),...Object.keys(g).length>0?{properties:g}:{}}})}),v(!1)}catch{}};return e.jsx(xe,{open:n,onOpenChange:v,title:d?`Edit ${(c==null?void 0:c.name)??S}`:"Add custom provider",description:d?"Update the endpoint, credentials, and models for this provider.":"Connect any OpenAI-compatible endpoint, whether it's a local model, a proxy, or your own hosted service.",contentSized:!0,children:e.jsxs("form",{className:"flex min-h-0 flex-1 flex-col",onSubmit:s=>{s.preventDefault(),I()},children:[e.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-y-auto px-5 pt-4 pb-8",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-name",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Name",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-name",type:"text",value:S,onChange:s=>O(s.target.value),onBlur:()=>U(!0),placeholder:"local-llama",autoFocus:!d,readOnly:d,"aria-readonly":d,"aria-invalid":se?!0:void 0,className:P(Q,d&&"cursor-not-allowed bg-secondary-bg/60 text-text-secondary",se&&V)}),d?e.jsx(ne,{children:"Provider names cannot be changed after creation."}):null,se?e.jsx(ee,{children:D}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-base-url",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["Base URL",e.jsx(re,{})]}),e.jsx("input",{id:"custom-provider-base-url",type:"text",value:F,onChange:s=>M(s.target.value),onBlur:()=>T(!0),placeholder:"http://localhost:11434/v1",autoFocus:d,"aria-invalid":H?!0:void 0,className:P(Q,H&&V)}),H?e.jsx(ee,{children:h}):_?null:e.jsx(ne,{children:"OpenAI-compatible endpoint, usually ending in /v1."})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"custom-provider-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"custom-provider-api-key",type:"password",value:$,onChange:s=>y(s.target.value),placeholder:"sk-…",className:Q}),e.jsx(ne,{children:d?"Leave blank to keep the saved key, or enter a new key to replace it.":"Leave blank if your endpoint needs no key (e.g. a local model)."})]}),e.jsxs("fieldset",{className:"m-0 min-w-0 border-0 p-0",children:[e.jsxs("legend",{className:"float-left mb-2 w-full p-0 text-sm font-medium text-text-primary",children:["Models",e.jsx(re,{})]}),e.jsx("div",{className:"clear-both",children:x.map((s,r)=>{const g=W(s),u=s.idTouched&&g,j=te(s),R=!!j&&s.nameDirty,le=q(s),C=Z(s),z=s.contextTouched&&le,ae=s.maxTouched&&C;return e.jsxs("div",{className:P("pb-6",r>0?"border-t border-border pt-6":"pt-1"),style:r>0?{borderTopWidth:"0.5px"}:void 0,children:[e.jsxs("div",{className:"grid grid-cols-[1fr_1fr_2rem] items-end gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-id`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model ID"}),e.jsx("input",{id:`custom-provider-model-${r}-id`,type:"text",value:s.id,onChange:t=>{const a=t.target.value;i(r,{id:a,...s.nameDirty?{}:{name:Se(a)}})},onBlur:()=>i(r,{idTouched:!0}),placeholder:"llama3.1:70b","aria-invalid":u?!0:void 0,className:P(Q,"font-mono",u&&V)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("label",{htmlFor:`custom-provider-model-${r}-name`,className:"mb-1 block text-xs font-normal text-text-secondary",children:"Model name"}),e.jsx("input",{id:`custom-provider-model-${r}-name`,type:"text",value:s.name,onChange:t=>i(r,{name:t.target.value,nameDirty:!0}),placeholder:"llama-3-1-70b","aria-invalid":R?!0:void 0,className:P(Q,R&&V)})]}),e.jsx("button",{type:"button","aria-label":`Remove model ${r+1}`,disabled:x.length===1||p,className:"mb-0.5 flex size-9 items-center justify-center rounded-md text-text-secondary transition-colors hover:text-text-primary disabled:opacity-40",onClick:()=>w(t=>t.filter((a,m)=>m!==r)),children:e.jsx(L,{name:"trash",className:"size-4"})})]}),u?e.jsx(ee,{children:g}):null,R?e.jsx(ee,{children:j}):null,e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button","aria-expanded":s.advancedExpanded,"aria-controls":`custom-provider-model-${r}-advanced`,className:"flex cursor-pointer items-center gap-1.5 text-sm font-medium text-text-primary",onClick:()=>i(r,{advancedExpanded:!s.advancedExpanded}),children:[e.jsx(L,{name:"chevron-down",className:P("size-4 text-text-secondary transition-transform",s.advancedExpanded?"":"-rotate-90")}),"Advanced"]}),s.advancedExpanded?e.jsxs("div",{id:`custom-provider-model-${r}-advanced`,className:"mt-3 space-y-4 pl-6",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-context-length`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Context length",e.jsx(re,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-context-length`,type:"number",min:1,inputMode:"numeric",value:s.contextLength,onChange:t=>i(r,{contextLength:t.target.value}),onBlur:()=>i(r,{contextTouched:!0}),placeholder:ke,"aria-invalid":z?!0:void 0,className:P(Q,z&&V)}),z?e.jsx(ee,{children:le}):s.contextLength.trim()===""?e.jsx(ne,{children:"Prevents the context window from overflowing during a run."}):null]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:`custom-provider-model-${r}-max-output-tokens`,className:"mb-1.5 block text-xs font-medium text-text-secondary",children:["Max output tokens",e.jsx(re,{})]}),e.jsx("input",{id:`custom-provider-model-${r}-max-output-tokens`,type:"number",min:1,inputMode:"numeric",value:s.maxOutputTokens,onChange:t=>i(r,{maxOutputTokens:t.target.value}),onBlur:()=>i(r,{maxTouched:!0}),placeholder:Ee,"aria-invalid":ae?!0:void 0,className:P(Q,ae&&V)}),ae?e.jsx(ee,{children:C}):s.maxOutputTokens.trim()===""?e.jsx(ne,{children:"Caps tokens per model call."}):null]}),k&&k.length>0?e.jsxs("div",{children:[e.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 select-none",children:[e.jsx("input",{type:"checkbox",className:"size-4 shrink-0 cursor-pointer accent-primary-button-bg disabled:cursor-not-allowed disabled:opacity-50",checked:s.reasoningEfforts!==void 0,"aria-label":`Enable reasoning effort for model ${r+1}`,disabled:p,onChange:t=>i(r,{reasoningEfforts:t.target.checked?[]:void 0})}),e.jsx("span",{className:"text-text-secondary text-xs font-medium",children:"Reasoning effort"})]}),s.reasoningEfforts!==void 0?e.jsx("div",{role:"group","aria-label":`Supported reasoning efforts for model ${r+1}`,className:"mt-2 flex flex-wrap gap-2",children:k.map(t=>{var m;const a=((m=s.reasoningEfforts)==null?void 0:m.includes(t))??!1;return e.jsx("button",{type:"button","aria-pressed":a,disabled:p,className:P("rounded-full border px-3 py-1 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/40 disabled:opacity-50",a?"border-primary-button-bg bg-primary-button-bg text-primary-button-text":"border-border text-text-secondary hover:bg-ghost-button-hover"),onClick:()=>{var J;return i(r,{reasoningEfforts:a?(J=s.reasoningEfforts)==null?void 0:J.filter(de=>de!==t):[...s.reasoningEfforts??[],t]})},children:t},t)})}):null]}):null]}):null]})]},r)})}),e.jsxs(B,{variant:"secondary",size:"sm",type:"button",className:"mt-4 w-fit",onClick:()=>w(s=>[...s,pe()]),children:[e.jsx(L,{name:"plus",className:"size-3.5"}),"Add model"]})]})]}),e.jsxs("div",{className:"shrink-0 space-y-3 border-t border-border px-5 py-4",children:[E?e.jsx("p",{className:"text-failure-bg text-sm",children:E}):null,e.jsx(B,{type:"submit",size:"lg",disabled:!oe||p,className:"w-full",children:d?"Save changes":"Add provider"})]})]})})},Ue=Me;function Te(n){return"baseUrl"in n&&typeof n.baseUrl=="string"?n.baseUrl:""}var Pe=()=>{const{modelCatalog:n}=be(),l=fe(),[b,k]=o.useState(""),[p,E]=o.useState([]),[d,c]=o.useState([]),[S,O]=o.useState(!0),[F,M]=o.useState(null),[$,y]=o.useState(null),[x,w]=o.useState(!1),[A,U]=o.useState(null),[X,T]=o.useState(null),[G,v]=o.useState(null),[i,K]=o.useState(!1),[f,D]=o.useState(null),_=o.useMemo(()=>(d??[]).reduce((t,a)=>(t[a.name]=a.logo??"",t),{}),[d]),h=b.trim().toLowerCase(),W=o.useCallback(async()=>{O(!0),M(null);try{const[t,a]=await Promise.all([n.listModelProviders(),n.getModelProviderCatalog()]);E(t),c(a)}catch(t){M(Y(t,"Failed to load model providers"))}finally{O(!1)}},[n]);o.useEffect(()=>{W()},[W]);const te=o.useMemo(()=>new Set(p.map(t=>t.type)),[p]),q=o.useMemo(()=>p.filter(t=>{var a;return((a=t.name)==null?void 0:a.toLowerCase().includes(h))||t.models.some(m=>m.name.toLowerCase().includes(h)||m.id.toLowerCase().includes(h))}),[p,h]),Z=o.useMemo(()=>d.filter(t=>t.type!=="custom"&&!te.has(t.type)&&(t.name.toLowerCase().includes(h)||t.models.some(a=>a.name.toLowerCase().includes(h)||a.id.toLowerCase().includes(h)))),[d,te,h]),oe=o.useMemo(()=>{var t;return(t=d.find(a=>a.type==="custom"))==null?void 0:t.supportedReasoningEfforts},[d]),se=o.useMemo(()=>{const t=new Map;for(const a of d)t.set(a.type,a.models);return t},[d]),H=()=>{U(null),T(null),v(null)},I=async(t,a)=>{w(!0),M(null);try{await t(),await W(),H()}catch(m){throw a?a(m):l==null?M(Y(m,"Request failed")):l.showError(m),m}finally{w(!1)}},s=async(t,a)=>{v(null),await I(async()=>{await n.createModelProvider({type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(Y(m,"Request failed")))},r=async(t,a)=>{v(null),await I(async()=>{await n.updateModelProvider({id:t.id,type:t.type,name:t.name,...a.baseUrl?{baseUrl:a.baseUrl}:{},apiKey:a.apiKey,models:t.models})},m=>v(Y(m,"Request failed"))),l==null||l.showSuccess({title:`${t.name} updated`})},g=t=>{n.deleteModelProvider&&I(async()=>{await n.deleteModelProvider({id:t.id})}).catch(()=>{})},u=(t,a)=>{I(async()=>{await n.updateModelProvider({id:t.id,type:t.type,name:t.name,...t.baseUrl?{baseUrl:t.baseUrl}:{},apiKey:"",models:a})}).catch(()=>{})},j=async t=>{y(null),await I(async()=>{await n.createModelProvider({type:"custom",name:t.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},a=>y(Y(a,"Request failed"))),setTimeout(()=>{l==null||l.showSuccess({title:`${t.name} added`})},0)},R=async t=>{if(!f)return;const a=f;y(null),await I(async()=>{await n.updateModelProvider({id:a.id,type:a.type,name:a.name,baseUrl:t.baseUrl,apiKey:t.apiKey,models:t.models})},m=>y(Y(m,"Request failed"))),setTimeout(()=>{l==null||l.showSuccess({title:"Model provider updated",description:`${a.name} was updated successfully.`})},0)},le=f?{name:f.name,baseUrl:f.baseUrl??"",models:f.models}:void 0,C=A!=null?p.find(t=>t.id===A)??null:null,z=X!=null?d.find(t=>t.type===X)??null:null,ae=C!=null||z!=null;return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Models"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Connect providers and choose which models are available."}),F?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:F}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-3",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(ge,{query:b,setQuery:k,placeholder:"Search providers and models"})}),e.jsxs(B,{variant:"secondary",type:"button",onClick:()=>{y(null),D(null),K(!0)},children:[e.jsx(L,{name:"plus",size:"1rem",className:"mr-1"}),"Add Custom Provider"]})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-2 overflow-y-auto",children:[S?e.jsx("p",{className:"py-8 text-center text-sm text-text-secondary",children:"Loading…"}):null,!S&&q.length>0?e.jsxs("section",{"aria-labelledby":"configured-providers-heading",children:[e.jsx("div",{id:"configured-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Configured"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:q.map(t=>{const a=se.get(t.type)??[],m=new Set(t.models.map(N=>N.id)),J=a.filter(N=>!m.has(N.id)),de=_[t.name];return e.jsxs("article",{className:"border-b border-border p-3 last:border-b-0",children:[e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:de?e.jsx(ie,{src:de,alt:t.name,className:"size-4.5"}):e.jsx(L,{name:"cpu",className:"size-4.5"})}),e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-success-bg",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success-bg"}),"Connected"]}),e.jsxs(B,{variant:"secondary",size:"sm",className:"text-[0.8125rem]",type:"button","aria-label":`Edit ${t.name}`,title:`Edit ${t.name}`,disabled:x,onClick:()=>{t.type==="custom"?(H(),y(null),D(t),K(!0)):(v(null),T(null),U(t.id))},children:[e.jsx(L,{name:"wrench",className:"size-3.5"}),"Edit"]}),n.deleteModelProvider?e.jsx(B,{variant:"outline",size:"sm",className:"transition-colors hover:bg-failure-bg/10 hover:text-failure-bg",type:"button",disabled:x,onClick:()=>{g(t)},children:"Remove"}):null]})]}),e.jsxs("div",{className:"mt-3 overflow-hidden rounded-lg border border-border bg-secondary-bg/30",children:[t.models.map(N=>e.jsxs("div",{className:"flex min-h-10 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:N.name}),e.jsx("button",{type:"button","aria-label":`Remove ${N.name}`,disabled:x,className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md text-text-secondary hover:bg-ghost-button-hover hover:text-ghost-button-text focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring disabled:opacity-50",onClick:()=>{u(t,t.models.filter(he=>he.id!==N.id))},children:e.jsx(L,{name:"trash",className:"size-3.5"})})]},N.id)),J.length>0?e.jsxs("section",{children:[e.jsxs("div",{className:"border-b border-border bg-secondary-bg/40 px-3 py-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available to add · ",J.length]}),J.map(N=>e.jsxs("div",{className:"flex min-h-12 items-center gap-3 border-b border-border px-3 py-2 text-sm text-text-primary last:border-b-0",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:N.name}),e.jsx(B,{variant:"outline",size:"sm",type:"button",disabled:x,onClick:()=>{u(t,[...t.models,N])},children:"Add"})]},N.id))]}):null]})]},t.id)})})]}):null,!S&&Z.length>0?e.jsxs("section",{"aria-labelledby":"available-providers-heading",className:"mt-2",children:[e.jsx("div",{id:"available-providers-heading",className:"mb-2 text-[0.8125rem] font-semibold uppercase text-text-secondary",children:"Available"}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:Z.map(t=>{const a=_[t.name];return e.jsx("article",{className:"border-b border-border p-3 last:border-b-0",children:e.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:a?e.jsx(ie,{src:a,alt:t.name,className:"size-4.5"}):e.jsx(L,{name:"cpu",className:"size-4.5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h5",{className:"truncate text-base font-medium text-text-primary",children:t.name}),e.jsx("p",{className:"truncate text-sm text-text-secondary",children:t.models.map(m=>m.name).join(" · ")})]})]}),e.jsxs(B,{variant:"secondary",type:"button",disabled:x,onClick:()=>{v(null),U(null),T(t.type)},children:[e.jsx(L,{name:"wrench",className:"size-4"}),"Configure"]})]})},t.type)})})]}):null,!S&&q.length===0&&Z.length===0?e.jsx("div",{className:"flex flex-1 items-center justify-center rounded-xl border border-dashed border-border p-8 text-center text-sm text-text-secondary",children:h?`No providers match “${b.trim()}”.`:"No model providers yet."}):null]}),e.jsx(Ce,{open:ae,onOpenChange:t=>{t||H()},onSave:t=>{if(C)return r(C,t);if(z)return s(z,t)},title:C?"Edit Provider Details":"Configure Provider Details",initialBaseUrl:C?C.baseUrl??"":z?Te(z):"",requireApiKey:C==null,submitLabel:C?"Save":"Create",busy:x,error:G}),e.jsx(Ue,{open:i,onOpenChange:t=>{K(t),t||(y(null),D(null))},isEditMode:f!==null,initialValues:le,onSubmit:f?R:j,reasoningEffortOptions:oe,busy:x,error:$},(f==null?void 0:f.id)??"add-custom-provider")]})})]})},ze=Pe;export{ze as default};
@@ -1 +0,0 @@
1
- import{p as B,q as _,r as a,s as q,j as e,I as U,B as O,w as L,A as R,x as $,e as G,y as V,z as Y}from"./index-B8NomNE2.js";var H={execTimeoutMs:3e5,autoStopIntervalInMinutes:15,autoArchiveIntervalInMinutes:10080,autoDeleteIntervalInMinutes:43200},F=Y("h-11 shadow-sm");function D(n){if(n.trim()==="")return null;const r=Number(n);return!Number.isFinite(r)||r<0?null:r}var J=({open:n,onOpenChange:r,onSave:o,title:j,description:u,initialConfig:E=null,requireApiKey:f=!0,busy:N=!1,error:S})=>{const[m,I]=a.useState(""),[d,c]=a.useState(""),[C,l]=a.useState(""),[x,i]=a.useState(""),[b,h]=a.useState(""),[v,p]=a.useState(!1),z=()=>{I(""),c(""),l(""),i(""),h(""),p(!1)};a.useEffect(()=>{if(!n)return;const t=E??H;I(String(t.execTimeoutMs)),c(String(t.autoStopIntervalInMinutes)),l(String(t.autoArchiveIntervalInMinutes)),i(String(t.autoDeleteIntervalInMinutes)),h(""),p(!1)},[n,E]);const w=t=>{t||z(),r(t)},k=D(m),M=D(d),A=D(C),P=D(x),g=b.trim(),T=(!f||!!g)&&k!=null&&M!=null&&A!=null&&P!=null,s=async t=>{if(t.preventDefault(),!(!T||N||k==null||M==null||A==null||P==null))try{await o({snapshotName:"",execTimeoutMs:k,autoStopIntervalInMinutes:M,autoArchiveIntervalInMinutes:A,autoDeleteIntervalInMinutes:P,apiKey:g}),z(),r(!1)}catch{}};return e.jsx(L,{open:n,onOpenChange:w,title:j,description:u,contentSized:!0,headerIcon:e.jsx("span",{className:"flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(U,{name:"cube",className:"size-6"})}),children:e.jsxs("form",{className:"flex flex-col overflow-y-auto p-5 md:p-6",onSubmit:s,children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"sandbox-api-key",className:"mb-1.5 block text-sm font-medium text-text-primary",children:["API key",f?null:e.jsx("span",{className:"font-normal text-text-secondary",children:" (optional)"})]}),e.jsx("input",{id:"sandbox-api-key",type:"password",required:f,value:b,onChange:t=>{h(t.target.value)},placeholder:f?"dtn_...":"Leave blank to keep existing",autoFocus:!0,className:F})]}),e.jsxs(R,{expanded:v,onChange:(t,y)=>p(y),className:"rounded-md border border-border",children:[e.jsx($,{className:"px-3 py-2.5",children:e.jsxs("span",{className:"flex w-full items-center justify-between text-sm font-medium text-text-primary",children:["Advanced settings",e.jsx(U,{name:"chevron-down",className:G("size-4 shrink-0 text-text-secondary transition-transform duration-200",v?"rotate-0":"-rotate-90")})]})}),e.jsxs(V,{className:"space-y-4 border-t border-border px-3 pb-3 pt-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-exec-timeout",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Exec timeout (ms)"}),e.jsx("input",{id:"sandbox-exec-timeout",type:"number",min:0,required:!0,value:m,onChange:t=>{I(t.target.value)},placeholder:"300000",className:F})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-stop",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-stop interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-stop",type:"number",min:0,required:!0,value:d,onChange:t=>{c(t.target.value)},placeholder:"15",className:F})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-archive",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-archive interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-archive",type:"number",min:0,required:!0,value:C,onChange:t=>{l(t.target.value)},placeholder:"10080",className:F})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"sandbox-auto-delete",className:"mb-1.5 block text-sm font-medium text-text-primary",children:"Auto-delete interval (minutes)"}),e.jsx("input",{id:"sandbox-auto-delete",type:"number",min:0,required:!0,value:x,onChange:t=>{i(t.target.value)},placeholder:"43200",className:F})]})]})]})]}),e.jsxs("div",{className:"mt-6 space-y-3",children:[S?e.jsx("p",{className:"text-failure-bg text-sm",children:S}):null,e.jsx(O,{type:"submit",size:"lg",disabled:!T||N,className:"w-full shrink-0",children:"Save"})]})]})})},Q=J,K=({snapshotName:n,execTimeoutMs:r,autoStopIntervalInMinutes:o,autoArchiveIntervalInMinutes:j,autoDeleteIntervalInMinutes:u})=>({snapshotName:n,execTimeoutMs:r,autoStopIntervalInMinutes:o,autoArchiveIntervalInMinutes:j,autoDeleteIntervalInMinutes:u}),W=()=>{const{sandboxCatalog:n}=B(),r=_(),[o,j]=a.useState([]),[u,E]=a.useState([]),[f,N]=a.useState(!0),[S,m]=a.useState(null),[I,d]=a.useState(null),[c,C]=a.useState(!1),[l,x]=a.useState(null),[i,b]=a.useState(null),h=a.useCallback(async({quiet:s=!1}={})=>{if(n){s||N(!0),m(null);try{const[t,y]=await Promise.all([n.listSandboxProviders(),n.getSandboxProviderCatalog()]);j(t),E(y)}catch(t){m(q(t,"Failed to load sandbox providers"))}finally{s||N(!1)}}},[n]);a.useEffect(()=>{h()},[h]);const v=o.length>0,p=a.useMemo(()=>{if(v)return[];const s=new Set(o.map(t=>t.catalogId));return u.filter(t=>!s.has(t.id))},[u,o,v]),z=a.useMemo(()=>i?K(i):l?K(l):null,[i,l]);if(!n)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Sandbox provider catalog is not available."});const w=async(s,t=m)=>{C(!0),m(null);try{await s(),await h({quiet:!0})}catch(y){throw t(q(y,"Request failed")),y}finally{C(!1)}},k=async s=>{l&&(d(null),await w(async()=>{await n.createSandboxProvider({catalogId:l.id,name:l.name,type:l.type,...K(s),apiKey:s.apiKey})},d),x(null),setTimeout(()=>{r==null||r.showSuccess({title:`${l.name} configured`})},0))},M=async s=>{i&&(d(null),await w(async()=>{await n.updateSandboxProvider({id:i.id,...K(s),...s.apiKey?{apiKey:s.apiKey}:{}})},d),b(null),setTimeout(()=>{r==null||r.showSuccess({title:`${i.name} updated`})},0))},A=s=>{const t=n.deleteSandboxProvider;t&&w(async()=>{await t({id:s.id})}).catch(()=>{})},P=l!=null||i!=null,g=i!=null,T=i?`Update ${i.name}`:l?`Configure ${l.name}`:"Configure sandbox provider";return e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xl font-semibold tracking-tight text-text-primary",children:"Sandbox providers"}),e.jsx("p",{className:"mt-1 text-sm text-text-secondary",children:"Choose a provider that runs sandboxes for code, files and shell commands. Only one can be active at a time."}),S?e.jsx("p",{className:"mt-3 rounded-md border border-failure-bg/30 bg-failure-bg/10 px-3 py-2 text-sm text-failure-bg",children:S}):null,e.jsx("div",{className:"mt-4 flex-1 overflow-y-auto",children:f?e.jsx("p",{className:"text-sm text-text-secondary",children:"Loading sandbox providers…"}):e.jsxs("div",{className:"space-y-6",children:[o.length>0?e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Configured · ",o.length]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:o.map(s=>e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(U,{name:"cube",className:"size-4.5"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:s.name})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 sm:justify-end",children:[s.isConnected?e.jsxs("span",{className:"flex items-center gap-1.5 rounded-full border border-border bg-secondary-bg/40 px-2 py-0.5 text-xs font-medium text-success-bg",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-success-bg"}),"Connected"]}):null,e.jsx(O,{variant:"secondary",size:"sm",type:"button",disabled:c,onClick:()=>{d(null),x(null),b(s)},children:"Update"}),n.deleteSandboxProvider?e.jsx(O,{variant:"ghost",size:"sm",className:"text-text-secondary",type:"button",disabled:c,onClick:()=>{A(s)},children:"Remove"}):null]})]},s.id))})]}):null,v?null:e.jsxs("section",{children:[e.jsxs("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-text-secondary",children:["Available · ",p.length]}),p.length===0?e.jsx("p",{className:"text-sm text-text-secondary",children:u.length>0?"All catalog providers are configured.":"No sandbox providers in the catalog."}):e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-card-bg",children:p.map(s=>e.jsxs("article",{className:"flex flex-col gap-3 border-b border-border p-3 last:border-b-0 sm:flex-row sm:items-center",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[e.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg border border-border bg-secondary-bg text-text-primary","aria-hidden":!0,children:e.jsx(U,{name:"cube",className:"size-4.5"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("h5",{className:"truncate text-sm font-medium text-text-primary",children:s.name})})]}),e.jsx(O,{variant:"secondary",type:"button",disabled:c,onClick:()=>{d(null),b(null),x(s)},children:"Configure"})]},s.id))})]})]})}),e.jsx(Q,{open:P,onOpenChange:s=>{s||(d(null),x(null),b(null))},onSave:g?M:k,title:T,description:g?"Update this sandbox provider. Leave API key blank to keep the existing key.":"Configure this sandbox provider. API key is never stored in the catalog.",initialConfig:z,requireApiKey:!g,busy:c,error:I})]})},Z=W;export{Z as default};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelSettings-IJ55QJQO-BFV2nfxB.js","assets/index-B8NomNE2.js","assets/index-DEKCw40W.css","assets/ConnectorSettings-CLBEWGQJ-BjMXOS3R.js","assets/SkillSettings-MXK4ZEI7-CrK7D1D-.js","assets/SandboxSettings-S5XGZWOL-BUQpWdqg.js"])))=>i.map(i=>d[i]);
2
- import{n as p,k as h,o as g,r as l,j as e,I as m,f as v,e as x,_ as o,S as y}from"./index-B8NomNE2.js";var j=l.lazy(()=>o(()=>import("./ModelSettings-IJ55QJQO-BFV2nfxB.js"),__vite__mapDeps([0,1,2]))),S=l.lazy(()=>o(()=>import("./ConnectorSettings-CLBEWGQJ-BjMXOS3R.js"),__vite__mapDeps([3,1,2]))),_=l.lazy(()=>o(()=>import("./SkillSettings-MXK4ZEI7-CrK7D1D-.js"),__vite__mapDeps([4,1,2]))),k=l.lazy(()=>o(()=>import("./SandboxSettings-S5XGZWOL-BUQpWdqg.js"),__vite__mapDeps([5,1,2])));function w(){return e.jsxs("div",{className:"flex flex-1 items-center justify-center py-8",role:"status","aria-live":"polite","aria-busy":"true",children:[e.jsx(y,{size:20,className:"text-text-secondary"}),e.jsx("span",{className:"sr-only",children:"Loading"})]})}var E=()=>{const{settingsOpen:c,setSettingsOpen:d}=p(),n=h(),i=g(),[t,u]=l.useState("models"),r=(n==null?void 0:n.skillCatalog)!=null,a=(n==null?void 0:n.sandboxCatalog)!=null;l.useEffect(()=>{!r&&t==="skills"&&u("models"),!a&&t==="sandbox"&&u("models")},[r,a,t]),l.useEffect(()=>{if(!c)return;const s=f=>{f.key==="Escape"&&(f.stopImmediatePropagation(),d(!1))};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[c,d]);const b=l.useMemo(()=>{const s=[{id:"models",label:"Models",icon:"cpu"},{id:"connectors",label:"Connectors",icon:"plug"}];return r&&s.push({id:"skills",label:"Skills",icon:"lightbulb"}),a&&s.push({id:"sandbox",label:"Sandbox providers",icon:"cube"}),s},[r,a]);return!c||!n?null:e.jsxs("div",{className:"flex h-full min-h-0 w-full flex-col bg-primary-bg",children:[e.jsxs("header",{className:"flex shrink-0 items-center gap-2 border-b border-border px-2 py-1.5",children:[e.jsx("button",{type:"button","aria-label":"Back",title:"Back",className:v({variant:"ghost",size:"icon"}),onClick:()=>d(!1),children:e.jsx(m,{name:"arrow-left"})}),e.jsx("h1",{className:"text-lg font-semibold tracking-tight text-text-primary",children:"Settings"})]}),e.jsxs("div",{className:x("flex min-h-0 flex-1 flex-col",!i&&"md:flex-row"),children:[e.jsx("nav",{"aria-label":"Settings sections",className:x("flex w-full gap-1 border-b border-border bg-secondary-bg/40 p-2",i?"min-w-0":"justify-center md:w-48 md:flex-col md:justify-start md:border-b-0 md:border-r"),children:b.map(s=>e.jsxs("button",{type:"button","aria-current":t===s.id?"page":void 0,...i?{title:s.label}:{},className:x("flex min-h-9 items-center gap-2 rounded-md px-3 text-sm font-medium transition-colors","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-focus-ring",i?"min-w-0 flex-1 justify-center gap-1.5 px-1.5":"shrink-0",t===s.id?"bg-primary-button-bg text-primary-button-text":"text-text-secondary hover:bg-ghost-button-hover/60 hover:text-text-primary"),onClick:()=>{u(s.id)},children:[e.jsx(m,{name:s.icon,className:"h-4 w-4 shrink-0"}),i?e.jsx("span",{className:"truncate",children:s.label}):s.label]},s.id))}),e.jsx("section",{className:"flex flex-col h-full flex-1 overflow-y-hidden px-6 py-4",children:e.jsx("div",{className:"w-full max-w-210 h-full min-h-0 flex flex-col mx-auto",children:e.jsxs(l.Suspense,{fallback:e.jsx(w,{}),children:[t==="models"?e.jsx(j,{}):null,t==="connectors"?e.jsx(S,{}):null,t==="skills"&&r?e.jsx(_,{}):null,t==="sandbox"&&a?e.jsx(k,{}):null]})})})]})]})},C=E;export{C as default};
@@ -1,2 +0,0 @@
1
- [ 䴩�~^�^>��M��A�t���0d���*fP4g1�y@z�����c/�X��@���ZD�\�
2
- W�OL>����N���Ts�+YA�����*���#9� x���{���o����Ewk��>�D�i.J ������mGu��.;>�:��/���o��n!*հB�&��7Ⱦܵ��AG�T��� ���z��.��RSCҐ�o$������5G0������yo��������`%?~;���:ߔ��q$;�_�C�ղ�w` ����s�Vh������$�Hʅ�W��$�=:���S�-;�[����`�Q@*d�F�V��Dn�ȍ��M��Kȁ;�3�{EN��a9 )ɬ��ųg�+ˡϞ)\�B)%�F(_Ys49]�8�����l�sj1�u���S���X!�`�2�0�TGz�4������=z�,H}#iQکe�c h���#=