@simonepri/refined-antigravity-acp 0.1.2 → 1.0.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 (165) hide show
  1. package/dist/bin/cli.js +2 -51
  2. package/dist/bin/cli.js.map +1 -1
  3. package/dist/src/cli.d.ts +2 -0
  4. package/dist/src/cli.d.ts.map +1 -0
  5. package/dist/src/cli.js +44 -0
  6. package/dist/src/cli.js.map +1 -0
  7. package/dist/src/{command.d.ts → core/command.d.ts} +4 -0
  8. package/dist/src/core/command.d.ts.map +1 -0
  9. package/dist/src/{command.js → core/command.js} +27 -11
  10. package/dist/src/core/command.js.map +1 -0
  11. package/dist/src/core/pipeline.d.ts +20 -0
  12. package/dist/src/core/pipeline.d.ts.map +1 -0
  13. package/dist/src/core/pipeline.js +94 -0
  14. package/dist/src/core/pipeline.js.map +1 -0
  15. package/dist/src/core/session-cache.d.ts +12 -0
  16. package/dist/src/core/session-cache.d.ts.map +1 -0
  17. package/dist/src/core/session-cache.js +85 -0
  18. package/dist/src/core/session-cache.js.map +1 -0
  19. package/dist/src/core/supervisor.d.ts +90 -0
  20. package/dist/src/core/supervisor.d.ts.map +1 -0
  21. package/dist/src/core/supervisor.js +582 -0
  22. package/dist/src/core/supervisor.js.map +1 -0
  23. package/dist/src/core/telemetry.d.ts +23 -0
  24. package/dist/src/core/telemetry.d.ts.map +1 -0
  25. package/dist/src/core/telemetry.js +75 -0
  26. package/dist/src/core/telemetry.js.map +1 -0
  27. package/dist/src/core/transport.d.ts +7 -0
  28. package/dist/src/core/transport.d.ts.map +1 -0
  29. package/dist/src/core/transport.js +37 -0
  30. package/dist/src/core/transport.js.map +1 -0
  31. package/dist/src/core/types.d.ts +293 -0
  32. package/dist/src/core/types.d.ts.map +1 -0
  33. package/dist/src/core/types.js +78 -0
  34. package/dist/src/core/types.js.map +1 -0
  35. package/dist/src/fixes/active-turn-collision/index.d.ts +27 -0
  36. package/dist/src/fixes/active-turn-collision/index.d.ts.map +1 -0
  37. package/dist/src/fixes/active-turn-collision/index.js +117 -0
  38. package/dist/src/fixes/active-turn-collision/index.js.map +1 -0
  39. package/dist/src/fixes/cancellation-leak/index.d.ts +17 -0
  40. package/dist/src/fixes/cancellation-leak/index.d.ts.map +1 -0
  41. package/dist/src/fixes/cancellation-leak/index.js +57 -0
  42. package/dist/src/fixes/cancellation-leak/index.js.map +1 -0
  43. package/dist/src/fixes/dangling-tool-calls/index.d.ts +32 -0
  44. package/dist/src/fixes/dangling-tool-calls/index.d.ts.map +1 -0
  45. package/dist/src/fixes/dangling-tool-calls/index.js +188 -0
  46. package/dist/src/fixes/dangling-tool-calls/index.js.map +1 -0
  47. package/dist/src/fixes/dropped-history-chunks/index.d.ts +47 -0
  48. package/dist/src/fixes/dropped-history-chunks/index.d.ts.map +1 -0
  49. package/dist/src/fixes/dropped-history-chunks/index.js +202 -0
  50. package/dist/src/fixes/dropped-history-chunks/index.js.map +1 -0
  51. package/dist/src/fixes/flattened-model-efforts/index.d.ts +39 -0
  52. package/dist/src/fixes/flattened-model-efforts/index.d.ts.map +1 -0
  53. package/dist/src/fixes/flattened-model-efforts/index.js +306 -0
  54. package/dist/src/fixes/flattened-model-efforts/index.js.map +1 -0
  55. package/dist/src/fixes/index.d.ts +25 -0
  56. package/dist/src/fixes/index.d.ts.map +1 -0
  57. package/dist/src/fixes/index.js +61 -0
  58. package/dist/src/fixes/index.js.map +1 -0
  59. package/dist/src/fixes/malformed-stream-syntax/index.d.ts +44 -0
  60. package/dist/src/fixes/malformed-stream-syntax/index.d.ts.map +1 -0
  61. package/dist/src/fixes/malformed-stream-syntax/index.js +346 -0
  62. package/dist/src/fixes/malformed-stream-syntax/index.js.map +1 -0
  63. package/dist/src/fixes/missing-localharness/index.d.ts +20 -0
  64. package/dist/src/fixes/missing-localharness/index.d.ts.map +1 -0
  65. package/dist/src/fixes/missing-localharness/index.js +103 -0
  66. package/dist/src/fixes/missing-localharness/index.js.map +1 -0
  67. package/dist/src/fixes/missing-question-fallback/index.d.ts +30 -0
  68. package/dist/src/fixes/missing-question-fallback/index.d.ts.map +1 -0
  69. package/dist/src/fixes/missing-question-fallback/index.js +119 -0
  70. package/dist/src/fixes/missing-question-fallback/index.js.map +1 -0
  71. package/dist/src/fixes/missing-slash-skills/index.d.ts +17 -0
  72. package/dist/src/fixes/missing-slash-skills/index.d.ts.map +1 -0
  73. package/dist/src/fixes/missing-slash-skills/index.js +107 -0
  74. package/dist/src/fixes/missing-slash-skills/index.js.map +1 -0
  75. package/dist/src/{skills.d.ts → fixes/missing-slash-skills/skills.d.ts} +2 -1
  76. package/dist/src/fixes/missing-slash-skills/skills.d.ts.map +1 -0
  77. package/dist/src/fixes/missing-slash-skills/skills.js +199 -0
  78. package/dist/src/fixes/missing-slash-skills/skills.js.map +1 -0
  79. package/dist/src/fixes/missing-system-prompt/index.d.ts +19 -0
  80. package/dist/src/fixes/missing-system-prompt/index.d.ts.map +1 -0
  81. package/dist/src/fixes/missing-system-prompt/index.js +118 -0
  82. package/dist/src/fixes/missing-system-prompt/index.js.map +1 -0
  83. package/dist/src/fixes/missing-usage-metrics/index.d.ts +26 -0
  84. package/dist/src/fixes/missing-usage-metrics/index.d.ts.map +1 -0
  85. package/dist/src/fixes/missing-usage-metrics/index.js +132 -0
  86. package/dist/src/fixes/missing-usage-metrics/index.js.map +1 -0
  87. package/dist/src/fixes/noisy-stderr-logs/index.d.ts +15 -0
  88. package/dist/src/fixes/noisy-stderr-logs/index.d.ts.map +1 -0
  89. package/dist/src/fixes/noisy-stderr-logs/index.js +23 -0
  90. package/dist/src/fixes/noisy-stderr-logs/index.js.map +1 -0
  91. package/dist/src/fixes/non-canonical-mode-ids/index.d.ts +26 -0
  92. package/dist/src/fixes/non-canonical-mode-ids/index.d.ts.map +1 -0
  93. package/dist/src/fixes/non-canonical-mode-ids/index.js +47 -0
  94. package/dist/src/fixes/non-canonical-mode-ids/index.js.map +1 -0
  95. package/dist/src/fixes/orphaned-checkpoints/index.d.ts +31 -0
  96. package/dist/src/fixes/orphaned-checkpoints/index.d.ts.map +1 -0
  97. package/dist/src/fixes/orphaned-checkpoints/index.js +82 -0
  98. package/dist/src/fixes/orphaned-checkpoints/index.js.map +1 -0
  99. package/dist/src/fixes/silent-background-tasks/index.d.ts +66 -0
  100. package/dist/src/fixes/silent-background-tasks/index.d.ts.map +1 -0
  101. package/dist/src/fixes/silent-background-tasks/index.js +491 -0
  102. package/dist/src/fixes/silent-background-tasks/index.js.map +1 -0
  103. package/dist/src/{mcp-proxy.d.ts → fixes/stale-mcp-endpoints/index.d.ts} +31 -4
  104. package/dist/src/fixes/stale-mcp-endpoints/index.d.ts.map +1 -0
  105. package/dist/src/{mcp-proxy.js → fixes/stale-mcp-endpoints/index.js} +162 -14
  106. package/dist/src/fixes/stale-mcp-endpoints/index.js.map +1 -0
  107. package/dist/src/fixes/subagent-hang/index.d.ts +2 -0
  108. package/dist/src/fixes/subagent-hang/index.d.ts.map +1 -0
  109. package/dist/src/fixes/subagent-hang/index.js +2 -0
  110. package/dist/src/fixes/subagent-hang/index.js.map +1 -0
  111. package/dist/src/fixes/subagent-hang/subagent-hang.d.ts +43 -0
  112. package/dist/src/fixes/subagent-hang/subagent-hang.d.ts.map +1 -0
  113. package/dist/src/fixes/subagent-hang/subagent-hang.js +114 -0
  114. package/dist/src/fixes/subagent-hang/subagent-hang.js.map +1 -0
  115. package/dist/src/index.d.ts +27 -0
  116. package/dist/src/index.d.ts.map +1 -0
  117. package/dist/src/index.js +43 -0
  118. package/dist/src/index.js.map +1 -0
  119. package/dist/src/lib/protobuf.d.ts +9 -0
  120. package/dist/src/lib/protobuf.d.ts.map +1 -0
  121. package/dist/src/lib/protobuf.js +89 -0
  122. package/dist/src/lib/protobuf.js.map +1 -0
  123. package/package.json +22 -4
  124. package/readme.md +147 -141
  125. package/assets/icon.svg +0 -3
  126. package/dist/index.server.d.ts +0 -4
  127. package/dist/index.server.d.ts.map +0 -1
  128. package/dist/index.server.js +0 -7
  129. package/dist/index.server.js.map +0 -1
  130. package/dist/src/agy-patch.d.ts +0 -65
  131. package/dist/src/agy-patch.d.ts.map +0 -1
  132. package/dist/src/agy-patch.js +0 -351
  133. package/dist/src/agy-patch.js.map +0 -1
  134. package/dist/src/auth.d.ts +0 -27
  135. package/dist/src/auth.d.ts.map +0 -1
  136. package/dist/src/auth.js +0 -113
  137. package/dist/src/auth.js.map +0 -1
  138. package/dist/src/command.d.ts.map +0 -1
  139. package/dist/src/command.js.map +0 -1
  140. package/dist/src/connector.d.ts +0 -188
  141. package/dist/src/connector.d.ts.map +0 -1
  142. package/dist/src/connector.js +0 -1138
  143. package/dist/src/connector.js.map +0 -1
  144. package/dist/src/history.d.ts +0 -12
  145. package/dist/src/history.d.ts.map +0 -1
  146. package/dist/src/history.js +0 -152
  147. package/dist/src/history.js.map +0 -1
  148. package/dist/src/mcp-proxy.d.ts.map +0 -1
  149. package/dist/src/mcp-proxy.js.map +0 -1
  150. package/dist/src/provider.d.ts +0 -11
  151. package/dist/src/provider.d.ts.map +0 -1
  152. package/dist/src/provider.js +0 -31
  153. package/dist/src/provider.js.map +0 -1
  154. package/dist/src/sanitize.d.ts +0 -29
  155. package/dist/src/sanitize.d.ts.map +0 -1
  156. package/dist/src/sanitize.js +0 -237
  157. package/dist/src/sanitize.js.map +0 -1
  158. package/dist/src/skills.d.ts.map +0 -1
  159. package/dist/src/skills.js +0 -140
  160. package/dist/src/skills.js.map +0 -1
  161. package/dist/src/steering.d.ts +0 -30
  162. package/dist/src/steering.d.ts.map +0 -1
  163. package/dist/src/steering.js +0 -174
  164. package/dist/src/steering.js.map +0 -1
  165. package/paseo-plugin.json +0 -7
@@ -1,10 +1,21 @@
1
+ /**
2
+ * Problem:
3
+ * When an upstream process hangs or panics and is recycled, resending client `mcpServers`
4
+ * with stale ephemeral localhost ports fails because proxy endpoints have moved or closed.
5
+ *
6
+ * Solution:
7
+ * Establishes a dynamic loopback MCP proxy pool that intercepts outbound `mcpServers` URLs,
8
+ * remaps ephemeral ports to stable virtual endpoints, and rewrites headers across process restarts.
9
+ */
1
10
  import fs from "node:fs";
2
11
  import http from "node:http";
3
12
  import https from "node:https";
4
13
  import os from "node:os";
5
14
  import path from "node:path";
15
+ import { ACP_METHODS, getFixData, setFixData, } from "../../core/types.js";
16
+ import { getOrCreateSession, extractSessionId } from "../../core/session-cache.js";
6
17
  /**
7
- * Protocol versions the target MCP server understands. Paseo's daemon embeds
18
+ * Protocol versions the target MCP server understands. Standard MCP servers embed
8
19
  * `@modelcontextprotocol/sdk`, whose streamable-HTTP transport rejects any request
9
20
  * carrying an `MCP-Protocol-Version` header outside this list with HTTP 400.
10
21
  */
@@ -16,7 +27,7 @@ export const DEFAULT_SUPPORTED_PROTOCOL_VERSIONS = [
16
27
  "2024-10-07",
17
28
  ];
18
29
  /** Headers that are meaningful only for a single hop and must not be forwarded. */
19
- const HOP_BY_HOP_HEADERS = [
30
+ const HOP_BY_HOP_HEADERS = new Set([
20
31
  "connection",
21
32
  "keep-alive",
22
33
  "proxy-authenticate",
@@ -25,10 +36,10 @@ const HOP_BY_HOP_HEADERS = [
25
36
  "trailer",
26
37
  "transfer-encoding",
27
38
  "upgrade",
28
- ];
39
+ ]);
29
40
  function defaultPortFile() {
30
- const base = process.env.PASEO_PLUGIN_DATA_DIR ?? path.join(os.homedir(), ".paseo", "plugin-data");
31
- return path.join(base, "antigravity", "mcp-proxy-ports.json");
41
+ const base = process.env.REFINED_AGY_DATA_DIR ?? path.join(os.homedir(), ".refined-antigravity");
42
+ return path.join(base, "mcp-proxy-ports.json");
32
43
  }
33
44
  function readPortFile(file) {
34
45
  try {
@@ -88,7 +99,7 @@ function describeJsonRpc(body) {
88
99
  }
89
100
  function formatNotificationAbsorbLog(statusCode, method) {
90
101
  const methodLabel = method ? '"' + method + '"' : "unknown";
91
- const base = "[paseo-antigravity][mcp-proxy] Absorbed upstream " +
102
+ const base = "[refined-antigravity-acp][mcp-proxy] Absorbed upstream " +
92
103
  statusCode +
93
104
  " on notification " +
94
105
  methodLabel +
@@ -109,8 +120,9 @@ function normalizeAccept(rawAccept) {
109
120
  * A loopback reverse proxy for a single upstream MCP origin.
110
121
  *
111
122
  * Google's `agy_acp_server` ships an MCP client that advertises protocol version
112
- * `2026-07-28`, which Paseo's daemon rejects with HTTP 400 on every request after
123
+ * `2026-07-28`, which standard MCP daemons reject with HTTP 400 on every request after
113
124
  * `initialize`. This proxy normalizes that header down to a version the upstream
125
+
114
126
  * accepts, turning a hard transport failure into ordinary version negotiation.
115
127
  *
116
128
  * It is origin-bound and forwards the request path and query verbatim, so
@@ -118,7 +130,7 @@ function normalizeAccept(rawAccept) {
118
130
  * (`/.well-known/oauth-protected-resource/...`) reach the real upstream path
119
131
  * instead of being collapsed onto the MCP endpoint.
120
132
  */
121
- export class McpProxy {
133
+ export class McpProxyServer {
122
134
  server = null;
123
135
  port = null;
124
136
  origin;
@@ -133,10 +145,12 @@ export class McpProxy {
133
145
  this.portFile = options.portFile === undefined ? defaultPortFile() : options.portFile;
134
146
  }
135
147
  buildForwardHeaders(req, bodyLength) {
136
- const headers = { ...req.headers };
137
- delete headers.host;
138
- for (const name of HOP_BY_HOP_HEADERS)
139
- delete headers[name];
148
+ const headers = {};
149
+ for (const [name, val] of Object.entries(req.headers)) {
150
+ if (name !== "host" && !HOP_BY_HOP_HEADERS.has(name) && val !== undefined) {
151
+ headers[name] = val;
152
+ }
153
+ }
140
154
  const version = req.headers["mcp-protocol-version"];
141
155
  if (typeof version === "string" && !this.supportedProtocolVersions.has(version)) {
142
156
  headers["mcp-protocol-version"] = this.fallbackProtocolVersion;
@@ -270,6 +284,8 @@ export class McpProxy {
270
284
  await new Promise((resolve) => server.close(() => resolve()));
271
285
  }
272
286
  }
287
+ /** Backward compatibility alias */
288
+ export { McpProxyServer as McpProxy };
273
289
  /**
274
290
  * Process-wide pool of proxies keyed by upstream origin.
275
291
  *
@@ -288,7 +304,7 @@ export class McpProxyPool {
288
304
  let pending = this.proxies.get(origin);
289
305
  if (!pending) {
290
306
  pending = (async () => {
291
- const proxy = new McpProxy(origin, this.options);
307
+ const proxy = new McpProxyServer(origin, this.options);
292
308
  await proxy.start();
293
309
  return proxy;
294
310
  })();
@@ -305,4 +321,136 @@ export class McpProxyPool {
305
321
  }
306
322
  /** Shared pool. One proxy per upstream origin for the lifetime of the daemon process. */
307
323
  export const sharedMcpProxyPool = new McpProxyPool();
308
- //# sourceMappingURL=mcp-proxy.js.map
324
+ function normalizeArrayHeaders(headers) {
325
+ const result = [];
326
+ for (const h of headers) {
327
+ if (!h || typeof h !== "object")
328
+ continue;
329
+ const entry = h;
330
+ const name = typeof entry.name === "string" ? entry.name : typeof entry.key === "string" ? entry.key : "";
331
+ const value = typeof entry.value === "string" ? entry.value : "";
332
+ if (name)
333
+ result.push({ name, value });
334
+ }
335
+ return result;
336
+ }
337
+ function normalizeObjectHeaders(headers) {
338
+ const result = [];
339
+ for (const [name, val] of Object.entries(headers)) {
340
+ if (typeof val === "string")
341
+ result.push({ name, value: val });
342
+ }
343
+ return result;
344
+ }
345
+ export function normalizeMcpHeaders(headers) {
346
+ if (!headers)
347
+ return undefined;
348
+ if (Array.isArray(headers))
349
+ return normalizeArrayHeaders(headers);
350
+ if (typeof headers === "object") {
351
+ return normalizeObjectHeaders(headers);
352
+ }
353
+ return undefined;
354
+ }
355
+ export const MCP_SERVERS_KEY = "mcpServers";
356
+ export const MCP_SERVERS_ORIGINAL_KEY = "mcpServersOriginal";
357
+ export function getSessionMcpServers(session) {
358
+ return getFixData(session, MCP_SERVERS_KEY);
359
+ }
360
+ export function setSessionMcpServers(session, servers) {
361
+ setFixData(session, MCP_SERVERS_KEY, servers);
362
+ }
363
+ export function getSessionMcpServersOriginal(session) {
364
+ return getFixData(session, MCP_SERVERS_ORIGINAL_KEY);
365
+ }
366
+ export function setSessionMcpServersOriginal(session, servers) {
367
+ setFixData(session, MCP_SERVERS_ORIGINAL_KEY, servers);
368
+ }
369
+ export async function rewriteMcpServers(servers, proxies) {
370
+ for (const s of servers) {
371
+ if (!s || typeof s !== "object")
372
+ continue;
373
+ const server = s;
374
+ if (server.url && proxies) {
375
+ server.url = await proxies.rewriteUrl(server.url);
376
+ }
377
+ const normalized = normalizeMcpHeaders(server.headers);
378
+ if (normalized) {
379
+ server.headers = normalized;
380
+ }
381
+ }
382
+ }
383
+ function handleSessionLoadMcp(params, context) {
384
+ if (typeof params.sessionId !== "string" || params.mcpServers)
385
+ return false;
386
+ const session = getOrCreateSession(context.sessionCache, params.sessionId);
387
+ const cachedServers = getSessionMcpServers(session);
388
+ if (cachedServers) {
389
+ params.mcpServers = structuredClone(cachedServers);
390
+ return true;
391
+ }
392
+ return false;
393
+ }
394
+ function recordOutboundMcpServersOriginal(msg, context, sessionId, original) {
395
+ if (!original)
396
+ return;
397
+ if (sessionId) {
398
+ const session = getOrCreateSession(context.sessionCache, sessionId);
399
+ setSessionMcpServersOriginal(session, original);
400
+ }
401
+ else if ("id" in msg && msg.id !== null && msg.id !== undefined) {
402
+ const pending = context.sessionCache.pendingSessionMetadata.get(msg.id) ?? {};
403
+ pending.fixData ??= new Map();
404
+ pending.fixData.set(MCP_SERVERS_ORIGINAL_KEY, original);
405
+ context.sessionCache.pendingSessionMetadata.set(msg.id, pending);
406
+ }
407
+ }
408
+ function recordOutboundMcpServers(msg, context, sessionId, servers) {
409
+ if (!servers)
410
+ return;
411
+ if (sessionId) {
412
+ const session = getOrCreateSession(context.sessionCache, sessionId);
413
+ setSessionMcpServers(session, servers);
414
+ }
415
+ else if ("id" in msg && msg.id !== null && msg.id !== undefined) {
416
+ const pending = context.sessionCache.pendingSessionMetadata.get(msg.id) ?? {};
417
+ pending.fixData ??= new Map();
418
+ pending.fixData.set(MCP_SERVERS_KEY, servers);
419
+ context.sessionCache.pendingSessionMetadata.set(msg.id, pending);
420
+ }
421
+ }
422
+ export const staleMcpEndpointsFix = {
423
+ name: "stale-mcp-endpoints",
424
+ description: "Dynamic loopback proxy pool to maintain stable MCP tool URLs across child process recycling",
425
+ async onOutbound(msg, context) {
426
+ if (!("method" in msg))
427
+ return msg;
428
+ const params = msg.params;
429
+ if (!params)
430
+ return msg;
431
+ if (msg.method === ACP_METHODS.SESSION_LOAD && handleSessionLoadMcp(params, context)) {
432
+ return msg;
433
+ }
434
+ if (Array.isArray(params.mcpServers)) {
435
+ const sessionId = extractSessionId(msg);
436
+ const original = structuredClone(params.mcpServers);
437
+ recordOutboundMcpServersOriginal(msg, context, sessionId, original);
438
+ await rewriteMcpServers(params.mcpServers, context.proxies);
439
+ recordOutboundMcpServers(msg, context, sessionId, params.mcpServers);
440
+ }
441
+ return msg;
442
+ },
443
+ async onRecycle(session, _newChild, context) {
444
+ const original = getSessionMcpServersOriginal(session);
445
+ if (!original)
446
+ return;
447
+ const reRewritten = structuredClone(original);
448
+ await rewriteMcpServers(reRewritten, context.proxies);
449
+ setSessionMcpServers(session, reRewritten);
450
+ },
451
+ dispose() {
452
+ void sharedMcpProxyPool.stopAll();
453
+ },
454
+ };
455
+ export const mcpPortRemappingFix = staleMcpEndpointsFix;
456
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/fixes/stale-mcp-endpoints/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,WAAW,EACX,UAAU,EACV,UAAU,GAOX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEnF;;;;GAIG;AAEH,MAAM,CAAC,MAAM,mCAAmC,GAAG;IACjD,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YA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,CAAC,QAAQ,CAAC,CAAC;QAC9C,MAAM,iBAAiB,CAAC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QACtD,oBAAoB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO;QACL,KAAK,kBAAkB,CAAC,OAAO,EAAE,CAAC;IACpC,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./subagent-hang.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fixes/subagent-hang/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./subagent-hang.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/fixes/subagent-hang/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Problem:
3
+ * Subprocesses can enter unmonitored deadlocks or panic (`could not find doneCh for checkpoint`)
4
+ * during background subagent execution, causing turns to hang indefinitely with no client response.
5
+ *
6
+ * Solution:
7
+ * Monitors telemetry stream events and stderr panic signatures in real-time, declaring hangs
8
+ * to trigger automatic supervisor process recycling and turn re-execution.
9
+ */
10
+ import { type AcpStreamMessage, type AcpFix } from "../../core/types.js";
11
+ import { RAW_WS_MSG_MARKER, TELEMETRY_STATES, TARGET_ENVIRONMENT, parseTrajectoryStateUpdate, parseStepUpdate, type TrajectoryStateUpdate, type StepUpdate } from "../../core/telemetry.js";
12
+ import { DONE_CH_PANIC_MARKER } from "../orphaned-checkpoints/index.js";
13
+ export { RAW_WS_MSG_MARKER, TELEMETRY_STATES, TARGET_ENVIRONMENT, DONE_CH_PANIC_MARKER, parseTrajectoryStateUpdate, parseStepUpdate, };
14
+ export type { TrajectoryStateUpdate, StepUpdate };
15
+ export interface HangDetectorOptions {
16
+ onHangDeclared?: ((nativeSessionId: string, promptId: string | number) => void) | undefined;
17
+ onSessionIdle?: ((nativeSessionId: string) => void) | undefined;
18
+ }
19
+ export declare class HangDetector {
20
+ onHangDeclared?: ((nativeSessionId: string, promptId: string | number) => void) | undefined;
21
+ onSessionIdle?: ((nativeSessionId: string) => void) | undefined;
22
+ readonly pendingPrompts: Map<string | number, string>;
23
+ readonly lastStates: Map<string, string>;
24
+ constructor(options?: HangDetectorOptions);
25
+ getPendingPrompt(id: string | number): string | undefined;
26
+ isWaitingForTasks(nativeSessionId: string): boolean;
27
+ recordPrompt(id: string | number, nativeSessionId: string): void;
28
+ resolvePrompt(id: string | number): void;
29
+ declareHang(nativeSessionId: string, promptId: string | number): void;
30
+ private declareCrashForAllPending;
31
+ private handleTrajectoryState;
32
+ processStderrLine(line: string): void;
33
+ processOutbound(msg: AcpStreamMessage): void;
34
+ processInbound(msg: AcpStreamMessage): void;
35
+ dispose(): void;
36
+ }
37
+ export declare function createSubagentHangFix(options?: HangDetectorOptions): AcpFix & {
38
+ detector: HangDetector;
39
+ };
40
+ export declare const subagentHangFix: AcpFix & {
41
+ detector: HangDetector;
42
+ };
43
+ //# sourceMappingURL=subagent-hang.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagent-hang.d.ts","sourceRoot":"","sources":["../../../../src/fixes/subagent-hang/subagent-hang.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,MAAM,EAEZ,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,k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AC,GAAG,EAAE,gBAAgB,GAAG,IAAI;IAQ5C,cAAc,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI;IAM3C,OAAO,IAAI,IAAI;CAIhB;AAED,wBAAgB,qBAAqB,CACnC,OAAO,CAAC,EAAE,mBAAmB,GAC5B,MAAM,GAAG;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,CAoCrC;AAED,eAAO,MAAM,eAAe;cAtCJ,YAAY;CAsCkB,CAAC"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Problem:
3
+ * Subprocesses can enter unmonitored deadlocks or panic (`could not find doneCh for checkpoint`)
4
+ * during background subagent execution, causing turns to hang indefinitely with no client response.
5
+ *
6
+ * Solution:
7
+ * Monitors telemetry stream events and stderr panic signatures in real-time, declaring hangs
8
+ * to trigger automatic supervisor process recycling and turn re-execution.
9
+ */
10
+ import { ACP_METHODS, isJsonRpcRequest, } from "../../core/types.js";
11
+ import { extractSessionId } from "../../core/session-cache.js";
12
+ import { RAW_WS_MSG_MARKER, TELEMETRY_STATES, TARGET_ENVIRONMENT, parseTrajectoryStateUpdate, parseStepUpdate, } from "../../core/telemetry.js";
13
+ import { DONE_CH_PANIC_MARKER } from "../orphaned-checkpoints/index.js";
14
+ export { RAW_WS_MSG_MARKER, TELEMETRY_STATES, TARGET_ENVIRONMENT, DONE_CH_PANIC_MARKER, parseTrajectoryStateUpdate, parseStepUpdate, };
15
+ export class HangDetector {
16
+ onHangDeclared;
17
+ onSessionIdle;
18
+ pendingPrompts = new Map();
19
+ lastStates = new Map();
20
+ constructor(options) {
21
+ this.onHangDeclared = options?.onHangDeclared;
22
+ this.onSessionIdle = options?.onSessionIdle;
23
+ }
24
+ getPendingPrompt(id) {
25
+ return this.pendingPrompts.get(id);
26
+ }
27
+ isWaitingForTasks(nativeSessionId) {
28
+ return this.lastStates.get(nativeSessionId) === TELEMETRY_STATES.WAITING_FOR_TASKS;
29
+ }
30
+ recordPrompt(id, nativeSessionId) {
31
+ this.pendingPrompts.set(id, nativeSessionId);
32
+ }
33
+ resolvePrompt(id) {
34
+ this.pendingPrompts.delete(id);
35
+ }
36
+ declareHang(nativeSessionId, promptId) {
37
+ this.pendingPrompts.delete(promptId);
38
+ console.error(`[refined-antigravity-acp] Harness crash detected for session ${nativeSessionId}, prompt ${promptId} (doneCh for checkpoint)`);
39
+ this.onHangDeclared?.(nativeSessionId, promptId);
40
+ }
41
+ declareCrashForAllPending() {
42
+ for (const [promptId, nativeSessionId] of Array.from(this.pendingPrompts.entries())) {
43
+ this.declareHang(nativeSessionId, promptId);
44
+ }
45
+ }
46
+ handleTrajectoryState(trajectoryId, state) {
47
+ this.lastStates.set(trajectoryId, state);
48
+ if (state === TELEMETRY_STATES.FULLY_IDLE ||
49
+ state === TELEMETRY_STATES.COMPLETE ||
50
+ state === TELEMETRY_STATES.IDLE) {
51
+ this.onSessionIdle?.(trajectoryId);
52
+ }
53
+ }
54
+ processStderrLine(line) {
55
+ if (line.includes(DONE_CH_PANIC_MARKER)) {
56
+ this.declareCrashForAllPending();
57
+ return;
58
+ }
59
+ const tsu = parseTrajectoryStateUpdate(line);
60
+ if (tsu) {
61
+ this.handleTrajectoryState(tsu.trajectoryId, tsu.state);
62
+ }
63
+ }
64
+ processOutbound(msg) {
65
+ if (!isJsonRpcRequest(msg) || msg.method !== ACP_METHODS.SESSION_PROMPT)
66
+ return;
67
+ const sessionId = extractSessionId(msg);
68
+ if (sessionId) {
69
+ this.recordPrompt(msg.id, sessionId);
70
+ }
71
+ }
72
+ processInbound(msg) {
73
+ if ("id" in msg && msg.id !== null && msg.id !== undefined) {
74
+ this.resolvePrompt(msg.id);
75
+ }
76
+ }
77
+ dispose() {
78
+ this.pendingPrompts.clear();
79
+ this.lastStates.clear();
80
+ }
81
+ }
82
+ export function createSubagentHangFix(options) {
83
+ const detector = new HangDetector(options);
84
+ return {
85
+ name: "subagent-hang",
86
+ description: "Subagent crash recovery and telemetry watchdog",
87
+ detector,
88
+ onOutbound(msg) {
89
+ detector.processOutbound(msg);
90
+ return msg;
91
+ },
92
+ onInbound(msg) {
93
+ detector.processInbound(msg);
94
+ return [msg];
95
+ },
96
+ onStderrLine(line, context) {
97
+ if (detector.onHangDeclared === undefined) {
98
+ detector.onHangDeclared = (sessionId, promptId) => {
99
+ context.declareHang(sessionId, promptId, "hang");
100
+ };
101
+ }
102
+ detector.processStderrLine(line);
103
+ return false;
104
+ },
105
+ onRecycle() {
106
+ detector.dispose();
107
+ },
108
+ dispose() {
109
+ detector.dispose();
110
+ },
111
+ };
112
+ }
113
+ export const subagentHangFix = createSubagentHangFix();
114
+ //# sourceMappingURL=subagent-hang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subagent-hang.js","sourceRoot":"","sources":["../../../../src/fixes/subagent-hang/subagent-hang.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,WAAW,EACX,gBAAgB,GAIjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,GAGhB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,EAC1B,eAAe,GAChB,CAAC;AAQF,MAAM,OAAO,YAAY;IAChB,cAAc,CAEP;IACP,aAAa,CAAmD;IACvD,cAAc,GAAG,IAAI,GAAG,EAA2B,CAAC;IACpD,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEvD,YAAY,OAA6B;QACvC,IAAI,CAAC,cAAc,GAAG,OAAO,EAAE,cAAc,CAAC;QAC9C,IAAI,CAAC,aAAa,GAAG,OAAO,EAAE,aAAa,CAAC;IAC9C,CAAC;IAED,gBAAgB,CAAC,EAAmB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AAQ,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;YAC9B,OAAO,GAAG,CAAC;QACb,CAAC;QAED,SAAS,CAAC,GAAqB;YAC7B,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,CAAC;QACf,CAAC;QAED,YAAY,CAAC,IAAY,EAAE,OAAsB;YAC/C,IAAI,QAAQ,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;gBAC1C,QAAQ,CAAC,cAAc,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE;oBAChD,OAAO,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;gBACnD,CAAC,CAAC;YACJ,CAAC;YACD,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACjC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,SAAS;YACP,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,CAAC;QAED,OAAO;YACL,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { ChildProcess } from "node:child_process";
2
+ import type { AcpConnector, AcpStreamMessage } from "./core/types.js";
3
+ import { type McpProxyPool } from "./fixes/stale-mcp-endpoints/index.js";
4
+ export * from "./fixes/index.js";
5
+ export * from "./core/types.js";
6
+ export * from "./core/session-cache.js";
7
+ export * from "./core/transport.js";
8
+ export * from "./core/pipeline.js";
9
+ export * from "./core/supervisor.js";
10
+ export * from "./core/command.js";
11
+ export declare const PROMPT_RETRY_DELAY_MS = 500;
12
+ export interface AntigravityConnectorOptions {
13
+ spawnProcess?: (cmd: string, args: string[]) => ChildProcess | Promise<ChildProcess>;
14
+ recycleTimeoutMs?: number;
15
+ /** Total spawn+resync attempts per recycle before giving up (including the first). */
16
+ recycleSpawnAttempts?: number;
17
+ /** Delay between failed respawn attempts. */
18
+ recycleRetryDelayMs?: number;
19
+ }
20
+ /**
21
+ * Creates an in-process ACP connector stream that launches the official `agy_acp_server` binary,
22
+ * automatically downloading it if not present, and applies mode option filtering, outbound MCP adaptation,
23
+ * text sanitization, hang detection, and transparent process recycling.
24
+ */
25
+ export declare function createAntigravityConnector(proxies?: McpProxyPool, options?: AntigravityConnectorOptions): AcpConnector;
26
+ export type { AcpConnector, AcpStreamMessage };
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAa,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAWjF,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,sCAAsC,CAAC;AAG7F,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAElC,eAAO,MAAM,qBAAqB,MAAgC,CAAC;AAEnE,MAAM,WAAW,2BAA2B;IAC1C,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACrF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sFAAsF;IACtF,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,6CAA6C;IAC7C,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,YAAiC,EAC1C,OAAO,CAAC,EAAE,2BAA2B,GACpC,YAAY,CAqBd;AAED,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,43 @@
1
+ // Core generic transport and plumbing
2
+ import { AcpPipeline } from "./core/pipeline.js";
3
+ import { defaultSpawnProcess } from "./core/transport.js";
4
+ import { ProcessSupervisor } from "./core/supervisor.js";
5
+ // Dedicated Fixes (Mapped 1:1 to Readme Table)
6
+ import { createDefaultFixes } from "./fixes/index.js";
7
+ import { resolveBinaryCommand } from "./fixes/missing-localharness/index.js";
8
+ import { DEFAULT_PROMPT_RETRY_DELAY_MS } from "./fixes/active-turn-collision/index.js";
9
+ import { sharedMcpProxyPool } from "./fixes/stale-mcp-endpoints/index.js";
10
+ // Export all fixes and plumbing
11
+ export * from "./fixes/index.js";
12
+ export * from "./core/types.js";
13
+ export * from "./core/session-cache.js";
14
+ export * from "./core/transport.js";
15
+ export * from "./core/pipeline.js";
16
+ export * from "./core/supervisor.js";
17
+ export * from "./core/command.js";
18
+ export const PROMPT_RETRY_DELAY_MS = DEFAULT_PROMPT_RETRY_DELAY_MS;
19
+ /**
20
+ * Creates an in-process ACP connector stream that launches the official `agy_acp_server` binary,
21
+ * automatically downloading it if not present, and applies mode option filtering, outbound MCP adaptation,
22
+ * text sanitization, hang detection, and transparent process recycling.
23
+ */
24
+ export function createAntigravityConnector(proxies = sharedMcpProxyPool, options) {
25
+ return async () => {
26
+ const [cmd, ...args] = await resolveBinaryCommand();
27
+ const spawnFn = options?.spawnProcess ?? ((c, a) => defaultSpawnProcess(c, a));
28
+ const initialChild = await spawnFn(cmd, args);
29
+ const supervisor = new ProcessSupervisor({
30
+ cmd,
31
+ args,
32
+ initialChild,
33
+ pipeline: new AcpPipeline(createDefaultFixes()),
34
+ proxies,
35
+ spawnProcess: options?.spawnProcess,
36
+ recycleTimeoutMs: options?.recycleTimeoutMs,
37
+ recycleSpawnAttempts: options?.recycleSpawnAttempts,
38
+ recycleRetryDelayMs: options?.recycleRetryDelayMs,
39
+ });
40
+ return supervisor.createStreams();
41
+ };
42
+ }
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,+CAA+C;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACvF,OAAO,EAAqB,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE7F,gCAAgC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAElC,MAAM,CAAC,MAAM,qBAAqB,GAAG,6BAA6B,CAAC;AAWnE;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,UAAwB,kBAAkB,EAC1C,OAAqC;IAErC,OAAO,KAAK,IAAwB,EAAE;QACpC,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,MAAM,oBAAoB,EAAE,CAAC;QAEpD,MAAM,OAAO,GAAG,OAAO,EAAE,YAAY,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC/E,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAE9C,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC;YACvC,GAAG;YACH,IAAI;YACJ,YAAY;YACZ,QAAQ,EAAE,IAAI,WAAW,CAAC,kBAAkB,EAAE,CAAC;YAC/C,OAAO;YACP,YAAY,EAAE,OAAO,EAAE,YAAY;YACnC,gBAAgB,EAAE,OAAO,EAAE,gBAAgB;YAC3C,oBAAoB,EAAE,OAAO,EAAE,oBAAoB;YACnD,mBAAmB,EAAE,OAAO,EAAE,mBAAmB;SAClD,CAAC,CAAC;QAEH,OAAO,UAAU,CAAC,aAAa,EAAE,CAAC;IACpC,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Zero-dependency Protobuf wire-format encoders and decoders.
3
+ */
4
+ export declare function encodeVarint(val: number): Buffer;
5
+ export declare function encodeLengthDelimited(fieldNumber: number, data: Buffer): Buffer;
6
+ export declare function decodeVarint(buffer: Uint8Array, start: number): [number, number];
7
+ export declare function getField(buffer: Uint8Array | null | undefined, targetField: number): Uint8Array | null;
8
+ export declare function getVarintField(buffer: Uint8Array | null | undefined, targetField: number): number | null;
9
+ //# sourceMappingURL=protobuf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protobuf.d.ts","sourceRoot":"","sources":["../../../src/lib/protobuf.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAShD;AAED,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG/E;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAYhF;AAED,wBAAgB,QAAQ,CACtB,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EACrC,WAAW,EAAE,MAAM,GAClB,UAAU,GAAG,IAAI,CAqBnB;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,EACrC,WAAW,EAAE,MAAM,GAClB,MAAM,GAAG,IAAI,CAoBf"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Zero-dependency Protobuf wire-format encoders and decoders.
3
+ */
4
+ export function encodeVarint(val) {
5
+ const bytes = [];
6
+ let v = val;
7
+ while (v >= 0x80) {
8
+ bytes.push((v & 0x7f) | 0x80);
9
+ v >>>= 7;
10
+ }
11
+ bytes.push(v);
12
+ return Buffer.from(bytes);
13
+ }
14
+ export function encodeLengthDelimited(fieldNumber, data) {
15
+ const tag = (fieldNumber << 3) | 2;
16
+ return Buffer.concat([encodeVarint(tag), encodeVarint(data.length), data]);
17
+ }
18
+ export function decodeVarint(buffer, start) {
19
+ let res = 0;
20
+ let shift = 0;
21
+ let offset = start;
22
+ while (offset < buffer.length) {
23
+ const b = buffer[offset++];
24
+ if (b === undefined)
25
+ break;
26
+ res |= (b & 0x7f) << shift;
27
+ shift += 7;
28
+ if (!(b & 0x80))
29
+ break;
30
+ }
31
+ return [res, offset];
32
+ }
33
+ export function getField(buffer, targetField) {
34
+ if (!buffer)
35
+ return null;
36
+ let offset = 0;
37
+ while (offset < buffer.length) {
38
+ const [tag, nextOffset] = decodeVarint(buffer, offset);
39
+ offset = nextOffset;
40
+ const wireType = tag & 0x7;
41
+ const fieldNum = tag >> 3;
42
+ if (wireType === 2) {
43
+ const [len, afterLen] = decodeVarint(buffer, offset);
44
+ const slice = buffer.subarray(afterLen, afterLen + len);
45
+ offset = afterLen + len;
46
+ if (fieldNum === targetField)
47
+ return slice;
48
+ }
49
+ else if (wireType === 0) {
50
+ [, offset] = decodeVarint(buffer, offset);
51
+ }
52
+ else if (wireType === 1)
53
+ offset += 8;
54
+ else if (wireType === 5)
55
+ offset += 4;
56
+ else
57
+ break;
58
+ }
59
+ return null;
60
+ }
61
+ export function getVarintField(buffer, targetField) {
62
+ if (!buffer)
63
+ return null;
64
+ let offset = 0;
65
+ while (offset < buffer.length) {
66
+ const [tag, nextOffset] = decodeVarint(buffer, offset);
67
+ offset = nextOffset;
68
+ const wireType = tag & 0x7;
69
+ const fieldNum = tag >> 3;
70
+ if (wireType === 0) {
71
+ const [val, afterVal] = decodeVarint(buffer, offset);
72
+ offset = afterVal;
73
+ if (fieldNum === targetField)
74
+ return val;
75
+ }
76
+ else if (wireType === 2) {
77
+ const [len, afterLen] = decodeVarint(buffer, offset);
78
+ offset = afterLen + len;
79
+ }
80
+ else if (wireType === 1)
81
+ offset += 8;
82
+ else if (wireType === 5)
83
+ offset += 4;
84
+ else
85
+ break;
86
+ }
87
+ return null;
88
+ }
89
+ //# sourceMappingURL=protobuf.js.map