@nekzus/liop 2.4.0-alpha.25 → 2.4.0-alpha.26

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 (61) hide show
  1. package/dist/bin/agent.js +27 -933
  2. package/dist/bridge.js +1 -5
  3. package/dist/chunk-2XHSALII.js +3 -0
  4. package/dist/chunk-2ZYX736J.js +2 -0
  5. package/dist/chunk-3WRKTVOF.js +2 -0
  6. package/dist/chunk-6KFKO6ZX.js +2 -0
  7. package/dist/chunk-6VK2XALI.js +2 -0
  8. package/dist/chunk-AYDF3IFZ.js +2 -0
  9. package/dist/chunk-CTTTLCGL.js +31 -0
  10. package/dist/chunk-ECRS6N33.js +4 -0
  11. package/dist/chunk-FDJMH4CB.js +2 -0
  12. package/dist/chunk-FTF6AMF6.js +0 -1
  13. package/dist/chunk-GWVSCZUS.js +2 -0
  14. package/dist/chunk-LEXMMIQI.js +15 -0
  15. package/dist/chunk-LM26HOJ6.js +31 -0
  16. package/dist/chunk-MQ5SU26J.js +2 -0
  17. package/dist/chunk-N35BC62H.js +2 -0
  18. package/dist/chunk-P6IJ3VBD.js +3 -0
  19. package/dist/chunk-TKLRW52V.js +2 -0
  20. package/dist/chunk-V35CXJQN.js +2 -0
  21. package/dist/chunk-WP5ER7RH.js +3 -0
  22. package/dist/chunk-XLVEDKM6.js +2 -0
  23. package/dist/chunk-Y675R34Z.js +2 -0
  24. package/dist/chunk-YD2AF2M6.js +46 -0
  25. package/dist/chunk-YLCNV764.js +3 -0
  26. package/dist/chunk-ZZMSFCJP.js +3 -0
  27. package/dist/client.js +1 -12
  28. package/dist/gateway.js +1 -13
  29. package/dist/index.js +4 -320
  30. package/dist/kyber-PULV7PQX.js +2 -0
  31. package/dist/mesh.js +1 -5
  32. package/dist/server.js +1 -10
  33. package/dist/types.js +1 -3
  34. package/dist/verifier-J4NQYZX5.js +2 -0
  35. package/dist/workers/logic-execution.js +1 -355
  36. package/dist/workers/zk-verifier.js +1 -275
  37. package/package.json +1 -1
  38. package/dist/chunk-3664H3CV.js +0 -136
  39. package/dist/chunk-3QH44NKZ.js +0 -115
  40. package/dist/chunk-6MYJBM2E.js +0 -818
  41. package/dist/chunk-7PITYWOV.js +0 -68
  42. package/dist/chunk-DSOB2JKM.js +0 -1507
  43. package/dist/chunk-ET6VRUK2.js +0 -58
  44. package/dist/chunk-FIVRGOA4.js +0 -280
  45. package/dist/chunk-IHKKWXHJ.js +0 -876
  46. package/dist/chunk-IK7CGWAZ.js +0 -24
  47. package/dist/chunk-JPWC6XG6.js +0 -941
  48. package/dist/chunk-K3DGJLUY.js +0 -106
  49. package/dist/chunk-KR5UZUEY.js +0 -98
  50. package/dist/chunk-NXCAFF73.js +0 -59
  51. package/dist/chunk-Q3FKHJ3B.js +0 -345
  52. package/dist/chunk-R52TZEIL.js +0 -426
  53. package/dist/chunk-S3RAZTEM.js +0 -807
  54. package/dist/chunk-V47P2AQR.js +0 -281
  55. package/dist/chunk-WXOWJXY6.js +0 -564
  56. package/dist/chunk-WXYDFCIW.js +0 -293
  57. package/dist/chunk-Y62GORQF.js +0 -51
  58. package/dist/chunk-ZP3VVXOI.js +0 -66
  59. package/dist/chunk-ZU3WVVLC.js +0 -3752
  60. package/dist/kyber-CGOA7Q6A.js +0 -3
  61. package/dist/verifier-55HW6AFN.js +0 -6
@@ -1,281 +0,0 @@
1
- import { TOOL_ALIASES } from './chunk-KR5UZUEY.js';
2
- import { log } from './chunk-K3DGJLUY.js';
3
-
4
- // src/runtime/routing-table.ts
5
- var RoutingTable = class _RoutingTable {
6
- routes = /* @__PURE__ */ new Map();
7
- static MAX_FAILURES = 5;
8
- /**
9
- * Registers or updates a collection of tools exposed via an HTTP Gateway.
10
- */
11
- registerGatewayTools(tools, mcpEndpoint, authRequired = true) {
12
- for (const tool of tools) {
13
- const existing = this.routes.get(tool.name);
14
- this.routes.set(tool.name, {
15
- name: tool.name,
16
- provider: "http-gateway",
17
- endpoint: mcpEndpoint,
18
- description: tool.description ?? existing?.description,
19
- inputSchema: tool.inputSchema ?? existing?.inputSchema,
20
- latencyMs: existing?.latencyMs ?? 0,
21
- failCount: 0,
22
- lastSuccess: existing?.lastSuccess ?? Date.now(),
23
- authRequired
24
- });
25
- }
26
- log.info(
27
- `[RoutingTable] Registered ${tools.length} tool(s) via HTTP Gateway (${mcpEndpoint})`
28
- );
29
- }
30
- /**
31
- * Registers tools discovered directly over the P2P Mesh (gRPC).
32
- */
33
- registerMeshTools(tools, grpcTarget, authRequired = false) {
34
- for (const tool of tools) {
35
- const existing = this.routes.get(tool.name);
36
- if (existing && existing.provider === "http-gateway" && existing.failCount === 0) {
37
- continue;
38
- }
39
- this.routes.set(tool.name, {
40
- name: tool.name,
41
- provider: "p2p-grpc",
42
- endpoint: grpcTarget,
43
- description: tool.description ?? existing?.description,
44
- inputSchema: tool.inputSchema ?? existing?.inputSchema,
45
- latencyMs: existing?.latencyMs ?? 0,
46
- failCount: 0,
47
- lastSuccess: existing?.lastSuccess ?? Date.now(),
48
- authRequired
49
- });
50
- }
51
- log.info(
52
- `[RoutingTable] Registered ${tools.length} tool(s) via P2P Mesh gRPC (${grpcTarget})`
53
- );
54
- }
55
- /**
56
- * Registers an in-process local tool (e.g. LiopMeshStatus).
57
- */
58
- registerLocalTool(tool) {
59
- this.routes.set(tool.name, {
60
- name: tool.name,
61
- provider: "local",
62
- endpoint: "in-process",
63
- description: tool.description,
64
- inputSchema: tool.inputSchema,
65
- latencyMs: 0,
66
- failCount: 0,
67
- lastSuccess: Date.now(),
68
- authRequired: false
69
- });
70
- }
71
- /**
72
- * Resolves the optimal route for a specific tool.
73
- */
74
- resolve(toolName) {
75
- const targetName = TOOL_ALIASES[toolName] || toolName;
76
- const route = this.routes.get(targetName) ?? this.routes.get(toolName);
77
- if (!route) return void 0;
78
- if (route.failCount >= _RoutingTable.MAX_FAILURES) {
79
- log.warn(
80
- `[RoutingTable] Tool '${toolName}' route has tripped circuit breaker (${route.failCount} consecutive failures).`
81
- );
82
- }
83
- return route;
84
- }
85
- /**
86
- * Records a successful invocation on a route, resetting failures and updating latency.
87
- */
88
- recordSuccess(toolName, latencyMs) {
89
- const route = this.routes.get(toolName);
90
- if (route) {
91
- route.failCount = 0;
92
- route.latencyMs = latencyMs;
93
- route.lastSuccess = Date.now();
94
- }
95
- }
96
- /**
97
- * Records a failed invocation on a route.
98
- */
99
- recordFailure(toolName) {
100
- const route = this.routes.get(toolName);
101
- if (route) {
102
- route.failCount += 1;
103
- log.warn(
104
- `[RoutingTable] Failure recorded for tool '${toolName}' (failCount: ${route.failCount})`
105
- );
106
- }
107
- }
108
- /**
109
- * Lists all registered tools in sorted format for tools/list.
110
- */
111
- getAllToolDefinitions() {
112
- const list = [];
113
- for (const route of this.routes.values()) {
114
- list.push({
115
- name: route.name,
116
- description: route.description,
117
- inputSchema: route.inputSchema
118
- });
119
- }
120
- return list.sort((a, b) => a.name.localeCompare(b.name));
121
- }
122
- getRoute(toolName) {
123
- return this.routes.get(toolName);
124
- }
125
- size() {
126
- return this.routes.size;
127
- }
128
- clear() {
129
- this.routes.clear();
130
- }
131
- };
132
-
133
- // src/runtime/topology-probe.ts
134
- async function probeGatewayUrl(candidateUrl, options) {
135
- const trimmedUrl = candidateUrl.replace(/\/+$/, "");
136
- const healthUrl = `${trimmedUrl}/health`;
137
- try {
138
- log.info(`[TopologyProbe] Probing candidate Gateway at: ${healthUrl}`);
139
- const healthRes = await fetch(healthUrl, {
140
- headers: { Accept: "application/json" },
141
- signal: AbortSignal.timeout(3e3)
142
- });
143
- if (!healthRes.ok) {
144
- log.info(
145
- `[TopologyProbe] Probe failed at ${healthUrl} [HTTP ${healthRes.status}]`
146
- );
147
- return null;
148
- }
149
- const healthData = await healthRes.json();
150
- if (healthData.status !== "healthy") {
151
- return null;
152
- }
153
- let issuer = healthData.auth?.issuer || "";
154
- let tokenEndpoint = healthData.auth?.token_endpoint || "";
155
- let audience = options.audience || "urn:liop:mesh:api";
156
- let scopes = [
157
- "liop:tools:list",
158
- "liop:tools:call",
159
- "liop:resources:read",
160
- "liop:schema:read",
161
- "liop:mesh:query"
162
- ];
163
- try {
164
- const prmUrl = `${trimmedUrl}/.well-known/oauth-protected-resource`;
165
- const prmRes = await fetch(prmUrl, {
166
- headers: { Accept: "application/json" },
167
- signal: AbortSignal.timeout(2e3)
168
- });
169
- if (prmRes.ok) {
170
- const prmData = await prmRes.json();
171
- if (prmData.resource) audience = prmData.resource;
172
- if (prmData.authorization_servers?.length) {
173
- issuer = prmData.authorization_servers[0];
174
- }
175
- if (prmData.scopes_supported?.length) {
176
- scopes = prmData.scopes_supported;
177
- }
178
- }
179
- } catch {
180
- }
181
- if (!tokenEndpoint && issuer) {
182
- const baseIssuer = issuer.endsWith("/oidc") ? issuer : `${issuer}/oidc`;
183
- tokenEndpoint = `${baseIssuer}/token`;
184
- }
185
- if (tokenEndpoint) {
186
- try {
187
- const parsedEndpoint = new URL(tokenEndpoint);
188
- if (options.nexusUrl) {
189
- const nexusBase = options.nexusUrl.replace(/\/+$/, "");
190
- const nexusHost = new URL(nexusBase).host;
191
- parsedEndpoint.host = nexusHost;
192
- tokenEndpoint = parsedEndpoint.toString();
193
- } else if ((parsedEndpoint.hostname === "nexus" || parsedEndpoint.hostname === "nexus-prod" || parsedEndpoint.hostname.startsWith("172.")) && trimmedUrl.includes("127.0.0.1")) {
194
- parsedEndpoint.host = "127.0.0.1:15000";
195
- tokenEndpoint = parsedEndpoint.toString();
196
- }
197
- } catch {
198
- }
199
- }
200
- log.info(
201
- `[TopologyProbe] \u2705 Verified Gateway at ${trimmedUrl} (Tools: ${healthData.tools?.length ?? 0}, Tier: ${healthData.topology?.tier ?? 2})`
202
- );
203
- return {
204
- baseUrl: trimmedUrl,
205
- mcpEndpoint: `${trimmedUrl}/mcp`,
206
- healthEndpoint: `${trimmedUrl}/health`,
207
- tokenEndpoint,
208
- issuer,
209
- audience,
210
- scopes,
211
- tools: healthData.tools || [],
212
- tier: healthData.topology?.tier ?? 2
213
- };
214
- } catch (err) {
215
- log.info(
216
- `[TopologyProbe] Gateway probe unreachable at ${trimmedUrl}: ${err instanceof Error ? err.message : String(err)}`
217
- );
218
- return null;
219
- }
220
- }
221
- async function probeTopology(options = {}) {
222
- log.info("[TopologyProbe] Starting adaptive network topology discovery...");
223
- let gatewayInfo = null;
224
- if (options.blgUrl) {
225
- gatewayInfo = await probeGatewayUrl(options.blgUrl, options);
226
- }
227
- if (!gatewayInfo && (options.autoProbeLocal ?? true)) {
228
- const candidateUrls = [
229
- "http://127.0.0.1:15018",
230
- // Production BLG port
231
- "http://127.0.0.1:15000",
232
- // Production Nexus port
233
- "http://127.0.0.1:13000"
234
- // Demo Nexus port
235
- ];
236
- for (const url of candidateUrls) {
237
- if (options.blgUrl && url.includes(new URL(options.blgUrl).port))
238
- continue;
239
- gatewayInfo = await probeGatewayUrl(url, options);
240
- if (gatewayInfo) break;
241
- }
242
- }
243
- const bootstrapNodes = options.bootstrapNodes || [];
244
- const hasMeshBootstraps = bootstrapNodes.length > 0;
245
- if (gatewayInfo && hasMeshBootstraps) {
246
- log.info(
247
- `[TopologyProbe] \u26A1 Mode Determined: HYBRID (Gateway: ${gatewayInfo.baseUrl} + ${bootstrapNodes.length} P2P bootstraps)`
248
- );
249
- return {
250
- mode: "hybrid",
251
- gateway: gatewayInfo,
252
- mesh: {
253
- bootstrapNodes,
254
- identityPath: options.identityPath
255
- }
256
- };
257
- }
258
- if (gatewayInfo) {
259
- log.info(
260
- `[TopologyProbe] \u{1F680} Mode Determined: GATEWAY (Zero-P2P overhead, direct to ${gatewayInfo.baseUrl})`
261
- );
262
- return {
263
- mode: "gateway",
264
- gateway: gatewayInfo
265
- };
266
- }
267
- log.info(
268
- `[TopologyProbe] \u{1F310} Mode Determined: MESH (Standard P2P DHT, Bootstraps: ${bootstrapNodes.length})`
269
- );
270
- return {
271
- mode: "mesh",
272
- mesh: {
273
- bootstrapNodes,
274
- identityPath: options.identityPath
275
- }
276
- };
277
- }
278
-
279
- export { RoutingTable, probeTopology };
280
- //# sourceMappingURL=chunk-V47P2AQR.js.map
281
- //# sourceMappingURL=chunk-V47P2AQR.js.map