agentbnb 8.4.7 → 9.0.0
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 +60 -17
- package/dist/{card-BN643ZOY.js → card-6KL6L4GF.js} +2 -2
- package/dist/{card-HYTD2BJQ.js → card-NKQFB3HD.js} +3 -3
- package/dist/{chunk-UNXCKETK.js → chunk-27VHBFUP.js} +11 -9
- package/dist/{chunk-CFHCG5FE.js → chunk-2GWOFP24.js} +1 -1
- package/dist/{chunk-PQIP7EXY.js → chunk-3466S65P.js} +6 -2
- package/dist/{chunk-SME5LJTE.js → chunk-4FK45WJI.js} +4 -4
- package/dist/chunk-5CC6O6SO.js +152 -0
- package/dist/{chunk-MZSVVG55.js → chunk-5PV5YCSN.js} +1 -1
- package/dist/{chunk-5SIGMKOD.js → chunk-77HAL2ZL.js} +14 -5
- package/dist/{chunk-EKLVNIIY.js → chunk-AZEGOADG.js} +5 -5
- package/dist/{chunk-NQANA6WH.js → chunk-BNS76U6K.js} +2 -2
- package/dist/{chunk-JDAFLPR7.js → chunk-BOBND3QV.js} +5 -5
- package/dist/{chunk-VRPLSK34.js → chunk-D4IJQ3TK.js} +1 -1
- package/dist/{chunk-4NFJ3VYZ.js → chunk-DYJ7YGBM.js} +6 -2
- package/dist/{chunk-PIPCGRCR.js → chunk-ELFGYC22.js} +1 -1
- package/dist/{chunk-WTHMHNKC.js → chunk-J4RFJVXI.js} +1 -1
- package/dist/{chunk-IMLFBU3H.js → chunk-LLL3KYEM.js} +8 -8
- package/dist/{chunk-VAAEBCMU.js → chunk-N3TXLBGK.js} +2 -2
- package/dist/{chunk-COA2D7QM.js → chunk-NLQCHO7N.js} +2 -2
- package/dist/{chunk-WK2QSO4E.js → chunk-NZTLBAML.js} +7 -141
- package/dist/{chunk-HU46M4JA.js → chunk-P3FDT7G5.js} +4 -4
- package/dist/{chunk-ZU2TP7CN.js → chunk-PG3CLSAH.js} +1 -1
- package/dist/chunk-PMVHKTFG.js +199 -0
- package/dist/{chunk-OPRCWXD5.js → chunk-SLZBE2I5.js} +198 -5
- package/dist/{chunk-AZKVGC5T.js → chunk-TLT6F35V.js} +1 -1
- package/dist/{chunk-2PP5MQPD.js → chunk-UIPGGNRC.js} +4 -4
- package/dist/{chunk-NX27AFPA.js → chunk-UR3MISL2.js} +1 -1
- package/dist/{chunk-I7KWA7OB.js → chunk-UVCNMRPS.js} +4 -0
- package/dist/{chunk-RF4A5X5U.js → chunk-W5J3PEQ6.js} +6 -4
- package/dist/{chunk-YKMBFQC2.js → chunk-W6LOCBWQ.js} +2 -2
- package/dist/{chunk-U6LP4KWN.js → chunk-YDGXKH2T.js} +1 -1
- package/dist/{chunk-GIEJVKZZ.js → chunk-YNBZLXYS.js} +1 -1
- package/dist/cli/index.js +75 -61
- package/dist/{client-UQBGCIPA.js → client-YB3IYO3S.js} +3 -3
- package/dist/conduct-4NPMP4GL.js +25 -0
- package/dist/{conduct-TE4YAXKR.js → conduct-5FTKINWU.js} +16 -16
- package/dist/{conductor-mode-2F5OP7Q4.js → conductor-mode-NRSVP2AU.js} +157 -7
- package/dist/{conductor-mode-TLIQMU4A.js → conductor-mode-ZWC5BZUL.js} +167 -15
- package/dist/did-action-MQLDT4RF.js +50 -0
- package/dist/{execute-VRTABQ6F.js → execute-DNRNU3HM.js} +5 -5
- package/dist/execute-JTPFFEH6.js +20 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +405 -32
- package/dist/{openclaw-setup-5ZWWRVF3.js → openclaw-setup-HVEVSKXQ.js} +14 -13
- package/dist/{openclaw-skills-6ZWQJ5V6.js → openclaw-skills-QLC4D6DZ.js} +12 -2
- package/dist/{process-guard-TNSUNHSR.js → process-guard-QDBIOLY4.js} +1 -1
- package/dist/{publish-capability-GNH5FHKG.js → publish-capability-FOCHYNYE.js} +4 -4
- package/dist/{reliability-metrics-G7LPUYJD.js → reliability-metrics-JSOY3PNW.js} +1 -1
- package/dist/{reliability-metrics-RRUKJ4ME.js → reliability-metrics-KKUFFVB6.js} +3 -3
- package/dist/{request-XWEOIVB3.js → request-WX3VLXBT.js} +14 -14
- package/dist/{serve-skill-UD7TLSRN.js → serve-skill-C7JU24CF.js} +14 -13
- package/dist/{server-XWTGBJHV.js → server-Z6P3AHKN.js} +15 -13
- package/dist/{service-coordinator-RN7GOLLC.js → service-coordinator-PLUPMPSC.js} +181 -27
- package/dist/skills/agentbnb/bootstrap.js +170 -20
- package/dist/{store-4Z446745.js → store-S22F3I7G.js} +3 -3
- package/dist/vc-action-SUD7TMN2.js +75 -0
- package/dist/websocket-client-5CRE36Z5.js +7 -0
- package/dist/{websocket-client-SNDF3B6N.js → websocket-client-WHEHIYIZ.js} +1 -1
- package/package.json +1 -1
- package/dist/conduct-2RD45QKB.js +0 -25
- package/dist/execute-6EJSVBFB.js +0 -19
- package/dist/websocket-client-3U27WJUU.js +0 -7
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
conductAction
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-AZEGOADG.js";
|
|
4
|
+
import "./chunk-4FK45WJI.js";
|
|
5
5
|
import "./chunk-3MJT4PZG.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-LLL3KYEM.js";
|
|
7
|
+
import "./chunk-TLT6F35V.js";
|
|
8
|
+
import "./chunk-5PV5YCSN.js";
|
|
9
9
|
import "./chunk-G5WKW3ED.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-UIPGGNRC.js";
|
|
11
|
+
import "./chunk-ELFGYC22.js";
|
|
12
|
+
import "./chunk-P3FDT7G5.js";
|
|
13
|
+
import "./chunk-UR3MISL2.js";
|
|
14
|
+
import "./chunk-3466S65P.js";
|
|
15
|
+
import "./chunk-W6LOCBWQ.js";
|
|
16
|
+
import "./chunk-YNBZLXYS.js";
|
|
17
|
+
import "./chunk-YDGXKH2T.js";
|
|
18
18
|
import "./chunk-3YQ73ZM6.js";
|
|
19
19
|
import "./chunk-3XPBFF6H.js";
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
20
|
+
import "./chunk-NLQCHO7N.js";
|
|
21
|
+
import "./chunk-J4RFJVXI.js";
|
|
22
|
+
import "./chunk-UVCNMRPS.js";
|
|
23
23
|
|
|
24
24
|
// src/mcp/tools/conduct.ts
|
|
25
25
|
import { z } from "zod";
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BudgetController,
|
|
3
3
|
BudgetManager,
|
|
4
|
+
createUCAN,
|
|
5
|
+
decodeUCAN,
|
|
4
6
|
decompose,
|
|
5
7
|
matchSubTasks,
|
|
6
8
|
orchestrate,
|
|
7
9
|
validateAndNormalizeSubtasks
|
|
8
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-SLZBE2I5.js";
|
|
9
11
|
import {
|
|
10
12
|
requestCapability
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-W6LOCBWQ.js";
|
|
14
|
+
import "./chunk-DYJ7YGBM.js";
|
|
13
15
|
import "./chunk-HLUEOLSZ.js";
|
|
14
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-BNS76U6K.js";
|
|
15
17
|
import "./chunk-6QMDJVMS.js";
|
|
16
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-YNBZLXYS.js";
|
|
17
19
|
import "./chunk-IVOYM3WG.js";
|
|
18
20
|
import {
|
|
19
21
|
getCardsByCapabilityType,
|
|
20
22
|
getCardsBySkillCapability
|
|
21
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-PG3CLSAH.js";
|
|
22
24
|
import "./chunk-EE3V3DXK.js";
|
|
23
|
-
import
|
|
25
|
+
import {
|
|
26
|
+
AgentBnBError
|
|
27
|
+
} from "./chunk-UVCNMRPS.js";
|
|
24
28
|
|
|
25
29
|
// src/conductor/team-formation.ts
|
|
26
30
|
import { randomUUID } from "crypto";
|
|
@@ -112,6 +116,133 @@ async function formTeam(opts) {
|
|
|
112
116
|
return { team_id, strategy, matched, unrouted };
|
|
113
117
|
}
|
|
114
118
|
|
|
119
|
+
// src/auth/ucan-resources.ts
|
|
120
|
+
var SCHEME = "agentbnb";
|
|
121
|
+
var URI_PREFIX = `${SCHEME}://`;
|
|
122
|
+
function parseResource(uri) {
|
|
123
|
+
if (!uri.startsWith(URI_PREFIX)) {
|
|
124
|
+
throw new AgentBnBError(
|
|
125
|
+
`Invalid resource URI: must start with "${URI_PREFIX}", got "${uri}"`,
|
|
126
|
+
"INVALID_RESOURCE_URI"
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
const body = uri.slice(URI_PREFIX.length);
|
|
130
|
+
if (body.length === 0) {
|
|
131
|
+
throw new AgentBnBError(
|
|
132
|
+
`Invalid resource URI: missing resource type in "${uri}"`,
|
|
133
|
+
"INVALID_RESOURCE_URI"
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
const slashIdx = body.indexOf("/");
|
|
137
|
+
if (slashIdx === -1) {
|
|
138
|
+
return { scheme: SCHEME, resourceType: body, path: "" };
|
|
139
|
+
}
|
|
140
|
+
const resourceType = body.slice(0, slashIdx);
|
|
141
|
+
if (resourceType.length === 0) {
|
|
142
|
+
throw new AgentBnBError(
|
|
143
|
+
`Invalid resource URI: empty resource type in "${uri}"`,
|
|
144
|
+
"INVALID_RESOURCE_URI"
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
const path = body.slice(slashIdx + 1);
|
|
148
|
+
return { scheme: SCHEME, resourceType, path };
|
|
149
|
+
}
|
|
150
|
+
function splitPath(path) {
|
|
151
|
+
if (path === "") return [];
|
|
152
|
+
return path.split("/").filter((s) => s.length > 0);
|
|
153
|
+
}
|
|
154
|
+
function isAttenuation(original, narrowed) {
|
|
155
|
+
const orig = parseResource(original);
|
|
156
|
+
const narr = parseResource(narrowed);
|
|
157
|
+
if (orig.resourceType !== narr.resourceType) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
const origSegs = splitPath(orig.path);
|
|
161
|
+
const narrSegs = splitPath(narr.path);
|
|
162
|
+
return isSubPattern(origSegs, 0, narrSegs, 0);
|
|
163
|
+
}
|
|
164
|
+
function isSubPattern(broad, bi, narrow, ni) {
|
|
165
|
+
if (bi === broad.length && ni === narrow.length) {
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
if (bi < broad.length && broad[bi] === "**") {
|
|
169
|
+
if (isSubPattern(broad, bi + 1, narrow, ni)) {
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
if (ni < narrow.length) {
|
|
173
|
+
return isSubPattern(broad, bi, narrow, ni + 1);
|
|
174
|
+
}
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
if (bi === broad.length) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
if (ni === narrow.length) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
const bSeg = broad[bi];
|
|
184
|
+
const nSeg = narrow[ni];
|
|
185
|
+
if (bSeg === "*") {
|
|
186
|
+
if (nSeg === "**") {
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
return isSubPattern(broad, bi + 1, narrow, ni + 1);
|
|
190
|
+
}
|
|
191
|
+
if (nSeg === "**") {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
if (nSeg === "*") {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
if (bSeg === nSeg) {
|
|
198
|
+
return isSubPattern(broad, bi + 1, narrow, ni + 1);
|
|
199
|
+
}
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// src/auth/ucan-delegation.ts
|
|
204
|
+
var ACTION_HIERARCHY = {
|
|
205
|
+
delegate: 4,
|
|
206
|
+
write: 3,
|
|
207
|
+
settle: 2,
|
|
208
|
+
invoke: 1,
|
|
209
|
+
read: 0
|
|
210
|
+
};
|
|
211
|
+
function isNarrowed(parent, child) {
|
|
212
|
+
if (!isAttenuation(parent.with, child.with)) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
const parentLevel = ACTION_HIERARCHY[parent.can];
|
|
216
|
+
const childLevel = ACTION_HIERARCHY[child.can];
|
|
217
|
+
if (parentLevel === void 0 || childLevel === void 0) {
|
|
218
|
+
return parent.can === child.can;
|
|
219
|
+
}
|
|
220
|
+
return childLevel <= parentLevel;
|
|
221
|
+
}
|
|
222
|
+
function isAttenuationSubset(parentAtts, childAtts) {
|
|
223
|
+
return childAtts.every(
|
|
224
|
+
(child) => parentAtts.some((parent) => isNarrowed(parent, child))
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
function delegateUCAN(opts) {
|
|
228
|
+
const parent = decodeUCAN(opts.parentToken);
|
|
229
|
+
if (!isAttenuationSubset(parent.payload.att, opts.narrowedAttenuations)) {
|
|
230
|
+
throw new AgentBnBError(
|
|
231
|
+
"Delegated UCAN attenuations must be a subset of the parent token",
|
|
232
|
+
"UCAN_DELEGATION_ERROR"
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
const expiry = opts.expiresAt !== void 0 ? Math.min(opts.expiresAt, parent.payload.exp) : parent.payload.exp;
|
|
236
|
+
return createUCAN({
|
|
237
|
+
issuerDid: parent.payload.aud,
|
|
238
|
+
audienceDid: opts.newAudienceDid,
|
|
239
|
+
attenuations: opts.narrowedAttenuations,
|
|
240
|
+
signerKey: opts.signerKey,
|
|
241
|
+
expiresAt: expiry,
|
|
242
|
+
proofs: [opts.parentToken]
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
115
246
|
// src/conductor/conductor-mode.ts
|
|
116
247
|
var ConductorMode = class {
|
|
117
248
|
db;
|
|
@@ -216,6 +347,25 @@ var ConductorMode = class {
|
|
|
216
347
|
conductorOwner: this.conductorOwner
|
|
217
348
|
});
|
|
218
349
|
onProgress?.({ step: 2, total: 5, message: `Formed team: ${team.matched.length} members, ${team.unrouted.length} unrouted` });
|
|
350
|
+
const conductorUCAN = typeof params.ucan_token === "string" ? params.ucan_token : void 0;
|
|
351
|
+
const conductorKey = params.conductor_private_key instanceof Buffer ? params.conductor_private_key : void 0;
|
|
352
|
+
if (conductorUCAN && conductorKey) {
|
|
353
|
+
for (const member of team.matched) {
|
|
354
|
+
try {
|
|
355
|
+
const memberAtts = [
|
|
356
|
+
{ with: `agentbnb://skill/${member.skill}`, can: "invoke" }
|
|
357
|
+
];
|
|
358
|
+
const memberUCAN = delegateUCAN({
|
|
359
|
+
parentToken: conductorUCAN,
|
|
360
|
+
newAudienceDid: `did:agentbnb:${member.agent}`,
|
|
361
|
+
narrowedAttenuations: memberAtts,
|
|
362
|
+
signerKey: conductorKey
|
|
363
|
+
});
|
|
364
|
+
member.ucan_token = memberUCAN;
|
|
365
|
+
} catch {
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
219
369
|
}
|
|
220
370
|
const budgetManager = new BudgetManager(this.creditDb, this.conductorOwner);
|
|
221
371
|
const budgetController = new BudgetController(budgetManager, this.maxBudget);
|
|
@@ -4,32 +4,38 @@ import {
|
|
|
4
4
|
matchSubTasks,
|
|
5
5
|
orchestrate,
|
|
6
6
|
validateAndNormalizeSubtasks
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-4FK45WJI.js";
|
|
8
|
+
import {
|
|
9
|
+
createUCAN,
|
|
10
|
+
decodeUCAN
|
|
11
|
+
} from "./chunk-PMVHKTFG.js";
|
|
8
12
|
import "./chunk-3MJT4PZG.js";
|
|
9
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-LLL3KYEM.js";
|
|
10
14
|
import {
|
|
11
15
|
BudgetManager
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-TLT6F35V.js";
|
|
17
|
+
import "./chunk-5PV5YCSN.js";
|
|
14
18
|
import "./chunk-G5WKW3ED.js";
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-UIPGGNRC.js";
|
|
20
|
+
import "./chunk-ELFGYC22.js";
|
|
21
|
+
import "./chunk-P3FDT7G5.js";
|
|
22
|
+
import "./chunk-UR3MISL2.js";
|
|
23
|
+
import "./chunk-3466S65P.js";
|
|
20
24
|
import {
|
|
21
25
|
requestCapability
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
26
|
+
} from "./chunk-W6LOCBWQ.js";
|
|
27
|
+
import "./chunk-YNBZLXYS.js";
|
|
28
|
+
import "./chunk-YDGXKH2T.js";
|
|
25
29
|
import "./chunk-3YQ73ZM6.js";
|
|
26
30
|
import "./chunk-3XPBFF6H.js";
|
|
27
31
|
import {
|
|
28
32
|
getCardsByCapabilityType,
|
|
29
33
|
getCardsBySkillCapability
|
|
30
|
-
} from "./chunk-
|
|
31
|
-
import "./chunk-
|
|
32
|
-
import
|
|
34
|
+
} from "./chunk-NLQCHO7N.js";
|
|
35
|
+
import "./chunk-J4RFJVXI.js";
|
|
36
|
+
import {
|
|
37
|
+
AgentBnBError
|
|
38
|
+
} from "./chunk-UVCNMRPS.js";
|
|
33
39
|
|
|
34
40
|
// src/conductor/team-formation.ts
|
|
35
41
|
import { randomUUID } from "crypto";
|
|
@@ -121,6 +127,133 @@ async function formTeam(opts) {
|
|
|
121
127
|
return { team_id, strategy, matched, unrouted };
|
|
122
128
|
}
|
|
123
129
|
|
|
130
|
+
// src/auth/ucan-resources.ts
|
|
131
|
+
var SCHEME = "agentbnb";
|
|
132
|
+
var URI_PREFIX = `${SCHEME}://`;
|
|
133
|
+
function parseResource(uri) {
|
|
134
|
+
if (!uri.startsWith(URI_PREFIX)) {
|
|
135
|
+
throw new AgentBnBError(
|
|
136
|
+
`Invalid resource URI: must start with "${URI_PREFIX}", got "${uri}"`,
|
|
137
|
+
"INVALID_RESOURCE_URI"
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
const body = uri.slice(URI_PREFIX.length);
|
|
141
|
+
if (body.length === 0) {
|
|
142
|
+
throw new AgentBnBError(
|
|
143
|
+
`Invalid resource URI: missing resource type in "${uri}"`,
|
|
144
|
+
"INVALID_RESOURCE_URI"
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
const slashIdx = body.indexOf("/");
|
|
148
|
+
if (slashIdx === -1) {
|
|
149
|
+
return { scheme: SCHEME, resourceType: body, path: "" };
|
|
150
|
+
}
|
|
151
|
+
const resourceType = body.slice(0, slashIdx);
|
|
152
|
+
if (resourceType.length === 0) {
|
|
153
|
+
throw new AgentBnBError(
|
|
154
|
+
`Invalid resource URI: empty resource type in "${uri}"`,
|
|
155
|
+
"INVALID_RESOURCE_URI"
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
const path = body.slice(slashIdx + 1);
|
|
159
|
+
return { scheme: SCHEME, resourceType, path };
|
|
160
|
+
}
|
|
161
|
+
function splitPath(path) {
|
|
162
|
+
if (path === "") return [];
|
|
163
|
+
return path.split("/").filter((s) => s.length > 0);
|
|
164
|
+
}
|
|
165
|
+
function isAttenuation(original, narrowed) {
|
|
166
|
+
const orig = parseResource(original);
|
|
167
|
+
const narr = parseResource(narrowed);
|
|
168
|
+
if (orig.resourceType !== narr.resourceType) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
const origSegs = splitPath(orig.path);
|
|
172
|
+
const narrSegs = splitPath(narr.path);
|
|
173
|
+
return isSubPattern(origSegs, 0, narrSegs, 0);
|
|
174
|
+
}
|
|
175
|
+
function isSubPattern(broad, bi, narrow, ni) {
|
|
176
|
+
if (bi === broad.length && ni === narrow.length) {
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
if (bi < broad.length && broad[bi] === "**") {
|
|
180
|
+
if (isSubPattern(broad, bi + 1, narrow, ni)) {
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
if (ni < narrow.length) {
|
|
184
|
+
return isSubPattern(broad, bi, narrow, ni + 1);
|
|
185
|
+
}
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
if (bi === broad.length) {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
if (ni === narrow.length) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
const bSeg = broad[bi];
|
|
195
|
+
const nSeg = narrow[ni];
|
|
196
|
+
if (bSeg === "*") {
|
|
197
|
+
if (nSeg === "**") {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
return isSubPattern(broad, bi + 1, narrow, ni + 1);
|
|
201
|
+
}
|
|
202
|
+
if (nSeg === "**") {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
if (nSeg === "*") {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
if (bSeg === nSeg) {
|
|
209
|
+
return isSubPattern(broad, bi + 1, narrow, ni + 1);
|
|
210
|
+
}
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// src/auth/ucan-delegation.ts
|
|
215
|
+
var ACTION_HIERARCHY = {
|
|
216
|
+
delegate: 4,
|
|
217
|
+
write: 3,
|
|
218
|
+
settle: 2,
|
|
219
|
+
invoke: 1,
|
|
220
|
+
read: 0
|
|
221
|
+
};
|
|
222
|
+
function isNarrowed(parent, child) {
|
|
223
|
+
if (!isAttenuation(parent.with, child.with)) {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
const parentLevel = ACTION_HIERARCHY[parent.can];
|
|
227
|
+
const childLevel = ACTION_HIERARCHY[child.can];
|
|
228
|
+
if (parentLevel === void 0 || childLevel === void 0) {
|
|
229
|
+
return parent.can === child.can;
|
|
230
|
+
}
|
|
231
|
+
return childLevel <= parentLevel;
|
|
232
|
+
}
|
|
233
|
+
function isAttenuationSubset(parentAtts, childAtts) {
|
|
234
|
+
return childAtts.every(
|
|
235
|
+
(child) => parentAtts.some((parent) => isNarrowed(parent, child))
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
function delegateUCAN(opts) {
|
|
239
|
+
const parent = decodeUCAN(opts.parentToken);
|
|
240
|
+
if (!isAttenuationSubset(parent.payload.att, opts.narrowedAttenuations)) {
|
|
241
|
+
throw new AgentBnBError(
|
|
242
|
+
"Delegated UCAN attenuations must be a subset of the parent token",
|
|
243
|
+
"UCAN_DELEGATION_ERROR"
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
const expiry = opts.expiresAt !== void 0 ? Math.min(opts.expiresAt, parent.payload.exp) : parent.payload.exp;
|
|
247
|
+
return createUCAN({
|
|
248
|
+
issuerDid: parent.payload.aud,
|
|
249
|
+
audienceDid: opts.newAudienceDid,
|
|
250
|
+
attenuations: opts.narrowedAttenuations,
|
|
251
|
+
signerKey: opts.signerKey,
|
|
252
|
+
expiresAt: expiry,
|
|
253
|
+
proofs: [opts.parentToken]
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
|
|
124
257
|
// src/conductor/conductor-mode.ts
|
|
125
258
|
var ConductorMode = class {
|
|
126
259
|
db;
|
|
@@ -225,6 +358,25 @@ var ConductorMode = class {
|
|
|
225
358
|
conductorOwner: this.conductorOwner
|
|
226
359
|
});
|
|
227
360
|
onProgress?.({ step: 2, total: 5, message: `Formed team: ${team.matched.length} members, ${team.unrouted.length} unrouted` });
|
|
361
|
+
const conductorUCAN = typeof params.ucan_token === "string" ? params.ucan_token : void 0;
|
|
362
|
+
const conductorKey = params.conductor_private_key instanceof Buffer ? params.conductor_private_key : void 0;
|
|
363
|
+
if (conductorUCAN && conductorKey) {
|
|
364
|
+
for (const member of team.matched) {
|
|
365
|
+
try {
|
|
366
|
+
const memberAtts = [
|
|
367
|
+
{ with: `agentbnb://skill/${member.skill}`, can: "invoke" }
|
|
368
|
+
];
|
|
369
|
+
const memberUCAN = delegateUCAN({
|
|
370
|
+
parentToken: conductorUCAN,
|
|
371
|
+
newAudienceDid: `did:agentbnb:${member.agent}`,
|
|
372
|
+
narrowedAttenuations: memberAtts,
|
|
373
|
+
signerKey: conductorKey
|
|
374
|
+
});
|
|
375
|
+
member.ucan_token = memberUCAN;
|
|
376
|
+
} catch {
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
228
380
|
}
|
|
229
381
|
const budgetManager = new BudgetManager(this.creditDb, this.conductorOwner);
|
|
230
382
|
const budgetController = new BudgetController(budgetManager, this.maxBudget);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadIdentity
|
|
3
|
+
} from "./chunk-5CC6O6SO.js";
|
|
4
|
+
import "./chunk-YNBZLXYS.js";
|
|
5
|
+
import {
|
|
6
|
+
getConfigDir
|
|
7
|
+
} from "./chunk-3XPBFF6H.js";
|
|
8
|
+
import "./chunk-UVCNMRPS.js";
|
|
9
|
+
|
|
10
|
+
// src/cli/did-action.ts
|
|
11
|
+
async function didShow() {
|
|
12
|
+
const configDir = getConfigDir();
|
|
13
|
+
const identity = loadIdentity(configDir);
|
|
14
|
+
if (!identity) {
|
|
15
|
+
console.error("Error: no identity found. Run `agentbnb init` first.");
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
const didAgentBnB = identity.did ?? `did:agentbnb:${identity.agent_id}`;
|
|
19
|
+
console.log("Agent Identity (DID)");
|
|
20
|
+
console.log("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
21
|
+
console.log(` agent_id: ${identity.agent_id}`);
|
|
22
|
+
console.log(` did:agentbnb: ${didAgentBnB}`);
|
|
23
|
+
console.log(` owner: ${identity.owner}`);
|
|
24
|
+
console.log(` public_key: ${identity.public_key.slice(0, 32)}...`);
|
|
25
|
+
console.log(` created_at: ${identity.created_at}`);
|
|
26
|
+
if (identity.guarantor) {
|
|
27
|
+
console.log(` guarantor: ${identity.guarantor.github_login}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function didShowJson() {
|
|
31
|
+
const configDir = getConfigDir();
|
|
32
|
+
const identity = loadIdentity(configDir);
|
|
33
|
+
if (!identity) {
|
|
34
|
+
console.error("Error: no identity found. Run `agentbnb init` first.");
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
const output = {
|
|
38
|
+
agent_id: identity.agent_id,
|
|
39
|
+
did: identity.did ?? `did:agentbnb:${identity.agent_id}`,
|
|
40
|
+
owner: identity.owner,
|
|
41
|
+
public_key: identity.public_key,
|
|
42
|
+
created_at: identity.created_at,
|
|
43
|
+
guarantor: identity.guarantor ?? null
|
|
44
|
+
};
|
|
45
|
+
console.log(JSON.stringify(output, null, 2));
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
didShow,
|
|
49
|
+
didShowJson
|
|
50
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
executeCapabilityBatch,
|
|
3
3
|
executeCapabilityRequest
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-77HAL2ZL.js";
|
|
5
|
+
import "./chunk-BNS76U6K.js";
|
|
6
6
|
import "./chunk-6QMDJVMS.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-YNBZLXYS.js";
|
|
8
8
|
import "./chunk-IVOYM3WG.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-PG3CLSAH.js";
|
|
10
10
|
import "./chunk-EE3V3DXK.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-UVCNMRPS.js";
|
|
12
12
|
export {
|
|
13
13
|
executeCapabilityBatch,
|
|
14
14
|
executeCapabilityRequest
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
executeCapabilityBatch,
|
|
3
|
+
executeCapabilityRequest
|
|
4
|
+
} from "./chunk-BOBND3QV.js";
|
|
5
|
+
import "./chunk-W5J3PEQ6.js";
|
|
6
|
+
import "./chunk-NZTLBAML.js";
|
|
7
|
+
import "./chunk-5CC6O6SO.js";
|
|
8
|
+
import "./chunk-UIPGGNRC.js";
|
|
9
|
+
import "./chunk-ELFGYC22.js";
|
|
10
|
+
import "./chunk-P3FDT7G5.js";
|
|
11
|
+
import "./chunk-YNBZLXYS.js";
|
|
12
|
+
import "./chunk-YDGXKH2T.js";
|
|
13
|
+
import "./chunk-3XPBFF6H.js";
|
|
14
|
+
import "./chunk-NLQCHO7N.js";
|
|
15
|
+
import "./chunk-J4RFJVXI.js";
|
|
16
|
+
import "./chunk-UVCNMRPS.js";
|
|
17
|
+
export {
|
|
18
|
+
executeCapabilityBatch,
|
|
19
|
+
executeCapabilityRequest
|
|
20
|
+
};
|