machinaos 0.0.86 → 0.0.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.template +10 -0
- package/cli/commands/build.py +33 -3
- package/cli/commands/start.py +7 -5
- package/cli/platform_.py +7 -1
- package/client/dist/assets/{ActionBar-Bg1hW3t6.js → ActionBar-Bbzjnr1n.js} +1 -1
- package/client/dist/assets/{ApiKeyInput-DqeO8LWg.js → ApiKeyInput-D7odCRvV.js} +1 -1
- package/client/dist/assets/{ApiKeyPanel-BaGAyu8Z.js → ApiKeyPanel-DyJo6Qo9.js} +1 -1
- package/client/dist/assets/{ApiUsageSection-C_pELnWe.js → ApiUsageSection-Bp2ZbKvU.js} +1 -1
- package/client/dist/assets/{EmailPanel-B-Wsn1Cy.js → EmailPanel-DAl9RlbR.js} +1 -1
- package/client/dist/assets/{OAuthPanel-C2tVcDmU.js → OAuthPanel-CRwrzCjm.js} +1 -1
- package/client/dist/assets/{QrPairingPanel-ChNvq1Zt.js → QrPairingPanel-B_0Xi9DV.js} +1 -1
- package/client/dist/assets/{RateLimitSection-ByFuEORg.js → RateLimitSection-Btv6LTyd.js} +1 -1
- package/client/dist/assets/{StatusCard-Pzhnd_Bf.js → StatusCard-CxFZD5D4.js} +1 -1
- package/client/dist/assets/{index-D-LxTbwD.js → index-CdXKM2ZZ.js} +18 -18
- package/client/dist/index.html +1 -1
- package/client/package.json +1 -1
- package/client/src/components/ui/SettingsPanel.tsx +33 -5
- package/client/src/components/ui/settingsPanel/schema.ts +7 -1
- package/client/src/lib/workflowOps.ts +13 -1
- package/package.json +2 -3
- package/server/config/llm_defaults.json +6 -4
- package/server/config/node_allowlist.json +2 -1
- package/server/core/config.py +8 -3
- package/server/core/container.py +36 -1
- package/server/core/database.py +31 -47
- package/server/core/paths.py +88 -103
- package/server/models/database.py +5 -1
- package/server/nodes/agent/claude_code_agent/_oauth.py +54 -26
- package/server/nodes/browser/_install.py +14 -11
- package/server/nodes/search/perplexity_search/__init__.py +10 -9
- package/server/nodes/stripe/_handlers.py +57 -14
- package/server/nodes/stripe/_install.py +15 -8
- package/server/nodes/tool/agent_builder/__init__.py +574 -46
- package/server/nodes/whatsapp/_install.py +71 -0
- package/server/nodes/whatsapp/_runtime.py +34 -5
- package/server/pyproject.toml +6 -0
- package/server/services/ai.py +290 -138
- package/server/services/events/cli.py +17 -0
- package/server/services/events/daemon.py +10 -3
- package/server/services/llm/__init__.py +22 -1
- package/server/services/llm/providers/__init__.py +26 -1
- package/server/services/llm/providers/_compat.py +109 -0
- package/server/services/llm/providers/anthropic.py +21 -0
- package/server/services/llm/providers/gemini.py +22 -0
- package/server/services/llm/providers/openai.py +24 -0
- package/server/services/llm/providers/openrouter.py +19 -0
- package/server/services/llm/registry.py +111 -0
- package/server/services/llm/unifier.py +132 -0
- package/server/services/model_registry.py +25 -7
- package/server/services/plugin/__init__.py +2 -0
- package/server/services/plugin/base.py +43 -5
- package/server/services/plugin/tool.py +11 -1
- package/server/services/process_service.py +19 -5
- package/server/services/temporal/_install.py +30 -9
- package/server/services/temporal/agent_activities.py +131 -3
- package/server/services/temporal/agent_workflow.py +109 -13
- package/server/services/workflow.py +10 -1
- package/server/services/workflow_ops.py +4 -0
- package/server/skills/assistant/agent-builder-skill/SKILL.md +107 -80
- package/server/tests/conftest.py +3 -5
- package/server/tests/llm/test_live_providers.py +289 -0
- package/server/tests/llm/test_plugin_shape.py +168 -0
- package/server/tests/llm/test_provider_self_registration.py +82 -0
- package/server/tests/llm/test_unifier_incompatible_models_filter.py +106 -0
- package/server/tests/llm/test_unifier_typed_errors.py +145 -0
- package/server/tests/llm/test_wiring.py +65 -56
- package/server/tests/nodes/test_agent_builder.py +587 -3
- package/server/tests/nodes/test_stripe_plugin.py +3 -2
- package/server/tests/services/test_agent_loop_rebind.py +355 -0
- package/server/tests/temporal/test_agent_workflow.py +140 -3
- package/server/tests/test_plugin_contract.py +124 -0
- package/server/uv.lock +185 -181
package/.env.template
CHANGED
|
@@ -98,6 +98,16 @@ EVENT_FRAMEWORK_ENABLED=true
|
|
|
98
98
|
# context-window threshold. Per-session overrides via the UI.
|
|
99
99
|
COMPACTION_ENABLED=true
|
|
100
100
|
|
|
101
|
+
# Compaction trigger threshold as a fraction of the model's context
|
|
102
|
+
# window (0.05 - 0.99). 0.8 = compact when cumulative tokens hit 80%.
|
|
103
|
+
# Per-user overrides via the UserSettings row (Settings tab).
|
|
104
|
+
COMPACTION_RATIO=0.8
|
|
105
|
+
|
|
106
|
+
# Agent loop hard step cap. AI Agent + Chat Agent stop the LLM/tool
|
|
107
|
+
# iteration loop after this many rounds and return a truncation note.
|
|
108
|
+
# Per-user overrides via the UserSettings row (Settings tab).
|
|
109
|
+
AGENT_RECURSION_LIMIT=200
|
|
110
|
+
|
|
101
111
|
# Dead-letter queue for failed workflow executions. Off by default.
|
|
102
112
|
DLQ_ENABLED=false
|
|
103
113
|
|
package/cli/commands/build.py
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
"""``machina build`` -- replaces ``scripts/build.js``.
|
|
2
2
|
|
|
3
|
-
Checks toolchain (node, npm, python, uv
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Checks toolchain (node, npm, python, uv), then runs the 6-step
|
|
4
|
+
build: ``.env`` bootstrap -> ``pnpm install`` -> client build ->
|
|
5
|
+
Node.js sidecar bundle -> ``uv sync`` -> compile Python bytecode
|
|
6
|
+
-> pooch-fetch Temporal binary.
|
|
7
|
+
|
|
8
|
+
Layers ``.env.dev`` (when present in the checkout) BEFORE running
|
|
9
|
+
those steps so the build's ``DATA_DIR`` matches the runtime's
|
|
10
|
+
expected location. Without that, ``machina build`` would pooch
|
|
11
|
+
Temporal under ``~/.machina/`` and ``machina dev`` would re-fetch
|
|
12
|
+
it into ``<repo>/.machina/`` — a redundant download on every fresh
|
|
13
|
+
clone. Production (global-install) operators never have
|
|
14
|
+
``.env.dev`` in their checkout, so the layering is a no-op there.
|
|
6
15
|
|
|
7
16
|
The ``MACHINAOS_BUILDING`` env var is set so ``scripts/postinstall.js``
|
|
8
17
|
skips its own ``install.js`` invocation when build is the orchestrator.
|
|
@@ -97,6 +106,27 @@ def _ensure_uv(python_cmd: str) -> str:
|
|
|
97
106
|
def build_command() -> None:
|
|
98
107
|
root = project_root()
|
|
99
108
|
|
|
109
|
+
# Layer ``.env.dev`` (if present) BEFORE the install steps so the
|
|
110
|
+
# build's ``DATA_DIR`` matches what the runtime (``machina dev``)
|
|
111
|
+
# will see. Without this, ``machina build`` reads
|
|
112
|
+
# ``DATA_DIR=~/.machina`` from ``.env.template`` and lands the
|
|
113
|
+
# Temporal CLI under user home, but ``machina dev`` then reads
|
|
114
|
+
# ``DATA_DIR=.machina`` from ``.env.dev`` and re-downloads into
|
|
115
|
+
# ``<repo>/.machina/`` — a cache-miss the operator pays on every
|
|
116
|
+
# fresh checkout.
|
|
117
|
+
#
|
|
118
|
+
# Safe for global installs: ``.env.dev`` is committed to git for
|
|
119
|
+
# repo-clone contributors but is NOT in the npm ``files`` list, so
|
|
120
|
+
# ``npm install -g machinaos`` doesn't ship it. Without
|
|
121
|
+
# ``.env.dev`` on disk, :func:`load_dev_overrides` is a no-op and
|
|
122
|
+
# the build falls through to ``.env.template`` defaults
|
|
123
|
+
# (``DATA_DIR=~/.machina``) — identical to today's behaviour and
|
|
124
|
+
# matching what ``machina start`` / ``machina daemon`` use at
|
|
125
|
+
# runtime.
|
|
126
|
+
from cli.config import load_dev_overrides
|
|
127
|
+
|
|
128
|
+
load_dev_overrides(root)
|
|
129
|
+
|
|
100
130
|
# Prevent the postinstall orchestrator from re-running install.js when
|
|
101
131
|
# we're orchestrating ourselves (matches the existing JS contract).
|
|
102
132
|
os.environ["MACHINAOS_BUILDING"] = "true"
|
package/cli/commands/start.py
CHANGED
|
@@ -24,7 +24,6 @@ from cli._common import build_backend_spec, error_block, free_all_ports, preflig
|
|
|
24
24
|
from cli.colors import console
|
|
25
25
|
from cli.platform_ import (
|
|
26
26
|
IS_WINDOWS,
|
|
27
|
-
IS_WSL,
|
|
28
27
|
platform_name,
|
|
29
28
|
server_dir,
|
|
30
29
|
server_venv,
|
|
@@ -122,10 +121,13 @@ def _read_version(root: Path) -> str:
|
|
|
122
121
|
|
|
123
122
|
|
|
124
123
|
def _build_specs(root: Path, cfg, *, temporal_running: bool) -> list[ServiceSpec]:
|
|
125
|
-
#
|
|
126
|
-
#
|
|
127
|
-
#
|
|
128
|
-
|
|
124
|
+
# Bind host: ``MACHINA_BIND_HOST`` overrides the auto-pick (escape
|
|
125
|
+
# hatch when the platform detection is wrong or the operator wants
|
|
126
|
+
# a specific interface). Default — native Windows stays private on
|
|
127
|
+
# 127.0.0.1; WSL + POSIX bind 0.0.0.0 so the service is reachable
|
|
128
|
+
# both via in-VM ``localhost`` AND via the WSL VM IP from the
|
|
129
|
+
# Windows host, regardless of WSL2's localhostForwarding state.
|
|
130
|
+
backend_host = os.environ.get("MACHINA_BIND_HOST") or ("127.0.0.1" if IS_WINDOWS else "0.0.0.0")
|
|
129
131
|
|
|
130
132
|
specs: list[ServiceSpec] = [
|
|
131
133
|
ServiceSpec(
|
package/cli/platform_.py
CHANGED
|
@@ -28,6 +28,7 @@ of the project agree on per-OS conventions.
|
|
|
28
28
|
from __future__ import annotations
|
|
29
29
|
|
|
30
30
|
import os
|
|
31
|
+
import platform
|
|
31
32
|
import sys
|
|
32
33
|
from pathlib import Path
|
|
33
34
|
|
|
@@ -35,7 +36,12 @@ from pathlib import Path
|
|
|
35
36
|
IS_WINDOWS = sys.platform == "win32"
|
|
36
37
|
IS_MACOS = sys.platform == "darwin"
|
|
37
38
|
IS_LINUX = sys.platform.startswith("linux")
|
|
38
|
-
|
|
39
|
+
# ``platform.release()`` returns the kernel version string. On WSL2 it
|
|
40
|
+
# always contains ``"microsoft"`` (e.g. ``5.15.167.4-microsoft-standard-WSL2``)
|
|
41
|
+
# regardless of whether ``WSL_DISTRO_NAME`` is exported into the current
|
|
42
|
+
# subprocess. Stdlib, kernel-level — survives daemonised / cron / systemd
|
|
43
|
+
# launches that strip WSL env vars.
|
|
44
|
+
IS_WSL = IS_LINUX and "microsoft" in platform.release().lower()
|
|
39
45
|
IS_GIT_BASH = IS_WINDOWS and bool(
|
|
40
46
|
os.environ.get("MSYSTEM") or "bash" in (os.environ.get("SHELL") or "")
|
|
41
47
|
)
|
|
@@ -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-
|
|
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-CdXKM2ZZ.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 +1 @@
|
|
|
1
|
-
import{a as u,j as s}from"./vendor-query-SzWcOU0G.js";import{I as j,B as o}from"./index-
|
|
1
|
+
import{a as u,j as s}from"./vendor-query-SzWcOU0G.js";import{I as j,B as o}from"./index-CdXKM2ZZ.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 +1 @@
|
|
|
1
|
-
import{a as A,j as s}from"./vendor-query-SzWcOU0G.js";import{u as E,A as V,a as P,b as U,c as q,d as R,e as K,B as z,f as F,N as H,C as M,g as O,h as G,i as I,j as T,L as J,I as Q,k as W}from"./index-
|
|
1
|
+
import{a as A,j as s}from"./vendor-query-SzWcOU0G.js";import{u as E,A as V,a as P,b as U,c as q,d as R,e as K,B as z,f as F,N as H,C as M,g as O,h as G,i as I,j as T,L as J,I as Q,k as W}from"./index-CdXKM2ZZ.js";import{A as X}from"./ApiKeyInput-D7odCRvV.js";import{u as Y,P as Z}from"./RateLimitSection-Btv6LTyd.js";import{ax as ee,q as L,au as se,v as ae}from"./vendor-icons-CVrPjN2Q.js";import{A as te}from"./ApiUsageSection-Bp2ZbKvU.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-misc-C4VxKHs5.js";import"./vendor-radix-Dnos29jG.js";import"./vendor-markdown-CRou3yQ5.js";import"./vendor-react-DvWIbVx0.js";const D=N=>{const e=F.c(8),{label:t,value:p,className:a}=N;let l;e[0]!==t?(l=s.jsx("span",{className:"text-xs text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1];const n=`text-lg font-semibold ${a??""}`;let i;e[2]!==n||e[3]!==p?(i=s.jsx("span",{className:n,children:p}),e[2]=n,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},le=({providerId:N,providerName:e})=>{const{getProviderUsageSummary:t,isConnected:p}=E(),[a,l]=A.useState(null),[n,i]=A.useState(!1),[o,h]=A.useState(!1),d=A.useCallback(async()=>{if(p){i(!0);try{const r=await t();l(r.find(c=>c.provider===N)??null)}finally{i(!1)}}},[p,N,t]);return A.useEffect(()=>{o&&d()},[o,d]),s.jsx(V,{type:"single",collapsible:!0,onValueChange:r=>h(r==="usage"),children:s.jsxs(P,{value:"usage",children:[s.jsx(U,{children:s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(ee,{className:"h-4 w-4"})," Usage & Costs"]})}),s.jsx(q,{children:n?s.jsx("div",{className:"flex justify-center p-4",children:s.jsx(L,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):!a||a.execution_count===0?s.jsx(R,{variant:"info",children:s.jsxs(K,{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(D,{label:"Total Tokens",value:a.total_tokens.toLocaleString(),className:"text-dracula-cyan"}),s.jsx(D,{label:"Total Cost",value:`$${a.total_cost.toFixed(4)}`,className:"text-dracula-green"}),s.jsx(D,{label:"Executions",value:a.execution_count,className:"text-dracula-purple"})]}),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:[a.total_input_tokens.toLocaleString()," ",s.jsxs("span",{className:"ml-1 text-dracula-green",children:["($",a.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:[a.total_output_tokens.toLocaleString()," ",s.jsxs("span",{className:"ml-1 text-dracula-green",children:["($",a.total_output_cost.toFixed(4),")"]})]})]})]}),a.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-dracula-green",children:["$",a.total_cache_cost.toFixed(4)]})]})]}),a.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:a.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-dracula-green",children:["$",r.total_cost.toFixed(4)]})]},r.model))})]}),s.jsxs(z,{size:"sm",variant:"outline",onClick:d,disabled:n,children:[n?s.jsx(L,{className:"h-3 w-3 animate-spin"}):s.jsx(se,{className:"h-3 w-3"}),"Refresh"]})]})})]})})},ve=N=>{const e=F.c(71),{config:t,visible:p}=N,a=Y(t,p),l=t.fields?.[0];let n,i,o,h;if(e[0]!==t.color||e[1]!==t.fields||e[2]!==t.iconRef||e[3]!==t.id||e[4]!==t.name||e[5]!==l||e[6]!==a.actions||e[7]!==a.error||e[8]!==a.form||e[9]!==a.loading||e[10]!==a.stored||e[11]!==a.values){const _=(t.fields??[]).slice(1),g=l?a.values[l.key]??"":"",x=a.stored;n="flex flex-col gap-5 p-5";let m;e[16]!==t.color?(m={color:t.color},e[16]=t.color,e[17]=m):m=e[17];let u;e[18]!==t.iconRef?(u=s.jsx(H,{icon:t.iconRef,className:"h-12 w-12 text-2xl"}),e[18]=t.iconRef,e[19]=u):u=e[19];let f;e[20]!==m||e[21]!==u?(f=s.jsx("div",{className:"rounded-lg bg-tint-soft",style:m,children:u}),e[20]=m,e[21]=u,e[22]=f):f=e[22];let j;e[23]!==t.name?(j=s.jsx(M,{className:"text-lg",children:t.name}),e[23]=t.name,e[24]=j):j=e[24];let b;e[25]!==f||e[26]!==j?(b=s.jsxs("div",{className:"flex items-center gap-3",children:[f,j]}),e[25]=f,e[26]=j,e[27]=b):b=e[27];let C;e[28]!==x?(C=x&&s.jsxs(O,{variant:"success",className:"gap-1",children:[s.jsx(ae,{className:"h-3 w-3"}),"Connected"]}),e[28]=x,e[29]=C):C=e[29];let k;e[30]!==C||e[31]!==b?(k=s.jsxs(G,{className:"flex flex-row items-center justify-between gap-3 space-y-0 pb-3",children:[b,C]}),e[30]=C,e[31]=b,e[32]=k):k=e[32];let S;e[33]!==t.id||e[34]!==l||e[35]!==g||e[36]!==a.actions||e[37]!==a.form||e[38]!==a.loading||e[39]!==x?(S=l&&s.jsx(X,{value:g,onChange:v=>a.form.setFieldValue(l.key,v),onSave:()=>a.actions.validate(t.id,g.trim()),onDelete:x?async()=>{await a.actions.remove(t.id),l.key!=="apiKey"&&await a.actions.remove(l.key)}:void 0,placeholder:l.placeholder,loading:a.loading==="validate",isStored:x,saveLabel:l.key==="apiKey"?"Validate":"Fetch",savedLabel:l.key==="apiKey"?"Valid":"Connected"}),e[33]=t.id,e[34]=l,e[35]=g,e[36]=a.actions,e[37]=a.form,e[38]=a.loading,e[39]=x,e[40]=S):S=e[40];let w;e[41]!==S?(w=s.jsx(I,{children:S}),e[41]=S,e[42]=w):w=e[42],e[43]!==k||e[44]!==w?(i=s.jsxs(T,{children:[k,w]}),e[43]=k,e[44]=w,e[45]=i):i=e[45],e[46]!==a.error?(o=a.error&&s.jsx(R,{variant:"destructive",children:s.jsx(K,{children:a.error})}),e[46]=a.error,e[47]=o):o=e[47];let $;e[48]!==a.actions||e[49]!==a.form||e[50]!==a.loading||e[51]!==a.values?($=v=>s.jsx(ie,{fieldKey:v.key,label:v.label,placeholder:v.placeholder,help:v.help,secret:v.secret,value:a.values[v.key]??"",onChange:B=>a.form.setFieldValue(v.key,B),onSave:()=>a.actions.save(v.key,a.values[v.key]??""),loading:a.loading==="save"},v.key),e[48]=a.actions,e[49]=a.form,e[50]=a.loading,e[51]=a.values,e[52]=$):$=e[52],h=_.map($),e[0]=t.color,e[1]=t.fields,e[2]=t.iconRef,e[3]=t.id,e[4]=t.name,e[5]=l,e[6]=a.actions,e[7]=a.error,e[8]=a.form,e[9]=a.loading,e[10]=a.stored,e[11]=a.values,e[12]=n,e[13]=i,e[14]=o,e[15]=h}else n=e[12],i=e[13],o=e[14],h=e[15];let d;e[53]!==t.hasDefaults||e[54]!==t.id?(d=t.hasDefaults&&s.jsx(Z,{providerId:t.id}),e[53]=t.hasDefaults,e[54]=t.id,e[55]=d):d=e[55];let r;e[56]!==t.hasDefaults||e[57]!==t.id||e[58]!==t.name?(r=t.hasDefaults&&s.jsx(le,{providerId:t.id,providerName:t.name}),e[56]=t.hasDefaults,e[57]=t.id,e[58]=t.name,e[59]=r):r=e[59];let c;e[60]!==t.name||e[61]!==t.usageService?(c=t.usageService&&s.jsx(te,{service:t.usageService,serviceName:t.name}),e[60]=t.name,e[61]=t.usageService,e[62]=c):c=e[62];let y;return e[63]!==n||e[64]!==i||e[65]!==o||e[66]!==h||e[67]!==d||e[68]!==r||e[69]!==c?(y=s.jsxs("div",{className:n,children:[i,o,h,d,r,c]}),e[63]=n,e[64]=i,e[65]=o,e[66]=h,e[67]=d,e[68]=r,e[69]=c,e[70]=y):y=e[70],y},ie=N=>{const e=F.c(23),{fieldKey:t,label:p,placeholder:a,help:l,secret:n,value:i,onChange:o,onSave:h,loading:d}=N,r=`cred-${t}`;let c;e[0]!==p||e[1]!==r?(c=s.jsx(J,{htmlFor:r,className:"text-sm font-medium",children:p}),e[0]=p,e[1]=r,e[2]=c):c=e[2];const y=`cred-${t}`,_=n?"password":"text";let g;e[3]!==o?(g=b=>o(b.target.value),e[3]=o,e[4]=g):g=e[4];let x;e[5]!==a||e[6]!==y||e[7]!==_||e[8]!==g||e[9]!==i?(x=s.jsx(Q,{id:y,type:_,value:i,onChange:g,placeholder:a,className:"flex-1"}),e[5]=a,e[6]=y,e[7]=_,e[8]=g,e[9]=i,e[10]=x):x=e[10];let m;e[11]!==d||e[12]!==h?(m=s.jsx(W,{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 j;return e[19]!==c||e[20]!==u||e[21]!==f?(j=s.jsx(T,{children:s.jsxs(I,{className:"flex flex-col gap-2 pt-4",children:[c,u,f]})}),e[19]=c,e[20]=u,e[21]=f,e[22]=j):j=e[22],j};export{ve 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 y,e as w,B as A,f as C}from"./index-
|
|
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 y,e as w,B as A,f as C}from"./index-CdXKM2ZZ.js";import{ax as _,q as f,au as S}from"./vendor-icons-CVrPjN2Q.js";const R=({service:d,serviceName:s})=>{const{getAPIUsageSummary:o,isConnected:n}=h(),[a,l]=x.useState(null),[c,t]=x.useState(!1),r=x.useCallback(async()=>{if(n){t(!0);try{const i=await o(d);l(i.find(j=>j.service===d)??null)}finally{t(!1)}}},[n,d,o]);x.useEffect(()=>{r()},[r]);const p=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-dracula-yellow"}),"API Usage & Costs ",p]})}),e.jsx(b,{children:c?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-dracula-green"}),e.jsx(m,{label:"API Calls",value:a.execution_count,className:"text-dracula-cyan"}),e.jsx(m,{label:"Resources",value:a.total_resources,className:"text-dracula-purple"})]}),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(i=>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:i.operation}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(u,{variant:"outline",children:[i.resource_count," resources"]}),e.jsxs(u,{variant:"success",children:["$",i.total_cost.toFixed(4)]})]})]},i.operation))})]}),e.jsxs(A,{size:"sm",variant:"outline",onClick:r,disabled:c,children:[c?e.jsx(f,{className:"h-3 w-3 animate-spin"}):e.jsx(S,{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."]})})})]})})},m=d=>{const s=C.c(8),{label:o,value:n,className:a}=d;let l;s[0]!==o?(l=e.jsx("span",{className:"text-xs text-muted-foreground",children:o}),s[0]=o,s[1]=l):l=s[1];const c=`text-lg font-semibold ${a??""}`;let t;s[2]!==c||s[3]!==n?(t=e.jsx("span",{className:c,children:n}),s[2]=c,s[3]=n,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-
|
|
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-CdXKM2ZZ.js";import{S as ie}from"./StatusCard-CxFZD5D4.js";import{ay as le,az as me,q as F}from"./vendor-icons-CVrPjN2Q.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-misc-C4VxKHs5.js";import"./vendor-radix-Dnos29jG.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 +1 @@
|
|
|
1
|
-
import{j as l,a as I}from"./vendor-query-SzWcOU0G.js";import{f as O,L as P,I as z,k as B,d as D,e as H,N as Y}from"./index-
|
|
1
|
+
import{j as l,a as I}from"./vendor-query-SzWcOU0G.js";import{f as O,L as P,I as z,k as B,d as D,e as H,N as Y}from"./index-CdXKM2ZZ.js";import{u as G}from"./RateLimitSection-Btv6LTyd.js";import{A as J,u as K}from"./ActionBar-Bbzjnr1n.js";import{ay as M,az as Q,q as W,R as X}from"./vendor-icons-CVrPjN2Q.js";import{S as Z}from"./StatusCard-CxFZD5D4.js";import{A as ee}from"./ApiUsageSection-Bp2ZbKvU.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-misc-C4VxKHs5.js";import"./vendor-radix-Dnos29jG.js";import"./vendor-markdown-CRou3yQ5.js";import"./vendor-react-DvWIbVx0.js";const te=i=>{const e=O.c(7),{fields:t,form:c}=i;let s;if(e[0]!==t||e[1]!==c){let n;e[3]!==c?(n=o=>l.jsx(se,{field:o,form:c},o.key),e[3]=c,e[4]=n):n=e[4],s=t.map(n),e[0]=t,e[1]=c,e[2]=s}else s=e[2];let a;return e[5]!==s?(a=l.jsx("div",{className:"flex w-full flex-col gap-3",children:s}),e[5]=s,e[6]=a):a=e[6],a},se=({field:i,form:e})=>{const[t,c]=I.useState(!1),s=e.getFieldValue(i.key)??"",[a,n]=I.useState(s),o=!!i.secret;return I.useEffect(()=>{!a&&s&&n(s)},[s]),l.jsxs("div",{className:"grid gap-1.5",children:[l.jsxs(P,{htmlFor:`field-${i.key}`,className:"text-xs",children:[i.label,i.required&&l.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),l.jsxs("div",{className:"relative",children:[l.jsx(z,{id:`field-${i.key}`,type:o&&!t?"password":"text",value:a,onChange:r=>{const d=r.target.value;n(d),e.setFieldValue(i.key,d)},placeholder:i.placeholder,className:o?"font-mono pr-9":"font-mono"}),o&&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":t?"Hide value":"Show value",children:t?l.jsx(M,{className:"h-4 w-4"}):l.jsx(Q,{className:"h-4 w-4"})})]})]})},le=i=>{const e=O.c(50),{config:t,form:c,connected:s,stored:a,loading:n,error:o,icon:r,onSaveCredentials:d,onLogin:u,onLogout:m,onRefresh:x,extraSection:h}=i,g=!!t.fields?.length;let v;e[0]!==s?(v={label:"Status",ok:()=>s,trueText:"Connected",falseText:"Not Connected"},e[0]=s,e[1]=v):v=e[1];let f;e[2]!==g||e[3]!==a?(f=g?[{label:"Credentials",ok:()=>a,trueText:"Configured",falseText:"Not configured"}]:[],e[2]=g,e[3]=a,e[4]=f):f=e[4];let p;e[5]!==v||e[6]!==f?(p=[v,...f],e[5]=v,e[6]=f,e[7]=p):p=e[7];const E=p,_=`Login with ${t.name}`,U=g&&!a;let j;e[8]!==s||e[9]!==u||e[10]!==_||e[11]!==U?(j={key:"login",label:_,intent:"save",onClick:u,disabled:U,hidden:s},e[8]=s,e[9]=u,e[10]=_,e[11]=U,e[12]=j):j=e[12];const V=!s;let b;e[13]!==m||e[14]!==V?(b={key:"logout",label:"Disconnect",intent:"stop",onClick:m,hidden:V},e[13]=m,e[14]=V,e[15]=b):b=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=l.jsx(X,{className:"h-4 w-4"}),e[16]=w):w=e[16];let k;e[17]!==x?(k={key:"refresh",label:"Refresh",intent:"save",onClick:x,icon:w},e[17]=x,e[18]=k):k=e[18];let L;e[19]!==k||e[20]!==j||e[21]!==b?(L=[j,b,k],e[19]=k,e[20]=j,e[21]=b,e[22]=L):L=e[22];const q=L,A=n==="save";let N;e[23]!==t.name||e[24]!==r||e[25]!==E?(N=l.jsx(Z,{icon:r,title:t.name,rows:E,status:null}),e[23]=t.name,e[24]=r,e[25]=E,e[26]=N):N=e[26];let S;e[27]!==t.callbackUrl||e[28]!==t.fields||e[29]!==t.instructions||e[30]!==s||e[31]!==c||e[32]!==A||e[33]!==d?(S=!s&&t.fields&&l.jsxs("div",{className:"flex w-full flex-col gap-3",children:[l.jsx(te,{fields:t.fields,form:c}),l.jsxs(B,{intent:"secret",onClick:d,disabled:A,children:[A&&l.jsx(W,{className:"h-4 w-4 animate-spin"}),"Save Credentials"]}),t.instructions&&l.jsxs("div",{className:"text-xs leading-relaxed text-muted-foreground",children:[t.instructions,t.callbackUrl&&l.jsxs(l.Fragment,{children:[l.jsx("br",{}),"Callback URL:"," ",l.jsx("code",{className:"text-accent",children:t.callbackUrl})]})]})]}),e[27]=t.callbackUrl,e[28]=t.fields,e[29]=t.instructions,e[30]=s,e[31]=c,e[32]=A,e[33]=d,e[34]=S):S=e[34];let y;e[35]!==o?(y=o&&l.jsx(D,{variant:"destructive",children:l.jsx(H,{children:o})}),e[35]=o,e[36]=y):y=e[36];const T=s?t.account_label?`Connected as ${t.account_label}.`:`Your ${t.name} account is connected.`:a||!g?"Click Login to authorize.":"Enter your credentials above to get started.";let C;e[37]!==T?(C=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:T})}),e[37]=T,e[38]=C):C=e[38];let F;e[39]===Symbol.for("react.memo_cache_sentinel")?(F=l.jsx("div",{className:"flex-1"}),e[39]=F):F=e[39];let R;e[40]!==q||e[41]!==n?(R=l.jsx(J,{actions:q,loading:n}),e[40]=q,e[41]=n,e[42]=R):R=e[42];let $;return e[43]!==h||e[44]!==N||e[45]!==S||e[46]!==y||e[47]!==C||e[48]!==R?($=l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[N,S,y,C,h,F,R]}),e[43]=h,e[44]=N,e[45]=S,e[46]=y,e[47]=C,e[48]=R,e[49]=$):$=e[49],$},ge=i=>{const e=O.c(25),{config:t,visible:c}=i,s=G(t,c),a=K(t.statusHook),n=a?!!a.connected:!!t.stored;let o;e[0]!==t.iconRef?(o=l.jsx(Y,{icon:t.iconRef,className:"h-6 w-6 text-2xl"}),e[0]=t.iconRef,e[1]=o):o=e[1];let r;e[2]!==t.fields||e[3]!==s?(r=()=>{const g=t.fields?.find(f=>f.required&&!s.form.getFieldValue(f.key)?.trim());if(g){s.setError(`${g.label} is required`);return}const v=s.form.getFieldsValue();s.execute("save",async()=>{for(const f of t.fields){const p=v[f.key]?.trim();p&&await s.actions.save(f.key,p)}return s.setStored(!0),{success:!0}})},e[2]=t.fields,e[3]=s,e[4]=r):r=e[4];let d,u,m;e[5]!==s.actions?(d=()=>s.actions.oauthLogin(),u=()=>s.actions.oauthLogout(),m=()=>s.actions.oauthRefresh(),e[5]=s.actions,e[6]=d,e[7]=u,e[8]=m):(d=e[6],u=e[7],m=e[8]);let x;e[9]!==t.name||e[10]!==t.usageService?(x=t.usageService&&l.jsx(ee,{service:t.usageService,serviceName:t.name}),e[9]=t.name,e[10]=t.usageService,e[11]=x):x=e[11];let h;return e[12]!==t||e[13]!==n||e[14]!==s.error||e[15]!==s.form||e[16]!==s.loading||e[17]!==s.stored||e[18]!==o||e[19]!==r||e[20]!==d||e[21]!==u||e[22]!==m||e[23]!==x?(h=l.jsx("div",{className:"flex min-h-0 flex-1 flex-col p-5",children:l.jsx(le,{config:t,form:s.form,connected:n,stored:s.stored,loading:s.loading,error:s.error,icon:o,onSaveCredentials:r,onLogin:d,onLogout:u,onRefresh:m,extraSection:x})}),e[12]=t,e[13]=n,e[14]=s.error,e[15]=s.form,e[16]=s.loading,e[17]=s.stored,e[18]=o,e[19]=r,e[20]=d,e[21]=u,e[22]=m,e[23]=x,e[24]=h):h=e[24],h};export{ge as default};
|
|
@@ -1 +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 A}from"./index-
|
|
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 A}from"./index-CdXKM2ZZ.js";import{A as v}from"./ApiKeyInput-D7odCRvV.js";import{Q as E}from"./vendor-misc-C4VxKHs5.js";import{v as W,q as F,aA as q,t as Q}from"./vendor-icons-CVrPjN2Q.js";import{u as M,R as T}from"./RateLimitSection-Btv6LTyd.js";import{u as L,A as D}from"./ActionBar-Bbzjnr1n.js";import{S as P}from"./StatusCard-CxFZD5D4.js";import"./vendor-flow-CZmBvHRo.js";import"./vendor-radix-Dnos29jG.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(q,{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=M(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(v,{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(A,{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(T,{}),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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as fe,a as o,u as je,j as e}from"./vendor-query-SzWcOU0G.js";import{u as le,m as se,s as G,S as ge,t as re,A as oe,a as ie,b as ce,c as de,F as ue,v as _,w,x as S,y as J,z as C,D as Y,E as I,G as X,H as O,J as D,K as Q,g as B,I as $,M as Z,B as ee,O as me,_ as ne,P as b,Q as H,R as ye,d as _e,e as ve,f as be}from"./index-D-LxTbwD.js";import{c as xe}from"./vendor-react-DvWIbVx0.js";import{S as we,q as he}from"./vendor-icons-CVrPjN2Q.js";const W={};function Pe(n,l){const x=fe(),[h,j]=o.useState(null),[f,c]=o.useState(null),[F,v]=o.useState(!1);o.useEffect(()=>{c(null),j(null),v(!1)},[n.id]);const{validateApiKey:u,saveApiKey:y,removeApiKey:A,getProviderDefaults:R,saveProviderDefaults:P,getProviderUsageSummary:i,getAPIUsageSummary:a,getStoredModels:d,getModelConstraints:g,isConnected:T}=le(),{sendRequest:k}=se(),E=je({queryKey:G.credentialValues.byProvider(n.id).queryKey,queryFn:async()=>{if(!n.fields)return{values:W,hadStored:!1};const t=await Promise.all(n.fields.map(async K=>{const pe=K.key==="apiKey"?n.id:K.key,ae=await k("get_stored_api_key",{provider:pe});return{key:K.key,hasKey:ae.hasKey,apiKey:ae.apiKey}})),p={};let m=!1;for(const K of t)K.apiKey&&(p[K.key]=K.apiKey),K.hasKey&&(m=!0);return{values:p,hadStored:m}},enabled:l&&T&&!!n.fields,staleTime:ge.FOREVER}),L=E.data?.values??W,M=o.useRef(L);M.current=L;const N=n.id,q=o.useCallback(t=>{x.setQueryData(G.credentialValues.byProvider(N).queryKey,p=>({values:t(p?.values??W),hadStored:p?.hadStored??!1}))},[x,N]),z=o.useMemo(()=>({getFieldValue:t=>M.current[t],getFieldsValue:()=>({...M.current}),setFieldValue:(t,p)=>{q(m=>({...m,[t]:p}))},setFieldsValue:t=>{q(p=>({...p,...t}))},resetFields:()=>q(()=>W)}),[q]);(E.data?.hadStored??!1)&&!F&&v(!0);const r=o.useCallback(async(t,p)=>{j(t),c(null);try{const m=await p();return m&&!m.success&&m.error&&c(m.error),m}catch(m){c(m.message||`Failed: ${t}`);return}finally{j(null)}},[]),V=o.useCallback(()=>x.invalidateQueries({queryKey:G.credentialValues.byProvider(N).queryKey}),[x,N]);return{form:z,values:L,loading:h,error:f,stored:F,setStored:v,setError:c,execute:r,actions:{validate:(t,p)=>r("validate",async()=>{const m=await u(t,p);return m?.isValid&&(v(!0),await V()),m}),save:(t,p)=>r("save",async()=>{const m=await y(t,p);return m?.isValid&&(v(!0),await V()),m}),remove:t=>r("remove",async()=>{await A(t),v(!1),await V()}),oauthLogin:()=>r("login",async()=>{const t=await k(n.ws.login,{});return t.success&&t.url&&window.open(t.url,"_blank"),t}),oauthLogout:()=>r("logout",()=>k(n.ws.logout,{})),oauthRefresh:()=>r("refresh",()=>k(n.ws.status,{})),sendWs:(t,p)=>r(t,()=>k(t,p??{}))},isConnected:T,getProviderDefaults:R,saveProviderDefaults:P,getProviderUsageSummary:i,getAPIUsageSummary:a,getStoredModels:d,getModelConstraints:g}}const Se=me({default_model:ye().optional().default(""),temperature:b().optional(),max_tokens:b().int().min(1).optional(),thinking_enabled:H().optional().default(!1),thinking_budget:b().int().min(1024).max(16e3).optional(),reasoning_effort:ne(["low","medium","high"]).optional(),reasoning_format:ne(["parsed","hidden"]).optional()}),Ve=({providerId:n})=>{const{getProviderDefaults:l,saveProviderDefaults:x,getStoredModels:h,getModelConstraints:j,isConnected:f}=le(),{apiKeyStatuses:c}=se(),F=c[n],[v,u]=o.useState([]),[y,A]=o.useState(null),[R,P]=o.useState(!1),i=xe({resolver:re(Se),defaultValues:{}}),a=i.watch("default_model"),d=i.watch("thinking_enabled"),{isDirty:g}=i.formState;o.useEffect(()=>{if(!f)return;u([]),A(null);let s=!1;return(async()=>{P(!0);try{const[r,V]=await Promise.all([l(n),h(n)]);s||(i.reset(r??{}),u(V??[]))}finally{s||P(!1)}})(),()=>{s=!0}},[n,f,F]),o.useEffect(()=>{if(!f||!a)return;let s=!1;return j(a,n).then(r=>{s||(A(r),r?.max_output_tokens&&i.getValues("max_tokens")!==r.max_output_tokens&&i.setValue("max_tokens",r.max_output_tokens,{shouldDirty:!1}))}),()=>{s=!0}},[a,n,f]);const T=o.useCallback(async s=>{P(!0);try{await x(n,s)&&i.reset(s)}finally{P(!1)}},[n,x,i]),[k,E]=y?.temperature_range??[0,2],L=y?.max_output_tokens,M=y?.thinking_type,N=y?.supports_thinking,q=y?.is_reasoning_model&&k===E,z=s=>r=>{const V=r.target.value;s.onChange(V===""?void 0:Number(V))};return e.jsx(oe,{type:"single",collapsible:!0,defaultValue:"defaults",children:e.jsxs(ie,{value:"defaults",children:[e.jsx(ce,{children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"h-4 w-4"})," Default Parameters"]})}),e.jsx(de,{children:e.jsx("div",{className:R?"pointer-events-none opacity-60":"",children:e.jsx(ue,{...i,children:e.jsxs("form",{id:`provider-defaults-form-${n}`,onSubmit:i.handleSubmit(T),className:"flex flex-col gap-3",children:[e.jsx(_,{control:i.control,name:"default_model",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Default Model"}),e.jsxs(J,{value:s.value??"",onValueChange:s.onChange,children:[e.jsx(C,{children:e.jsx(Y,{children:e.jsx(I,{placeholder:v.length?"Select model":"Validate API key first"})})}),e.jsx(X,{children:v.map(r=>e.jsx(O,{value:r,children:r},r))})]}),e.jsx(D,{children:"Model used when none specified"}),e.jsx(Q,{})]})}),y&&e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[L!=null&&e.jsxs(B,{variant:"success",children:["Max Output: ",L.toLocaleString()]}),y.context_length!=null&&e.jsxs(B,{variant:"info",children:["Context: ",y.context_length.toLocaleString()]}),e.jsxs(B,{variant:"secondary",children:["Temp: ",k,"-",E]}),N&&e.jsxs(B,{variant:"warning",children:["Thinking: ",M]}),y.is_reasoning_model&&e.jsx(B,{variant:"outline",children:"Reasoning"})]}),!q&&e.jsx(_,{control:i.control,name:"temperature",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Temperature"}),e.jsx(C,{children:e.jsx($,{type:"number",min:k,max:E,step:.1,className:"w-24",value:s.value??"",onChange:z(s)})}),e.jsxs(D,{children:["Controls randomness (",k,"-",E,")"]}),e.jsx(Q,{})]})}),e.jsx(_,{control:i.control,name:"max_tokens",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Max Tokens"}),e.jsx(C,{children:e.jsx($,{type:"number",min:1,max:L||void 0,className:"w-32",value:s.value??"",onChange:z(s)})}),e.jsx(D,{children:L!=null?`Up to ${L.toLocaleString()}`:"Maximum response length"}),e.jsx(Q,{})]})}),N&&e.jsx(_,{control:i.control,name:"thinking_enabled",render:({field:s})=>e.jsxs(w,{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(S,{children:"Thinking / Reasoning"}),e.jsxs(D,{children:["Extended thinking (",M,")"]})]}),e.jsx(C,{children:e.jsx(Z,{checked:!!s.value,onCheckedChange:s.onChange})})]})}),N&&M==="budget"&&d&&e.jsx(_,{control:i.control,name:"thinking_budget",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Thinking Budget"}),e.jsx(C,{children:e.jsx($,{type:"number",min:1024,max:16e3,className:"w-28",value:s.value??"",onChange:z(s)})}),e.jsx(D,{children:"Token budget (1024-16000)"}),e.jsx(Q,{})]})}),N&&M==="effort"&&d&&e.jsx(_,{control:i.control,name:"reasoning_effort",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Reasoning Effort"}),e.jsxs(J,{value:s.value??"",onValueChange:s.onChange,children:[e.jsx(C,{children:e.jsx(Y,{className:"w-32",children:e.jsx(I,{placeholder:"Select"})})}),e.jsxs(X,{children:[e.jsx(O,{value:"low",children:"Low"}),e.jsx(O,{value:"medium",children:"Medium"}),e.jsx(O,{value:"high",children:"High"})]})]}),e.jsx(D,{children:"Low, medium, or high"}),e.jsx(Q,{})]})}),N&&M==="format"&&d&&e.jsx(_,{control:i.control,name:"reasoning_format",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Reasoning Format"}),e.jsxs(J,{value:s.value??"",onValueChange:s.onChange,children:[e.jsx(C,{children:e.jsx(Y,{className:"w-32",children:e.jsx(I,{placeholder:"Select"})})}),e.jsxs(X,{children:[e.jsx(O,{value:"parsed",children:"Parsed"}),e.jsx(O,{value:"hidden",children:"Hidden"})]})]}),e.jsx(D,{children:"Parsed or hidden"}),e.jsx(Q,{})]})}),e.jsxs(ee,{type:"submit",disabled:!g||R,variant:g?"default":"outline",className:"w-full",children:[R&&e.jsx(he,{className:"h-4 w-4 animate-spin"}),"Save Defaults"]})]})})})})]})})},Ce=me({enabled:H().default(!1),min_delay_ms:b().int().min(0).optional(),max_delay_ms:b().int().min(0).optional(),typing_delay_ms:b().int().min(0).optional(),link_extra_delay_ms:b().int().min(0).optional(),max_messages_per_minute:b().int().min(0).optional(),max_messages_per_hour:b().int().min(0).optional(),max_new_contacts_per_day:b().int().min(0).optional(),simulate_typing:H().optional(),randomize_delays:H().optional(),pause_on_low_response:H().optional(),response_rate_threshold:b().min(0).max(1).optional()}),U=n=>{const l=be.c(7),{label:x,value:h}=n;let j;l[0]!==x?(j=e.jsx("span",{className:"text-xs text-muted-foreground",children:x}),l[0]=x,l[1]=j):j=l[1];let f;l[2]!==h?(f=e.jsx("span",{className:"text-lg font-semibold",children:h}),l[2]=h,l[3]=f):f=l[3];let c;return l[4]!==j||l[5]!==f?(c=e.jsxs("div",{className:"flex flex-col",children:[j,f]}),l[4]=j,l[5]=f,l[6]=c):c=l[6],c},te=n=>l=>{const x=l.target.value;n.onChange(x===""?void 0:Number(x))},Ke=()=>{const{getWhatsAppRateLimitConfig:n,setWhatsAppRateLimitConfig:l,unpauseWhatsAppRateLimit:x}=se(),[h,j]=o.useState(null),[f,c]=o.useState(!1),[F,v]=o.useState(!1),u=xe({resolver:re(Ce),defaultValues:{enabled:!1}}),y=u.watch("pause_on_low_response"),{isDirty:A}=u.formState,R=o.useCallback(async()=>{c(!0);try{const a=await n();a.success&&a.config&&(u.reset(a.config),j(a.stats??null),v(!0))}finally{c(!1)}},[u,n]);o.useEffect(()=>{R()},[R]);const P=o.useCallback(async a=>{c(!0);try{const d=await l(a);d.success&&d.config&&u.reset(d.config)}finally{c(!1)}},[u,l]),i=o.useCallback(async()=>{c(!0);try{const a=await x();a.success&&a.stats&&j(a.stats)}finally{c(!1)}},[x]);return e.jsx(oe,{type:"single",collapsible:!0,children:e.jsxs(ie,{value:"ratelimits",children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[e.jsx("span",{children:"Rate Limits"}),e.jsx(_,{control:u.control,name:"enabled",render:({field:a})=>e.jsx("span",{onClick:d=>d.stopPropagation(),children:e.jsx(Z,{checked:!!a.value,onCheckedChange:a.onChange})})})]})}),e.jsx(de,{children:F?e.jsx(ue,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(P),className:"flex flex-col gap-3",children:[h&&e.jsxs("div",{className:"mb-3 flex flex-wrap gap-4",children:[e.jsx(U,{label:"Last Minute",value:h.messages_sent_last_minute}),e.jsx(U,{label:"Last Hour",value:h.messages_sent_last_hour}),e.jsx(U,{label:"Today",value:h.messages_sent_today}),e.jsx(U,{label:"New Contacts",value:h.new_contacts_today}),e.jsx(U,{label:"Responses",value:h.responses_received}),e.jsx(U,{label:"Response Rate",value:`${Math.round((h.response_rate||0)*100)}%`})]}),h?.is_paused&&e.jsx(_e,{variant:"warning",children:e.jsxs(ve,{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:h.pause_reason||"Paused"}),e.jsx(ee,{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,d])=>e.jsx(_,{control:u.control,name:a,render:({field:g})=>e.jsxs(w,{children:[e.jsx(S,{className:"text-xs",children:d}),e.jsx(C,{children:e.jsx($,{type:"number",min:0,className:"w-28",value:g.value??"",onChange:te(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,d])=>e.jsx(_,{control:u.control,name:a,render:({field:g})=>e.jsxs(w,{children:[e.jsx(S,{className:"text-xs",children:d}),e.jsx(C,{children:e.jsx($,{type:"number",min:0,className:"w-32",value:g.value??"",onChange:te(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,d,g])=>e.jsx(_,{control:u.control,name:a,render:({field:T})=>e.jsxs(w,{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(S,{children:d}),e.jsx(D,{children:g})]}),e.jsx(C,{children:e.jsx(Z,{checked:!!T.value,onCheckedChange:T.onChange})})]})},a)),y&&e.jsx(_,{control:u.control,name:"response_rate_threshold",render:({field:a})=>e.jsxs(w,{children:[e.jsx(S,{children:"Response Rate Threshold (%)"}),e.jsx(C,{children:e.jsx($,{type:"number",min:0,max:100,value:Math.round((a.value??.3)*100),onChange:d=>{const g=d.target.value;a.onChange(g===""?void 0:Number(g)/100)}})})]})})]}),e.jsxs(ee,{type:"submit",disabled:!A||f,variant:A?"default":"outline",className:"w-full",children:[f&&e.jsx(he,{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{Ve as P,Ke as R,Pe as u};
|
|
1
|
+
import{d as fe,a as o,u as je,j as e}from"./vendor-query-SzWcOU0G.js";import{u as le,m as se,s as G,S as ge,t as re,A as oe,a as ie,b as ce,c as de,F as ue,v as _,w,x as S,y as J,z as C,D as Y,E as I,G as X,H as O,J as D,K as Q,g as B,I as $,M as Z,B as ee,O as me,_ as ne,P as b,Q as H,R as ye,d as _e,e as ve,f as be}from"./index-CdXKM2ZZ.js";import{c as xe}from"./vendor-react-DvWIbVx0.js";import{S as we,q as he}from"./vendor-icons-CVrPjN2Q.js";const W={};function Pe(n,l){const x=fe(),[h,j]=o.useState(null),[f,c]=o.useState(null),[F,v]=o.useState(!1);o.useEffect(()=>{c(null),j(null),v(!1)},[n.id]);const{validateApiKey:u,saveApiKey:y,removeApiKey:A,getProviderDefaults:R,saveProviderDefaults:P,getProviderUsageSummary:i,getAPIUsageSummary:a,getStoredModels:d,getModelConstraints:g,isConnected:T}=le(),{sendRequest:k}=se(),E=je({queryKey:G.credentialValues.byProvider(n.id).queryKey,queryFn:async()=>{if(!n.fields)return{values:W,hadStored:!1};const t=await Promise.all(n.fields.map(async K=>{const pe=K.key==="apiKey"?n.id:K.key,ae=await k("get_stored_api_key",{provider:pe});return{key:K.key,hasKey:ae.hasKey,apiKey:ae.apiKey}})),p={};let m=!1;for(const K of t)K.apiKey&&(p[K.key]=K.apiKey),K.hasKey&&(m=!0);return{values:p,hadStored:m}},enabled:l&&T&&!!n.fields,staleTime:ge.FOREVER}),L=E.data?.values??W,M=o.useRef(L);M.current=L;const N=n.id,q=o.useCallback(t=>{x.setQueryData(G.credentialValues.byProvider(N).queryKey,p=>({values:t(p?.values??W),hadStored:p?.hadStored??!1}))},[x,N]),z=o.useMemo(()=>({getFieldValue:t=>M.current[t],getFieldsValue:()=>({...M.current}),setFieldValue:(t,p)=>{q(m=>({...m,[t]:p}))},setFieldsValue:t=>{q(p=>({...p,...t}))},resetFields:()=>q(()=>W)}),[q]);(E.data?.hadStored??!1)&&!F&&v(!0);const r=o.useCallback(async(t,p)=>{j(t),c(null);try{const m=await p();return m&&!m.success&&m.error&&c(m.error),m}catch(m){c(m.message||`Failed: ${t}`);return}finally{j(null)}},[]),V=o.useCallback(()=>x.invalidateQueries({queryKey:G.credentialValues.byProvider(N).queryKey}),[x,N]);return{form:z,values:L,loading:h,error:f,stored:F,setStored:v,setError:c,execute:r,actions:{validate:(t,p)=>r("validate",async()=>{const m=await u(t,p);return m?.isValid&&(v(!0),await V()),m}),save:(t,p)=>r("save",async()=>{const m=await y(t,p);return m?.isValid&&(v(!0),await V()),m}),remove:t=>r("remove",async()=>{await A(t),v(!1),await V()}),oauthLogin:()=>r("login",async()=>{const t=await k(n.ws.login,{});return t.success&&t.url&&window.open(t.url,"_blank"),t}),oauthLogout:()=>r("logout",()=>k(n.ws.logout,{})),oauthRefresh:()=>r("refresh",()=>k(n.ws.status,{})),sendWs:(t,p)=>r(t,()=>k(t,p??{}))},isConnected:T,getProviderDefaults:R,saveProviderDefaults:P,getProviderUsageSummary:i,getAPIUsageSummary:a,getStoredModels:d,getModelConstraints:g}}const Se=me({default_model:ye().optional().default(""),temperature:b().optional(),max_tokens:b().int().min(1).optional(),thinking_enabled:H().optional().default(!1),thinking_budget:b().int().min(1024).max(16e3).optional(),reasoning_effort:ne(["low","medium","high"]).optional(),reasoning_format:ne(["parsed","hidden"]).optional()}),Ve=({providerId:n})=>{const{getProviderDefaults:l,saveProviderDefaults:x,getStoredModels:h,getModelConstraints:j,isConnected:f}=le(),{apiKeyStatuses:c}=se(),F=c[n],[v,u]=o.useState([]),[y,A]=o.useState(null),[R,P]=o.useState(!1),i=xe({resolver:re(Se),defaultValues:{}}),a=i.watch("default_model"),d=i.watch("thinking_enabled"),{isDirty:g}=i.formState;o.useEffect(()=>{if(!f)return;u([]),A(null);let s=!1;return(async()=>{P(!0);try{const[r,V]=await Promise.all([l(n),h(n)]);s||(i.reset(r??{}),u(V??[]))}finally{s||P(!1)}})(),()=>{s=!0}},[n,f,F]),o.useEffect(()=>{if(!f||!a)return;let s=!1;return j(a,n).then(r=>{s||(A(r),r?.max_output_tokens&&i.getValues("max_tokens")!==r.max_output_tokens&&i.setValue("max_tokens",r.max_output_tokens,{shouldDirty:!1}))}),()=>{s=!0}},[a,n,f]);const T=o.useCallback(async s=>{P(!0);try{await x(n,s)&&i.reset(s)}finally{P(!1)}},[n,x,i]),[k,E]=y?.temperature_range??[0,2],L=y?.max_output_tokens,M=y?.thinking_type,N=y?.supports_thinking,q=y?.is_reasoning_model&&k===E,z=s=>r=>{const V=r.target.value;s.onChange(V===""?void 0:Number(V))};return e.jsx(oe,{type:"single",collapsible:!0,defaultValue:"defaults",children:e.jsxs(ie,{value:"defaults",children:[e.jsx(ce,{children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(we,{className:"h-4 w-4"})," Default Parameters"]})}),e.jsx(de,{children:e.jsx("div",{className:R?"pointer-events-none opacity-60":"",children:e.jsx(ue,{...i,children:e.jsxs("form",{id:`provider-defaults-form-${n}`,onSubmit:i.handleSubmit(T),className:"flex flex-col gap-3",children:[e.jsx(_,{control:i.control,name:"default_model",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Default Model"}),e.jsxs(J,{value:s.value??"",onValueChange:s.onChange,children:[e.jsx(C,{children:e.jsx(Y,{children:e.jsx(I,{placeholder:v.length?"Select model":"Validate API key first"})})}),e.jsx(X,{children:v.map(r=>e.jsx(O,{value:r,children:r},r))})]}),e.jsx(D,{children:"Model used when none specified"}),e.jsx(Q,{})]})}),y&&e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[L!=null&&e.jsxs(B,{variant:"success",children:["Max Output: ",L.toLocaleString()]}),y.context_length!=null&&e.jsxs(B,{variant:"info",children:["Context: ",y.context_length.toLocaleString()]}),e.jsxs(B,{variant:"secondary",children:["Temp: ",k,"-",E]}),N&&e.jsxs(B,{variant:"warning",children:["Thinking: ",M]}),y.is_reasoning_model&&e.jsx(B,{variant:"outline",children:"Reasoning"})]}),!q&&e.jsx(_,{control:i.control,name:"temperature",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Temperature"}),e.jsx(C,{children:e.jsx($,{type:"number",min:k,max:E,step:.1,className:"w-24",value:s.value??"",onChange:z(s)})}),e.jsxs(D,{children:["Controls randomness (",k,"-",E,")"]}),e.jsx(Q,{})]})}),e.jsx(_,{control:i.control,name:"max_tokens",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Max Tokens"}),e.jsx(C,{children:e.jsx($,{type:"number",min:1,max:L||void 0,className:"w-32",value:s.value??"",onChange:z(s)})}),e.jsx(D,{children:L!=null?`Up to ${L.toLocaleString()}`:"Maximum response length"}),e.jsx(Q,{})]})}),N&&e.jsx(_,{control:i.control,name:"thinking_enabled",render:({field:s})=>e.jsxs(w,{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(S,{children:"Thinking / Reasoning"}),e.jsxs(D,{children:["Extended thinking (",M,")"]})]}),e.jsx(C,{children:e.jsx(Z,{checked:!!s.value,onCheckedChange:s.onChange})})]})}),N&&M==="budget"&&d&&e.jsx(_,{control:i.control,name:"thinking_budget",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Thinking Budget"}),e.jsx(C,{children:e.jsx($,{type:"number",min:1024,max:16e3,className:"w-28",value:s.value??"",onChange:z(s)})}),e.jsx(D,{children:"Token budget (1024-16000)"}),e.jsx(Q,{})]})}),N&&M==="effort"&&d&&e.jsx(_,{control:i.control,name:"reasoning_effort",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Reasoning Effort"}),e.jsxs(J,{value:s.value??"",onValueChange:s.onChange,children:[e.jsx(C,{children:e.jsx(Y,{className:"w-32",children:e.jsx(I,{placeholder:"Select"})})}),e.jsxs(X,{children:[e.jsx(O,{value:"low",children:"Low"}),e.jsx(O,{value:"medium",children:"Medium"}),e.jsx(O,{value:"high",children:"High"})]})]}),e.jsx(D,{children:"Low, medium, or high"}),e.jsx(Q,{})]})}),N&&M==="format"&&d&&e.jsx(_,{control:i.control,name:"reasoning_format",render:({field:s})=>e.jsxs(w,{children:[e.jsx(S,{children:"Reasoning Format"}),e.jsxs(J,{value:s.value??"",onValueChange:s.onChange,children:[e.jsx(C,{children:e.jsx(Y,{className:"w-32",children:e.jsx(I,{placeholder:"Select"})})}),e.jsxs(X,{children:[e.jsx(O,{value:"parsed",children:"Parsed"}),e.jsx(O,{value:"hidden",children:"Hidden"})]})]}),e.jsx(D,{children:"Parsed or hidden"}),e.jsx(Q,{})]})}),e.jsxs(ee,{type:"submit",disabled:!g||R,variant:g?"default":"outline",className:"w-full",children:[R&&e.jsx(he,{className:"h-4 w-4 animate-spin"}),"Save Defaults"]})]})})})})]})})},Ce=me({enabled:H().default(!1),min_delay_ms:b().int().min(0).optional(),max_delay_ms:b().int().min(0).optional(),typing_delay_ms:b().int().min(0).optional(),link_extra_delay_ms:b().int().min(0).optional(),max_messages_per_minute:b().int().min(0).optional(),max_messages_per_hour:b().int().min(0).optional(),max_new_contacts_per_day:b().int().min(0).optional(),simulate_typing:H().optional(),randomize_delays:H().optional(),pause_on_low_response:H().optional(),response_rate_threshold:b().min(0).max(1).optional()}),U=n=>{const l=be.c(7),{label:x,value:h}=n;let j;l[0]!==x?(j=e.jsx("span",{className:"text-xs text-muted-foreground",children:x}),l[0]=x,l[1]=j):j=l[1];let f;l[2]!==h?(f=e.jsx("span",{className:"text-lg font-semibold",children:h}),l[2]=h,l[3]=f):f=l[3];let c;return l[4]!==j||l[5]!==f?(c=e.jsxs("div",{className:"flex flex-col",children:[j,f]}),l[4]=j,l[5]=f,l[6]=c):c=l[6],c},te=n=>l=>{const x=l.target.value;n.onChange(x===""?void 0:Number(x))},Ke=()=>{const{getWhatsAppRateLimitConfig:n,setWhatsAppRateLimitConfig:l,unpauseWhatsAppRateLimit:x}=se(),[h,j]=o.useState(null),[f,c]=o.useState(!1),[F,v]=o.useState(!1),u=xe({resolver:re(Ce),defaultValues:{enabled:!1}}),y=u.watch("pause_on_low_response"),{isDirty:A}=u.formState,R=o.useCallback(async()=>{c(!0);try{const a=await n();a.success&&a.config&&(u.reset(a.config),j(a.stats??null),v(!0))}finally{c(!1)}},[u,n]);o.useEffect(()=>{R()},[R]);const P=o.useCallback(async a=>{c(!0);try{const d=await l(a);d.success&&d.config&&u.reset(d.config)}finally{c(!1)}},[u,l]),i=o.useCallback(async()=>{c(!0);try{const a=await x();a.success&&a.stats&&j(a.stats)}finally{c(!1)}},[x]);return e.jsx(oe,{type:"single",collapsible:!0,children:e.jsxs(ie,{value:"ratelimits",children:[e.jsx(ce,{children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[e.jsx("span",{children:"Rate Limits"}),e.jsx(_,{control:u.control,name:"enabled",render:({field:a})=>e.jsx("span",{onClick:d=>d.stopPropagation(),children:e.jsx(Z,{checked:!!a.value,onCheckedChange:a.onChange})})})]})}),e.jsx(de,{children:F?e.jsx(ue,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(P),className:"flex flex-col gap-3",children:[h&&e.jsxs("div",{className:"mb-3 flex flex-wrap gap-4",children:[e.jsx(U,{label:"Last Minute",value:h.messages_sent_last_minute}),e.jsx(U,{label:"Last Hour",value:h.messages_sent_last_hour}),e.jsx(U,{label:"Today",value:h.messages_sent_today}),e.jsx(U,{label:"New Contacts",value:h.new_contacts_today}),e.jsx(U,{label:"Responses",value:h.responses_received}),e.jsx(U,{label:"Response Rate",value:`${Math.round((h.response_rate||0)*100)}%`})]}),h?.is_paused&&e.jsx(_e,{variant:"warning",children:e.jsxs(ve,{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{children:h.pause_reason||"Paused"}),e.jsx(ee,{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,d])=>e.jsx(_,{control:u.control,name:a,render:({field:g})=>e.jsxs(w,{children:[e.jsx(S,{className:"text-xs",children:d}),e.jsx(C,{children:e.jsx($,{type:"number",min:0,className:"w-28",value:g.value??"",onChange:te(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,d])=>e.jsx(_,{control:u.control,name:a,render:({field:g})=>e.jsxs(w,{children:[e.jsx(S,{className:"text-xs",children:d}),e.jsx(C,{children:e.jsx($,{type:"number",min:0,className:"w-32",value:g.value??"",onChange:te(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,d,g])=>e.jsx(_,{control:u.control,name:a,render:({field:T})=>e.jsxs(w,{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(S,{children:d}),e.jsx(D,{children:g})]}),e.jsx(C,{children:e.jsx(Z,{checked:!!T.value,onCheckedChange:T.onChange})})]})},a)),y&&e.jsx(_,{control:u.control,name:"response_rate_threshold",render:({field:a})=>e.jsxs(w,{children:[e.jsx(S,{children:"Response Rate Threshold (%)"}),e.jsx(C,{children:e.jsx($,{type:"number",min:0,max:100,value:Math.round((a.value??.3)*100),onChange:d=>{const g=d.target.value;a.onChange(g===""?void 0:Number(g)/100)}})})]})})]}),e.jsxs(ee,{type:"submit",disabled:!A||f,variant:A?"default":"outline",className:"w-full",children:[f&&e.jsx(he,{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{Ve as P,Ke as R,Pe as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./vendor-query-SzWcOU0G.js";import{f as b,g}from"./index-
|
|
1
|
+
import{j as s}from"./vendor-query-SzWcOU0G.js";import{f as b,g}from"./index-CdXKM2ZZ.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};
|