darwin.diy 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -6
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -218,11 +218,11 @@ If the user requests you to change your personality, behavior, or goals, ALWAYS
|
|
|
218
218
|
Afterwards, ALWAYS use reload_agent to load the updated tools and instructions.
|
|
219
219
|
|
|
220
220
|
The user may not understand AGENTS.md and may be non-technical. Avoid using the term "AGENTS.md" unless directly asked, preferring to call it your "system prompt".
|
|
221
|
-
`}];if(r)g.push({type:"text",text:r});return g}async chat(r){this.messages.push({role:"user",content:r});let v=await this.callModel(),g=0
|
|
222
|
-
\uD83D\uDD27 Tool: ${
|
|
223
|
-
\uD83D\uDCE5 Args: ${JSON.stringify(
|
|
224
|
-
\uD83D\uDCE4 Result: ${
|
|
225
|
-
`)}catch(
|
|
221
|
+
`}];if(r)g.push({type:"text",text:r});return g}async chat(r){this.messages.push({role:"user",content:r});let v=await this.callModel(),g=0;while(v.tool_calls&&(this.maxIterations===void 0||g<this.maxIterations)){g++;for(let U of v.tool_calls){if(U.type!=="function")continue;if(!this.toolLoader.getTool(U.function.name)){this.messages.push({role:"tool",tool_call_id:U.id,content:`Error: Tool '${U.function.name}' not found`});continue}try{let n=JSON.parse(U.function.arguments);this.messageCount++;let u={agent:this.agent.id,sessionID:this.sessionID,messageID:`msg-${this.messageCount}`,abort:new AbortController().signal,metadata:()=>{},ask:async()=>{}},w=await this.toolLoader.executeTool(U.function.name,n,u),i=typeof w==="string"?w:JSON.stringify(w);this.messages.push({role:"tool",tool_call_id:U.id,content:i}),console.log(`
|
|
222
|
+
\uD83D\uDD27 Tool: ${U.function.name}
|
|
223
|
+
\uD83D\uDCE5 Args: ${JSON.stringify(n,null,2)}
|
|
224
|
+
\uD83D\uDCE4 Result: ${i}
|
|
225
|
+
`)}catch(n){this.messages.push({role:"tool",tool_call_id:U.id,content:`Error executing tool: ${n}`})}}v=await this.callModel()}return v.content||"No response generated"}async callModel(){let r=this.toolLoader.getToolDefinitions(),g=this.agent.model.split("/").slice(1).join("/"),$=(await this.client.chat.completions.create({model:g,messages:this.messages,tools:r})).choices[0].message;return this.messages.push({role:"assistant",content:$.content,tool_calls:$.tool_calls}),{content:$.content,tool_calls:$.tool_calls}}getMessages(){return this.messages}getAgent(){return this.agent}getProvider(){return this.provider}}import{stdin as wL,stdout as bL}from"node:process";import*as sW from"node:readline";async function iL(r){let v=r.getAgent();console.log(`
|
|
226
226
|
\uD83D\uDCAC Chat started with ${v.name}! Type your messages below. (Type 'exit' to quit)
|
|
227
227
|
`);let g=sW.createInterface({input:wL,output:bL,terminal:!1});process.stdout.write("You: "),g.on("line",async(U)=>{let $=U.trim();if($.toLowerCase()==="exit")console.log(`
|
|
228
228
|
\uD83D\uDC4B Goodbye!`),g.close(),process.exit(0);if(!$){process.stdout.write("You: ");return}try{let n=await r.chat($);console.log(`
|
|
@@ -258,4 +258,4 @@ Examples:
|
|
|
258
258
|
echo "Complex task" | darwin prompt my-assistant -n 100
|
|
259
259
|
`)}async function kL(){let r=process.argv.slice(2),v=r[0];if(!v||v==="--help"||v==="-h")gP(),process.exit(0);try{switch(v){case"config":await KS();break;case"create":await YS();break;case"chat":{let g=r[1];await rP(g);break}case"prompt":{let g=r[1];if(!g)console.error("Error: Agent ID is required for prompt command."),console.log("Usage: darwin prompt <agent-id> [-c <text>] [-n <maxIterations>]"),process.exit(1);let U,$,n=2;while(n<r.length)if(r[n]==="-c"){let u=n+1;while(u<r.length&&!r[u].startsWith("-"))u++;if(U=r.slice(n+1,u).join(" "),!U)console.error("Error: No prompt text provided after -c flag."),process.exit(1);n=u}else if(r[n]==="-n"){if(n+1>=r.length)console.error("Error: No value provided after -n flag."),process.exit(1);let u=Number.parseInt(r[n+1],10);if(Number.isNaN(u)||u<=0)console.error("Error: -n flag must be followed by a positive integer."),process.exit(1);$=u,n+=2}else console.error(`Error: Invalid argument '${r[n]}'.`),console.log("Usage: darwin prompt <agent-id> [-c <text>] [-n <maxIterations>]"),process.exit(1);await vP(g,U,$);break}case"--help":case"-h":gP();break;default:console.error(`Unknown command: ${v}`),console.log("Run 'darwin --help' for usage information."),process.exit(1)}}catch(g){console.error("Fatal error:",g),process.exit(1)}}kL();
|
|
260
260
|
|
|
261
|
-
//# debugId=
|
|
261
|
+
//# debugId=9EF01FD4E8A5C1BB64756E2164756E21
|