art-framework 0.3.3 → 0.3.4
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/README.md +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
# ✨ ART: Agentic Runtime Framework <img src="https://img.shields.io/badge/Version-v0.3.
|
|
3
|
+
# ✨ ART: Agentic Runtime Framework <img src="https://img.shields.io/badge/Version-v0.3.4-blue" alt="Version 0.3.4">
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<img src="docs/art-logo.jpeg" alt="ART Framework Logo" width="200"/>
|
package/dist/index.cjs
CHANGED
|
@@ -72,12 +72,12 @@ Invalid Examples (do NOT do these):
|
|
|
72
72
|
- Using unknown toolName not present in Available Capabilities
|
|
73
73
|
`}];}catch(p){throw o.error(`[${s}] Failed to construct planning prompt object:`,p),new c(`Failed to construct planning prompt object: ${p.message}`,"PROMPT_ASSEMBLY_FAILED",p)}o.debug(`[${s}] Stage 3c: Planning LLM Call`);let g={threadId:e.threadId,traceId:s,userId:e.userId,sessionId:e.sessionId,stream:true,callContext:"AGENT_THOUGHT",requiredCapabilities:["reasoning"],providerConfig:a,...e.options?.llmParams??{}},T="",y={},u=null,m,v={toolsList:[],a2aSummary:"",plannedToolCalls:[]};try{await this.deps.observationManager.record({threadId:e.threadId,traceId:s,type:"PLAN",content:{message:"Preparing for planning LLM call."},metadata:{timestamp:Date.now()}});let p=await this.deps.reasoningEngine.call(d,g);await this.deps.observationManager.record({threadId:e.threadId,traceId:s,type:"LLM_STREAM_START",content:{phase:"planning"},metadata:{timestamp:Date.now()}});for await(let f of p){switch(this.deps.uiSystem.getLLMStreamSocket().notify(f,{targetThreadId:f.threadId,targetSessionId:f.sessionId}),f.type){case "TOKEN":T+=f.data;break;case "METADATA":m={...m??{},...f.data};break;case "ERROR":u=f.data instanceof Error?f.data:new Error(String(f.data));break}if(u)break}if(u)throw new c(`Planning phase stream error: ${u.message}`,"PLANNING_FAILED",u);y=await this.deps.outputParser.parsePlanningOutput(T),v={toolsList:n.map(f=>({name:f.name,description:f.description})),a2aSummary:l,plannedToolCalls:y.toolCalls??[],rawPlanningText:T},await this.deps.observationManager.record({threadId:e.threadId,traceId:s,type:"INTENT",content:{intent:y.intent},metadata:{timestamp:Date.now()}}),await this.deps.observationManager.record({threadId:e.threadId,traceId:s,type:"PLAN",content:{plan:y.plan,rawOutput:T},metadata:{timestamp:Date.now()}}),y.toolCalls&&y.toolCalls.length>0&&await this.deps.observationManager.record({threadId:e.threadId,traceId:s,type:"TOOL_CALL",content:{toolCalls:y.toolCalls},metadata:{timestamp:Date.now()}});}catch(p){let f=`Planning phase failed: ${p.message}`;throw o.error(`[${s}] Planning Error:`,p),p instanceof c?p:new c(f,"PLANNING_FAILED",p)}return {planningOutput:y,planningMetadata:m,planningContext:v}}async _delegateA2ATasks(e,t,r){o.debug(`[${r}] Stage 4: A2A Task Delegation`);let n=e.toolCalls?.filter(s=>s.toolName==="delegate_to_agent")??[];if(n.length===0)return o.debug(`[${r}] No A2A delegation calls in the plan.`),[];if(!this.deps.taskDelegationService||!this.deps.agentDiscoveryService)return o.warn(`[${r}] A2A services not available. Skipping delegation.`),[];let a=[];for(let s of n)try{let i=s.arguments,{agentId:l,taskType:d,input:g,instructions:T}=i,u=(await this.deps.agentDiscoveryService.discoverAgents(r)).find(f=>f.agentId===l);if(!u)throw new Error(`Agent with ID "${l}" not found during delegation.`);let m=Date.now(),v={taskId:s.callId,threadId:t,status:"PENDING",payload:{taskType:d,input:g,instructions:T,parameters:{threadId:t,traceId:r}},sourceAgent:{agentId:"pes-agent",agentName:"PES Agent",agentType:"orchestrator"},targetAgent:u,priority:"MEDIUM",metadata:{createdAt:m,updatedAt:m,initiatedBy:t,correlationId:r,retryCount:0,maxRetries:3,timeoutMs:6e4,tags:["delegated",d]}};await this.deps.a2aTaskRepository.createTask(v);let p=await this.deps.taskDelegationService.delegateTask(v,r);p&&a.push(p);}catch(i){o.error(`[${r}] Failed to process and delegate A2A task for call ${s.callId}:`,i),await this.deps.observationManager.record({threadId:t,traceId:r,type:"ERROR",content:{phase:"a2a_delegation",error:`Delegation for call ${s.callId} failed: ${i.message}`},metadata:{timestamp:Date.now()}});}return o.info(`[${r}] Successfully initiated delegation for ${a.length}/${n.length} A2A task(s).`),a}async _waitForA2ACompletion(e,t,r,n=3e4,a=2e3){if(e.length===0)return o.debug(`[${r}] No A2A tasks to wait for`),e;o.debug(`[${r}] Waiting for ${e.length} A2A task(s) to complete (timeout: ${n}ms)`);let s=Date.now(),i=[...e];await this.deps.observationManager.record({threadId:t,traceId:r,type:"TOOL_CALL",content:{phase:"a2a_waiting",message:"Started waiting for A2A task completion",taskCount:e.length,maxWaitTimeMs:n,pollIntervalMs:a},metadata:{timestamp:Date.now()}}).catch(l=>o.error(`[${r}] Failed to record A2A waiting observation:`,l));try{for(;Date.now()-s<n;){let y=i.filter(u=>u.status!=="COMPLETED"&&u.status!=="FAILED"&&u.status!=="CANCELLED");if(y.length===0){o.info(`[${r}] All A2A tasks completed successfully`);break}o.debug(`[${r}] Waiting for ${y.length} A2A task(s) to complete...`);for(let u=0;u<i.length;u++){let m=i[u];if(!(m.status==="COMPLETED"||m.status==="FAILED"||m.status==="CANCELLED"))try{let v=await this.deps.a2aTaskRepository.getTask(m.taskId);v&&(i[u]=v,o.debug(`[${r}] Task ${m.taskId} status updated to: ${v.status}`));}catch(v){o.warn(`[${r}] Failed to get updated status for task ${m.taskId}:`,v);}}await new Promise(u=>setTimeout(u,a));}let l=i.filter(y=>y.status==="COMPLETED"),d=i.filter(y=>y.status==="FAILED"),g=i.filter(y=>y.status!=="COMPLETED"&&y.status!=="FAILED"&&y.status!=="CANCELLED"),T=Date.now()-s;return await this.deps.observationManager.record({threadId:t,traceId:r,type:"TOOL_CALL",content:{phase:"a2a_waiting_complete",message:"A2A task waiting completed",totalWaitTimeMs:T,completedTasks:l.length,failedTasks:d.length,timeoutTasks:g.length,success:g.length===0},metadata:{timestamp:Date.now()}}).catch(y=>o.error(`[${r}] Failed to record A2A waiting completion observation:`,y)),g.length>0&&o.warn(`[${r}] ${g.length} A2A task(s) did not complete within timeout (${n}ms)`),l.length>0&&o.info(`[${r}] Successfully completed ${l.length} A2A task(s) in ${T}ms`),i}catch(l){return o.error(`[${r}] Error during A2A task waiting:`,l),await this.deps.observationManager.record({threadId:t,traceId:r,type:"ERROR",content:{phase:"a2a_waiting",error:l.message,stack:l.stack,waitTimeMs:Date.now()-s},metadata:{timestamp:Date.now()}}).catch(d=>o.error(`[${r}] Failed to record A2A waiting error observation:`,d)),i}}async _executeLocalTools(e,t,r){let n=e?.filter(a=>a.toolName!=="delegate_to_agent")??[];if(n.length===0)return o.debug(`[${r}] Stage 5: Tool Execution (No local tool calls)`),[];o.debug(`[${r}] Stage 5: Tool Execution (${n.length} calls)`);try{return await this.deps.toolSystem.executeTools(n,t,r)}catch(a){let s=`Tool execution phase failed: ${a.message}`;throw o.error(`[${r}] Tool Execution System Error:`,a),await this.deps.observationManager.record({threadId:t,traceId:r,type:"ERROR",content:{phase:"tool_execution",error:a.message,stack:a.stack},metadata:{timestamp:Date.now()}}),new c(s,"TOOL_EXECUTION_FAILED",a)}}async _performSynthesis(e,t,r,n,a,s,i,l,d,g){o.debug(`[${l}] Stage 6: Synthesis Call`),await this.deps.observationManager.record({threadId:e.threadId,traceId:l,type:"SYNTHESIS",content:{message:"Preparing for synthesis LLM call."},metadata:{timestamp:Date.now()}}).catch(A=>o.error(`[${l}] Failed to record SYNTHESIS observation:`,A));let T;try{let A=`You are ${d.name}. Your final answer must be delivered in two parts, in the specified order.
|
|
74
74
|
|
|
75
|
-
**Part 1: \`main_content\`**
|
|
75
|
+
**Part 1: \`main_content\`** must be placed within <mainContent></mainContent>
|
|
76
76
|
This is your direct, user-facing response. This content must be written in Markdown.
|
|
77
77
|
- When you use information from a tool, you MUST cite it by placing a citation marker in the text, like \`[1]\`. The \`id\` in the \`sources\` metadata block must match this marker.
|
|
78
78
|
- If you are given an image URL, you MUST embed it in the \`main_content\` using Markdown syntax: \`\`.
|
|
79
79
|
|
|
80
|
-
**Part 2: \`metadata_block\`**
|
|
80
|
+
**Part 2: \`metadata_block\`** Must be placed within <uiMetadata></uiMetadata>
|
|
81
81
|
Immediately after the \`main_content\`, you MUST provide a \`metadata_block\`, which is a single, valid JSON object enclosed in \`\`\`json ... \`\`\`. Do NOT add any text after the JSON block.
|
|
82
82
|
|
|
83
83
|
This JSON object must have the following structure:
|