agentbnb 4.0.4 → 5.1.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.
Files changed (58) hide show
  1. package/dist/chunk-AUBHR7HH.js +25 -0
  2. package/dist/chunk-B5FTAGFN.js +393 -0
  3. package/dist/{chunk-GGYC5U2Z.js → chunk-BTTL24TZ.js} +29 -91
  4. package/dist/chunk-C6KPAFCC.js +387 -0
  5. package/dist/{chunk-JXEOE7HX.js → chunk-CRFCWD6V.js} +163 -92
  6. package/dist/chunk-CSATDXZC.js +89 -0
  7. package/dist/{chunk-T7NS2J2B.js → chunk-DFBX3BBD.js} +84 -1
  8. package/dist/{chunk-DNWT5FZQ.js → chunk-EANI2N2V.js} +98 -1
  9. package/dist/{chunk-HH24WMFN.js → chunk-FLY3WIQR.js} +1 -1
  10. package/dist/{chunk-EVBX22YU.js → chunk-HLUEOLSZ.js} +11 -17
  11. package/dist/chunk-IVOYM3WG.js +25 -0
  12. package/dist/chunk-LCAIAAG2.js +916 -0
  13. package/dist/chunk-MLS6IGGG.js +294 -0
  14. package/dist/{chunk-4P3EMGL4.js → chunk-MNO4COST.js} +5 -3
  15. package/dist/chunk-NH2FIERR.js +138 -0
  16. package/dist/chunk-UKT6H7YT.js +29 -0
  17. package/dist/{chunk-BH6WGYFB.js → chunk-VE3E4AMH.js} +8 -8
  18. package/dist/{chunk-5QGXARLJ.js → chunk-W5BZMKMF.js} +159 -27
  19. package/dist/{chunk-FF226TIV.js → chunk-ZX5623ER.js} +0 -57
  20. package/dist/cli/index.js +362 -4633
  21. package/dist/{conduct-N52JX7RT.js → conduct-KM6ZNJGE.js} +10 -8
  22. package/dist/{conduct-GZQNFTRP.js → conduct-WGTMQND5.js} +10 -8
  23. package/dist/{conductor-mode-XUWGR4ZE.js → conductor-mode-OL2FNOYY.js} +6 -4
  24. package/dist/{conductor-mode-ESGFZ6T5.js → conductor-mode-VRO7TYW2.js} +20 -167
  25. package/dist/execute-CPFSOOO3.js +13 -0
  26. package/dist/execute-IP2QHALV.js +10 -0
  27. package/dist/index.d.ts +14 -8
  28. package/dist/index.js +190 -36
  29. package/dist/{peers-E4MKNNDN.js → peers-CJ7T4RJO.js} +2 -1
  30. package/dist/process-guard-CC7CNRQJ.js +176 -0
  31. package/dist/{request-4GQSSM4B.js → request-YOWPXVLQ.js} +13 -10
  32. package/dist/schema-7BSSLZ4S.js +8 -0
  33. package/dist/{serve-skill-Q6NHX2RA.js → serve-skill-JHFNR7BW.js} +8 -7
  34. package/dist/{server-B5E566CI.js → server-HKJJWFRG.js} +10 -8
  35. package/dist/service-coordinator-UTKI4FRI.js +4922 -0
  36. package/dist/skills/agentbnb/bootstrap.js +5034 -849
  37. package/dist/websocket-client-WRN3HO73.js +6 -0
  38. package/package.json +4 -1
  39. package/skills/agentbnb/SKILL.md +87 -70
  40. package/skills/agentbnb/bootstrap.test.ts +142 -242
  41. package/skills/agentbnb/bootstrap.ts +88 -95
  42. package/skills/agentbnb/install.sh +97 -27
  43. package/skills/deep-stock-analyst/package.json +24 -0
  44. package/skills/deep-stock-analyst/src/analysis/financial-health.ts +167 -0
  45. package/skills/deep-stock-analyst/src/analysis/sentiment.ts +68 -0
  46. package/skills/deep-stock-analyst/src/analysis/signal.ts +188 -0
  47. package/skills/deep-stock-analyst/src/analysis/technicals.ts +318 -0
  48. package/skills/deep-stock-analyst/src/analysis/utils.ts +137 -0
  49. package/skills/deep-stock-analyst/src/analysis/valuation.ts +95 -0
  50. package/skills/deep-stock-analyst/src/api/alpha-vantage.ts +133 -0
  51. package/skills/deep-stock-analyst/src/api/types.ts +238 -0
  52. package/skills/deep-stock-analyst/src/index.ts +84 -0
  53. package/skills/deep-stock-analyst/src/llm/thesis.ts +101 -0
  54. package/skills/deep-stock-analyst/src/orchestrator.ts +228 -0
  55. package/skills/deep-stock-analyst/tsconfig.json +21 -0
  56. package/dist/card-RNEWSAQ6.js +0 -88
  57. package/dist/chunk-UB2NPFC7.js +0 -165
  58. package/dist/execute-QH6F54D7.js +0 -10
@@ -0,0 +1,89 @@
1
+ import {
2
+ AgentBnBError
3
+ } from "./chunk-WGZ5AGOX.js";
4
+
5
+ // src/autonomy/tiers.ts
6
+ import { randomUUID } from "crypto";
7
+ var DEFAULT_AUTONOMY_CONFIG = {
8
+ tier1_max_credits: 0,
9
+ tier2_max_credits: 0
10
+ };
11
+ function getAutonomyTier(creditAmount, config) {
12
+ if (creditAmount < config.tier1_max_credits) return 1;
13
+ if (creditAmount < config.tier2_max_credits) return 2;
14
+ return 3;
15
+ }
16
+ function insertAuditEvent(db, event) {
17
+ const isShareEvent = event.type === "auto_share" || event.type === "auto_share_notify" || event.type === "auto_share_pending";
18
+ const cardId = isShareEvent ? "system" : event.card_id;
19
+ const creditsCharged = isShareEvent ? 0 : event.credits;
20
+ const stmt = db.prepare(`
21
+ INSERT INTO request_log (
22
+ id, card_id, card_name, requester, status, latency_ms, credits_charged,
23
+ created_at, skill_id, action_type, tier_invoked
24
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
25
+ `);
26
+ stmt.run(
27
+ randomUUID(),
28
+ cardId,
29
+ "autonomy-audit",
30
+ "self",
31
+ "success",
32
+ 0,
33
+ creditsCharged,
34
+ (/* @__PURE__ */ new Date()).toISOString(),
35
+ event.skill_id,
36
+ event.type,
37
+ event.tier_invoked
38
+ );
39
+ }
40
+
41
+ // src/autonomy/pending-requests.ts
42
+ import { randomUUID as randomUUID2 } from "crypto";
43
+ function createPendingRequest(db, opts) {
44
+ const id = randomUUID2();
45
+ const now = (/* @__PURE__ */ new Date()).toISOString();
46
+ const paramsJson = opts.params !== void 0 ? JSON.stringify(opts.params) : null;
47
+ db.prepare(`
48
+ INSERT INTO pending_requests (
49
+ id, skill_query, max_cost_credits, selected_peer, selected_card_id,
50
+ selected_skill_id, credits, status, params, created_at, resolved_at
51
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, 'pending', ?, ?, NULL)
52
+ `).run(
53
+ id,
54
+ opts.skill_query,
55
+ opts.max_cost_credits,
56
+ opts.selected_peer ?? null,
57
+ opts.selected_card_id ?? null,
58
+ opts.selected_skill_id ?? null,
59
+ opts.credits,
60
+ paramsJson,
61
+ now
62
+ );
63
+ return id;
64
+ }
65
+ function listPendingRequests(db) {
66
+ const rows = db.prepare(`SELECT * FROM pending_requests WHERE status = 'pending' ORDER BY created_at DESC`).all();
67
+ return rows;
68
+ }
69
+ function resolvePendingRequest(db, id, resolution) {
70
+ const now = (/* @__PURE__ */ new Date()).toISOString();
71
+ const result = db.prepare(
72
+ `UPDATE pending_requests SET status = ?, resolved_at = ? WHERE id = ?`
73
+ ).run(resolution, now, id);
74
+ if (result.changes === 0) {
75
+ throw new AgentBnBError(
76
+ `Pending request not found: ${id}`,
77
+ "NOT_FOUND"
78
+ );
79
+ }
80
+ }
81
+
82
+ export {
83
+ DEFAULT_AUTONOMY_CONFIG,
84
+ getAutonomyTier,
85
+ insertAuditEvent,
86
+ createPendingRequest,
87
+ listPendingRequests,
88
+ resolvePendingRequest
89
+ };
@@ -1,5 +1,9 @@
1
+ import {
2
+ initFeedbackTable
3
+ } from "./chunk-EANI2N2V.js";
1
4
  import {
2
5
  AgentBnBError,
6
+ AnyCardSchema,
3
7
  CapabilityCardSchema
4
8
  } from "./chunk-WGZ5AGOX.js";
5
9
 
@@ -115,6 +119,80 @@ function getRequestLog(db, limit = 10, since) {
115
119
 
116
120
  // src/registry/store.ts
117
121
  import Database from "better-sqlite3";
122
+
123
+ // src/evolution/store.ts
124
+ import { randomUUID } from "crypto";
125
+ function initEvolutionTable(db) {
126
+ db.exec(`
127
+ CREATE TABLE IF NOT EXISTS evolution_versions (
128
+ id TEXT PRIMARY KEY,
129
+ template_name TEXT NOT NULL,
130
+ template_version TEXT NOT NULL,
131
+ publisher_agent TEXT NOT NULL,
132
+ changelog TEXT NOT NULL,
133
+ core_memory_snapshot TEXT NOT NULL,
134
+ fitness_improvement REAL NOT NULL,
135
+ timestamp TEXT NOT NULL,
136
+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
137
+ );
138
+
139
+ CREATE INDEX IF NOT EXISTS evolution_template_idx
140
+ ON evolution_versions(template_name, created_at DESC);
141
+ `);
142
+ }
143
+ function insertEvolution(db, ev) {
144
+ const id = randomUUID();
145
+ const now = (/* @__PURE__ */ new Date()).toISOString();
146
+ db.prepare(`
147
+ INSERT INTO evolution_versions (
148
+ id, template_name, template_version, publisher_agent,
149
+ changelog, core_memory_snapshot, fitness_improvement, timestamp, created_at
150
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
151
+ `).run(
152
+ id,
153
+ ev.template_name,
154
+ ev.template_version,
155
+ ev.publisher_agent,
156
+ ev.changelog,
157
+ JSON.stringify(ev.core_memory_snapshot),
158
+ ev.fitness_improvement,
159
+ ev.timestamp,
160
+ now
161
+ );
162
+ return id;
163
+ }
164
+ function getLatestEvolution(db, templateName) {
165
+ const row = db.prepare(`
166
+ SELECT * FROM evolution_versions
167
+ WHERE template_name = ?
168
+ ORDER BY created_at DESC
169
+ LIMIT 1
170
+ `).get(templateName);
171
+ if (!row) return null;
172
+ return rowToEvolution(row);
173
+ }
174
+ function getEvolutionHistory(db, templateName, limit = 20) {
175
+ const rows = db.prepare(`
176
+ SELECT * FROM evolution_versions
177
+ WHERE template_name = ?
178
+ ORDER BY created_at DESC
179
+ LIMIT ?
180
+ `).all(templateName, limit);
181
+ return rows.map(rowToEvolution);
182
+ }
183
+ function rowToEvolution(row) {
184
+ return {
185
+ template_name: row["template_name"],
186
+ template_version: row["template_version"],
187
+ publisher_agent: row["publisher_agent"],
188
+ changelog: row["changelog"],
189
+ core_memory_snapshot: JSON.parse(row["core_memory_snapshot"]),
190
+ fitness_improvement: row["fitness_improvement"],
191
+ timestamp: row["timestamp"]
192
+ };
193
+ }
194
+
195
+ // src/registry/store.ts
118
196
  var V2_FTS_TRIGGERS = `
119
197
  DROP TRIGGER IF EXISTS cards_ai;
120
198
  DROP TRIGGER IF EXISTS cards_au;
@@ -268,6 +346,8 @@ function openDatabase(path = ":memory:") {
268
346
  );
269
347
  `);
270
348
  createRequestLogTable(db);
349
+ initFeedbackTable(db);
350
+ initEvolutionTable(db);
271
351
  runMigrations(db);
272
352
  return db;
273
353
  }
@@ -385,7 +465,7 @@ function updateCard(db, id, owner, updates) {
385
465
  }
386
466
  const now = (/* @__PURE__ */ new Date()).toISOString();
387
467
  const merged = { ...existing, ...updates, updated_at: now };
388
- const parsed = CapabilityCardSchema.safeParse(merged);
468
+ const parsed = AnyCardSchema.safeParse(merged);
389
469
  if (!parsed.success) {
390
470
  throw new AgentBnBError(
391
471
  `Card validation failed: ${parsed.error.message}`,
@@ -478,6 +558,9 @@ export {
478
558
  getSkillRequestCount,
479
559
  getActivityFeed,
480
560
  getRequestLog,
561
+ insertEvolution,
562
+ getLatestEvolution,
563
+ getEvolutionHistory,
481
564
  openDatabase,
482
565
  insertCard,
483
566
  getCard,
@@ -198,6 +198,99 @@ function migrateOwner(db, oldOwner, newOwner) {
198
198
  })();
199
199
  }
200
200
 
201
+ // src/feedback/store.ts
202
+ import { randomUUID as randomUUID3 } from "crypto";
203
+ function initFeedbackTable(db) {
204
+ db.exec(`
205
+ CREATE TABLE IF NOT EXISTS feedback (
206
+ id TEXT PRIMARY KEY,
207
+ transaction_id TEXT NOT NULL,
208
+ provider_agent TEXT NOT NULL,
209
+ skill_id TEXT NOT NULL,
210
+ requester_agent TEXT NOT NULL,
211
+ rating INTEGER NOT NULL,
212
+ latency_ms INTEGER NOT NULL,
213
+ result_quality TEXT NOT NULL,
214
+ quality_details TEXT,
215
+ would_reuse INTEGER NOT NULL,
216
+ cost_value_ratio TEXT NOT NULL,
217
+ timestamp TEXT NOT NULL,
218
+ created_at TEXT NOT NULL DEFAULT (datetime('now'))
219
+ );
220
+
221
+ CREATE INDEX IF NOT EXISTS feedback_provider_idx ON feedback(provider_agent);
222
+ CREATE INDEX IF NOT EXISTS feedback_skill_idx ON feedback(skill_id);
223
+ `);
224
+ }
225
+ function insertFeedback(db, feedback) {
226
+ const id = randomUUID3();
227
+ const now = (/* @__PURE__ */ new Date()).toISOString();
228
+ db.prepare(`
229
+ INSERT INTO feedback (
230
+ id, transaction_id, provider_agent, skill_id, requester_agent,
231
+ rating, latency_ms, result_quality, quality_details,
232
+ would_reuse, cost_value_ratio, timestamp, created_at
233
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
234
+ `).run(
235
+ id,
236
+ feedback.transaction_id,
237
+ feedback.provider_agent,
238
+ feedback.skill_id,
239
+ feedback.requester_agent,
240
+ feedback.rating,
241
+ feedback.latency_ms,
242
+ feedback.result_quality,
243
+ feedback.quality_details ?? null,
244
+ feedback.would_reuse ? 1 : 0,
245
+ feedback.cost_value_ratio,
246
+ feedback.timestamp,
247
+ now
248
+ );
249
+ return id;
250
+ }
251
+ function getFeedbackForSkill(db, skillId, limit = 20) {
252
+ const rows = db.prepare(`
253
+ SELECT * FROM feedback
254
+ WHERE skill_id = ?
255
+ ORDER BY timestamp DESC
256
+ LIMIT ?
257
+ `).all(skillId, limit);
258
+ return rows.map(rowToFeedback);
259
+ }
260
+ function getFeedbackForProvider(db, providerAgent, sinceDays) {
261
+ let rows;
262
+ if (sinceDays !== void 0) {
263
+ rows = db.prepare(`
264
+ SELECT * FROM feedback
265
+ WHERE provider_agent = ?
266
+ AND timestamp >= datetime('now', ? || ' days')
267
+ ORDER BY timestamp DESC
268
+ `).all(providerAgent, `-${sinceDays}`);
269
+ } else {
270
+ rows = db.prepare(`
271
+ SELECT * FROM feedback
272
+ WHERE provider_agent = ?
273
+ ORDER BY timestamp DESC
274
+ `).all(providerAgent);
275
+ }
276
+ return rows.map(rowToFeedback);
277
+ }
278
+ function rowToFeedback(row) {
279
+ return {
280
+ transaction_id: row["transaction_id"],
281
+ provider_agent: row["provider_agent"],
282
+ skill_id: row["skill_id"],
283
+ requester_agent: row["requester_agent"],
284
+ rating: row["rating"],
285
+ latency_ms: row["latency_ms"],
286
+ result_quality: row["result_quality"],
287
+ quality_details: row["quality_details"] ?? void 0,
288
+ would_reuse: row["would_reuse"] === 1,
289
+ cost_value_ratio: row["cost_value_ratio"],
290
+ timestamp: row["timestamp"]
291
+ };
292
+ }
293
+
201
294
  export {
202
295
  holdEscrow,
203
296
  settleEscrow,
@@ -208,5 +301,9 @@ export {
208
301
  getBalance,
209
302
  getTransactions,
210
303
  recordEarning,
211
- migrateOwner
304
+ migrateOwner,
305
+ initFeedbackTable,
306
+ insertFeedback,
307
+ getFeedbackForSkill,
308
+ getFeedbackForProvider
212
309
  };
@@ -7,7 +7,7 @@ import {
7
7
  openCreditDb,
8
8
  releaseEscrow,
9
9
  settleEscrow
10
- } from "./chunk-DNWT5FZQ.js";
10
+ } from "./chunk-EANI2N2V.js";
11
11
  import {
12
12
  signEscrowReceipt,
13
13
  verifyEscrowReceipt
@@ -1,26 +1,20 @@
1
- // src/cli/peers.ts
2
- import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, existsSync as existsSync2, mkdirSync as mkdirSync2 } from "fs";
3
- import { join as join2 } from "path";
4
-
5
- // src/cli/config.ts
6
- import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
7
- import { homedir } from "os";
8
- import { join } from "path";
9
- function getConfigDir() {
10
- return process.env["AGENTBNB_DIR"] ?? join(homedir(), ".agentbnb");
11
- }
1
+ import {
2
+ getConfigDir
3
+ } from "./chunk-IVOYM3WG.js";
12
4
 
13
5
  // src/cli/peers.ts
6
+ import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
7
+ import { join } from "path";
14
8
  function getPeersPath() {
15
- return join2(getConfigDir(), "peers.json");
9
+ return join(getConfigDir(), "peers.json");
16
10
  }
17
11
  function loadPeers() {
18
12
  const peersPath = getPeersPath();
19
- if (!existsSync2(peersPath)) {
13
+ if (!existsSync(peersPath)) {
20
14
  return [];
21
15
  }
22
16
  try {
23
- const raw = readFileSync2(peersPath, "utf-8");
17
+ const raw = readFileSync(peersPath, "utf-8");
24
18
  return JSON.parse(raw);
25
19
  } catch {
26
20
  return [];
@@ -28,10 +22,10 @@ function loadPeers() {
28
22
  }
29
23
  function writePeers(peers) {
30
24
  const dir = getConfigDir();
31
- if (!existsSync2(dir)) {
32
- mkdirSync2(dir, { recursive: true });
25
+ if (!existsSync(dir)) {
26
+ mkdirSync(dir, { recursive: true });
33
27
  }
34
- writeFileSync2(getPeersPath(), JSON.stringify(peers, null, 2), "utf-8");
28
+ writeFileSync(getPeersPath(), JSON.stringify(peers, null, 2), "utf-8");
35
29
  }
36
30
  function savePeer(peer) {
37
31
  const peers = loadPeers();
@@ -0,0 +1,25 @@
1
+ // src/cli/config.ts
2
+ import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
3
+ import { homedir } from "os";
4
+ import { join } from "path";
5
+ function getConfigDir() {
6
+ return process.env["AGENTBNB_DIR"] ?? join(homedir(), ".agentbnb");
7
+ }
8
+ function getConfigPath() {
9
+ return join(getConfigDir(), "config.json");
10
+ }
11
+ function loadConfig() {
12
+ const configPath = getConfigPath();
13
+ if (!existsSync(configPath)) return null;
14
+ try {
15
+ const raw = readFileSync(configPath, "utf-8");
16
+ return JSON.parse(raw);
17
+ } catch {
18
+ return null;
19
+ }
20
+ }
21
+
22
+ export {
23
+ getConfigDir,
24
+ loadConfig
25
+ };