agentxchain 2.155.39 → 2.155.41

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentxchain",
3
- "version": "2.155.39",
3
+ "version": "2.155.41",
4
4
  "description": "CLI for AgentXchain — governed multi-agent software delivery",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,8 +8,11 @@ import {
8
8
  formatGovernanceReportText,
9
9
  } from '../lib/report.js';
10
10
 
11
+ // BUG-88: apply bounding to prevent Invalid string length on large accumulated state
12
+ const defaultExportOpts = { maxJsonlEntries: 1000, maxBase64Bytes: 1024 * 1024, maxExportFiles: 500, maxTextDataBytes: 131072, maxJsonDataBytes: 262144 };
13
+
11
14
  function detectAuditKind(cwd) {
12
- const runResult = buildRunExport(cwd);
15
+ const runResult = buildRunExport(cwd, defaultExportOpts);
13
16
  if (runResult.ok) {
14
17
  return {
15
18
  ok: true,
@@ -381,7 +381,8 @@ function assertExpectedWorkloadSignals(workload, metrics) {
381
381
 
382
382
  async function buildAndVerifyRunExport(root) {
383
383
  const { buildRunExport } = await import('../lib/export.js');
384
- const exportResult = buildRunExport(root);
384
+ // BUG-88: apply bounding to prevent Invalid string length on large accumulated state
385
+ const exportResult = buildRunExport(root, { maxJsonlEntries: 1000, maxBase64Bytes: 1024 * 1024, maxExportFiles: 500, maxTextDataBytes: 131072, maxJsonDataBytes: 262144 });
385
386
  if (!exportResult.ok) {
386
387
  return {
387
388
  ok: false,
@@ -28,10 +28,13 @@ export async function exportCommand(options) {
28
28
  const cwd = process.cwd();
29
29
  const kind = detectExportKind(cwd);
30
30
 
31
+ // BUG-88: apply bounding to prevent Invalid string length on large accumulated state
32
+ const defaultExportOpts = { maxJsonlEntries: 1000, maxBase64Bytes: 1024 * 1024, maxExportFiles: 500, maxTextDataBytes: 131072, maxJsonDataBytes: 262144 };
33
+
31
34
  let result;
32
35
  try {
33
36
  if (kind === 'governed') {
34
- result = buildRunExport(cwd);
37
+ result = buildRunExport(cwd, defaultExportOpts);
35
38
  } else if (kind === 'coordinator') {
36
39
  result = buildCoordinatorExport(cwd);
37
40
  } else {
@@ -59,5 +62,22 @@ export async function exportCommand(options) {
59
62
  return;
60
63
  }
61
64
 
62
- console.log(JSON.stringify(result.export, null, 2));
65
+ // BUG-88: compact JSON to avoid string-length overflow on large exports
66
+ try {
67
+ console.log(JSON.stringify(result.export));
68
+ } catch (serializeErr) {
69
+ if (/Invalid string length/i.test(serializeErr.message)) {
70
+ // Retry with tighter bounds
71
+ const tightOpts = { maxJsonlEntries: 500, maxBase64Bytes: 65536, maxExportFiles: 200, maxTextDataBytes: 32768, maxJsonDataBytes: 65536 };
72
+ const tightResult = buildRunExport(cwd, tightOpts);
73
+ if (tightResult.ok) {
74
+ console.log(JSON.stringify(tightResult.export));
75
+ } else {
76
+ console.error(tightResult.error || serializeErr.message);
77
+ process.exitCode = 1;
78
+ }
79
+ } else {
80
+ throw serializeErr;
81
+ }
82
+ }
63
83
  }
@@ -674,8 +674,8 @@ export async function executeGovernedRun(context, opts = {}) {
674
674
  mkdirSync(reportsDir, { recursive: true });
675
675
 
676
676
  // BUG-88: two-attempt export with fallback to tighter bounds on string-length overflow
677
- const defaultExportOpts = { maxJsonlEntries: 1000, maxBase64Bytes: 1024 * 1024, maxExportFiles: 500, maxTextDataBytes: 131072 };
678
- const tightExportOpts = { maxJsonlEntries: 500, maxBase64Bytes: 65536, maxExportFiles: 200, maxTextDataBytes: 32768 };
677
+ const defaultExportOpts = { maxJsonlEntries: 1000, maxBase64Bytes: 1024 * 1024, maxExportFiles: 500, maxTextDataBytes: 131072, maxJsonDataBytes: 262144 };
678
+ const tightExportOpts = { maxJsonlEntries: 500, maxBase64Bytes: 65536, maxExportFiles: 200, maxTextDataBytes: 32768, maxJsonDataBytes: 65536 };
679
679
 
680
680
  let exportResult = buildRunExport(root, defaultExportOpts);
681
681
  if (exportResult.ok) {
package/src/lib/export.js CHANGED
@@ -34,6 +34,12 @@ const RUN_EXPORT_ONLY_ROOTS = [
34
34
  '.planning',
35
35
  ];
36
36
 
37
+ const GENERATED_GOVERNANCE_REPORT_PATTERNS = Object.freeze([
38
+ /^\.agentxchain\/reports\/report-[^/]+\.md$/,
39
+ /^\.agentxchain\/reports\/export-[^/]+\.json$/,
40
+ /^\.agentxchain\/reports\/chain-[^/]+\.json$/,
41
+ ]);
42
+
37
43
  export const RUN_EXPORT_INCLUDED_ROOTS = [
38
44
  'agentxchain.json',
39
45
  ...RUN_CONTINUITY_STATE_FILES,
@@ -52,6 +58,10 @@ function pathWithinRoots(relPath, roots) {
52
58
  return roots.some((root) => relPath === root || relPath.startsWith(`${root}/`));
53
59
  }
54
60
 
61
+ export function isGeneratedGovernanceReportPath(relPath) {
62
+ return GENERATED_GOVERNANCE_REPORT_PATTERNS.some((pattern) => pattern.test(relPath));
63
+ }
64
+
55
65
  export function isRunRestorePath(relPath) {
56
66
  return pathWithinRoots(relPath, RUN_RESTORE_ROOTS);
57
67
  }
@@ -165,11 +175,16 @@ function parseFile(root, relPath, opts = {}) {
165
175
 
166
176
  if (relPath.endsWith('.json')) {
167
177
  const raw = buffer.toString('utf8');
168
- try {
169
- data = JSON.parse(raw);
170
- format = 'json';
171
- } catch (error) {
172
- throw new Error(`${relPath}: invalid JSON: ${error.message}`);
178
+ format = 'json';
179
+ if (opts.maxJsonDataBytes && buffer.byteLength > opts.maxJsonDataBytes) {
180
+ data = null;
181
+ truncated = true;
182
+ } else {
183
+ try {
184
+ data = JSON.parse(raw);
185
+ } catch (error) {
186
+ throw new Error(`${relPath}: invalid JSON: ${error.message}`);
187
+ }
173
188
  }
174
189
  } else if (relPath.endsWith('.jsonl')) {
175
190
  const maxEntries = opts.maxJsonlEntries;
@@ -199,8 +214,14 @@ function parseFile(root, relPath, opts = {}) {
199
214
 
200
215
  if (truncated) {
201
216
  result.truncated = true;
202
- result.total_entries = totalEntries;
203
- result.retained_entries = data.length;
217
+ if (format === 'jsonl') {
218
+ result.total_entries = totalEntries;
219
+ result.retained_entries = data.length;
220
+ } else if (format === 'text') {
221
+ result.retained_bytes = Buffer.byteLength(data, 'utf8');
222
+ } else if (format === 'json') {
223
+ result.retained_bytes = 0;
224
+ }
204
225
  }
205
226
  if (skipBase64 && !truncated) {
206
227
  result.content_base64_skipped = true;
@@ -459,6 +480,7 @@ export function buildRunExport(startDir = process.cwd(), exportOpts = {}) {
459
480
  const state = loadProjectState(root, config);
460
481
 
461
482
  const collectedPaths = [...new Set(RUN_EXPORT_INCLUDED_ROOTS.flatMap((relPath) => collectPaths(root, relPath)))]
483
+ .filter((relPath) => !isGeneratedGovernanceReportPath(relPath))
462
484
  .sort((a, b) => a.localeCompare(b, 'en'));
463
485
 
464
486
  const parseOpts = {};
@@ -471,6 +493,9 @@ export function buildRunExport(startDir = process.cwd(), exportOpts = {}) {
471
493
  if (exportOpts.maxTextDataBytes) {
472
494
  parseOpts.maxTextDataBytes = exportOpts.maxTextDataBytes;
473
495
  }
496
+ if (exportOpts.maxJsonDataBytes) {
497
+ parseOpts.maxJsonDataBytes = exportOpts.maxJsonDataBytes;
498
+ }
474
499
 
475
500
  // BUG-88: apply maxExportFiles cap with priority ordering.
476
501
  // Core governance files first, then dispatch/staging, then .planning/ last.
@@ -616,7 +641,7 @@ function buildAggregatedEventsSummary(workspaceRoot, repoEntries) {
616
641
  };
617
642
  }
618
643
 
619
- export function buildCoordinatorExport(startDir = process.cwd()) {
644
+ export function buildCoordinatorExport(startDir = process.cwd(), exportOpts = {}) {
620
645
  const workspaceRoot = resolve(startDir);
621
646
  const configPath = join(workspaceRoot, COORDINATOR_CONFIG_FILE);
622
647
 
@@ -679,7 +704,8 @@ export function buildCoordinatorExport(startDir = process.cwd()) {
679
704
  const resolvedPath = resolve(workspaceRoot, repoPath);
680
705
 
681
706
  try {
682
- const childExport = buildRunExport(resolvedPath);
707
+ // BUG-88: apply bounding to child exports in coordinator workspaces
708
+ const childExport = buildRunExport(resolvedPath, exportOpts);
683
709
  if (childExport.ok) {
684
710
  repos[repoId] = {
685
711
  ok: true,