agentbnb 5.1.11 → 7.0.0-beta.1
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 +245 -39
- package/dist/{card-RSGDCHCV.js → card-REW7BSWW.js} +1 -1
- package/dist/{chunk-FLY3WIQR.js → chunk-2HSUPCBT.js} +3 -3
- package/dist/{chunk-WGZ5AGOX.js → chunk-3CIMVISQ.js} +24 -1
- package/dist/{chunk-NH2FIERR.js → chunk-574W3HHE.js} +1 -1
- package/dist/{chunk-WTXRY7R2.js → chunk-APEG4QIN.js} +157 -9
- package/dist/chunk-BP3L2TET.js +148 -0
- package/dist/{chunk-NLAWT4DT.js → chunk-CWYPTQRQ.js} +7 -7
- package/dist/{chunk-UKT6H7YT.js → chunk-DUW6RX6I.js} +5 -2
- package/dist/chunk-EAD4A4KG.js +430 -0
- package/dist/{chunk-QT7TEVNV.js → chunk-EHSHB7TY.js} +23 -1
- package/dist/{chunk-B5FTAGFN.js → chunk-ETGOKDFR.js} +75 -75
- package/dist/{chunk-5KFI5X7B.js → chunk-F53QQIM2.js} +1 -1
- package/dist/{chunk-MLS6IGGG.js → chunk-FK2MDNTB.js} +117 -117
- package/dist/{chunk-EGUOAHCW.js → chunk-GO4FVRVN.js} +15 -13
- package/dist/{chunk-CRFCWD6V.js → chunk-J2K5S5MX.js} +136 -173
- package/dist/chunk-K5FO42YF.js +1136 -0
- package/dist/{chunk-DFBX3BBD.js → chunk-KA2VIEGM.js} +211 -16
- package/dist/chunk-NWIQJ2CL.js +108 -0
- package/dist/chunk-OCSU2S6W.js +168 -0
- package/dist/{chunk-QQFBFV4V.js → chunk-PGDBUUGR.js} +60 -19
- package/dist/{chunk-QITOPASZ.js → chunk-PSQHUZ7X.js} +1 -1
- package/dist/{chunk-C6KPAFCC.js → chunk-PU7LXOQ3.js} +23 -1
- package/dist/{chunk-JOY533UH.js → chunk-TW65F5EU.js} +1 -1
- package/dist/{chunk-ZX5623ER.js → chunk-VMH2YS2I.js} +1 -1
- package/dist/{chunk-XND2DWTZ.js → chunk-VPQ44XKE.js} +2 -2
- package/dist/{chunk-CSATDXZC.js → chunk-Y7T6IMM3.js} +1 -1
- package/dist/cli/index.js +755 -379
- package/dist/{client-T5MTY3CS.js → client-HRYRJKSA.js} +3 -3
- package/dist/{conduct-WU3VEXB6.js → conduct-JNYJCDHQ.js} +14 -13
- package/dist/conduct-KJUD2RTB.js +22 -0
- package/dist/{conductor-mode-ZMTFZGJP.js → conductor-mode-2VVFMKVE.js} +313 -14
- package/dist/conductor-mode-VGUU54QI.js +276 -0
- package/dist/execute-I4PKSNJM.js +12 -0
- package/dist/execute-MOXSSA3Q.js +15 -0
- package/dist/index.d.ts +795 -2
- package/dist/index.js +861 -111
- package/dist/{process-guard-CC7CNRQJ.js → process-guard-QCCBGILS.js} +1 -1
- package/dist/publish-capability-TS6CNR5G.js +12 -0
- package/dist/reliability-metrics-QG7WC5QK.js +18 -0
- package/dist/{request-VOXBFUOG.js → request-E7TA7COA.js} +19 -18
- package/dist/{serve-skill-IH7UAJNR.js → serve-skill-HIOWYKRU.js} +13 -11
- package/dist/{server-JVQW2TID.js → server-I63CXFX3.js} +17 -16
- package/dist/{service-coordinator-EYRDTHL5.js → service-coordinator-XBNT3SMU.js} +369 -260
- package/dist/skill-config-FETXPNVP.js +22 -0
- package/dist/skills/agentbnb/bootstrap.js +430 -84
- package/dist/websocket-client-5MH6QRJK.js +7 -0
- package/dist/{websocket-client-WRN3HO73.js → websocket-client-PFGVTXNE.js} +1 -1
- package/openclaw.plugin.json +2 -2
- package/package.json +2 -1
- package/skills/agentbnb/SKILL.md +35 -0
- package/skills/agentbnb/bootstrap.ts +126 -8
- package/skills/agentbnb/install.sh +49 -9
- package/dist/chunk-EANI2N2V.js +0 -309
- package/dist/chunk-EPIWHNB2.js +0 -946
- package/dist/conduct-6LKIJJKQ.js +0 -21
- package/dist/conductor-mode-Q4IIDY5E.js +0 -123
- package/dist/execute-4D4ITQCL.js +0 -10
- package/dist/execute-T7Y6RKSW.js +0 -13
- package/dist/websocket-client-6IIDGXKB.js +0 -7
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BudgetController,
|
|
3
|
+
decompose,
|
|
4
|
+
matchSubTasks,
|
|
5
|
+
orchestrate,
|
|
6
|
+
validateAndNormalizeSubtasks
|
|
7
|
+
} from "./chunk-APEG4QIN.js";
|
|
8
|
+
import "./chunk-3MJT4PZG.js";
|
|
9
|
+
import {
|
|
10
|
+
BudgetManager
|
|
11
|
+
} from "./chunk-GO4FVRVN.js";
|
|
12
|
+
import "./chunk-VMH2YS2I.js";
|
|
13
|
+
import "./chunk-Y7T6IMM3.js";
|
|
14
|
+
import "./chunk-574W3HHE.js";
|
|
15
|
+
import "./chunk-J2K5S5MX.js";
|
|
16
|
+
import "./chunk-NWIQJ2CL.js";
|
|
17
|
+
import {
|
|
18
|
+
requestCapability
|
|
19
|
+
} from "./chunk-VPQ44XKE.js";
|
|
20
|
+
import "./chunk-F53QQIM2.js";
|
|
21
|
+
import "./chunk-5AH3CMOX.js";
|
|
22
|
+
import "./chunk-75OC6E4F.js";
|
|
23
|
+
import {
|
|
24
|
+
getCardsByCapabilityType,
|
|
25
|
+
getCardsBySkillCapability
|
|
26
|
+
} from "./chunk-KA2VIEGM.js";
|
|
27
|
+
import "./chunk-3CIMVISQ.js";
|
|
28
|
+
|
|
29
|
+
// src/conductor/team-formation.ts
|
|
30
|
+
import { randomUUID } from "crypto";
|
|
31
|
+
function selectByStrategy(matches, strategy) {
|
|
32
|
+
if (matches.length === 0) return void 0;
|
|
33
|
+
if (strategy === "balanced") {
|
|
34
|
+
return matches[0];
|
|
35
|
+
}
|
|
36
|
+
if (strategy === "quality_optimized") {
|
|
37
|
+
return matches.reduce((best, m) => m.score > best.score ? m : best, matches[0]);
|
|
38
|
+
}
|
|
39
|
+
return matches.reduce((best, m) => {
|
|
40
|
+
if (m.credits < best.credits) return m;
|
|
41
|
+
if (m.credits === best.credits && m.score > best.score) return m;
|
|
42
|
+
return best;
|
|
43
|
+
}, matches[0]);
|
|
44
|
+
}
|
|
45
|
+
async function formTeam(opts) {
|
|
46
|
+
const { subtasks, strategy, db, conductorOwner, registryUrl } = opts;
|
|
47
|
+
const team_id = randomUUID();
|
|
48
|
+
if (subtasks.length === 0) {
|
|
49
|
+
return { team_id, strategy, matched: [], unrouted: [] };
|
|
50
|
+
}
|
|
51
|
+
const matched = [];
|
|
52
|
+
const unrouted = [];
|
|
53
|
+
for (const subtask of subtasks) {
|
|
54
|
+
const skillCards = getCardsBySkillCapability(db, subtask.required_capability).filter((c) => c.owner !== conductorOwner);
|
|
55
|
+
if (skillCards.length > 0) {
|
|
56
|
+
const candidates = skillCards.map((card) => {
|
|
57
|
+
const skills = card.skills ?? [];
|
|
58
|
+
const matchingSkill = skills.find(
|
|
59
|
+
(s) => s.capability_type === subtask.required_capability || (s.capability_types ?? []).includes(subtask.required_capability)
|
|
60
|
+
);
|
|
61
|
+
return {
|
|
62
|
+
subtask_id: subtask.id,
|
|
63
|
+
selected_agent: card.owner,
|
|
64
|
+
selected_skill: matchingSkill?.id ?? "",
|
|
65
|
+
selected_card_id: card.id,
|
|
66
|
+
score: 1,
|
|
67
|
+
credits: matchingSkill?.pricing.credits_per_call ?? 0,
|
|
68
|
+
alternatives: []
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
const selected2 = selectByStrategy(candidates, strategy);
|
|
72
|
+
matched.push({
|
|
73
|
+
subtask,
|
|
74
|
+
capability_type: subtask.required_capability,
|
|
75
|
+
agent: selected2.selected_agent,
|
|
76
|
+
skill: selected2.selected_skill,
|
|
77
|
+
card_id: selected2.selected_card_id,
|
|
78
|
+
credits: selected2.credits,
|
|
79
|
+
score: selected2.score
|
|
80
|
+
});
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const matchResults = await matchSubTasks({
|
|
84
|
+
db,
|
|
85
|
+
subtasks: [subtask],
|
|
86
|
+
conductorOwner,
|
|
87
|
+
registryUrl
|
|
88
|
+
});
|
|
89
|
+
const m = matchResults[0];
|
|
90
|
+
if (!m || m.selected_agent === "") {
|
|
91
|
+
unrouted.push(subtask);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const allCandidates = [
|
|
95
|
+
m,
|
|
96
|
+
...m.alternatives.map((alt) => ({
|
|
97
|
+
subtask_id: m.subtask_id,
|
|
98
|
+
selected_agent: alt.agent,
|
|
99
|
+
selected_skill: alt.skill,
|
|
100
|
+
score: alt.score,
|
|
101
|
+
credits: alt.credits,
|
|
102
|
+
alternatives: []
|
|
103
|
+
}))
|
|
104
|
+
];
|
|
105
|
+
const selected = selectByStrategy(allCandidates, strategy);
|
|
106
|
+
matched.push({
|
|
107
|
+
subtask,
|
|
108
|
+
capability_type: subtask.required_capability,
|
|
109
|
+
agent: selected.selected_agent,
|
|
110
|
+
skill: selected.selected_skill,
|
|
111
|
+
card_id: selected === m ? m.selected_card_id : void 0,
|
|
112
|
+
credits: selected.credits,
|
|
113
|
+
score: selected.score
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return { team_id, strategy, matched, unrouted };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/conductor/conductor-mode.ts
|
|
120
|
+
var ConductorMode = class {
|
|
121
|
+
db;
|
|
122
|
+
creditDb;
|
|
123
|
+
conductorOwner;
|
|
124
|
+
gatewayToken;
|
|
125
|
+
resolveAgentUrl;
|
|
126
|
+
maxBudget;
|
|
127
|
+
constructor(opts) {
|
|
128
|
+
this.db = opts.db;
|
|
129
|
+
this.creditDb = opts.creditDb;
|
|
130
|
+
this.conductorOwner = opts.conductorOwner;
|
|
131
|
+
this.gatewayToken = opts.gatewayToken;
|
|
132
|
+
this.resolveAgentUrl = opts.resolveAgentUrl;
|
|
133
|
+
this.maxBudget = opts.maxBudget ?? 100;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Execute a conductor skill with the given config and params.
|
|
137
|
+
*
|
|
138
|
+
* @param config - SkillConfig with type 'conductor' and conductor_skill field.
|
|
139
|
+
* @param params - Must include `task` string.
|
|
140
|
+
* @returns Execution result without latency_ms (added by SkillExecutor).
|
|
141
|
+
*/
|
|
142
|
+
async execute(config, params, onProgress) {
|
|
143
|
+
const conductorSkill = config.conductor_skill;
|
|
144
|
+
if (conductorSkill !== "orchestrate" && conductorSkill !== "plan") {
|
|
145
|
+
return {
|
|
146
|
+
success: false,
|
|
147
|
+
error: `Unknown conductor skill: "${conductorSkill}"`
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
const task = params.task;
|
|
151
|
+
if (typeof task !== "string" || task.length === 0) {
|
|
152
|
+
return {
|
|
153
|
+
success: false,
|
|
154
|
+
error: 'Missing or empty "task" parameter'
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const orchestrationDepth = typeof params.orchestration_depth === "number" ? params.orchestration_depth : 0;
|
|
158
|
+
const decompositionDepth = typeof params.decomposition_depth === "number" ? params.decomposition_depth : 0;
|
|
159
|
+
if (orchestrationDepth >= 2) {
|
|
160
|
+
return {
|
|
161
|
+
success: false,
|
|
162
|
+
error: "orchestration_depth limit exceeded: max 1 nested orchestration"
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
let subtasks = [];
|
|
166
|
+
if (decompositionDepth === 0) {
|
|
167
|
+
const allDecomposers = getCardsByCapabilityType(this.db, "task_decomposition");
|
|
168
|
+
const externalDecomposers = allDecomposers.filter((c) => c.owner !== this.conductorOwner);
|
|
169
|
+
if (externalDecomposers.length > 0) {
|
|
170
|
+
const provider = externalDecomposers[0];
|
|
171
|
+
try {
|
|
172
|
+
const providerUrl = this.resolveAgentUrl(provider.owner);
|
|
173
|
+
const response = await requestCapability({
|
|
174
|
+
gatewayUrl: providerUrl.url,
|
|
175
|
+
token: this.gatewayToken,
|
|
176
|
+
cardId: provider.id,
|
|
177
|
+
params: {
|
|
178
|
+
task,
|
|
179
|
+
decomposition_depth: decompositionDepth + 1,
|
|
180
|
+
orchestration_depth: orchestrationDepth + 1
|
|
181
|
+
},
|
|
182
|
+
timeoutMs: 3e4
|
|
183
|
+
});
|
|
184
|
+
if (Array.isArray(response)) {
|
|
185
|
+
const validation = validateAndNormalizeSubtasks(response, {
|
|
186
|
+
max_credits: this.maxBudget
|
|
187
|
+
});
|
|
188
|
+
if (validation.errors.length === 0) {
|
|
189
|
+
subtasks = validation.valid;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
} catch {
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (subtasks.length === 0) {
|
|
197
|
+
subtasks = decompose(task);
|
|
198
|
+
}
|
|
199
|
+
if (subtasks.length === 0) {
|
|
200
|
+
return {
|
|
201
|
+
success: false,
|
|
202
|
+
error: "No template matches task"
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
onProgress?.({ step: 1, total: 5, message: `Decomposed into ${subtasks.length} sub-tasks` });
|
|
206
|
+
const matchResults = await matchSubTasks({
|
|
207
|
+
db: this.db,
|
|
208
|
+
subtasks,
|
|
209
|
+
conductorOwner: this.conductorOwner
|
|
210
|
+
});
|
|
211
|
+
onProgress?.({ step: 2, total: 5, message: `Matched ${matchResults.length} sub-tasks to agents` });
|
|
212
|
+
let team;
|
|
213
|
+
if (conductorSkill === "orchestrate") {
|
|
214
|
+
const strategy = typeof params.formation_strategy === "string" && ["cost_optimized", "quality_optimized", "balanced"].includes(params.formation_strategy) ? params.formation_strategy : "balanced";
|
|
215
|
+
team = await formTeam({
|
|
216
|
+
subtasks,
|
|
217
|
+
strategy,
|
|
218
|
+
db: this.db,
|
|
219
|
+
conductorOwner: this.conductorOwner
|
|
220
|
+
});
|
|
221
|
+
onProgress?.({ step: 2, total: 5, message: `Formed team: ${team.matched.length} members, ${team.unrouted.length} unrouted` });
|
|
222
|
+
}
|
|
223
|
+
const budgetManager = new BudgetManager(this.creditDb, this.conductorOwner);
|
|
224
|
+
const budgetController = new BudgetController(budgetManager, this.maxBudget);
|
|
225
|
+
const executionBudget = budgetController.calculateBudget(matchResults);
|
|
226
|
+
if (!budgetController.canExecute(executionBudget)) {
|
|
227
|
+
return {
|
|
228
|
+
success: false,
|
|
229
|
+
error: `Budget exceeded: estimated ${executionBudget.estimated_total} cr, max ${this.maxBudget} cr`
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
onProgress?.({ step: 3, total: 5, message: `Budget approved: ${executionBudget.estimated_total} cr` });
|
|
233
|
+
if (conductorSkill === "plan") {
|
|
234
|
+
return {
|
|
235
|
+
success: true,
|
|
236
|
+
result: {
|
|
237
|
+
subtasks,
|
|
238
|
+
matches: matchResults,
|
|
239
|
+
budget: executionBudget,
|
|
240
|
+
team
|
|
241
|
+
// undefined when no role hints
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
const matchMap = new Map(
|
|
246
|
+
matchResults.map((m) => [m.subtask_id, m])
|
|
247
|
+
);
|
|
248
|
+
const orchResult = await orchestrate({
|
|
249
|
+
subtasks,
|
|
250
|
+
matches: matchMap,
|
|
251
|
+
gatewayToken: this.gatewayToken,
|
|
252
|
+
resolveAgentUrl: this.resolveAgentUrl,
|
|
253
|
+
maxBudget: this.maxBudget,
|
|
254
|
+
team
|
|
255
|
+
});
|
|
256
|
+
onProgress?.({ step: 4, total: 5, message: "Pipeline execution complete" });
|
|
257
|
+
const resultObj = {};
|
|
258
|
+
for (const [key, value] of orchResult.results) {
|
|
259
|
+
resultObj[key] = value;
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
success: orchResult.success,
|
|
263
|
+
result: {
|
|
264
|
+
plan: subtasks,
|
|
265
|
+
execution: resultObj,
|
|
266
|
+
total_credits: orchResult.total_credits,
|
|
267
|
+
latency_ms: orchResult.latency_ms,
|
|
268
|
+
errors: orchResult.errors
|
|
269
|
+
},
|
|
270
|
+
error: orchResult.success ? void 0 : orchResult.errors?.join("; ")
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
export {
|
|
275
|
+
ConductorMode
|
|
276
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
executeCapabilityBatch,
|
|
3
|
+
executeCapabilityRequest
|
|
4
|
+
} from "./chunk-EAD4A4KG.js";
|
|
5
|
+
import "./chunk-K5FO42YF.js";
|
|
6
|
+
import "./chunk-NWIQJ2CL.js";
|
|
7
|
+
import "./chunk-IVOYM3WG.js";
|
|
8
|
+
import "./chunk-3CIMVISQ.js";
|
|
9
|
+
export {
|
|
10
|
+
executeCapabilityBatch,
|
|
11
|
+
executeCapabilityRequest
|
|
12
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
executeCapabilityBatch,
|
|
3
|
+
executeCapabilityRequest
|
|
4
|
+
} from "./chunk-PGDBUUGR.js";
|
|
5
|
+
import "./chunk-DUW6RX6I.js";
|
|
6
|
+
import "./chunk-J2K5S5MX.js";
|
|
7
|
+
import "./chunk-NWIQJ2CL.js";
|
|
8
|
+
import "./chunk-F53QQIM2.js";
|
|
9
|
+
import "./chunk-75OC6E4F.js";
|
|
10
|
+
import "./chunk-KA2VIEGM.js";
|
|
11
|
+
import "./chunk-3CIMVISQ.js";
|
|
12
|
+
export {
|
|
13
|
+
executeCapabilityBatch,
|
|
14
|
+
executeCapabilityRequest
|
|
15
|
+
};
|