@molecule/api-ai-tools 1.5.11 → 1.5.13

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/README.md CHANGED
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-10-16T00:26:34.364Z
6
+ Generated: 2026-10-16T02:43:35.968Z
7
7
  -->
8
8
 
9
9
  # @molecule/api-ai-tools
@@ -814,6 +814,19 @@ function truncateMiddle(s: string, maxLength: number): string
814
814
 
815
815
  **Returns:** The original string, or head + an elision notice + tail.
816
816
 
817
+ #### `failureBlocks(s)`
818
+
819
+ The numbered failure blocks of a Playwright report (` 1) [chromium] › file:line › title`
820
+ up to the next block or the tally).
821
+
822
+ ```typescript
823
+ function failureBlocks(s: string): string[]
824
+ ```
825
+
826
+ - `s` — Test-runner output.
827
+
828
+ **Returns:** Each block, in order (empty when there are none).
829
+
817
830
  #### `whitespaceTolerantReplace(content, oldString, newString)`
818
831
 
819
832
  Attempt a whitespace-tolerant replacement when an exact `old_string` match
@@ -286,6 +286,14 @@ export declare function truncate(s: string, maxLength: number): string;
286
286
  * @returns The original string, or head + an elision notice + tail.
287
287
  */
288
288
  export declare function truncateMiddle(s: string, maxLength: number): string;
289
+ /**
290
+ * The numbered failure blocks of a Playwright report (` 1) [chromium] › file:line › title`
291
+ * up to the next block or the tally).
292
+ *
293
+ * @param s - Test-runner output.
294
+ * @returns Each block, in order (empty when there are none).
295
+ */
296
+ export declare function failureBlocks(s: string): string[];
289
297
  /**
290
298
  * Attempt a whitespace-tolerant replacement when an exact `old_string` match
291
299
  * failed. Finds a contiguous run of lines in `content` whose per-line
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.d.ts","sourceRoot":"","s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MAAM,GAAG,IAAI,CAsCf;AAED,qEAAqE;AACrE,eAAO,MAAM,eAAe,QAA0C,CAAA;AAEtE;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgB7D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IACxC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB,GAAG,MAAM,GAAG,IAAI,CAKhB"}
package/dist/utilities.js CHANGED
@@ -38,7 +38,8 @@ s.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, '');
38
38
  // access controls than the vault). PWD (DB_PWD/MYSQL_PWD), APIKEY (no underscore,
39
39
  // e.g. MAILGUN_APIKEY), and SERVICE_ACCOUNT were the gaps; `_KEY` already covers
40
40
  // OPENAI_KEY / *_ROLE_KEY.
41
- const SECRET_KEYWORDS = 'SECRET|PASSWORD|PASSWD|PWD|TOKEN|API_KEY|APIKEY|PRIVATE_KEY|DATABASE_URL|REDIS_URL|AUTH|CREDENTIAL|ACCESS_KEY|SIGNING_KEY|ENCRYPTION_KEY|CONNECTION_STRING|SERVICE_ACCOUNT|DSN|SMTP_PASS|_KEY';
41
+ // AUTH but not AUTHOR (usernames printed as `author=…` were masked, X1 flash-m44); AUTHORIZATION still counts.
42
+ const SECRET_KEYWORDS = 'SECRET|PASSWORD|PASSWD|PWD|TOKEN|API_KEY|APIKEY|PRIVATE_KEY|DATABASE_URL|REDIS_URL|AUTH(?!OR(?!IZ))|CREDENTIAL|ACCESS_KEY|SIGNING_KEY|ENCRYPTION_KEY|CONNECTION_STRING|SERVICE_ACCOUNT|DSN|SMTP_PASS|_KEY';
42
43
  /**
43
44
  * A keyword-named `NAME=value` anywhere on a line — the ENV-DUMP grade pattern,
44
45
  * used by {@link redactSecrets} for command output and `.env` reads. The permissive
@@ -555,6 +556,29 @@ export function truncateMiddle(s, maxLength) {
555
556
  if (maxLength <= noticeReserve)
556
557
  return s.slice(0, maxLength);
557
558
  const budget = maxLength - noticeReserve;
559
+ // A test run's numbered failure blocks are what the reader needs, and in a long run they
560
+ // sit in the middle, between per-test progress and the tally: keep them over progress
561
+ // (X1 flash-m45: 31 failure bodies dropped, 8 KB of passing progress kept).
562
+ const failures = failureBlocks(s);
563
+ if (failures.length > 0) {
564
+ const headLen = Math.min(800, Math.floor(budget * 0.1));
565
+ const tailLen = Math.min(1500, Math.floor(budget * 0.2));
566
+ let room = budget - headLen - tailLen;
567
+ const kept = [];
568
+ for (const block of failures) {
569
+ const piece = block.length > 900 ? `${block.slice(0, 897)}...` : block;
570
+ if (piece.length + 1 > room)
571
+ break;
572
+ kept.push(piece);
573
+ room -= piece.length + 1;
574
+ }
575
+ const left = failures.length - kept.length;
576
+ return (s.slice(0, headLen) +
577
+ `\n\n... [middle truncated — progress lines left out; ${kept.length} of ${failures.length} failure blocks kept${left ? `, ${left} more not shown` : ''}] ...\n\n` +
578
+ kept.join('\n') +
579
+ '\n\n' +
580
+ s.slice(s.length - tailLen));
581
+ }
558
582
  const headLen = Math.floor(budget * 0.4);
559
583
  const tailLen = budget - headLen;
560
584
  const omitted = s.length - headLen - tailLen;
@@ -562,6 +586,36 @@ export function truncateMiddle(s, maxLength) {
562
586
  `\n\n... [middle truncated — ${omitted} chars omitted; the head AND the tail are shown, a failing command's error is usually near the end] ...\n\n` +
563
587
  s.slice(s.length - tailLen));
564
588
  }
589
+ /**
590
+ * The numbered failure blocks of a Playwright report (` 1) [chromium] › file:line › title`
591
+ * up to the next block or the tally).
592
+ *
593
+ * @param s - Test-runner output.
594
+ * @returns Each block, in order (empty when there are none).
595
+ */
596
+ export function failureBlocks(s) {
597
+ const lines = s.split('\n');
598
+ const blocks = [];
599
+ let current = null;
600
+ for (const line of lines) {
601
+ if (/^\s*\d+\) \[[^\]\n]+\] › /.test(line)) {
602
+ if (current)
603
+ blocks.push(current.join('\n').trimEnd());
604
+ current = [line];
605
+ }
606
+ else if (current) {
607
+ if (/^\s*\d+ (?:passed|failed|flaky|skipped|did not run)\b/.test(line)) {
608
+ blocks.push(current.join('\n').trimEnd());
609
+ current = null;
610
+ }
611
+ else
612
+ current.push(line);
613
+ }
614
+ }
615
+ if (current)
616
+ blocks.push(current.join('\n').trimEnd());
617
+ return blocks;
618
+ }
565
619
  /**
566
620
  * Attempt a whitespace-tolerant replacement when an exact `old_string` match
567
621
  * failed. Finds a contiguous run of lines in `content` whose per-line
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-ai-tools",
3
- "version": "1.5.11",
3
+ "version": "1.5.13",
4
4
  "description": "Shared AI agent tools with backend abstraction for sandbox and local execution",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",