@reformer/builder 3.0.0-beta.4 → 3.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{App-BzMuBv1U.js → App-BupMDG_t.js} +6 -6
- package/dist/assets/{BootError-CH4BoW__.js → BootError-CWnToysV.js} +1 -1
- package/dist/assets/{ChatPanel-9qHpjmLO.js → ChatPanel-B4wt7hBH.js} +3 -3
- package/dist/assets/{CodeEditor-CuHAtGtB.js → CodeEditor-Cca8j3Z3.js} +1 -1
- package/dist/assets/{MarkdownPreview-DwyxNTbn.js → MarkdownPreview-CmqjlfzE.js} +3 -3
- package/dist/assets/{RawJsonEditor-jYY7XCW2.js → RawJsonEditor-D5mwkIJa.js} +1 -1
- package/dist/assets/{boot-DTWnczkO.js → boot-BCJd6Ujw.js} +1 -1
- package/dist/assets/{byok-BM21dMSQ.js → byok-B9mwOrn0.js} +1 -1
- package/dist/assets/{editor.api-B4g2PJYj.js → editor.api-BWDeQ8t4.js} +1 -1
- package/dist/assets/{freemarker2-BlPZHoyx.js → freemarker2-DQaxDgne.js} +1 -1
- package/dist/assets/{handlebars-Dd8yor3z.js → handlebars-e1hbsCFi.js} +1 -1
- package/dist/assets/{html-C3wl1HPz.js → html-QXilGQ4Y.js} +1 -1
- package/dist/assets/index-BwhW-Atz.js +3 -0
- package/dist/assets/{index-OZOUDUGD.js → index-CF7RI8Bt.js} +1 -1
- package/dist/assets/{index-CU07HM8S.js → index-CLTXPf4k.js} +1 -1
- package/dist/assets/{index-CY45QPm-.js → index-DhcNqNgT.js} +2 -2
- package/dist/assets/{index-DCa3wFwm.js → index-U9gpmElw.js} +3 -3
- package/dist/assets/{index-BmJVVkA_.js → index-eRs9yupj.js} +1 -1
- package/dist/assets/{javascript-BF-EEvQI.js → javascript-C7cOj8ds.js} +1 -1
- package/dist/assets/{jsonMode-DGlgsS1d.js → jsonMode-DEqS3I0B.js} +1 -1
- package/dist/assets/{liquid-C0Gfg9TY.js → liquid-grdNDW6i.js} +1 -1
- package/dist/assets/{load-FrEYc91y.js → load-QsSQTL2T.js} +3 -3
- package/dist/assets/{mdx-bIG0iFaA.js → mdx-BGpbXlZS.js} +1 -1
- package/dist/assets/{monaco-languages-D5Bh48hh.js → monaco-languages-BZWxuU3F.js} +2 -2
- package/dist/assets/{monaco-setup-CAOrXrMd.js → monaco-setup-1PbjxubL.js} +3 -3
- package/dist/assets/{python-CciOb-4N.js → python-D5X7CY5Y.js} +1 -1
- package/dist/assets/{razor-cbEBt-Vr.js → razor-B2pbhZKy.js} +1 -1
- package/dist/assets/{reformer-ui-kit-11-BhXMU01R.js → reformer-ui-kit-11-bLtlFFvp.js} +1 -1
- package/dist/assets/{reformer-ui-kit-D8fAdwPH.js → reformer-ui-kit-tUqYBSLv.js} +1 -1
- package/dist/assets/{typescript-4hiO_obL.js → typescript-Ccn-IGn9.js} +1 -1
- package/dist/assets/{typescript-CNVC9ZHk.js → typescript-DL3gRsAd.js} +1 -1
- package/dist/assets/useFormField-BLbvmpme-Dwz_jyMW.js +1 -0
- package/dist/assets/{xml-RU_PX54U.js → xml-NgTjWpvZ.js} +1 -1
- package/dist/assets/{yaml-DsXE0ah6.js → yaml-CboCRslW.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/index-BC3M-FCZ.js +0 -3
- package/dist/assets/useFormField-BLbvmpme-BASGgtAT.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as o}from"./index-
|
|
1
|
+
import{j as o}from"./index-DhcNqNgT.js";import{R as s}from"./load-QsSQTL2T.js";const a={display:"grid",placeItems:"center",minHeight:"100vh",padding:"24px",fontFamily:"ui-sans-serif, system-ui, sans-serif",background:"#0b0d10",color:"#e6e8eb"},t={maxWidth:"640px",width:"100%",background:"#14171b",border:"1px solid #2a2f36",borderRadius:"12px",padding:"24px 28px"},d={whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"13px",lineHeight:1.5,background:"#0b0d10",border:"1px solid #2a2f36",borderRadius:"8px",padding:"12px 14px",marginTop:"12px",color:"#ffb4a9"};function l({error:e}){const n=e instanceof s,r=n?e.source==="config"?"reformer-builder.config.json":"component-catalog.json":null,i=e instanceof Error?e.message:String(e);return o.jsx("div",{style:a,children:o.jsxs("div",{style:t,role:"alert",children:[o.jsx("h1",{style:{fontSize:"18px",fontWeight:600,margin:0},children:"Не удалось запустить ReFormer Builder"}),o.jsx("p",{style:{margin:"10px 0 0",color:"#9aa4af",fontSize:"14px"},children:n?`Переданный клиентом файл ${r} не прошёл валидацию. Исправьте его и перезапустите билдер.`:"Ошибка инициализации при старте."}),o.jsx("pre",{style:d,children:i})]})})}export{l as BootError};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/byok-
|
|
2
|
-
import{_ as st,j as l,r as g}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/byok-B9mwOrn0.js","assets/index-DhcNqNgT.js","assets/index-BxUg93Np.css","assets/reformer-ui-kit-tUqYBSLv.js","assets/index-CF7RI8Bt.js","assets/useFormField-BLbvmpme-Dwz_jyMW.js","assets/App-BupMDG_t.js","assets/index-eRs9yupj.js","assets/load-QsSQTL2T.js","assets/boot-BCJd6Ujw.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as st,j as l,r as g}from"./index-DhcNqNgT.js";import{d as Se,o as F,T as it,u as q,b as w,a as at,e as lt,f as ct,S as dt,p as ut,C as _e,m as Pe,i as pt,s as ft,r as mt,U as ht,g as k,h as ue,t as pe,j as fe,k as me,l as he,n as I,q as gt,v as yt,w as xt}from"./reformer-ui-kit-tUqYBSLv.js";import{h as J,f as H,v as z,j as Ae,p as Oe,Q,X as Ee,t as bt,k as U,i as Ie,m as Nt,n as Z,o as ee,g as te,q as Ce,u as V,w as ne,x as vt,y as Re,A as $t,B as kt,C as wt,D as jt,F as Tt,G as St,I as _t,J as Pt,K as At,L as Ot,M as Et,a as It,N as Le,O as Ct,P as Rt,R as Lt,S as Mt,T as Dt,U as Ft,V as y,W as Me,Y as K,Z as qt}from"./App-BupMDG_t.js";import{m as De,A as Vt}from"./load-QsSQTL2T.js";import{C as Fe,X as zt,a as Ut}from"./index-CF7RI8Bt.js";function Kt(e){return{base:e,draft:e,ops:[]}}function Gt(e,t){return!t.ok||!t.schema?e:{base:e.base,draft:t.schema,ops:t.ops?.length?[...e.ops,...t.ops]:e.ops}}function qe(e){return e.draft!==e.base}function Ve(e,t={}){if(!qe(e))return{status:"empty"};const n=J(H.getState());if(!n||n.kind!=="form")return{status:"no-form"};if(n.schema!==e.base&&!t.force)return{status:"conflict"};const{valid:o,errors:r}=z(e.draft,{strict:!0,baseline:e.base});return o?(Ae.replaceSchema(e.draft),{status:"applied"}):{status:"invalid",errors:r}}function Bt(e){const t=J(H.getState());return!t||t.kind!=="form"||t.schema!==e.base}const _=1500;function S(e){return{ok:!0,text:e}}function f(e,t,n){return{ok:!1,text:n?.length?`${t} Did you mean: ${n.join(", ")}.`:t,error:{code:e,message:t,...n?.length?{suggestions:n}:{}}}}const Wt="FormArray";function P(e){return bt(e)}function oe(e){return Nt(e).map(t=>typeof t=="string"&&/^\d+$/.test(t)?Number(t):t)}function x(e){const t=e.component,n=Oe(t);if(n?.op==="component")return n.arg;if(n?.op==="html")return t;if(Q(e))return Wt}function ze(e){const t=Q(e)?e.array:Ee(e)?e.value:void 0;return Oe(t)?.arg}function j(e){const t=e.componentProps;for(const n of["label","title"]){const o=t?.[n];if(typeof o=="string"&&o)return o}}const Yt=["/children","/componentProps/steps","/item/$template"];function Ue(e){const t=Yt.find(o=>e.endsWith(o));return t?e.slice(0,-t.length)||"/root":void 0}function Xt(e,t,n){if(typeof t.at(-1)!="number")return;const r=U(e,t.slice(0,-1));if(!Array.isArray(r))return;const s=Ue(P(t.slice(0,-1)))??"/root";return r.length===0?`No node at ${n}: ${s} is still empty. Insert the first node with parent=${s}.`:`No node at ${n}: ${s} has ${r.length} child(ren), indices 0…${r.length-1}.`}function b(e,t,n){const o=oe(t),r=U(e,o);if(!Ie(r)){const s=Ue(t);if(s)return f("STALE_POINTER",`${t} is a slot, not a node. Pass the node itself as the parent: ${s}.`);const i=Xt(e,o,t);return i?f("STALE_POINTER",i):f("STALE_POINTER",`No node at ${t} — the form changed. Call get_form_outline again.`)}if(n?.component){const s=x(r);if(s!==n.component)return f("STALE_POINTER",`Expected ${n.component} at ${t}, found ${s??"a node without a component"}. Call get_form_outline again.`)}if(n?.model){const s=ze(r);if(s!==n.model)return f("STALE_POINTER",`Expected model ${n.model} at ${t}, found ${s??"a node without a model"}. Call get_form_outline again.`)}return{node:r,path:o}}function N(e){return"node"in e}function re(e,t,n,o){const r=[...e];for(const[s,i]of t.entries()){const c=[...r,i],a=o(s,t.length),d=c.join(`
|
|
3
3
|
`).length<=n,p=[...c,a].join(`
|
|
4
4
|
`).length<=n;if(s===t.length-1?d:p){r.push(i);continue}s>0&&r.push(a);break}return r.join(`
|
|
5
5
|
`)}function C(e){const t=[],n=e.root;return Ie(n)&&Ke(n,["root"],0,void 0,t),t}function Ke(e,t,n,o,r){const s=e.componentProps,i=x(e),c=ze(e),a=j(e);r.push({ref:P(t),depth:n,kind:Z(e),...i?{component:i}:{},...c?{model:c}:{},...a?{label:a}:{},...o?{slot:o}:{},...s?.required===!0?{required:!0}:{}});for(const d of ee(e,t))for(const p of d.entries){const h=d.single?d.path:[...d.path,p.index];Ke(p.node,h,n+1,d.kind,r)}}function Ge(e){const t=[e.component??`(${e.kind})`];return e.model&&t.push(`model=${e.model}`),e.label&&t.push(`«${e.label}»`),e.required&&t.push("required"),`${" ".repeat(e.depth)}${e.ref} · ${t.join(" · ")}`}function G(e,t){if(!e.length)return"The form is empty: no nodes.";const n=e.map(Ge);return n.join(`
|
|
@@ -79,4 +79,4 @@ It already contains:
|
|
|
79
79
|
Child nodes (omitted from the JSON above, see get_form_outline for their addresses) — ${n.map(r=>`${r.kind}: ${r.entries.length}`).join(", ")}.`:""}const En={name:"get_form_node",description:"Full JSON of a single node. Child nodes are not included — their addresses are in the form map.",inputSchema:{type:"object",properties:{ref:A},required:["ref"],additionalProperties:!1},readOnly:!0,run(e,t){const n=b(t.draft,e.ref);if(!N(n))return n;const o=JSON.stringify(An(n.node));return S(`${e.ref}:
|
|
80
80
|
${o}${On(n.node,n.path)}`)}},In={name:"get_form_outline",description:"Map of the current form: one line per node — address, component name, model path and caption. Re-read the form only if you lost track of it. For the full JSON of one node use get_form_node.",inputSchema:{type:"object",properties:{},additionalProperties:!1},readOnly:!0,run(e,t){return S(G(C(t.draft),_))}},Cn={name:"group_nodes",description:"Wrap several ADJACENT nodes into a shared container — for example to put first and last name on one line. direction/columns/gap set the layout of the resulting group.",inputSchema:{type:"object",properties:{refs:{type:"array",items:{type:"string"},minItems:2,description:"Addresses of adjacent nodes in one container, in document order"},...He},required:["refs"],additionalProperties:!1},readOnly:!1,run(e,t){const n=[];for(const a of e.refs){const d=b(t.draft,a);if(!N(d))return d;const p=St(t.draft,oe(a));if(!p)return f("INVALID_PARENT",`Node ${a} does not sit among the children of a container — nothing to group.`);n.push({ref:a,info:p})}const o=n[0].info.slotPath.join("/");if(n.some(a=>a.info.slotPath.join("/")!==o))return f("INVALID_PARENT","All nodes must sit in the same container.");if(n[0].info.slotPath.at(-1)==="steps")return f("INVALID_PARENT","Wizard steps cannot be grouped — the wrapper would collapse them into a single step. Group the fields INSIDE a step instead.");const r=n.map(a=>a.info.index).sort((a,d)=>a-d),s=r[0];if(!r.every((a,d)=>a===s+d))return f("INVALID_PARENT",`Only consecutive nodes can be grouped; got positions ${r.join(", ")}.`);const c=_t(t.draft,n[0].info.slotPath,s,r.length,{className:Ye(e)});return R(t,c,()=>({kind:"add",summary:`группа из ${r.length} узлов`,report:`group of ${r.length} nodes`}))}},Rn={name:"insert_node",description:"Insert a component into a container: a step, a section or the form root. A composite component arrives already assembled.",inputSchema:{type:"object",properties:{parent:A,index:{type:"integer",minimum:0,description:"Position of the first inserted node; appended by default"},nodes:{type:"array",minItems:1,description:"Components to insert into parent, in order",items:{type:"object",properties:{component:{type:"string",description:"Component name from list_components"},model:{type:"string",description:"Model path, bare: applicant.email"},props:{type:"object",description:"Component properties (describe_component)"}},required:["component"],additionalProperties:!1}}},required:["parent","nodes"],additionalProperties:!1},readOnly:!1,run(e,t){const n=b(t.draft,e.parent);if(!N(n))return n;const o=Je(n.node,n.path);if(!o)return f("INVALID_PARENT",`Node ${e.parent} does not accept children. Pick a container, a step or the form root.`);let r=t.draft;const s=[];let i=e.index??Number.MAX_SAFE_INTEGER;for(const[c,a]of e.nodes.entries()){const d=Mn(a,o.kind,e.parent);if("error"in d)return Ln(d.error,e.nodes.length,c);const p=Pt(r,o.path,i,d.node);r=p.schema,i=e.index===void 0?Number.MAX_SAFE_INTEGER:i+1,s.push({ref:P(p.newPath),...d.describe})}return B(t,r,s)}};function Ln(e,t,n){return t===1?e:{...e,text:`nodes[${n}]: ${e.text}`}}function Mn(e,t,n){const o=ne(e.component);if(!o)return{error:f("UNKNOWN_COMPONENT",`No component "${e.component}" in the catalog. Take a name from list_components.`,se(e.component,Be()))};if(t==="steps"&&o.role!=="container")return{error:f("INVALID_PARENT",`A wizard holds steps only, and ${o.name} is not a container. Insert a Step into ${n} first, then put this field inside that step.`)};const r=De(o.name,o.role,o.compoundParent);e.model&&(o.role==="field"?r.value=`$model(${e.model})`:o.role==="array"&&(r.array=`$model(${e.model})`)),e.props&&(r.componentProps={...r.componentProps,...e.props});const s=String(e.props?.label??e.model??o.name);return{node:r,describe:{kind:"add",summary:`${s} (${o.name})`,report:`${s} (${o.name})`}}}const Dn={name:"list_components",description:"Components available in this editor build: name, role (field/container/array) and category. Narrow the list with role and query.",inputSchema:{type:"object",properties:{role:{type:"string",enum:["field","container","array"],description:"Keep only components with this role"},query:{type:"string",description:"Substring of the name or category, case-insensitive"}},additionalProperties:!1},readOnly:!0,run(e){const t=e.query?"":Fn,n=rn(X(e),_-t.length);return S(t?`${n}
|
|
81
81
|
${t}`:n)}},Fn="Parts of composite components (TabsList, TabsTrigger, CardHeader…) are hidden from this list: they are created together with their root. To see them, query by the root name (e.g. tabs).",qn={name:"move_node",description:"Move a node into container parent at position index (appended by default). The same call reorders within the current container — pass that same container as parent.",inputSchema:{type:"object",properties:{ref:A,parent:{type:"string",description:"Address of the destination container"},index:{type:"integer",minimum:0,description:"Position among the children; appended by default"},expect:O},required:["ref","parent"],additionalProperties:!1},readOnly:!1,run(e,t){const n=b(t.draft,e.ref,e.expect);if(!N(n))return n;const o=b(t.draft,e.parent);if(!N(o))return o;if(At(n.path,o.path))return f("INVALID_PARENT",`Cannot move ${e.ref} inside itself.`);const r=Je(o.node,o.path);if(!r)return f("INVALID_PARENT",`Node ${e.parent} does not accept children.`);if(r.kind==="steps"&&Z(n.node)!=="container")return f("INVALID_PARENT",`A wizard holds steps only. Move ${e.ref} inside one of the steps of ${e.parent}.`);const s=j(n.node)??x(n.node)??e.ref,i=e.index??Number.MAX_SAFE_INTEGER,c=Ot(t.draft,n.path,r.path,i);return R(t,c,a=>({kind:"move",summary:`${s} → ${a}`,report:`${s} → ${a}`}))}},Vn={name:"remove_node",description:"Remove nodes together with everything inside them.",inputSchema:{type:"object",properties:{refs:{type:"array",minItems:1,items:{type:"string"},description:"Node addresses to remove"},expect:O},required:["refs"],additionalProperties:!1},readOnly:!1,run(e,t){if(e.expect&&e.refs.length>1)return f("INVALID_PARAMS","expect describes a single node — pass it only when refs holds exactly one address.");const n=[...new Set(e.refs)].sort(zn).reverse();let o=t.draft;const r=[];for(const s of n){const i=b(o,s,e.expect);if(!N(i))return i;const c=j(i.node)??x(i.node)??s,a=C(o).filter(d=>d.ref.startsWith(`${s}/`)&&oe(d.ref).length>i.path.length).length;o=Et(o,i.path).schema,r.push({ref:s,kind:"remove",summary:a>0?`${c} и вложенные узлы (${a})`:String(c),report:a>0?`${c} and ${a} nested node(s)`:String(c)})}return B(t,o,r)}};function zn(e,t){const n=e.split("/"),o=t.split("/");for(let r=0;r<Math.max(n.length,o.length);r++){const s=n[r],i=o[r];if(s===i)continue;if(s===void 0)return-1;if(i===void 0)return 1;const c=Number(s),a=Number(i);return Number.isInteger(c)&&Number.isInteger(a)?c-a:s<i?-1:1}return 0}const Un={name:"set_layout",description:"Set the layout of a container: direction (row/column), columns (grid) and gap (density). Styling classes are left alone.",inputSchema:{type:"object",properties:{ref:A,...He,expect:O},required:["ref"],additionalProperties:!1},readOnly:!1,run(e,t){const n=b(t.draft,e.ref,e.expect);if(!N(n))return n;if(!It(n.node))return f("INVALID_PARENT",`Only containers have a layout; ${e.ref} is not a container.`);const o=n.node.componentProps?.className,r=Ye(e,typeof o=="string"?o:""),s=Le(t.draft,n.path,"className",r),i=j(n.node)??x(n.node)??e.ref,c=e.columns?`${e.columns} колонки`:e.direction==="row"?"в строку":e.direction==="column"?"в столбец":`отступ ${e.gap}`,a=e.columns?`${e.columns} columns`:e.direction==="row"?"row":e.direction==="column"?"column":`gap ${e.gap}`;return R(t,s,()=>({kind:"update",summary:`${i} → раскладка: ${c}`,report:`${i} → layout: ${a}`}))}},Kn={name:"set_node_model",description:"Bind a field or an array to a data path. Write the path bare: applicant.email, not $model(...). Containers have no binding.",inputSchema:{type:"object",properties:{ref:A,model:{type:"string",minLength:1,description:"Model path, e.g. applicant.email"},expect:O},required:["ref","model"],additionalProperties:!1},readOnly:!1,run(e,t){const n=b(t.draft,e.ref,e.expect);if(!N(n))return n;const o=Q(n.node)?"array":Ee(n.node)?"value":null;if(!o)return f("INVALID_PARENT",`Node ${e.ref} is a container and has no data binding. Only fields and arrays do.`);const r=Ct(t.draft,n.path,o,`$model(${e.model})`),s=j(n.node)??x(n.node)??e.ref;return R(t,r,()=>({kind:"update",summary:`${s} → привязка ${e.model}`,report:`${s} → bound to ${e.model}`}))}},Gn={name:"set_node_prop",description:"Set component properties (label, placeholder, required, …). The same props go to every node in refs. The special key text sets the node's own content instead: a tab caption, a button label, a heading.",inputSchema:{type:"object",properties:{refs:{type:"array",minItems:1,items:{type:"string"},description:"Node addresses; the same props are applied to each"},props:{type:"object",minProperties:1,description:"name → value; null removes the property",additionalProperties:{type:["string","number","boolean","null"]}},expect:O},required:["refs","props"],additionalProperties:!1},readOnly:!1,run(e,t){if(e.expect&&e.refs.length>1)return f("INVALID_PARAMS","expect describes a single node — pass it only when refs holds exactly one address.");let n=t.draft;const o=[];for(const r of e.refs){const s=b(n,r,e.expect);if(!N(s))return s;let i=s.node,c=s.path;for(const[a,d]of Object.entries(e.props)){const p=a===Wn?Jn(n,r,{node:i,path:c},d):Bn(n,{node:i,path:c},a,d);if("error"in p)return p.error;n=p.schema;const h=b(n,r);if(!N(h))return h;i=h.node,c=h.path,o.push({ref:r,...p.describe})}}return B(t,n,o)}};function Bn(e,t,n,o){const r=o===null?void 0:o,s=Le(e,t.path,n,r),i=j(t.node)??x(t.node)??P(t.path);return{schema:s.schema,describe:{kind:"update",summary:r===void 0?`${i} → свойство ${n} убрано`:`${i} → ${n} = ${JSON.stringify(r)}`,report:r===void 0?`${i} → property ${n} removed`:`${i} → ${n} = ${JSON.stringify(r)}`}}}const Wn="text",Yn=["title","label"];function Xn(e){const t=x(e),n=t?ne(t):void 0;if(!n)return;const o=new Set(V(n.propsSchema).map(r=>r.key));return Yn.find(r=>o.has(r))}function Jn(e,t,n,o){if(Z(n.node)!=="container"||Rt(n.node))return{error:f("INVALID_PARENT",`Node ${t} has no content of its own. A field's caption is its "label" property.`)};const r=Xn(n.node);if(r)return{error:f("INVALID_PARENT",`${x(n.node)??t} is captioned by its "${r}" property, not by content: set "${r}" instead of "text" on ${t}.`)};if(Lt(n.node)===null)return{error:f("SCHEMA_INVALID",`Content of ${t} is assembled from several parts (text and bindings) — a plain string would drop the bindings, so it is not replaced.`)};const s=o===null?"":String(o),i=Mt(e,n.path,s),c=x(n.node)??t;return{schema:i.schema,describe:{kind:"update",summary:s?`${c} → текст «${s}»`:`${c} → текст убран`,report:s?`${c} → text "${s}"`:`${c} → text removed`}}}const ke=5;function Hn(e,t){const n=Dt(e);if(!n?.segments.length)return e;const o=[...n.segments],r=[];for(;o.length&&!Qn(t,o);)r.unshift(o.pop());if(!o.length)return e;const s=P(o),i=x(U(t.draft,o)),{rest:c}=Ft(e),a=r.length?` ${r.join(".")}`:"";return`${s}${i?` (${i})`:""}${a}${c}`}function Qn(e,t){const n=U(e.draft,t);return!!n&&typeof n=="object"&&!Array.isArray(n)&&"component"in n}const Zn={name:"validate_form",description:"Check the whole form at once: node structure, component names, componentProps types and links between nodes (tab ↔ panel, wizard steps). Single edits are already checked as you make them.",inputSchema:{type:"object",properties:{},additionalProperties:!1},readOnly:!0,run(e,t){const{valid:n,errors:o,warnings:r}=z(t.draft,{strict:!0,baseline:t.base}),s=[];if(n)s.push("Schema is valid: no errors.");else{const i=o.slice(0,ke);s.push(`Errors: ${o.length}.`,...i.map(c=>`- ${Hn(c,t)}`),...o.length>i.length?[`… ${o.length-i.length} more`]:[])}if(r.length){const i=r.slice(0,ke);s.push(`Node links — ${r.length} issue(s).`,...i.map(c=>`- ${c}`),...r.length>i.length?[`… ${r.length-i.length} more`]:[])}return S(s.join(`
|
|
82
|
-
`))}},eo=[In,En,Dn,_n,Zn],to=[Rn,Gn,Kn,Vn,qn,Pn,Cn,Un],no=[...eo,...to];function oo(){return kn(no)}function ro(e){const t=(o="")=>{const r=Number(o.trim());return o.trim()&&Number.isFinite(r)&&r>0?r:void 0},n={};for(const o of["maxSteps","maxOutputTokens","maxInputTokens"]){const r=t(e[o]);r!==void 0&&(n[o]=r)}return n}const ie="rb.agent.provider",we="http://localhost:11434/v1";function ae(){try{const e=localStorage.getItem(ie);if(!e)return null;const t=JSON.parse(e);return t.kind?t:null}catch{return null}}function so(e){try{localStorage.setItem(ie,JSON.stringify(e))}catch{}}function io(){try{localStorage.removeItem(ie)}catch{}}const ao={anthropic:"Anthropic",openai:"OpenAI","openai-compatible":"Локальный (OpenAI-совместимый)"},lo={anthropic:"browser",openai:"browser","openai-compatible":"loopback"};let co=null;function uo(){return co??=oo()}const po=6e3,je=12;function fo(e){if(e.text.trim().length>0)return e.text;const t=e.tools.slice(0,je).map(o=>o.summary??o.name).join("; "),n=e.tools.length-Math.min(e.tools.length,je);return`(без комментария; сделано: ${t}${n>0?` и ещё ${n}`:""})`}function mo(){const e=Me.getState().entries.filter(o=>o.text.trim().length>0||o.tools.length>0).map(o=>({role:o.role,content:o.role==="assistant"?fo(o):o.text})),t=[];let n=0;for(let o=e.length-1;o>=0&&(n+=e[o].content.length,!(n>po&&t.length));o--)t.unshift(e[o]);return t}let D=null;function ho(){D?.abort()}async function go(e,t){const n=e.trim();if(!n||D)return;const o=J(H.getState());if(!o||o.kind!=="form"){y.startTurn(n),y.finishTurn(null,"Откройте форму — ассистент правит схему активной вкладки.");return}y.startTurn(n,o.schema);const r=mo(),{maxSteps:s,maxInputTokens:i}=ae()??{},c=new AbortController;D=c;try{for await(const a of yn({provider:t,registry:uo(),base:o.schema,messages:r,...s!==void 0?{maxSteps:s}:{},...i!==void 0?{maxInputTokens:i}:{},signal:c.signal}))switch(a.type){case"text":y.appendText(a.text);break;case"reasoning":y.appendReasoning(a.text);break;case"tool":y.logTool({name:a.name,ok:a.ok,...a.ops?.length?{summary:xo(a.ops)}:{},...a.error?{error:a.error.message}:{}});break;case"done":bo(a.stats),vo(a.changeSet,a.reason,a.message);break}}finally{D=null}}const yo=3;function xo(e){const t=e.slice(0,yo).map(o=>o.summary),n=e.length-t.length;return`${t.join("; ")}${n>0?` и ещё ${n}`:""}`}function bo(e){const t=e.inputTokens?`, вход ${e.inputTokens} (из кэша ${e.cachedInputTokens}), выход ${e.outputTokens}`:"";console.info(`[agent] ход: шагов ${e.steps}${t}`)}function No(){const e=Me.getState().entries.at(-1);if(!(!e||e.role!=="assistant")&&!(e.text.trim().length>0))return e.tools.length>0?"Ассистент вызывал инструменты, но форму не изменил и ничего не ответил.":"Ассистент ничего не сделал и не ответил. Обычно это значит, что весь ответ ушёл в рассуждение: у локальной модели поможет контекстное окно побольше (num_ctx / OLLAMA_CONTEXT_LENGTH), а задачу стоит разбить на части поменьше."}function vo(e,t,n){const o=t==="error"?n??"Ход прервался ошибкой.":void 0;if(!qe(e)){y.finishTurn(null,o??No());return}const r=Ve(e);if(r.status==="applied"){y.finishTurn(null,o);return}if(r.status==="conflict"){y.setConflict(!0),y.finishTurn(e,o);return}y.finishTurn(e,o??(r.status==="invalid"?`Правки не применены — они сделали бы форму невалидной: ${r.errors.slice(0,2).join("; ")}`:"Правки не применены: форма закрыта."))}const le=new Map;function $o(e){le.set(e.id,e)}function ko(){return[...le.values()]}function wo(){return ko().find(e=>e.capabilities().tools)}function Qe(){le.clear()}async function Ze(){return st(()=>import("./byok-BM21dMSQ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))}async function jo(e){const{listModels:t}=await Ze();return t(e)}async function et(e){const{createByokProvider:t}=await Ze(),n=t(e);return Qe(),$o(n),n}async function To(){const e=ae();e?.model&&await et(e)}const Te={add:{mark:"+",className:"text-emerald-600 dark:text-emerald-400"},update:{mark:"~",className:"text-amber-600 dark:text-amber-400"},remove:{mark:"−",className:"text-rose-600 dark:text-rose-400"},move:{mark:"→",className:"text-sky-600 dark:text-sky-400"}};function So({set:e,conflict:t,onApply:n,onForceApply:o,onReject:r}){return l.jsxs("div",{className:"flex max-h-[50%] min-h-0 flex-none flex-col border-t border-border bg-muted/40 px-3 py-2.5",children:[l.jsxs("div",{className:"mb-1.5 flex-none text-[11.5px] font-semibold text-muted-foreground",children:["Изменений: ",e.ops.length]}),l.jsx(Se,{className:"mb-2 min-h-0 flex-1",children:l.jsx("ul",{className:"space-y-0.5",children:e.ops.map((s,i)=>l.jsxs("li",{className:"flex gap-1.5 text-[12px] leading-5",children:[l.jsx("span",{className:K("flex-none font-mono",Te[s.kind].className),children:Te[s.kind].mark}),l.jsx("span",{className:"min-w-0 break-words",children:s.summary})]},`${s.ref}-${i}`))})}),t&&l.jsxs(F,{className:"mb-2 flex-none border-amber-500/40 bg-amber-500/10 py-2",children:[l.jsx(it,{className:"text-amber-600 dark:text-amber-400"}),l.jsx(q,{className:"text-[11.5px] leading-4",children:"Форму изменили, пока ассистент работал. Применение перезапишет эти правки."})]}),l.jsxs("div",{className:"flex flex-none gap-2",children:[l.jsxs(w,{size:"sm",className:"flex-1",onClick:t?o:n,children:[l.jsx(Fe,{}),t?"Применить всё равно":"Применить"]}),l.jsxs(w,{variant:"outline",size:"sm",onClick:r,children:[l.jsx(zt,{}),"Отклонить"]})]})]})}function _o({disabled:e,onRestore:t,title:n}){return l.jsxs("button",{type:"button",disabled:e,onClick:t,title:`Вернуть форму к состоянию перед «${n.slice(0,40)}${n.length>40?"…":""}»`,className:K("absolute -top-2 right-1 inline-flex items-center gap-1 rounded-md border border-border","bg-background px-1.5 py-0.5 text-[10.5px] leading-4 text-muted-foreground shadow-sm","opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100","hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","disabled:pointer-events-none disabled:opacity-0"),children:[l.jsx(ht,{className:"size-3"}),"Восстановить"]})}function Po({text:e}){const[t,n]=g.useState(!1);return l.jsxs(pt,{open:t,onOpenChange:n,className:"space-y-1",children:[l.jsxs(ft,{className:"flex items-center gap-1 text-[11.5px] leading-4 text-muted-foreground hover:text-foreground",children:[l.jsx(Ut,{className:K("size-3 flex-none transition-transform",t&&"rotate-90")}),"Рассуждение"]}),l.jsx(mt,{children:l.jsx("div",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words border-l-2 border-border pl-2 text-[11.5px] leading-4 text-muted-foreground",children:e})})]})}function Ao({entries:e,running:t,onRestore:n}){const o=g.useRef(null);return g.useEffect(()=>{o.current?.scrollIntoView({block:"end"})},[e,t]),e.length?l.jsx(Se,{className:"min-h-0 flex-1",children:l.jsxs("div",{className:"space-y-3 px-3 py-3",children:[e.map(r=>l.jsxs("div",{className:"space-y-1.5",children:[r.reasoning&&l.jsx(Po,{text:r.reasoning}),r.text&&l.jsxs("div",{className:K("group relative whitespace-pre-wrap break-words text-[12.5px] leading-5",r.role==="user"?"rounded-md bg-muted px-2.5 py-1.5":"text-foreground"),children:[r.text,r.role==="user"&&r.snapshot&&n&&l.jsx(_o,{disabled:t,onRestore:()=>n(r.id),title:r.text})]}),r.tools.length>0&&l.jsx("ul",{className:"space-y-0.5",children:r.tools.map((s,i)=>l.jsxs("li",{className:"flex gap-1.5 text-[11.5px] leading-4 text-muted-foreground",children:[s.ok?l.jsx(Fe,{className:"mt-px size-3 flex-none text-emerald-600 dark:text-emerald-400"}):l.jsx(_e,{className:"mt-px size-3 flex-none text-amber-600 dark:text-amber-400"}),l.jsx("span",{className:"min-w-0 break-words",children:s.summary??s.error??s.name})]},`${r.id}-${i}`))})]},r.id)),t&&l.jsxs("div",{className:"flex items-center gap-1.5 text-[11.5px] text-muted-foreground",children:[l.jsx(Pe,{className:"size-3"}),"Работаю…"]}),l.jsx("div",{ref:o})]})}):l.jsx(at,{className:"flex-1 p-6",children:l.jsxs(lt,{children:[l.jsx(ct,{variant:"icon",children:l.jsx(dt,{})}),l.jsx(ut,{className:"text-[12px] leading-5",children:"Опишите, что нужно сделать с формой: «добавь поле email», «сделай телефон обязательным», «поставь имя и фамилию в одну строку»."})]})})}const Oo=["anthropic","openai","openai-compatible"],Eo={browser:"Запросы идут из браузера напрямую к провайдеру. Ключ хранится в этом браузере и доступен странице — используйте ключ с ограниченным бюджетом.",loopback:"Запросы идут на локальный сервер и наружу не уходят."};function Io({onConnected:e}){const t=ae(),[n,o]=g.useState(t?.kind??"anthropic"),[r,s]=g.useState(t?.apiKey??""),[i,c]=g.useState(t?.baseUrl??we),[a,d]=g.useState([]),[p,h]=g.useState(t?.model??""),[v,T]=g.useState(t?.maxOutputTokens?String(t.maxOutputTokens):""),[m,$]=g.useState(t?.maxSteps?String(t.maxSteps):""),[L,tt]=g.useState(t?.maxInputTokens?String(t.maxInputTokens):""),[W,M]=g.useState(!1),[ce,E]=g.useState(null),de=()=>({kind:n,...r?{apiKey:r}:{},...n==="openai-compatible"?{baseUrl:i}:{},...p?{model:p}:{},...ro({maxSteps:m,maxOutputTokens:v,maxInputTokens:L})}),nt=async()=>{M(!0),E(null);try{const u=await jo(de());d(u),u.length&&!u.includes(p)&&h(u[0]),u.length||E("Провайдер вернул пустой список моделей.")}catch(u){E(u instanceof Error?u.message:String(u)),d([])}finally{M(!1)}},ot=async()=>{M(!0),E(null);try{const u=de();await et(u),so(u),e()}catch(u){E(u instanceof Error?u.message:String(u))}finally{M(!1)}},rt=()=>{io(),Qe(),s(""),h(""),d([])};return l.jsxs("div",{className:"space-y-3 px-3 py-3",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(k,{htmlFor:"rb-agent-provider",className:"text-[11.5px] text-muted-foreground",children:"Провайдер"}),l.jsxs(ue,{value:n,onValueChange:u=>{o(u),d([]),h("")},children:[l.jsx(pe,{id:"rb-agent-provider",size:"sm",className:"w-full",children:l.jsx(fe,{})}),l.jsx(me,{children:Oo.map(u=>l.jsx(he,{value:u,children:ao[u]},u))})]})]}),n==="openai-compatible"&&l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(k,{htmlFor:"rb-agent-base-url",className:"text-[11.5px] text-muted-foreground",children:"Адрес сервера"}),l.jsx(I,{id:"rb-agent-base-url",value:i,onChange:u=>c(u.target.value),onKeyDown:u=>u.stopPropagation(),placeholder:we,className:"h-8"})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsxs(k,{htmlFor:"rb-agent-key",className:"text-[11.5px] text-muted-foreground",children:["Ключ API",n==="openai-compatible"?" (обычно не нужен)":""]}),l.jsx(I,{id:"rb-agent-key",type:"password",value:r,onChange:u=>s(u.target.value),onKeyDown:u=>u.stopPropagation(),autoComplete:"off",placeholder:"sk-…",className:"h-8"})]}),l.jsxs(w,{variant:"outline",size:"sm",className:"w-full",onClick:nt,disabled:W,children:[W&&l.jsx(Pe,{className:"size-3.5"}),"Загрузить список моделей"]}),a.length>0&&l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(k,{htmlFor:"rb-agent-model",className:"text-[11.5px] text-muted-foreground",children:"Модель"}),l.jsxs(ue,{value:p,onValueChange:h,children:[l.jsx(pe,{id:"rb-agent-model",size:"sm",className:"w-full",children:l.jsx(fe,{})}),l.jsx(me,{children:a.map(u=>l.jsx(he,{value:u,children:u},u))})]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(k,{htmlFor:"rb-agent-max-steps",className:"text-[11.5px] text-muted-foreground",children:"Шагов за ход"}),l.jsx(I,{id:"rb-agent-max-steps",type:"number",min:1,value:m,onChange:u=>$(u.target.value),onKeyDown:u=>u.stopPropagation(),placeholder:"без предела",className:"h-8"})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(k,{htmlFor:"rb-agent-max-output",className:"text-[11.5px] text-muted-foreground",children:"Ответ за шаг, токенов"}),l.jsx(I,{id:"rb-agent-max-output",type:"number",min:256,value:v,onChange:u=>T(u.target.value),onKeyDown:u=>u.stopPropagation(),placeholder:"без предела",className:"h-8"})]})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(k,{htmlFor:"rb-agent-max-input",className:"text-[11.5px] text-muted-foreground",children:"Вход за ход, токенов"}),l.jsx(I,{id:"rb-agent-max-input",type:"number",min:1e3,value:L,onChange:u=>tt(u.target.value),onKeyDown:u=>u.stopPropagation(),placeholder:"без предела",className:"h-8"})]}),l.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Пустые поля — без ограничений. На платном канале страхует от разгона именно предел по входным токенам: цена шага растёт вместе с диалогом, поэтому счёт зависит от них, а не от числа вызовов. Занижать любой из пределов не стоит — ход оборвётся на середине формы."}),ce&&l.jsx(F,{variant:"destructive",children:l.jsx(q,{className:"text-[11.5px] leading-4",children:ce})}),l.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:Eo[lo[n]]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(w,{size:"sm",className:"flex-1",onClick:ot,disabled:W||!p,children:"Подключить"}),l.jsx(w,{variant:"outline",size:"sm",onClick:rt,children:"Забыть ключ"})]})]})}function Co(){const e=qt(),[t,n]=g.useState(""),[o,r]=g.useState(null),[,s]=g.useState(0),i=()=>s(m=>m+1);g.useEffect(()=>{To().then(i)},[]);const c=wo(),a=e.status==="running",d=e.settingsOpen||!c,p=()=>{const m=t.trim();!m||a||!c||(n(""),r(null),go(m,c))},h=m=>{m.stopPropagation(),m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),p())},v=m=>{if(a)return;const $=e.entries.find(L=>L.id===m);$?.snapshot&&(Ae.replaceSchema($.snapshot),y.restoreTo(m),r(null),n($.text))},T=m=>{if(!e.pending)return;const $=Ve(e.pending,{force:m});switch($.status){case"applied":y.resolvePending(),r(null);break;case"conflict":y.setConflict(!0);break;case"no-form":r("Нет открытой формы: вкладку закрыли или переключили на код.");break;case"invalid":r(`Изменения не прошли проверку: ${$.errors.slice(0,2).join("; ")}`);break;case"empty":y.resolvePending();break}};return d?l.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:l.jsx(Io,{onConnected:()=>{i(),y.setSettings(!1)}})}):l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[l.jsx(Ao,{entries:e.entries,running:a,onRestore:v}),e.error&&l.jsx("div",{className:"flex-none border-t border-border p-2",children:l.jsxs(F,{variant:"destructive",className:"py-2",children:[l.jsx(_e,{}),l.jsx(q,{className:"text-[11.5px] leading-4",children:e.error})]})}),o&&l.jsx("div",{className:"flex-none border-t border-border p-2",children:l.jsx(F,{className:"py-2",children:l.jsx(q,{className:"text-[11.5px] leading-4",children:o})})}),e.pending&&l.jsx(So,{set:e.pending,conflict:e.conflict||Bt(e.pending),onApply:()=>T(!1),onForceApply:()=>T(!0),onReject:y.resolvePending}),l.jsx("footer",{className:"flex-none border-t border-border p-2",children:l.jsxs("div",{className:"flex items-end gap-1.5",children:[l.jsx(gt,{value:t,onChange:m=>n(m.target.value),onKeyDown:h,rows:2,placeholder:"Что сделать с формой?",disabled:a,className:"min-h-[38px] flex-1 resize-none px-2 py-1.5 text-[12.5px] md:text-[12.5px]"}),a?l.jsx(w,{variant:"outline",size:"icon-sm",title:"Остановить",onClick:ho,children:l.jsx(yt,{})}):l.jsx(w,{size:"icon-sm",title:"Отправить (Enter)",onClick:p,disabled:!t.trim(),children:l.jsx(xt,{})})]})})]})}const qo=Object.freeze(Object.defineProperty({__proto__:null,ChatPanel:Co},Symbol.toStringTag,{value:"Module"}));export{qo as C,we as D,lo as P,ao as a};
|
|
82
|
+
`))}},eo=[In,En,Dn,_n,Zn],to=[Rn,Gn,Kn,Vn,qn,Pn,Cn,Un],no=[...eo,...to];function oo(){return kn(no)}function ro(e){const t=(o="")=>{const r=Number(o.trim());return o.trim()&&Number.isFinite(r)&&r>0?r:void 0},n={};for(const o of["maxSteps","maxOutputTokens","maxInputTokens"]){const r=t(e[o]);r!==void 0&&(n[o]=r)}return n}const ie="rb.agent.provider",we="http://localhost:11434/v1";function ae(){try{const e=localStorage.getItem(ie);if(!e)return null;const t=JSON.parse(e);return t.kind?t:null}catch{return null}}function so(e){try{localStorage.setItem(ie,JSON.stringify(e))}catch{}}function io(){try{localStorage.removeItem(ie)}catch{}}const ao={anthropic:"Anthropic",openai:"OpenAI","openai-compatible":"Локальный (OpenAI-совместимый)"},lo={anthropic:"browser",openai:"browser","openai-compatible":"loopback"};let co=null;function uo(){return co??=oo()}const po=6e3,je=12;function fo(e){if(e.text.trim().length>0)return e.text;const t=e.tools.slice(0,je).map(o=>o.summary??o.name).join("; "),n=e.tools.length-Math.min(e.tools.length,je);return`(без комментария; сделано: ${t}${n>0?` и ещё ${n}`:""})`}function mo(){const e=Me.getState().entries.filter(o=>o.text.trim().length>0||o.tools.length>0).map(o=>({role:o.role,content:o.role==="assistant"?fo(o):o.text})),t=[];let n=0;for(let o=e.length-1;o>=0&&(n+=e[o].content.length,!(n>po&&t.length));o--)t.unshift(e[o]);return t}let D=null;function ho(){D?.abort()}async function go(e,t){const n=e.trim();if(!n||D)return;const o=J(H.getState());if(!o||o.kind!=="form"){y.startTurn(n),y.finishTurn(null,"Откройте форму — ассистент правит схему активной вкладки.");return}y.startTurn(n,o.schema);const r=mo(),{maxSteps:s,maxInputTokens:i}=ae()??{},c=new AbortController;D=c;try{for await(const a of yn({provider:t,registry:uo(),base:o.schema,messages:r,...s!==void 0?{maxSteps:s}:{},...i!==void 0?{maxInputTokens:i}:{},signal:c.signal}))switch(a.type){case"text":y.appendText(a.text);break;case"reasoning":y.appendReasoning(a.text);break;case"tool":y.logTool({name:a.name,ok:a.ok,...a.ops?.length?{summary:xo(a.ops)}:{},...a.error?{error:a.error.message}:{}});break;case"done":bo(a.stats),vo(a.changeSet,a.reason,a.message);break}}finally{D=null}}const yo=3;function xo(e){const t=e.slice(0,yo).map(o=>o.summary),n=e.length-t.length;return`${t.join("; ")}${n>0?` и ещё ${n}`:""}`}function bo(e){const t=e.inputTokens?`, вход ${e.inputTokens} (из кэша ${e.cachedInputTokens}), выход ${e.outputTokens}`:"";console.info(`[agent] ход: шагов ${e.steps}${t}`)}function No(){const e=Me.getState().entries.at(-1);if(!(!e||e.role!=="assistant")&&!(e.text.trim().length>0))return e.tools.length>0?"Ассистент вызывал инструменты, но форму не изменил и ничего не ответил.":"Ассистент ничего не сделал и не ответил. Обычно это значит, что весь ответ ушёл в рассуждение: у локальной модели поможет контекстное окно побольше (num_ctx / OLLAMA_CONTEXT_LENGTH), а задачу стоит разбить на части поменьше."}function vo(e,t,n){const o=t==="error"?n??"Ход прервался ошибкой.":void 0;if(!qe(e)){y.finishTurn(null,o??No());return}const r=Ve(e);if(r.status==="applied"){y.finishTurn(null,o);return}if(r.status==="conflict"){y.setConflict(!0),y.finishTurn(e,o);return}y.finishTurn(e,o??(r.status==="invalid"?`Правки не применены — они сделали бы форму невалидной: ${r.errors.slice(0,2).join("; ")}`:"Правки не применены: форма закрыта."))}const le=new Map;function $o(e){le.set(e.id,e)}function ko(){return[...le.values()]}function wo(){return ko().find(e=>e.capabilities().tools)}function Qe(){le.clear()}async function Ze(){return st(()=>import("./byok-B9mwOrn0.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))}async function jo(e){const{listModels:t}=await Ze();return t(e)}async function et(e){const{createByokProvider:t}=await Ze(),n=t(e);return Qe(),$o(n),n}async function To(){const e=ae();e?.model&&await et(e)}const Te={add:{mark:"+",className:"text-emerald-600 dark:text-emerald-400"},update:{mark:"~",className:"text-amber-600 dark:text-amber-400"},remove:{mark:"−",className:"text-rose-600 dark:text-rose-400"},move:{mark:"→",className:"text-sky-600 dark:text-sky-400"}};function So({set:e,conflict:t,onApply:n,onForceApply:o,onReject:r}){return l.jsxs("div",{className:"flex max-h-[50%] min-h-0 flex-none flex-col border-t border-border bg-muted/40 px-3 py-2.5",children:[l.jsxs("div",{className:"mb-1.5 flex-none text-[11.5px] font-semibold text-muted-foreground",children:["Изменений: ",e.ops.length]}),l.jsx(Se,{className:"mb-2 min-h-0 flex-1",children:l.jsx("ul",{className:"space-y-0.5",children:e.ops.map((s,i)=>l.jsxs("li",{className:"flex gap-1.5 text-[12px] leading-5",children:[l.jsx("span",{className:K("flex-none font-mono",Te[s.kind].className),children:Te[s.kind].mark}),l.jsx("span",{className:"min-w-0 break-words",children:s.summary})]},`${s.ref}-${i}`))})}),t&&l.jsxs(F,{className:"mb-2 flex-none border-amber-500/40 bg-amber-500/10 py-2",children:[l.jsx(it,{className:"text-amber-600 dark:text-amber-400"}),l.jsx(q,{className:"text-[11.5px] leading-4",children:"Форму изменили, пока ассистент работал. Применение перезапишет эти правки."})]}),l.jsxs("div",{className:"flex flex-none gap-2",children:[l.jsxs(w,{size:"sm",className:"flex-1",onClick:t?o:n,children:[l.jsx(Fe,{}),t?"Применить всё равно":"Применить"]}),l.jsxs(w,{variant:"outline",size:"sm",onClick:r,children:[l.jsx(zt,{}),"Отклонить"]})]})]})}function _o({disabled:e,onRestore:t,title:n}){return l.jsxs("button",{type:"button",disabled:e,onClick:t,title:`Вернуть форму к состоянию перед «${n.slice(0,40)}${n.length>40?"…":""}»`,className:K("absolute -top-2 right-1 inline-flex items-center gap-1 rounded-md border border-border","bg-background px-1.5 py-0.5 text-[10.5px] leading-4 text-muted-foreground shadow-sm","opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100","hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","disabled:pointer-events-none disabled:opacity-0"),children:[l.jsx(ht,{className:"size-3"}),"Восстановить"]})}function Po({text:e}){const[t,n]=g.useState(!1);return l.jsxs(pt,{open:t,onOpenChange:n,className:"space-y-1",children:[l.jsxs(ft,{className:"flex items-center gap-1 text-[11.5px] leading-4 text-muted-foreground hover:text-foreground",children:[l.jsx(Ut,{className:K("size-3 flex-none transition-transform",t&&"rotate-90")}),"Рассуждение"]}),l.jsx(mt,{children:l.jsx("div",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap break-words border-l-2 border-border pl-2 text-[11.5px] leading-4 text-muted-foreground",children:e})})]})}function Ao({entries:e,running:t,onRestore:n}){const o=g.useRef(null);return g.useEffect(()=>{o.current?.scrollIntoView({block:"end"})},[e,t]),e.length?l.jsx(Se,{className:"min-h-0 flex-1",children:l.jsxs("div",{className:"space-y-3 px-3 py-3",children:[e.map(r=>l.jsxs("div",{className:"space-y-1.5",children:[r.reasoning&&l.jsx(Po,{text:r.reasoning}),r.text&&l.jsxs("div",{className:K("group relative whitespace-pre-wrap break-words text-[12.5px] leading-5",r.role==="user"?"rounded-md bg-muted px-2.5 py-1.5":"text-foreground"),children:[r.text,r.role==="user"&&r.snapshot&&n&&l.jsx(_o,{disabled:t,onRestore:()=>n(r.id),title:r.text})]}),r.tools.length>0&&l.jsx("ul",{className:"space-y-0.5",children:r.tools.map((s,i)=>l.jsxs("li",{className:"flex gap-1.5 text-[11.5px] leading-4 text-muted-foreground",children:[s.ok?l.jsx(Fe,{className:"mt-px size-3 flex-none text-emerald-600 dark:text-emerald-400"}):l.jsx(_e,{className:"mt-px size-3 flex-none text-amber-600 dark:text-amber-400"}),l.jsx("span",{className:"min-w-0 break-words",children:s.summary??s.error??s.name})]},`${r.id}-${i}`))})]},r.id)),t&&l.jsxs("div",{className:"flex items-center gap-1.5 text-[11.5px] text-muted-foreground",children:[l.jsx(Pe,{className:"size-3"}),"Работаю…"]}),l.jsx("div",{ref:o})]})}):l.jsx(at,{className:"flex-1 p-6",children:l.jsxs(lt,{children:[l.jsx(ct,{variant:"icon",children:l.jsx(dt,{})}),l.jsx(ut,{className:"text-[12px] leading-5",children:"Опишите, что нужно сделать с формой: «добавь поле email», «сделай телефон обязательным», «поставь имя и фамилию в одну строку»."})]})})}const Oo=["anthropic","openai","openai-compatible"],Eo={browser:"Запросы идут из браузера напрямую к провайдеру. Ключ хранится в этом браузере и доступен странице — используйте ключ с ограниченным бюджетом.",loopback:"Запросы идут на локальный сервер и наружу не уходят."};function Io({onConnected:e}){const t=ae(),[n,o]=g.useState(t?.kind??"anthropic"),[r,s]=g.useState(t?.apiKey??""),[i,c]=g.useState(t?.baseUrl??we),[a,d]=g.useState([]),[p,h]=g.useState(t?.model??""),[v,T]=g.useState(t?.maxOutputTokens?String(t.maxOutputTokens):""),[m,$]=g.useState(t?.maxSteps?String(t.maxSteps):""),[L,tt]=g.useState(t?.maxInputTokens?String(t.maxInputTokens):""),[W,M]=g.useState(!1),[ce,E]=g.useState(null),de=()=>({kind:n,...r?{apiKey:r}:{},...n==="openai-compatible"?{baseUrl:i}:{},...p?{model:p}:{},...ro({maxSteps:m,maxOutputTokens:v,maxInputTokens:L})}),nt=async()=>{M(!0),E(null);try{const u=await jo(de());d(u),u.length&&!u.includes(p)&&h(u[0]),u.length||E("Провайдер вернул пустой список моделей.")}catch(u){E(u instanceof Error?u.message:String(u)),d([])}finally{M(!1)}},ot=async()=>{M(!0),E(null);try{const u=de();await et(u),so(u),e()}catch(u){E(u instanceof Error?u.message:String(u))}finally{M(!1)}},rt=()=>{io(),Qe(),s(""),h(""),d([])};return l.jsxs("div",{className:"space-y-3 px-3 py-3",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(k,{htmlFor:"rb-agent-provider",className:"text-[11.5px] text-muted-foreground",children:"Провайдер"}),l.jsxs(ue,{value:n,onValueChange:u=>{o(u),d([]),h("")},children:[l.jsx(pe,{id:"rb-agent-provider",size:"sm",className:"w-full",children:l.jsx(fe,{})}),l.jsx(me,{children:Oo.map(u=>l.jsx(he,{value:u,children:ao[u]},u))})]})]}),n==="openai-compatible"&&l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(k,{htmlFor:"rb-agent-base-url",className:"text-[11.5px] text-muted-foreground",children:"Адрес сервера"}),l.jsx(I,{id:"rb-agent-base-url",value:i,onChange:u=>c(u.target.value),onKeyDown:u=>u.stopPropagation(),placeholder:we,className:"h-8"})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsxs(k,{htmlFor:"rb-agent-key",className:"text-[11.5px] text-muted-foreground",children:["Ключ API",n==="openai-compatible"?" (обычно не нужен)":""]}),l.jsx(I,{id:"rb-agent-key",type:"password",value:r,onChange:u=>s(u.target.value),onKeyDown:u=>u.stopPropagation(),autoComplete:"off",placeholder:"sk-…",className:"h-8"})]}),l.jsxs(w,{variant:"outline",size:"sm",className:"w-full",onClick:nt,disabled:W,children:[W&&l.jsx(Pe,{className:"size-3.5"}),"Загрузить список моделей"]}),a.length>0&&l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(k,{htmlFor:"rb-agent-model",className:"text-[11.5px] text-muted-foreground",children:"Модель"}),l.jsxs(ue,{value:p,onValueChange:h,children:[l.jsx(pe,{id:"rb-agent-model",size:"sm",className:"w-full",children:l.jsx(fe,{})}),l.jsx(me,{children:a.map(u=>l.jsx(he,{value:u,children:u},u))})]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(k,{htmlFor:"rb-agent-max-steps",className:"text-[11.5px] text-muted-foreground",children:"Шагов за ход"}),l.jsx(I,{id:"rb-agent-max-steps",type:"number",min:1,value:m,onChange:u=>$(u.target.value),onKeyDown:u=>u.stopPropagation(),placeholder:"без предела",className:"h-8"})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(k,{htmlFor:"rb-agent-max-output",className:"text-[11.5px] text-muted-foreground",children:"Ответ за шаг, токенов"}),l.jsx(I,{id:"rb-agent-max-output",type:"number",min:256,value:v,onChange:u=>T(u.target.value),onKeyDown:u=>u.stopPropagation(),placeholder:"без предела",className:"h-8"})]})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(k,{htmlFor:"rb-agent-max-input",className:"text-[11.5px] text-muted-foreground",children:"Вход за ход, токенов"}),l.jsx(I,{id:"rb-agent-max-input",type:"number",min:1e3,value:L,onChange:u=>tt(u.target.value),onKeyDown:u=>u.stopPropagation(),placeholder:"без предела",className:"h-8"})]}),l.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:"Пустые поля — без ограничений. На платном канале страхует от разгона именно предел по входным токенам: цена шага растёт вместе с диалогом, поэтому счёт зависит от них, а не от числа вызовов. Занижать любой из пределов не стоит — ход оборвётся на середине формы."}),ce&&l.jsx(F,{variant:"destructive",children:l.jsx(q,{className:"text-[11.5px] leading-4",children:ce})}),l.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:Eo[lo[n]]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(w,{size:"sm",className:"flex-1",onClick:ot,disabled:W||!p,children:"Подключить"}),l.jsx(w,{variant:"outline",size:"sm",onClick:rt,children:"Забыть ключ"})]})]})}function Co(){const e=qt(),[t,n]=g.useState(""),[o,r]=g.useState(null),[,s]=g.useState(0),i=()=>s(m=>m+1);g.useEffect(()=>{To().then(i)},[]);const c=wo(),a=e.status==="running",d=e.settingsOpen||!c,p=()=>{const m=t.trim();!m||a||!c||(n(""),r(null),go(m,c))},h=m=>{m.stopPropagation(),m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),p())},v=m=>{if(a)return;const $=e.entries.find(L=>L.id===m);$?.snapshot&&(Ae.replaceSchema($.snapshot),y.restoreTo(m),r(null),n($.text))},T=m=>{if(!e.pending)return;const $=Ve(e.pending,{force:m});switch($.status){case"applied":y.resolvePending(),r(null);break;case"conflict":y.setConflict(!0);break;case"no-form":r("Нет открытой формы: вкладку закрыли или переключили на код.");break;case"invalid":r(`Изменения не прошли проверку: ${$.errors.slice(0,2).join("; ")}`);break;case"empty":y.resolvePending();break}};return d?l.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:l.jsx(Io,{onConnected:()=>{i(),y.setSettings(!1)}})}):l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[l.jsx(Ao,{entries:e.entries,running:a,onRestore:v}),e.error&&l.jsx("div",{className:"flex-none border-t border-border p-2",children:l.jsxs(F,{variant:"destructive",className:"py-2",children:[l.jsx(_e,{}),l.jsx(q,{className:"text-[11.5px] leading-4",children:e.error})]})}),o&&l.jsx("div",{className:"flex-none border-t border-border p-2",children:l.jsx(F,{className:"py-2",children:l.jsx(q,{className:"text-[11.5px] leading-4",children:o})})}),e.pending&&l.jsx(So,{set:e.pending,conflict:e.conflict||Bt(e.pending),onApply:()=>T(!1),onForceApply:()=>T(!0),onReject:y.resolvePending}),l.jsx("footer",{className:"flex-none border-t border-border p-2",children:l.jsxs("div",{className:"flex items-end gap-1.5",children:[l.jsx(gt,{value:t,onChange:m=>n(m.target.value),onKeyDown:h,rows:2,placeholder:"Что сделать с формой?",disabled:a,className:"min-h-[38px] flex-1 resize-none px-2 py-1.5 text-[12.5px] md:text-[12.5px]"}),a?l.jsx(w,{variant:"outline",size:"icon-sm",title:"Остановить",onClick:ho,children:l.jsx(yt,{})}):l.jsx(w,{size:"icon-sm",title:"Отправить (Enter)",onClick:p,disabled:!t.trim(),children:l.jsx(xt,{})})]})})]})}const qo=Object.freeze(Object.defineProperty({__proto__:null,ChatPanel:Co},Symbol.toStringTag,{value:"Module"}));export{qo as C,we as D,lo as P,ao as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as m}from"./index-
|
|
1
|
+
import{j as m}from"./index-DhcNqNgT.js";import{F as n}from"./monaco-setup-1PbjxubL.js";import"./monaco-languages-BZWxuU3F.js";import"./editor.api-BWDeQ8t4.js";import"./App-BupMDG_t.js";import"./reformer-ui-kit-tUqYBSLv.js";import"./index-CF7RI8Bt.js";import"./useFormField-BLbvmpme-Dwz_jyMW.js";import"./index-eRs9yupj.js";import"./load-QsSQTL2T.js";import"./boot-BCJd6Ujw.js";function z({value:o,language:t,theme:r,onChange:i,onMount:e}){return m.jsx(n,{height:"100%",language:t,theme:r==="dark"?"vs-dark":"light",value:o,onChange:a=>i(a??""),onMount:e,options:{minimap:{enabled:!1},fontSize:12,lineNumbers:"on",folding:!0,scrollBeyondLastLine:!1,tabSize:2,wordWrap:"off",automaticLayout:!0,renderLineHighlight:"line",scrollbar:{verticalScrollbarSize:10,horizontalScrollbarSize:10},padding:{top:8,bottom:8}}})}export{z as default};
|