agentbnb 9.0.2 → 9.1.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.
Files changed (72) hide show
  1. package/dist/{card-NKQFB3HD.js → card-NQHAGTQQ.js} +3 -1
  2. package/dist/{card-6KL6L4GF.js → card-VVT3XBOI.js} +3 -1
  3. package/dist/chunk-3RG5ZIWI.js +10 -0
  4. package/dist/{chunk-76YORWFJ.js → chunk-3Y76PHEY.js} +62 -5
  5. package/dist/{chunk-QEDVPJKP.js → chunk-4DBSSFHG.js} +20 -16
  6. package/dist/chunk-4HLGFR72.js +155 -0
  7. package/dist/{chunk-ERT77HKY.js → chunk-4M6IAIVK.js} +2 -2
  8. package/dist/{chunk-FUGWPKXN.js → chunk-4UIUIHST.js} +1 -1
  9. package/dist/chunk-4XTYT4JW.js +147 -0
  10. package/dist/{chunk-2SOHHB2O.js → chunk-AR7Z3EQB.js} +34 -11
  11. package/dist/{chunk-Z4IDXMSP.js → chunk-D7NH6YLM.js} +6 -1
  12. package/dist/{chunk-SLZBE2I5.js → chunk-DBO2335D.js} +17 -12
  13. package/dist/{chunk-N3TXLBGK.js → chunk-GAZCZCAZ.js} +1 -1
  14. package/dist/{chunk-UQCQ2JCG.js → chunk-JJHQAZWE.js} +4 -4
  15. package/dist/{chunk-NLQCHO7N.js → chunk-JKD6QRUD.js} +3 -134
  16. package/dist/{chunk-74OZGLIT.js → chunk-LENX5NUW.js} +1 -1
  17. package/dist/{chunk-I3RRMAAD.js → chunk-PIO2FMX4.js} +5 -5
  18. package/dist/{chunk-77HAL2ZL.js → chunk-PYZGF5QH.js} +60 -3
  19. package/dist/chunk-Q5OFZ2JR.js +292 -0
  20. package/dist/{chunk-YJ3RGKPU.js → chunk-QG2LLVXP.js} +6 -2
  21. package/dist/chunk-QXRNW4OJ.js +35 -0
  22. package/dist/{chunk-UR3MISL2.js → chunk-UPNREF4L.js} +1 -1
  23. package/dist/{chunk-SMQDT7CT.js → chunk-UXL7DV7P.js} +7 -3
  24. package/dist/{chunk-PG3CLSAH.js → chunk-VJ2Q33AP.js} +3 -134
  25. package/dist/{chunk-DYJ7YGBM.js → chunk-WOVESOQ7.js} +237 -124
  26. package/dist/{chunk-BNS76U6K.js → chunk-XL5XD3IG.js} +23 -17
  27. package/dist/{chunk-FMKBCO2Q.js → chunk-ZYOMPJGG.js} +2 -2
  28. package/dist/cli/index.js +133 -59
  29. package/dist/{client-YB3IYO3S.js → client-XOSXFC7Q.js} +1 -0
  30. package/dist/{conduct-URYWMA5T.js → conduct-6C6JWZKZ.js} +13 -10
  31. package/dist/conduct-VSSHJHVH.js +29 -0
  32. package/dist/{conductor-mode-NRSVP2AU.js → conductor-mode-KKPSNN7V.js} +9 -6
  33. package/dist/{conductor-mode-2UFN6BUL.js → conductor-mode-NKHIZG4N.js} +17 -14
  34. package/dist/{config-IRWLG6IW.js → config-ZFWBAGDU.js} +1 -0
  35. package/dist/{credits-action-24EPLUHG.js → credits-action-N3WB4WSI.js} +5 -3
  36. package/dist/{daemon-A7DXZIQW.js → daemon-OM2K3U7J.js} +1 -0
  37. package/dist/{did-action-MQLDT4RF.js → did-action-3PNFYLX2.js} +1 -0
  38. package/dist/{execute-DNRNU3HM.js → execute-IEQ3RV7I.js} +6 -3
  39. package/dist/{execute-2Z3XIUHR.js → execute-QHP4KUV2.js} +10 -7
  40. package/dist/index.d.ts +412 -275
  41. package/dist/index.js +886 -282
  42. package/dist/{openclaw-setup-WA625DZA.js → openclaw-setup-PKGFB4IH.js} +19 -16
  43. package/dist/{openclaw-skills-76ZWXHFM.js → openclaw-skills-5VJDA6SX.js} +7 -6
  44. package/dist/{peers-F2EWUMVQ.js → peers-7BMU2775.js} +1 -0
  45. package/dist/{peers-CJ7T4RJO.js → peers-IOVCBWAI.js} +1 -0
  46. package/dist/{process-guard-QDBIOLY4.js → process-guard-6324CZDC.js} +1 -0
  47. package/dist/{publish-capability-FOCHYNYE.js → publish-capability-CHMPZ6W3.js} +4 -2
  48. package/dist/{reliability-metrics-JSOY3PNW.js → reliability-metrics-22JTZGB4.js} +1 -0
  49. package/dist/{reliability-metrics-KKUFFVB6.js → reliability-metrics-MIJ3TJWL.js} +1 -0
  50. package/dist/{request-KPKWBL5W.js → request-6TBVP3GR.js} +12 -9
  51. package/dist/request-log-2D253WML.js +17 -0
  52. package/dist/request-log-SIGTGOFA.js +16 -0
  53. package/dist/{scanner-GP4AOCW6.js → scanner-EFU6NBEJ.js} +1 -0
  54. package/dist/{schema-7BSSLZ4S.js → schema-FABVZKSI.js} +1 -0
  55. package/dist/{serve-skill-QSUIK3ZF.js → serve-skill-BRUHUDRA.js} +12 -9
  56. package/dist/{server-TGV2OPUM.js → server-N4BJW4TS.js} +15 -8
  57. package/dist/{service-coordinator-4JAUUNUL.js → service-coordinator-M2CBDEUQ.js} +539 -50
  58. package/dist/session-5AIRM7YF.js +144 -0
  59. package/dist/session-action-67J57636.js +131 -0
  60. package/dist/{skill-config-5O2VR546.js → skill-config-VYNF7BCY.js} +1 -0
  61. package/dist/skill-wrap-IAZHOYM4.js +365 -0
  62. package/dist/skills/agentbnb/bootstrap.js +564 -75
  63. package/dist/{store-S22F3I7G.js → store-A4YPEHDV.js} +3 -1
  64. package/dist/{vc-action-SUD7TMN2.js → vc-action-TSAIABUM.js} +1 -0
  65. package/dist/websocket-client-FCPZOE4S.js +9 -0
  66. package/dist/websocket-client-RT4KLJL4.js +8 -0
  67. package/dist/{writer-4QJ3U3WE.js → writer-V7JBWKKZ.js} +1 -0
  68. package/package.json +1 -1
  69. package/dist/chunk-3466S65P.js +0 -179
  70. package/dist/conduct-UAEEMVFD.js +0 -26
  71. package/dist/websocket-client-5CRE36Z5.js +0 -7
  72. package/dist/websocket-client-WHEHIYIZ.js +0 -6
@@ -0,0 +1,35 @@
1
+ import {
2
+ __require
3
+ } from "./chunk-3RG5ZIWI.js";
4
+
5
+ // src/core-config.ts
6
+ import { readFileSync } from "fs";
7
+ import { join } from "path";
8
+ var coreBasePath = null;
9
+ var coreResolved = false;
10
+ function resolveCoreBase() {
11
+ if (coreResolved) return coreBasePath;
12
+ coreResolved = true;
13
+ try {
14
+ const pkgPath = __require.resolve("@agentbnb/core/package.json");
15
+ coreBasePath = join(pkgPath, "..");
16
+ return coreBasePath;
17
+ } catch {
18
+ return null;
19
+ }
20
+ }
21
+ function loadCoreConfig(configName) {
22
+ const base = resolveCoreBase();
23
+ if (!base) return null;
24
+ try {
25
+ const filePath = join(base, "config", `${configName}.json`);
26
+ const raw = readFileSync(filePath, "utf8");
27
+ return JSON.parse(raw);
28
+ } catch {
29
+ return null;
30
+ }
31
+ }
32
+
33
+ export {
34
+ loadCoreConfig
35
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  RelayMessageSchema
3
- } from "./chunk-3466S65P.js";
3
+ } from "./chunk-Q5OFZ2JR.js";
4
4
 
5
5
  // src/relay/websocket-client.ts
6
6
  import WebSocket from "ws";
@@ -3,13 +3,16 @@ import {
3
3
  } from "./chunk-3MJT4PZG.js";
4
4
  import {
5
5
  scorePeers
6
- } from "./chunk-UQCQ2JCG.js";
6
+ } from "./chunk-JJHQAZWE.js";
7
7
  import {
8
8
  fetchRemoteCards
9
9
  } from "./chunk-ELFGYC22.js";
10
10
  import {
11
11
  searchCards
12
- } from "./chunk-QEDVPJKP.js";
12
+ } from "./chunk-4DBSSFHG.js";
13
+ import {
14
+ loadCoreConfig
15
+ } from "./chunk-QXRNW4OJ.js";
13
16
  import {
14
17
  requestCapability,
15
18
  requestCapabilityBatch
@@ -321,7 +324,8 @@ async function matchSubTasks(opts) {
321
324
  }
322
325
 
323
326
  // src/conductor/budget-controller.ts
324
- var ORCHESTRATION_FEE = 5;
327
+ var coreConductor = loadCoreConfig("economics");
328
+ var ORCHESTRATION_FEE = coreConductor?.conductor?.orchestration_fee ?? 5;
325
329
  var BudgetController = class {
326
330
  /**
327
331
  * Creates a new BudgetController.
@@ -1,3 +1,6 @@
1
+ import {
2
+ createRequestLogTable
3
+ } from "./chunk-4XTYT4JW.js";
1
4
  import {
2
5
  ensureAgentsTable,
3
6
  resolveCanonicalIdentity
@@ -8,136 +11,6 @@ import {
8
11
  CapabilityCardSchema
9
12
  } from "./chunk-UVCNMRPS.js";
10
13
 
11
- // src/registry/request-log.ts
12
- var SINCE_MS = {
13
- "24h": 864e5,
14
- "7d": 6048e5,
15
- "30d": 2592e6
16
- };
17
- function createRequestLogTable(db) {
18
- db.exec(`
19
- CREATE TABLE IF NOT EXISTS request_log (
20
- id TEXT PRIMARY KEY,
21
- card_id TEXT NOT NULL,
22
- card_name TEXT NOT NULL,
23
- requester TEXT NOT NULL,
24
- status TEXT NOT NULL CHECK(status IN ('success', 'failure', 'timeout')),
25
- latency_ms INTEGER NOT NULL,
26
- credits_charged INTEGER NOT NULL,
27
- created_at TEXT NOT NULL
28
- );
29
-
30
- CREATE INDEX IF NOT EXISTS request_log_created_at_idx
31
- ON request_log (created_at DESC);
32
- `);
33
- try {
34
- db.exec("ALTER TABLE request_log ADD COLUMN skill_id TEXT");
35
- } catch {
36
- }
37
- try {
38
- db.exec("ALTER TABLE request_log ADD COLUMN action_type TEXT");
39
- } catch {
40
- }
41
- try {
42
- db.exec("ALTER TABLE request_log ADD COLUMN tier_invoked INTEGER");
43
- } catch {
44
- }
45
- try {
46
- db.exec("ALTER TABLE request_log ADD COLUMN failure_reason TEXT");
47
- } catch {
48
- }
49
- try {
50
- db.exec("ALTER TABLE request_log ADD COLUMN team_id TEXT");
51
- } catch {
52
- }
53
- try {
54
- db.exec("ALTER TABLE request_log ADD COLUMN role TEXT");
55
- } catch {
56
- }
57
- try {
58
- db.exec("ALTER TABLE request_log ADD COLUMN capability_type TEXT");
59
- } catch {
60
- }
61
- }
62
- function insertRequestLog(db, entry) {
63
- const stmt = db.prepare(`
64
- INSERT INTO request_log (id, card_id, card_name, requester, status, latency_ms, credits_charged, created_at, skill_id, action_type, tier_invoked, failure_reason, team_id, role, capability_type)
65
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
66
- `);
67
- stmt.run(
68
- entry.id,
69
- entry.card_id,
70
- entry.card_name,
71
- entry.requester,
72
- entry.status,
73
- entry.latency_ms,
74
- entry.credits_charged,
75
- entry.created_at,
76
- entry.skill_id ?? null,
77
- entry.action_type ?? null,
78
- entry.tier_invoked ?? null,
79
- entry.failure_reason ?? null,
80
- entry.team_id ?? null,
81
- entry.role ?? null,
82
- entry.capability_type ?? null
83
- );
84
- }
85
- function getSkillRequestCount(db, skillId, windowMs) {
86
- const cutoff = new Date(Date.now() - windowMs).toISOString();
87
- const stmt = db.prepare(
88
- `SELECT COUNT(*) as cnt FROM request_log
89
- WHERE skill_id = ? AND created_at >= ? AND status = 'success' AND action_type IS NULL`
90
- );
91
- const row = stmt.get(skillId, cutoff);
92
- return row.cnt;
93
- }
94
- function getActivityFeed(db, limit = 20, since) {
95
- const effectiveLimit = Math.min(limit, 100);
96
- if (since !== void 0) {
97
- const stmt2 = db.prepare(`
98
- SELECT r.id, r.card_name, r.requester, c.owner AS provider,
99
- r.status, r.credits_charged, r.latency_ms, r.created_at, r.action_type
100
- FROM request_log r
101
- LEFT JOIN capability_cards c ON r.card_id = c.id
102
- WHERE (r.action_type IS NULL OR r.action_type IN ('auto_share', 'agent_joined'))
103
- AND r.created_at > ?
104
- ORDER BY r.created_at DESC
105
- LIMIT ?
106
- `);
107
- return stmt2.all(since, effectiveLimit);
108
- }
109
- const stmt = db.prepare(`
110
- SELECT r.id, r.card_name, r.requester, c.owner AS provider,
111
- r.status, r.credits_charged, r.latency_ms, r.created_at, r.action_type
112
- FROM request_log r
113
- LEFT JOIN capability_cards c ON r.card_id = c.id
114
- WHERE (r.action_type IS NULL OR r.action_type IN ('auto_share', 'agent_joined'))
115
- ORDER BY r.created_at DESC
116
- LIMIT ?
117
- `);
118
- return stmt.all(effectiveLimit);
119
- }
120
- function getRequestLog(db, limit = 10, since) {
121
- if (since !== void 0) {
122
- const cutoff = new Date(Date.now() - SINCE_MS[since]).toISOString();
123
- const stmt2 = db.prepare(`
124
- SELECT id, card_id, card_name, requester, status, latency_ms, credits_charged, created_at, skill_id, action_type, tier_invoked, failure_reason, team_id, role, capability_type
125
- FROM request_log
126
- WHERE created_at >= ?
127
- ORDER BY created_at DESC
128
- LIMIT ?
129
- `);
130
- return stmt2.all(cutoff, limit);
131
- }
132
- const stmt = db.prepare(`
133
- SELECT id, card_id, card_name, requester, status, latency_ms, credits_charged, created_at, skill_id, action_type, tier_invoked, failure_reason, team_id, role
134
- FROM request_log
135
- ORDER BY created_at DESC
136
- LIMIT ?
137
- `);
138
- return stmt.all(limit);
139
- }
140
-
141
14
  // src/registry/store.ts
142
15
  import Database from "better-sqlite3";
143
16
 
@@ -822,10 +695,6 @@ function getCardsBySkillCapability(db, capabilityType) {
822
695
  }
823
696
 
824
697
  export {
825
- insertRequestLog,
826
- getSkillRequestCount,
827
- getActivityFeed,
828
- getRequestLog,
829
698
  insertFeedback,
830
699
  getFeedbackForSkill,
831
700
  getFeedbackForProvider,
@@ -1,165 +1,267 @@
1
+ import {
2
+ loadCoreConfig
3
+ } from "./chunk-QXRNW4OJ.js";
4
+
1
5
  // src/relay/websocket-client.ts
2
6
  import WebSocket from "ws";
3
7
  import { randomUUID } from "crypto";
4
8
 
5
9
  // src/relay/types.ts
10
+ import { z as z2 } from "zod";
11
+
12
+ // src/session/session-types.ts
6
13
  import { z } from "zod";
7
- var RegisterMessageSchema = z.object({
8
- type: z.literal("register"),
9
- owner: z.string().min(1),
14
+ var DEFAULT_SESSION_CONFIG = {
15
+ pricing: {
16
+ default_model: "per_message",
17
+ per_message_base_rate: 2,
18
+ per_minute_base_rate: 1,
19
+ per_session_flat_rate: 10,
20
+ max_messages_per_session: 50,
21
+ max_minutes_per_session: 30
22
+ },
23
+ timeouts: {
24
+ idle_timeout_ms: 12e4,
25
+ max_session_duration_ms: 18e5,
26
+ message_timeout_ms: 9e4
27
+ },
28
+ abuse: {
29
+ max_concurrent_sessions_per_agent: 5,
30
+ max_sessions_per_hour: 20,
31
+ min_message_interval_ms: 1e3
32
+ },
33
+ quality: {
34
+ min_provider_reputation_for_session: 0.5,
35
+ auto_refund_on_timeout: true,
36
+ partial_refund_ratio: 0.5
37
+ }
38
+ };
39
+ function loadSessionConfig() {
40
+ const core = loadCoreConfig("session");
41
+ if (!core) return DEFAULT_SESSION_CONFIG;
42
+ return {
43
+ pricing: { ...DEFAULT_SESSION_CONFIG.pricing, ...core.pricing },
44
+ timeouts: { ...DEFAULT_SESSION_CONFIG.timeouts, ...core.timeouts },
45
+ abuse: { ...DEFAULT_SESSION_CONFIG.abuse, ...core.abuse },
46
+ quality: { ...DEFAULT_SESSION_CONFIG.quality, ...core.quality }
47
+ };
48
+ }
49
+ var SessionPricingModelSchema = z.enum(["per_message", "per_minute", "per_session"]);
50
+ var SessionOpenMessageSchema = z.object({
51
+ type: z.literal("session_open"),
52
+ session_id: z.string().uuid(),
53
+ requester_id: z.string().min(1),
54
+ provider_id: z.string().min(1),
55
+ card_id: z.string().min(1),
56
+ skill_id: z.string().min(1),
57
+ budget: z.number().positive(),
58
+ pricing_model: SessionPricingModelSchema.default("per_message"),
59
+ initial_message: z.string().min(1),
60
+ ucan_token: z.string().optional()
61
+ });
62
+ var SessionAckMessageSchema = z.object({
63
+ type: z.literal("session_ack"),
64
+ session_id: z.string(),
65
+ escrow_id: z.string(),
66
+ status: z.literal("open")
67
+ });
68
+ var SessionMessageMessageSchema = z.object({
69
+ type: z.literal("session_message"),
70
+ session_id: z.string().uuid(),
71
+ sender: z.enum(["requester", "provider"]),
72
+ content: z.string().min(1),
73
+ metadata: z.object({
74
+ model: z.string().optional(),
75
+ latency_ms: z.number().optional(),
76
+ tokens_used: z.number().optional()
77
+ }).optional()
78
+ });
79
+ var SessionEndMessageSchema = z.object({
80
+ type: z.literal("session_end"),
81
+ session_id: z.string().uuid(),
82
+ reason: z.enum(["completed", "timeout", "budget_exhausted", "error", "cancelled"]).default("completed"),
83
+ summary: z.string().optional()
84
+ });
85
+ var SessionSettledMessageSchema = z.object({
86
+ type: z.literal("session_settled"),
87
+ session_id: z.string(),
88
+ total_cost: z.number(),
89
+ messages_count: z.number(),
90
+ duration_seconds: z.number(),
91
+ refunded: z.number()
92
+ });
93
+ var SessionErrorMessageSchema = z.object({
94
+ type: z.literal("session_error"),
95
+ session_id: z.string(),
96
+ code: z.string(),
97
+ message: z.string()
98
+ });
99
+ var SESSION_MESSAGE_TYPES = /* @__PURE__ */ new Set([
100
+ "session_open",
101
+ "session_ack",
102
+ "session_message",
103
+ "session_end",
104
+ "session_settled",
105
+ "session_error"
106
+ ]);
107
+
108
+ // src/relay/types.ts
109
+ var RegisterMessageSchema = z2.object({
110
+ type: z2.literal("register"),
111
+ owner: z2.string().min(1),
10
112
  /** V8: Cryptographic agent identity. When present, used as the canonical key. */
11
- agent_id: z.string().optional(),
113
+ agent_id: z2.string().optional(),
12
114
  /** V8 Phase 3: Server identifier for multi-agent delegation. */
13
- server_id: z.string().optional(),
14
- token: z.string().min(1),
15
- card: z.record(z.unknown()),
115
+ server_id: z2.string().optional(),
116
+ token: z2.string().min(1),
117
+ card: z2.record(z2.unknown()),
16
118
  // CapabilityCard (validated separately)
17
- cards: z.array(z.record(z.unknown())).optional(),
119
+ cards: z2.array(z2.record(z2.unknown())).optional(),
18
120
  // Additional cards (e.g., conductor card)
19
121
  /** V8 Phase 3: Additional agents served by this server (multi-agent registration). */
20
- agents: z.array(z.object({
21
- agent_id: z.string().min(1),
22
- display_name: z.string().min(1),
23
- cards: z.array(z.record(z.unknown())),
24
- delegation_token: z.record(z.unknown()).optional()
122
+ agents: z2.array(z2.object({
123
+ agent_id: z2.string().min(1),
124
+ display_name: z2.string().min(1),
125
+ cards: z2.array(z2.record(z2.unknown())),
126
+ delegation_token: z2.record(z2.unknown()).optional()
25
127
  })).optional()
26
128
  });
27
- var RegisteredMessageSchema = z.object({
28
- type: z.literal("registered"),
29
- agent_id: z.string()
129
+ var RegisteredMessageSchema = z2.object({
130
+ type: z2.literal("registered"),
131
+ agent_id: z2.string()
30
132
  });
31
- var RelayRequestMessageSchema = z.object({
32
- type: z.literal("relay_request"),
33
- id: z.string().uuid(),
34
- target_owner: z.string().min(1),
133
+ var RelayRequestMessageSchema = z2.object({
134
+ type: z2.literal("relay_request"),
135
+ id: z2.string().uuid(),
136
+ target_owner: z2.string().min(1),
35
137
  /** V8: Target agent's cryptographic identity. Preferred over target_owner. */
36
- target_agent_id: z.string().optional(),
37
- card_id: z.string(),
38
- skill_id: z.string().optional(),
39
- params: z.record(z.unknown()).default({}),
40
- requester: z.string().optional(),
41
- escrow_receipt: z.record(z.unknown()).optional(),
138
+ target_agent_id: z2.string().optional(),
139
+ card_id: z2.string(),
140
+ skill_id: z2.string().optional(),
141
+ params: z2.record(z2.unknown()).default({}),
142
+ requester: z2.string().optional(),
143
+ escrow_receipt: z2.record(z2.unknown()).optional(),
42
144
  /** Optional UCAN token for capability delegation. */
43
- ucan_token: z.string().optional()
145
+ ucan_token: z2.string().optional()
44
146
  });
45
- var IncomingRequestMessageSchema = z.object({
46
- type: z.literal("incoming_request"),
47
- id: z.string().uuid(),
48
- from_owner: z.string().min(1),
49
- card_id: z.string(),
50
- skill_id: z.string().optional(),
51
- params: z.record(z.unknown()).default({}),
52
- requester: z.string().optional(),
53
- escrow_receipt: z.record(z.unknown()).optional(),
147
+ var IncomingRequestMessageSchema = z2.object({
148
+ type: z2.literal("incoming_request"),
149
+ id: z2.string().uuid(),
150
+ from_owner: z2.string().min(1),
151
+ card_id: z2.string(),
152
+ skill_id: z2.string().optional(),
153
+ params: z2.record(z2.unknown()).default({}),
154
+ requester: z2.string().optional(),
155
+ escrow_receipt: z2.record(z2.unknown()).optional(),
54
156
  /** Optional UCAN token for capability delegation. */
55
- ucan_token: z.string().optional()
157
+ ucan_token: z2.string().optional()
56
158
  });
57
- var RelayResponseMessageSchema = z.object({
58
- type: z.literal("relay_response"),
59
- id: z.string().uuid(),
60
- result: z.unknown().optional(),
61
- error: z.object({
62
- code: z.number(),
63
- message: z.string()
159
+ var RelayResponseMessageSchema = z2.object({
160
+ type: z2.literal("relay_response"),
161
+ id: z2.string().uuid(),
162
+ result: z2.unknown().optional(),
163
+ error: z2.object({
164
+ code: z2.number(),
165
+ message: z2.string()
64
166
  }).optional()
65
167
  });
66
- var ResponseMessageSchema = z.object({
67
- type: z.literal("response"),
68
- id: z.string().uuid(),
69
- result: z.unknown().optional(),
70
- error: z.object({
71
- code: z.number(),
72
- message: z.string()
168
+ var ResponseMessageSchema = z2.object({
169
+ type: z2.literal("response"),
170
+ id: z2.string().uuid(),
171
+ result: z2.unknown().optional(),
172
+ error: z2.object({
173
+ code: z2.number(),
174
+ message: z2.string()
73
175
  }).optional()
74
176
  });
75
- var ErrorMessageSchema = z.object({
76
- type: z.literal("error"),
77
- code: z.string(),
78
- message: z.string(),
79
- request_id: z.string().optional()
177
+ var ErrorMessageSchema = z2.object({
178
+ type: z2.literal("error"),
179
+ code: z2.string(),
180
+ message: z2.string(),
181
+ request_id: z2.string().optional()
80
182
  });
81
- var RelayProgressMessageSchema = z.object({
82
- type: z.literal("relay_progress"),
83
- id: z.string().uuid(),
183
+ var RelayProgressMessageSchema = z2.object({
184
+ type: z2.literal("relay_progress"),
185
+ id: z2.string().uuid(),
84
186
  // request ID this progress relates to
85
- progress: z.number().min(0).max(100).optional(),
187
+ progress: z2.number().min(0).max(100).optional(),
86
188
  // optional percentage
87
- message: z.string().optional()
189
+ message: z2.string().optional()
88
190
  // optional status message
89
191
  });
90
- var RelayStartedMessageSchema = z.object({
91
- type: z.literal("relay_started"),
92
- id: z.string().uuid(),
93
- message: z.string().optional()
192
+ var RelayStartedMessageSchema = z2.object({
193
+ type: z2.literal("relay_started"),
194
+ id: z2.string().uuid(),
195
+ message: z2.string().optional()
94
196
  });
95
- var HeartbeatMessageSchema = z.object({
96
- type: z.literal("heartbeat"),
97
- owner: z.string().min(1),
98
- capacity: z.object({
99
- current_load: z.number(),
100
- max_concurrent: z.number(),
101
- queue_depth: z.number()
197
+ var HeartbeatMessageSchema = z2.object({
198
+ type: z2.literal("heartbeat"),
199
+ owner: z2.string().min(1),
200
+ capacity: z2.object({
201
+ current_load: z2.number(),
202
+ max_concurrent: z2.number(),
203
+ queue_depth: z2.number()
102
204
  }),
103
- self_summary: z.object({
104
- capabilities: z.array(z.string()),
105
- success_rate: z.number(),
106
- credit_balance: z.number(),
107
- total_completed: z.number(),
108
- provider_number: z.number(),
109
- reliability: z.object({
110
- current_streak: z.number(),
111
- repeat_hire_rate: z.number(),
112
- avg_feedback: z.number()
205
+ self_summary: z2.object({
206
+ capabilities: z2.array(z2.string()),
207
+ success_rate: z2.number(),
208
+ credit_balance: z2.number(),
209
+ total_completed: z2.number(),
210
+ provider_number: z2.number(),
211
+ reliability: z2.object({
212
+ current_streak: z2.number(),
213
+ repeat_hire_rate: z2.number(),
214
+ avg_feedback: z2.number()
113
215
  })
114
216
  })
115
217
  });
116
- var EscrowHoldMessageSchema = z.object({
117
- type: z.literal("escrow_hold"),
118
- consumer_agent_id: z.string().min(1),
119
- provider_agent_id: z.string().min(1),
120
- skill_id: z.string().min(1),
121
- amount: z.number().positive(),
122
- request_id: z.string().uuid(),
123
- signature: z.string().optional(),
124
- public_key: z.string().optional()
218
+ var EscrowHoldMessageSchema = z2.object({
219
+ type: z2.literal("escrow_hold"),
220
+ consumer_agent_id: z2.string().min(1),
221
+ provider_agent_id: z2.string().min(1),
222
+ skill_id: z2.string().min(1),
223
+ amount: z2.number().positive(),
224
+ request_id: z2.string().uuid(),
225
+ signature: z2.string().optional(),
226
+ public_key: z2.string().optional()
125
227
  });
126
- var EscrowHoldConfirmedMessageSchema = z.object({
127
- type: z.literal("escrow_hold_confirmed"),
128
- request_id: z.string(),
129
- escrow_id: z.string(),
130
- hold_amount: z.number(),
131
- consumer_remaining: z.number()
228
+ var EscrowHoldConfirmedMessageSchema = z2.object({
229
+ type: z2.literal("escrow_hold_confirmed"),
230
+ request_id: z2.string(),
231
+ escrow_id: z2.string(),
232
+ hold_amount: z2.number(),
233
+ consumer_remaining: z2.number()
132
234
  });
133
- var EscrowSettleMessageSchema = z.object({
134
- type: z.literal("escrow_settle"),
135
- escrow_id: z.string().min(1),
136
- request_id: z.string().uuid(),
137
- success: z.boolean(),
138
- failure_reason: z.enum(["bad_execution", "overload", "timeout", "auth_error", "not_found"]).optional(),
139
- result_hash: z.string().optional(),
140
- signature: z.string().optional(),
141
- public_key: z.string().optional(),
142
- consumer_agent_id: z.string().optional()
235
+ var EscrowSettleMessageSchema = z2.object({
236
+ type: z2.literal("escrow_settle"),
237
+ escrow_id: z2.string().min(1),
238
+ request_id: z2.string().uuid(),
239
+ success: z2.boolean(),
240
+ failure_reason: z2.enum(["bad_execution", "overload", "timeout", "auth_error", "not_found"]).optional(),
241
+ result_hash: z2.string().optional(),
242
+ signature: z2.string().optional(),
243
+ public_key: z2.string().optional(),
244
+ consumer_agent_id: z2.string().optional()
143
245
  });
144
- var EscrowSettledMessageSchema = z.object({
145
- type: z.literal("escrow_settled"),
146
- escrow_id: z.string(),
147
- request_id: z.string(),
148
- provider_earned: z.number(),
149
- network_fee: z.number(),
150
- consumer_remaining: z.number(),
151
- provider_balance: z.number()
246
+ var EscrowSettledMessageSchema = z2.object({
247
+ type: z2.literal("escrow_settled"),
248
+ escrow_id: z2.string(),
249
+ request_id: z2.string(),
250
+ provider_earned: z2.number(),
251
+ network_fee: z2.number(),
252
+ consumer_remaining: z2.number(),
253
+ provider_balance: z2.number()
152
254
  });
153
- var BalanceSyncMessageSchema = z.object({
154
- type: z.literal("balance_sync"),
155
- agent_id: z.string().min(1)
255
+ var BalanceSyncMessageSchema = z2.object({
256
+ type: z2.literal("balance_sync"),
257
+ agent_id: z2.string().min(1)
156
258
  });
157
- var BalanceSyncResponseMessageSchema = z.object({
158
- type: z.literal("balance_sync_response"),
159
- agent_id: z.string(),
160
- balance: z.number()
259
+ var BalanceSyncResponseMessageSchema = z2.object({
260
+ type: z2.literal("balance_sync_response"),
261
+ agent_id: z2.string(),
262
+ balance: z2.number()
161
263
  });
162
- var RelayMessageSchema = z.discriminatedUnion("type", [
264
+ var RelayMessageSchema = z2.discriminatedUnion("type", [
163
265
  RegisterMessageSchema,
164
266
  RegisteredMessageSchema,
165
267
  RelayRequestMessageSchema,
@@ -175,7 +277,13 @@ var RelayMessageSchema = z.discriminatedUnion("type", [
175
277
  EscrowSettleMessageSchema,
176
278
  EscrowSettledMessageSchema,
177
279
  BalanceSyncMessageSchema,
178
- BalanceSyncResponseMessageSchema
280
+ BalanceSyncResponseMessageSchema,
281
+ SessionOpenMessageSchema,
282
+ SessionAckMessageSchema,
283
+ SessionMessageMessageSchema,
284
+ SessionEndMessageSchema,
285
+ SessionSettledMessageSchema,
286
+ SessionErrorMessageSchema
179
287
  ]);
180
288
 
181
289
  // src/relay/websocket-client.ts
@@ -496,6 +604,11 @@ var RelayClient = class {
496
604
  };
497
605
 
498
606
  export {
607
+ loadSessionConfig,
608
+ SessionOpenMessageSchema,
609
+ SessionMessageMessageSchema,
610
+ SessionEndMessageSchema,
611
+ SESSION_MESSAGE_TYPES,
499
612
  RelayMessageSchema,
500
613
  RelayClient
501
614
  };