agentbnb 8.3.2 → 8.4.2

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 (45) hide show
  1. package/dist/{card-T2XJZA5A.js → card-HYTD2BJQ.js} +1 -1
  2. package/dist/{chunk-S7DZHKCG.js → chunk-2PP5MQPD.js} +5 -3
  3. package/dist/{chunk-75OC6E4F.js → chunk-3XPBFF6H.js} +1 -0
  4. package/dist/{chunk-5AH3CMOX.js → chunk-3YQ73ZM6.js} +1 -1
  5. package/dist/{chunk-FELGHDCA.js → chunk-6FZ4WYQL.js} +38 -4
  6. package/dist/{chunk-D242QZCR.js → chunk-6XCN62YU.js} +10 -54
  7. package/dist/chunk-AZKVGC5T.js +53 -0
  8. package/dist/{chunk-NHVHLUYS.js → chunk-CFHCG5FE.js} +6 -217
  9. package/dist/{chunk-5AIYALBX.js → chunk-COA2D7QM.js} +4 -3
  10. package/dist/chunk-G5WKW3ED.js +41 -0
  11. package/dist/{chunk-F3KIEVJ2.js → chunk-HU46M4JA.js} +2 -87
  12. package/dist/{chunk-77KGEDH4.js → chunk-MZSVVG55.js} +2 -41
  13. package/dist/chunk-PCQEHIGF.js +750 -0
  14. package/dist/chunk-PIPCGRCR.js +91 -0
  15. package/dist/{chunk-QFPXZITP.js → chunk-PMRTQ2RL.js} +34 -0
  16. package/dist/{chunk-7IQE34QK.js → chunk-UF6R2RVN.js} +5 -3
  17. package/dist/{chunk-IGQNP3ZO.js → chunk-VAAEBCMU.js} +1 -1
  18. package/dist/chunk-VRPLSK34.js +214 -0
  19. package/dist/{chunk-BARHNIKG.js → chunk-WK2QSO4E.js} +1 -1
  20. package/dist/chunk-WPB5LFGI.js +132 -0
  21. package/dist/chunk-XGOA5J2K.js +173 -0
  22. package/dist/{chunk-VJ7XBEY6.js → chunk-Z5726VPY.js} +6 -6
  23. package/dist/cli/index.js +118 -789
  24. package/dist/conduct-FZPUMPCI.js +25 -0
  25. package/dist/{conduct-VYYBCPHA.js → conduct-J2NXU6RM.js} +12 -9
  26. package/dist/{conductor-mode-SBDCRIX6.js → conductor-mode-HNNMWZIH.js} +11 -8
  27. package/dist/config-IRWLG6IW.js +12 -0
  28. package/dist/{execute-FZLQGIXB.js → execute-UAD5T3BQ.js} +1 -1
  29. package/dist/{execute-TEZPQ5WP.js → execute-UP46R7KS.js} +6 -5
  30. package/dist/index.js +34 -0
  31. package/dist/openclaw-setup-KA72IIEW.js +296 -0
  32. package/dist/openclaw-skills-CT673RBL.js +370 -0
  33. package/dist/{peers-K7FSHPN3.js → peers-F2EWUMVQ.js} +2 -2
  34. package/dist/{publish-capability-HVYILTPR.js → publish-capability-GNH5FHKG.js} +2 -2
  35. package/dist/{request-KJNKR27T.js → request-IM3ZLAOA.js} +13 -9
  36. package/dist/scanner-F5VNV5FP.js +8 -0
  37. package/dist/{serve-skill-GC6NIQ5T.js → serve-skill-6RKMVDMK.js} +6 -5
  38. package/dist/{server-6I7GU2OZ.js → server-O77TDLDU.js} +11 -9
  39. package/dist/{service-coordinator-LZJCAQSJ.js → service-coordinator-R5LZVM6A.js} +31 -26
  40. package/dist/skills/agentbnb/bootstrap.js +34 -2
  41. package/dist/store-4Z446745.js +32 -0
  42. package/dist/writer-4QJ3U3WE.js +16 -0
  43. package/package.json +1 -1
  44. package/skills/agentbnb/bootstrap.ts +45 -2
  45. package/dist/conduct-4JDMWBQD.js +0 -22
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  attachCanonicalAgentId
3
- } from "./chunk-5AIYALBX.js";
3
+ } from "./chunk-COA2D7QM.js";
4
4
  import "./chunk-WTHMHNKC.js";
5
5
  import {
6
6
  CapabilityCardV2Schema
@@ -1,10 +1,12 @@
1
1
  import {
2
- fetchRemoteCards,
2
+ fetchRemoteCards
3
+ } from "./chunk-PIPCGRCR.js";
4
+ import {
3
5
  searchCards
4
- } from "./chunk-F3KIEVJ2.js";
6
+ } from "./chunk-HU46M4JA.js";
5
7
  import {
6
8
  getCard
7
- } from "./chunk-5AIYALBX.js";
9
+ } from "./chunk-COA2D7QM.js";
8
10
  import {
9
11
  resolveCanonicalIdentity
10
12
  } from "./chunk-WTHMHNKC.js";
@@ -28,6 +28,7 @@ function saveConfig(config) {
28
28
 
29
29
  export {
30
30
  getConfigDir,
31
+ getConfigPath,
31
32
  loadConfig,
32
33
  saveConfig
33
34
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getConfigDir
3
- } from "./chunk-75OC6E4F.js";
3
+ } from "./chunk-3XPBFF6H.js";
4
4
 
5
5
  // src/cli/peers.ts
6
6
  import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
@@ -1,20 +1,20 @@
1
1
  import {
2
2
  resolveTargetCapability
3
- } from "./chunk-S7DZHKCG.js";
3
+ } from "./chunk-2PP5MQPD.js";
4
4
  import {
5
5
  getBalance,
6
6
  holdEscrow,
7
7
  releaseEscrow,
8
8
  settleEscrow
9
- } from "./chunk-F3KIEVJ2.js";
9
+ } from "./chunk-HU46M4JA.js";
10
10
  import {
11
11
  loadConfig
12
- } from "./chunk-75OC6E4F.js";
12
+ } from "./chunk-3XPBFF6H.js";
13
13
  import {
14
14
  getCard,
15
15
  insertRequestLog,
16
16
  updateReputation
17
- } from "./chunk-5AIYALBX.js";
17
+ } from "./chunk-COA2D7QM.js";
18
18
  import {
19
19
  AgentBnBError
20
20
  } from "./chunk-I7KWA7OB.js";
@@ -43,6 +43,29 @@ async function notifyTelegramSkillExecuted(opts) {
43
43
  body: JSON.stringify({ chat_id: chatId, text })
44
44
  });
45
45
  }
46
+ async function notifyTelegramSkillFailed(opts) {
47
+ const cfg = loadConfig();
48
+ if (!cfg?.telegram_notifications) return;
49
+ const token = cfg.telegram_bot_token ?? process.env["TELEGRAM_BOT_TOKEN"];
50
+ const chatId = cfg.telegram_chat_id ?? process.env["TELEGRAM_CHAT_ID"];
51
+ if (!token || !chatId) return;
52
+ const balance = getBalance(opts.creditDb, opts.owner);
53
+ const skillLabel = opts.skillId ? `${opts.skillName} (${opts.skillId})` : opts.skillName;
54
+ const text = [
55
+ "[AgentBnB] Skill failed",
56
+ `Skill: ${skillLabel}`,
57
+ `Requester: ${opts.requester}`,
58
+ `Reason: ${opts.failureReason}`,
59
+ `Error: ${opts.message}`,
60
+ `Balance: ${balance} credits`,
61
+ `Latency: ${opts.latencyMs}ms`
62
+ ].join("\n");
63
+ await fetch(`https://api.telegram.org/bot${token}/sendMessage`, {
64
+ method: "POST",
65
+ headers: { "Content-Type": "application/json" },
66
+ body: JSON.stringify({ chat_id: chatId, text })
67
+ });
68
+ }
46
69
  async function executeCapabilityRequest(opts) {
47
70
  const {
48
71
  registryDb,
@@ -143,6 +166,17 @@ async function executeCapabilityRequest(opts) {
143
166
  });
144
167
  } catch {
145
168
  }
169
+ notifyTelegramSkillFailed({
170
+ creditDb,
171
+ owner: card.owner,
172
+ skillName: cardName,
173
+ skillId: resolvedSkillId ?? null,
174
+ requester,
175
+ latencyMs,
176
+ failureReason,
177
+ message
178
+ }).catch(() => {
179
+ });
146
180
  return { success: false, error: { code: -32603, message } };
147
181
  };
148
182
  const handleSuccess = (result, latencyMs) => {
@@ -1,19 +1,22 @@
1
1
  import {
2
- createPendingRequest,
2
+ createPendingRequest
3
+ } from "./chunk-MZSVVG55.js";
4
+ import {
3
5
  getAutonomyTier,
4
6
  insertAuditEvent
5
- } from "./chunk-77KGEDH4.js";
7
+ } from "./chunk-G5WKW3ED.js";
6
8
  import {
7
9
  resolveTargetCapability
8
- } from "./chunk-S7DZHKCG.js";
10
+ } from "./chunk-2PP5MQPD.js";
11
+ import {
12
+ fetchRemoteCards
13
+ } from "./chunk-PIPCGRCR.js";
9
14
  import {
10
- fetchRemoteCards,
11
- getBalance,
12
15
  holdEscrow,
13
16
  releaseEscrow,
14
17
  searchCards,
15
18
  settleEscrow
16
- } from "./chunk-F3KIEVJ2.js";
19
+ } from "./chunk-HU46M4JA.js";
17
20
  import {
18
21
  RelayClient
19
22
  } from "./chunk-NX27AFPA.js";
@@ -23,7 +26,7 @@ import {
23
26
  } from "./chunk-YKMBFQC2.js";
24
27
  import {
25
28
  findPeer
26
- } from "./chunk-5AH3CMOX.js";
29
+ } from "./chunk-3YQ73ZM6.js";
27
30
  import {
28
31
  resolveCanonicalIdentity
29
32
  } from "./chunk-WTHMHNKC.js";
@@ -90,51 +93,6 @@ async function requestViaTemporaryRelay(opts) {
90
93
  }
91
94
  }
92
95
 
93
- // src/credit/budget.ts
94
- var DEFAULT_BUDGET_CONFIG = {
95
- reserve_credits: 20
96
- };
97
- var BudgetManager = class {
98
- /**
99
- * Creates a new BudgetManager.
100
- *
101
- * @param creditDb - The credit SQLite database instance.
102
- * @param owner - Agent owner identifier.
103
- * @param config - Budget configuration. Defaults to DEFAULT_BUDGET_CONFIG (20 credit reserve).
104
- */
105
- constructor(creditDb, owner, config = DEFAULT_BUDGET_CONFIG) {
106
- this.creditDb = creditDb;
107
- this.owner = owner;
108
- this.config = config;
109
- }
110
- /**
111
- * Returns the number of credits available for spending.
112
- * Computed as: max(0, balance - reserve_credits).
113
- * Always returns a non-negative number — never goes below zero.
114
- *
115
- * @returns Available credits (balance minus reserve, floored at 0).
116
- */
117
- availableCredits() {
118
- const balance = getBalance(this.creditDb, this.owner);
119
- return Math.max(0, balance - this.config.reserve_credits);
120
- }
121
- /**
122
- * Returns true if spending `amount` credits is permitted by budget rules.
123
- *
124
- * Rules:
125
- * - Zero-cost calls (amount <= 0) always return true.
126
- * - Any positive amount requires availableCredits() >= amount.
127
- * - If balance is at or below the reserve floor, all positive-cost calls return false.
128
- *
129
- * @param amount - Number of credits to spend.
130
- * @returns true if the spend is allowed, false if it would breach the reserve floor.
131
- */
132
- canSpend(amount) {
133
- if (amount <= 0) return true;
134
- return this.availableCredits() >= amount;
135
- }
136
- };
137
-
138
96
  // src/autonomy/auto-request.ts
139
97
  function minMaxNormalize(values) {
140
98
  if (values.length === 0) return [];
@@ -522,8 +480,6 @@ var AutoRequestor = class {
522
480
 
523
481
  export {
524
482
  requestViaTemporaryRelay,
525
- DEFAULT_BUDGET_CONFIG,
526
- BudgetManager,
527
483
  scorePeers,
528
484
  AutoRequestor
529
485
  };
@@ -0,0 +1,53 @@
1
+ import {
2
+ getBalance
3
+ } from "./chunk-HU46M4JA.js";
4
+
5
+ // src/credit/budget.ts
6
+ var DEFAULT_BUDGET_CONFIG = {
7
+ reserve_credits: 20
8
+ };
9
+ var BudgetManager = class {
10
+ /**
11
+ * Creates a new BudgetManager.
12
+ *
13
+ * @param creditDb - The credit SQLite database instance.
14
+ * @param owner - Agent owner identifier.
15
+ * @param config - Budget configuration. Defaults to DEFAULT_BUDGET_CONFIG (20 credit reserve).
16
+ */
17
+ constructor(creditDb, owner, config = DEFAULT_BUDGET_CONFIG) {
18
+ this.creditDb = creditDb;
19
+ this.owner = owner;
20
+ this.config = config;
21
+ }
22
+ /**
23
+ * Returns the number of credits available for spending.
24
+ * Computed as: max(0, balance - reserve_credits).
25
+ * Always returns a non-negative number — never goes below zero.
26
+ *
27
+ * @returns Available credits (balance minus reserve, floored at 0).
28
+ */
29
+ availableCredits() {
30
+ const balance = getBalance(this.creditDb, this.owner);
31
+ return Math.max(0, balance - this.config.reserve_credits);
32
+ }
33
+ /**
34
+ * Returns true if spending `amount` credits is permitted by budget rules.
35
+ *
36
+ * Rules:
37
+ * - Zero-cost calls (amount <= 0) always return true.
38
+ * - Any positive amount requires availableCredits() >= amount.
39
+ * - If balance is at or below the reserve floor, all positive-cost calls return false.
40
+ *
41
+ * @param amount - Number of credits to spend.
42
+ * @returns true if the spend is allowed, false if it would breach the reserve floor.
43
+ */
44
+ canSpend(amount) {
45
+ if (amount <= 0) return true;
46
+ return this.availableCredits() >= amount;
47
+ }
48
+ };
49
+
50
+ export {
51
+ DEFAULT_BUDGET_CONFIG,
52
+ BudgetManager
53
+ };
@@ -1,9 +1,6 @@
1
1
  import {
2
2
  searchCards
3
- } from "./chunk-F3KIEVJ2.js";
4
- import {
5
- AgentBnBError
6
- } from "./chunk-I7KWA7OB.js";
3
+ } from "./chunk-HU46M4JA.js";
7
4
 
8
5
  // src/registry/pricing.ts
9
6
  function getPricingStats(db, query) {
@@ -46,210 +43,6 @@ function computeMedian(sorted) {
46
43
  return (sorted[mid - 1] + sorted[mid]) / 2;
47
44
  }
48
45
 
49
- // src/discovery/mdns.ts
50
- import { Bonjour } from "bonjour-service";
51
- var bonjourInstance = null;
52
- function getBonjour() {
53
- if (bonjourInstance === null) {
54
- bonjourInstance = new Bonjour();
55
- }
56
- return bonjourInstance;
57
- }
58
- function announceGateway(owner, port, metadata) {
59
- const bonjour = getBonjour();
60
- const txt = {
61
- owner,
62
- version: "1.0",
63
- ...metadata
64
- };
65
- bonjour.publish({
66
- name: owner,
67
- type: "agentbnb",
68
- port,
69
- txt
70
- });
71
- }
72
- function discoverLocalAgents(onFound, onDown) {
73
- const bonjour = getBonjour();
74
- const browser = bonjour.find({ type: "agentbnb" });
75
- browser.on("up", (service) => {
76
- const addresses = service.addresses ?? [];
77
- const ipv4Addresses = addresses.filter((addr) => !addr.includes(":"));
78
- const host = ipv4Addresses.length > 0 ? ipv4Addresses[0] : service.host;
79
- const url = `http://${host}:${service.port}`;
80
- const owner = service.txt?.owner ?? service.name;
81
- onFound({
82
- name: service.name,
83
- url,
84
- owner
85
- });
86
- });
87
- if (onDown) {
88
- browser.on("down", (service) => {
89
- const addresses = service.addresses ?? [];
90
- const ipv4Addresses = addresses.filter((addr) => !addr.includes(":"));
91
- const host = ipv4Addresses.length > 0 ? ipv4Addresses[0] : service.host;
92
- const url = `http://${host}:${service.port}`;
93
- const owner = service.txt?.owner ?? service.name;
94
- onDown({
95
- name: service.name,
96
- url,
97
- owner
98
- });
99
- });
100
- }
101
- return {
102
- stop: () => browser.stop()
103
- };
104
- }
105
- async function stopAnnouncement() {
106
- if (bonjourInstance === null) {
107
- return;
108
- }
109
- const instance = bonjourInstance;
110
- bonjourInstance = null;
111
- await new Promise((resolve2) => {
112
- instance.unpublishAll(() => {
113
- instance.destroy();
114
- resolve2();
115
- });
116
- });
117
- }
118
-
119
- // src/runtime/resolve-self-cli.ts
120
- import { execFileSync } from "child_process";
121
- import { existsSync, realpathSync } from "fs";
122
- import { createRequire } from "module";
123
- import { homedir } from "os";
124
- import { basename, dirname, isAbsolute, join, resolve } from "path";
125
- function resolveSelfCli() {
126
- const require2 = createRequire(import.meta.url);
127
- return resolveSelfCliWithDeps({
128
- argv1: process.argv[1],
129
- cwd: process.cwd(),
130
- platform: process.platform,
131
- homeDir: homedir(),
132
- envPath: process.env["PATH"],
133
- nodeExecDir: dirname(process.execPath),
134
- exists: existsSync,
135
- realpath: realpathSync,
136
- runWhich: (pathEnv) => execFileSync("which", ["agentbnb"], {
137
- encoding: "utf8",
138
- env: { ...process.env, PATH: pathEnv }
139
- }).trim(),
140
- requireResolve: (id) => require2.resolve(id)
141
- });
142
- }
143
- function resolveSelfCliWithDeps(deps) {
144
- const tried = [];
145
- const tryCandidate = (rawPath, label, requireCliShape = false) => {
146
- if (!rawPath || rawPath.trim().length === 0) {
147
- tried.push(`${label}: <empty>`);
148
- return null;
149
- }
150
- const maybeAbsolute = isAbsolute(rawPath) ? rawPath : resolve(deps.cwd, rawPath);
151
- tried.push(`${label}: ${maybeAbsolute}`);
152
- if (!deps.exists(maybeAbsolute)) return null;
153
- const resolvedPath = safeRealpath(deps.realpath, maybeAbsolute);
154
- if (requireCliShape && !looksLikeAgentbnbCli(resolvedPath)) return null;
155
- return resolvedPath;
156
- };
157
- const argvPath = tryCandidate(deps.argv1, "process.argv[1]", true);
158
- if (argvPath) return argvPath;
159
- const fullPathEnv = buildFullPathEnv(deps.envPath, deps.homeDir, deps.nodeExecDir);
160
- tried.push(`which agentbnb PATH=${fullPathEnv}`);
161
- try {
162
- const whichPath = tryCandidate(deps.runWhich(fullPathEnv), "which agentbnb");
163
- if (whichPath) return whichPath;
164
- } catch (err) {
165
- tried.push(`which agentbnb failed: ${extractErrorMessage(err)}`);
166
- }
167
- const npmGlobalCandidates = ["/usr/local/bin/agentbnb", "/opt/homebrew/bin/agentbnb"];
168
- for (const candidate of npmGlobalCandidates) {
169
- const resolvedPath = tryCandidate(candidate, "npm-global");
170
- if (resolvedPath) return resolvedPath;
171
- }
172
- const pnpmCandidates = getPnpmGlobalCandidates(deps.platform, deps.homeDir);
173
- for (const candidate of pnpmCandidates) {
174
- const resolvedPath = tryCandidate(candidate, "pnpm-global");
175
- if (resolvedPath) return resolvedPath;
176
- }
177
- if (deps.nodeExecDir) {
178
- const execDirCandidate = tryCandidate(
179
- join(deps.nodeExecDir, "agentbnb"),
180
- "node-execpath-dir"
181
- );
182
- if (execDirCandidate) return execDirCandidate;
183
- }
184
- try {
185
- const requireResolved = deps.requireResolve("agentbnb/dist/cli/index.js");
186
- const resolvedPath = tryCandidate(requireResolved, "require.resolve(agentbnb/dist/cli/index.js)");
187
- if (resolvedPath) return resolvedPath;
188
- } catch (err) {
189
- tried.push(`require.resolve(agentbnb/dist/cli/index.js) failed: ${extractErrorMessage(err)}`);
190
- }
191
- throw new AgentBnBError(
192
- `Unable to resolve absolute path to agentbnb CLI.
193
- Paths tried:
194
- ${tried.map((item) => `- ${item}`).join("\n")}`,
195
- "CLI_ENTRY_NOT_FOUND"
196
- );
197
- }
198
- function buildFullPathEnv(pathEnv, homeDir, nodeExecDir) {
199
- const values = /* @__PURE__ */ new Set();
200
- for (const item of (pathEnv ?? "").split(":")) {
201
- if (item.trim()) values.add(item.trim());
202
- }
203
- for (const extra of [
204
- "/usr/local/bin",
205
- "/opt/homebrew/bin",
206
- "/usr/bin",
207
- "/bin",
208
- "/usr/sbin",
209
- "/sbin",
210
- join(homeDir, ".local", "bin"),
211
- join(homeDir, "Library", "pnpm"),
212
- join(homeDir, ".local", "share", "pnpm")
213
- ]) {
214
- values.add(extra);
215
- }
216
- if (nodeExecDir) {
217
- values.add(nodeExecDir);
218
- }
219
- return [...values].join(":");
220
- }
221
- function safeRealpath(realpath, path) {
222
- try {
223
- return realpath(path);
224
- } catch {
225
- return path;
226
- }
227
- }
228
- function getPnpmGlobalCandidates(platform, homeDir) {
229
- const candidates = /* @__PURE__ */ new Set();
230
- if (platform === "darwin") {
231
- candidates.add(join(homeDir, "Library", "pnpm", "agentbnb"));
232
- }
233
- if (platform === "linux") {
234
- candidates.add(join(homeDir, ".local", "share", "pnpm", "agentbnb"));
235
- }
236
- candidates.add(join(homeDir, "Library", "pnpm", "agentbnb"));
237
- candidates.add(join(homeDir, ".local", "share", "pnpm", "agentbnb"));
238
- return [...candidates];
239
- }
240
- function looksLikeAgentbnbCli(path) {
241
- const normalized = path.replace(/\\/g, "/").toLowerCase();
242
- const fileName = basename(normalized);
243
- if (fileName === "agentbnb" || fileName === "agentbnb.cmd" || fileName === "agentbnb.exe") {
244
- return true;
245
- }
246
- return normalized.includes("/agentbnb/dist/cli/index.") || normalized.endsWith("/dist/cli/index.js") || normalized.endsWith("/dist/cli/index.mjs") || normalized.endsWith("/dist/cli/index.cjs");
247
- }
248
- function extractErrorMessage(err) {
249
- if (err instanceof Error && err.message) return err.message;
250
- return String(err);
251
- }
252
-
253
46
  // src/cli/onboarding.ts
254
47
  import { randomUUID } from "crypto";
255
48
  import { createConnection } from "net";
@@ -371,20 +164,20 @@ function detectApiKeys(knownKeys) {
371
164
  return knownKeys.filter((key) => key in process.env);
372
165
  }
373
166
  async function isPortOpen(port, host = "127.0.0.1", timeoutMs = 300) {
374
- return new Promise((resolve2) => {
167
+ return new Promise((resolve) => {
375
168
  const socket = createConnection({ port, host });
376
169
  const timer = setTimeout(() => {
377
170
  socket.destroy();
378
- resolve2(false);
171
+ resolve(false);
379
172
  }, timeoutMs);
380
173
  socket.on("connect", () => {
381
174
  clearTimeout(timer);
382
175
  socket.destroy();
383
- resolve2(true);
176
+ resolve(true);
384
177
  });
385
178
  socket.on("error", () => {
386
179
  clearTimeout(timer);
387
- resolve2(false);
180
+ resolve(false);
388
181
  });
389
182
  });
390
183
  }
@@ -421,12 +214,8 @@ function buildDraftCard(apiKey, owner) {
421
214
 
422
215
  export {
423
216
  getPricingStats,
424
- announceGateway,
425
- discoverLocalAgents,
426
- stopAnnouncement,
427
217
  KNOWN_API_KEYS,
428
218
  detectApiKeys,
429
219
  detectOpenPorts,
430
- buildDraftCard,
431
- resolveSelfCli
220
+ buildDraftCard
432
221
  };
@@ -8,6 +8,9 @@ import {
8
8
  CapabilityCardSchema
9
9
  } from "./chunk-I7KWA7OB.js";
10
10
 
11
+ // src/registry/store.ts
12
+ import Database from "better-sqlite3";
13
+
11
14
  // src/registry/request-log.ts
12
15
  var SINCE_MS = {
13
16
  "24h": 864e5,
@@ -138,9 +141,6 @@ function getRequestLog(db, limit = 10, since) {
138
141
  return stmt.all(limit);
139
142
  }
140
143
 
141
- // src/registry/store.ts
142
- import Database from "better-sqlite3";
143
-
144
144
  // src/feedback/store.ts
145
145
  import { randomUUID } from "crypto";
146
146
  function initFeedbackTable(db) {
@@ -843,6 +843,7 @@ export {
843
843
  getLatestEvolution,
844
844
  getEvolutionHistory,
845
845
  openDatabase,
846
+ runMigrations,
846
847
  insertCard,
847
848
  getCard,
848
849
  attachCanonicalAgentId,
@@ -0,0 +1,41 @@
1
+ // src/autonomy/tiers.ts
2
+ import { randomUUID } from "crypto";
3
+ var DEFAULT_AUTONOMY_CONFIG = {
4
+ tier1_max_credits: 0,
5
+ tier2_max_credits: 0
6
+ };
7
+ function getAutonomyTier(creditAmount, config) {
8
+ if (creditAmount < config.tier1_max_credits) return 1;
9
+ if (creditAmount < config.tier2_max_credits) return 2;
10
+ return 3;
11
+ }
12
+ function insertAuditEvent(db, event) {
13
+ const isShareEvent = event.type === "auto_share" || event.type === "auto_share_notify" || event.type === "auto_share_pending";
14
+ const cardId = isShareEvent ? "system" : event.card_id;
15
+ const creditsCharged = isShareEvent ? 0 : event.credits;
16
+ const stmt = db.prepare(`
17
+ INSERT INTO request_log (
18
+ id, card_id, card_name, requester, status, latency_ms, credits_charged,
19
+ created_at, skill_id, action_type, tier_invoked
20
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
21
+ `);
22
+ stmt.run(
23
+ randomUUID(),
24
+ cardId,
25
+ "autonomy-audit",
26
+ "self",
27
+ "success",
28
+ 0,
29
+ creditsCharged,
30
+ (/* @__PURE__ */ new Date()).toISOString(),
31
+ event.skill_id,
32
+ event.type,
33
+ event.tier_invoked
34
+ );
35
+ }
36
+
37
+ export {
38
+ DEFAULT_AUTONOMY_CONFIG,
39
+ getAutonomyTier,
40
+ insertAuditEvent
41
+ };