agentbnb 4.0.0 → 4.0.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/dist/{card-IE5UV5QX.js → card-4XH4AOTE.js} +11 -4
- package/dist/chunk-3MJT4PZG.js +50 -0
- package/dist/{conduct-IQYAT6ZU.js → chunk-3UKAVIMC.js} +70 -33
- package/dist/chunk-5AH3CMOX.js +62 -0
- package/dist/{chunk-UJWYE7VL.js → chunk-6K5WUVF3.js} +28 -111
- package/dist/chunk-75OC6E4F.js +33 -0
- package/dist/{chunk-QO67IGCW.js → chunk-DVAS2443.js} +1 -1
- package/dist/{chunk-XA63SD4T.js → chunk-FNKBHBYK.js} +3 -0
- package/dist/{websocket-client-5TIQDYQ4.js → chunk-JOY533UH.js} +38 -4
- package/dist/{chunk-RSX4SCPN.js → chunk-KJG2UJV5.js} +3 -3
- package/dist/chunk-M3G5NR2Z.js +90 -0
- package/dist/{chunk-HEVXCYCY.js → chunk-MQKYGY5I.js} +61 -24
- package/dist/chunk-ODBGCCEH.js +358 -0
- package/dist/{chunk-CUVIWPQO.js → chunk-Q7HRI666.js} +7 -6
- package/dist/chunk-QJEOCKVF.js +148 -0
- package/dist/{chunk-3Y36WQDV.js → chunk-QT7TEVNV.js} +14 -2
- package/dist/{chunk-UOGDK2S2.js → chunk-TLU7ALCZ.js} +1 -1
- package/dist/{chunk-QVV2P3FN.js → chunk-XQHN6ITI.js} +1 -1
- package/dist/cli/index.js +2665 -845
- package/dist/{client-IOTK6GOS.js → client-BTPIFY7E.js} +3 -3
- package/dist/conduct-CW62HBPT.js +52 -0
- package/dist/conduct-FXLVGKD5.js +19 -0
- package/dist/{conductor-mode-XU7ONJWC.js → conductor-mode-3JS4VWCR.js} +16 -9
- package/dist/execute-EXOITLHN.js +10 -0
- package/dist/index.d.ts +1005 -916
- package/dist/index.js +516 -120
- package/dist/{peers-G36URZYB.js → peers-K7FSHPN3.js} +2 -1
- package/dist/request-CNZ3XIVX.js +196 -0
- package/dist/serve-skill-SUOGUM7N.js +104 -0
- package/dist/server-2LWHL24P.js +295 -0
- package/dist/types-FGBUZ3QV.js +18 -0
- package/dist/websocket-client-6IIDGXKB.js +7 -0
- package/package.json +1 -1
- package/dist/chunk-BEI5MTNZ.js +0 -91
- package/dist/cli/index.d.ts +0 -1
- package/dist/execute-GDGBU6DJ.js +0 -10
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentBnBError
|
|
3
|
+
} from "./chunk-FNKBHBYK.js";
|
|
4
|
+
|
|
5
|
+
// src/registry/matcher.ts
|
|
6
|
+
function searchCards(db, query, filters = {}) {
|
|
7
|
+
const words = query.trim().split(/\s+/).map((w) => w.replace(/["*^{}():]/g, "")).filter((w) => w.length > 0);
|
|
8
|
+
if (words.length === 0) return [];
|
|
9
|
+
const ftsQuery = words.map((w) => `"${w}"`).join(" OR ");
|
|
10
|
+
const conditions = [];
|
|
11
|
+
const params = [ftsQuery];
|
|
12
|
+
if (filters.level !== void 0) {
|
|
13
|
+
conditions.push(`json_extract(cc.data, '$.level') = ?`);
|
|
14
|
+
params.push(filters.level);
|
|
15
|
+
}
|
|
16
|
+
if (filters.online !== void 0) {
|
|
17
|
+
conditions.push(`json_extract(cc.data, '$.availability.online') = ?`);
|
|
18
|
+
params.push(filters.online ? 1 : 0);
|
|
19
|
+
}
|
|
20
|
+
const whereClause = conditions.length > 0 ? `AND ${conditions.join(" AND ")}` : "";
|
|
21
|
+
const sql = `
|
|
22
|
+
SELECT cc.data
|
|
23
|
+
FROM capability_cards cc
|
|
24
|
+
JOIN cards_fts ON cc.rowid = cards_fts.rowid
|
|
25
|
+
WHERE cards_fts MATCH ?
|
|
26
|
+
${whereClause}
|
|
27
|
+
ORDER BY bm25(cards_fts)
|
|
28
|
+
LIMIT 50
|
|
29
|
+
`;
|
|
30
|
+
const stmt = db.prepare(sql);
|
|
31
|
+
const rows = stmt.all(...params);
|
|
32
|
+
const results = rows.map((row) => JSON.parse(row.data));
|
|
33
|
+
if (filters.apis_used && filters.apis_used.length > 0) {
|
|
34
|
+
const requiredApis = filters.apis_used;
|
|
35
|
+
return results.filter((card) => {
|
|
36
|
+
const cardApis = card.metadata?.apis_used ?? [];
|
|
37
|
+
return requiredApis.every((api) => cardApis.includes(api));
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return results;
|
|
41
|
+
}
|
|
42
|
+
function filterCards(db, filters) {
|
|
43
|
+
const conditions = [];
|
|
44
|
+
const params = [];
|
|
45
|
+
if (filters.level !== void 0) {
|
|
46
|
+
conditions.push(`json_extract(data, '$.level') = ?`);
|
|
47
|
+
params.push(filters.level);
|
|
48
|
+
}
|
|
49
|
+
if (filters.online !== void 0) {
|
|
50
|
+
conditions.push(`json_extract(data, '$.availability.online') = ?`);
|
|
51
|
+
params.push(filters.online ? 1 : 0);
|
|
52
|
+
}
|
|
53
|
+
const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
54
|
+
const sql = `SELECT data FROM capability_cards ${whereClause}`;
|
|
55
|
+
const stmt = db.prepare(sql);
|
|
56
|
+
const rows = stmt.all(...params);
|
|
57
|
+
return rows.map((row) => JSON.parse(row.data));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// src/cli/remote-registry.ts
|
|
61
|
+
var RegistryTimeoutError = class extends AgentBnBError {
|
|
62
|
+
constructor(url) {
|
|
63
|
+
super(
|
|
64
|
+
`Registry at ${url} did not respond within 5s. Showing local results only.`,
|
|
65
|
+
"REGISTRY_TIMEOUT"
|
|
66
|
+
);
|
|
67
|
+
this.name = "RegistryTimeoutError";
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
var RegistryConnectionError = class extends AgentBnBError {
|
|
71
|
+
constructor(url) {
|
|
72
|
+
super(
|
|
73
|
+
`Cannot reach ${url}. Is the registry running? Showing local results only.`,
|
|
74
|
+
"REGISTRY_CONNECTION"
|
|
75
|
+
);
|
|
76
|
+
this.name = "RegistryConnectionError";
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
var RegistryAuthError = class extends AgentBnBError {
|
|
80
|
+
constructor(url) {
|
|
81
|
+
super(
|
|
82
|
+
`Authentication failed for ${url}. Run \`agentbnb config set token <your-token>\`.`,
|
|
83
|
+
"REGISTRY_AUTH"
|
|
84
|
+
);
|
|
85
|
+
this.name = "RegistryAuthError";
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
async function fetchRemoteCards(registryUrl, params, timeoutMs = 5e3) {
|
|
89
|
+
let cardsUrl;
|
|
90
|
+
try {
|
|
91
|
+
cardsUrl = new URL("/cards", registryUrl);
|
|
92
|
+
} catch {
|
|
93
|
+
throw new AgentBnBError(`Invalid registry URL: ${registryUrl}`, "INVALID_REGISTRY_URL");
|
|
94
|
+
}
|
|
95
|
+
const searchParams = new URLSearchParams();
|
|
96
|
+
if (params.q !== void 0) searchParams.set("q", params.q);
|
|
97
|
+
if (params.level !== void 0) searchParams.set("level", String(params.level));
|
|
98
|
+
if (params.online !== void 0) searchParams.set("online", String(params.online));
|
|
99
|
+
if (params.tag !== void 0) searchParams.set("tag", params.tag);
|
|
100
|
+
searchParams.set("limit", "100");
|
|
101
|
+
cardsUrl.search = searchParams.toString();
|
|
102
|
+
const controller = new AbortController();
|
|
103
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
104
|
+
let response;
|
|
105
|
+
try {
|
|
106
|
+
response = await fetch(cardsUrl.toString(), { signal: controller.signal });
|
|
107
|
+
} catch (err) {
|
|
108
|
+
clearTimeout(timer);
|
|
109
|
+
const isTimeout = err instanceof Error && err.name === "AbortError";
|
|
110
|
+
if (isTimeout) {
|
|
111
|
+
throw new RegistryTimeoutError(registryUrl);
|
|
112
|
+
}
|
|
113
|
+
throw new RegistryConnectionError(registryUrl);
|
|
114
|
+
} finally {
|
|
115
|
+
clearTimeout(timer);
|
|
116
|
+
}
|
|
117
|
+
if (response.status === 401 || response.status === 403) {
|
|
118
|
+
throw new RegistryAuthError(registryUrl);
|
|
119
|
+
}
|
|
120
|
+
if (!response.ok) {
|
|
121
|
+
throw new RegistryConnectionError(registryUrl);
|
|
122
|
+
}
|
|
123
|
+
const body = await response.json();
|
|
124
|
+
return body.items;
|
|
125
|
+
}
|
|
126
|
+
function mergeResults(localCards, remoteCards, hasQuery) {
|
|
127
|
+
const taggedLocal = localCards.map((c) => ({ ...c, source: "local" }));
|
|
128
|
+
const taggedRemote = remoteCards.map((c) => ({ ...c, source: "remote" }));
|
|
129
|
+
const localIds = new Set(localCards.map((c) => c.id));
|
|
130
|
+
const dedupedRemote = taggedRemote.filter((c) => !localIds.has(c.id));
|
|
131
|
+
if (!hasQuery) {
|
|
132
|
+
return [...taggedLocal, ...dedupedRemote];
|
|
133
|
+
}
|
|
134
|
+
const result = [];
|
|
135
|
+
const maxLen = Math.max(taggedLocal.length, dedupedRemote.length);
|
|
136
|
+
for (let i = 0; i < maxLen; i++) {
|
|
137
|
+
if (i < taggedLocal.length) result.push(taggedLocal[i]);
|
|
138
|
+
if (i < dedupedRemote.length) result.push(dedupedRemote[i]);
|
|
139
|
+
}
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export {
|
|
144
|
+
searchCards,
|
|
145
|
+
filterCards,
|
|
146
|
+
fetchRemoteCards,
|
|
147
|
+
mergeResults
|
|
148
|
+
};
|
|
@@ -4,8 +4,10 @@ var RegisterMessageSchema = z.object({
|
|
|
4
4
|
type: z.literal("register"),
|
|
5
5
|
owner: z.string().min(1),
|
|
6
6
|
token: z.string().min(1),
|
|
7
|
-
card: z.record(z.unknown())
|
|
7
|
+
card: z.record(z.unknown()),
|
|
8
8
|
// CapabilityCard (validated separately)
|
|
9
|
+
cards: z.array(z.record(z.unknown())).optional()
|
|
10
|
+
// Additional cards (e.g., conductor card)
|
|
9
11
|
});
|
|
10
12
|
var RegisteredMessageSchema = z.object({
|
|
11
13
|
type: z.literal("registered"),
|
|
@@ -55,6 +57,15 @@ var ErrorMessageSchema = z.object({
|
|
|
55
57
|
message: z.string(),
|
|
56
58
|
request_id: z.string().optional()
|
|
57
59
|
});
|
|
60
|
+
var RelayProgressMessageSchema = z.object({
|
|
61
|
+
type: z.literal("relay_progress"),
|
|
62
|
+
id: z.string().uuid(),
|
|
63
|
+
// request ID this progress relates to
|
|
64
|
+
progress: z.number().min(0).max(100).optional(),
|
|
65
|
+
// optional percentage
|
|
66
|
+
message: z.string().optional()
|
|
67
|
+
// optional status message
|
|
68
|
+
});
|
|
58
69
|
var RelayMessageSchema = z.discriminatedUnion("type", [
|
|
59
70
|
RegisterMessageSchema,
|
|
60
71
|
RegisteredMessageSchema,
|
|
@@ -62,7 +73,8 @@ var RelayMessageSchema = z.discriminatedUnion("type", [
|
|
|
62
73
|
IncomingRequestMessageSchema,
|
|
63
74
|
RelayResponseMessageSchema,
|
|
64
75
|
ResponseMessageSchema,
|
|
65
|
-
ErrorMessageSchema
|
|
76
|
+
ErrorMessageSchema,
|
|
77
|
+
RelayProgressMessageSchema
|
|
66
78
|
]);
|
|
67
79
|
|
|
68
80
|
export {
|