dsh-comfyui-mcp 0.1.6 → 0.1.7
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/client.js +1 -1
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({id:'dsh-comfyui-mcp',factory(require){const React=require('react'),h=React.createElement;return {inject:['slots','locale'],apply(ctx){ctx.locale.register('dsh-comfyui-mcp','zh',{title:'连接与运行状态',test:'测试连接',loading:'正在测试…',idle:'尚未测试',online:'连接成功',offline:'未连接',standby:'未运行 · 按需启动待命',owned:'本插件进程',external:'外部进程',hint:'测试只探测地址,不启动 ComfyUI 或加载模型。请在下方运行配置中编辑参数。',safety:'禁用或卸载仅停止本插件进程;保留模型、工作流与图片。',credit:'工具由 artokun/comfyui-mcp 0.52.206 提供。'});ctx.locale.register('dsh-comfyui-mcp','en',{title:'Connection & runtime',test:'Test connection',loading:'Testing…',idle:'Not tested',online:'Connected',offline:'Offline',standby:'Not running · on-demand ready',owned:'Plugin-owned process',external:'External process',hint:'Testing never starts ComfyUI or loads models. Edit runtime parameters in the form below.',safety:'Disabling/uninstalling stops only plugin-owned processes; models, workflows and images are retained.',credit:'Tools powered by artokun/comfyui-mcp 0.52.206.'});const t=ctx.locale.bind('dsh-comfyui-mcp');function Status(){const [s,set]=React.useState(),[busy,setBusy]=React.useState(false);React.useSyncExternalStore(fn=>ctx.locale.subscribe(fn),()=>ctx.locale.getSnapshot());async function test(){setBusy(true);try{const r=await fetch('/api/dsh-comfyui/status',{cache:'no-store'});if(!r.ok)throw Error('HTTP '+r.status);set(await r.json());}catch(e){set({running:false,error:e.message});}finally{setBusy(false);}}const standby=!!s&&!s.running&&s.autoStart===true&&!s.owned&&!s.lastError&&s.error==='fetch failed';return h('section',{className:'dcm-status'},h('style',null,'.dcm-status{border:1px solid var(--dsw-alias-border-l1);border-radius:12px;padding:20px;color:var(--dsw-alias-label-primary);font-size:14px}.dcm-status .dcm-row{display:flex;justify-content:space-between;align-items:center;gap:16px}.dcm-status .dcm-badge{font-size:12px;background:var(--dsw-alias-bg-layer-2);padding:6px 10px;border-radius:20px}.dcm-status h3{font-size:15px;margin:0 0 16px}.dcm-status p{line-height:1.7;color:var(--dsw-alias-label-secondary)}.dcm-status button{font:inherit;padding:9px 12px;border:1px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-bg-base);cursor:pointer}.dcm-status pre{white-space:pre-wrap;overflow-wrap:anywhere}.dcm-status small{color:var(--dsw-alias-label-secondary)}'),h('div',{className:'dcm-row'},h('h3',null,t('title')),h('span',{className:'dcm-badge',role:'status'},busy?t('loading'):!s?t('idle'):s.running?t('online')+' · '+t(s.owned?'owned':'external'):t(standby?'standby':'offline'))),h('p',null,'工具发现不会启动 ComfyUI 或加载模型。'),s?.error&&!standby?h('pre',{role:'alert'},s.error):null,s?.lastError?h('pre',null,s.lastError):null,h('button',{onClick:test,disabled:busy},t(busy?'loading':'test')),h('p',null,t('hint')),h('p',null,t('safety')),h('small',null,t('credit')));}function ConfigPage({view,form}){const initial=form?.state?.value;const [draft,setDraft]=React.useState(null),[busy,setBusy]=React.useState(false),[message,setMessage]=React.useState('');const zh=ctx.locale.getLocale().id!=='en';const text=(a,b)=>zh?a:b;const fields=['lazyTools','url','autoStart','comfyuiDir','pythonPath','launchArgs','startupTimeoutMs'];const defaults={lazyTools:true,url:'http://127.0.0.1:8188',autoStart:false,comfyuiDir:'',pythonPath:'',launchArgs:[],startupTimeoutMs:120000};if(view==='summary')return text('ComfyUI 连接与本地按需启动参数','ComfyUI connection and local on-demand startup');if(!initial)return h('p',{role:'status'},text('配置尚未就绪或不可用','Configuration is loading or unavailable'));const values=draft||Object.fromEntries(fields.map(k=>[k,k==='launchArgs'?JSON.stringify(initial[k]??defaults[k]):initial[k]??defaults[k]]));async function save(e){e.preventDefault();setBusy(true);setMessage('');try{const v={...values,launchArgs:JSON.parse(values.launchArgs),startupTimeoutMs:Number(values.startupTimeoutMs)};if(!Array.isArray(v.launchArgs)||v.launchArgs.some(x=>typeof x!=='string'))throw Error('launchArgs must be a JSON string array');if(!Number.isFinite(v.startupTimeoutMs)||v.startupTimeoutMs<1000||v.startupTimeoutMs>600000)throw Error('startupTimeoutMs: 1000–600000');const ok=await form.mutate(fields.map(k=>({op:'set',path:[k],value:v[k]})),form.state.revision);setMessage(ok?text('配置已保存','Configuration saved'):text('保存失败或配置已变更,请重新打开页面后重试','Save failed or configuration changed; reopen this page and retry'));if(ok)setDraft(null);}catch(e){setMessage(e.message);}finally{setBusy(false);}}return h('form',{className:'dcm-config',onSubmit:save},h('style',null,'.dcm-config{max-width:760px;font-size:14px}.dcm-config .dcm-lazy-row{display:flex;align-items:center;justify-content:space-between;gap:16px;border-bottom:1px solid var(--dsw-alias-border-l1);padding-bottom:18px;margin-bottom:20px}.dcm-lazy-row p{margin:6px 0 0;font-size:13px;line-height:1.7;color:var(--dsw-alias-label-secondary)}.dcm-config .dcm-switch{flex-shrink:0;display:flex;justify-content:flex-end;width:36px;height:20px;padding:2px;border:0;border-radius:20px;background:var(--dsw-alias-brand-primary)}.dcm-switch::after{content:"";width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-bg-base)}.dcm-config .dcm-switch[aria-checked=false]{background:var(--dsw-alias-state-idle-primary);justify-content:flex-start}.dcm-config button:disabled{opacity:.5;cursor:not-allowed}.dcm-config label{display:block;margin:18px 0 6px}.dcm-config input,.dcm-config select,.dcm-config textarea{display:block;box-sizing:border-box;width:100%;padding:9px 12px;margin-top:6px;border:1px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font:inherit}.dcm-config button{font:inherit;padding:9px 12px;border:1px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-bg-base)}'),h('div',{className:'dcm-lazy-row'},h('div',null,h('span',{id:'dcm-lazy-label'},text('工具懒加载','Lazy tool loading')),h('p',{id:'dcm-lazy-help'},values.lazyTools?text('仅保留加载入口,需要时再展开 4 个 ComfyUI 工具;不启动服务。','Keep one loader; expose four ComfyUI tools on demand without starting the service.'):text('直接提供 4 个 ComfyUI 工具,省去首次加载调用。','Expose four ComfyUI tools immediately; skip the initial loading call.'))),h('button',{className:'dcm-switch',type:'button',role:'switch','aria-checked':values.lazyTools,'aria-labelledby':'dcm-lazy-label','aria-describedby':'dcm-lazy-help',disabled:busy||!form.state.writable,onClick:()=>setDraft({...values,lazyTools:!values.lazyTools})})),...fields.filter(k=>k!=='lazyTools').map(k=>h('label',{key:k},text({url:'ComfyUI 地址',autoStart:'允许本地按需启动',comfyuiDir:'ComfyUI 目录',pythonPath:'Python 可执行文件',launchArgs:'额外启动参数',startupTimeoutMs:'启动超时(毫秒)'}[k],{url:'ComfyUI address',autoStart:'Allow local on-demand startup',comfyuiDir:'ComfyUI directory',pythonPath:'Python executable',launchArgs:'Extra launch arguments',startupTimeoutMs:'Startup timeout (ms)'}[k]),k==='autoStart'?h('select',{value:String(values[k]),disabled:busy||!form.state.writable,onChange:e=>setDraft({...values,[k]:e.target.value==='true'})},h('option',{value:'false'},text('关闭:仅连接现有服务','Off: existing service only')),h('option',{value:'true'},text('开启:首次执行工具时启动','On: start on first tool execution'))):h(k==='launchArgs'?'textarea':'input',{type:k==='startupTimeoutMs'?'number':'text',rows:k==='launchArgs'?3:undefined,placeholder:k==='comfyuiDir'?text('包含 main.py 的目录','Directory containing main.py'):k==='pythonPath'?text('Python 的完整路径','Full Python path'):undefined,value:values[k],disabled:busy||!form.state.writable,onChange:e=>setDraft({...values,[k]:e.target.value})}))),h('p',null,text('仅保存时更新配置;不会安装模型或 Python 依赖。启动参数为 JSON 数组。','Only Save updates configuration. No models or Python dependencies are installed. Launch arguments are a JSON array.')),h('button',{type:'submit',disabled:busy||!form.state.writable},busy?text('保存中…','Saving…'):text('保存配置','Save configuration')),h('p',{role:'status'},message));}function UnifiedPage({scope}){const state=React.useSyncExternalStore(fn=>scope.subscribe(fn),()=>scope.getSnapshot());return h('div',{className:'dcm-page',style:{maxWidth:760}},h(Status),h('section',{style:{border:'1px solid var(--dsw-alias-border-l1)',borderRadius:12,padding:20,marginTop:24}},h('h3',{style:{fontSize:15,margin:'0 0 16px'}},ctx.locale.getLocale().id==='en'?'Runtime configuration · DSH configuration form':'运行配置 · DSH 官方配置表单'),h('p',{style:{lineHeight:1.7,color:'var(--dsw-alias-label-secondary)'}},ctx.locale.getLocale().id==='en'?'This page uses DSH configuration snapshots, revisions and atomic saves.':'表单与连接状态位于同一插件详情页,使用 DSH 官方配置快照、修订号及原子保存操作。'),h(ConfigPage,{view:'page',form:{state,mutate:(ops,revision)=>scope.mutate(ops,revision)}})));}ctx.inject(['configForms'],c=>{const forms=c.configForms;c.effect(()=>forms.whileServed(['dsh-comfyui-mcp'],()=>c.slots.inject('plugins.bundle.config',()=>c.slots.register({name:'plugins.bundle.config',key:'dsh-comfyui-mcp'},()=>h(UnifiedPage,{scope:forms.get('dsh-comfyui-mcp')})))),'comfyui.config-page');});}};}});
|
|
1
|
+
window.__ModuleLoader__.load({id:'dsh-comfyui-mcp',factory(require){const React=require('react'),h=React.createElement;return {inject:['slots','locale'],apply(ctx){ctx.effect(()=>ctx.locale.register('dsh-comfyui-mcp-ui','zh',{title:'连接与运行状态',test:'测试连接',loading:'正在测试…',idle:'尚未测试',online:'连接成功',offline:'未连接',standby:'未运行 · 按需启动待命',owned:'本插件进程',external:'外部进程',hint:'测试只探测地址,不启动 ComfyUI 或加载模型。请在下方运行配置中编辑参数。',safety:'禁用或卸载仅停止本插件进程;保留模型、工作流与图片。',credit:'工具由 artokun/comfyui-mcp 0.52.206 提供。'}),'comfyui.locale.zh');ctx.effect(()=>ctx.locale.register('dsh-comfyui-mcp-ui','en',{title:'Connection & runtime',test:'Test connection',loading:'Testing…',idle:'Not tested',online:'Connected',offline:'Offline',standby:'Not running · on-demand ready',owned:'Plugin-owned process',external:'External process',hint:'Testing never starts ComfyUI or loads models. Edit runtime parameters in the form below.',safety:'Disabling/uninstalling stops only plugin-owned processes; models, workflows and images are retained.',credit:'Tools powered by artokun/comfyui-mcp 0.52.206.'}),'comfyui.locale.en');const t=ctx.locale.bind('dsh-comfyui-mcp-ui');function Status(){const [s,set]=React.useState(),[busy,setBusy]=React.useState(false);React.useSyncExternalStore(fn=>ctx.locale.subscribe(fn),()=>ctx.locale.getSnapshot());async function test(){setBusy(true);try{const r=await fetch('/api/dsh-comfyui/status',{cache:'no-store'});if(!r.ok)throw Error('HTTP '+r.status);set(await r.json());}catch(e){set({running:false,error:e.message});}finally{setBusy(false);}}const standby=!!s&&!s.running&&s.autoStart===true&&!s.owned&&!s.lastError&&s.error==='fetch failed';return h('section',{className:'dcm-status'},h('style',null,'.dcm-status{border:1px solid var(--dsw-alias-border-l1);border-radius:12px;padding:20px;color:var(--dsw-alias-label-primary);font-size:14px}.dcm-status .dcm-row{display:flex;justify-content:space-between;align-items:center;gap:16px}.dcm-status .dcm-badge{font-size:12px;background:var(--dsw-alias-bg-layer-2);padding:6px 10px;border-radius:20px}.dcm-status h3{font-size:15px;margin:0 0 16px}.dcm-status p{line-height:1.7;color:var(--dsw-alias-label-secondary)}.dcm-status button{font:inherit;padding:9px 12px;border:1px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-bg-base);cursor:pointer}.dcm-status pre{white-space:pre-wrap;overflow-wrap:anywhere}.dcm-status small{color:var(--dsw-alias-label-secondary)}'),h('div',{className:'dcm-row'},h('h3',null,t('title')),h('span',{className:'dcm-badge',role:'status'},busy?t('loading'):!s?t('idle'):s.running?t('online')+' · '+t(s.owned?'owned':'external'):t(standby?'standby':'offline'))),h('p',null,'工具发现不会启动 ComfyUI 或加载模型。'),s?.error&&!standby?h('pre',{role:'alert'},s.error):null,s?.lastError?h('pre',null,s.lastError):null,h('button',{onClick:test,disabled:busy},t(busy?'loading':'test')),h('p',null,t('hint')),h('p',null,t('safety')),h('small',null,t('credit')));}function ConfigPage({view,form}){const initial=form?.state?.value;const [draft,setDraft]=React.useState(null),[busy,setBusy]=React.useState(false),[message,setMessage]=React.useState('');const zh=ctx.locale.getLocale().id!=='en';const text=(a,b)=>zh?a:b;const fields=['lazyTools','url','autoStart','comfyuiDir','pythonPath','launchArgs','startupTimeoutMs'];const defaults={lazyTools:true,url:'http://127.0.0.1:8188',autoStart:false,comfyuiDir:'',pythonPath:'',launchArgs:[],startupTimeoutMs:120000};if(view==='summary')return text('ComfyUI 连接与本地按需启动参数','ComfyUI connection and local on-demand startup');if(!initial)return h('p',{role:'status'},text('配置尚未就绪或不可用','Configuration is loading or unavailable'));const values=draft||Object.fromEntries(fields.map(k=>[k,k==='launchArgs'?JSON.stringify(initial[k]??defaults[k]):initial[k]??defaults[k]]));async function save(e){e.preventDefault();setBusy(true);setMessage('');try{const v={...values,launchArgs:JSON.parse(values.launchArgs),startupTimeoutMs:Number(values.startupTimeoutMs)};if(!Array.isArray(v.launchArgs)||v.launchArgs.some(x=>typeof x!=='string'))throw Error('launchArgs must be a JSON string array');if(!Number.isFinite(v.startupTimeoutMs)||v.startupTimeoutMs<1000||v.startupTimeoutMs>600000)throw Error('startupTimeoutMs: 1000–600000');const ok=await form.mutate(fields.map(k=>({op:'set',path:[k],value:v[k]})),form.state.revision);setMessage(ok?text('配置已保存','Configuration saved'):text('保存失败或配置已变更,请重新打开页面后重试','Save failed or configuration changed; reopen this page and retry'));if(ok)setDraft(null);}catch(e){setMessage(e.message);}finally{setBusy(false);}}return h('form',{className:'dcm-config',onSubmit:save},h('style',null,'.dcm-config{max-width:760px;font-size:14px}.dcm-config .dcm-lazy-row{display:flex;align-items:center;justify-content:space-between;gap:16px;border-bottom:1px solid var(--dsw-alias-border-l1);padding-bottom:18px;margin-bottom:20px}.dcm-lazy-row p{margin:6px 0 0;font-size:13px;line-height:1.7;color:var(--dsw-alias-label-secondary)}.dcm-config .dcm-switch{flex-shrink:0;display:flex;justify-content:flex-end;width:36px;height:20px;padding:2px;border:0;border-radius:20px;background:var(--dsw-alias-brand-primary)}.dcm-switch::after{content:"";width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-bg-base)}.dcm-config .dcm-switch[aria-checked=false]{background:var(--dsw-alias-state-idle-primary);justify-content:flex-start}.dcm-config button:disabled{opacity:.5;cursor:not-allowed}.dcm-config label{display:block;margin:18px 0 6px}.dcm-config input,.dcm-config select,.dcm-config textarea{display:block;box-sizing:border-box;width:100%;padding:9px 12px;margin-top:6px;border:1px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font:inherit}.dcm-config button{font:inherit;padding:9px 12px;border:1px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-bg-base)}'),h('div',{className:'dcm-lazy-row'},h('div',null,h('span',{id:'dcm-lazy-label'},text('工具懒加载','Lazy tool loading')),h('p',{id:'dcm-lazy-help'},values.lazyTools?text('仅保留加载入口,需要时再展开 4 个 ComfyUI 工具;不启动服务。','Keep one loader; expose four ComfyUI tools on demand without starting the service.'):text('直接提供 4 个 ComfyUI 工具,省去首次加载调用。','Expose four ComfyUI tools immediately; skip the initial loading call.'))),h('button',{className:'dcm-switch',type:'button',role:'switch','aria-checked':values.lazyTools,'aria-labelledby':'dcm-lazy-label','aria-describedby':'dcm-lazy-help',disabled:busy||!form.state.writable,onClick:()=>setDraft({...values,lazyTools:!values.lazyTools})})),...fields.filter(k=>k!=='lazyTools').map(k=>h('label',{key:k},text({url:'ComfyUI 地址',autoStart:'允许本地按需启动',comfyuiDir:'ComfyUI 目录',pythonPath:'Python 可执行文件',launchArgs:'额外启动参数',startupTimeoutMs:'启动超时(毫秒)'}[k],{url:'ComfyUI address',autoStart:'Allow local on-demand startup',comfyuiDir:'ComfyUI directory',pythonPath:'Python executable',launchArgs:'Extra launch arguments',startupTimeoutMs:'Startup timeout (ms)'}[k]),k==='autoStart'?h('select',{value:String(values[k]),disabled:busy||!form.state.writable,onChange:e=>setDraft({...values,[k]:e.target.value==='true'})},h('option',{value:'false'},text('关闭:仅连接现有服务','Off: existing service only')),h('option',{value:'true'},text('开启:首次执行工具时启动','On: start on first tool execution'))):h(k==='launchArgs'?'textarea':'input',{type:k==='startupTimeoutMs'?'number':'text',rows:k==='launchArgs'?3:undefined,placeholder:k==='comfyuiDir'?text('包含 main.py 的目录','Directory containing main.py'):k==='pythonPath'?text('Python 的完整路径','Full Python path'):undefined,value:values[k],disabled:busy||!form.state.writable,onChange:e=>setDraft({...values,[k]:e.target.value})}))),h('p',null,text('仅保存时更新配置;不会安装模型或 Python 依赖。启动参数为 JSON 数组。','Only Save updates configuration. No models or Python dependencies are installed. Launch arguments are a JSON array.')),h('button',{type:'submit',disabled:busy||!form.state.writable},busy?text('保存中…','Saving…'):text('保存配置','Save configuration')),h('p',{role:'status'},message));}function UnifiedPage({scope}){const state=React.useSyncExternalStore(fn=>scope.subscribe(fn),()=>scope.getSnapshot());return h('div',{className:'dcm-page',style:{maxWidth:760}},h(Status),h('section',{style:{border:'1px solid var(--dsw-alias-border-l1)',borderRadius:12,padding:20,marginTop:24}},h('h3',{style:{fontSize:15,margin:'0 0 16px'}},ctx.locale.getLocale().id==='en'?'Runtime configuration · DSH configuration form':'运行配置 · DSH 官方配置表单'),h('p',{style:{lineHeight:1.7,color:'var(--dsw-alias-label-secondary)'}},ctx.locale.getLocale().id==='en'?'This page uses DSH configuration snapshots, revisions and atomic saves.':'表单与连接状态位于同一插件详情页,使用 DSH 官方配置快照、修订号及原子保存操作。'),h(ConfigPage,{view:'page',form:{state,mutate:(ops,revision)=>scope.mutate(ops,revision)}})));}ctx.inject(['configForms'],c=>{const forms=c.configForms;c.effect(()=>forms.whileServed(['dsh-comfyui-mcp'],()=>c.slots.inject('plugins.bundle.config',()=>c.slots.register({name:'plugins.bundle.config',key:'dsh-comfyui-mcp'},()=>h(UnifiedPage,{scope:forms.get('dsh-comfyui-mcp')})))),'comfyui.config-page');});}};}});
|