@rallycry/conveyor-agent 11.0.29 → 11.0.30

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.
@@ -8,7 +8,7 @@ import {
8
8
  readWorkspaceBytes,
9
9
  statWorkspacePath,
10
10
  workspacePathExists
11
- } from "./chunk-KLM6ZOUX.js";
11
+ } from "./chunk-7KG7CDVU.js";
12
12
  import {
13
13
  reportBootMilestone
14
14
  } from "./chunk-Q4FQOJ7D.js";
@@ -240,6 +240,38 @@ function syncBundleGithubToken(token) {
240
240
  syncGithubTokenFiles(token);
241
241
  }
242
242
 
243
+ // src/connection/event-batch.ts
244
+ var MAX_EVENT_BATCH_BYTES = 256 * 1024;
245
+ var CLIPPED_FIELD_CHARS = 16 * 1024;
246
+ function sizeOf(event) {
247
+ return JSON.stringify(event).length;
248
+ }
249
+ function fitEvent(event) {
250
+ const size = sizeOf(event);
251
+ if (size <= MAX_EVENT_BATCH_BYTES) return { event, size };
252
+ const clipped = { ...event };
253
+ for (const [key, value] of Object.entries(clipped)) {
254
+ if (typeof value === "string" && value.length > CLIPPED_FIELD_CHARS) {
255
+ const dropped = value.length - CLIPPED_FIELD_CHARS;
256
+ clipped[key] = `${value.slice(0, CLIPPED_FIELD_CHARS)}
257
+ [conveyor-agent] truncated ${dropped} chars
258
+ `;
259
+ }
260
+ }
261
+ const clippedSize = sizeOf(clipped);
262
+ return clippedSize <= MAX_EVENT_BATCH_BYTES ? { event: clipped, size: clippedSize } : null;
263
+ }
264
+ function batchLength(entries) {
265
+ let total = 0;
266
+ for (let i = 0; i < entries.length; i++) {
267
+ const entry = entries[i];
268
+ const size = entry.size ?? sizeOf(entry.event);
269
+ total += size + 1;
270
+ if (total > MAX_EVENT_BATCH_BYTES && i > 0) return i;
271
+ }
272
+ return entries.length;
273
+ }
274
+
243
275
  // src/connection/agent-connection.ts
244
276
  var logger = createServiceLogger("agent-connection");
245
277
  var EVENT_BATCH_MS = 500;
@@ -1431,7 +1463,15 @@ ${q.question}${q.options.length ? "\n" + q.options.map((o) => `- ${o.label}: ${o
1431
1463
  // ── Event buffering ────────────────────────────────────────────────
1432
1464
  sendEvent(event) {
1433
1465
  if (!this.socket) return;
1434
- this.enqueueEvents([{ event }], false);
1466
+ const fitted = fitEvent(event);
1467
+ if (!fitted) {
1468
+ process.stderr.write(
1469
+ `[conveyor-agent] dropped oversized ${event.type} event (over the emit batch limit)
1470
+ `
1471
+ );
1472
+ return;
1473
+ }
1474
+ this.enqueueEvents([fitted], false);
1435
1475
  }
1436
1476
  /** Append (or, on `toFront`, prepend for a failed-flush re-queue) events to
1437
1477
  * the buffer, then cap + arm the flush timer. Single owner of the overflow
@@ -1458,14 +1498,15 @@ ${q.question}${q.options.length ? "\n" + q.options.map((o) => `- ${o.label}: ${o
1458
1498
  clearTimeout(this.flushTimer);
1459
1499
  this.flushTimer = null;
1460
1500
  }
1461
- if (!this.socket || this.eventBuffer.length === 0) return;
1462
- const entries = this.eventBuffer;
1463
- this.eventBuffer = [];
1464
- const events = entries.map((entry) => entry.event);
1465
- try {
1466
- await this.call("emitAgentEvent", { sessionId: this.config.sessionId, events });
1467
- } catch {
1468
- this.requeueFailedEvents(entries);
1501
+ while (this.socket && this.eventBuffer.length > 0) {
1502
+ const entries = this.eventBuffer.splice(0, batchLength(this.eventBuffer));
1503
+ const events = entries.map((entry) => entry.event);
1504
+ try {
1505
+ await this.call("emitAgentEvent", { sessionId: this.config.sessionId, events });
1506
+ } catch {
1507
+ this.requeueFailedEvents(entries);
1508
+ return;
1509
+ }
1469
1510
  }
1470
1511
  }
1471
1512
  /** Put a failed flush's events back at the FRONT of the buffer, preserving
@@ -95,7 +95,7 @@ import {
95
95
  statWorkspacePath,
96
96
  updateRemoteToken,
97
97
  verifyGitCredential
98
- } from "./chunk-KLM6ZOUX.js";
98
+ } from "./chunk-7KG7CDVU.js";
99
99
  import {
100
100
  registerBootMilestoneSocketFallback,
101
101
  reportBootMilestone
package/dist/cli.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  WorkspaceCommandSupervisor,
8
8
  startWorkspaceCommandsAfterConnect,
9
9
  stopWorkspaceCommands
10
- } from "./chunk-V5X3JCAZ.js";
10
+ } from "./chunk-2BHXJ37W.js";
11
11
  import {
12
12
  PtyHarness,
13
13
  SessionRunner,
@@ -25,7 +25,7 @@ import {
25
25
  runUsageProbe,
26
26
  sampleKeyUsage,
27
27
  usesNativeUsageReporting
28
- } from "./chunk-FF5JML7W.js";
28
+ } from "./chunk-HYXAXQHN.js";
29
29
  import "./chunk-37J5MMQT.js";
30
30
  import {
31
31
  inheritedEnv,
@@ -44,7 +44,7 @@ import {
44
44
  createServiceLogger,
45
45
  fetchBootstrap,
46
46
  loadConveyorConfig
47
- } from "./chunk-KLM6ZOUX.js";
47
+ } from "./chunk-7KG7CDVU.js";
48
48
  import "./chunk-Q4FQOJ7D.js";
49
49
  import "./chunk-W4LZ7R6Z.js";
50
50
  import "./chunk-372R6E4C.js";
@@ -1458,7 +1458,7 @@ if (!RUNNER_MODES.includes(CONVEYOR_MODE)) {
1458
1458
  process.exit(1);
1459
1459
  }
1460
1460
  if (CONVEYOR_MODE === "serving") {
1461
- const { runServingSession } = await import("./serve-boot-N5XKECWC.js");
1461
+ const { runServingSession } = await import("./serve-boot-F2G7ZXFF.js");
1462
1462
  exitContext.runnerMode = "serving";
1463
1463
  exitContext.sessionId = process.env.CONVEYOR_SESSION_ID ?? exitContext.sessionId;
1464
1464
  const outcome = await runServingSession({
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SessionRunner,
3
3
  unshallowRepo
4
- } from "./chunk-FF5JML7W.js";
4
+ } from "./chunk-HYXAXQHN.js";
5
5
  import "./chunk-37J5MMQT.js";
6
6
  import "./chunk-WCJ6HRVU.js";
7
7
  import {
@@ -17,7 +17,7 @@ import {
17
17
  stageAndCommit,
18
18
  updateRemoteToken,
19
19
  workspacePathExists
20
- } from "./chunk-KLM6ZOUX.js";
20
+ } from "./chunk-7KG7CDVU.js";
21
21
  import "./chunk-Q4FQOJ7D.js";
22
22
  import {
23
23
  runAuthTokenCommand,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  WorkspaceCommandSupervisor
3
- } from "./chunk-V5X3JCAZ.js";
3
+ } from "./chunk-2BHXJ37W.js";
4
4
  import {
5
5
  AgentConnection,
6
6
  CodespacePortVisibility,
@@ -11,7 +11,7 @@ import {
11
11
  createServiceLogger,
12
12
  ensureOnTaskBranch,
13
13
  loadConveyorConfig
14
- } from "./chunk-KLM6ZOUX.js";
14
+ } from "./chunk-7KG7CDVU.js";
15
15
  import "./chunk-Q4FQOJ7D.js";
16
16
  import "./chunk-W4LZ7R6Z.js";
17
17
  import "./chunk-IA45XHOA.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rallycry/conveyor-agent",
3
- "version": "11.0.29",
3
+ "version": "11.0.30",
4
4
  "description": "Conveyor Agent Runner v10 - PTY harness for the task chat (SDK harness for audit/project-chat). Agent-as-User architecture with BaseService patterns. Works locally too.",
5
5
  "keywords": [
6
6
  "agent",