@sleep2agi/agent-node 0.3.1 → 0.3.2
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/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -90,7 +90,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
90
90
|
|
|
91
91
|
${t.content}
|
|
92
92
|
|
|
93
|
-
执行完后简要汇报结果。`,s={model:this.config.model,tools:this.config.tools?.length?this.config.tools:[],maxTurns:this.config.maxTurns,permissionMode:"bypassPermissions",allowDangerouslySkipPermissions:!0};if(this.config.systemPrompt)s.systemPrompt=this.config.systemPrompt;if(this.sessionId)s.resume=this.sessionId;let r="";try{for await(let a of sy({prompt:e,options:s})){if(a.type==="system"&&a.subtype==="init")this.sessionId=a.session_id;if(a.type==="result")r=a.subtype==="success"?a.result:`错误: ${a.result||a.error}`}}catch(a){r=`SDK 错误: ${a.message}`,this.log(`错误: ${a.message}`)}if(this.config.onResult)await this.config.onResult(t,r);return r}async start(){this.running=!0,this.log(`启动 | Hub: ${this.config.hub} | Model: ${this.config.model} | Runtime: ${this.config.runtime}`),await this.hub.connect(),this.log("已连接 CommHub"),this.hub.on("task",async(e)=>{let s=e.from_session||"hub";this.log(`← [${s}] ${e.content?.slice(0,60)}`),await this.hub.status("working",{task:e.content?.slice(0,50)});let r=await this.processTask(e);this.log(`→ [${s}] ${r?.slice(0,60)}`),await this.hub.send(s,`[${this.config.alias}] ${r?.slice(0,2000)}`),await this.hub.status("idle")});let t=async()=>{this.log("退出..."),this.running=!1,await this.hub.disconnect(),process.exit(0)};process.on("SIGINT",t),process.on("SIGTERM",t),await new Promise(()=>{})}async stop(){this.running=!1,await this.hub.disconnect(),this.log("已停止")}}var Mx=I3;import{readFileSync as Uk,existsSync as Gk}from"fs";import{join as v3}from"path";import{homedir as Wk}from"os";var iy=Wk(),Se=process.argv.slice(2),c0={};for(let t=0;t<Se.length;t++)if(Se[t].startsWith("--")&&t+1<Se.length)c0[Se[t].slice(2)]=Se[++t];else if(Se[t]==="-h"||Se[t]==="--help")console.log(`
|
|
93
|
+
执行完后简要汇报结果。`,s={model:this.config.model,tools:this.config.tools?.length?this.config.tools:[],maxTurns:this.config.maxTurns,permissionMode:"bypassPermissions",allowDangerouslySkipPermissions:!0,env:process.env,cwd:process.cwd(),stderr:(a)=>{if(a.trim())this.log(`[stderr] ${a.trim().slice(0,200)}`)}};if(this.config.systemPrompt)s.systemPrompt=this.config.systemPrompt;if(this.sessionId)s.resume=this.sessionId;let r="";try{for await(let a of sy({prompt:e,options:s})){if(a.type==="system"&&a.subtype==="init")this.sessionId=a.session_id;if(a.type==="result")r=a.subtype==="success"?a.result:`错误: ${a.result||a.error}`}}catch(a){r=`SDK 错误: ${a.message}`,this.log(`错误: ${a.message}`)}if(this.config.onResult)await this.config.onResult(t,r);return r}async start(){this.running=!0,this.log(`启动 | Hub: ${this.config.hub} | Model: ${this.config.model} | Runtime: ${this.config.runtime}`),await this.hub.connect(),this.log("已连接 CommHub"),this.hub.on("task",async(e)=>{let s=e.from_session||"hub";this.log(`← [${s}] ${e.content?.slice(0,60)}`),await this.hub.status("working",{task:e.content?.slice(0,50)});let r=await this.processTask(e);this.log(`→ [${s}] ${r?.slice(0,60)}`),await this.hub.send(s,`[${this.config.alias}] ${r?.slice(0,2000)}`),await this.hub.status("idle")});let t=async()=>{this.log("退出..."),this.running=!1,await this.hub.disconnect(),process.exit(0)};process.on("SIGINT",t),process.on("SIGTERM",t),await new Promise(()=>{})}async stop(){this.running=!1,await this.hub.disconnect(),this.log("已停止")}}var Mx=I3;import{readFileSync as Uk,existsSync as Gk}from"fs";import{join as v3}from"path";import{homedir as Wk}from"os";var iy=Wk(),Se=process.argv.slice(2),c0={};for(let t=0;t<Se.length;t++)if(Se[t].startsWith("--")&&t+1<Se.length)c0[Se[t].slice(2)]=Se[++t];else if(Se[t]==="-h"||Se[t]==="--help")console.log(`
|
|
94
94
|
@sleep2agi/agent-node — AI Agent 节点,一行命令加入 CommHub 网络
|
|
95
95
|
|
|
96
96
|
用法:
|
package/dist/index.js
CHANGED
|
@@ -89,4 +89,4 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
89
89
|
|
|
90
90
|
${t.content}
|
|
91
91
|
|
|
92
|
-
执行完后简要汇报结果。`,s={model:this.config.model,tools:this.config.tools?.length?this.config.tools:[],maxTurns:this.config.maxTurns,permissionMode:"bypassPermissions",allowDangerouslySkipPermissions:!0};if(this.config.systemPrompt)s.systemPrompt=this.config.systemPrompt;if(this.sessionId)s.resume=this.sessionId;let i="";try{for await(let a of Ql({prompt:e,options:s})){if(a.type==="system"&&a.subtype==="init")this.sessionId=a.session_id;if(a.type==="result")i=a.subtype==="success"?a.result:`错误: ${a.result||a.error}`}}catch(a){i=`SDK 错误: ${a.message}`,this.log(`错误: ${a.message}`)}if(this.config.onResult)await this.config.onResult(t,i);return i}async start(){this.running=!0,this.log(`启动 | Hub: ${this.config.hub} | Model: ${this.config.model} | Runtime: ${this.config.runtime}`),await this.hub.connect(),this.log("已连接 CommHub"),this.hub.on("task",async(e)=>{let s=e.from_session||"hub";this.log(`← [${s}] ${e.content?.slice(0,60)}`),await this.hub.status("working",{task:e.content?.slice(0,50)});let i=await this.processTask(e);this.log(`→ [${s}] ${i?.slice(0,60)}`),await this.hub.send(s,`[${this.config.alias}] ${i?.slice(0,2000)}`),await this.hub.status("idle")});let t=async()=>{this.log("退出..."),this.running=!1,await this.hub.disconnect(),process.exit(0)};process.on("SIGINT",t),process.on("SIGTERM",t),await new Promise(()=>{})}async stop(){this.running=!1,await this.hub.disconnect(),this.log("已停止")}}var ug=Yl;export{ug as default,Yl as AgentNode};
|
|
92
|
+
执行完后简要汇报结果。`,s={model:this.config.model,tools:this.config.tools?.length?this.config.tools:[],maxTurns:this.config.maxTurns,permissionMode:"bypassPermissions",allowDangerouslySkipPermissions:!0,env:process.env,cwd:process.cwd(),stderr:(a)=>{if(a.trim())this.log(`[stderr] ${a.trim().slice(0,200)}`)}};if(this.config.systemPrompt)s.systemPrompt=this.config.systemPrompt;if(this.sessionId)s.resume=this.sessionId;let i="";try{for await(let a of Ql({prompt:e,options:s})){if(a.type==="system"&&a.subtype==="init")this.sessionId=a.session_id;if(a.type==="result")i=a.subtype==="success"?a.result:`错误: ${a.result||a.error}`}}catch(a){i=`SDK 错误: ${a.message}`,this.log(`错误: ${a.message}`)}if(this.config.onResult)await this.config.onResult(t,i);return i}async start(){this.running=!0,this.log(`启动 | Hub: ${this.config.hub} | Model: ${this.config.model} | Runtime: ${this.config.runtime}`),await this.hub.connect(),this.log("已连接 CommHub"),this.hub.on("task",async(e)=>{let s=e.from_session||"hub";this.log(`← [${s}] ${e.content?.slice(0,60)}`),await this.hub.status("working",{task:e.content?.slice(0,50)});let i=await this.processTask(e);this.log(`→ [${s}] ${i?.slice(0,60)}`),await this.hub.send(s,`[${this.config.alias}] ${i?.slice(0,2000)}`),await this.hub.status("idle")});let t=async()=>{this.log("退出..."),this.running=!1,await this.hub.disconnect(),process.exit(0)};process.on("SIGINT",t),process.on("SIGTERM",t),await new Promise(()=>{})}async stop(){this.running=!1,await this.hub.disconnect(),this.log("已停止")}}var ug=Yl;export{ug as default,Yl as AgentNode};
|