@ycodium-ai/plugin-im 0.2.3180 → 0.2.3192

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/assets/ui.js CHANGED
@@ -1,8 +1,8 @@
1
- var rn=window.__ycodiumPluginHost.react;var{Activity:vn,Children:Sn,Component:bn,Fragment:pn,Profiler:wn,PureComponent:In,StrictMode:hn,Suspense:Cn,__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:xn,__COMPILER_RUNTIME:kn,act:Rn,cache:Tn,cacheSignal:Nn,captureOwnerStack:Pn,cloneElement:An,createContext:z,createElement:me,createRef:En,forwardRef:On,isValidElement:_n,lazy:Bn,memo:Ln,startTransition:Vn,unstable_useCacheRefresh:Fn,use:$,useActionState:Dn,useCallback:Kn,useContext:Mn,useDebugValue:Gn,useDeferredValue:Un,useEffect:we,useEffectEvent:Hn,useId:zn,useImperativeHandle:$n,useInsertionEffect:qn,useLayoutEffect:Yn,useMemo:T,useOptimistic:Wn,useReducer:jn,useRef:E,useState:p,useSyncExternalStore:Qn,useTransition:Jn,version:Zn}=rn;var q=(e,n)=>{let t=e[n];return typeof t=="string"?t.trim():""};var Ie="settings.view",he="settings.saveBot",Ce="settings.removeBot",xe="settings.saveGeneral",ke="settings.saveTarget",Re="settings.removeTarget",Te="larkSetup.session",D={labelKey:"setup.action.label",descriptionKey:"setup.action.description",badgeKey:"setup.action.badge",warningKey:"setup.action.warning"},Ne={checkConnection:"im.settings.checkConnection",copyDiagnostics:"im.settings.copyDiagnostics",larkRepair:"im.settings.larkRepair"},Pe=[{id:"checkConnection",labelKey:"rowAction.checkConnection.label",descriptionKey:"rowAction.checkConnection.description"},{id:"copyDiagnostics",labelKey:"rowAction.copyDiagnostics.label",descriptionKey:"rowAction.copyDiagnostics.description"},{id:"larkRepair",labelKey:"rowAction.larkRepair.label",descriptionKey:"rowAction.larkRepair.description",platform:"lark"}],on="lark",Y=[{value:"zh-CN",labelKey:"settings.language.zhCN"},{value:"en",labelKey:"settings.language.en"}],ln="botId",W=e=>q(e,"platform")||on,Ae=(e,n)=>{let t=e.showWhen;if(t===void 0)return!0;let r=t.key==="platform"?W(n):q(n,t.key);return t.equals.includes(r)},Ee=(e,n,t)=>e.map(r=>r.key===ln?{...r,kind:"select",options:n.map(l=>({value:l.rowId,label:`${q(l.values,"displayName")||t(l.platform)} (${l.rowId})`}))}:r),Oe=(e,n)=>{switch(n.kind){case"qr":{let{expired:t,...r}=e,l=n.expiresAt===void 0?{payload:n.payload}:{payload:n.payload,expiresAt:n.expiresAt};return{...r,qr:l}}case"status":{let t=n.params===void 0?{statusKey:n.statusKey}:{statusKey:n.statusKey,params:n.params};if(n.expired!==!0)return{...e,status:t};let{qr:r,...l}=e;return{...l,status:t,expired:!0}}case"steps":return{...e,steps:n.steps};case"done":case"failed":{let{status:t,...r}=e;return{...r,result:n}}}};var{jsx:i,jsxs:d,Fragment:x}=window.__ycodiumPluginHost.jsxRuntime;var _e=z(null);function Be(e){return i(_e,{value:e.bridge,children:e.children})}var an=new Set(["Collapsible","CollapsiblePanel","CollapsibleTrigger"]);function f(e){let n=t=>{let o=$(_e)?.ui?.[e];return o===void 0?an.has(e)?me("div",{className:t.className},t.children):null:me(o,t)};return n.displayName=e,n}var y=f("Button"),O=f("Input"),_=f("Label"),Le=f("Switch"),j=f("Select"),Q=f("SelectTrigger"),K=f("SelectValue"),J=f("SelectPopup"),Z=f("SelectItem"),Ve=f("StatusPill"),Fe=f("EmptyInline"),X=f("Alert"),De=f("AlertAction"),ee=f("AlertDescription"),Ke=f("Collapsible"),Me=f("CollapsibleTrigger"),Ge=f("CollapsiblePanel"),N=f("Spinner"),Ue=f("QRCodeSvg"),He=f("ProxyChoiceSelect");var ne=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),ze=e=>ne(e)&&Array.isArray(e.bots)&&Array.isArray(e.targets)&&ne(e.delivery),$e=e=>ne(e)&&ze(e.view)&&Array.isArray(e.columns)&&Array.isArray(e.targetColumns)&&Array.isArray(e.proxies)?e:null,M=async(e,n,t,r)=>{try{let l=await e.commands.invoke(n,t,r);return ne(l)&&l.ok===!0&&ze(l.view)?l.view:null}catch{return null}},qe=(e,n)=>n.isPending?e.phase==="asked"?{...e,phase:"refetching"}:e:n.view!==null&&!n.failed?e.phase==="refetching"||JSON.stringify(n.view)===JSON.stringify(e.view)?null:e:e.phase==="asked"?e:{...e,phase:"asked"},k=e=>e==null||e.length===0?{}:{environmentId:e},ge=e=>JSON.stringify(e),G=(e,n)=>n===null?e:`${e}:${n}`,ye=e=>JSON.stringify([e.replyLanguage,e.delivery]);function B(e,n,t){if(n!==void 0&&n.length>0)return e(n);if(t!==void 0&&t.length>0)return t}function Ye(e,n){return n.length===0?null:n.map(t=>e(t==="required"?"settingsSection.issue.required":"settingsSection.issue.format")).join(" ")}function P(e,n,t){return`im-${(e??"here").replace(/[^A-Za-z0-9_-]/g,"")}-${n}-${t}`}function U(e,n,t){let r=[n?`${e}-issue`:null,t?`${e}-hint`:null].filter(l=>l!==null);return r.length===0?void 0:r.join(" ")}function R(e){return d("div",{className:e.span===!0?"im-field im-span":"im-field",children:[i(_,{htmlFor:e.id,children:e.label}),e.children,e.issue?i("p",{id:`${e.id}-issue`,className:"im-small im-issue",role:"alert",children:e.issue}):null,e.description===void 0?null:i("p",{id:`${e.id}-hint`,className:"im-hint im-small im-muted",children:e.description})]})}function te(e){let n=e.stored&&e.value===""&&!e.clearing?e.savedPlaceholder:e.placeholder;return d("div",{className:"im-secret",children:[i(O,{id:e.id,type:"password",value:e.value,placeholder:n,disabled:e.disabled,autoComplete:"new-password","aria-invalid":e.invalid?!0:void 0,"aria-describedby":e.describedBy,onChange:t=>e.onChange(t.target.value)}),e.stored?i(y,{variant:"ghost",size:"sm","aria-pressed":e.clearing,disabled:e.disabled,onClick:e.onToggleClear,children:e.clearing?e.undoLabel:e.clearLabel}):null]})}function ie(e){let n=e.saving||e.busy===!0;return!e.dirty&&!e.saving&&!e.failed?null:d("div",{className:"im-span",children:[e.dirty||e.saving?d("div",{className:"im-actions",children:[d(y,{variant:e.solid?"default":"outline",disabled:n||!e.dirty,onClick:e.onSave,children:[e.saving?i(N,{}):null,e.saveLabel]}),e.dirty&&!n?i(y,{variant:"ghost",size:"sm",onClick:e.onRevert,children:e.revertLabel}):null]}):null,e.failed?i("p",{className:"im-small im-issue",role:"alert",children:e.failedLabel}):null]})}async function re(e,n,t){try{await e.writeClipboard(n),e.notify(t("settingsSection.copied"),"success")}catch{e.notify(t("settingsSection.copyFailed"),"warning")}}var sn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function oe(e){let n=T(()=>k(e.environmentId),[e.environmentId]),t=e.bridge.commands.useSubscription(e.command,e.payload,n),r=T(()=>sn(t.data)?e.items==="snapshots"?t.data:Oe({},t.data):{},[t.data,e.items]),l=r.result,o=E(null),a=e.onSettled;we(()=>{l===void 0||o.current===t.data||(o.current=t.data,a?.(l))},[l,t.data,a]);let s=e.t,g=l===void 0&&t.error===null&&!t.isUnavailable;return d("div",{className:"im-flow im-span",children:[t.isUnavailable||t.error!==null?i(X,{variant:"error",layout:"inline",children:i(ee,{children:s("settingsSection.action.failedToRun")})}):null,r.qr===void 0?null:i("div",{className:"im-qr",children:i(Ue,{value:r.qr.payload,size:176,marginSize:2,title:s("settingsSection.action.qrTitle")})}),r.status===void 0?null:d("p",{className:"im-inline im-medium",children:[g?i(N,{}):null,i("span",{children:s(r.status.statusKey,r.status.params)})]}),g&&r.status===void 0&&r.qr===void 0?d("p",{className:"im-inline im-medium",children:[i(N,{}),i("span",{children:s("settingsSection.action.running")})]}):null,r.steps===void 0?null:i("ul",{className:"im-steps im-small",children:r.steps.map(v=>d("li",{"data-state":v.state,children:[i("span",{children:s(v.labelKey)}),i("span",{className:"im-muted",children:s(`settingsSection.step.${v.state}`)})]},v.id))}),l===void 0?null:i(dn,{result:l,bridge:e.bridge,t:s}),d("div",{className:"im-actions",children:[l?.kind==="failed"||r.expired===!0||t.error!==null?i(y,{variant:"ghost",size:"sm",onClick:t.refresh,children:s("settingsSection.retry")}):null,i(y,{variant:"ghost",size:"sm",onClick:e.onClose,children:s(l===void 0?"settingsSection.cancel":"settingsSection.action.close")})]})]})}function dn(e){let{result:n,t}=e,r=n.kind==="done"?n.messageKey===void 0?t("settingsSection.action.done"):t(n.messageKey):t(n.reasonKey,n.params),l=n.kind==="done"?(n.warnings??[]).map(o=>t(o.key,o.params)):n.detail===void 0?[]:[n.detail];return d("div",{className:"im-result",children:[i("p",{className:n.kind==="failed"?"im-medium im-issue":"im-medium",role:"status",children:r}),l.length===0?null:d(x,{children:[i("pre",{className:"im-detail im-small",children:l.join(`
1
+ var ln=window.__ycodiumPluginHost.react;var{Activity:bn,Children:pn,Component:wn,Fragment:we,Profiler:hn,PureComponent:In,StrictMode:Cn,Suspense:xn,__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:kn,__COMPILER_RUNTIME:Rn,act:Tn,cache:Nn,cacheSignal:Pn,captureOwnerStack:An,cloneElement:En,createContext:z,createElement:me,createRef:On,forwardRef:_n,isValidElement:Bn,lazy:Ln,memo:Vn,startTransition:Fn,unstable_useCacheRefresh:Dn,use:$,useActionState:Kn,useCallback:Mn,useContext:Gn,useDebugValue:Un,useDeferredValue:Hn,useEffect:he,useEffectEvent:zn,useId:$n,useImperativeHandle:qn,useInsertionEffect:Yn,useLayoutEffect:Wn,useMemo:T,useOptimistic:jn,useReducer:Qn,useRef:E,useState:p,useSyncExternalStore:Jn,useTransition:Zn,version:Xn}=ln;var q=(e,n)=>{let t=e[n];return typeof t=="string"?t.trim():""};var Ie="settings.view",Ce="settings.saveBot",xe="settings.removeBot",ke="settings.saveGeneral",Re="settings.saveTarget",Te="settings.removeTarget",Ne="larkSetup.session",D={labelKey:"setup.action.label",descriptionKey:"setup.action.description",badgeKey:"setup.action.badge",warningKey:"setup.action.warning"},Pe={checkConnection:"im.settings.checkConnection",copyDiagnostics:"im.settings.copyDiagnostics",larkRepair:"im.settings.larkRepair"},Ae=[{id:"checkConnection",labelKey:"rowAction.checkConnection.label",descriptionKey:"rowAction.checkConnection.description"},{id:"copyDiagnostics",labelKey:"rowAction.copyDiagnostics.label",descriptionKey:"rowAction.copyDiagnostics.description"},{id:"larkRepair",labelKey:"rowAction.larkRepair.label",descriptionKey:"rowAction.larkRepair.description",platform:"lark"}],on="lark",Y=[{value:"zh-CN",labelKey:"settings.language.zhCN"},{value:"en",labelKey:"settings.language.en"}],an="botId",W=e=>q(e,"platform")||on,Ee=(e,n)=>{let t=e.showWhen;if(t===void 0)return!0;let r=t.key==="platform"?W(n):q(n,t.key);return t.equals.includes(r)},Oe=(e,n,t)=>e.map(r=>r.key===an?{...r,kind:"select",options:n.map(o=>({value:o.rowId,label:`${q(o.values,"displayName")||t(o.platform)} (${o.rowId})`}))}:r),_e=(e,n)=>{switch(n.kind){case"qr":{let{expired:t,...r}=e,o=n.expiresAt===void 0?{payload:n.payload}:{payload:n.payload,expiresAt:n.expiresAt};return{...r,qr:o}}case"status":{let t=n.params===void 0?{statusKey:n.statusKey}:{statusKey:n.statusKey,params:n.params};if(n.expired!==!0)return{...e,status:t};let{qr:r,...o}=e;return{...o,status:t,expired:!0}}case"steps":return{...e,steps:n.steps};case"done":case"failed":{let{status:t,...r}=e;return{...r,result:n}}}};var{jsx:i,jsxs:d,Fragment:x}=window.__ycodiumPluginHost.jsxRuntime;var Be=z(null);function Le(e){return i(Be,{value:e.bridge,children:e.children})}var sn=new Set(["Collapsible","CollapsiblePanel","CollapsibleTrigger"]);function f(e){let n=t=>{let l=$(Be)?.ui?.[e];return l===void 0?sn.has(e)?me("div",{className:t.className},t.children):null:me(l,t)};return n.displayName=e,n}var y=f("Button"),O=f("Input"),_=f("Label"),Ve=f("Switch"),j=f("Select"),Q=f("SelectTrigger"),K=f("SelectValue"),J=f("SelectPopup"),Z=f("SelectItem"),Fe=f("StatusPill"),De=f("EmptyInline"),X=f("Alert"),Ke=f("AlertAction"),ee=f("AlertDescription"),Me=f("Collapsible"),Ge=f("CollapsibleTrigger"),Ue=f("CollapsiblePanel"),N=f("Spinner"),He=f("QRCodeSvg"),ze=f("ProxyChoiceSelect");var ne=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),$e=e=>ne(e)&&Array.isArray(e.bots)&&Array.isArray(e.targets)&&ne(e.delivery),qe=e=>ne(e)&&$e(e.view)&&Array.isArray(e.columns)&&Array.isArray(e.targetColumns)&&Array.isArray(e.proxies)?e:null,M=async(e,n,t,r)=>{try{let o=await e.commands.invoke(n,t,r);return ne(o)&&o.ok===!0&&$e(o.view)?o.view:null}catch{return null}},Ye=(e,n)=>n.isPending?e.phase==="asked"?{...e,phase:"refetching"}:e:n.view!==null&&!n.failed?e.phase==="refetching"||JSON.stringify(n.view)===JSON.stringify(e.view)?null:e:e.phase==="asked"?e:{...e,phase:"asked"},k=e=>e==null||e.length===0?{}:{environmentId:e},ge=e=>JSON.stringify(e),G=(e,n)=>n===null?e:`${e}:${n}`,ye=e=>JSON.stringify([e.replyLanguage,e.delivery]);function B(e,n,t){if(n!==void 0&&n.length>0)return e(n);if(t!==void 0&&t.length>0)return t}function We(e,n){return n.length===0?null:n.map(t=>e(t==="required"?"settingsSection.issue.required":"settingsSection.issue.format")).join(" ")}function P(e,n,t){return`im-${(e??"here").replace(/[^A-Za-z0-9_-]/g,"")}-${n}-${t}`}function U(e,n,t){let r=[n?`${e}-issue`:null,t?`${e}-hint`:null].filter(o=>o!==null);return r.length===0?void 0:r.join(" ")}function R(e){return d("div",{className:e.span===!0?"im-field im-span":"im-field",children:[i(_,{htmlFor:e.id,children:e.label}),e.children,e.issue?i("p",{id:`${e.id}-issue`,className:"im-small im-issue",role:"alert",children:e.issue}):null,e.description===void 0?null:i("p",{id:`${e.id}-hint`,className:"im-hint im-small im-muted",children:e.description})]})}function te(e){let n=e.stored&&e.value===""&&!e.clearing?e.savedPlaceholder:e.placeholder;return d("div",{className:"im-secret",children:[i(O,{id:e.id,type:"password",value:e.value,placeholder:n,disabled:e.disabled,autoComplete:"new-password","aria-invalid":e.invalid?!0:void 0,"aria-describedby":e.describedBy,onChange:t=>e.onChange(t.target.value)}),e.stored?i(y,{variant:"ghost",size:"sm","aria-pressed":e.clearing,disabled:e.disabled,onClick:e.onToggleClear,children:e.clearing?e.undoLabel:e.clearLabel}):null]})}function ie(e){let n=e.saving||e.busy===!0;return!e.dirty&&!e.saving&&!e.failed?null:d("div",{className:"im-span",children:[e.dirty||e.saving?d("div",{className:"im-actions",children:[d(y,{variant:e.solid?"default":"outline",disabled:n||!e.dirty,onClick:e.onSave,children:[e.saving?i(N,{}):null,e.saveLabel]}),e.dirty&&!n?i(y,{variant:"ghost",size:"sm",onClick:e.onRevert,children:e.revertLabel}):null]}):null,e.failed?i("p",{className:"im-small im-issue",role:"alert",children:e.failedLabel}):null]})}async function re(e,n,t){try{await e.writeClipboard(n),e.notify(t("settingsSection.copied"),"success")}catch{e.notify(t("settingsSection.copyFailed"),"warning")}}var dn=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function le(e){let n=T(()=>k(e.environmentId),[e.environmentId]),t=e.bridge.commands.useSubscription(e.command,e.payload,n),r=T(()=>dn(t.data)?e.items==="snapshots"?t.data:_e({},t.data):{},[t.data,e.items]),o=r.result,l=E(null),a=e.onSettled;he(()=>{o===void 0||l.current===t.data||(l.current=t.data,a?.(o))},[o,t.data,a]);let s=e.t,g=o===void 0&&t.error===null&&!t.isUnavailable;return d("div",{className:"im-flow im-span",children:[t.isUnavailable||t.error!==null?i(X,{variant:"error",layout:"inline",children:i(ee,{children:s("settingsSection.action.failedToRun")})}):null,r.qr===void 0?null:i("div",{className:"im-qr",children:i(He,{value:r.qr.payload,size:176,marginSize:2,title:s("settingsSection.action.qrTitle")})}),r.status===void 0?null:d("p",{className:"im-inline im-medium",children:[g?i(N,{}):null,i("span",{children:s(r.status.statusKey,r.status.params)})]}),g&&r.status===void 0&&r.qr===void 0?d("p",{className:"im-inline im-medium",children:[i(N,{}),i("span",{children:s("settingsSection.action.running")})]}):null,r.steps===void 0?null:i("ul",{className:"im-steps im-small",children:r.steps.map(v=>d("li",{"data-state":v.state,children:[i("span",{children:s(v.labelKey)}),i("span",{className:"im-muted",children:s(`settingsSection.step.${v.state}`)})]},v.id))}),o===void 0?null:i(cn,{result:o,bridge:e.bridge,t:s}),d("div",{className:"im-actions",children:[o?.kind==="failed"||r.expired===!0||t.error!==null?i(y,{variant:"ghost",size:"sm",onClick:t.refresh,children:s("settingsSection.retry")}):null,i(y,{variant:"ghost",size:"sm",onClick:e.onClose,children:s(o===void 0?"settingsSection.cancel":"settingsSection.action.close")})]})]})}function cn(e){let{result:n,t}=e,r=n.kind==="done"?n.messageKey===void 0?t("settingsSection.action.done"):t(n.messageKey):t(n.reasonKey,n.params),o=n.kind==="done"?(n.warnings??[]).map(l=>t(l.key,l.params)):n.detail===void 0?[]:[n.detail];return d("div",{className:"im-result",children:[i("p",{className:n.kind==="failed"?"im-medium im-issue":"im-medium",role:"status",children:r}),o.length===0?null:d(x,{children:[i("pre",{className:"im-detail im-small",children:o.join(`
2
2
 
3
- `)}),i("div",{className:"im-actions",children:i(y,{variant:"ghost",size:"sm",onClick:()=>{re(e.bridge,l.join(`
3
+ `)}),i("div",{className:"im-actions",children:i(y,{variant:"ghost",size:"sm",onClick:()=>{re(e.bridge,o.join(`
4
4
 
5
- `),t)},children:t("settingsSection.copy")})})]})]})}function le(e){return i("section",{className:"im-block",children:d(Ke,{className:"im-collapse",defaultOpen:e.defaultOpen,children:[d("div",{className:"im-head",children:[d(Me,{className:"im-toggle",children:[i("span",{className:"im-chevron","aria-hidden":"true"}),i("span",{className:"im-title im-medium",children:e.title}),e.meta]}),e.actions]}),e.notice,i(Ge,{children:i("div",{className:"im-panel",children:e.children})})]})})}function We(e){let n=e.columns.filter(t=>Ae(t,e.values));return d(x,{children:[n.map(t=>i(cn,{column:t,scope:e.scope,environmentId:e.environmentId,proxies:e.proxies,values:e.values,secrets:e.secrets,clearSecrets:e.clearSecrets,storedSecrets:e.storedSecrets,issues:e.issues,disabled:e.disabled,t:e.t,onValue:e.onValue,onSecret:e.onSecret,onToggleClear:e.onToggleClear},t.key)),e.publicFields.map(t=>i(mn,{field:t,scope:e.scope,environmentId:e.environmentId,bridge:e.bridge,t:e.t},t.key))]})}function cn(e){let n=e.column,t=P(e.environmentId,e.scope,n.key),r=B(e.t,n.labelKey,n.label)??n.key,l=B(e.t,n.descriptionKey,n.description),o=B(e.t,n.placeholderKey,n.placeholder),a=Ye(e.t,e.issues.filter(g=>g.column===n.key).map(g=>g.code)),s=U(t,a!==null,l!==void 0);return n.kind==="password"?i(R,{id:t,label:r,description:l,issue:a,children:i(te,{id:t,value:e.secrets[n.key]??"",stored:e.storedSecrets[n.key]===!0,clearing:e.clearSecrets.includes(n.key),disabled:e.disabled,invalid:a!==null,describedBy:s,placeholder:o,savedPlaceholder:e.t("settingsSection.secret.saved"),clearLabel:e.t("settingsSection.secret.clear"),undoLabel:e.t("settingsSection.secret.clearUndo"),onChange:g=>{g!==(e.secrets[n.key]??"")&&e.onSecret(n.key,g)},onToggleClear:()=>e.onToggleClear(n.key)})}):n.kind==="select"?i(un,{column:n,id:t,label:r,description:l,issue:a,described:s,values:e.values,disabled:e.disabled,t:e.t,onValue:e.onValue}):n.kind==="proxy"?i("div",{className:"im-field",children:i(He,{id:t,label:r,hint:l,value:e.values[n.key]??"",proxies:e.proxies,disabled:e.disabled,onChange:g=>{g!==(e.values[n.key]??"")&&e.onValue(n.key,g)},children:a===null?null:i("p",{id:`${t}-issue`,className:"im-small im-issue",role:"alert",children:a})})}):i(R,{id:t,label:r,description:l,issue:a,children:i(O,{id:t,type:"text",value:e.values[n.key]??"",placeholder:o,disabled:e.disabled,"aria-invalid":a!==null?!0:void 0,"aria-describedby":s,onChange:g=>{let v=g.target.value;v!==(e.values[n.key]??"")&&e.onValue(n.key,v)}})})}function un(e){let n=e.values[e.column.key]??"",t=e.column.options??[],r=t.find(o=>o.value===n),l=n===""?void 0:r===void 0?n:B(e.t,r.labelKey,r.label)??r.value;return i(R,{id:e.id,label:e.label,description:e.description,issue:e.issue,children:d(j,{className:"im-wide",value:n===""?null:n,disabled:e.disabled,onValueChange:o=>{let a=o??"";a!==n&&e.onValue(e.column.key,a)},children:[i(Q,{id:e.id,"aria-invalid":e.issue!==null?!0:void 0,"aria-describedby":e.described,children:l===void 0?i(K,{placeholder:e.t("settingsSection.select.default")}):i(K,{children:l})}),i(J,{children:t.map(o=>o.value===""?null:i(Z,{value:o.value,children:B(e.t,o.labelKey,o.label)??o.value},o.value))})]})})}function mn(e){let n=P(e.environmentId,`${e.scope}-pub`,e.field.key);return d("div",{className:"im-field im-span",children:[i(_,{children:e.t(`settingsSection.publicField.${e.field.key}`)}),d("div",{className:"im-inline",children:[i("span",{id:n,className:"im-public-value im-small",children:e.field.value}),e.field.copyable?i(y,{variant:"ghost",size:"sm",onClick:()=>{re(e.bridge,e.field.value,e.t)},children:e.t("settingsSection.copy")}):null]})]})}function je(e){let n={};for(let[o,a]of Object.entries(e.values))(e.baseline[o]??"")!==a&&(n[o]=a);let t={};for(let[o,a]of Object.entries(e.secrets))a!==""&&(t[o]=a);let r=[];for(let o of e.clearSecrets)Object.hasOwn(t,o)||r.includes(o)||r.push(o);return e.rowId===void 0||Object.keys(n).length>0||Object.keys(t).length>0||r.length>0?{changed:!0,edit:{...e.rowId===void 0?{}:{rowId:e.rowId},values:n,...Object.keys(t).length>0?{secrets:t}:{},...r.length>0?{clearSecrets:r}:{}}}:{changed:!1}}function gn(e){let n=e.trim();if(!/^\d+$/.test(n))return null;let t=Number(n);return!Number.isInteger(t)||t<1||t>65535?null:t}function Qe(e){let n={};e.replyLanguage!==e.baseline.replyLanguage&&(n.replyLanguage=e.replyLanguage),e.enabled!==e.baseline.enabled&&(n.deliveryHttpEnabled=e.enabled);let t=!1;if(e.enabled){let r=gn(e.port);r===null?t=!0:r!==e.baseline.port&&(n.deliveryHttpPort=r),e.token!==""?n.deliveryHttpToken=e.token:e.clearToken&&e.baseline.hasToken&&(n.clearDeliveryHttpToken=!0)}return t?{changed:!0,invalidPort:!0}:Object.keys(n).length===0?{changed:!1}:{changed:!0,invalidPort:!1,payload:n}}var Je=z({activeId:null,activate:()=>{}});function Ze(e){return i(Je,{value:{activeId:e.activeId,activate:e.activate},children:e.children})}function ae(e){let n=$(Je);return{chosen:n.activeId===e,activate:()=>n.activate(e)}}function se(e,n){return{signature:n,values:{...e?.values??{}},secrets:{},clearSecrets:[],saving:!1,failed:!1,confirming:!1,removing:!1,removeFailed:!1}}function fe(e){let{kind:n,row:t}=e,r=t===null?n.newSlot:ge(t),l=ae(G(n.newSlot,t?.rowId??null)),o=E(0),[a,s]=p(()=>se(t,r));a.signature!==r&&(o.current+=1,s(se(t,r)));let g=je({...t===null?{}:{rowId:t.rowId},baseline:t?.values??{},values:a.values,secrets:a.secrets,clearSecrets:a.clearSecrets}),v=g.changed,w=t===null||!t.configured,I=a.saving||a.removing;function h(c){l.activate(),s(m=>({...c(m),failed:!1}))}function C(){if(!g.changed||I)return;l.activate();let c=g.edit,m=++o.current;s(u=>({...u,saving:!0,failed:!1})),M(e.bridge,n.saveCommand,c,k(e.environmentId)).then(u=>{if(o.current!==m)return;if(u===null){s(L=>({...L,saving:!1,failed:!0}));return}let b=t===null?void 0:n.rows(u).find(L=>L.rowId===t.rowId);b!==void 0&&s(se(b,ge(b))),e.onSaved(u)})}function A(){if(t===null){e.onDiscard();return}let c=t.rowId,m=++o.current;s(u=>({...u,removing:!0,removeFailed:!1})),M(e.bridge,n.removeCommand,{rowId:c},k(e.environmentId)).then(u=>{if(o.current===m){if(u===null){s(b=>({...b,removing:!1,removeFailed:!0,confirming:!0}));return}e.onSaved(u)}})}return i(le,{title:e.title(a.values),defaultOpen:w,meta:d(x,{children:[e.meta?.(a.values),i(Ve,{tone:w?"attention":"success",children:e.t(w?"settingsSection.status.incomplete":"settingsSection.status.ready")})]}),actions:a.confirming?d("div",{className:"im-actions",children:[i(y,{variant:"ghost",size:"sm",disabled:a.removing||a.saving,onClick:A,children:e.t(n.removeConfirmKey)}),i(y,{variant:"ghost",size:"sm",disabled:a.removing||a.saving,onClick:()=>s(c=>({...c,confirming:!1})),children:e.t("settingsSection.cancel")})]}):i(y,{variant:"ghost",size:"sm",disabled:I,onClick:()=>s(c=>({...c,confirming:!0,removeFailed:!1})),children:e.t("settingsSection.remove")}),notice:d(x,{children:[a.confirming&&t!==null&&n.removeHintKey!==void 0?i("p",{className:"im-small im-muted",children:e.t(n.removeHintKey)}):null,a.removeFailed?i("p",{className:"im-small im-issue",role:"alert",children:e.t(n.removeFailedKey)}):null]}),children:d("div",{className:"im-form",children:[i(We,{scope:`${n.newSlot}-${t?.rowId??"new"}`,environmentId:e.environmentId,columns:e.columns,proxies:e.proxies,values:a.values,secrets:a.secrets,clearSecrets:a.clearSecrets,storedSecrets:t?.secrets??{},issues:t?.issues??[],publicFields:t?.publicFields??[],disabled:I,bridge:e.bridge,t:e.t,onValue:(c,m)=>h(u=>({...u,values:{...u.values,[c]:m}})),onSecret:(c,m)=>h(u=>({...u,secrets:{...u.secrets,[c]:m}})),onToggleClear:c=>h(m=>({...m,clearSecrets:m.clearSecrets.includes(c)?m.clearSecrets.filter(u=>u!==c):[...m.clearSecrets,c]}))}),e.extra?.({dirty:v,frozen:I}),i(ie,{dirty:v,saving:a.saving,busy:a.removing,solid:l.chosen&&v,failed:a.failed,saveLabel:e.t("settingsSection.save"),revertLabel:e.t("settingsSection.revert"),failedLabel:e.t("settingsSection.saveFailed"),onSave:C,onRevert:()=>{o.current+=1,s(se(t,r))}})]})})}var de={newSlot:"im-new-row",saveCommand:he,removeCommand:Ce,rows:e=>e.bots,removeConfirmKey:"settingsSection.removeConfirm",removeHintKey:"settingsSection.removeHint",removeFailedKey:"settingsSection.removeFailed"},ce={newSlot:"im-new-target",saveCommand:ke,removeCommand:Re,rows:e=>e.targets,removeConfirmKey:"settingsSection.target.removeConfirm",removeFailedKey:"settingsSection.target.removeFailed"};function ve(e){let{bot:n,t}=e,[r,l]=p(null);return i(fe,{...e,kind:de,row:n,title:o=>{let a=(o.displayName??"").trim();return a.length>0?a:t(`platform.${W(o)}`)},meta:o=>i("span",{className:"im-small im-muted",children:t(`platform.${W(o)}`)}),extra:({dirty:o,frozen:a})=>n===null?null:d(x,{children:[d("div",{className:"im-span",children:[i("div",{className:"im-actions",children:Pe.filter(s=>s.platform===void 0||s.platform===n.platform).map(s=>i(y,{variant:"ghost",size:"sm",disabled:o||a,title:t(s.descriptionKey),onClick:()=>l({id:s.id,payload:{rowId:n.rowId}}),children:t(s.labelKey)},s.id))}),o?i("p",{className:"im-small im-muted",children:t("settingsSection.action.saveFirst")}):null]}),r===null?null:i(oe,{bridge:e.bridge,command:Ne[r.id],payload:r.payload,items:"latest",environmentId:e.environmentId,t,onClose:()=>l(null)},r.id)]})})}function Se(e){let{t:n}=e;return i(fe,{...e,kind:ce,row:e.target,title:t=>{let r=(t.name??"").trim()||(t.targetId??"").trim();return r.length>0?r:n("settingsSection.target.untitled")}})}var yn="im-general";function ue(e,n){return{signature:n,replyLanguage:e.replyLanguage,enabled:e.delivery.enabled,port:String(e.delivery.port),token:"",clearToken:!1,saving:!1,failed:!1}}function Xe(e){let n=e.view,t=ye(n),r=ae(yn),l=E(0),[o,a]=p(()=>ue(n,t));o.signature!==t&&(l.current+=1,a(ue(n,t)));let s=Qe({baseline:{replyLanguage:n.replyLanguage,enabled:n.delivery.enabled,port:n.delivery.port,hasToken:n.delivery.hasToken},replyLanguage:o.replyLanguage,enabled:o.enabled,port:o.port,token:o.token,clearToken:o.clearToken}),g=s.changed,v=s.changed&&s.invalidPort,w=P(e.environmentId,"general","port"),I=P(e.environmentId,"general","token"),h=P(e.environmentId,"general","language");function C(c){r.activate(),a(m=>({...m,...c,failed:!1}))}function A(){if(!s.changed||o.saving)return;if(r.activate(),s.invalidPort){a(u=>({...u,failed:!0}));return}let c=s.payload,m=++l.current;a(u=>({...u,saving:!0,failed:!1})),M(e.bridge,xe,c,k(e.environmentId)).then(u=>{if(l.current===m){if(u===null){a(b=>({...b,saving:!1,failed:!0}));return}a(ue(u,ye(u))),e.onSaved(u)}})}return i(le,{title:e.t("settingsSection.general"),defaultOpen:!1,children:d("div",{className:"im-form",children:[i(R,{id:h,label:e.t("settings.language.label"),description:e.t("settings.language.description"),children:d(j,{className:"im-wide",value:o.replyLanguage,disabled:o.saving,onValueChange:c=>{let m=Y.find(u=>u.value===c);m===void 0||m.value===o.replyLanguage||C({replyLanguage:m.value})},children:[i(Q,{id:h,"aria-describedby":`${h}-hint`,children:i(K,{children:Y.filter(c=>c.value===o.replyLanguage).map(c=>e.t(c.labelKey))})}),i(J,{children:Y.map(c=>i(Z,{value:c.value,children:e.t(c.labelKey)},c.value))})]})}),d("div",{className:"im-field",children:[d(_,{className:"im-inline",children:[i("span",{className:"im-medium",children:e.t("settings.deliveryHttp.enabled.label")}),i(Le,{checked:o.enabled,disabled:o.saving,onCheckedChange:c=>{c!==o.enabled&&C({enabled:c})}})]}),i("p",{className:"im-small im-muted",children:e.t("settings.deliveryHttp.enabled.description")})]}),o.enabled?i(R,{id:w,label:e.t("settings.deliveryHttp.port.label"),description:e.t("settings.deliveryHttp.port.description"),issue:v?e.t("settingsSection.issue.format"):null,children:i(O,{id:w,type:"number",value:o.port,disabled:o.saving,"aria-invalid":v?!0:void 0,"aria-describedby":U(w,v,!0),onChange:c=>{c.target.value!==o.port&&C({port:c.target.value})}})}):null,o.enabled?i(R,{id:I,label:e.t("settings.deliveryHttp.token.label"),description:e.t("settings.deliveryHttp.token.description"),children:i(te,{id:I,value:o.token,stored:n.delivery.hasToken,clearing:o.clearToken,disabled:o.saving,invalid:!1,describedBy:U(I,!1,!0),savedPlaceholder:e.t("settingsSection.secret.saved"),clearLabel:e.t("settingsSection.secret.clear"),undoLabel:e.t("settingsSection.secret.clearUndo"),onChange:c=>{c!==o.token&&C({token:c})},onToggleClear:()=>C({clearToken:!o.clearToken})})}):null,i(ie,{dirty:g,saving:o.saving,solid:r.chosen&&g,failed:o.failed,saveLabel:e.t("settingsSection.save"),revertLabel:e.t("settingsSection.revert"),failedLabel:e.t("settingsSection.saveFailed"),onSave:A,onRevert:()=>{l.current+=1,a(ue(n,t))}})]})})}var en=`
5
+ `),t)},children:t("settingsSection.copy")})})]})]})}function oe(e){return i("section",{className:"im-block",children:d(Me,{className:"im-collapse",defaultOpen:e.defaultOpen,children:[d("div",{className:"im-head",children:[d(Ge,{className:"im-toggle",children:[i("span",{className:"im-chevron","aria-hidden":"true"}),i("span",{className:"im-title im-medium",children:e.title}),e.meta]}),e.actions]}),e.notice,i(Ue,{children:i("div",{className:"im-panel",children:e.children})})]})})}function je(e){let n=e.columns.filter(t=>Ee(t,e.values));return d(x,{children:[n.map(t=>i(un,{column:t,scope:e.scope,environmentId:e.environmentId,proxies:e.proxies,values:e.values,secrets:e.secrets,clearSecrets:e.clearSecrets,storedSecrets:e.storedSecrets,issues:e.issues,disabled:e.disabled,t:e.t,onValue:e.onValue,onSecret:e.onSecret,onToggleClear:e.onToggleClear},t.key)),e.publicFields.map(t=>i(gn,{field:t,scope:e.scope,environmentId:e.environmentId,bridge:e.bridge,t:e.t},t.key))]})}function un(e){let n=e.column,t=P(e.environmentId,e.scope,n.key),r=B(e.t,n.labelKey,n.label)??n.key,o=B(e.t,n.descriptionKey,n.description),l=B(e.t,n.placeholderKey,n.placeholder),a=We(e.t,e.issues.filter(g=>g.column===n.key).map(g=>g.code)),s=U(t,a!==null,o!==void 0);return n.kind==="password"?i(R,{id:t,label:r,description:o,issue:a,children:i(te,{id:t,value:e.secrets[n.key]??"",stored:e.storedSecrets[n.key]===!0,clearing:e.clearSecrets.includes(n.key),disabled:e.disabled,invalid:a!==null,describedBy:s,placeholder:l,savedPlaceholder:e.t("settingsSection.secret.saved"),clearLabel:e.t("settingsSection.secret.clear"),undoLabel:e.t("settingsSection.secret.clearUndo"),onChange:g=>{g!==(e.secrets[n.key]??"")&&e.onSecret(n.key,g)},onToggleClear:()=>e.onToggleClear(n.key)})}):n.kind==="select"?i(mn,{column:n,id:t,label:r,description:o,issue:a,described:s,values:e.values,disabled:e.disabled,t:e.t,onValue:e.onValue}):n.kind==="proxy"?i("div",{className:"im-field",children:i(ze,{id:t,label:r,hint:o,value:e.values[n.key]??"",proxies:e.proxies,disabled:e.disabled,onChange:g=>{g!==(e.values[n.key]??"")&&e.onValue(n.key,g)},children:a===null?null:i("p",{id:`${t}-issue`,className:"im-small im-issue",role:"alert",children:a})})}):i(R,{id:t,label:r,description:o,issue:a,children:i(O,{id:t,type:"text",value:e.values[n.key]??"",placeholder:l,disabled:e.disabled,"aria-invalid":a!==null?!0:void 0,"aria-describedby":s,onChange:g=>{let v=g.target.value;v!==(e.values[n.key]??"")&&e.onValue(n.key,v)}})})}function mn(e){let n=e.values[e.column.key]??"",t=e.column.options??[],r=t.find(l=>l.value===n),o=n===""?void 0:r===void 0?n:B(e.t,r.labelKey,r.label)??r.value;return i(R,{id:e.id,label:e.label,description:e.description,issue:e.issue,children:d(j,{className:"im-wide",value:n===""?null:n,disabled:e.disabled,onValueChange:l=>{let a=l??"";a!==n&&e.onValue(e.column.key,a)},children:[i(Q,{id:e.id,"aria-invalid":e.issue!==null?!0:void 0,"aria-describedby":e.described,children:o===void 0?i(K,{placeholder:e.t("settingsSection.select.default")}):i(K,{children:o})}),i(J,{children:t.map(l=>l.value===""?null:i(Z,{value:l.value,children:B(e.t,l.labelKey,l.label)??l.value},l.value))})]})})}function gn(e){let n=P(e.environmentId,`${e.scope}-pub`,e.field.key);return d("div",{className:"im-field im-span",children:[i(_,{children:e.t(`settingsSection.publicField.${e.field.key}`)}),e.field.value===""?null:d("div",{className:"im-inline im-public-row",children:[i("span",{id:n,className:"im-public-value im-small",children:yn(e.field.value)}),e.field.copyable?i(y,{variant:"ghost",size:"sm",onClick:()=>{re(e.bridge,e.field.value,e.t)},children:e.t("settingsSection.copy")}):null]}),e.field.hint===void 0?null:i("p",{className:"im-small im-muted",children:e.t(`settingsSection.publicFieldHint.${e.field.hint}`)})]})}function yn(e){return e.split(/(?<=\/)(?!\/)/).map((n,t)=>d(we,{children:[t===0?null:i("wbr",{}),n]},t))}function Qe(e){let n={};for(let[l,a]of Object.entries(e.values))(e.baseline[l]??"")!==a&&(n[l]=a);let t={};for(let[l,a]of Object.entries(e.secrets))a!==""&&(t[l]=a);let r=[];for(let l of e.clearSecrets)Object.hasOwn(t,l)||r.includes(l)||r.push(l);return e.rowId===void 0||Object.keys(n).length>0||Object.keys(t).length>0||r.length>0?{changed:!0,edit:{...e.rowId===void 0?{}:{rowId:e.rowId},values:n,...Object.keys(t).length>0?{secrets:t}:{},...r.length>0?{clearSecrets:r}:{}}}:{changed:!1}}function fn(e){let n=e.trim();if(!/^\d+$/.test(n))return null;let t=Number(n);return!Number.isInteger(t)||t<1||t>65535?null:t}function Je(e){let n={};e.replyLanguage!==e.baseline.replyLanguage&&(n.replyLanguage=e.replyLanguage),e.enabled!==e.baseline.enabled&&(n.deliveryHttpEnabled=e.enabled);let t=!1;if(e.enabled){let r=fn(e.port);r===null?t=!0:r!==e.baseline.port&&(n.deliveryHttpPort=r),e.token!==""?n.deliveryHttpToken=e.token:e.clearToken&&e.baseline.hasToken&&(n.clearDeliveryHttpToken=!0)}return t?{changed:!0,invalidPort:!0}:Object.keys(n).length===0?{changed:!1}:{changed:!0,invalidPort:!1,payload:n}}var Ze=z({activeId:null,activate:()=>{}});function Xe(e){return i(Ze,{value:{activeId:e.activeId,activate:e.activate},children:e.children})}function ae(e){let n=$(Ze);return{chosen:n.activeId===e,activate:()=>n.activate(e)}}function se(e,n){return{signature:n,values:{...e?.values??{}},secrets:{},clearSecrets:[],saving:!1,failed:!1,confirming:!1,removing:!1,removeFailed:!1}}function fe(e){let{kind:n,row:t}=e,r=t===null?n.newSlot:ge(t),o=ae(G(n.newSlot,t?.rowId??null)),l=E(0),[a,s]=p(()=>se(t,r));a.signature!==r&&(l.current+=1,s(se(t,r)));let g=Qe({...t===null?{}:{rowId:t.rowId},baseline:t?.values??{},values:a.values,secrets:a.secrets,clearSecrets:a.clearSecrets}),v=g.changed,w=t===null||!t.configured,h=a.saving||a.removing;function I(c){o.activate(),s(m=>({...c(m),failed:!1}))}function C(){if(!g.changed||h)return;o.activate();let c=g.edit,m=++l.current;s(u=>({...u,saving:!0,failed:!1})),M(e.bridge,n.saveCommand,c,k(e.environmentId)).then(u=>{if(l.current!==m)return;if(u===null){s(L=>({...L,saving:!1,failed:!0}));return}let b=t===null?void 0:n.rows(u).find(L=>L.rowId===t.rowId);b!==void 0&&s(se(b,ge(b))),e.onSaved(u)})}function A(){if(t===null){e.onDiscard();return}let c=t.rowId,m=++l.current;s(u=>({...u,removing:!0,removeFailed:!1})),M(e.bridge,n.removeCommand,{rowId:c},k(e.environmentId)).then(u=>{if(l.current===m){if(u===null){s(b=>({...b,removing:!1,removeFailed:!0,confirming:!0}));return}e.onSaved(u)}})}return i(oe,{title:e.title(a.values),defaultOpen:w,meta:d(x,{children:[e.meta?.(a.values),i(Fe,{tone:w?"attention":"success",children:e.t(w?"settingsSection.status.incomplete":"settingsSection.status.ready")})]}),actions:a.confirming?d("div",{className:"im-actions",children:[i(y,{variant:"ghost",size:"sm",disabled:a.removing||a.saving,onClick:A,children:e.t(n.removeConfirmKey)}),i(y,{variant:"ghost",size:"sm",disabled:a.removing||a.saving,onClick:()=>s(c=>({...c,confirming:!1})),children:e.t("settingsSection.cancel")})]}):i(y,{variant:"ghost",size:"sm",disabled:h,onClick:()=>s(c=>({...c,confirming:!0,removeFailed:!1})),children:e.t("settingsSection.remove")}),notice:d(x,{children:[a.confirming&&t!==null&&n.removeHintKey!==void 0?i("p",{className:"im-small im-muted",children:e.t(n.removeHintKey)}):null,a.removeFailed?i("p",{className:"im-small im-issue",role:"alert",children:e.t(n.removeFailedKey)}):null]}),children:d("div",{className:"im-form",children:[i(je,{scope:`${n.newSlot}-${t?.rowId??"new"}`,environmentId:e.environmentId,columns:e.columns,proxies:e.proxies,values:a.values,secrets:a.secrets,clearSecrets:a.clearSecrets,storedSecrets:t?.secrets??{},issues:t?.issues??[],publicFields:t?.publicFields??[],disabled:h,bridge:e.bridge,t:e.t,onValue:(c,m)=>I(u=>({...u,values:{...u.values,[c]:m}})),onSecret:(c,m)=>I(u=>({...u,secrets:{...u.secrets,[c]:m}})),onToggleClear:c=>I(m=>({...m,clearSecrets:m.clearSecrets.includes(c)?m.clearSecrets.filter(u=>u!==c):[...m.clearSecrets,c]}))}),e.extra?.({dirty:v,frozen:h}),i(ie,{dirty:v,saving:a.saving,busy:a.removing,solid:o.chosen&&v,failed:a.failed,saveLabel:e.t("settingsSection.save"),revertLabel:e.t("settingsSection.revert"),failedLabel:e.t("settingsSection.saveFailed"),onSave:C,onRevert:()=>{l.current+=1,s(se(t,r))}})]})})}var de={newSlot:"im-new-row",saveCommand:Ce,removeCommand:xe,rows:e=>e.bots,removeConfirmKey:"settingsSection.removeConfirm",removeHintKey:"settingsSection.removeHint",removeFailedKey:"settingsSection.removeFailed"},ce={newSlot:"im-new-target",saveCommand:Re,removeCommand:Te,rows:e=>e.targets,removeConfirmKey:"settingsSection.target.removeConfirm",removeFailedKey:"settingsSection.target.removeFailed"};function ve(e){let{bot:n,t}=e,[r,o]=p(null);return i(fe,{...e,kind:de,row:n,title:l=>{let a=(l.displayName??"").trim();return a.length>0?a:t(`platform.${W(l)}`)},meta:l=>i("span",{className:"im-small im-muted",children:t(`platform.${W(l)}`)}),extra:({dirty:l,frozen:a})=>n===null?null:d(x,{children:[d("div",{className:"im-span",children:[i("div",{className:"im-actions",children:Ae.filter(s=>s.platform===void 0||s.platform===n.platform).map(s=>i(y,{variant:"ghost",size:"sm",disabled:l||a,title:t(s.descriptionKey),onClick:()=>o({id:s.id,payload:{rowId:n.rowId}}),children:t(s.labelKey)},s.id))}),l?i("p",{className:"im-small im-muted",children:t("settingsSection.action.saveFirst")}):null]}),r===null?null:i(le,{bridge:e.bridge,command:Pe[r.id],payload:r.payload,items:"latest",environmentId:e.environmentId,t,onClose:()=>o(null)},r.id)]})})}function Se(e){let{t:n}=e;return i(fe,{...e,kind:ce,row:e.target,title:t=>{let r=(t.name??"").trim()||(t.targetId??"").trim();return r.length>0?r:n("settingsSection.target.untitled")}})}var vn="im-general";function ue(e,n){return{signature:n,replyLanguage:e.replyLanguage,enabled:e.delivery.enabled,port:String(e.delivery.port),token:"",clearToken:!1,saving:!1,failed:!1}}function en(e){let n=e.view,t=ye(n),r=ae(vn),o=E(0),[l,a]=p(()=>ue(n,t));l.signature!==t&&(o.current+=1,a(ue(n,t)));let s=Je({baseline:{replyLanguage:n.replyLanguage,enabled:n.delivery.enabled,port:n.delivery.port,hasToken:n.delivery.hasToken},replyLanguage:l.replyLanguage,enabled:l.enabled,port:l.port,token:l.token,clearToken:l.clearToken}),g=s.changed,v=s.changed&&s.invalidPort,w=P(e.environmentId,"general","port"),h=P(e.environmentId,"general","token"),I=P(e.environmentId,"general","language");function C(c){r.activate(),a(m=>({...m,...c,failed:!1}))}function A(){if(!s.changed||l.saving)return;if(r.activate(),s.invalidPort){a(u=>({...u,failed:!0}));return}let c=s.payload,m=++o.current;a(u=>({...u,saving:!0,failed:!1})),M(e.bridge,ke,c,k(e.environmentId)).then(u=>{if(o.current===m){if(u===null){a(b=>({...b,saving:!1,failed:!0}));return}a(ue(u,ye(u))),e.onSaved(u)}})}return i(oe,{title:e.t("settingsSection.general"),defaultOpen:!1,children:d("div",{className:"im-form",children:[i(R,{id:I,label:e.t("settings.language.label"),description:e.t("settings.language.description"),children:d(j,{className:"im-wide",value:l.replyLanguage,disabled:l.saving,onValueChange:c=>{let m=Y.find(u=>u.value===c);m===void 0||m.value===l.replyLanguage||C({replyLanguage:m.value})},children:[i(Q,{id:I,"aria-describedby":`${I}-hint`,children:i(K,{children:Y.filter(c=>c.value===l.replyLanguage).map(c=>e.t(c.labelKey))})}),i(J,{children:Y.map(c=>i(Z,{value:c.value,children:e.t(c.labelKey)},c.value))})]})}),d("div",{className:"im-field",children:[d(_,{className:"im-inline",children:[i("span",{className:"im-medium",children:e.t("settings.deliveryHttp.enabled.label")}),i(Ve,{checked:l.enabled,disabled:l.saving,onCheckedChange:c=>{c!==l.enabled&&C({enabled:c})}})]}),i("p",{className:"im-small im-muted",children:e.t("settings.deliveryHttp.enabled.description")})]}),l.enabled?i(R,{id:w,label:e.t("settings.deliveryHttp.port.label"),description:e.t("settings.deliveryHttp.port.description"),issue:v?e.t("settingsSection.issue.format"):null,children:i(O,{id:w,type:"number",value:l.port,disabled:l.saving,"aria-invalid":v?!0:void 0,"aria-describedby":U(w,v,!0),onChange:c=>{c.target.value!==l.port&&C({port:c.target.value})}})}):null,l.enabled?i(R,{id:h,label:e.t("settings.deliveryHttp.token.label"),description:e.t("settings.deliveryHttp.token.description"),children:i(te,{id:h,value:l.token,stored:n.delivery.hasToken,clearing:l.clearToken,disabled:l.saving,invalid:!1,describedBy:U(h,!1,!0),savedPlaceholder:e.t("settingsSection.secret.saved"),clearLabel:e.t("settingsSection.secret.clear"),undoLabel:e.t("settingsSection.secret.clearUndo"),onChange:c=>{c!==l.token&&C({token:c})},onToggleClear:()=>C({clearToken:!l.clearToken})})}):null,i(ie,{dirty:g,saving:l.saving,solid:r.chosen&&g,failed:l.failed,saveLabel:e.t("settingsSection.save"),revertLabel:e.t("settingsSection.revert"),failedLabel:e.t("settingsSection.saveFailed"),onSave:A,onRevert:()=>{o.current+=1,a(ue(n,t))}})]})})}var nn=`
6
6
  .im-settings {
7
7
  box-sizing: border-box;
8
8
  color: var(--foreground);
@@ -126,6 +126,15 @@ var rn=window.__ycodiumPluginHost.react;var{Activity:vn,Children:Sn,Component:bn
126
126
  min-width: 0;
127
127
  overflow-wrap: anywhere;
128
128
  }
129
+ /* \u590D\u5236\u6309\u94AE\u7D27\u8DDF\u5728\u503C\u540E\u9762\uFF0C\u5BBD\u7A97\u4E0D\u88AB\u63A8\u5230\u884C\u5C3E\uFF1B\u7A84\u65F6\u503C\u5728\u81EA\u5DF1\u90A3\u4E00\u680F\u91CC\u6298\u884C\uFF0C\u6309\u94AE\u4E0D\u6389\u5230\u4E0B\u4E00\u884C\uFF0C
130
+ \u4E0E\u503C\u7684\u7B2C\u4E00\u884C\u5BF9\u9F50\u3002 */
131
+ .im-settings .im-public-row {
132
+ flex-wrap: nowrap;
133
+ align-items: baseline;
134
+ }
135
+ .im-settings .im-public-row > .im-public-value {
136
+ flex: 0 1 auto;
137
+ }
129
138
  .im-settings .im-small {
130
139
  font-size: var(--ui-text-sm);
131
140
  line-height: var(--ui-leading-sm);
@@ -198,4 +207,4 @@ var rn=window.__ycodiumPluginHost.react;var{Activity:vn,Children:Sn,Component:bn
198
207
  grid-column: 1 / -1;
199
208
  }
200
209
  }
201
- `;var nn={};function tn(e){let n=e.bridge.i18n.usePluginTranslation(),t=T(()=>k(e.environmentId),[e.environmentId]),r=e.bridge.commands.useQuery(Ie,nn,t),l=T(()=>$e(r.data),[r.data]),[o,a]=p(null),[s,g]=p(null),[v,w]=p(!1),[I,h]=p(!1),[C,A]=p(!1),[c,m]=p(null);if(l!==null&&l!==o&&a(l),s!==null){let S=qe(s,{view:l?.view??null,isPending:r.isPending,failed:r.error!==null});S!==s&&g(S)}let u=s?.view??l?.view??o?.view??null,b=l??o,L=l===null&&r.data!==null&&!r.isPending,pe=T(()=>Ee(b?.targetColumns??[],u?.bots??[],S=>n(`platform.${S}`)),[b,u,n]);function V(S){g({view:S,phase:"asked"}),r.refresh()}function H(){g(null),r.refresh()}let F;return r.isUnavailable?F=i(be,{variant:"warning",message:n("settingsSection.unavailable"),retryLabel:n("settingsSection.retry"),onRetry:H}):u===null&&r.isPending?F=i("div",{className:"im-pending",children:i(N,{size:"md"})}):u===null||b===null?F=i(be,{variant:"error",message:n("settingsSection.loadFailed"),retryLabel:n("settingsSection.retry"),onRetry:H}):F=d(Ze,{activeId:c,activate:m,children:[r.error!==null||L?i(be,{variant:"error",message:n("settingsSection.loadFailed"),retryLabel:n("settingsSection.retry"),onRetry:H}):null,i(Xe,{view:u,environmentId:e.environmentId,bridge:e.bridge,t:n,onSaved:V}),u.bots.map(S=>i(ve,{bot:S,columns:b.columns,proxies:b.proxies,environmentId:e.environmentId,bridge:e.bridge,t:n,onSaved:V,onDiscard:()=>{}},S.rowId)),v?i(ve,{bot:null,columns:b.columns,proxies:b.proxies,environmentId:e.environmentId,bridge:e.bridge,t:n,onSaved:S=>{w(!1),V(S)},onDiscard:()=>w(!1)},de.newSlot):null,u.bots.length===0&&!v?i(Fe,{title:n("settingsSection.empty")}):null,d("div",{className:"im-actions",children:[i(y,{variant:"outline",disabled:v,onClick:()=>{w(!0),m(G(de.newSlot,null))},children:n("settingsSection.addBot")}),d(y,{variant:"outline",disabled:C,onClick:()=>A(!0),children:[n(D.labelKey),i("span",{className:"im-badge im-small",children:n(D.badgeKey)})]})]}),i("p",{className:"im-small im-muted",children:n(D.warningKey)}),C?d("section",{className:"im-block",children:[i("p",{className:"im-small im-muted",children:n(D.descriptionKey)}),i(oe,{bridge:e.bridge,command:Te,payload:nn,items:"snapshots",environmentId:e.environmentId,t:n,onSettled:S=>{S.kind==="done"&&H()},onClose:()=>A(!1)})]}):null,i("h3",{className:"im-heading im-medium",children:n("settings.deliveryTargets.label")}),i("p",{className:"im-small im-muted",children:n("settingsSection.target.description")}),u.targets.map(S=>i(Se,{target:S,columns:pe,proxies:b.proxies,environmentId:e.environmentId,bridge:e.bridge,t:n,onSaved:V,onDiscard:()=>{}},S.rowId)),I?i(Se,{target:null,columns:pe,proxies:b.proxies,environmentId:e.environmentId,bridge:e.bridge,t:n,onSaved:S=>{h(!1),V(S)},onDiscard:()=>h(!1)},ce.newSlot):null,i("div",{className:"im-actions",children:i(y,{variant:"outline",disabled:I,onClick:()=>{h(!0),m(G(ce.newSlot,null))},children:n("settingsSection.target.add")})})]}),i(Be,{bridge:e.bridge,children:d("div",{className:"im-settings",children:[i("style",{children:en}),i("h2",{className:"im-heading im-medium",children:n("settings.title")}),F]})})}function be(e){return d(X,{variant:e.variant,layout:"inline",children:[i(ee,{children:e.message}),i(De,{children:i(y,{variant:"ghost",size:"sm",onClick:e.onRetry,children:e.retryLabel})})]})}function fn(e){return{slots:[{name:"settings.section",order:20,component(n){return i(tn,{bridge:e,environmentId:n.environmentId??null},n.environmentId??"")}}]}}export{fn as default};
210
+ `;var tn={};function rn(e){let n=e.bridge.i18n.usePluginTranslation(),t=T(()=>k(e.environmentId),[e.environmentId]),r=e.bridge.commands.useQuery(Ie,tn,t),o=T(()=>qe(r.data),[r.data]),[l,a]=p(null),[s,g]=p(null),[v,w]=p(!1),[h,I]=p(!1),[C,A]=p(!1),[c,m]=p(null);if(o!==null&&o!==l&&a(o),s!==null){let S=Ye(s,{view:o?.view??null,isPending:r.isPending,failed:r.error!==null});S!==s&&g(S)}let u=s?.view??o?.view??l?.view??null,b=o??l,L=o===null&&r.data!==null&&!r.isPending,pe=T(()=>Oe(b?.targetColumns??[],u?.bots??[],S=>n(`platform.${S}`)),[b,u,n]);function V(S){g({view:S,phase:"asked"}),r.refresh()}function H(){g(null),r.refresh()}let F;return r.isUnavailable?F=i(be,{variant:"warning",message:n("settingsSection.unavailable"),retryLabel:n("settingsSection.retry"),onRetry:H}):u===null&&r.isPending?F=i("div",{className:"im-pending",children:i(N,{size:"md"})}):u===null||b===null?F=i(be,{variant:"error",message:n("settingsSection.loadFailed"),retryLabel:n("settingsSection.retry"),onRetry:H}):F=d(Xe,{activeId:c,activate:m,children:[r.error!==null||L?i(be,{variant:"error",message:n("settingsSection.loadFailed"),retryLabel:n("settingsSection.retry"),onRetry:H}):null,i(en,{view:u,environmentId:e.environmentId,bridge:e.bridge,t:n,onSaved:V}),u.bots.map(S=>i(ve,{bot:S,columns:b.columns,proxies:b.proxies,environmentId:e.environmentId,bridge:e.bridge,t:n,onSaved:V,onDiscard:()=>{}},S.rowId)),v?i(ve,{bot:null,columns:b.columns,proxies:b.proxies,environmentId:e.environmentId,bridge:e.bridge,t:n,onSaved:S=>{w(!1),V(S)},onDiscard:()=>w(!1)},de.newSlot):null,u.bots.length===0&&!v?i(De,{title:n("settingsSection.empty")}):null,d("div",{className:"im-actions",children:[i(y,{variant:"outline",disabled:v,onClick:()=>{w(!0),m(G(de.newSlot,null))},children:n("settingsSection.addBot")}),d(y,{variant:"outline",disabled:C,onClick:()=>A(!0),children:[n(D.labelKey),i("span",{className:"im-badge im-small",children:n(D.badgeKey)})]})]}),i("p",{className:"im-small im-muted",children:n(D.warningKey)}),C?d("section",{className:"im-block",children:[i("p",{className:"im-small im-muted",children:n(D.descriptionKey)}),i(le,{bridge:e.bridge,command:Ne,payload:tn,items:"snapshots",environmentId:e.environmentId,t:n,onSettled:S=>{S.kind==="done"&&H()},onClose:()=>A(!1)})]}):null,i("h3",{className:"im-heading im-medium",children:n("settings.deliveryTargets.label")}),i("p",{className:"im-small im-muted",children:n("settingsSection.target.description")}),u.targets.map(S=>i(Se,{target:S,columns:pe,proxies:b.proxies,environmentId:e.environmentId,bridge:e.bridge,t:n,onSaved:V,onDiscard:()=>{}},S.rowId)),h?i(Se,{target:null,columns:pe,proxies:b.proxies,environmentId:e.environmentId,bridge:e.bridge,t:n,onSaved:S=>{I(!1),V(S)},onDiscard:()=>I(!1)},ce.newSlot):null,i("div",{className:"im-actions",children:i(y,{variant:"outline",disabled:h,onClick:()=>{I(!0),m(G(ce.newSlot,null))},children:n("settingsSection.target.add")})})]}),i(Le,{bridge:e.bridge,children:d("div",{className:"im-settings",children:[i("style",{children:nn}),i("h2",{className:"im-heading im-medium",children:n("settings.title")}),F]})})}function be(e){return d(X,{variant:e.variant,layout:"inline",children:[i(ee,{children:e.message}),i(Ke,{children:i(y,{variant:"ghost",size:"sm",onClick:e.onRetry,children:e.retryLabel})})]})}function Sn(e){return{slots:[{name:"settings.section",order:20,component(n){return i(rn,{bridge:e,environmentId:n.environmentId??null},n.environmentId??"")}}]}}export{Sn as default};
package/dist/index.js CHANGED
@@ -138285,7 +138285,7 @@ var en_default = {
138285
138285
  },
138286
138286
  wecomAppCallbackBaseUrl: {
138287
138287
  label: "Public callback base URL (optional)",
138288
- description: "When set, logs print the full callback URL to paste into WeCom \u201CReceive messages \u2192 API receive\u201D. Default listener is 127.0.0.1; use a reverse proxy or tunnel.",
138288
+ description: "The public address that forwards to this machine's callback port. When set, the full callback URL to paste into WeCom \u201CReceive messages \u2192 API receive\u201D appears below; otherwise only the path does.",
138289
138289
  placeholder: "https://im.example.com or http://IP:30987"
138290
138290
  },
138291
138291
  wecomAppApiBaseUrl: {
@@ -138295,9 +138295,14 @@ var en_default = {
138295
138295
  },
138296
138296
  wecomAppListenPort: {
138297
138297
  label: "Local callback port (optional)",
138298
- description: "Defaults to 30987 on 127.0.0.1. Shared across self-built apps.",
138298
+ description: "Defaults to 30987. Self-built apps listening on the same address share one port.",
138299
138299
  placeholder: "30987"
138300
138300
  },
138301
+ wecomAppListenHost: {
138302
+ label: "Local listen address (optional)",
138303
+ description: "Defaults to 127.0.0.1: only this machine can reach the callback port, so put a reverse proxy or tunnel in front of it. 0.0.0.0 listens on every network interface, which opens the callback port to the network; only use it behind a firewall you control.",
138304
+ placeholder: "127.0.0.1"
138305
+ },
138301
138306
  wechatBotToken: {
138302
138307
  label: "WeChat bot token",
138303
138308
  description: "bot_token from QR binding. Live iLink login is gated by proposal 0069; filling this in does not connect yet."
@@ -138331,7 +138336,8 @@ var en_default = {
138331
138336
  unsupportedType: "I can't process {{type}} messages yet.",
138332
138337
  unsupportedFolder: "Folders can't be downloaded. Zip it and send the archive instead.",
138333
138338
  sendingFile: "Sending {{name}}:",
138334
- notAllowedYet: `You are not on the allow list yet. Your user id is {{id}}. Add it under Settings \u2192 Plugins \u2192 Chat, in this bot's "Allowed people" box.`
138339
+ notAllowedYet: `You are not on the allow list yet. Your user id is {{id}}. Add it under Settings \u2192 Plugins \u2192 Chat, in this bot's "Allowed people" box.`,
138340
+ received: "Got it, working on it."
138335
138341
  },
138336
138342
  approval: {
138337
138343
  allow: "Allow",
@@ -138744,7 +138750,8 @@ var en_default = {
138744
138750
  format: "This format isn't right."
138745
138751
  },
138746
138752
  publicField: {
138747
- callbackUrl: "Callback URL"
138753
+ callbackUrl: "Callback URL",
138754
+ callbackPath: "Callback path"
138748
138755
  },
138749
138756
  action: {
138750
138757
  running: "Working\u2026",
@@ -138770,6 +138777,11 @@ var en_default = {
138770
138777
  untitled: "New target",
138771
138778
  removeConfirm: "Delete this target",
138772
138779
  removeFailed: "Couldn't delete this target."
138780
+ },
138781
+ publicFieldHint: {
138782
+ callbackNeedsKeys: "Fill in Token and EncodingAESKey and save; the callback URL is derived from them and appears here.",
138783
+ callbackPathNeedsBase: "Put the public address that forwards to this machine in front of this path, or fill in the public callback base URL above to get the full URL.",
138784
+ callbackFollowsKeys: "This URL changes when Token or EncodingAESKey changes. Paste it into WeCom again after changing them."
138773
138785
  }
138774
138786
  },
138775
138787
  team: {
@@ -138955,7 +138967,7 @@ var zh_CN_default = {
138955
138967
  },
138956
138968
  wecomAppCallbackBaseUrl: {
138957
138969
  label: "\u516C\u7F51\u56DE\u8C03\u57FA\u5740\uFF08\u53EF\u9009\uFF09",
138958
- description: "\u586B\u516C\u7F51\u53EF\u8FBE\u7684 http(s) \u57FA\u5740\u540E\uFF0C\u65E5\u5FD7\u4F1A\u6253\u5370\u5B8C\u6574\u56DE\u8C03 URL\uFF0C\u628A\u5B83\u8D34\u8FDB\u4F01\u5FAE\u300C\u63A5\u6536\u6D88\u606F \u2192 \u8BBE\u7F6E API \u63A5\u6536\u300D\u3002\u4E0D\u586B\u53EA\u663E\u793A\u672C\u673A\u8DEF\u5F84\u3002\u9ED8\u8BA4\u76D1\u542C 127.0.0.1\uFF0C\u9700\u53CD\u4EE3\u6216\u96A7\u9053\u3002",
138970
+ description: "\u8F6C\u53D1\u5230\u672C\u673A\u56DE\u8C03\u7AEF\u53E3\u7684\u516C\u7F51\u5730\u5740\u3002\u586B\u4E86\u4E0B\u9762\u5C31\u7ED9\u51FA\u5B8C\u6574\u56DE\u8C03\u5730\u5740\uFF0C\u8D34\u8FDB\u4F01\u4E1A\u5FAE\u4FE1\u300C\u63A5\u6536\u6D88\u606F \u2192 \u8BBE\u7F6E API \u63A5\u6536\u300D\uFF1B\u4E0D\u586B\u53EA\u7ED9\u8DEF\u5F84\u3002",
138959
138971
  placeholder: "https://im.example.com \u6216 http://IP:30987"
138960
138972
  },
138961
138973
  wecomAppApiBaseUrl: {
@@ -138965,9 +138977,14 @@ var zh_CN_default = {
138965
138977
  },
138966
138978
  wecomAppListenPort: {
138967
138979
  label: "\u672C\u673A\u56DE\u8C03\u7AEF\u53E3\uFF08\u53EF\u9009\uFF09",
138968
- description: "\u9ED8\u8BA4 30987\uFF0C\u53EA\u542C 127.0.0.1\u3002\u591A\u53F0\u81EA\u5EFA\u5E94\u7528\u5171\u7528\u4E00\u4E2A\u7AEF\u53E3\u3002",
138980
+ description: "\u9ED8\u8BA4 30987\u3002\u76D1\u542C\u5730\u5740\u76F8\u540C\u7684\u81EA\u5EFA\u5E94\u7528\u5171\u7528\u4E00\u4E2A\u7AEF\u53E3\u3002",
138969
138981
  placeholder: "30987"
138970
138982
  },
138983
+ wecomAppListenHost: {
138984
+ label: "\u672C\u673A\u76D1\u542C\u5730\u5740\uFF08\u53EF\u9009\uFF09",
138985
+ description: "\u9ED8\u8BA4 127.0.0.1\uFF1A\u53EA\u6709\u672C\u673A\u8FDE\u5F97\u4E0A\u56DE\u8C03\u7AEF\u53E3\uFF0C\u9700\u8981\u5728\u524D\u9762\u653E\u53CD\u4EE3\u6216\u96A7\u9053\u3002\u586B 0.0.0.0 \u4F1A\u5728\u6240\u6709\u7F51\u5361\u4E0A\u76D1\u542C\uFF0C\u7B49\u4E8E\u628A\u56DE\u8C03\u7AEF\u53E3\u5BF9\u5916\u5F00\u653E\uFF0C\u8981\u81EA\u5DF1\u7528\u9632\u706B\u5899\u63A7\u597D\u3002",
138986
+ placeholder: "127.0.0.1"
138987
+ },
138971
138988
  wechatBotToken: {
138972
138989
  label: "\u5FAE\u4FE1\u673A\u5668\u4EBA\u4EE4\u724C",
138973
138990
  description: "\u626B\u7801\u7ED1\u5B9A\u540E\u5F97\u5230\u7684 bot_token\u3002\u771F\u767B\u5F55\u5C1A\u672A\u5F00\u653E\uFF1A\u586B\u4E86\u4E5F\u4E0D\u4F1A\u8FDE\u4E0A iLink\uFF0C\u89C1\u63D0\u6848 0069 \u5B89\u5168\u8BC4\u5BA1\u3002"
@@ -139001,7 +139018,8 @@ var zh_CN_default = {
139001
139018
  unsupportedType: "\u6211\u8FD8\u4E0D\u80FD\u5904\u7406 {{type}} \u7C7B\u578B\u7684\u6D88\u606F\u3002",
139002
139019
  unsupportedFolder: "\u6587\u4EF6\u5939\u6CA1\u6CD5\u4E0B\u8F7D\uFF0C\u8BF7\u6253\u5305\u6210\u538B\u7F29\u6587\u4EF6\u518D\u53D1\u3002",
139003
139020
  sendingFile: "\u6B63\u5728\u53D1\u9001 {{name}}\uFF1A",
139004
- notAllowedYet: "\u4F60\u8FD8\u4E0D\u5728\u5141\u8BB8\u540D\u5355\u91CC\uFF0C\u4F60\u7684\u7528\u6237 id \u662F {{id}}\uFF0C\u8BF7\u628A\u5B83\u586B\u8FDB \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 \u804A\u5929 \u2192 \u8FD9\u4E2A\u673A\u5668\u4EBA\u7684\u300C\u5141\u8BB8\u7684\u4EBA\u300D\u3002"
139021
+ notAllowedYet: "\u4F60\u8FD8\u4E0D\u5728\u5141\u8BB8\u540D\u5355\u91CC\uFF0C\u4F60\u7684\u7528\u6237 id \u662F {{id}}\uFF0C\u8BF7\u628A\u5B83\u586B\u8FDB \u8BBE\u7F6E \u2192 \u63D2\u4EF6 \u2192 \u804A\u5929 \u2192 \u8FD9\u4E2A\u673A\u5668\u4EBA\u7684\u300C\u5141\u8BB8\u7684\u4EBA\u300D\u3002",
139022
+ received: "\u6536\u5230\uFF0C\u5728\u5904\u7406\u3002"
139005
139023
  },
139006
139024
  approval: {
139007
139025
  allow: "\u5141\u8BB8",
@@ -139414,7 +139432,8 @@ var zh_CN_default = {
139414
139432
  format: "\u8FD9\u4E2A\u683C\u5F0F\u4E0D\u5BF9\u3002"
139415
139433
  },
139416
139434
  publicField: {
139417
- callbackUrl: "\u56DE\u8C03\u5730\u5740"
139435
+ callbackUrl: "\u56DE\u8C03\u5730\u5740",
139436
+ callbackPath: "\u56DE\u8C03\u8DEF\u5F84"
139418
139437
  },
139419
139438
  action: {
139420
139439
  running: "\u6B63\u5728\u5904\u7406\u2026",
@@ -139440,6 +139459,11 @@ var zh_CN_default = {
139440
139459
  untitled: "\u65B0\u76EE\u6807",
139441
139460
  removeConfirm: "\u5220\u9664\u8FD9\u4E2A\u76EE\u6807",
139442
139461
  removeFailed: "\u8FD9\u4E2A\u76EE\u6807\u6CA1\u5220\u6389\u3002"
139462
+ },
139463
+ publicFieldHint: {
139464
+ callbackNeedsKeys: "\u586B\u597D Token \u548C EncodingAESKey \u5E76\u4FDD\u5B58\u540E\uFF0C\u8FD9\u91CC\u7ED9\u51FA\u56DE\u8C03\u5730\u5740\uFF08\u5730\u5740\u7531\u5B83\u4FE9\u7B97\u51FA\uFF09\u3002",
139465
+ callbackPathNeedsBase: "\u628A\u8F6C\u53D1\u5230\u672C\u673A\u7684\u516C\u7F51\u5730\u5740\u62FC\u5728\u8FD9\u6BB5\u8DEF\u5F84\u524D\u9762\uFF0C\u6216\u5728\u4E0A\u9762\u586B\u516C\u7F51\u56DE\u8C03\u57FA\u5740\uFF0C\u8FD9\u91CC\u5C31\u7ED9\u51FA\u5B8C\u6574\u5730\u5740\u3002",
139466
+ callbackFollowsKeys: "\u6539\u4E86 Token \u6216 EncodingAESKey\uFF0C\u8FD9\u4E2A\u5730\u5740\u4F1A\u53D8\uFF0C\u8981\u91CD\u65B0\u8D34\u8FDB\u4F01\u4E1A\u5FAE\u4FE1\u3002"
139443
139467
  }
139444
139468
  },
139445
139469
  team: {
@@ -143898,6 +143922,7 @@ var WecomAppApi = class {
143898
143922
 
143899
143923
  // src/wecomAppCallback.ts
143900
143924
  import * as NodeHttp2 from "node:http";
143925
+ import * as NodeNet from "node:net";
143901
143926
 
143902
143927
  // src/wecomAppCrypto.ts
143903
143928
  import * as NodeCrypto6 from "node:crypto";
@@ -144060,6 +144085,10 @@ var parseWecomAppPlainMessage = (raw) => {
144060
144085
 
144061
144086
  // src/wecomAppCallback.ts
144062
144087
  var WECOM_APP_DEFAULT_CALLBACK_HOST = "127.0.0.1";
144088
+ var parseListenHost = (raw) => {
144089
+ if (raw === "") return WECOM_APP_DEFAULT_CALLBACK_HOST;
144090
+ return NodeNet.isIPv4(raw) ? raw : null;
144091
+ };
144063
144092
  var WECOM_APP_DEFAULT_CALLBACK_PORT = 30987;
144064
144093
  var WECOM_APP_CALLBACK_PATH_PREFIX = "/wecom-app-callback";
144065
144094
  var MAX_BODY_BYTES2 = 1 * 1024 * 1024;
@@ -144318,7 +144347,8 @@ var wecomAppCredentials = (bot) => ({
144318
144347
  encodingAESKey: value(bot, "wecomAppEncodingAESKey"),
144319
144348
  callbackBaseUrl: value(bot, "wecomAppCallbackBaseUrl").replace(/\/+$/u, ""),
144320
144349
  apiBaseUrl: value(bot, "wecomAppApiBaseUrl"),
144321
- listenPortRaw: value(bot, "wecomAppListenPort")
144350
+ listenPortRaw: value(bot, "wecomAppListenPort"),
144351
+ listenHostRaw: value(bot, "wecomAppListenHost")
144322
144352
  });
144323
144353
  var validCorpId = (id) => /^[A-Za-z][A-Za-z0-9_-]{2,127}$/u.test(id);
144324
144354
  var validAgentId = (id) => /^\d{1,32}$/u.test(id) && Number(id) > 0;
@@ -144361,14 +144391,18 @@ var validateWecomAppBot = (bot) => {
144361
144391
  if (parseListenPort(c.listenPortRaw) === null) {
144362
144392
  issues.push({ column: "wecomAppListenPort", code: "format" });
144363
144393
  }
144394
+ if (parseListenHost(c.listenHostRaw) === null) {
144395
+ issues.push({ column: "wecomAppListenHost", code: "format" });
144396
+ }
144364
144397
  return issues;
144365
144398
  };
144366
144399
  var readWecomAppConnectConfig = (bot) => {
144367
144400
  const issues = validateWecomAppBot(bot);
144368
144401
  const credentials3 = wecomAppCredentials(bot);
144369
144402
  const listenPort = parseListenPort(credentials3.listenPortRaw);
144370
- if (issues.length > 0 || listenPort === null) return { ok: false, issues };
144371
- return { ok: true, credentials: credentials3, listenPort };
144403
+ const listenHost = parseListenHost(credentials3.listenHostRaw);
144404
+ if (issues.length > 0 || listenPort === null || listenHost === null) return { ok: false, issues };
144405
+ return { ok: true, credentials: credentials3, listenHost, listenPort };
144372
144406
  };
144373
144407
 
144374
144408
  // src/wecomAppAdapter.ts
@@ -144413,6 +144447,13 @@ var COLUMNS5 = [
144413
144447
  labelKey: "column.wecomAppListenPort.label",
144414
144448
  descriptionKey: "column.wecomAppListenPort.description",
144415
144449
  placeholderKey: "column.wecomAppListenPort.placeholder"
144450
+ },
144451
+ {
144452
+ key: "wecomAppListenHost",
144453
+ kind: "text",
144454
+ labelKey: "column.wecomAppListenHost.label",
144455
+ descriptionKey: "column.wecomAppListenHost.description",
144456
+ placeholderKey: "column.wecomAppListenHost.placeholder"
144416
144457
  }
144417
144458
  ];
144418
144459
  var WECOM_APP_IMAGE_BYTES = 10 * 1024 * 1024;
@@ -144422,15 +144463,19 @@ var WECOM_APP_IMAGE_TYPES = /* @__PURE__ */ new Set(["image/jpeg", "image/png"])
144422
144463
  var joinCallbackUrl = (baseOrOrigin, path) => `${baseOrOrigin}${path}`;
144423
144464
  var wecomAppPublicFields = (bot) => {
144424
144465
  const c = wecomAppCredentials(bot);
144425
- if (c.callbackBaseUrl === "") return [];
144466
+ if (c.token === "" || c.encodingAESKey === "") {
144467
+ return [{ key: "callbackUrl", value: "", hint: "callbackNeedsKeys" }];
144468
+ }
144469
+ const path = callbackRoutePath(bot.rowId, c.token, c.encodingAESKey);
144470
+ if (c.callbackBaseUrl === "") {
144471
+ return [{ key: "callbackPath", value: path, copyable: true, hint: "callbackPathNeedsBase" }];
144472
+ }
144426
144473
  return [
144427
144474
  {
144428
144475
  key: "callbackUrl",
144429
- value: joinCallbackUrl(
144430
- c.callbackBaseUrl,
144431
- callbackRoutePath(bot.rowId, c.token, c.encodingAESKey)
144432
- ),
144433
- copyable: true
144476
+ value: joinCallbackUrl(c.callbackBaseUrl, path),
144477
+ copyable: true,
144478
+ hint: "callbackFollowsKeys"
144434
144479
  }
144435
144480
  ];
144436
144481
  };
@@ -144552,7 +144597,7 @@ var makeWecomAppAdapter = (deps) => {
144552
144597
  );
144553
144598
  }
144554
144599
  const c = config2.credentials;
144555
- const lease = await callbackHub.acquire({ port: config2.listenPort });
144600
+ const lease = await callbackHub.acquire({ host: config2.listenHost, port: config2.listenPort });
144556
144601
  const server = lease.server;
144557
144602
  const api = newApi(c);
144558
144603
  apis.set(bot.rowId, api);
@@ -144599,6 +144644,15 @@ var makeWecomAppAdapter = (deps) => {
144599
144644
  }
144600
144645
  await apiFor(binding).sendText({ userId: binding.chatId, content: text4 });
144601
144646
  },
144647
+ // D376:企业微信自建应用没有表情回执也没有流式,开工时先回一句文字,结论照常另发。没有要撤的
144648
+ // 东西,回 null;发不出去由核心记一条 warn,不拦这一轮。
144649
+ acknowledge: async (binding) => {
144650
+ await apiFor(binding).sendText({
144651
+ userId: binding.chatId,
144652
+ content: deps.translate("reply.received")
144653
+ });
144654
+ return null;
144655
+ },
144602
144656
  sendImage: (binding, image2) => sendMedia(binding, "image", image2),
144603
144657
  sendFile: (binding, file) => sendMedia(binding, "file", file),
144604
144658
  outboundLimits: {
@@ -144621,7 +144675,7 @@ var makeWecomAppAdapter = (deps) => {
144621
144675
  // src/index.ts
144622
144676
  var imPlugin = definePlugin({
144623
144677
  id: "im",
144624
- apiVersion: 16,
144678
+ apiVersion: 17,
144625
144679
  activate: async (ctx) => {
144626
144680
  const { t, setLanguage } = makeLiveTranslate(
144627
144681
  parseReplyLanguage(ctx.config[REPLY_LANGUAGE_FIELD])
package/locales/en.json CHANGED
@@ -170,7 +170,7 @@
170
170
  },
171
171
  "wecomAppCallbackBaseUrl": {
172
172
  "label": "Public callback base URL (optional)",
173
- "description": "When set, logs print the full callback URL to paste into WeCom “Receive messages → API receive”. Default listener is 127.0.0.1; use a reverse proxy or tunnel.",
173
+ "description": "The public address that forwards to this machine's callback port. When set, the full callback URL to paste into WeCom “Receive messages → API receive” appears below; otherwise only the path does.",
174
174
  "placeholder": "https://im.example.com or http://IP:30987"
175
175
  },
176
176
  "wecomAppApiBaseUrl": {
@@ -180,9 +180,14 @@
180
180
  },
181
181
  "wecomAppListenPort": {
182
182
  "label": "Local callback port (optional)",
183
- "description": "Defaults to 30987 on 127.0.0.1. Shared across self-built apps.",
183
+ "description": "Defaults to 30987. Self-built apps listening on the same address share one port.",
184
184
  "placeholder": "30987"
185
185
  },
186
+ "wecomAppListenHost": {
187
+ "label": "Local listen address (optional)",
188
+ "description": "Defaults to 127.0.0.1: only this machine can reach the callback port, so put a reverse proxy or tunnel in front of it. 0.0.0.0 listens on every network interface, which opens the callback port to the network; only use it behind a firewall you control.",
189
+ "placeholder": "127.0.0.1"
190
+ },
186
191
  "wechatBotToken": {
187
192
  "label": "WeChat bot token",
188
193
  "description": "bot_token from QR binding. Live iLink login is gated by proposal 0069; filling this in does not connect yet."
@@ -216,7 +221,8 @@
216
221
  "unsupportedType": "I can't process {{type}} messages yet.",
217
222
  "unsupportedFolder": "Folders can't be downloaded. Zip it and send the archive instead.",
218
223
  "sendingFile": "Sending {{name}}:",
219
- "notAllowedYet": "You are not on the allow list yet. Your user id is {{id}}. Add it under Settings → Plugins → Chat, in this bot's \"Allowed people\" box."
224
+ "notAllowedYet": "You are not on the allow list yet. Your user id is {{id}}. Add it under Settings → Plugins → Chat, in this bot's \"Allowed people\" box.",
225
+ "received": "Got it, working on it."
220
226
  },
221
227
  "approval": {
222
228
  "allow": "Allow",
@@ -629,7 +635,8 @@
629
635
  "format": "This format isn't right."
630
636
  },
631
637
  "publicField": {
632
- "callbackUrl": "Callback URL"
638
+ "callbackUrl": "Callback URL",
639
+ "callbackPath": "Callback path"
633
640
  },
634
641
  "action": {
635
642
  "running": "Working…",
@@ -655,6 +662,11 @@
655
662
  "untitled": "New target",
656
663
  "removeConfirm": "Delete this target",
657
664
  "removeFailed": "Couldn't delete this target."
665
+ },
666
+ "publicFieldHint": {
667
+ "callbackNeedsKeys": "Fill in Token and EncodingAESKey and save; the callback URL is derived from them and appears here.",
668
+ "callbackPathNeedsBase": "Put the public address that forwards to this machine in front of this path, or fill in the public callback base URL above to get the full URL.",
669
+ "callbackFollowsKeys": "This URL changes when Token or EncodingAESKey changes. Paste it into WeCom again after changing them."
658
670
  }
659
671
  },
660
672
  "team": {
@@ -170,7 +170,7 @@
170
170
  },
171
171
  "wecomAppCallbackBaseUrl": {
172
172
  "label": "公网回调基址(可选)",
173
- "description": "填公网可达的 http(s) 基址后,日志会打印完整回调 URL,把它贴进企微「接收消息 → 设置 API 接收」。不填只显示本机路径。默认监听 127.0.0.1,需反代或隧道。",
173
+ "description": "转发到本机回调端口的公网地址。填了下面就给出完整回调地址,贴进企业微信「接收消息 → 设置 API 接收」;不填只给路径。",
174
174
  "placeholder": "https://im.example.com 或 http://IP:30987"
175
175
  },
176
176
  "wecomAppApiBaseUrl": {
@@ -180,9 +180,14 @@
180
180
  },
181
181
  "wecomAppListenPort": {
182
182
  "label": "本机回调端口(可选)",
183
- "description": "默认 30987,只听 127.0.0.1。多台自建应用共用一个端口。",
183
+ "description": "默认 30987。监听地址相同的自建应用共用一个端口。",
184
184
  "placeholder": "30987"
185
185
  },
186
+ "wecomAppListenHost": {
187
+ "label": "本机监听地址(可选)",
188
+ "description": "默认 127.0.0.1:只有本机连得上回调端口,需要在前面放反代或隧道。填 0.0.0.0 会在所有网卡上监听,等于把回调端口对外开放,要自己用防火墙控好。",
189
+ "placeholder": "127.0.0.1"
190
+ },
186
191
  "wechatBotToken": {
187
192
  "label": "微信机器人令牌",
188
193
  "description": "扫码绑定后得到的 bot_token。真登录尚未开放:填了也不会连上 iLink,见提案 0069 安全评审。"
@@ -216,7 +221,8 @@
216
221
  "unsupportedType": "我还不能处理 {{type}} 类型的消息。",
217
222
  "unsupportedFolder": "文件夹没法下载,请打包成压缩文件再发。",
218
223
  "sendingFile": "正在发送 {{name}}:",
219
- "notAllowedYet": "你还不在允许名单里,你的用户 id 是 {{id}},请把它填进 设置 → 插件 → 聊天 → 这个机器人的「允许的人」。"
224
+ "notAllowedYet": "你还不在允许名单里,你的用户 id 是 {{id}},请把它填进 设置 → 插件 → 聊天 → 这个机器人的「允许的人」。",
225
+ "received": "收到,在处理。"
220
226
  },
221
227
  "approval": {
222
228
  "allow": "允许",
@@ -629,7 +635,8 @@
629
635
  "format": "这个格式不对。"
630
636
  },
631
637
  "publicField": {
632
- "callbackUrl": "回调地址"
638
+ "callbackUrl": "回调地址",
639
+ "callbackPath": "回调路径"
633
640
  },
634
641
  "action": {
635
642
  "running": "正在处理…",
@@ -655,6 +662,11 @@
655
662
  "untitled": "新目标",
656
663
  "removeConfirm": "删除这个目标",
657
664
  "removeFailed": "这个目标没删掉。"
665
+ },
666
+ "publicFieldHint": {
667
+ "callbackNeedsKeys": "填好 Token 和 EncodingAESKey 并保存后,这里给出回调地址(地址由它俩算出)。",
668
+ "callbackPathNeedsBase": "把转发到本机的公网地址拼在这段路径前面,或在上面填公网回调基址,这里就给出完整地址。",
669
+ "callbackFollowsKeys": "改了 Token 或 EncodingAESKey,这个地址会变,要重新贴进企业微信。"
658
670
  }
659
671
  },
660
672
  "team": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/plugin-im",
3
- "version": "0.2.3180",
3
+ "version": "0.2.3192",
4
4
  "description": "Talk to your agents from Telegram, WeCom, Lark, or WeChat (experimental).",
5
5
  "keywords": [
6
6
  "im",
@@ -32,7 +32,7 @@
32
32
  "markdown-it": "^15.0.2",
33
33
  "react": "19.2.6",
34
34
  "vite-plus": "0.2.2",
35
- "@ycodium-ai/plugin-api": "0.2.3180"
35
+ "@ycodium-ai/plugin-api": "0.2.3192"
36
36
  },
37
37
  "ycodium": {
38
38
  "plugin": "./dist/index.js",