@ton/mcp 0.1.15-alpha.2 → 0.1.15-alpha.4
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/cli.js +127 -92
- package/dist/index.cjs +127 -92
- package/dist/index.js +127 -92
- package/dist/serverless.cjs +127 -92
- package/dist/serverless.js +127 -92
- package/dist/utils/agentic.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/serverless.cjs
CHANGED
|
@@ -28058,6 +28058,15 @@ function Base64Normalize(data) {
|
|
|
28058
28058
|
return data.replace(/\s+/g, "").replace(/-/g, "+").replace(/_/g, "/");
|
|
28059
28059
|
}
|
|
28060
28060
|
/**
|
|
28061
|
+
* Make base64url string
|
|
28062
|
+
* @param data Base64url or base64 string
|
|
28063
|
+
* @returns Normalized base64url string
|
|
28064
|
+
* example: a+/ => a-_=
|
|
28065
|
+
*/
|
|
28066
|
+
function Base64NormalizeUrl(data) {
|
|
28067
|
+
return Base64Normalize(data).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
28068
|
+
}
|
|
28069
|
+
/**
|
|
28061
28070
|
* Parse base64 string
|
|
28062
28071
|
* @param data Base64 string
|
|
28063
28072
|
* @returns utf-8 string
|
|
@@ -69479,37 +69488,37 @@ var import_blakejs = /* @__PURE__ */ __toESM(require_blakejs(), 1);
|
|
|
69479
69488
|
function P() {
|
|
69480
69489
|
return typeof process < "u" && !!process.env;
|
|
69481
69490
|
}
|
|
69482
|
-
function B(
|
|
69483
|
-
return process?.env?.[
|
|
69491
|
+
function B(i) {
|
|
69492
|
+
return process?.env?.[i];
|
|
69484
69493
|
}
|
|
69485
|
-
var O = P() && !B("TONBRIDGE_DEBUG"), s = (...
|
|
69486
|
-
O || console.debug("[TON_CONNECT_BRIDGE_SDK]", ...
|
|
69487
|
-
}, b = (...
|
|
69488
|
-
console.error("[TON_CONNECT_BRIDGE_SDK]", ...
|
|
69494
|
+
var O = P() && !B("TONBRIDGE_DEBUG"), s = (...i) => {
|
|
69495
|
+
O || console.debug("[TON_CONNECT_BRIDGE_SDK]", ...i);
|
|
69496
|
+
}, b = (...i) => {
|
|
69497
|
+
console.error("[TON_CONNECT_BRIDGE_SDK]", ...i);
|
|
69489
69498
|
};
|
|
69490
|
-
var a = class
|
|
69499
|
+
var a = class i extends Error {
|
|
69491
69500
|
static prefix = "[BRIDGE_SDK_ERROR]";
|
|
69492
69501
|
constructor(e, t) {
|
|
69493
|
-
super(e, t), this.message = `${
|
|
69494
|
-
` + e : ""}`, s(this.message), Object.setPrototypeOf(this,
|
|
69502
|
+
super(e, t), this.message = `${i.prefix} ${e ? `
|
|
69503
|
+
` + e : ""}`, s(this.message), Object.setPrototypeOf(this, i.prototype);
|
|
69495
69504
|
}
|
|
69496
69505
|
};
|
|
69497
|
-
function k(
|
|
69498
|
-
return
|
|
69506
|
+
function k(i) {
|
|
69507
|
+
return i.slice(-1) === "/" ? i.slice(0, -1) : i;
|
|
69499
69508
|
}
|
|
69500
|
-
function
|
|
69501
|
-
return k(
|
|
69509
|
+
function v(i, e) {
|
|
69510
|
+
return k(i) + "/" + e;
|
|
69502
69511
|
}
|
|
69503
|
-
function p(
|
|
69512
|
+
function p(i) {
|
|
69504
69513
|
let e = new AbortController();
|
|
69505
|
-
return
|
|
69514
|
+
return i?.aborted ? e.abort() : i?.addEventListener("abort", () => e.abort(), { once: true }), e;
|
|
69506
69515
|
}
|
|
69507
|
-
function
|
|
69516
|
+
function M(i, e) {
|
|
69508
69517
|
let t = null, r = null, n = null;
|
|
69509
69518
|
return {
|
|
69510
69519
|
create: async (d, ...u) => {
|
|
69511
69520
|
if (n?.abort(), n = p(d), n.signal.aborted) throw new a("Resource creation was aborted");
|
|
69512
|
-
let m =
|
|
69521
|
+
let m = i(n.signal, ...u);
|
|
69513
69522
|
r = m;
|
|
69514
69523
|
let g = await m;
|
|
69515
69524
|
if (r !== m && g !== t) throw await e(g), new a("Resource creation was aborted by a new resource creation");
|
|
@@ -69530,9 +69539,9 @@ function D(o, e) {
|
|
|
69530
69539
|
}
|
|
69531
69540
|
};
|
|
69532
69541
|
}
|
|
69533
|
-
function
|
|
69542
|
+
function D(i, e) {
|
|
69534
69543
|
let t = e?.timeout, r = e?.signal, n = p(r);
|
|
69535
|
-
return new Promise(async (
|
|
69544
|
+
return new Promise(async (o, c) => {
|
|
69536
69545
|
if (r?.aborted) {
|
|
69537
69546
|
c(new a("Timeout aborted before setTimeout"));
|
|
69538
69547
|
return;
|
|
@@ -69542,8 +69551,8 @@ function M(o, e) {
|
|
|
69542
69551
|
n.abort(), c(new a(`Timeout after ${t}ms`));
|
|
69543
69552
|
}, t)), n.signal.addEventListener("abort", () => {
|
|
69544
69553
|
l && (clearTimeout(l), l = void 0, c(new a("Timeout aborted after setTimeout")));
|
|
69545
|
-
}, { once: true }), await
|
|
69546
|
-
clearTimeout(l), l = void 0,
|
|
69554
|
+
}, { once: true }), await i((...d) => {
|
|
69555
|
+
clearTimeout(l), l = void 0, o(...d);
|
|
69547
69556
|
}, (d) => {
|
|
69548
69557
|
clearTimeout(l), l = void 0, c(d);
|
|
69549
69558
|
}, {
|
|
@@ -69552,22 +69561,23 @@ function M(o, e) {
|
|
|
69552
69561
|
});
|
|
69553
69562
|
});
|
|
69554
69563
|
}
|
|
69555
|
-
var
|
|
69556
|
-
constructor(e, t, r, n,
|
|
69564
|
+
var y = class i {
|
|
69565
|
+
constructor(e, t, r, n, o, c, l) {
|
|
69557
69566
|
this.bridgeUrl = e;
|
|
69558
69567
|
this.sessionIds = t;
|
|
69559
69568
|
this.listener = r;
|
|
69560
69569
|
this.errorsListener = n;
|
|
69561
|
-
this.lastEventId =
|
|
69570
|
+
this.lastEventId = o;
|
|
69562
69571
|
this.heartbeatFormat = c;
|
|
69563
69572
|
this.enableQueueDoneEvent = l;
|
|
69564
69573
|
}
|
|
69565
69574
|
static ssePath = "events";
|
|
69566
69575
|
static postPath = "message";
|
|
69576
|
+
static verifyPath = "verify";
|
|
69567
69577
|
static defaultTtl = 300;
|
|
69568
|
-
eventSource =
|
|
69578
|
+
eventSource = M(async (e, t) => await U({
|
|
69569
69579
|
bridgeUrl: this.bridgeUrl,
|
|
69570
|
-
ssePath:
|
|
69580
|
+
ssePath: i.ssePath,
|
|
69571
69581
|
sessionIds: this.sessionIds,
|
|
69572
69582
|
errorHandler: this.errorsHandler.bind(this),
|
|
69573
69583
|
messageHandler: this.messagesHandler.bind(this),
|
|
@@ -69589,7 +69599,7 @@ var v = class o {
|
|
|
69589
69599
|
return this.eventSource.current()?.readyState === EventSource.CONNECTING;
|
|
69590
69600
|
}
|
|
69591
69601
|
static async open(e) {
|
|
69592
|
-
let t = new
|
|
69602
|
+
let t = new i(e.bridgeUrl, e.sessionIds, e.listener, e.errorsListener, e.lastEventId, e.heartbeatFormat, e.enableQueueDoneEvent);
|
|
69593
69603
|
try {
|
|
69594
69604
|
return await t.registerSession(e.options), t;
|
|
69595
69605
|
} catch (r) {
|
|
@@ -69599,14 +69609,25 @@ var v = class o {
|
|
|
69599
69609
|
async registerSession(e) {
|
|
69600
69610
|
await this.eventSource.create(e?.signal, e?.connectingDeadlineMS);
|
|
69601
69611
|
}
|
|
69602
|
-
static async
|
|
69603
|
-
let
|
|
69604
|
-
|
|
69605
|
-
|
|
69606
|
-
|
|
69612
|
+
static async verifyRequest(e, t, r) {
|
|
69613
|
+
let n = new URL(v(e, this.verifyPath));
|
|
69614
|
+
return { status: (await (await this.post(n, {
|
|
69615
|
+
client_id: t.clientId,
|
|
69616
|
+
url: t.url,
|
|
69617
|
+
type: t.type
|
|
69618
|
+
}, r?.signal)).json()).status };
|
|
69619
|
+
}
|
|
69620
|
+
static async sendRequest(e, t, r, n, o) {
|
|
69621
|
+
let c = new URL(v(e, this.postPath));
|
|
69622
|
+
c.searchParams.append("client_id", r), c.searchParams.append("to", n), c.searchParams.append("ttl", (o?.ttl ?? i.defaultTtl).toString()), o?.topic && c.searchParams.append("topic", o.topic), o?.traceId && c.searchParams.append("trace_id", o.traceId);
|
|
69623
|
+
let l = Base64.encode(t);
|
|
69624
|
+
await this.post(c, l, o?.signal);
|
|
69625
|
+
}
|
|
69626
|
+
async verify(e, t) {
|
|
69627
|
+
return i.verifyRequest(this.bridgeUrl, e, t);
|
|
69607
69628
|
}
|
|
69608
69629
|
async send(e, t, r, n) {
|
|
69609
|
-
return
|
|
69630
|
+
return i.sendRequest(this.bridgeUrl, e, t, r, n);
|
|
69610
69631
|
}
|
|
69611
69632
|
async close() {
|
|
69612
69633
|
await this.eventSource.dispose().catch((e) => {
|
|
@@ -69622,10 +69643,11 @@ var v = class o {
|
|
|
69622
69643
|
static async post(e, t, r) {
|
|
69623
69644
|
let n = await fetch(e, {
|
|
69624
69645
|
method: "post",
|
|
69625
|
-
body: t,
|
|
69626
|
-
signal: r
|
|
69646
|
+
body: typeof t == "object" ? JSON.stringify(t) : t,
|
|
69647
|
+
signal: r,
|
|
69648
|
+
headers: typeof t == "object" ? { "Content-Type": "application/json" } : void 0
|
|
69627
69649
|
});
|
|
69628
|
-
if (!n.ok) throw new a(`Bridge
|
|
69650
|
+
if (!n.ok) throw new a(`Bridge post failed, status ${n.status}`);
|
|
69629
69651
|
return n;
|
|
69630
69652
|
}
|
|
69631
69653
|
async errorsHandler(e, t) {
|
|
@@ -69635,96 +69657,96 @@ var v = class o {
|
|
|
69635
69657
|
this.listener(e);
|
|
69636
69658
|
}
|
|
69637
69659
|
};
|
|
69638
|
-
async function U(
|
|
69639
|
-
let { lastEventId: e, heartbeatFormat: t, enableQueueDoneEvent: r } =
|
|
69640
|
-
return await
|
|
69660
|
+
async function U(i) {
|
|
69661
|
+
let { lastEventId: e, heartbeatFormat: t, enableQueueDoneEvent: r } = i;
|
|
69662
|
+
return await D(async (n, o, c) => {
|
|
69641
69663
|
let { signal: l } = c;
|
|
69642
69664
|
if (s("[BridgeGateway] Connecting to bridge SSE..."), l?.aborted) {
|
|
69643
|
-
|
|
69665
|
+
o(new a("Bridge connection aborted before connection"));
|
|
69644
69666
|
return;
|
|
69645
69667
|
}
|
|
69646
|
-
let d = new URL(
|
|
69647
|
-
if (d.searchParams.append("client_id",
|
|
69648
|
-
|
|
69668
|
+
let d = new URL(v(i.bridgeUrl, i.ssePath));
|
|
69669
|
+
if (d.searchParams.append("client_id", i.sessionIds.join(",")), e && d.searchParams.append("last_event_id", e), t && d.searchParams.append("heartbeat", t), r && d.searchParams.append("enable_queue_done_event", "true"), l?.aborted) {
|
|
69670
|
+
o(new a("Bridge connection aborted after building url"));
|
|
69649
69671
|
return;
|
|
69650
69672
|
}
|
|
69651
69673
|
s("[BridgeGateway] Initializing EventSource instance...");
|
|
69652
69674
|
let u = new EventSource(d.toString()), m = false;
|
|
69653
69675
|
u.onerror = async (g) => {
|
|
69654
69676
|
if (s("[BridgeGateway] EventSource error occurred:", JSON.stringify(g)), l?.aborted) {
|
|
69655
|
-
u.close(),
|
|
69677
|
+
u.close(), o(new a("Bridge connection aborted on error callback"));
|
|
69656
69678
|
return;
|
|
69657
69679
|
}
|
|
69658
69680
|
if (!m) {
|
|
69659
|
-
u.close(),
|
|
69681
|
+
u.close(), o(new a("Bridge error before connecting"));
|
|
69660
69682
|
return;
|
|
69661
69683
|
}
|
|
69662
69684
|
try {
|
|
69663
|
-
u.close(), await
|
|
69664
|
-
} catch (
|
|
69665
|
-
u.close(),
|
|
69685
|
+
u.close(), await i.errorHandler(u, g);
|
|
69686
|
+
} catch (I) {
|
|
69687
|
+
u.close(), o(I);
|
|
69666
69688
|
}
|
|
69667
69689
|
}, u.onopen = () => {
|
|
69668
69690
|
if (l?.aborted) {
|
|
69669
|
-
u.close(),
|
|
69691
|
+
u.close(), o(new a("Bridge connection aborted on open"));
|
|
69670
69692
|
return;
|
|
69671
69693
|
}
|
|
69672
69694
|
m = true, s("[BridgeGateway] EventSource connection established."), n(u);
|
|
69673
69695
|
}, u.onmessage = (g) => {
|
|
69674
69696
|
if (l?.aborted) {
|
|
69675
|
-
u.close(),
|
|
69697
|
+
u.close(), o(new a("Bridge connection aborted on message"));
|
|
69676
69698
|
return;
|
|
69677
69699
|
}
|
|
69678
|
-
e = g.lastEventId,
|
|
69679
|
-
},
|
|
69680
|
-
u.close(),
|
|
69700
|
+
e = g.lastEventId, i.messageHandler(g);
|
|
69701
|
+
}, i.signal?.addEventListener("abort", () => {
|
|
69702
|
+
u.close(), o(new a("Bridge connection aborted"));
|
|
69681
69703
|
}, { once: true });
|
|
69682
69704
|
}, {
|
|
69683
|
-
timeout:
|
|
69684
|
-
signal:
|
|
69705
|
+
timeout: i.connectingDeadlineMS,
|
|
69706
|
+
signal: i.signal
|
|
69685
69707
|
});
|
|
69686
69708
|
}
|
|
69687
|
-
async function
|
|
69709
|
+
async function h(i, e) {
|
|
69688
69710
|
if (e?.signal?.aborted) throw new a("Delay aborted before setTimeout");
|
|
69689
69711
|
return new Promise((t, r) => {
|
|
69690
|
-
let n = setTimeout(t,
|
|
69712
|
+
let n = setTimeout(t, i);
|
|
69691
69713
|
e?.signal?.addEventListener("abort", () => {
|
|
69692
69714
|
clearTimeout(n), r(new a("Delay aborted after setTimeout"));
|
|
69693
69715
|
}, { once: true });
|
|
69694
69716
|
});
|
|
69695
69717
|
}
|
|
69696
|
-
async function
|
|
69718
|
+
async function f(i, e) {
|
|
69697
69719
|
let { signal: t, attempts: r = 10, delayMs: n = 100 } = e ?? {};
|
|
69698
|
-
if (typeof
|
|
69699
|
-
let
|
|
69700
|
-
for (;
|
|
69701
|
-
if (s(`[callForSuccess] Attempt: ${
|
|
69720
|
+
if (typeof i != "function") throw new a(`Expected a function, got ${typeof i}`);
|
|
69721
|
+
let o = 0, c;
|
|
69722
|
+
for (; o < r;) {
|
|
69723
|
+
if (s(`[callForSuccess] Attempt: ${o}`), t?.aborted) throw new a(`Aborted after attempts ${o}`);
|
|
69702
69724
|
try {
|
|
69703
|
-
return await
|
|
69725
|
+
return await i({ signal: t });
|
|
69704
69726
|
} catch (l) {
|
|
69705
|
-
s(`[callForSuccess], error after attempt ${
|
|
69727
|
+
s(`[callForSuccess], error after attempt ${o}, ${/* @__PURE__ */ new Date()}: ${JSON.stringify(l)}`, l), c = l, o++, o < r && (await h(n, { signal: t }), e?.exponential && (n = Math.min(n * 2, e.maxDelayMs ?? Number.MAX_SAFE_INTEGER)));
|
|
69706
69728
|
}
|
|
69707
69729
|
}
|
|
69708
69730
|
throw c;
|
|
69709
69731
|
}
|
|
69710
|
-
function
|
|
69711
|
-
return [...new Set(
|
|
69732
|
+
function x(i) {
|
|
69733
|
+
return [...new Set(i)];
|
|
69712
69734
|
}
|
|
69713
|
-
function
|
|
69714
|
-
let t = new Set(
|
|
69735
|
+
function T(i, e) {
|
|
69736
|
+
let t = new Set(i), r = new Set(e);
|
|
69715
69737
|
if (t.size !== r.size) return false;
|
|
69716
69738
|
for (let n of t) if (!r.has(n)) return false;
|
|
69717
69739
|
return true;
|
|
69718
69740
|
}
|
|
69719
|
-
function G(
|
|
69741
|
+
function G(i, e) {
|
|
69720
69742
|
let t = import_blakejs.default.blake2bInit(import_nacl_fast.default.box.nonceLength);
|
|
69721
|
-
return import_blakejs.default.blake2bUpdate(t,
|
|
69743
|
+
return import_blakejs.default.blake2bUpdate(t, i), import_blakejs.default.blake2bUpdate(t, e), import_blakejs.default.blake2bFinal(t);
|
|
69722
69744
|
}
|
|
69723
|
-
function
|
|
69724
|
-
let r =
|
|
69725
|
-
return import_nacl_fast.default.box.open(
|
|
69745
|
+
function R(i, e, t) {
|
|
69746
|
+
let r = i.subarray(0, import_nacl_fast.default.box.publicKeyLength), n = G(r, e), o = i.subarray(import_nacl_fast.default.box.publicKeyLength);
|
|
69747
|
+
return import_nacl_fast.default.box.open(o, n, r, t);
|
|
69726
69748
|
}
|
|
69727
|
-
var C = class
|
|
69749
|
+
var C = class i {
|
|
69728
69750
|
constructor(e, t = null, r = null, n = void 0) {
|
|
69729
69751
|
this.bridgeUrl = e;
|
|
69730
69752
|
this.listener = t;
|
|
@@ -69747,7 +69769,7 @@ var C = class o {
|
|
|
69747
69769
|
heartbeatTimer = null;
|
|
69748
69770
|
connectionOptions = {};
|
|
69749
69771
|
static async open(e) {
|
|
69750
|
-
let t = new
|
|
69772
|
+
let t = new i(e.bridgeUrl, e.listener, e.errorListener, e.options?.heartbeatReconnectIntervalMs);
|
|
69751
69773
|
e.onConnecting && (t.onConnecting = e.onConnecting), e.onQueueDone && (t.onQueueDone = e.onQueueDone);
|
|
69752
69774
|
try {
|
|
69753
69775
|
return await t.restoreConnection(e.clients, e.options), t;
|
|
@@ -69770,8 +69792,8 @@ var C = class o {
|
|
|
69770
69792
|
let { signal: r } = p(e);
|
|
69771
69793
|
this.lastHeartbeatAt = Date.now();
|
|
69772
69794
|
let n = (c) => {
|
|
69773
|
-
this.heartbeatTimer = setTimeout(
|
|
69774
|
-
},
|
|
69795
|
+
this.heartbeatTimer = setTimeout(o, c);
|
|
69796
|
+
}, o = async () => {
|
|
69775
69797
|
if (r.aborted) {
|
|
69776
69798
|
this.stopHeartbeatWatcher();
|
|
69777
69799
|
return;
|
|
@@ -69780,7 +69802,7 @@ var C = class o {
|
|
|
69780
69802
|
n(this.heartbeatReconnectIntervalMs / 2);
|
|
69781
69803
|
return;
|
|
69782
69804
|
}
|
|
69783
|
-
if (await
|
|
69805
|
+
if (await h(this.missedHeartbeatDelay, { signal: r }), r.aborted) {
|
|
69784
69806
|
this.stopHeartbeatWatcher();
|
|
69785
69807
|
return;
|
|
69786
69808
|
}
|
|
@@ -69826,7 +69848,7 @@ var C = class o {
|
|
|
69826
69848
|
this.startHeartbeatWatcher(t?.signal);
|
|
69827
69849
|
}
|
|
69828
69850
|
async updateClients(e, t) {
|
|
69829
|
-
|
|
69851
|
+
T(this.clients.map((o) => o.session.sessionId), e.map((o) => o.session.sessionId)) || (this.clients = e, await this.restoreConnection(e, {
|
|
69830
69852
|
...this.connectionOptions,
|
|
69831
69853
|
signal: t?.signal
|
|
69832
69854
|
}));
|
|
@@ -69842,7 +69864,7 @@ var C = class o {
|
|
|
69842
69864
|
return;
|
|
69843
69865
|
}
|
|
69844
69866
|
let t = this.connectionOptions;
|
|
69845
|
-
await
|
|
69867
|
+
await f(({ signal: r }) => this.openGateway(this.clients.map((n) => n.session), {
|
|
69846
69868
|
lastEventId: this.lastEventId,
|
|
69847
69869
|
connectingDeadlineMS: t?.connectingDeadlineMs ?? this.defaultConnectingDeadlineMS,
|
|
69848
69870
|
signal: r
|
|
@@ -69854,14 +69876,23 @@ var C = class o {
|
|
|
69854
69876
|
maxDelayMs: t?.maxDelayMs ?? this.defaultMaxExponentialDelayMS
|
|
69855
69877
|
});
|
|
69856
69878
|
}
|
|
69879
|
+
async verify(e, t) {
|
|
69880
|
+
return f(async ({ signal: r }) => y.verifyRequest(this.bridgeUrl, e, { signal: r }), {
|
|
69881
|
+
attempts: t?.attempts ?? Number.MAX_SAFE_INTEGER,
|
|
69882
|
+
delayMs: t?.delayMs ?? this.defaultRetryDelayMs,
|
|
69883
|
+
signal: t?.signal,
|
|
69884
|
+
exponential: t?.exponential ?? true,
|
|
69885
|
+
maxDelayMs: t?.maxDelayMs ?? this.defaultMaxExponentialDelayMS
|
|
69886
|
+
});
|
|
69887
|
+
}
|
|
69857
69888
|
async send(e, t, r, n) {
|
|
69858
69889
|
if (n?.signal?.aborted) {
|
|
69859
69890
|
s("[BridgeProvider] Send aborted before encryption.");
|
|
69860
69891
|
return;
|
|
69861
69892
|
}
|
|
69862
|
-
let
|
|
69863
|
-
await
|
|
69864
|
-
await
|
|
69893
|
+
let o = t.encrypt(JSON.stringify(e), hexToByteArray(r)), c = n?.topic ?? ("method" in e ? e.method : void 0);
|
|
69894
|
+
await f(async ({ signal: l }) => {
|
|
69895
|
+
await y.sendRequest(this.bridgeUrl, o, t.sessionId, r, {
|
|
69865
69896
|
traceId: n?.traceId,
|
|
69866
69897
|
topic: c,
|
|
69867
69898
|
signal: l,
|
|
@@ -69906,7 +69937,7 @@ var C = class o {
|
|
|
69906
69937
|
}
|
|
69907
69938
|
loadMaybeSource(e, t) {
|
|
69908
69939
|
if (!t) return;
|
|
69909
|
-
let r =
|
|
69940
|
+
let r = R(Base64.decode(t).toUint8Array(), hexToByteArray(e.sessionId), hexToByteArray(e.stringifyKeypair().secretKey));
|
|
69910
69941
|
if (!r) throw new Error("Decrypt error ");
|
|
69911
69942
|
let n = JSON.parse(new TextDecoder().decode(r));
|
|
69912
69943
|
return {
|
|
@@ -69933,13 +69964,13 @@ var C = class o {
|
|
|
69933
69964
|
this.errorListener?.(new a(`Failed to parse message: ${e.data}`));
|
|
69934
69965
|
return;
|
|
69935
69966
|
}
|
|
69936
|
-
let r = this.getCryptoSession(t.from), n = JSON.parse(r.decrypt(Base64.decode(t.message).toUint8Array(), hexToByteArray(t.from))),
|
|
69967
|
+
let r = this.getCryptoSession(t.from), n = JSON.parse(r.decrypt(Base64.decode(t.message).toUint8Array(), hexToByteArray(t.from))), o = this.loadMaybeSource(r, t.request_source);
|
|
69937
69968
|
s("[BridgeProvider] Incoming message decrypted:", n), this.lastEventId = e.lastEventId, this.listener?.({
|
|
69938
69969
|
lastEventId: e.lastEventId,
|
|
69939
69970
|
traceId: t.trace_id,
|
|
69940
69971
|
...n,
|
|
69941
69972
|
from: t.from,
|
|
69942
|
-
requestSource:
|
|
69973
|
+
requestSource: o,
|
|
69943
69974
|
connectSource: t.connect_source
|
|
69944
69975
|
});
|
|
69945
69976
|
}
|
|
@@ -69964,7 +69995,7 @@ var C = class o {
|
|
|
69964
69995
|
s("[BridgeProvider] Open gateway aborted after close.");
|
|
69965
69996
|
return;
|
|
69966
69997
|
}
|
|
69967
|
-
this.gateway = new
|
|
69998
|
+
this.gateway = new y(this.bridgeUrl, x(e.map(({ sessionId: r }) => r)), this.gatewayListener.bind(this), this.gatewayErrorsListener.bind(this), this.lastEventId, "message", true), s("[BridgeProvider] BridgeGateway created. Connecting to bridge..."), this.onConnectingCallback?.(), await this.gateway.registerSession({
|
|
69968
69999
|
connectingDeadlineMS: t?.connectingDeadlineMS,
|
|
69969
70000
|
signal: t?.signal
|
|
69970
70001
|
}), s("[BridgeProvider] Connected to bridge successfully.");
|
|
@@ -109526,11 +109557,15 @@ async function resolveOperatorCredentials(privateKey, expectedPublicKey, deps) {
|
|
|
109526
109557
|
}
|
|
109527
109558
|
function buildAgenticCreateDeepLink(input) {
|
|
109528
109559
|
const url = new URL("/create", AGENTIC_DASHBOARD_BASE_URL);
|
|
109529
|
-
|
|
109530
|
-
|
|
109531
|
-
|
|
109532
|
-
|
|
109533
|
-
if (input.
|
|
109560
|
+
const payload = {
|
|
109561
|
+
originOperatorPublicKey: input.operatorPublicKey,
|
|
109562
|
+
callbackUrl: input.callbackUrl
|
|
109563
|
+
};
|
|
109564
|
+
if (input.agentName?.trim()) payload.agentName = input.agentName.trim();
|
|
109565
|
+
if (input.source?.trim()) payload.source = input.source.trim();
|
|
109566
|
+
if (input.tonDeposit?.trim()) payload.tonDeposit = input.tonDeposit.trim();
|
|
109567
|
+
const payloadBytes = new TextEncoder().encode(JSON.stringify(payload));
|
|
109568
|
+
url.searchParams.set("data", Base64NormalizeUrl(Uint8ArrayToBase64(payloadBytes)));
|
|
109534
109569
|
return url.toString();
|
|
109535
109570
|
}
|
|
109536
109571
|
function buildAgenticDashboardLink(address) {
|