@shuttle-ai/client 0.0.6 → 0.0.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/dist/cjs/agent.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/es/agent.mjs +1 -1
- package/dist/es/index.mjs +3 -3
- package/dist/types/type.d.ts +1 -0
- package/package.json +2 -2
package/dist/cjs/agent.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class n{constructor(s){this.options=s,this._messages=[...s.history||[]],this._status=s.status||"idle"}_children=[];_messages=[];_status="idle";listener={status:[],messages:[],aiMessage:[],toolMessage:[],subAgents:[]};addChild(s,t){this._children.push(s),this.trigger("subAgents",void 0);const e=this.findAiMessageById(t);e&&(e.subAgents=[...e.subAgents||[],{id:s.options.id,name:s.options.name}],this.trigger("aiMessage",e))}run(){this._status="running",this.trigger("status",this._status)}end(){this._status="idle",this.trigger("status",this._status)}addChunk(s){const t=this._messages[this._messages.length-1];t.role==="assistant"&&t.id===s.id?(t.content+=s.content,this.trigger("aiMessage",t)):(this._messages.push({role:"assistant",content:s.content,id:s.id,agentId:this.options.id,workId:this.options.work.id}),this.trigger("messages",this._messages))}addMessage(s){this._messages.push(s),this.trigger("messages",this._messages)}revokeMessages(s){this._messages=s,this._status="idle",this.trigger("messages",this._messages),this.trigger("status",this._status)}addToolCall(s){const t=this.findAiMessageById(s.id);t&&(t.toolCalls=[...t.toolCalls||[],s.toolCall],this._messages.push({role:"tool",name:s.toolCall.name,id:s.toolCall.id,aiMessageId:s.id,agentId:this.options.id,workId:this.options.work.id,confirm:s.needConfirm?void 0:{type:"confirm"}}),this.trigger("aiMessage",t),this.trigger("messages",this._messages),s.needConfirm&&this.checkAutoRun(s.toolCall.name)&&this.confirmTool(s.toolCall.id,{type:"confirm"}))}endTool(s){const t=this.findToolMessageById(s.toolPath.toolId);t&&(t.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class n{constructor(s){this.options=s,this._messages=[...s.history||[]],this._status=s.status||"idle"}_children=[];_messages=[];_status="idle";listener={status:[],messages:[],aiMessage:[],toolMessage:[],subAgents:[]};addChild(s,t){this._children.push(s),this.trigger("subAgents",void 0);const e=this.findAiMessageById(t);e&&(e.subAgents=[...e.subAgents||[],{id:s.options.id,name:s.options.name}],this.trigger("aiMessage",e))}run(){this._status="running",this.trigger("status",this._status)}end(){this._status="idle",this.trigger("status",this._status)}addChunk(s){const t=this._messages[this._messages.length-1];t.role==="assistant"&&t.id===s.id?(t.content+=s.content,this.trigger("aiMessage",t)):(this._messages.push({role:"assistant",content:s.content,id:s.id,agentId:this.options.id,workId:this.options.work.id}),this.trigger("messages",this._messages))}addMessage(s){this._messages.push(s),this.trigger("messages",this._messages)}revokeMessages(s){this._messages=s,this._status="idle",this.trigger("messages",this._messages),this.trigger("status",this._status)}addToolCall(s){const t=this.findAiMessageById(s.id);t&&(t.toolCalls=[...t.toolCalls||[],s.toolCall],this._messages.push({role:"tool",name:s.toolCall.name,id:s.toolCall.id,aiMessageId:s.id,agentId:this.options.id,workId:this.options.work.id,confirm:s.needConfirm?void 0:{type:"confirm"}}),this.trigger("aiMessage",t),this.trigger("messages",this._messages),s.needConfirm&&this.checkAutoRun(s.toolCall.name)&&this.confirmTool(s.toolCall.id,{type:"confirm"}))}endTool(s){const t=this.findToolMessageById(s.toolPath.toolId);t&&(t.result=s.toolResult,this.trigger("toolMessage",t))}async confirmTool(s,t){const e=this.findToolMessageById(s);if(!e)return;const i=this.findAiMessageById(e.aiMessageId);if(i){if(t.type!=="reject"){const o=this.options.tools?.find(r=>r.name===e.name);if(o?.run.type==="fn"){const r=i.toolCalls?.find(a=>a.id===e.id);t.result=await this.runTool(o.run.fn,r),t.type="confirmWithResult"}}await this.options.work.options.transporter.report({type:"toolConfirm",workId:this.options.work.id,data:{toolId:s,result:t}}),e.confirm=t,this.trigger("toolMessage",e)}}findToolMessageById(s){let t;for(let e=this._messages.length-1;e>=0;e--){const i=this._messages[e];if(i.role==="tool"&&i.id===s){t=i;break}}return t}findAiMessageById(s){let t;for(let e=this._messages.length-1;e>=0;e--){const i=this._messages[e];if(i.role==="assistant"&&i.id===s){t=i;break}}return t}revoke(){return this.options.work.revokeAgent(this.options.id,this.options.name)}checkAutoRun(s){const t=this.options.tools?.find(e=>e.name===s);return t?t.extras?.onlyShow||t.extras?.scope==="autoRun"||this.options.work.autoRunScope==="always"?!0:this.options.work.autoRunScope==="read"?t.extras?.scope==="read":!1:!1}async runTool(s,t){if(!t)return{status:"error",message:"toolCall is required"};try{return await s(t.args||{})}catch(e){return{status:"error",message:e.message}}}trigger(s,t){this.listener[s].forEach(e=>e(t))}on(s,t){return this.listener[s].push(t),()=>{this.listener[s]=this.listener[s].filter(e=>e!==t)}}get children(){return this._children}get messages(){return this._messages}get status(){return this._status}}exports.default=n;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./transporter/http/index.cjs"),t=require("@shuttle-ai/type"),o=require("./work.cjs"),n=require("./agent.cjs");exports.HttpTransporter=r.default;exports.AgentWork=o.default;exports.Agent=n.default;Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
|
package/dist/es/agent.mjs
CHANGED
|
@@ -61,7 +61,7 @@ class g {
|
|
|
61
61
|
}
|
|
62
62
|
endTool(s) {
|
|
63
63
|
const t = this.findToolMessageById(s.toolPath.toolId);
|
|
64
|
-
t && (t.
|
|
64
|
+
t && (t.result = s.toolResult, this.trigger("toolMessage", t));
|
|
65
65
|
}
|
|
66
66
|
async confirmTool(s, t) {
|
|
67
67
|
const e = this.findToolMessageById(s);
|
package/dist/es/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
|
|
1
|
+
import { default as e } from "./transporter/http/index.mjs";
|
|
2
|
+
export * from "@shuttle-ai/type";
|
|
3
3
|
import { default as f } from "./work.mjs";
|
|
4
4
|
import { default as m } from "./agent.mjs";
|
|
5
5
|
export {
|
|
6
6
|
m as Agent,
|
|
7
7
|
f as AgentWork,
|
|
8
|
-
|
|
8
|
+
e as HttpTransporter
|
|
9
9
|
};
|
package/dist/types/type.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuttle-ai/client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"author": "Mingbing-get <1508850533@qq.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Shuttle AI 客户端操作库",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"zod": "^4.3.5",
|
|
24
24
|
"axios": "^1.13.2",
|
|
25
|
-
"@shuttle-ai/type": "0.0.
|
|
25
|
+
"@shuttle-ai/type": "0.0.7"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"typescript": "^5.3.3"
|