agentbnb 9.1.0 → 9.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 (42) hide show
  1. package/README.md +29 -4
  2. package/dist/{card-VVT3XBOI.js → card-U2HQRPYN.js} +2 -1
  3. package/dist/{card-NQHAGTQQ.js → card-UF465O7O.js} +2 -1
  4. package/dist/{chunk-PYZGF5QH.js → chunk-2HH2F3DM.js} +161 -97
  5. package/dist/{chunk-JKD6QRUD.js → chunk-7VZ4M4CT.js} +4 -0
  6. package/dist/{chunk-JJHQAZWE.js → chunk-AMABG5SI.js} +5 -5
  7. package/dist/{chunk-GAZCZCAZ.js → chunk-AW4VSROG.js} +1 -1
  8. package/dist/{chunk-VJ2Q33AP.js → chunk-BPPFY72X.js} +4 -0
  9. package/dist/{chunk-DBO2335D.js → chunk-F2CIPAN2.js} +7 -7
  10. package/dist/{chunk-4UIUIHST.js → chunk-G4TF4LB4.js} +1 -1
  11. package/dist/chunk-GZUTU6IZ.js +153 -0
  12. package/dist/{chunk-4DBSSFHG.js → chunk-I4E5ERDN.js} +3 -3
  13. package/dist/{chunk-XL5XD3IG.js → chunk-MPS4RE7T.js} +7 -7
  14. package/dist/{chunk-4M6IAIVK.js → chunk-O44N3KR7.js} +2 -2
  15. package/dist/{chunk-3Y76PHEY.js → chunk-RVOZHVM7.js} +153 -87
  16. package/dist/{chunk-AR7Z3EQB.js → chunk-TCA63C42.js} +8 -8
  17. package/dist/{chunk-UXL7DV7P.js → chunk-WARYO57F.js} +2 -2
  18. package/dist/{chunk-PIO2FMX4.js → chunk-Y7CO3VLF.js} +5 -5
  19. package/dist/cli/index.js +61 -46
  20. package/dist/{conduct-VSSHJHVH.js → conduct-MALC6HEK.js} +9 -8
  21. package/dist/{conduct-6C6JWZKZ.js → conduct-UT6ZYSJD.js} +9 -8
  22. package/dist/{conductor-mode-NKHIZG4N.js → conductor-mode-3WLLERB4.js} +11 -10
  23. package/dist/{conductor-mode-KKPSNN7V.js → conductor-mode-UJKMO2GW.js} +12 -11
  24. package/dist/{execute-IEQ3RV7I.js → execute-3RADNI74.js} +7 -6
  25. package/dist/{execute-QHP4KUV2.js → execute-UFMGTXET.js} +6 -5
  26. package/dist/index.js +350 -147
  27. package/dist/{openclaw-setup-PKGFB4IH.js → openclaw-setup-HEWZZOY7.js} +9 -8
  28. package/dist/{openclaw-skills-5VJDA6SX.js → openclaw-skills-5XLQFRWT.js} +2 -2
  29. package/dist/provider-events-GTTJPYHS.js +13 -0
  30. package/dist/{publish-capability-CHMPZ6W3.js → publish-capability-LM4RSQXX.js} +3 -2
  31. package/dist/{request-6TBVP3GR.js → request-LID2N42Y.js} +9 -8
  32. package/dist/{serve-skill-BRUHUDRA.js → serve-skill-CDNSHTEE.js} +9 -8
  33. package/dist/{server-N4BJW4TS.js → server-QIAO3YSK.js} +14 -13
  34. package/dist/{service-coordinator-M2CBDEUQ.js → service-coordinator-FB44QL7L.js} +201 -38
  35. package/dist/skills/agentbnb/bootstrap.js +210 -47
  36. package/dist/{store-A4YPEHDV.js → store-C4DLIXYM.js} +2 -1
  37. package/package.json +3 -1
  38. package/dist/{credits-action-N3WB4WSI.js → credits-action-KOUJNR36.js} +2 -2
  39. package/dist/{daemon-OM2K3U7J.js → daemon-ETXXE4IS.js} +1 -1
  40. package/dist/{did-action-3PNFYLX2.js → did-action-UHUYMA4Y.js} +1 -1
  41. package/dist/{session-action-67J57636.js → session-action-GYITLYOE.js} +1 -1
  42. package/dist/{vc-action-TSAIABUM.js → vc-action-BWGNQ77Y.js} +1 -1
@@ -5,13 +5,13 @@ import {
5
5
  import {
6
6
  performInit,
7
7
  publishFromSoulV2
8
- } from "./chunk-AR7Z3EQB.js";
8
+ } from "./chunk-TCA63C42.js";
9
9
  import {
10
10
  getPricingStats
11
- } from "./chunk-4UIUIHST.js";
11
+ } from "./chunk-G4TF4LB4.js";
12
12
  import {
13
13
  parseSoulMd
14
- } from "./chunk-GAZCZCAZ.js";
14
+ } from "./chunk-AW4VSROG.js";
15
15
  import {
16
16
  findSoulMd,
17
17
  getOpenClawWorkspaceDir,
@@ -22,16 +22,17 @@ import "./chunk-QG2LLVXP.js";
22
22
  import "./chunk-G5WKW3ED.js";
23
23
  import "./chunk-LENX5NUW.js";
24
24
  import "./chunk-5CC6O6SO.js";
25
- import "./chunk-4DBSSFHG.js";
25
+ import "./chunk-I4E5ERDN.js";
26
26
  import "./chunk-D7NH6YLM.js";
27
+ import "./chunk-7VZ4M4CT.js";
27
28
  import "./chunk-QXRNW4OJ.js";
28
29
  import "./chunk-YNBZLXYS.js";
29
30
  import "./chunk-YDGXKH2T.js";
30
- import "./chunk-3XPBFF6H.js";
31
- import "./chunk-JKD6QRUD.js";
32
31
  import "./chunk-J4RFJVXI.js";
33
32
  import "./chunk-UVCNMRPS.js";
33
+ import "./chunk-3XPBFF6H.js";
34
34
  import "./chunk-4XTYT4JW.js";
35
+ import "./chunk-GZUTU6IZ.js";
35
36
  import "./chunk-3RG5ZIWI.js";
36
37
 
37
38
  // src/cli/openclaw-setup.ts
@@ -247,7 +248,7 @@ Reading ${agentName}/SOUL.md...`);
247
248
  const { loadConfig: loadConfig2 } = await import("./config-ZFWBAGDU.js");
248
249
  const cfg2 = loadConfig2();
249
250
  if (cfg2) {
250
- const db2 = (await import("./store-A4YPEHDV.js")).openDatabase(cfg2.db_path);
251
+ const db2 = (await import("./store-C4DLIXYM.js")).openDatabase(cfg2.db_path);
251
252
  try {
252
253
  for (const cap of parsed.capabilities) {
253
254
  const stats = getPricingStats(db2, cap.name);
@@ -300,7 +301,7 @@ Share ${parsed.capabilities.length} skill(s) on the AgentBnB network? [Y/n]: `);
300
301
  console.error("Error: config not found after init.");
301
302
  process.exit(1);
302
303
  }
303
- const db = (await import("./store-A4YPEHDV.js")).openDatabase(cfg.db_path);
304
+ const db = (await import("./store-C4DLIXYM.js")).openDatabase(cfg.db_path);
304
305
  try {
305
306
  const card = publishFromSoulV2(db, soulContent, cfg.owner, void 0);
306
307
  console.log(` \u2713 Published capability card (${card.skills.length} skill(s))`);
@@ -78,7 +78,7 @@ async function skillsList(opts) {
78
78
  const config = loadConfig();
79
79
  if (config) {
80
80
  try {
81
- const { openDatabase } = await import("./store-A4YPEHDV.js");
81
+ const { openDatabase } = await import("./store-C4DLIXYM.js");
82
82
  const db = openDatabase(config.db_path);
83
83
  try {
84
84
  const rows = db.prepare(
@@ -357,7 +357,7 @@ async function skillsStats(opts) {
357
357
  const config = loadConfig();
358
358
  if (config) {
359
359
  try {
360
- const { openDatabase } = await import("./store-A4YPEHDV.js");
360
+ const { openDatabase } = await import("./store-C4DLIXYM.js");
361
361
  const db = openDatabase(config.db_path);
362
362
  try {
363
363
  rows = db.prepare(
@@ -0,0 +1,13 @@
1
+ import {
2
+ emitProviderEvent,
3
+ ensureProviderEventsTable,
4
+ getProviderEvents,
5
+ getProviderStats
6
+ } from "./chunk-GZUTU6IZ.js";
7
+ import "./chunk-3RG5ZIWI.js";
8
+ export {
9
+ emitProviderEvent,
10
+ ensureProviderEventsTable,
11
+ getProviderEvents,
12
+ getProviderStats
13
+ };
@@ -2,11 +2,12 @@ import {
2
2
  parseSoulMd,
3
3
  publishFromSoul,
4
4
  skillConfigToSkill
5
- } from "./chunk-GAZCZCAZ.js";
6
- import "./chunk-JKD6QRUD.js";
5
+ } from "./chunk-AW4VSROG.js";
6
+ import "./chunk-7VZ4M4CT.js";
7
7
  import "./chunk-J4RFJVXI.js";
8
8
  import "./chunk-UVCNMRPS.js";
9
9
  import "./chunk-4XTYT4JW.js";
10
+ import "./chunk-GZUTU6IZ.js";
10
11
  import "./chunk-3RG5ZIWI.js";
11
12
  export {
12
13
  parseSoulMd,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  AutoRequestor,
3
3
  requestViaTemporaryRelay
4
- } from "./chunk-JJHQAZWE.js";
4
+ } from "./chunk-AMABG5SI.js";
5
5
  import "./chunk-5PV5YCSN.js";
6
6
  import {
7
7
  BudgetManager,
@@ -10,12 +10,15 @@ import {
10
10
  import {
11
11
  DEFAULT_AUTONOMY_CONFIG
12
12
  } from "./chunk-G5WKW3ED.js";
13
- import "./chunk-4M6IAIVK.js";
13
+ import "./chunk-O44N3KR7.js";
14
14
  import "./chunk-ELFGYC22.js";
15
- import "./chunk-4DBSSFHG.js";
15
+ import "./chunk-I4E5ERDN.js";
16
16
  import {
17
17
  openCreditDb
18
18
  } from "./chunk-D7NH6YLM.js";
19
+ import {
20
+ openDatabase
21
+ } from "./chunk-7VZ4M4CT.js";
19
22
  import "./chunk-UPNREF4L.js";
20
23
  import "./chunk-Q5OFZ2JR.js";
21
24
  import "./chunk-QXRNW4OJ.js";
@@ -26,14 +29,12 @@ import {
26
29
  loadKeyPair
27
30
  } from "./chunk-YNBZLXYS.js";
28
31
  import "./chunk-YDGXKH2T.js";
29
- import "./chunk-3YQ73ZM6.js";
30
- import "./chunk-3XPBFF6H.js";
31
- import {
32
- openDatabase
33
- } from "./chunk-JKD6QRUD.js";
34
32
  import "./chunk-J4RFJVXI.js";
35
33
  import "./chunk-UVCNMRPS.js";
34
+ import "./chunk-3YQ73ZM6.js";
35
+ import "./chunk-3XPBFF6H.js";
36
36
  import "./chunk-4XTYT4JW.js";
37
+ import "./chunk-GZUTU6IZ.js";
37
38
  import "./chunk-3RG5ZIWI.js";
38
39
 
39
40
  // src/mcp/tools/request.ts
@@ -1,15 +1,19 @@
1
1
  import {
2
2
  executeCapabilityRequest
3
- } from "./chunk-3Y76PHEY.js";
3
+ } from "./chunk-RVOZHVM7.js";
4
4
  import "./chunk-ZYOMPJGG.js";
5
5
  import "./chunk-LENX5NUW.js";
6
6
  import "./chunk-5CC6O6SO.js";
7
- import "./chunk-4M6IAIVK.js";
7
+ import "./chunk-O44N3KR7.js";
8
8
  import "./chunk-ELFGYC22.js";
9
- import "./chunk-4DBSSFHG.js";
9
+ import "./chunk-I4E5ERDN.js";
10
10
  import {
11
11
  openCreditDb
12
12
  } from "./chunk-D7NH6YLM.js";
13
+ import {
14
+ listCards,
15
+ openDatabase
16
+ } from "./chunk-7VZ4M4CT.js";
13
17
  import {
14
18
  RelayClient
15
19
  } from "./chunk-UPNREF4L.js";
@@ -17,14 +21,11 @@ import "./chunk-Q5OFZ2JR.js";
17
21
  import "./chunk-QXRNW4OJ.js";
18
22
  import "./chunk-YNBZLXYS.js";
19
23
  import "./chunk-YDGXKH2T.js";
20
- import "./chunk-3XPBFF6H.js";
21
- import {
22
- listCards,
23
- openDatabase
24
- } from "./chunk-JKD6QRUD.js";
25
24
  import "./chunk-J4RFJVXI.js";
26
25
  import "./chunk-UVCNMRPS.js";
26
+ import "./chunk-3XPBFF6H.js";
27
27
  import "./chunk-4XTYT4JW.js";
28
+ import "./chunk-GZUTU6IZ.js";
28
29
  import "./chunk-3RG5ZIWI.js";
29
30
 
30
31
  // src/mcp/tools/serve-skill.ts
@@ -10,29 +10,30 @@ import {
10
10
  } from "./chunk-ELFGYC22.js";
11
11
  import {
12
12
  searchCards
13
- } from "./chunk-4DBSSFHG.js";
13
+ } from "./chunk-I4E5ERDN.js";
14
14
  import {
15
15
  getBalance,
16
16
  openCreditDb
17
17
  } from "./chunk-D7NH6YLM.js";
18
+ import {
19
+ insertCard,
20
+ openDatabase
21
+ } from "./chunk-7VZ4M4CT.js";
18
22
  import "./chunk-QXRNW4OJ.js";
19
23
  import {
20
24
  loadKeyPair
21
25
  } from "./chunk-YNBZLXYS.js";
22
26
  import "./chunk-YDGXKH2T.js";
23
- import {
24
- getConfigDir,
25
- loadConfig
26
- } from "./chunk-3XPBFF6H.js";
27
- import {
28
- insertCard,
29
- openDatabase
30
- } from "./chunk-JKD6QRUD.js";
31
27
  import "./chunk-J4RFJVXI.js";
32
28
  import {
33
29
  AnyCardSchema
34
30
  } from "./chunk-UVCNMRPS.js";
31
+ import {
32
+ getConfigDir,
33
+ loadConfig
34
+ } from "./chunk-3XPBFF6H.js";
35
35
  import "./chunk-4XTYT4JW.js";
36
+ import "./chunk-GZUTU6IZ.js";
36
37
  import "./chunk-3RG5ZIWI.js";
37
38
 
38
39
  // src/mcp/server.ts
@@ -261,7 +262,7 @@ function registerPublishTool(server, ctx) {
261
262
  }
262
263
 
263
264
  // src/mcp/server.ts
264
- var VERSION = true ? "9.1.0" : "0.0.0-dev";
265
+ var VERSION = true ? "9.1.1" : "0.0.0-dev";
265
266
  async function startMcpServer() {
266
267
  const config = loadConfig();
267
268
  if (!config) {
@@ -282,9 +283,9 @@ async function startMcpServer() {
282
283
  registerDiscoverTool(server, ctx);
283
284
  registerStatusTool(server, ctx);
284
285
  registerPublishTool(server, ctx);
285
- const { registerRequestTool } = await import("./request-6TBVP3GR.js");
286
- const { registerConductTool } = await import("./conduct-6C6JWZKZ.js");
287
- const { registerServeSkillTool } = await import("./serve-skill-BRUHUDRA.js");
286
+ const { registerRequestTool } = await import("./request-LID2N42Y.js");
287
+ const { registerConductTool } = await import("./conduct-UT6ZYSJD.js");
288
+ const { registerServeSkillTool } = await import("./serve-skill-CDNSHTEE.js");
288
289
  registerRequestTool(server, ctx);
289
290
  registerConductTool(server, ctx);
290
291
  registerServeSkillTool(server, ctx);
@@ -1,3 +1,6 @@
1
+ import {
2
+ StructuredFeedbackSchema
3
+ } from "./chunk-AUBHR7HH.js";
1
4
  import {
2
5
  ApiSkillConfigSchema,
3
6
  parseSkillsFile
@@ -11,11 +14,9 @@ import {
11
14
  } from "./chunk-3MJT4PZG.js";
12
15
  import {
13
16
  executeCapabilityBatch,
14
- executeCapabilityRequest
15
- } from "./chunk-3Y76PHEY.js";
16
- import {
17
- StructuredFeedbackSchema
18
- } from "./chunk-AUBHR7HH.js";
17
+ executeCapabilityRequest,
18
+ notifyProviderEvent
19
+ } from "./chunk-RVOZHVM7.js";
19
20
  import {
20
21
  announceGateway,
21
22
  stopAnnouncement
@@ -28,7 +29,7 @@ import {
28
29
  buildDraftCard,
29
30
  detectApiKeys,
30
31
  getPricingStats
31
- } from "./chunk-4UIUIHST.js";
32
+ } from "./chunk-G4TF4LB4.js";
32
33
  import {
33
34
  listPendingRequests,
34
35
  resolvePendingRequest
@@ -48,14 +49,14 @@ import {
48
49
  import {
49
50
  deriveAgentId
50
51
  } from "./chunk-5CC6O6SO.js";
51
- import "./chunk-4M6IAIVK.js";
52
+ import "./chunk-O44N3KR7.js";
52
53
  import "./chunk-ELFGYC22.js";
53
54
  import {
54
55
  buildReputationMap,
55
56
  computeReputation,
56
57
  filterCards,
57
58
  searchCards
58
- } from "./chunk-4DBSSFHG.js";
59
+ } from "./chunk-I4E5ERDN.js";
59
60
  import {
60
61
  NETWORK_FEE_RATE,
61
62
  bootstrapAgent,
@@ -70,25 +71,6 @@ import {
70
71
  releaseEscrow,
71
72
  settleEscrow
72
73
  } from "./chunk-D7NH6YLM.js";
73
- import {
74
- RelayMessageSchema,
75
- SESSION_MESSAGE_TYPES,
76
- SessionEndMessageSchema,
77
- SessionMessageMessageSchema,
78
- SessionOpenMessageSchema,
79
- loadSessionConfig
80
- } from "./chunk-Q5OFZ2JR.js";
81
- import {
82
- loadCoreConfig
83
- } from "./chunk-QXRNW4OJ.js";
84
- import {
85
- generateKeyPair,
86
- verifyEscrowReceipt
87
- } from "./chunk-YNBZLXYS.js";
88
- import "./chunk-YDGXKH2T.js";
89
- import {
90
- getConfigDir
91
- } from "./chunk-3XPBFF6H.js";
92
74
  import {
93
75
  attachCanonicalAgentId,
94
76
  getCard,
@@ -105,22 +87,44 @@ import {
105
87
  updateCard,
106
88
  updateSkillAvailability,
107
89
  updateSkillIdleRate
108
- } from "./chunk-JKD6QRUD.js";
90
+ } from "./chunk-7VZ4M4CT.js";
91
+ import {
92
+ RelayMessageSchema,
93
+ SESSION_MESSAGE_TYPES,
94
+ SessionEndMessageSchema,
95
+ SessionMessageMessageSchema,
96
+ SessionOpenMessageSchema,
97
+ loadSessionConfig
98
+ } from "./chunk-Q5OFZ2JR.js";
99
+ import {
100
+ loadCoreConfig
101
+ } from "./chunk-QXRNW4OJ.js";
102
+ import {
103
+ generateKeyPair,
104
+ verifyEscrowReceipt
105
+ } from "./chunk-YNBZLXYS.js";
106
+ import "./chunk-YDGXKH2T.js";
109
107
  import "./chunk-J4RFJVXI.js";
110
108
  import {
111
109
  AgentBnBError,
112
110
  AnyCardSchema
113
111
  } from "./chunk-UVCNMRPS.js";
112
+ import {
113
+ getConfigDir
114
+ } from "./chunk-3XPBFF6H.js";
114
115
  import {
115
116
  getActivityFeed,
116
117
  getRequestLog,
117
118
  getSkillRequestCount,
118
119
  insertRequestLog
119
120
  } from "./chunk-4XTYT4JW.js";
121
+ import {
122
+ emitProviderEvent
123
+ } from "./chunk-GZUTU6IZ.js";
120
124
  import "./chunk-3RG5ZIWI.js";
121
125
 
122
126
  // src/runtime/agent-runtime.ts
123
- import { readFileSync, existsSync } from "fs";
127
+ import { readFileSync as readFileSync2, existsSync } from "fs";
124
128
 
125
129
  // src/skills/executor.ts
126
130
  function buildTimeoutError(skillId, timeoutMs) {
@@ -775,7 +779,30 @@ var OpenClawBridge = class {
775
779
 
776
780
  // src/skills/command-executor.ts
777
781
  import { spawn } from "child_process";
782
+ import { readFileSync, statSync } from "fs";
783
+ import { basename, extname } from "path";
778
784
  var KILL_GRACE_MS = 5e3;
785
+ var MAX_INLINE_FILE_BYTES = 5 * 1024 * 1024;
786
+ var MIME_TYPES = {
787
+ ".mp3": "audio/mpeg",
788
+ ".wav": "audio/wav",
789
+ ".ogg": "audio/ogg",
790
+ ".m4a": "audio/mp4",
791
+ ".pdf": "application/pdf",
792
+ ".png": "image/png",
793
+ ".jpg": "image/jpeg",
794
+ ".jpeg": "image/jpeg",
795
+ ".gif": "image/gif",
796
+ ".webp": "image/webp",
797
+ ".svg": "image/svg+xml",
798
+ ".json": "application/json",
799
+ ".txt": "text/plain",
800
+ ".md": "text/markdown",
801
+ ".csv": "text/csv"
802
+ };
803
+ function guessMimeType(filePath) {
804
+ return MIME_TYPES[extname(filePath).toLowerCase()] ?? "application/octet-stream";
805
+ }
779
806
  function shellEscape2(value) {
780
807
  return "'" + value.replace(/'/g, "'\\''") + "'";
781
808
  }
@@ -991,8 +1018,34 @@ var CommandExecutor = class {
991
1018
  };
992
1019
  }
993
1020
  }
994
- case "file":
995
- return { success: true, result: { file_path: rawOutput } };
1021
+ case "file": {
1022
+ try {
1023
+ const stats = statSync(rawOutput);
1024
+ if (stats.size > MAX_INLINE_FILE_BYTES) {
1025
+ return {
1026
+ success: false,
1027
+ error: `File too large for inline return: ${stats.size} bytes (max ${MAX_INLINE_FILE_BYTES})`
1028
+ };
1029
+ }
1030
+ const buffer = readFileSync(rawOutput);
1031
+ return {
1032
+ success: true,
1033
+ result: {
1034
+ file: {
1035
+ name: basename(rawOutput),
1036
+ mime_type: guessMimeType(rawOutput),
1037
+ size_bytes: stats.size,
1038
+ data_base64: buffer.toString("base64")
1039
+ },
1040
+ // Keep file_path for backward compat (local workflows)
1041
+ file_path: rawOutput
1042
+ }
1043
+ };
1044
+ } catch (err) {
1045
+ const msg = err instanceof Error ? err.message : String(err);
1046
+ return { success: false, error: `Failed to read file "${rawOutput}": ${msg}` };
1047
+ }
1048
+ }
996
1049
  default:
997
1050
  return {
998
1051
  success: false,
@@ -1121,13 +1174,13 @@ var AgentRuntime = class {
1121
1174
  }
1122
1175
  let configs = [];
1123
1176
  if (hasSkillsYaml) {
1124
- const yamlContent = readFileSync(this.skillsYamlPath, "utf8");
1177
+ const yamlContent = readFileSync2(this.skillsYamlPath, "utf8");
1125
1178
  configs = parseSkillsFile(yamlContent);
1126
1179
  }
1127
1180
  const modes = /* @__PURE__ */ new Map();
1128
1181
  if (this.conductorEnabled) {
1129
- const { ConductorMode } = await import("./conductor-mode-NKHIZG4N.js");
1130
- const { registerConductorCard, CONDUCTOR_OWNER } = await import("./card-NQHAGTQQ.js");
1182
+ const { ConductorMode } = await import("./conductor-mode-3WLLERB4.js");
1183
+ const { registerConductorCard, CONDUCTOR_OWNER } = await import("./card-UF465O7O.js");
1131
1184
  const { loadPeers } = await import("./peers-7BMU2775.js");
1132
1185
  registerConductorCard(this.registryDb);
1133
1186
  const resolveAgentUrl = (owner) => {
@@ -2006,12 +2059,14 @@ var SessionManager = class {
2006
2059
  escrow;
2007
2060
  config;
2008
2061
  sendToAgent;
2062
+ registryDb;
2009
2063
  /** Maps agent connection key → set of session IDs they participate in. */
2010
2064
  agentSessions = /* @__PURE__ */ new Map();
2011
2065
  constructor(opts) {
2012
2066
  this.escrow = new SessionEscrow(opts.creditDb);
2013
2067
  this.config = opts.config ?? loadSessionConfig();
2014
2068
  this.sendToAgent = opts.sendToAgent;
2069
+ this.registryDb = opts.registryDb ?? null;
2015
2070
  }
2016
2071
  /**
2017
2072
  * Open a new session between requester and provider.
@@ -2070,6 +2125,15 @@ var SessionManager = class {
2070
2125
  }
2071
2126
  this.resetIdleTimer(session.id);
2072
2127
  this.startDurationTimer(session.id);
2128
+ this.emitEvent({
2129
+ event_type: "session.opened",
2130
+ skill_id: session.skill_id,
2131
+ session_id: session.id,
2132
+ requester: session.requester_id,
2133
+ credits: session.budget,
2134
+ duration_ms: 0,
2135
+ metadata: { engine: "session", pricing_model: session.pricing_model }
2136
+ });
2073
2137
  return session;
2074
2138
  }
2075
2139
  /**
@@ -2130,6 +2194,15 @@ var SessionManager = class {
2130
2194
  content: msg.content,
2131
2195
  metadata: msg.metadata
2132
2196
  });
2197
+ this.emitEvent({
2198
+ event_type: "session.message",
2199
+ skill_id: session.skill_id,
2200
+ session_id: session.id,
2201
+ requester: session.requester_id,
2202
+ credits: session.spent,
2203
+ duration_ms: Date.now() - new Date(session.created_at).getTime(),
2204
+ metadata: { message_count: session.messages.length, running_cost: session.spent, sender: msg.sender }
2205
+ });
2133
2206
  this.resetIdleTimer(session.id);
2134
2207
  }
2135
2208
  /**
@@ -2173,6 +2246,19 @@ var SessionManager = class {
2173
2246
  this.durationTimers.clear();
2174
2247
  }
2175
2248
  // -------------------------------------------------------------------------
2249
+ // Event emission
2250
+ // -------------------------------------------------------------------------
2251
+ /** Emit a provider event + Telegram notification. Silently no-ops on failure. */
2252
+ emitEvent(event) {
2253
+ if (!this.registryDb) return;
2254
+ try {
2255
+ const emitted = emitProviderEvent(this.registryDb, event);
2256
+ notifyProviderEvent(emitted).catch(() => {
2257
+ });
2258
+ } catch {
2259
+ }
2260
+ }
2261
+ // -------------------------------------------------------------------------
2176
2262
  // Internal helpers
2177
2263
  // -------------------------------------------------------------------------
2178
2264
  endSessionInternal(session, reason) {
@@ -2196,6 +2282,27 @@ var SessionManager = class {
2196
2282
  };
2197
2283
  session.status = "settled";
2198
2284
  session.updated_at = (/* @__PURE__ */ new Date()).toISOString();
2285
+ const isFailed = reason === "error";
2286
+ const eventMetadata = {
2287
+ total_messages: session.messages.length,
2288
+ reason,
2289
+ refunded: session.budget - session.spent
2290
+ };
2291
+ if (isFailed) {
2292
+ eventMetadata["last_messages"] = session.messages.slice(-3).map((m) => ({
2293
+ sender: m.sender,
2294
+ content: m.content.slice(0, 200)
2295
+ }));
2296
+ }
2297
+ this.emitEvent({
2298
+ event_type: isFailed ? "session.failed" : "session.ended",
2299
+ skill_id: session.skill_id,
2300
+ session_id: session.id,
2301
+ requester: session.requester_id,
2302
+ credits: session.spent,
2303
+ duration_ms: durationMs,
2304
+ metadata: eventMetadata
2305
+ });
2199
2306
  this.sendToAgent(session.requester_id, settledMsg);
2200
2307
  this.sendToAgent(session.provider_id, settledMsg);
2201
2308
  session.status = "closed";
@@ -5693,6 +5800,62 @@ function createRegistryServer(opts) {
5693
5800
  const items = await ledger.getHistory(ownerName, limit);
5694
5801
  return reply.send({ items, limit });
5695
5802
  });
5803
+ ownerRoutes.get("/me/events", {
5804
+ schema: {
5805
+ tags: ["owner"],
5806
+ summary: "Provider event stream",
5807
+ security: [{ bearerAuth: [] }],
5808
+ querystring: {
5809
+ type: "object",
5810
+ properties: {
5811
+ limit: { type: "integer", description: "Max entries (default 50)" },
5812
+ since: { type: "string", description: "ISO timestamp for cursor-based polling" },
5813
+ event_type: { type: "string", description: "Filter by event type" }
5814
+ }
5815
+ }
5816
+ }
5817
+ }, async (request, reply) => {
5818
+ const { getProviderEvents: getEvents } = await import("./provider-events-GTTJPYHS.js");
5819
+ const query = request.query;
5820
+ const limit = query.limit ? parseInt(query.limit, 10) : void 0;
5821
+ const events = getEvents(db, {
5822
+ limit,
5823
+ since: query.since,
5824
+ event_type: query.event_type
5825
+ });
5826
+ return reply.send({ events });
5827
+ });
5828
+ ownerRoutes.get("/me/stats", {
5829
+ schema: {
5830
+ tags: ["owner"],
5831
+ summary: "Aggregated provider stats",
5832
+ security: [{ bearerAuth: [] }],
5833
+ querystring: {
5834
+ type: "object",
5835
+ properties: { period: { type: "string", enum: ["24h", "7d", "30d"] } }
5836
+ }
5837
+ }
5838
+ }, async (request, reply) => {
5839
+ const { getProviderStats: getStats } = await import("./provider-events-GTTJPYHS.js");
5840
+ const query = request.query;
5841
+ const period = query.period ?? "7d";
5842
+ const stats = getStats(db, period);
5843
+ if (opts.creditDb) {
5844
+ const periodMs = { "24h": 864e5, "7d": 6048e5, "30d": 2592e6 }[period];
5845
+ const cutoff = new Date(Date.now() - periodMs).toISOString();
5846
+ try {
5847
+ const row = opts.creditDb.prepare(`
5848
+ SELECT COALESCE(SUM(CASE WHEN amount < 0 AND reason IN ('escrow_hold', 'voucher_hold', 'network_fee') THEN -amount ELSE 0 END), 0) as spent
5849
+ FROM credit_transactions
5850
+ WHERE owner = ? AND created_at >= ?
5851
+ `).get(ownerName, cutoff);
5852
+ stats.total_spending = row?.spent ?? 0;
5853
+ stats.net_pnl = stats.total_earnings - stats.total_spending;
5854
+ } catch {
5855
+ }
5856
+ }
5857
+ return reply.send(stats);
5858
+ });
5696
5859
  });
5697
5860
  }
5698
5861
  api.get("/api/providers/:owner/reliability", {
@@ -5897,7 +6060,7 @@ var IdleMonitor = class {
5897
6060
 
5898
6061
  // src/runtime/service-coordinator.ts
5899
6062
  import { spawn as spawn2 } from "child_process";
5900
- import { existsSync as existsSync3, readFileSync as readFileSync2 } from "fs";
6063
+ import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
5901
6064
  import { join as join2 } from "path";
5902
6065
  import { randomUUID as randomUUID8 } from "crypto";
5903
6066
  import { Cron as Cron2 } from "croner";
@@ -6072,7 +6235,7 @@ var ServiceCoordinator = class {
6072
6235
  console.log("Conductor mode enabled \u2014 orchestrate/plan skills available via gateway");
6073
6236
  }
6074
6237
  if (opts.conductorEnabled && this.config.conductor?.public) {
6075
- const { buildConductorCard } = await import("./card-NQHAGTQQ.js");
6238
+ const { buildConductorCard } = await import("./card-UF465O7O.js");
6076
6239
  const conductorCard = attachCanonicalAgentId(
6077
6240
  this.runtime.registryDb,
6078
6241
  buildConductorCard(this.config.owner)
@@ -6149,7 +6312,7 @@ var ServiceCoordinator = class {
6149
6312
  }
6150
6313
  if (opts.registryUrl && opts.relay) {
6151
6314
  const { RelayClient } = await import("./websocket-client-FCPZOE4S.js");
6152
- const { executeCapabilityRequest: executeCapabilityRequest2 } = await import("./execute-QHP4KUV2.js");
6315
+ const { executeCapabilityRequest: executeCapabilityRequest2 } = await import("./execute-UFMGTXET.js");
6153
6316
  const localCards = listCards(this.runtime.registryDb, this.config.owner);
6154
6317
  const { primaryCard, additionalCards } = buildRelayRegistrationCards(this.config.owner, localCards);
6155
6318
  if (this.config.conductor?.public) {
@@ -6410,7 +6573,7 @@ function loadPersistedRuntime(configDir) {
6410
6573
  const runtimePath = join2(configDir, "runtime.json");
6411
6574
  if (!existsSync3(runtimePath)) return null;
6412
6575
  try {
6413
- const raw = readFileSync2(runtimePath, "utf8");
6576
+ const raw = readFileSync3(runtimePath, "utf8");
6414
6577
  const parsed = JSON.parse(raw);
6415
6578
  const nodeExec = parsed["node_exec"];
6416
6579
  if (typeof nodeExec !== "string" || nodeExec.trim().length === 0) {