machinaos 0.0.91 → 0.0.93

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 (109) hide show
  1. package/.env.template +20 -0
  2. package/README.md +12 -9
  3. package/client/dist/assets/{ActionBar-BBRXTHL_.js → ActionBar-D7ffu8J-.js} +1 -1
  4. package/client/dist/assets/{ApiKeyInput-DAqXRgBY.js → ApiKeyInput-Dpxo3mVb.js} +1 -1
  5. package/client/dist/assets/{ApiKeyPanel-D4bXAniy.js → ApiKeyPanel-DO3lqgAH.js} +1 -1
  6. package/client/dist/assets/{ApiUsageSection-Bc-BEySC.js → ApiUsageSection-DcCBizXU.js} +1 -1
  7. package/client/dist/assets/{EmailPanel-CDqj-89J.js → EmailPanel-T9yOKXbB.js} +1 -1
  8. package/client/dist/assets/OAuthPanel-BP93t1lz.js +1 -0
  9. package/client/dist/assets/QrPairingPanel-BcTMFk59.js +1 -0
  10. package/client/dist/assets/RateLimitSection-BpJMUqlB.js +1 -0
  11. package/client/dist/assets/{StatusCard-DsxIEg0p.js → StatusCard-kHLR8lx_.js} +1 -1
  12. package/client/dist/assets/index-B4Z5KMNm.css +1 -0
  13. package/client/dist/assets/index-CyQ67hhw.js +165 -0
  14. package/client/dist/assets/vendor-icons-D3wxn0N1.js +22 -0
  15. package/client/dist/index.html +3 -3
  16. package/client/package.json +1 -1
  17. package/client/src/ParameterPanel.tsx +4 -0
  18. package/client/src/assets/icons/index.ts +13 -1
  19. package/client/src/components/__tests__/OutputPanel.test.tsx +96 -0
  20. package/client/src/components/credentials/panels/OAuthPanel.tsx +1 -0
  21. package/client/src/components/credentials/primitives/OAuthConnect.tsx +24 -8
  22. package/client/src/components/credentials/useCredentialPanel.ts +11 -1
  23. package/client/src/components/output/OutputPanel.tsx +52 -12
  24. package/client/src/components/parameterPanel/InputSection.tsx +5 -2
  25. package/client/src/components/parameterPanel/MasterSkillEditor.tsx +53 -19
  26. package/client/src/components/parameterPanel/MiddleSection.tsx +15 -4
  27. package/client/src/components/parameterPanel/OutputSection.tsx +3 -1
  28. package/client/src/components/parameterPanel/ParameterPanelLayout.tsx +6 -4
  29. package/client/src/components/parameterPanel/TodoEditor.tsx +221 -0
  30. package/client/src/contexts/WebSocketContext.tsx +15 -0
  31. package/client/src/themes/atomic.css +13 -0
  32. package/client/src/types/INodeProperties.ts +8 -0
  33. package/client/src/utils/formatters.ts +18 -0
  34. package/package.json +2 -1
  35. package/server/config/credential_providers.json +44 -1
  36. package/server/config/llm_defaults.json +19 -15
  37. package/server/config/model_registry.json +1088 -593
  38. package/server/config/pricing.json +14 -5
  39. package/server/core/ansi.py +34 -0
  40. package/server/core/cache.py +5 -102
  41. package/server/core/config.py +29 -0
  42. package/server/main.py +25 -11
  43. package/server/nodes/README.md +26 -5
  44. package/server/nodes/browser/__init__.py +5 -0
  45. package/server/nodes/browser/browser_harness/__init__.py +164 -0
  46. package/server/nodes/browser/browser_harness/_install.py +73 -0
  47. package/server/nodes/browser/browser_harness/_service.py +219 -0
  48. package/server/nodes/browser/browser_harness/icon.svg +9 -0
  49. package/server/nodes/browser/browser_harness/meta.json +3 -0
  50. package/server/nodes/filesystem/shell/__init__.py +10 -3
  51. package/server/nodes/github/__init__.py +28 -0
  52. package/server/nodes/github/_credentials.py +28 -0
  53. package/server/nodes/github/_handlers.py +304 -0
  54. package/server/nodes/github/_install.py +142 -0
  55. package/server/nodes/github/_service.py +101 -0
  56. package/server/nodes/github/github_action.py +319 -0
  57. package/server/nodes/github/meta.json +1 -0
  58. package/server/nodes/groups.py +2 -0
  59. package/server/nodes/tool/write_todos/__init__.py +25 -1
  60. package/server/nodes/tool/write_todos/_events.py +76 -0
  61. package/server/nodes/tool/write_todos/_handlers.py +72 -0
  62. package/server/nodes/vercel/__init__.py +26 -0
  63. package/server/nodes/vercel/_credentials.py +36 -0
  64. package/server/nodes/vercel/_handlers.py +325 -0
  65. package/server/nodes/vercel/_install.py +121 -0
  66. package/server/nodes/vercel/_service.py +105 -0
  67. package/server/nodes/vercel/meta.json +1 -0
  68. package/server/nodes/vercel/vercel_action.py +353 -0
  69. package/server/nodes/visuals.json +8 -0
  70. package/server/pyproject.toml +8 -3
  71. package/server/requirements.txt +7 -8
  72. package/server/services/deployment/manager.py +40 -86
  73. package/server/services/deployment/triggers.py +5 -45
  74. package/server/services/event_waiter.py +34 -233
  75. package/server/services/events/cli.py +6 -0
  76. package/server/services/events/envelope.py +5 -17
  77. package/server/services/plugin/base.py +22 -0
  78. package/server/services/process_service.py +5 -1
  79. package/server/services/skill_loader.py +24 -2
  80. package/server/services/status_broadcaster.py +4 -5
  81. package/server/services/temporal/_interceptors.py +97 -0
  82. package/server/services/temporal/_retry_policies.py +15 -0
  83. package/server/services/temporal/agent_workflow.py +32 -8
  84. package/server/services/temporal/schedules.py +10 -1
  85. package/server/services/temporal/worker.py +164 -7
  86. package/server/services/temporal/workflow.py +30 -11
  87. package/server/skills/github/github-skill/SKILL.md +135 -0
  88. package/server/skills/vercel/vercel-skill/SKILL.md +186 -0
  89. package/server/skills/web_agent/browser-harness-skill/SKILL.md +114 -0
  90. package/server/tests/conftest.py +12 -0
  91. package/server/tests/nodes/test_browser_harness.py +234 -0
  92. package/server/tests/nodes/test_write_todos_handlers.py +78 -0
  93. package/server/tests/temporal/test_dispatch.py +45 -7
  94. package/server/tests/temporal/test_machina_workflow_loop.py +139 -0
  95. package/server/tests/test_ansi.py +39 -0
  96. package/server/tests/test_github_plugin.py +329 -0
  97. package/server/tests/test_node_spec.py +7 -0
  98. package/server/tests/test_plugin_self_containment.py +2 -0
  99. package/server/tests/test_status_broadcasts.py +13 -6
  100. package/server/tests/test_task_queue_coverage.py +127 -0
  101. package/server/tests/test_vercel_plugin.py +292 -0
  102. package/server/uv.lock +583 -600
  103. package/client/dist/assets/OAuthPanel-CJqgpEDK.js +0 -1
  104. package/client/dist/assets/QrPairingPanel-DhXSjm5v.js +0 -1
  105. package/client/dist/assets/RateLimitSection-CbLUmd7P.js +0 -1
  106. package/client/dist/assets/index-BsU6riLP.js +0 -165
  107. package/client/dist/assets/index-D9U3x3FB.css +0 -1
  108. package/client/dist/assets/vendor-icons-CVrPjN2Q.js +0 -22
  109. package/server/services/scheduler.py +0 -124
package/.env.template CHANGED
@@ -56,6 +56,26 @@ TEMPORAL_NAMESPACE=default
56
56
  TEMPORAL_TASK_QUEUE=machina-tasks
57
57
  TEMPORAL_PER_TYPE_DISPATCH=true
58
58
  TEMPORAL_AGENT_WORKFLOW_ENABLED=true
59
+ # Per-queue activity routing (Wave 16, default-on since 16.4). A
60
+ # TemporalWorkerPool starts one activity-only Worker per plugin-declared
61
+ # task queue (ai-heavy / browser / code-exec / rest-api / messaging /
62
+ # ...) and per-type activities route to their specialised queue instead
63
+ # of the single 100-slot pool on machina-tasks. Rollback channel: set
64
+ # false + restart — activities route back to the manager worker
65
+ # unchanged.
66
+ TEMPORAL_WORKER_POOL_ENABLED=true
67
+ # Deployment topology hint: local (dev laptop; sleeps; halved per-queue
68
+ # concurrency) | cloud (machina deploy VM) | self_hosted. Drives worker
69
+ # identity strings in the Temporal Web UI and per-mode concurrency
70
+ # defaults. Explicit TEMPORAL_<QUEUE>_CONCURRENCY overrides always win.
71
+ DEPLOYMENT_MODE=local
72
+ # Per-queue concurrency overrides for the worker pool. Cloud defaults:
73
+ # machina-default=20, rest-api=50, ai-heavy=4, code-exec=10,
74
+ # triggers-poll=100, triggers-event=100, android=10, browser=4,
75
+ # messaging=20 (DEPLOYMENT_MODE=local halves these, floor 1).
76
+ # Examples:
77
+ # 4-core laptop: TEMPORAL_AI_HEAVY_CONCURRENCY=2 TEMPORAL_BROWSER_CONCURRENCY=2 TEMPORAL_CODE_EXEC_CONCURRENCY=4
78
+ # 32-core cloud: TEMPORAL_AI_HEAVY_CONCURRENCY=16 TEMPORAL_BROWSER_CONCURRENCY=8 TEMPORAL_CODE_EXEC_CONCURRENCY=32
59
79
  # gRPC frontend port the CLI dev server binds (``--port``). Default per
60
80
  # https://docs.temporal.io/references/configuration.
61
81
  TEMPORAL_FRONTEND_GRPC_PORT=7233
package/README.md CHANGED
@@ -1,5 +1,4 @@
1
- <img width="1584" height="672" alt="image" src="https://github.com/user-attachments/assets/54be1590-7e08-4b60-9a3d-aadcb3aa44f3" />
2
-
1
+ <img width="1584" height="672" alt="image" src="https://github.com/user-attachments/assets/cebd0198-4c09-4757-9407-a7ad79a7d71e" />
3
2
 
4
3
 
5
4
  # MachinaOS
@@ -39,11 +38,15 @@ The `dev` task starts the Python backend, Vite client, WhatsApp service, and Tem
39
38
 
40
39
  </details>
41
40
 
42
- ## See It In Action
41
+ ## Quick Hello World Setup for MachinaOS
42
+ https://github.com/user-attachments/assets/a5a5583f-bb5f-4d27-a387-8522c556e89e
43
+
44
+
45
+ ## AI Building Itself For Complex Tasks, See It In Action ↓.
46
+ https://github.com/user-attachments/assets/035a2293-0837-4969-8b9d-8d680e023b89
43
47
 
44
- https://github.com/user-attachments/assets/5ee81bb3-12cf-4755-8532-7470c6f1d841
45
48
 
46
- ## Full Capabilities
49
+ ## Multiple Specialized Loop Agents Orchestration
47
50
 
48
51
  https://github.com/user-attachments/assets/5798fe61-8d26-4d3a-90aa-189bf4eec79f
49
52
 
@@ -53,7 +56,7 @@ https://github.com/user-attachments/assets/5798fe61-8d26-4d3a-90aa-189bf4eec79f
53
56
 
54
57
  Pick nodes from the palette, drag them onto a canvas, connect them with lines, give your AI agent some memory and skills, and hit Play. Or **deploy** the workflow so it runs forever in the background — waiting for emails, responding to messages, checking in on a schedule, doing the work you'd rather not.
55
58
 
56
- ## Three Workflows You Get on Day One
59
+ ## Three Example Workflows For Reference.
57
60
 
58
61
  [![Default workflows that ship with MachinaOS](docs/diagrams/default-workflows.svg)](https://raw.githubusercontent.com/zeenie-ai/MachinaOS/main/docs/diagrams/default-workflows.svg)
59
62
 
@@ -117,7 +120,7 @@ RAG pipeline out of the box: parse PDFs and HTML, chunk into searchable pieces,
117
120
 
118
121
  Local providers (Ollama, LM Studio) are first-class — context length, vision support, and tool-use capability are detected automatically from your running server. No paid API needed.
119
122
 
120
- ### 17 specialized agent types
123
+ ### 16 specialized agent types
121
124
 
122
125
  Pick the right agent for the job:
123
126
 
@@ -147,7 +150,7 @@ Skills are short markdown files that teach an agent how to do something well —
147
150
 
148
151
  ### Memory that scales with your context window
149
152
 
150
- Agents track token usage and automatically compact long conversations when you hit half your model's context limit. Compaction summarizes in five sections — Task Overview, Current State, Important Discoveries, Next Steps, Context to Preserve — so the agent picks up exactly where it left off. For Anthropic and OpenAI, native API compaction is used; everywhere else, the agent summarizes itself.
153
+ Agents track token usage and automatically compact long conversations as you approach your model's context limit (80% by default, configurable). Compaction summarizes in five sections — Task Overview, Current State, Important Discoveries, Next Steps, Context to Preserve — so the agent picks up exactly where it left off. For Anthropic and OpenAI, native API compaction is used; everywhere else, the agent summarizes itself.
151
154
 
152
155
  ### Cost tracking, built in
153
156
 
@@ -155,7 +158,7 @@ Every LLM call and API request is tracked with USD cost. See per-provider spend
155
158
 
156
159
  ## The Canvas
157
160
 
158
- - **10 visual themes** — light, dark, Renaissance, Greek, Edo, Steampunk, Atomic, Cyber, Wasteland, Rot, Plague, Surveillance — each with its own icon set, sound pack, and decorative ornaments. Pick the vibe that matches your workflow.
161
+ - **12 visual themes** — light, dark, Renaissance, Greek, Edo, Steampunk, Atomic, Cyber, Wasteland, Rot, Plague, Surveillance — each with its own icon set, sound pack, and decorative ornaments. Pick the vibe that matches your workflow.
159
162
  - **Drag-to-map outputs** from one node's output directly onto another's input fields.
160
163
  - **Live execution animations** — nodes glow while running, show iteration count for AI agents, and surface errors inline.
161
164
  - **Multi-tab Console** — chat with trigger nodes, watch console logs, and view terminal output side by side.
@@ -1 +1 @@
1
- import{f as u,n as d,o as p,p as m,q as f,r as g,k as x}from"./index-BsU6riLP.js";import{j as l}from"./vendor-query-SzWcOU0G.js";import{q as b}from"./vendor-icons-CVrPjN2Q.js";function h(r){const t=u.c(7),a=d(),n=p(),s=m(),i=f(),o=g();if(!r)return null;let e;return t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==s||t[4]!==o||t[5]!==a?(e={whatsapp:a,android:n,twitter:s,google:i,telegram:o}[r]??null,t[0]=n,t[1]=i,t[2]=r,t[3]=s,t[4]=o,t[5]=a,t[6]=e):e=t[6],e}const y=r=>{const t=u.c(7),{actions:a,loading:n}=r;let s;if(t[0]!==a||t[1]!==n){let o;t[3]!==n?(o=e=>{const c=n===e.key;return l.jsxs(x,{intent:e.intent,onClick:e.onClick,disabled:e.disabled||c,children:[c?l.jsx(b,{className:"h-4 w-4 animate-spin"}):e.icon,e.label]},e.key)},t[3]=n,t[4]=o):o=t[4],s=a.filter(j).map(o),t[0]=a,t[1]=n,t[2]=s}else s=t[2];let i;return t[5]!==s?(i=l.jsx("div",{className:"flex justify-center gap-2 border-t border-border pt-3",children:s}),t[5]=s,t[6]=i):i=t[6],i};function j(r){return!r.hidden}export{y as A,h as u};
1
+ import{f as u,n as d,o as p,p as m,q as f,r as g,k as x}from"./index-CyQ67hhw.js";import{j as l}from"./vendor-query-SzWcOU0G.js";import{s as b}from"./vendor-icons-D3wxn0N1.js";function h(r){const t=u.c(7),a=d(),n=p(),s=m(),i=f(),o=g();if(!r)return null;let e;return t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==s||t[4]!==o||t[5]!==a?(e={whatsapp:a,android:n,twitter:s,google:i,telegram:o}[r]??null,t[0]=n,t[1]=i,t[2]=r,t[3]=s,t[4]=o,t[5]=a,t[6]=e):e=t[6],e}const y=r=>{const t=u.c(7),{actions:a,loading:n}=r;let s;if(t[0]!==a||t[1]!==n){let o;t[3]!==n?(o=e=>{const c=n===e.key;return l.jsxs(x,{intent:e.intent,onClick:e.onClick,disabled:e.disabled||c,children:[c?l.jsx(b,{className:"h-4 w-4 animate-spin"}):e.icon,e.label]},e.key)},t[3]=n,t[4]=o):o=t[4],s=a.filter(j).map(o),t[0]=a,t[1]=n,t[2]=s}else s=t[2];let i;return t[5]!==s?(i=l.jsx("div",{className:"flex justify-center gap-2 border-t border-border pt-3",children:s}),t[5]=s,t[6]=i):i=t[6],i};function j(r){return!r.hidden}export{y as A,h as u};
@@ -1 +1 @@
1
- import{a as u,j as s}from"./vendor-query-SzWcOU0G.js";import{I as j,B as o}from"./index-BsU6riLP.js";import{ay as d,az as v,q as y,v as N,B as w,T as k}from"./vendor-icons-CVrPjN2Q.js";const E=({value:l,onChange:c,onSave:m,onDelete:i,placeholder:x="Enter API key...",loading:n=!1,isStored:a=!1,disabled:e=!1,saveLabel:h="Validate",savedLabel:f="Valid"})=>{const[t,p]=u.useState(!1);return s.jsxs("div",{className:"flex w-full items-stretch gap-1",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(j,{type:t?"text":"password",value:l,onChange:r=>c(r.target.value),placeholder:x,disabled:e,className:"font-mono pr-9"}),s.jsx("button",{type:"button",onClick:()=>p(r=>!r),className:"absolute top-1/2 right-2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":t?"Hide key":"Show key",children:t?s.jsx(d,{className:"h-4 w-4"}):s.jsx(v,{className:"h-4 w-4"})})]}),s.jsxs(o,{variant:"default",onClick:m,disabled:!l.trim()||e||n,children:[n?s.jsx(y,{className:"h-4 w-4 animate-spin"}):a?s.jsx(N,{className:"h-4 w-4"}):s.jsx(w,{className:"h-4 w-4"}),a?f:h]}),a&&i&&s.jsx(o,{variant:"destructive",size:"icon",onClick:i,disabled:e,children:s.jsx(k,{className:"h-4 w-4"})})]})};export{E as A};
1
+ import{a as u,j as s}from"./vendor-query-SzWcOU0G.js";import{I as j,B as o}from"./index-CyQ67hhw.js";import{aC as d,aD as N,s as v,x as w,H as y,T as C}from"./vendor-icons-D3wxn0N1.js";const E=({value:l,onChange:c,onSave:m,onDelete:i,placeholder:x="Enter API key...",loading:n=!1,isStored:a=!1,disabled:e=!1,saveLabel:h="Validate",savedLabel:f="Valid"})=>{const[t,p]=u.useState(!1);return s.jsxs("div",{className:"flex w-full items-stretch gap-1",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(j,{type:t?"text":"password",value:l,onChange:r=>c(r.target.value),placeholder:x,disabled:e,className:"font-mono pr-9"}),s.jsx("button",{type:"button",onClick:()=>p(r=>!r),className:"absolute top-1/2 right-2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":t?"Hide key":"Show key",children:t?s.jsx(d,{className:"h-4 w-4"}):s.jsx(N,{className:"h-4 w-4"})})]}),s.jsxs(o,{variant:"default",onClick:m,disabled:!l.trim()||e||n,children:[n?s.jsx(v,{className:"h-4 w-4 animate-spin"}):a?s.jsx(w,{className:"h-4 w-4"}):s.jsx(y,{className:"h-4 w-4"}),a?f:h]}),a&&i&&s.jsx(o,{variant:"destructive",size:"icon",onClick:i,disabled:e,children:s.jsx(C,{className:"h-4 w-4"})})]})};export{E as A};
@@ -1 +1 @@
1
- import{a as D,j as s}from"./vendor-query-SzWcOU0G.js";import{u as P,A as U,a as q,b as z,c as H,d as I,e as T,B as M,f as R,N as O,C as Q,g as W,h as G,i as B,j as E,L as J,I as X,k as Y}from"./index-BsU6riLP.js";import{A as Z}from"./ApiKeyInput-DAqXRgBY.js";import{u as ee,P as se}from"./RateLimitSection-CbLUmd7P.js";import{ax as te,q as K,au as ae,v as le}from"./vendor-icons-CVrPjN2Q.js";import{A as ie}from"./ApiUsageSection-Bc-BEySC.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-misc-DBQ988Ev.js";import"./vendor-radix-BHmt2CkM.js";import"./vendor-markdown-CRou3yQ5.js";import"./vendor-react-DvWIbVx0.js";const L=g=>{const e=R.c(8),{label:a,value:p,className:t}=g;let l;e[0]!==a?(l=s.jsx("span",{className:"text-xs text-muted-foreground",children:a}),e[0]=a,e[1]=l):l=e[1];const c=`text-lg font-semibold ${t??""}`;let i;e[2]!==c||e[3]!==p?(i=s.jsx("span",{className:c,children:p}),e[2]=c,e[3]=p,e[4]=i):i=e[4];let o;return e[5]!==l||e[6]!==i?(o=s.jsxs("div",{className:"flex flex-col",children:[l,i]}),e[5]=l,e[6]=i,e[7]=o):o=e[7],o},oe=({providerId:g,providerName:e})=>{const{getProviderUsageSummary:a,isConnected:p}=P(),[t,l]=D.useState(null),[c,i]=D.useState(!1),[o,h]=D.useState(!1),d=D.useCallback(async()=>{if(p){i(!0);try{const r=await a();l(r.find(n=>n.provider===g)??null)}finally{i(!1)}}},[p,g,a]);return D.useEffect(()=>{o&&d()},[o,d]),s.jsx(U,{type:"single",collapsible:!0,onValueChange:r=>h(r==="usage"),children:s.jsxs(q,{value:"usage",children:[s.jsx(z,{children:s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(te,{className:"h-4 w-4"})," Usage & Costs"]})}),s.jsx(H,{children:c?s.jsx("div",{className:"flex justify-center p-4",children:s.jsx(K,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):!t||t.execution_count===0?s.jsx(I,{variant:"info",children:s.jsxs(T,{children:["No usage data yet for ",e]})}):s.jsxs("div",{className:"flex w-full flex-col gap-4",children:[s.jsxs("div",{className:"flex flex-wrap gap-4",children:[s.jsx(L,{label:"Total Tokens",value:t.total_tokens.toLocaleString(),className:"text-info"}),s.jsx(L,{label:"Total Cost",value:`$${t.total_cost.toFixed(4)}`,className:"text-success"}),s.jsx(L,{label:"Executions",value:t.execution_count,className:"text-primary"})]}),s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsxs("div",{className:"grid grid-cols-2 divide-x divide-border border-b border-border",children:[s.jsxs("div",{className:"px-3 py-2 text-sm",children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Input Tokens"}),s.jsxs("div",{children:[t.total_input_tokens.toLocaleString()," ",s.jsxs("span",{className:"ml-1 text-success",children:["($",t.total_input_cost.toFixed(4),")"]})]})]}),s.jsxs("div",{className:"px-3 py-2 text-sm",children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Output Tokens"}),s.jsxs("div",{children:[t.total_output_tokens.toLocaleString()," ",s.jsxs("span",{className:"ml-1 text-success",children:["($",t.total_output_cost.toFixed(4),")"]})]})]})]}),t.total_cache_cost>0&&s.jsxs("div",{className:"px-3 py-2 text-sm",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:"Cache Cost: "}),s.jsxs("span",{className:"text-success",children:["$",t.total_cache_cost.toFixed(4)]})]})]}),t.models.length>1&&s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsx("div",{className:"border-b border-border bg-muted px-3 py-1.5 text-xs font-semibold",children:"By Model"}),s.jsx("div",{className:"divide-y divide-border",children:t.models.map(r=>s.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-3 px-3 py-2 text-sm",children:[s.jsx("code",{className:"text-xs",children:r.model}),s.jsxs("span",{className:"text-success",children:["$",r.total_cost.toFixed(4)]})]},r.model))})]}),s.jsxs(M,{size:"sm",variant:"outline",onClick:d,disabled:c,children:[c?s.jsx(K,{className:"h-3 w-3 animate-spin"}):s.jsx(ae,{className:"h-3 w-3"}),"Refresh"]})]})})]})})},ge=g=>{const e=R.c(75),{config:a,visible:p}=g,t=ee(a,p),l=a.fields?.[0];let c,i,o,h;if(e[0]!==a.color||e[1]!==a.fields||e[2]!==a.iconRef||e[3]!==a.id||e[4]!==a.name||e[5]!==a.vertexName||e[6]!==l||e[7]!==t.actions||e[8]!==t.error||e[9]!==t.form||e[10]!==t.loading||e[11]!==t.stored||e[12]!==t.values){const $=(a.fields??[]).slice(1),v=l?t.values[l.key]??"":"",x=t.stored;c="flex flex-col gap-5 p-5";let m;e[17]!==a.color?(m={color:a.color},e[17]=a.color,e[18]=m):m=e[18];let u;e[19]!==a.iconRef?(u=s.jsx(O,{icon:a.iconRef,className:"h-12 w-12 text-2xl"}),e[19]=a.iconRef,e[20]=u):u=e[20];let f;e[21]!==m||e[22]!==u?(f=s.jsx("div",{className:"rounded-lg bg-tint-soft",style:m,children:u}),e[21]=m,e[22]=u,e[23]=f):f=e[23];const y=a.vertexName&&v.startsWith("AQ.")?a.vertexName:a.name;let b;e[24]!==y?(b=s.jsx(Q,{className:"text-lg",children:y}),e[24]=y,e[25]=b):b=e[25];let C;e[26]!==f||e[27]!==b?(C=s.jsxs("div",{className:"flex items-center gap-3",children:[f,b]}),e[26]=f,e[27]=b,e[28]=C):C=e[28];let k;e[29]!==x?(k=x&&s.jsxs(W,{variant:"success",className:"gap-1",children:[s.jsx(le,{className:"h-3 w-3"}),"Connected"]}),e[29]=x,e[30]=k):k=e[30];let S;e[31]!==C||e[32]!==k?(S=s.jsxs(G,{className:"flex flex-row items-center justify-between gap-3 space-y-0 pb-3",children:[C,k]}),e[31]=C,e[32]=k,e[33]=S):S=e[33];let w;e[34]!==a.id||e[35]!==l||e[36]!==v||e[37]!==t.actions||e[38]!==t.form||e[39]!==t.loading||e[40]!==x?(w=l&&s.jsx(Z,{value:v,onChange:j=>t.form.setFieldValue(l.key,j),onSave:()=>t.actions.validate(a.id,v.trim()),onDelete:x?async()=>{await t.actions.remove(a.id),l.key!=="apiKey"&&await t.actions.remove(l.key)}:void 0,placeholder:l.placeholder,loading:t.loading==="validate",isStored:x,saveLabel:l.key==="apiKey"?"Validate":"Fetch",savedLabel:l.key==="apiKey"?"Valid":"Connected"}),e[34]=a.id,e[35]=l,e[36]=v,e[37]=t.actions,e[38]=t.form,e[39]=t.loading,e[40]=x,e[41]=w):w=e[41];let _;e[42]!==l?(_=l?.help&&s.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:l.help}),e[42]=l,e[43]=_):_=e[43];let A;e[44]!==w||e[45]!==_?(A=s.jsxs(B,{children:[w,_]}),e[44]=w,e[45]=_,e[46]=A):A=e[46],e[47]!==S||e[48]!==A?(i=s.jsxs(E,{children:[S,A]}),e[47]=S,e[48]=A,e[49]=i):i=e[49],e[50]!==t.error?(o=t.error&&s.jsx(I,{variant:"destructive",children:s.jsx(T,{children:t.error})}),e[50]=t.error,e[51]=o):o=e[51];let F;e[52]!==t.actions||e[53]!==t.form||e[54]!==t.loading||e[55]!==t.values?(F=j=>s.jsx(re,{fieldKey:j.key,label:j.label,placeholder:j.placeholder,help:j.help,secret:j.secret,value:t.values[j.key]??"",onChange:V=>t.form.setFieldValue(j.key,V),onSave:()=>t.actions.save(j.key,t.values[j.key]??""),loading:t.loading==="save"},j.key),e[52]=t.actions,e[53]=t.form,e[54]=t.loading,e[55]=t.values,e[56]=F):F=e[56],h=$.map(F),e[0]=a.color,e[1]=a.fields,e[2]=a.iconRef,e[3]=a.id,e[4]=a.name,e[5]=a.vertexName,e[6]=l,e[7]=t.actions,e[8]=t.error,e[9]=t.form,e[10]=t.loading,e[11]=t.stored,e[12]=t.values,e[13]=c,e[14]=i,e[15]=o,e[16]=h}else c=e[13],i=e[14],o=e[15],h=e[16];let d;e[57]!==a.hasDefaults||e[58]!==a.id?(d=a.hasDefaults&&s.jsx(se,{providerId:a.id}),e[57]=a.hasDefaults,e[58]=a.id,e[59]=d):d=e[59];let r;e[60]!==a.hasDefaults||e[61]!==a.id||e[62]!==a.name?(r=a.hasDefaults&&s.jsx(oe,{providerId:a.id,providerName:a.name}),e[60]=a.hasDefaults,e[61]=a.id,e[62]=a.name,e[63]=r):r=e[63];let n;e[64]!==a.name||e[65]!==a.usageService?(n=a.usageService&&s.jsx(ie,{service:a.usageService,serviceName:a.name}),e[64]=a.name,e[65]=a.usageService,e[66]=n):n=e[66];let N;return e[67]!==c||e[68]!==i||e[69]!==o||e[70]!==h||e[71]!==d||e[72]!==r||e[73]!==n?(N=s.jsxs("div",{className:c,children:[i,o,h,d,r,n]}),e[67]=c,e[68]=i,e[69]=o,e[70]=h,e[71]=d,e[72]=r,e[73]=n,e[74]=N):N=e[74],N},re=g=>{const e=R.c(23),{fieldKey:a,label:p,placeholder:t,help:l,secret:c,value:i,onChange:o,onSave:h,loading:d}=g,r=`cred-${a}`;let n;e[0]!==p||e[1]!==r?(n=s.jsx(J,{htmlFor:r,className:"text-sm font-medium",children:p}),e[0]=p,e[1]=r,e[2]=n):n=e[2];const N=`cred-${a}`,$=c?"password":"text";let v;e[3]!==o?(v=b=>o(b.target.value),e[3]=o,e[4]=v):v=e[4];let x;e[5]!==t||e[6]!==N||e[7]!==$||e[8]!==v||e[9]!==i?(x=s.jsx(X,{id:N,type:$,value:i,onChange:v,placeholder:t,className:"flex-1"}),e[5]=t,e[6]=N,e[7]=$,e[8]=v,e[9]=i,e[10]=x):x=e[10];let m;e[11]!==d||e[12]!==h?(m=s.jsx(Y,{intent:"save",onClick:h,disabled:d,children:"Save"}),e[11]=d,e[12]=h,e[13]=m):m=e[13];let u;e[14]!==x||e[15]!==m?(u=s.jsxs("div",{className:"flex gap-2",children:[x,m]}),e[14]=x,e[15]=m,e[16]=u):u=e[16];let f;e[17]!==l?(f=l&&s.jsx("p",{className:"text-xs text-muted-foreground",children:l}),e[17]=l,e[18]=f):f=e[18];let y;return e[19]!==n||e[20]!==u||e[21]!==f?(y=s.jsx(E,{children:s.jsxs(B,{className:"flex flex-col gap-2 pt-4",children:[n,u,f]})}),e[19]=n,e[20]=u,e[21]=f,e[22]=y):y=e[22],y};export{ge as default};
1
+ import{a as D,j as s}from"./vendor-query-SzWcOU0G.js";import{u as P,A as U,a as z,b as H,c as M,d as B,e as I,B as O,f as R,N as Q,C as W,g as q,h as G,i as T,j as E,L as J,I as X,k as Y}from"./index-CyQ67hhw.js";import{A as Z}from"./ApiKeyInput-Dpxo3mVb.js";import{u as ee,P as se}from"./RateLimitSection-BpJMUqlB.js";import{aB as te,s as K,ay as ae,x as le}from"./vendor-icons-D3wxn0N1.js";import{A as ie}from"./ApiUsageSection-DcCBizXU.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-misc-DBQ988Ev.js";import"./vendor-radix-BHmt2CkM.js";import"./vendor-markdown-CRou3yQ5.js";import"./vendor-react-DvWIbVx0.js";const L=g=>{const e=R.c(8),{label:a,value:p,className:t}=g;let l;e[0]!==a?(l=s.jsx("span",{className:"text-xs text-muted-foreground",children:a}),e[0]=a,e[1]=l):l=e[1];const c=`text-lg font-semibold ${t??""}`;let i;e[2]!==c||e[3]!==p?(i=s.jsx("span",{className:c,children:p}),e[2]=c,e[3]=p,e[4]=i):i=e[4];let o;return e[5]!==l||e[6]!==i?(o=s.jsxs("div",{className:"flex flex-col",children:[l,i]}),e[5]=l,e[6]=i,e[7]=o):o=e[7],o},oe=({providerId:g,providerName:e})=>{const{getProviderUsageSummary:a,isConnected:p}=P(),[t,l]=D.useState(null),[c,i]=D.useState(!1),[o,h]=D.useState(!1),d=D.useCallback(async()=>{if(p){i(!0);try{const r=await a();l(r.find(n=>n.provider===g)??null)}finally{i(!1)}}},[p,g,a]);return D.useEffect(()=>{o&&d()},[o,d]),s.jsx(U,{type:"single",collapsible:!0,onValueChange:r=>h(r==="usage"),children:s.jsxs(z,{value:"usage",children:[s.jsx(H,{children:s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(te,{className:"h-4 w-4"})," Usage & Costs"]})}),s.jsx(M,{children:c?s.jsx("div",{className:"flex justify-center p-4",children:s.jsx(K,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):!t||t.execution_count===0?s.jsx(B,{variant:"info",children:s.jsxs(I,{children:["No usage data yet for ",e]})}):s.jsxs("div",{className:"flex w-full flex-col gap-4",children:[s.jsxs("div",{className:"flex flex-wrap gap-4",children:[s.jsx(L,{label:"Total Tokens",value:t.total_tokens.toLocaleString(),className:"text-info"}),s.jsx(L,{label:"Total Cost",value:`$${t.total_cost.toFixed(4)}`,className:"text-success"}),s.jsx(L,{label:"Executions",value:t.execution_count,className:"text-primary"})]}),s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsxs("div",{className:"grid grid-cols-2 divide-x divide-border border-b border-border",children:[s.jsxs("div",{className:"px-3 py-2 text-sm",children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Input Tokens"}),s.jsxs("div",{children:[t.total_input_tokens.toLocaleString()," ",s.jsxs("span",{className:"ml-1 text-success",children:["($",t.total_input_cost.toFixed(4),")"]})]})]}),s.jsxs("div",{className:"px-3 py-2 text-sm",children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:"Output Tokens"}),s.jsxs("div",{children:[t.total_output_tokens.toLocaleString()," ",s.jsxs("span",{className:"ml-1 text-success",children:["($",t.total_output_cost.toFixed(4),")"]})]})]})]}),t.total_cache_cost>0&&s.jsxs("div",{className:"px-3 py-2 text-sm",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:"Cache Cost: "}),s.jsxs("span",{className:"text-success",children:["$",t.total_cache_cost.toFixed(4)]})]})]}),t.models.length>1&&s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsx("div",{className:"border-b border-border bg-muted px-3 py-1.5 text-xs font-semibold",children:"By Model"}),s.jsx("div",{className:"divide-y divide-border",children:t.models.map(r=>s.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-3 px-3 py-2 text-sm",children:[s.jsx("code",{className:"text-xs",children:r.model}),s.jsxs("span",{className:"text-success",children:["$",r.total_cost.toFixed(4)]})]},r.model))})]}),s.jsxs(O,{size:"sm",variant:"outline",onClick:d,disabled:c,children:[c?s.jsx(K,{className:"h-3 w-3 animate-spin"}):s.jsx(ae,{className:"h-3 w-3"}),"Refresh"]})]})})]})})},ge=g=>{const e=R.c(75),{config:a,visible:p}=g,t=ee(a,p),l=a.fields?.[0];let c,i,o,h;if(e[0]!==a.color||e[1]!==a.fields||e[2]!==a.iconRef||e[3]!==a.id||e[4]!==a.name||e[5]!==a.vertexName||e[6]!==l||e[7]!==t.actions||e[8]!==t.error||e[9]!==t.form||e[10]!==t.loading||e[11]!==t.stored||e[12]!==t.values){const $=(a.fields??[]).slice(1),v=l?t.values[l.key]??"":"",x=t.stored;c="flex flex-col gap-5 p-5";let m;e[17]!==a.color?(m={color:a.color},e[17]=a.color,e[18]=m):m=e[18];let u;e[19]!==a.iconRef?(u=s.jsx(Q,{icon:a.iconRef,className:"h-12 w-12 text-2xl"}),e[19]=a.iconRef,e[20]=u):u=e[20];let f;e[21]!==m||e[22]!==u?(f=s.jsx("div",{className:"rounded-lg bg-tint-soft",style:m,children:u}),e[21]=m,e[22]=u,e[23]=f):f=e[23];const y=a.vertexName&&v.startsWith("AQ.")?a.vertexName:a.name;let b;e[24]!==y?(b=s.jsx(W,{className:"text-lg",children:y}),e[24]=y,e[25]=b):b=e[25];let C;e[26]!==f||e[27]!==b?(C=s.jsxs("div",{className:"flex items-center gap-3",children:[f,b]}),e[26]=f,e[27]=b,e[28]=C):C=e[28];let k;e[29]!==x?(k=x&&s.jsxs(q,{variant:"success",className:"gap-1",children:[s.jsx(le,{className:"h-3 w-3"}),"Connected"]}),e[29]=x,e[30]=k):k=e[30];let S;e[31]!==C||e[32]!==k?(S=s.jsxs(G,{className:"flex flex-row items-center justify-between gap-3 space-y-0 pb-3",children:[C,k]}),e[31]=C,e[32]=k,e[33]=S):S=e[33];let w;e[34]!==a.id||e[35]!==l||e[36]!==v||e[37]!==t.actions||e[38]!==t.form||e[39]!==t.loading||e[40]!==x?(w=l&&s.jsx(Z,{value:v,onChange:j=>t.form.setFieldValue(l.key,j),onSave:()=>t.actions.validate(a.id,v.trim()),onDelete:x?async()=>{await t.actions.remove(a.id),l.key!=="apiKey"&&await t.actions.remove(l.key)}:void 0,placeholder:l.placeholder,loading:t.loading==="validate",isStored:x,saveLabel:l.key==="apiKey"?"Validate":"Fetch",savedLabel:l.key==="apiKey"?"Valid":"Connected"}),e[34]=a.id,e[35]=l,e[36]=v,e[37]=t.actions,e[38]=t.form,e[39]=t.loading,e[40]=x,e[41]=w):w=e[41];let _;e[42]!==l?(_=l?.help&&s.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:l.help}),e[42]=l,e[43]=_):_=e[43];let A;e[44]!==w||e[45]!==_?(A=s.jsxs(T,{children:[w,_]}),e[44]=w,e[45]=_,e[46]=A):A=e[46],e[47]!==S||e[48]!==A?(i=s.jsxs(E,{children:[S,A]}),e[47]=S,e[48]=A,e[49]=i):i=e[49],e[50]!==t.error?(o=t.error&&s.jsx(B,{variant:"destructive",children:s.jsx(I,{children:t.error})}),e[50]=t.error,e[51]=o):o=e[51];let F;e[52]!==t.actions||e[53]!==t.form||e[54]!==t.loading||e[55]!==t.values?(F=j=>s.jsx(re,{fieldKey:j.key,label:j.label,placeholder:j.placeholder,help:j.help,secret:j.secret,value:t.values[j.key]??"",onChange:V=>t.form.setFieldValue(j.key,V),onSave:()=>t.actions.save(j.key,t.values[j.key]??""),loading:t.loading==="save"},j.key),e[52]=t.actions,e[53]=t.form,e[54]=t.loading,e[55]=t.values,e[56]=F):F=e[56],h=$.map(F),e[0]=a.color,e[1]=a.fields,e[2]=a.iconRef,e[3]=a.id,e[4]=a.name,e[5]=a.vertexName,e[6]=l,e[7]=t.actions,e[8]=t.error,e[9]=t.form,e[10]=t.loading,e[11]=t.stored,e[12]=t.values,e[13]=c,e[14]=i,e[15]=o,e[16]=h}else c=e[13],i=e[14],o=e[15],h=e[16];let d;e[57]!==a.hasDefaults||e[58]!==a.id?(d=a.hasDefaults&&s.jsx(se,{providerId:a.id}),e[57]=a.hasDefaults,e[58]=a.id,e[59]=d):d=e[59];let r;e[60]!==a.hasDefaults||e[61]!==a.id||e[62]!==a.name?(r=a.hasDefaults&&s.jsx(oe,{providerId:a.id,providerName:a.name}),e[60]=a.hasDefaults,e[61]=a.id,e[62]=a.name,e[63]=r):r=e[63];let n;e[64]!==a.name||e[65]!==a.usageService?(n=a.usageService&&s.jsx(ie,{service:a.usageService,serviceName:a.name}),e[64]=a.name,e[65]=a.usageService,e[66]=n):n=e[66];let N;return e[67]!==c||e[68]!==i||e[69]!==o||e[70]!==h||e[71]!==d||e[72]!==r||e[73]!==n?(N=s.jsxs("div",{className:c,children:[i,o,h,d,r,n]}),e[67]=c,e[68]=i,e[69]=o,e[70]=h,e[71]=d,e[72]=r,e[73]=n,e[74]=N):N=e[74],N},re=g=>{const e=R.c(23),{fieldKey:a,label:p,placeholder:t,help:l,secret:c,value:i,onChange:o,onSave:h,loading:d}=g,r=`cred-${a}`;let n;e[0]!==p||e[1]!==r?(n=s.jsx(J,{htmlFor:r,className:"text-sm font-medium",children:p}),e[0]=p,e[1]=r,e[2]=n):n=e[2];const N=`cred-${a}`,$=c?"password":"text";let v;e[3]!==o?(v=b=>o(b.target.value),e[3]=o,e[4]=v):v=e[4];let x;e[5]!==t||e[6]!==N||e[7]!==$||e[8]!==v||e[9]!==i?(x=s.jsx(X,{id:N,type:$,value:i,onChange:v,placeholder:t,className:"flex-1"}),e[5]=t,e[6]=N,e[7]=$,e[8]=v,e[9]=i,e[10]=x):x=e[10];let m;e[11]!==d||e[12]!==h?(m=s.jsx(Y,{intent:"save",onClick:h,disabled:d,children:"Save"}),e[11]=d,e[12]=h,e[13]=m):m=e[13];let u;e[14]!==x||e[15]!==m?(u=s.jsxs("div",{className:"flex gap-2",children:[x,m]}),e[14]=x,e[15]=m,e[16]=u):u=e[16];let f;e[17]!==l?(f=l&&s.jsx("p",{className:"text-xs text-muted-foreground",children:l}),e[17]=l,e[18]=f):f=e[18];let y;return e[19]!==n||e[20]!==u||e[21]!==f?(y=s.jsx(E,{children:s.jsxs(T,{className:"flex flex-col gap-2 pt-4",children:[n,u,f]})}),e[19]=n,e[20]=u,e[21]=f,e[22]=y):y=e[22],y};export{ge as default};
@@ -1 +1 @@
1
- import{a as x,j as e}from"./vendor-query-SzWcOU0G.js";import{u as h,g as u,A as g,a as v,b as N,c as b,d as w,e as y,B as A,f as C}from"./index-BsU6riLP.js";import{ax as _,q as f,au as S}from"./vendor-icons-CVrPjN2Q.js";const R=({service:d,serviceName:s})=>{const{getAPIUsageSummary:c,isConnected:i}=h(),[a,l]=x.useState(null),[o,t]=x.useState(!1),r=x.useCallback(async()=>{if(i){t(!0);try{const n=await c(d);l(n.find(p=>p.service===d)??null)}finally{t(!1)}}},[i,d,c]);x.useEffect(()=>{r()},[r]);const j=a?e.jsxs(u,{variant:"success",children:["$",a.total_cost.toFixed(4)]}):null;return e.jsx(g,{type:"single",collapsible:!0,children:e.jsxs(v,{value:"usage",children:[e.jsx(N,{children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-4 w-4 text-warning"}),"API Usage & Costs ",j]})}),e.jsx(b,{children:o?e.jsx("div",{className:"flex justify-center p-4",children:e.jsx(f,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):a?e.jsxs("div",{className:"flex w-full flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsx(m,{label:"Total Cost",value:`$${a.total_cost.toFixed(4)}`,className:"text-success"}),e.jsx(m,{label:"API Calls",value:a.execution_count,className:"text-info"}),e.jsx(m,{label:"Resources",value:a.total_resources,className:"text-primary"})]}),a.operations?.length>0&&e.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[e.jsx("div",{className:"border-b border-border bg-muted px-3 py-1.5 text-xs font-semibold",children:"Operations Breakdown"}),e.jsx("div",{className:"divide-y divide-border",children:a.operations.map(n=>e.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-3 px-3 py-2 text-sm",children:[e.jsx("code",{className:"text-xs text-muted-foreground",children:n.operation}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(u,{variant:"outline",children:[n.resource_count," resources"]}),e.jsxs(u,{variant:"success",children:["$",n.total_cost.toFixed(4)]})]})]},n.operation))})]}),e.jsxs(A,{size:"sm",variant:"outline",onClick:r,disabled:o,children:[o?e.jsx(f,{className:"h-3 w-3 animate-spin"}):e.jsx(S,{className:"h-3 w-3"}),"Refresh"]})]}):e.jsx(w,{variant:"info",children:e.jsxs(y,{children:["No usage data yet. Use ",s," nodes in your workflows to track costs."]})})})]})})},m=d=>{const s=C.c(8),{label:c,value:i,className:a}=d;let l;s[0]!==c?(l=e.jsx("span",{className:"text-xs text-muted-foreground",children:c}),s[0]=c,s[1]=l):l=s[1];const o=`text-lg font-semibold ${a??""}`;let t;s[2]!==o||s[3]!==i?(t=e.jsx("span",{className:o,children:i}),s[2]=o,s[3]=i,s[4]=t):t=s[4];let r;return s[5]!==l||s[6]!==t?(r=e.jsxs("div",{className:"flex flex-col",children:[l,t]}),s[5]=l,s[6]=t,s[7]=r):r=s[7],r};export{R as A};
1
+ import{a as x,j as e}from"./vendor-query-SzWcOU0G.js";import{u as h,g as m,A as g,a as v,b as N,c as b,d as y,e as w,B as A,f as C}from"./index-CyQ67hhw.js";import{aB as _,s as f,ay as B}from"./vendor-icons-D3wxn0N1.js";const R=({service:d,serviceName:s})=>{const{getAPIUsageSummary:c,isConnected:i}=h(),[a,l]=x.useState(null),[o,t]=x.useState(!1),r=x.useCallback(async()=>{if(i){t(!0);try{const n=await c(d);l(n.find(p=>p.service===d)??null)}finally{t(!1)}}},[i,d,c]);x.useEffect(()=>{r()},[r]);const j=a?e.jsxs(m,{variant:"success",children:["$",a.total_cost.toFixed(4)]}):null;return e.jsx(g,{type:"single",collapsible:!0,children:e.jsxs(v,{value:"usage",children:[e.jsx(N,{children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-4 w-4 text-warning"}),"API Usage & Costs ",j]})}),e.jsx(b,{children:o?e.jsx("div",{className:"flex justify-center p-4",children:e.jsx(f,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):a?e.jsxs("div",{className:"flex w-full flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsx(u,{label:"Total Cost",value:`$${a.total_cost.toFixed(4)}`,className:"text-success"}),e.jsx(u,{label:"API Calls",value:a.execution_count,className:"text-info"}),e.jsx(u,{label:"Resources",value:a.total_resources,className:"text-primary"})]}),a.operations?.length>0&&e.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[e.jsx("div",{className:"border-b border-border bg-muted px-3 py-1.5 text-xs font-semibold",children:"Operations Breakdown"}),e.jsx("div",{className:"divide-y divide-border",children:a.operations.map(n=>e.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-3 px-3 py-2 text-sm",children:[e.jsx("code",{className:"text-xs text-muted-foreground",children:n.operation}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(m,{variant:"outline",children:[n.resource_count," resources"]}),e.jsxs(m,{variant:"success",children:["$",n.total_cost.toFixed(4)]})]})]},n.operation))})]}),e.jsxs(A,{size:"sm",variant:"outline",onClick:r,disabled:o,children:[o?e.jsx(f,{className:"h-3 w-3 animate-spin"}):e.jsx(B,{className:"h-3 w-3"}),"Refresh"]})]}):e.jsx(y,{variant:"info",children:e.jsxs(w,{children:["No usage data yet. Use ",s," nodes in your workflows to track costs."]})})})]})})},u=d=>{const s=C.c(8),{label:c,value:i,className:a}=d;let l;s[0]!==c?(l=e.jsx("span",{className:"text-xs text-muted-foreground",children:c}),s[0]=c,s[1]=l):l=s[1];const o=`text-lg font-semibold ${a??""}`;let t;s[2]!==o||s[3]!==i?(t=e.jsx("span",{className:o,children:i}),s[2]=o,s[3]=i,s[4]=t):t=s[4];let r;return s[5]!==l||s[6]!==t?(r=e.jsxs("div",{className:"flex flex-col",children:[l,t]}),s[5]=l,s[6]=t,s[7]=r):r=s[7],r};export{R as A};
@@ -1 +1 @@
1
- import{a as l,j as e}from"./vendor-query-SzWcOU0G.js";import{c as B}from"./vendor-react-DvWIbVx0.js";import{O as G,P as I,R as f,T as z,_ as Y,u as J,t as Q,N as W,F as X,v as m,w as n,x as d,y as Z,z as c,D as $,E as ee,G as se,H as ae,K as p,I as j,J as re,d as oe,e as te,k as M}from"./index-BsU6riLP.js";import{S as ie}from"./StatusCard-DsxIEg0p.js";import{ay as le,az as me,q as F}from"./vendor-icons-CVrPjN2Q.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-misc-DBQ988Ev.js";import"./vendor-radix-BHmt2CkM.js";import"./vendor-markdown-CRou3yQ5.js";const R=[{label:"Gmail",value:"gmail"},{label:"Outlook / Office 365",value:"outlook"},{label:"Yahoo Mail",value:"yahoo"},{label:"iCloud Mail",value:"icloud"},{label:"ProtonMail (Bridge)",value:"protonmail"},{label:"Fastmail",value:"fastmail"},{label:"Custom / Self-hosted",value:"custom"}],ne={gmail:"Use an App Password from Google Account > Security > 2-Step Verification.",outlook:"Use your account password or an App Password.",yahoo:"Use an App Password from Yahoo Account Security.",icloud:"Use an App-Specific Password from your Apple ID.",protonmail:"Requires ProtonMail Bridge running locally (127.0.0.1).",fastmail:"Use an App Password from Settings > Privacy & Security.",custom:"Enter credentials for your self-hosted IMAP/SMTP server below."},de=R.map(u=>u.value);function ce(u){return G({provider:Y(de),address:f().min(1,"Email address is required").pipe(z("Enter a valid email address")),password:u?f().min(1,"Password is required"):f().optional(),imapHost:f().optional(),imapPort:I().int().min(1).max(65535).optional(),smtpHost:f().optional(),smtpPort:I().int().min(1).max(65535).optional()}).superRefine((x,o)=>{x.provider==="custom"&&(x.imapHost?.trim()||o.addIssue({code:"custom",path:["imapHost"],message:"IMAP host is required for custom provider"}),x.smtpHost?.trim()||o.addIssue({code:"custom",path:["smtpHost"],message:"SMTP host is required for custom provider"}))})}const T={provider:"gmail",address:"",password:"",imapHost:"",imapPort:993,smtpHost:"",smtpPort:465},we=({config:u,visible:x})=>{const{saveApiKey:o,getStoredApiKey:h,hasStoredKey:k,removeApiKey:t,isConnected:y}=J(),[i,v]=l.useState(!1),[S,_]=l.useState(""),[P,g]=l.useState(null),[N,w]=l.useState(null),[b,O]=l.useState(!1),U=l.useMemo(()=>ce(!i),[i]),r=B({resolver:Q(U),defaultValues:T,mode:"onSubmit"}),A=r.watch("provider");l.useEffect(()=>{if(!x||!y)return;let s=!1;return(async()=>{try{const[a,H,K,q,E,L,C]=await Promise.all([h("email_provider"),h("email_address"),k("email_password"),h("email_imap_host"),h("email_imap_port"),h("email_smtp_host"),h("email_smtp_port")]);if(s)return;r.reset({provider:a||"gmail",address:H||"",password:"",imapHost:q||"",imapPort:E?parseInt(E,10):993,smtpHost:L||"",smtpPort:C?parseInt(C,10):465}),_(H||""),v(K)}catch{s||v(!1)}})(),()=>{s=!0}},[x,y]);const V=async s=>{g("save"),w(null);try{await o("email_provider",s.provider),await o("email_address",s.address.trim()),s.password?.trim()&&await o("email_password",s.password.trim()),s.provider==="custom"&&(s.imapHost&&await o("email_imap_host",s.imapHost.trim()),s.imapPort!=null&&await o("email_imap_port",String(s.imapPort)),s.smtpHost&&await o("email_smtp_host",s.smtpHost.trim()),s.smtpPort!=null&&await o("email_smtp_port",String(s.smtpPort))),v(!0),_(s.address.trim()),r.setValue("password","")}catch(a){w(a.message||"Failed to save email credentials")}finally{g(null)}},D=async()=>{g("remove"),w(null);try{await Promise.all([t("email_password"),t("email_address"),t("email_provider"),t("email_imap_host"),t("email_imap_port"),t("email_smtp_host"),t("email_smtp_port")]),v(!1),_(""),r.reset(T)}catch(s){w(s.message||"Failed to remove credentials")}finally{g(null)}};return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 p-5",children:[e.jsx(ie,{icon:e.jsx(W,{icon:u.iconRef,className:"h-6 w-6 text-2xl"}),title:u.name,status:{stored:i,address:S},rows:[{label:"Status",ok:s=>s.stored,trueText:"Configured",falseText:"Not configured"},...i&&S?[{label:"Account",ok:()=>!0,trueText:S,falseText:""}]:[]]}),e.jsx(X,{...r,children:e.jsxs("form",{id:"email-form",onSubmit:r.handleSubmit(V),className:"flex flex-col gap-4",children:[e.jsx(m,{control:r.control,name:"provider",render:({field:s})=>e.jsxs(n,{children:[e.jsx(d,{children:"Provider"}),e.jsxs(Z,{value:s.value,onValueChange:s.onChange,children:[e.jsx(c,{children:e.jsx($,{children:e.jsx(ee,{placeholder:"Choose a provider"})})}),e.jsx(se,{children:R.map(a=>e.jsx(ae,{value:a.value,children:a.label},a.value))})]}),e.jsx(p,{})]})}),e.jsx(m,{control:r.control,name:"address",render:({field:s})=>e.jsxs(n,{children:[e.jsx(d,{children:"Email Address"}),e.jsx(c,{children:e.jsx(j,{placeholder:"you@example.com",...s})}),e.jsx(p,{})]})}),e.jsx(m,{control:r.control,name:"password",render:({field:s})=>e.jsxs(n,{children:[e.jsxs(d,{className:"flex items-center gap-2",children:["Password",i&&e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(leave blank to keep existing)"})]}),e.jsx(c,{children:e.jsxs("div",{className:"relative",children:[e.jsx(j,{type:b?"text":"password",placeholder:i?"••••••••":"App password or account password",className:"font-mono pr-9",...s}),e.jsx("button",{type:"button",onClick:()=>O(a=>!a),className:"absolute top-1/2 right-2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":b?"Hide password":"Show password",children:b?e.jsx(le,{className:"h-4 w-4"}):e.jsx(me,{className:"h-4 w-4"})})]})}),e.jsx(re,{children:ne[A]}),e.jsx(p,{})]})}),A==="custom"&&e.jsxs("div",{className:"rounded-md border border-border bg-muted p-3",children:[e.jsx("div",{className:"mb-3 text-sm font-medium",children:"Custom IMAP / SMTP"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(m,{control:r.control,name:"imapHost",render:({field:s})=>e.jsxs(n,{className:"flex-[2]",children:[e.jsx(d,{children:"IMAP Host"}),e.jsx(c,{children:e.jsx(j,{placeholder:"imap.example.com",...s})}),e.jsx(p,{})]})}),e.jsx(m,{control:r.control,name:"imapPort",render:({field:s})=>e.jsxs(n,{className:"flex-1",children:[e.jsx(d,{children:"IMAP Port"}),e.jsx(c,{children:e.jsx(j,{type:"number",min:1,max:65535,...s,value:s.value??"",onChange:a=>s.onChange(a.target.value===""?void 0:Number(a.target.value))})}),e.jsx(p,{})]})})]}),e.jsxs("div",{className:"mt-3 flex gap-3",children:[e.jsx(m,{control:r.control,name:"smtpHost",render:({field:s})=>e.jsxs(n,{className:"flex-[2]",children:[e.jsx(d,{children:"SMTP Host"}),e.jsx(c,{children:e.jsx(j,{placeholder:"smtp.example.com",...s})}),e.jsx(p,{})]})}),e.jsx(m,{control:r.control,name:"smtpPort",render:({field:s})=>e.jsxs(n,{className:"flex-1",children:[e.jsx(d,{children:"SMTP Port"}),e.jsx(c,{children:e.jsx(j,{type:"number",min:1,max:65535,...s,value:s.value??"",onChange:a=>s.onChange(a.target.value===""?void 0:Number(a.target.value))})}),e.jsx(p,{})]})})]})]})]})}),N&&e.jsx(oe,{variant:"destructive",children:e.jsx(te,{children:N})}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex justify-center gap-2 border-t border-border pt-3",children:[e.jsxs(M,{intent:"save",type:"submit",form:"email-form",disabled:P==="save",children:[P==="save"&&e.jsx(F,{className:"h-4 w-4 animate-spin"}),"Save"]}),i&&e.jsxs(M,{intent:"stop",type:"button",onClick:D,disabled:P==="remove",children:[P==="remove"&&e.jsx(F,{className:"h-4 w-4 animate-spin"}),"Remove"]})]})]})};export{we as default};
1
+ import{a as l,j as e}from"./vendor-query-SzWcOU0G.js";import{c as B}from"./vendor-react-DvWIbVx0.js";import{O as G,P as I,R as f,T as Y,_ as z,u as J,t as Q,N as W,F as X,v as m,w as n,x as d,y as Z,z as c,D as $,E as ee,G as se,H as ae,K as p,I as j,J as re,d as oe,e as te,k as M}from"./index-CyQ67hhw.js";import{S as ie}from"./StatusCard-kHLR8lx_.js";import{aC as le,aD as me,s as F}from"./vendor-icons-D3wxn0N1.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-misc-DBQ988Ev.js";import"./vendor-radix-BHmt2CkM.js";import"./vendor-markdown-CRou3yQ5.js";const R=[{label:"Gmail",value:"gmail"},{label:"Outlook / Office 365",value:"outlook"},{label:"Yahoo Mail",value:"yahoo"},{label:"iCloud Mail",value:"icloud"},{label:"ProtonMail (Bridge)",value:"protonmail"},{label:"Fastmail",value:"fastmail"},{label:"Custom / Self-hosted",value:"custom"}],ne={gmail:"Use an App Password from Google Account > Security > 2-Step Verification.",outlook:"Use your account password or an App Password.",yahoo:"Use an App Password from Yahoo Account Security.",icloud:"Use an App-Specific Password from your Apple ID.",protonmail:"Requires ProtonMail Bridge running locally (127.0.0.1).",fastmail:"Use an App Password from Settings > Privacy & Security.",custom:"Enter credentials for your self-hosted IMAP/SMTP server below."},de=R.map(u=>u.value);function ce(u){return G({provider:z(de),address:f().min(1,"Email address is required").pipe(Y("Enter a valid email address")),password:u?f().min(1,"Password is required"):f().optional(),imapHost:f().optional(),imapPort:I().int().min(1).max(65535).optional(),smtpHost:f().optional(),smtpPort:I().int().min(1).max(65535).optional()}).superRefine((x,o)=>{x.provider==="custom"&&(x.imapHost?.trim()||o.addIssue({code:"custom",path:["imapHost"],message:"IMAP host is required for custom provider"}),x.smtpHost?.trim()||o.addIssue({code:"custom",path:["smtpHost"],message:"SMTP host is required for custom provider"}))})}const T={provider:"gmail",address:"",password:"",imapHost:"",imapPort:993,smtpHost:"",smtpPort:465},we=({config:u,visible:x})=>{const{saveApiKey:o,getStoredApiKey:h,hasStoredKey:k,removeApiKey:t,isConnected:y}=J(),[i,v]=l.useState(!1),[S,_]=l.useState(""),[P,g]=l.useState(null),[N,w]=l.useState(null),[b,O]=l.useState(!1),U=l.useMemo(()=>ce(!i),[i]),r=B({resolver:Q(U),defaultValues:T,mode:"onSubmit"}),A=r.watch("provider");l.useEffect(()=>{if(!x||!y)return;let s=!1;return(async()=>{try{const[a,H,K,L,C,q,E]=await Promise.all([h("email_provider"),h("email_address"),k("email_password"),h("email_imap_host"),h("email_imap_port"),h("email_smtp_host"),h("email_smtp_port")]);if(s)return;r.reset({provider:a||"gmail",address:H||"",password:"",imapHost:L||"",imapPort:C?parseInt(C,10):993,smtpHost:q||"",smtpPort:E?parseInt(E,10):465}),_(H||""),v(K)}catch{s||v(!1)}})(),()=>{s=!0}},[x,y]);const V=async s=>{g("save"),w(null);try{await o("email_provider",s.provider),await o("email_address",s.address.trim()),s.password?.trim()&&await o("email_password",s.password.trim()),s.provider==="custom"&&(s.imapHost&&await o("email_imap_host",s.imapHost.trim()),s.imapPort!=null&&await o("email_imap_port",String(s.imapPort)),s.smtpHost&&await o("email_smtp_host",s.smtpHost.trim()),s.smtpPort!=null&&await o("email_smtp_port",String(s.smtpPort))),v(!0),_(s.address.trim()),r.setValue("password","")}catch(a){w(a.message||"Failed to save email credentials")}finally{g(null)}},D=async()=>{g("remove"),w(null);try{await Promise.all([t("email_password"),t("email_address"),t("email_provider"),t("email_imap_host"),t("email_imap_port"),t("email_smtp_host"),t("email_smtp_port")]),v(!1),_(""),r.reset(T)}catch(s){w(s.message||"Failed to remove credentials")}finally{g(null)}};return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 p-5",children:[e.jsx(ie,{icon:e.jsx(W,{icon:u.iconRef,className:"h-6 w-6 text-2xl"}),title:u.name,status:{stored:i,address:S},rows:[{label:"Status",ok:s=>s.stored,trueText:"Configured",falseText:"Not configured"},...i&&S?[{label:"Account",ok:()=>!0,trueText:S,falseText:""}]:[]]}),e.jsx(X,{...r,children:e.jsxs("form",{id:"email-form",onSubmit:r.handleSubmit(V),className:"flex flex-col gap-4",children:[e.jsx(m,{control:r.control,name:"provider",render:({field:s})=>e.jsxs(n,{children:[e.jsx(d,{children:"Provider"}),e.jsxs(Z,{value:s.value,onValueChange:s.onChange,children:[e.jsx(c,{children:e.jsx($,{children:e.jsx(ee,{placeholder:"Choose a provider"})})}),e.jsx(se,{children:R.map(a=>e.jsx(ae,{value:a.value,children:a.label},a.value))})]}),e.jsx(p,{})]})}),e.jsx(m,{control:r.control,name:"address",render:({field:s})=>e.jsxs(n,{children:[e.jsx(d,{children:"Email Address"}),e.jsx(c,{children:e.jsx(j,{placeholder:"you@example.com",...s})}),e.jsx(p,{})]})}),e.jsx(m,{control:r.control,name:"password",render:({field:s})=>e.jsxs(n,{children:[e.jsxs(d,{className:"flex items-center gap-2",children:["Password",i&&e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(leave blank to keep existing)"})]}),e.jsx(c,{children:e.jsxs("div",{className:"relative",children:[e.jsx(j,{type:b?"text":"password",placeholder:i?"••••••••":"App password or account password",className:"font-mono pr-9",...s}),e.jsx("button",{type:"button",onClick:()=>O(a=>!a),className:"absolute top-1/2 right-2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":b?"Hide password":"Show password",children:b?e.jsx(le,{className:"h-4 w-4"}):e.jsx(me,{className:"h-4 w-4"})})]})}),e.jsx(re,{children:ne[A]}),e.jsx(p,{})]})}),A==="custom"&&e.jsxs("div",{className:"rounded-md border border-border bg-muted p-3",children:[e.jsx("div",{className:"mb-3 text-sm font-medium",children:"Custom IMAP / SMTP"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(m,{control:r.control,name:"imapHost",render:({field:s})=>e.jsxs(n,{className:"flex-[2]",children:[e.jsx(d,{children:"IMAP Host"}),e.jsx(c,{children:e.jsx(j,{placeholder:"imap.example.com",...s})}),e.jsx(p,{})]})}),e.jsx(m,{control:r.control,name:"imapPort",render:({field:s})=>e.jsxs(n,{className:"flex-1",children:[e.jsx(d,{children:"IMAP Port"}),e.jsx(c,{children:e.jsx(j,{type:"number",min:1,max:65535,...s,value:s.value??"",onChange:a=>s.onChange(a.target.value===""?void 0:Number(a.target.value))})}),e.jsx(p,{})]})})]}),e.jsxs("div",{className:"mt-3 flex gap-3",children:[e.jsx(m,{control:r.control,name:"smtpHost",render:({field:s})=>e.jsxs(n,{className:"flex-[2]",children:[e.jsx(d,{children:"SMTP Host"}),e.jsx(c,{children:e.jsx(j,{placeholder:"smtp.example.com",...s})}),e.jsx(p,{})]})}),e.jsx(m,{control:r.control,name:"smtpPort",render:({field:s})=>e.jsxs(n,{className:"flex-1",children:[e.jsx(d,{children:"SMTP Port"}),e.jsx(c,{children:e.jsx(j,{type:"number",min:1,max:65535,...s,value:s.value??"",onChange:a=>s.onChange(a.target.value===""?void 0:Number(a.target.value))})}),e.jsx(p,{})]})})]})]})]})}),N&&e.jsx(oe,{variant:"destructive",children:e.jsx(te,{children:N})}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex justify-center gap-2 border-t border-border pt-3",children:[e.jsxs(M,{intent:"save",type:"submit",form:"email-form",disabled:P==="save",children:[P==="save"&&e.jsx(F,{className:"h-4 w-4 animate-spin"}),"Save"]}),i&&e.jsxs(M,{intent:"stop",type:"button",onClick:D,disabled:P==="remove",children:[P==="remove"&&e.jsx(F,{className:"h-4 w-4 animate-spin"}),"Remove"]})]})]})};export{we as default};
@@ -0,0 +1 @@
1
+ import{j as l,a as I}from"./vendor-query-SzWcOU0G.js";import{f as O,L as P,I as B,k as H,d as z,e as Y,N as G}from"./index-CyQ67hhw.js";import{u as J}from"./RateLimitSection-BpJMUqlB.js";import{A as K,u as M}from"./ActionBar-D7ffu8J-.js";import{aC as Q,aD as W,s as X,R as Z}from"./vendor-icons-D3wxn0N1.js";import{S as ee}from"./StatusCard-kHLR8lx_.js";import{A as te}from"./ApiUsageSection-DcCBizXU.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-misc-DBQ988Ev.js";import"./vendor-radix-BHmt2CkM.js";import"./vendor-markdown-CRou3yQ5.js";import"./vendor-react-DvWIbVx0.js";const se=n=>{const e=O.c(7),{fields:s,form:c}=n;let t;if(e[0]!==s||e[1]!==c){let i;e[3]!==c?(i=a=>l.jsx(le,{field:a,form:c},a.key),e[3]=c,e[4]=i):i=e[4],t=s.map(i),e[0]=s,e[1]=c,e[2]=t}else t=e[2];let o;return e[5]!==t?(o=l.jsx("div",{className:"flex w-full flex-col gap-3",children:t}),e[5]=t,e[6]=o):o=e[6],o},le=({field:n,form:e})=>{const[s,c]=I.useState(!1),t=e.getFieldValue(n.key)??"",[o,i]=I.useState(t),a=!!n.secret;return I.useEffect(()=>{!o&&t&&i(t)},[t]),l.jsxs("div",{className:"grid gap-1.5",children:[l.jsxs(P,{htmlFor:`field-${n.key}`,className:"text-xs",children:[n.label,n.required&&l.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),l.jsxs("div",{className:"relative",children:[l.jsx(B,{id:`field-${n.key}`,type:a&&!s?"password":"text",value:o,onChange:r=>{const d=r.target.value;i(d),e.setFieldValue(n.key,d)},placeholder:n.placeholder,className:a?"font-mono pr-9":"font-mono"}),a&&l.jsx("button",{type:"button",onClick:()=>c(r=>!r),className:"absolute top-1/2 right-2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":s?"Hide value":"Show value",children:s?l.jsx(Q,{className:"h-4 w-4"}):l.jsx(W,{className:"h-4 w-4"})})]})]})},oe=n=>{const e=O.c(57),{config:s,form:c,connected:t,stored:o,loading:i,error:a,verificationCode:r,icon:d,onSaveCredentials:m,onLogin:u,onLogout:x,onRefresh:v,extraSection:p}=n,h=!!s.fields?.some(ae);let f;e[0]!==t?(f={label:"Status",ok:()=>t,trueText:"Connected",falseText:"Not Connected"},e[0]=t,e[1]=f):f=e[1];let g;e[2]!==h||e[3]!==o?(g=h?[{label:"Credentials",ok:()=>o,trueText:"Configured",falseText:"Not configured"}]:[],e[2]=h,e[3]=o,e[4]=g):g=e[4];let L;e[5]!==f||e[6]!==g?(L=[f,...g],e[5]=f,e[6]=g,e[7]=L):L=e[7];const q=L,U=`Login with ${s.name}`,V=h&&!o;let j;e[8]!==t||e[9]!==u||e[10]!==U||e[11]!==V?(j={key:"login",label:U,intent:"save",onClick:u,disabled:V,hidden:t},e[8]=t,e[9]=u,e[10]=U,e[11]=V,e[12]=j):j=e[12];const T=!t;let b;e[13]!==x||e[14]!==T?(b={key:"logout",label:"Disconnect",intent:"stop",onClick:x,hidden:T},e[13]=x,e[14]=T,e[15]=b):b=e[15];let _;e[16]===Symbol.for("react.memo_cache_sentinel")?(_=l.jsx(Z,{className:"h-4 w-4"}),e[16]=_):_=e[16];let k;e[17]!==v?(k={key:"refresh",label:"Refresh",intent:"save",onClick:v,icon:_},e[17]=v,e[18]=k):k=e[18];let A;e[19]!==k||e[20]!==j||e[21]!==b?(A=[j,b,k],e[19]=k,e[20]=j,e[21]=b,e[22]=A):A=e[22];const D=A,E=i==="save";let C;e[23]!==s.name||e[24]!==d||e[25]!==q?(C=l.jsx(ee,{icon:d,title:s.name,rows:q,status:null}),e[23]=s.name,e[24]=d,e[25]=q,e[26]=C):C=e[26];let N;e[27]!==s.callbackUrl||e[28]!==s.fields||e[29]!==s.instructions||e[30]!==t||e[31]!==c||e[32]!==E||e[33]!==m?(N=!t&&s.fields&&l.jsxs("div",{className:"flex w-full flex-col gap-3",children:[l.jsx(se,{fields:s.fields,form:c}),l.jsxs(H,{intent:"secret",onClick:m,disabled:E,children:[E&&l.jsx(X,{className:"h-4 w-4 animate-spin"}),"Save Credentials"]}),s.instructions&&l.jsxs("div",{className:"text-xs leading-relaxed text-muted-foreground",children:[s.instructions,s.callbackUrl&&l.jsxs(l.Fragment,{children:[l.jsx("br",{}),"Callback URL:"," ",l.jsx("code",{className:"text-accent",children:s.callbackUrl})]})]})]}),e[27]=s.callbackUrl,e[28]=s.fields,e[29]=s.instructions,e[30]=t,e[31]=c,e[32]=E,e[33]=m,e[34]=N):N=e[34];let S;e[35]!==a?(S=a&&l.jsx(z,{variant:"destructive",children:l.jsx(Y,{children:a})}),e[35]=a,e[36]=S):S=e[36];let y;e[37]!==s.account_label||e[38]!==s.name||e[39]!==t||e[40]!==h||e[41]!==o||e[42]!==r?(y=t?s.account_label?`Connected as ${s.account_label}.`:`Your ${s.name} account is connected.`:r?l.jsxs("div",{className:"flex flex-col items-center gap-2 py-1 text-center",children:[l.jsx("span",{children:"Enter this one-time code in the browser tab that just opened:"}),l.jsx("code",{className:"select-all font-mono text-3xl font-bold tracking-[0.25em] text-accent",children:r}),l.jsx("span",{className:"text-xs",children:"Click the code to select it, then approve the request to finish connecting."})]}):o||!h?"Click Login to authorize.":"Enter your credentials above to get started.",e[37]=s.account_label,e[38]=s.name,e[39]=t,e[40]=h,e[41]=o,e[42]=r,e[43]=y):y=e[43];let R;e[44]!==y?(R=l.jsx("div",{className:"rounded-md border border-accent/30 bg-accent/10 p-3",children:l.jsx("div",{className:"text-sm leading-relaxed text-muted-foreground",children:y})}),e[44]=y,e[45]=R):R=e[45];let F;e[46]===Symbol.for("react.memo_cache_sentinel")?(F=l.jsx("div",{className:"flex-1"}),e[46]=F):F=e[46];let w;e[47]!==D||e[48]!==i?(w=l.jsx(K,{actions:D,loading:i}),e[47]=D,e[48]=i,e[49]=w):w=e[49];let $;return e[50]!==p||e[51]!==C||e[52]!==N||e[53]!==S||e[54]!==R||e[55]!==w?($=l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[C,N,S,R,p,F,w]}),e[50]=p,e[51]=C,e[52]=N,e[53]=S,e[54]=R,e[55]=w,e[56]=$):$=e[56],$};function ae(n){return n.required}const pe=n=>{const e=O.c(26),{config:s,visible:c}=n,t=J(s,c),o=M(s.statusHook),i=o?!!o.connected:!!s.stored;let a;e[0]!==s.iconRef?(a=l.jsx(G,{icon:s.iconRef,className:"h-6 w-6 text-2xl"}),e[0]=s.iconRef,e[1]=a):a=e[1];let r;e[2]!==s.fields||e[3]!==t?(r=()=>{const p=s.fields?.find(f=>f.required&&!t.form.getFieldValue(f.key)?.trim());if(p){t.setError(`${p.label} is required`);return}const h=t.form.getFieldsValue();t.execute("save",async()=>{for(const f of s.fields){const g=h[f.key]?.trim();g&&await t.actions.save(f.key,g)}return t.setStored(!0),{success:!0}})},e[2]=s.fields,e[3]=t,e[4]=r):r=e[4];let d,m,u;e[5]!==t.actions?(d=()=>t.actions.oauthLogin(),m=()=>t.actions.oauthLogout(),u=()=>t.actions.oauthRefresh(),e[5]=t.actions,e[6]=d,e[7]=m,e[8]=u):(d=e[6],m=e[7],u=e[8]);let x;e[9]!==s.name||e[10]!==s.usageService?(x=s.usageService&&l.jsx(te,{service:s.usageService,serviceName:s.name}),e[9]=s.name,e[10]=s.usageService,e[11]=x):x=e[11];let v;return e[12]!==s||e[13]!==i||e[14]!==t.error||e[15]!==t.form||e[16]!==t.loading||e[17]!==t.stored||e[18]!==t.verificationCode||e[19]!==a||e[20]!==r||e[21]!==d||e[22]!==m||e[23]!==u||e[24]!==x?(v=l.jsx("div",{className:"flex min-h-0 flex-1 flex-col p-5",children:l.jsx(oe,{config:s,form:t.form,connected:i,stored:t.stored,loading:t.loading,error:t.error,verificationCode:t.verificationCode,icon:a,onSaveCredentials:r,onLogin:d,onLogout:m,onRefresh:u,extraSection:x})}),e[12]=s,e[13]=i,e[14]=t.error,e[15]=t.form,e[16]=t.loading,e[17]=t.stored,e[18]=t.verificationCode,e[19]=a,e[20]=r,e[21]=d,e[22]=m,e[23]=u,e[24]=x,e[25]=v):v=e[25],v};export{pe as default};
@@ -0,0 +1 @@
1
+ import{j as e,a as d,R as b}from"./vendor-query-SzWcOU0G.js";import{d as S,l as k,e as _,m as w,N as v}from"./index-CyQ67hhw.js";import{A}from"./ApiKeyInput-Dpxo3mVb.js";import{Q as E}from"./vendor-misc-DBQ988Ev.js";import{x as W,s as F,aE as M,v as Q}from"./vendor-icons-D3wxn0N1.js";import{u as T,R as q}from"./RateLimitSection-BpJMUqlB.js";import{u as L,A as D}from"./ActionBar-D7ffu8J-.js";import{S as P}from"./StatusCard-kHLR8lx_.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-radix-BHmt2CkM.js";import"./vendor-markdown-CRou3yQ5.js";import"./vendor-react-DvWIbVx0.js";const V=t=>t.length<100?!1:t.startsWith("data:image/")||t.startsWith("iVBOR")||t.startsWith("/9j/")?!0:t.length>5e3?/^[A-Za-z0-9+/=]+$/.test(t):!1,B=({value:t,isConnected:c=!1,size:s=280,loading:a=!1,connectedTitle:u="Connected",connectedSubtitle:x="No QR code needed",emptyText:h="QR code not available"})=>{if(c)return e.jsxs("div",{className:"flex flex-col items-center gap-3 p-8 text-center",children:[e.jsx(W,{className:"h-10 w-10 text-success"}),e.jsx("div",{className:"text-base font-semibold",children:u}),e.jsx("div",{className:"text-sm text-muted-foreground",children:x})]});if(a)return e.jsxs("div",{className:"p-10 text-center",children:[e.jsx(F,{className:"mx-auto h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("div",{className:"mt-4 text-sm text-muted-foreground",children:"Waiting for QR code..."})]});if(!t)return e.jsxs("div",{className:"p-10 text-center text-muted-foreground",children:[e.jsx(M,{className:"mx-auto h-12 w-12 opacity-30"}),e.jsx("div",{className:"mt-4",children:h})]});if(V(t)){const o=t.startsWith("data:")?t:`data:image/png;base64,${t}`;return e.jsx("div",{className:"p-4 text-center",children:e.jsx("img",{src:o,alt:"QR Code",style:{width:s,height:s,imageRendering:"pixelated"}})})}return e.jsx(I,{value:t,size:s})},I=({value:t,size:c})=>{const[s,a]=d.useState(null);return d.useEffect(()=>{a(null)},[t]),s?e.jsx("div",{className:"p-6 text-center",children:e.jsxs(S,{variant:"warning",children:[e.jsx(Q,{className:"h-4 w-4"}),e.jsx(k,{children:"QR Code Error"}),e.jsx(_,{children:"The QR code data is too large to display. Please try refreshing or reconnecting."})]})}):e.jsx(G,{onError:u=>a(u),children:e.jsx("div",{className:"p-4 text-center",children:e.jsx(E,{value:t,size:c,level:"L"})})})};class G extends b.Component{constructor(c){super(c),this.state={hasError:!1}}static getDerivedStateFromError(c){return{hasError:!0}}componentDidCatch(c){console.error("[QRCodeDisplay] QR code rendering error:",c.message),this.props.onError(c.message)}render(){return this.state.hasError?e.jsx("div",{className:"p-6 text-center",children:e.jsxs(S,{variant:"warning",children:[e.jsx(Q,{className:"h-4 w-4"}),e.jsx(k,{children:"QR Code Error"}),e.jsx(_,{children:"The QR code data is too large to display. Please try refreshing or reconnecting."})]})}):this.props.children}}const H=()=>{const{getWhatsAppStatus:t,getWhatsAppQR:c,sendWhatsAppMessage:s,startWhatsAppConnection:a,restartWhatsAppConnection:u,isConnected:x}=w(),[h,o]=d.useState(!1),[j,n]=d.useState(null),[p,y]=d.useState(null),m=d.useCallback(async()=>{o(!0),n(null);try{const r=await t();return y(r),r}catch(r){const l=r.message||"Failed to get status";return n(l),{connected:!1}}finally{o(!1)}},[t]),C=d.useCallback(async()=>{o(!0),n(null);try{const r=await c();return r.connected&&y({connected:!0}),r}catch(r){const l=r.message||"Failed to get QR code";return n(l),{connected:!1,message:l}}finally{o(!1)}},[c]),R=d.useCallback(async(r,l)=>{o(!0),n(null);try{const f=await s(r,l);return!f.success&&f.error&&n(f.error),f}catch(f){const N=f.message||"Failed to send message";return n(N),{success:!1,error:N}}finally{o(!1)}},[s]),i=d.useCallback(async()=>{o(!0),n(null);try{const r=await a();return!r.success&&r.message&&n(r.message),r}catch(r){const l=r.message||"Failed to start connection";return n(l),{success:!1,message:l}}finally{o(!1)}},[a]),g=d.useCallback(async()=>{o(!0),n(null);try{const r=await u();return!r.success&&r.message&&n(r.message),r}catch(r){const l=r.message||"Failed to restart connection";return n(l),{success:!1,message:l}}finally{o(!1)}},[u]);return{getStatus:m,getQRCode:C,sendMessage:R,startConnection:i,restartConnection:g,isLoading:h,lastError:j,connectionStatus:p,isConnected:x}},re=({config:t,visible:c})=>{const s=T(t,c),a=L(t.statusHook),{startConnection:u,restartConnection:x,getStatus:h}=H(),{sendRequest:o,setAndroidStatus:j}=w(),n=t.qr,p=n.isConnected(a),y=a?.[n.qrField],m=t.fields?.[0],C=d.useMemo(()=>({start:()=>s.execute("start",u),restart:()=>s.execute("restart",x),refresh:()=>s.execute("refresh",h),connect:()=>s.execute("connect",async()=>{const i=s.form.getFieldValue("android_remote")?.trim();if(!i){s.setError("No API key configured");return}const g=await o("android_relay_connect",{url:"",api_key:i});return g.qr_data&&j(r=>({...r,connected:!0,paired:!1,qr_data:g.qr_data,session_token:g.session_token||r.session_token})),g}),disconnect:()=>s.execute("disconnect",()=>o("android_relay_disconnect",{}))}),[s,u,x,h,o,j]),R=(t.actions??[]).map(i=>({key:i.key,label:i.label,intent:i.intent,onClick:C[i.key]??(()=>{}),hidden:i.hidden?.(a,s.stored),disabled:i.disabled?.(a,s.stored)}));return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 p-5",children:[m&&e.jsx(A,{value:s.form.getFieldValue(m.key)||"",onChange:i=>s.form.setFieldValue(m.key,i),onSave:()=>s.actions.save(m.key,(s.form.getFieldValue(m.key)??"").trim()).then(()=>s.setStored(!0)),onDelete:()=>s.actions.remove(m.key),placeholder:m.placeholder,loading:s.loading==="save",isStored:s.stored}),t.statusRows&&e.jsx(P,{icon:e.jsx(v,{icon:t.iconRef,className:"h-6 w-6 text-2xl"}),title:t.name,rows:t.statusRows,status:a}),e.jsxs("div",{className:"flex min-h-[300px] flex-1 flex-col items-center justify-center rounded-lg bg-muted p-5",children:[e.jsx(B,{value:y,isConnected:p,size:280,connectedTitle:n.connectedTitle,connectedSubtitle:n.connectedSubtitle(a),loading:n.isLoading(a),emptyText:n.emptyText(a,s.stored)}),!p&&y&&e.jsx("div",{className:"mt-3 text-sm text-muted-foreground",children:n.scanText})]}),t.hasRateLimits&&p&&e.jsx(q,{}),s.error&&e.jsx(S,{variant:"destructive",children:e.jsx(_,{children:s.error})}),e.jsx(D,{actions:R,loading:s.loading})]})};export{re as default};
@@ -0,0 +1 @@
1
+ import{d as ge,a as r,u as ye,j as e}from"./vendor-query-SzWcOU0G.js";import{u as oe,m as ne,s as Y,S as _e,t as ie,A as ce,a as de,b as ue,c as me,F as xe,v as _,w as S,x as C,y as X,z as k,D as Z,E as I,G as ee,H as Q,J as A,K as U,g as W,I as z,M as se,B as ae,O as he,_ as le,P as w,Q as G,R as ve,d as be,e as we,f as Se}from"./index-CyQ67hhw.js";import{c as fe}from"./vendor-react-DvWIbVx0.js";import{S as Ce,s as pe}from"./vendor-icons-D3wxn0N1.js";const J={};function Ke(n,o){const m=ge(),[x,p]=r.useState(null),[y,l]=r.useState(null),[F,v]=r.useState(!1),[d,j]=r.useState(null);r.useEffect(()=>{l(null),p(null),v(!1),j(null)},[n.id]);const{validateApiKey:E,saveApiKey:L,removeApiKey:M,getProviderDefaults:i,saveProviderDefaults:a,getProviderUsageSummary:c,getAPIUsageSummary:g,getStoredModels:q,getModelConstraints:O,isConnected:T}=oe(),{sendRequest:b}=ne(),V=ye({queryKey:Y.credentialValues.byProvider(n.id).queryKey,queryFn:async()=>{if(!n.fields)return{values:J,hadStored:!1};const t=await Promise.all(n.fields.map(async D=>{const je=D.key==="apiKey"?n.id:D.key,te=await b("get_stored_api_key",{provider:je});return{key:D.key,hasKey:te.hasKey,apiKey:te.apiKey}})),f={};let u=!1;for(const D of t)D.apiKey&&(f[D.key]=D.apiKey),D.hasKey&&(u=!0);return{values:f,hadStored:u}},enabled:o&&T&&!!n.fields,staleTime:_e.FOREVER}),R=V.data?.values??J,B=r.useRef(R);B.current=R;const P=n.id,s=r.useCallback(t=>{m.setQueryData(Y.credentialValues.byProvider(P).queryKey,f=>({values:t(f?.values??J),hadStored:f?.hadStored??!1}))},[m,P]),h=r.useMemo(()=>({getFieldValue:t=>B.current[t],getFieldsValue:()=>({...B.current}),setFieldValue:(t,f)=>{s(u=>({...u,[t]:f}))},setFieldsValue:t=>{s(f=>({...f,...t}))},resetFields:()=>s(()=>J)}),[s]);(V.data?.hadStored??!1)&&!F&&v(!0);const N=r.useCallback(async(t,f)=>{p(t),l(null);try{const u=await f();return u&&!u.success&&u.error&&l(u.error),u}catch(u){l(u.message||`Failed: ${t}`);return}finally{p(null)}},[]),H=r.useCallback(()=>m.invalidateQueries({queryKey:Y.credentialValues.byProvider(P).queryKey}),[m,P]);return{form:h,values:R,loading:x,error:y,stored:F,setStored:v,setError:l,verificationCode:d,execute:N,actions:{validate:(t,f)=>N("validate",async()=>{const u=await E(t,f);return u?.isValid&&(v(!0),await H()),u}),save:(t,f)=>N("save",async()=>{const u=await L(t,f);return u?.isValid&&(v(!0),await H()),u}),remove:t=>N("remove",async()=>{await M(t),v(!1),await H()}),oauthLogin:()=>N("login",async()=>{const t=await b(n.ws.login,{});return j(t.success?t.verification_code??null:null),t.success&&t.url&&window.open(t.url,"_blank"),t}),oauthLogout:()=>N("logout",async()=>(j(null),b(n.ws.logout,{}))),oauthRefresh:()=>N("refresh",()=>b(n.ws.status,{})),sendWs:(t,f)=>N(t,()=>b(t,f??{}))},isConnected:T,getProviderDefaults:i,saveProviderDefaults:a,getProviderUsageSummary:c,getAPIUsageSummary:g,getStoredModels:q,getModelConstraints:O}}const ke=he({default_model:ve().optional().default(""),temperature:w().optional(),max_tokens:w().int().min(1).optional(),thinking_enabled:G().optional().default(!1),thinking_budget:w().int().min(1024).max(16e3).optional(),reasoning_effort:le(["low","medium","high"]).optional(),reasoning_format:le(["parsed","hidden"]).optional()}),De=({providerId:n})=>{const{getProviderDefaults:o,saveProviderDefaults:m,getValidatedAiProviders:x,getModelConstraints:p}=oe(),{apiKeyStatuses:y,isReady:l}=ne(),F=y[n],[v,d]=r.useState([]),[j,E]=r.useState(null),[L,M]=r.useState(!1),i=fe({resolver:ie(ke),defaultValues:{}}),a=i.watch("default_model"),c=i.watch("thinking_enabled"),{isDirty:g}=i.formState;r.useEffect(()=>{if(!l)return;let s=!1;return(async()=>{M(!0);try{const h=await o(n);s||i.reset(h??{})}finally{s||M(!1)}})(),()=>{s=!0}},[n,l]),r.useEffect(()=>{if(!l)return;d([]),E(null);let s=!1;return x().then(h=>{if(s)return;const K=h.providers.find(H=>H.provider===n),N=K?K.models.length?K.models:K.popular_models:[];d(N)}),()=>{s=!0}},[n,l,F]),r.useEffect(()=>{if(!l||!a)return;let s=!1;return p(a,n).then(h=>{s||(E(h),h?.max_output_tokens&&i.getValues("max_tokens")!==h.max_output_tokens&&i.setValue("max_tokens",h.max_output_tokens,{shouldDirty:!1}))}),()=>{s=!0}},[a,n,l]);const q=r.useCallback(async s=>{M(!0);try{await m(n,s)&&i.reset(s)}finally{M(!1)}},[n,m,i]),[O,T]=j?.temperature_range??[0,2],b=j?.max_output_tokens,V=j?.thinking_type,R=j?.supports_thinking,B=j?.is_reasoning_model&&O===T,P=s=>h=>{const K=h.target.value;s.onChange(K===""?void 0:Number(K))};return e.jsx(ce,{type:"single",collapsible:!0,defaultValue:"defaults",children:e.jsxs(de,{value:"defaults",children:[e.jsx(ue,{children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"h-4 w-4"})," Default Parameters"]})}),e.jsx(me,{children:e.jsx("div",{className:L?"pointer-events-none opacity-60":"",children:e.jsx(xe,{...i,children:e.jsxs("form",{id:`provider-defaults-form-${n}`,onSubmit:i.handleSubmit(q),className:"flex flex-col gap-3",children:[e.jsx(_,{control:i.control,name:"default_model",render:({field:s})=>e.jsxs(S,{children:[e.jsx(C,{children:"Default Model"}),e.jsxs(X,{value:s.value??"",onValueChange:s.onChange,children:[e.jsx(k,{children:e.jsx(Z,{children:e.jsx(I,{placeholder:v.length?"Select model":"Validate API key first"})})}),e.jsx(ee,{children:v.map(h=>e.jsx(Q,{value:h,children:h},h))})]}),e.jsx(A,{children:"Model used when none specified"}),e.jsx(U,{})]})}),j&&e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[b!=null&&e.jsxs(W,{variant:"success",children:["Max Output: ",b.toLocaleString()]}),j.context_length!=null&&e.jsxs(W,{variant:"info",children:["Context: ",j.context_length.toLocaleString()]}),e.jsxs(W,{variant:"secondary",children:["Temp: ",O,"-",T]}),R&&e.jsxs(W,{variant:"warning",children:["Thinking: ",V]}),j.is_reasoning_model&&e.jsx(W,{variant:"outline",children:"Reasoning"})]}),!B&&e.jsx(_,{control:i.control,name:"temperature",render:({field:s})=>e.jsxs(S,{children:[e.jsx(C,{children:"Temperature"}),e.jsx(k,{children:e.jsx(z,{type:"number",min:O,max:T,step:.1,className:"w-24",value:s.value??"",onChange:P(s)})}),e.jsxs(A,{children:["Controls randomness (",O,"-",T,")"]}),e.jsx(U,{})]})}),e.jsx(_,{control:i.control,name:"max_tokens",render:({field:s})=>e.jsxs(S,{children:[e.jsx(C,{children:"Max Tokens"}),e.jsx(k,{children:e.jsx(z,{type:"number",min:1,max:b||void 0,className:"w-32",value:s.value??"",onChange:P(s)})}),e.jsx(A,{children:b!=null?`Up to ${b.toLocaleString()}`:"Maximum response length"}),e.jsx(U,{})]})}),R&&e.jsx(_,{control:i.control,name:"thinking_enabled",render:({field:s})=>e.jsxs(S,{className:"flex flex-row items-center justify-between rounded-md border border-border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{children:"Thinking / Reasoning"}),e.jsxs(A,{children:["Extended thinking (",V,")"]})]}),e.jsx(k,{children:e.jsx(se,{checked:!!s.value,onCheckedChange:s.onChange})})]})}),R&&V==="budget"&&c&&e.jsx(_,{control:i.control,name:"thinking_budget",render:({field:s})=>e.jsxs(S,{children:[e.jsx(C,{children:"Thinking Budget"}),e.jsx(k,{children:e.jsx(z,{type:"number",min:1024,max:16e3,className:"w-28",value:s.value??"",onChange:P(s)})}),e.jsx(A,{children:"Token budget (1024-16000)"}),e.jsx(U,{})]})}),R&&V==="effort"&&c&&e.jsx(_,{control:i.control,name:"reasoning_effort",render:({field:s})=>e.jsxs(S,{children:[e.jsx(C,{children:"Reasoning Effort"}),e.jsxs(X,{value:s.value??"",onValueChange:s.onChange,children:[e.jsx(k,{children:e.jsx(Z,{className:"w-32",children:e.jsx(I,{placeholder:"Select"})})}),e.jsxs(ee,{children:[e.jsx(Q,{value:"low",children:"Low"}),e.jsx(Q,{value:"medium",children:"Medium"}),e.jsx(Q,{value:"high",children:"High"})]})]}),e.jsx(A,{children:"Low, medium, or high"}),e.jsx(U,{})]})}),R&&V==="format"&&c&&e.jsx(_,{control:i.control,name:"reasoning_format",render:({field:s})=>e.jsxs(S,{children:[e.jsx(C,{children:"Reasoning Format"}),e.jsxs(X,{value:s.value??"",onValueChange:s.onChange,children:[e.jsx(k,{children:e.jsx(Z,{className:"w-32",children:e.jsx(I,{placeholder:"Select"})})}),e.jsxs(ee,{children:[e.jsx(Q,{value:"parsed",children:"Parsed"}),e.jsx(Q,{value:"hidden",children:"Hidden"})]})]}),e.jsx(A,{children:"Parsed or hidden"}),e.jsx(U,{})]})}),e.jsxs(ae,{type:"submit",disabled:!g||L,variant:g?"default":"outline",className:"w-full",children:[L&&e.jsx(pe,{className:"h-4 w-4 animate-spin"}),"Save Defaults"]})]})})})})]})})},Ne=he({enabled:G().default(!1),min_delay_ms:w().int().min(0).optional(),max_delay_ms:w().int().min(0).optional(),typing_delay_ms:w().int().min(0).optional(),link_extra_delay_ms:w().int().min(0).optional(),max_messages_per_minute:w().int().min(0).optional(),max_messages_per_hour:w().int().min(0).optional(),max_new_contacts_per_day:w().int().min(0).optional(),simulate_typing:G().optional(),randomize_delays:G().optional(),pause_on_low_response:G().optional(),response_rate_threshold:w().min(0).max(1).optional()}),$=n=>{const o=Se.c(7),{label:m,value:x}=n;let p;o[0]!==m?(p=e.jsx("span",{className:"text-xs text-muted-foreground",children:m}),o[0]=m,o[1]=p):p=o[1];let y;o[2]!==x?(y=e.jsx("span",{className:"text-lg font-semibold",children:x}),o[2]=x,o[3]=y):y=o[3];let l;return o[4]!==p||o[5]!==y?(l=e.jsxs("div",{className:"flex flex-col",children:[p,y]}),o[4]=p,o[5]=y,o[6]=l):l=o[6],l},re=n=>o=>{const m=o.target.value;n.onChange(m===""?void 0:Number(m))},Ae=()=>{const{getWhatsAppRateLimitConfig:n,setWhatsAppRateLimitConfig:o,unpauseWhatsAppRateLimit:m}=ne(),[x,p]=r.useState(null),[y,l]=r.useState(!1),[F,v]=r.useState(!1),d=fe({resolver:ie(Ne),defaultValues:{enabled:!1}}),j=d.watch("pause_on_low_response"),{isDirty:E}=d.formState,L=r.useCallback(async()=>{l(!0);try{const a=await n();a.success&&a.config&&(d.reset(a.config),p(a.stats??null),v(!0))}finally{l(!1)}},[d,n]);r.useEffect(()=>{L()},[L]);const M=r.useCallback(async a=>{l(!0);try{const c=await o(a);c.success&&c.config&&d.reset(c.config)}finally{l(!1)}},[d,o]),i=r.useCallback(async()=>{l(!0);try{const a=await m();a.success&&a.stats&&p(a.stats)}finally{l(!1)}},[m]);return e.jsx(ce,{type:"single",collapsible:!0,children:e.jsxs(de,{value:"ratelimits",children:[e.jsx(ue,{children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[e.jsx("span",{children:"Rate Limits"}),e.jsx(_,{control:d.control,name:"enabled",render:({field:a})=>e.jsx("span",{onClick:c=>c.stopPropagation(),children:e.jsx(se,{checked:!!a.value,onCheckedChange:a.onChange})})})]})}),e.jsx(me,{children:F?e.jsx(xe,{...d,children:e.jsxs("form",{onSubmit:d.handleSubmit(M),className:"flex flex-col gap-3",children:[x&&e.jsxs("div",{className:"mb-3 flex flex-wrap gap-4",children:[e.jsx($,{label:"Last Minute",value:x.messages_sent_last_minute}),e.jsx($,{label:"Last Hour",value:x.messages_sent_last_hour}),e.jsx($,{label:"Today",value:x.messages_sent_today}),e.jsx($,{label:"New Contacts",value:x.new_contacts_today}),e.jsx($,{label:"Responses",value:x.responses_received}),e.jsx($,{label:"Response Rate",value:`${Math.round((x.response_rate||0)*100)}%`})]}),x?.is_paused&&e.jsx(be,{variant:"warning",children:e.jsxs(we,{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:x.pause_reason||"Paused"}),e.jsx(ae,{size:"sm",variant:"outline",type:"button",onClick:i,children:"Unpause"})]})}),e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Message Delays (milliseconds)"}),e.jsx("div",{className:"flex flex-wrap gap-3",children:[["min_delay_ms","Min Delay"],["max_delay_ms","Max Delay"],["typing_delay_ms","Typing Duration"],["link_extra_delay_ms","Link Extra Delay"]].map(([a,c])=>e.jsx(_,{control:d.control,name:a,render:({field:g})=>e.jsxs(S,{children:[e.jsx(C,{className:"text-xs",children:c}),e.jsx(k,{children:e.jsx(z,{type:"number",min:0,className:"w-28",value:g.value??"",onChange:re(g)})})]})},a))}),e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Message Limits"}),e.jsx("div",{className:"flex flex-wrap gap-3",children:[["max_messages_per_minute","Per Minute"],["max_messages_per_hour","Per Hour"],["max_new_contacts_per_day","New Contacts/Day"]].map(([a,c])=>e.jsx(_,{control:d.control,name:a,render:({field:g})=>e.jsxs(S,{children:[e.jsx(C,{className:"text-xs",children:c}),e.jsx(k,{children:e.jsx(z,{type:"number",min:0,className:"w-32",value:g.value??"",onChange:re(g)})})]})},a))}),e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Behavior"}),e.jsxs("div",{className:"flex w-full flex-col gap-2",children:[[["simulate_typing","Simulate Typing","Show typing indicator before sending"],["randomize_delays","Randomize Delays","Add variance between min/max delay"],["pause_on_low_response","Pause on Low Response","Auto-pause if response rate drops below threshold"]].map(([a,c,g])=>e.jsx(_,{control:d.control,name:a,render:({field:q})=>e.jsxs(S,{className:"flex flex-row items-center justify-between rounded-md border border-border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(C,{children:c}),e.jsx(A,{children:g})]}),e.jsx(k,{children:e.jsx(se,{checked:!!q.value,onCheckedChange:q.onChange})})]})},a)),j&&e.jsx(_,{control:d.control,name:"response_rate_threshold",render:({field:a})=>e.jsxs(S,{children:[e.jsx(C,{children:"Response Rate Threshold (%)"}),e.jsx(k,{children:e.jsx(z,{type:"number",min:0,max:100,value:Math.round((a.value??.3)*100),onChange:c=>{const g=c.target.value;a.onChange(g===""?void 0:Number(g)/100)}})})]})})]}),e.jsxs(ae,{type:"submit",disabled:!E||y,variant:E?"default":"outline",className:"w-full",children:[y&&e.jsx(pe,{className:"h-4 w-4 animate-spin"}),"Save Changes"]})]})}):e.jsx("div",{className:"flex justify-center p-4 text-sm text-muted-foreground",children:"Loading..."})})]})})};export{De as P,Ae as R,Ke as u};
@@ -1 +1 @@
1
- import{j as s}from"./vendor-query-SzWcOU0G.js";import{f as b,g}from"./index-BsU6riLP.js";const h=p=>{const e=b.c(15),{icon:c,title:m,rows:x,status:o}=p;let t;e[0]!==m?(t=s.jsx("span",{children:m}),e[0]=m,e[1]=t):t=e[1];let r;e[2]!==c||e[3]!==t?(r=s.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-muted px-3 py-2 text-sm font-semibold",children:[c,t]}),e[2]=c,e[3]=t,e[4]=r):r=e[4];let i;if(e[5]!==x||e[6]!==o){let n;e[8]!==o?(n=l=>{const f=l.ok(o),u=f?"success":l.warn?"warning":"destructive";return s.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-3 px-3 py-2 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:l.label}),s.jsx(g,{variant:u,children:f?l.trueText:l.falseText})]},l.label)},e[8]=o,e[9]=n):n=e[9],i=x.map(n),e[5]=x,e[6]=o,e[7]=i}else i=e[7];let d;e[10]!==i?(d=s.jsx("div",{className:"divide-y divide-border",children:i}),e[10]=i,e[11]=d):d=e[11];let a;return e[12]!==r||e[13]!==d?(a=s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[r,d]}),e[12]=r,e[13]=d,e[14]=a):a=e[14],a};export{h as S};
1
+ import{j as s}from"./vendor-query-SzWcOU0G.js";import{f as b,g}from"./index-CyQ67hhw.js";const h=p=>{const e=b.c(15),{icon:c,title:m,rows:x,status:o}=p;let t;e[0]!==m?(t=s.jsx("span",{children:m}),e[0]=m,e[1]=t):t=e[1];let r;e[2]!==c||e[3]!==t?(r=s.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-muted px-3 py-2 text-sm font-semibold",children:[c,t]}),e[2]=c,e[3]=t,e[4]=r):r=e[4];let i;if(e[5]!==x||e[6]!==o){let n;e[8]!==o?(n=l=>{const f=l.ok(o),u=f?"success":l.warn?"warning":"destructive";return s.jsxs("div",{className:"grid grid-cols-[1fr_auto] items-center gap-3 px-3 py-2 text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:l.label}),s.jsx(g,{variant:u,children:f?l.trueText:l.falseText})]},l.label)},e[8]=o,e[9]=n):n=e[9],i=x.map(n),e[5]=x,e[6]=o,e[7]=i}else i=e[7];let d;e[10]!==i?(d=s.jsx("div",{className:"divide-y divide-border",children:i}),e[10]=i,e[11]=d):d=e[11];let a;return e[12]!==r||e[13]!==d?(a=s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[r,d]}),e[12]=r,e[13]=d,e[14]=a):a=e[14],a};export{h as S};