@caupulican/pi-adaptative 0.80.22 → 0.80.23

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 (74) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/cli/file-processor.d.ts.map +1 -1
  3. package/dist/cli/file-processor.js +28 -1
  4. package/dist/cli/file-processor.js.map +1 -1
  5. package/dist/core/agent-session.d.ts.map +1 -1
  6. package/dist/core/agent-session.js +10 -76
  7. package/dist/core/agent-session.js.map +1 -1
  8. package/dist/core/bash-executor.d.ts.map +1 -1
  9. package/dist/core/bash-executor.js +16 -7
  10. package/dist/core/bash-executor.js.map +1 -1
  11. package/dist/core/exec.d.ts +20 -1
  12. package/dist/core/exec.d.ts.map +1 -1
  13. package/dist/core/exec.js +52 -19
  14. package/dist/core/exec.js.map +1 -1
  15. package/dist/core/extensions/loader.d.ts +6 -0
  16. package/dist/core/extensions/loader.d.ts.map +1 -1
  17. package/dist/core/extensions/loader.js +33 -1
  18. package/dist/core/extensions/loader.js.map +1 -1
  19. package/dist/core/extensions/types.d.ts +2 -0
  20. package/dist/core/extensions/types.d.ts.map +1 -1
  21. package/dist/core/extensions/types.js.map +1 -1
  22. package/dist/core/message-retention.d.ts +26 -0
  23. package/dist/core/message-retention.d.ts.map +1 -0
  24. package/dist/core/message-retention.js +95 -0
  25. package/dist/core/message-retention.js.map +1 -0
  26. package/dist/core/package-manager.d.ts.map +1 -1
  27. package/dist/core/package-manager.js +14 -6
  28. package/dist/core/package-manager.js.map +1 -1
  29. package/dist/core/resource-loader.d.ts.map +1 -1
  30. package/dist/core/resource-loader.js +4 -1
  31. package/dist/core/resource-loader.js.map +1 -1
  32. package/dist/core/session-manager.d.ts +3 -1
  33. package/dist/core/session-manager.d.ts.map +1 -1
  34. package/dist/core/session-manager.js +45 -9
  35. package/dist/core/session-manager.js.map +1 -1
  36. package/dist/core/skills.d.ts.map +1 -1
  37. package/dist/core/skills.js +12 -0
  38. package/dist/core/skills.js.map +1 -1
  39. package/dist/core/tools/git-filter.d.ts +9 -1
  40. package/dist/core/tools/git-filter.d.ts.map +1 -1
  41. package/dist/core/tools/git-filter.js +94 -8
  42. package/dist/core/tools/git-filter.js.map +1 -1
  43. package/dist/core/tools/read.d.ts +31 -0
  44. package/dist/core/tools/read.d.ts.map +1 -1
  45. package/dist/core/tools/read.js +164 -33
  46. package/dist/core/tools/read.js.map +1 -1
  47. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  48. package/dist/modes/interactive/components/tool-execution.js +37 -4
  49. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  50. package/dist/modes/interactive/interactive-mode.d.ts +2 -1
  51. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  52. package/dist/modes/interactive/interactive-mode.js +54 -18
  53. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  54. package/dist/modes/rpc/jsonl.d.ts +0 -7
  55. package/dist/modes/rpc/jsonl.d.ts.map +1 -1
  56. package/dist/modes/rpc/jsonl.js +17 -0
  57. package/dist/modes/rpc/jsonl.js.map +1 -1
  58. package/dist/utils/safe-write-stream.d.ts +10 -0
  59. package/dist/utils/safe-write-stream.d.ts.map +1 -0
  60. package/dist/utils/safe-write-stream.js +16 -0
  61. package/dist/utils/safe-write-stream.js.map +1 -0
  62. package/dist/utils/sleep.d.ts +3 -1
  63. package/dist/utils/sleep.d.ts.map +1 -1
  64. package/dist/utils/sleep.js +10 -4
  65. package/dist/utils/sleep.js.map +1 -1
  66. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  67. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  68. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  69. package/examples/extensions/sandbox/package-lock.json +2 -2
  70. package/examples/extensions/sandbox/package.json +1 -1
  71. package/examples/extensions/with-deps/package-lock.json +2 -2
  72. package/examples/extensions/with-deps/package.json +1 -1
  73. package/npm-shrinkwrap.json +12 -12
  74. package/package.json +4 -4
@@ -6,12 +6,5 @@ import type { Readable } from "node:stream";
6
6
  * U+2028 and U+2029. Clients must split records on `\n` only.
7
7
  */
8
8
  export declare function serializeJsonLine(value: unknown): string;
9
- /**
10
- * Attach an LF-only JSONL reader to a stream.
11
- *
12
- * This intentionally does not use Node readline. Readline splits on additional
13
- * Unicode separators that are valid inside JSON strings and therefore does not
14
- * implement strict JSONL framing.
15
- */
16
9
  export declare function attachJsonlLineReader(stream: Readable, onLine: (line: string) => void): () => void;
17
10
  //# sourceMappingURL=jsonl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsonl.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/jsonl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAExD;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAqClG","sourcesContent":["import type { Readable } from \"node:stream\";\nimport { StringDecoder } from \"node:string_decoder\";\n\n/**\n * Serialize a single strict JSONL record.\n *\n * Framing is LF-only. Payload strings may contain other Unicode separators such as\n * U+2028 and U+2029. Clients must split records on `\\n` only.\n */\nexport function serializeJsonLine(value: unknown): string {\n\treturn `${JSON.stringify(value)}\\n`;\n}\n\n/**\n * Attach an LF-only JSONL reader to a stream.\n *\n * This intentionally does not use Node readline. Readline splits on additional\n * Unicode separators that are valid inside JSON strings and therefore does not\n * implement strict JSONL framing.\n */\nexport function attachJsonlLineReader(stream: Readable, onLine: (line: string) => void): () => void {\n\tconst decoder = new StringDecoder(\"utf8\");\n\tlet buffer = \"\";\n\n\tconst emitLine = (line: string) => {\n\t\tonLine(line.endsWith(\"\\r\") ? line.slice(0, -1) : line);\n\t};\n\n\tconst onData = (chunk: string | Buffer) => {\n\t\tbuffer += typeof chunk === \"string\" ? chunk : decoder.write(chunk);\n\n\t\twhile (true) {\n\t\t\tconst newlineIndex = buffer.indexOf(\"\\n\");\n\t\t\tif (newlineIndex === -1) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\temitLine(buffer.slice(0, newlineIndex));\n\t\t\tbuffer = buffer.slice(newlineIndex + 1);\n\t\t}\n\t};\n\n\tconst onEnd = () => {\n\t\tbuffer += decoder.end();\n\t\tif (buffer.length > 0) {\n\t\t\temitLine(buffer);\n\t\t\tbuffer = \"\";\n\t\t}\n\t};\n\n\tstream.on(\"data\", onData);\n\tstream.on(\"end\", onEnd);\n\n\treturn () => {\n\t\tstream.off(\"data\", onData);\n\t\tstream.off(\"end\", onEnd);\n\t};\n}\n"]}
1
+ {"version":3,"file":"jsonl.d.ts","sourceRoot":"","sources":["../../../src/modes/rpc/jsonl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAExD;AAaD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAoDlG","sourcesContent":["import type { Readable } from \"node:stream\";\nimport { StringDecoder } from \"node:string_decoder\";\n\n/**\n * Serialize a single strict JSONL record.\n *\n * Framing is LF-only. Payload strings may contain other Unicode separators such as\n * U+2028 and U+2029. Clients must split records on `\\n` only.\n */\nexport function serializeJsonLine(value: unknown): string {\n\treturn `${JSON.stringify(value)}\\n`;\n}\n\n/**\n * Attach an LF-only JSONL reader to a stream.\n *\n * This intentionally does not use Node readline. Readline splits on additional\n * Unicode separators that are valid inside JSON strings and therefore does not\n * implement strict JSONL framing.\n */\n// A non-compliant peer streaming without newlines would otherwise grow the\n// line buffer without bound; one line can never legitimately exceed this.\nconst MAX_JSONL_LINE_CHARS = 64 * 1024 * 1024;\n\nexport function attachJsonlLineReader(stream: Readable, onLine: (line: string) => void): () => void {\n\tconst decoder = new StringDecoder(\"utf8\");\n\tlet buffer = \"\";\n\tlet discardingOversizedLine = false;\n\n\tconst emitLine = (line: string) => {\n\t\tonLine(line.endsWith(\"\\r\") ? line.slice(0, -1) : line);\n\t};\n\n\tconst onData = (chunk: string | Buffer) => {\n\t\tbuffer += typeof chunk === \"string\" ? chunk : decoder.write(chunk);\n\n\t\tif (discardingOversizedLine) {\n\t\t\tconst resumeIndex = buffer.indexOf(\"\\n\");\n\t\t\tif (resumeIndex === -1) {\n\t\t\t\tbuffer = \"\";\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbuffer = buffer.slice(resumeIndex + 1);\n\t\t\tdiscardingOversizedLine = false;\n\t\t}\n\n\t\twhile (true) {\n\t\t\tconst newlineIndex = buffer.indexOf(\"\\n\");\n\t\t\tif (newlineIndex === -1) {\n\t\t\t\tif (buffer.length > MAX_JSONL_LINE_CHARS) {\n\t\t\t\t\tdiscardingOversizedLine = true;\n\t\t\t\t\tbuffer = \"\";\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\temitLine(buffer.slice(0, newlineIndex));\n\t\t\tbuffer = buffer.slice(newlineIndex + 1);\n\t\t}\n\t};\n\n\tconst onEnd = () => {\n\t\tbuffer += decoder.end();\n\t\tif (buffer.length > 0) {\n\t\t\temitLine(buffer);\n\t\t\tbuffer = \"\";\n\t\t}\n\t};\n\n\tstream.on(\"data\", onData);\n\tstream.on(\"end\", onEnd);\n\n\treturn () => {\n\t\tstream.off(\"data\", onData);\n\t\tstream.off(\"end\", onEnd);\n\t};\n}\n"]}
@@ -15,17 +15,34 @@ export function serializeJsonLine(value) {
15
15
  * Unicode separators that are valid inside JSON strings and therefore does not
16
16
  * implement strict JSONL framing.
17
17
  */
18
+ // A non-compliant peer streaming without newlines would otherwise grow the
19
+ // line buffer without bound; one line can never legitimately exceed this.
20
+ const MAX_JSONL_LINE_CHARS = 64 * 1024 * 1024;
18
21
  export function attachJsonlLineReader(stream, onLine) {
19
22
  const decoder = new StringDecoder("utf8");
20
23
  let buffer = "";
24
+ let discardingOversizedLine = false;
21
25
  const emitLine = (line) => {
22
26
  onLine(line.endsWith("\r") ? line.slice(0, -1) : line);
23
27
  };
24
28
  const onData = (chunk) => {
25
29
  buffer += typeof chunk === "string" ? chunk : decoder.write(chunk);
30
+ if (discardingOversizedLine) {
31
+ const resumeIndex = buffer.indexOf("\n");
32
+ if (resumeIndex === -1) {
33
+ buffer = "";
34
+ return;
35
+ }
36
+ buffer = buffer.slice(resumeIndex + 1);
37
+ discardingOversizedLine = false;
38
+ }
26
39
  while (true) {
27
40
  const newlineIndex = buffer.indexOf("\n");
28
41
  if (newlineIndex === -1) {
42
+ if (buffer.length > MAX_JSONL_LINE_CHARS) {
43
+ discardingOversizedLine = true;
44
+ buffer = "";
45
+ }
29
46
  return;
30
47
  }
31
48
  emitLine(buffer.slice(0, newlineIndex));
@@ -1 +1 @@
1
- {"version":3,"file":"jsonl.js","sourceRoot":"","sources":["../../../src/modes/rpc/jsonl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc,EAAU;IACzD,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;AAAA,CACpC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAgB,EAAE,MAA8B,EAAc;IACnG,MAAM,OAAO,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC;QAClC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CA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{ StringDecoder } from \"node:string_decoder\";\n\n/**\n * Serialize a single strict JSONL record.\n *\n * Framing is LF-only. Payload strings may contain other Unicode separators such as\n * U+2028 and U+2029. Clients must split records on `\\n` only.\n */\nexport function serializeJsonLine(value: unknown): string {\n\treturn `${JSON.stringify(value)}\\n`;\n}\n\n/**\n * Attach an LF-only JSONL reader to a stream.\n *\n * This intentionally does not use Node readline. Readline splits on additional\n * Unicode separators that are valid inside JSON strings and therefore does not\n * implement strict JSONL framing.\n */\nexport function attachJsonlLineReader(stream: Readable, onLine: (line: string) => void): () => void {\n\tconst decoder = new StringDecoder(\"utf8\");\n\tlet buffer = \"\";\n\n\tconst emitLine = (line: string) => {\n\t\tonLine(line.endsWith(\"\\r\") ? line.slice(0, -1) : line);\n\t};\n\n\tconst onData = (chunk: string | Buffer) => {\n\t\tbuffer += typeof chunk === \"string\" ? chunk : decoder.write(chunk);\n\n\t\twhile (true) {\n\t\t\tconst newlineIndex = buffer.indexOf(\"\\n\");\n\t\t\tif (newlineIndex === -1) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\temitLine(buffer.slice(0, newlineIndex));\n\t\t\tbuffer = buffer.slice(newlineIndex + 1);\n\t\t}\n\t};\n\n\tconst onEnd = () => {\n\t\tbuffer += decoder.end();\n\t\tif (buffer.length > 0) {\n\t\t\temitLine(buffer);\n\t\t\tbuffer = \"\";\n\t\t}\n\t};\n\n\tstream.on(\"data\", onData);\n\tstream.on(\"end\", onEnd);\n\n\treturn () => {\n\t\tstream.off(\"data\", onData);\n\t\tstream.off(\"end\", onEnd);\n\t};\n}\n"]}
1
+ {"version":3,"file":"jsonl.js","sourceRoot":"","sources":["../../../src/modes/rpc/jsonl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAc,EAAU;IACzD,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,I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,CAAC,MAAM,GAAG,oBAAoB,EAAE,CAAC;oBAC1C,uBAAuB,GAAG,IAAI,CAAC;oBAC/B,MAAM,GAAG,EAAE,CAAC;gBACb,CAAC;gBACD,OAAO;YACR,CAAC;YAED,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC;YACxC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;QACzC,CAAC;IAAA,CACD,CAAC;IAEF,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC;QACnB,MAAM,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACxB,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,QAAQ,CAAC,MAAM,CAAC,CAAC;YACjB,MAAM,GAAG,EAAE,CAAC;QACb,CAAC;IAAA,CACD,CAAC;IAEF,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAExB,OAAO,GAAG,EAAE,CAAC;QACZ,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAAA,CACzB,CAAC;AAAA,CACF","sourcesContent":["import type { Readable } from \"node:stream\";\nimport { StringDecoder } from \"node:string_decoder\";\n\n/**\n * Serialize a single strict JSONL record.\n *\n * Framing is LF-only. Payload strings may contain other Unicode separators such as\n * U+2028 and U+2029. Clients must split records on `\\n` only.\n */\nexport function serializeJsonLine(value: unknown): string {\n\treturn `${JSON.stringify(value)}\\n`;\n}\n\n/**\n * Attach an LF-only JSONL reader to a stream.\n *\n * This intentionally does not use Node readline. Readline splits on additional\n * Unicode separators that are valid inside JSON strings and therefore does not\n * implement strict JSONL framing.\n */\n// A non-compliant peer streaming without newlines would otherwise grow the\n// line buffer without bound; one line can never legitimately exceed this.\nconst MAX_JSONL_LINE_CHARS = 64 * 1024 * 1024;\n\nexport function attachJsonlLineReader(stream: Readable, onLine: (line: string) => void): () => void {\n\tconst decoder = new StringDecoder(\"utf8\");\n\tlet buffer = \"\";\n\tlet discardingOversizedLine = false;\n\n\tconst emitLine = (line: string) => {\n\t\tonLine(line.endsWith(\"\\r\") ? line.slice(0, -1) : line);\n\t};\n\n\tconst onData = (chunk: string | Buffer) => {\n\t\tbuffer += typeof chunk === \"string\" ? chunk : decoder.write(chunk);\n\n\t\tif (discardingOversizedLine) {\n\t\t\tconst resumeIndex = buffer.indexOf(\"\\n\");\n\t\t\tif (resumeIndex === -1) {\n\t\t\t\tbuffer = \"\";\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbuffer = buffer.slice(resumeIndex + 1);\n\t\t\tdiscardingOversizedLine = false;\n\t\t}\n\n\t\twhile (true) {\n\t\t\tconst newlineIndex = buffer.indexOf(\"\\n\");\n\t\t\tif (newlineIndex === -1) {\n\t\t\t\tif (buffer.length > MAX_JSONL_LINE_CHARS) {\n\t\t\t\t\tdiscardingOversizedLine = true;\n\t\t\t\t\tbuffer = \"\";\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\temitLine(buffer.slice(0, newlineIndex));\n\t\t\tbuffer = buffer.slice(newlineIndex + 1);\n\t\t}\n\t};\n\n\tconst onEnd = () => {\n\t\tbuffer += decoder.end();\n\t\tif (buffer.length > 0) {\n\t\t\temitLine(buffer);\n\t\t\tbuffer = \"\";\n\t\t}\n\t};\n\n\tstream.on(\"data\", onData);\n\tstream.on(\"end\", onEnd);\n\n\treturn () => {\n\t\tstream.off(\"data\", onData);\n\t\tstream.off(\"end\", onEnd);\n\t};\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { type WriteStream } from "node:fs";
2
+ /**
3
+ * Create a WriteStream whose "error" event is always handled.
4
+ *
5
+ * Best-effort artifact writes (full-output temp files, overflow spills) must never
6
+ * crash the host process: an fs.WriteStream "error" event with no listener becomes
7
+ * an uncaught exception. Errors are reported through the optional callback instead.
8
+ */
9
+ export declare function createSafeWriteStream(path: string, onError?: (error: Error) => void): WriteStream;
10
+ //# sourceMappingURL=safe-write-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-write-stream.d.ts","sourceRoot":"","sources":["../../src/utils/safe-write-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAE9D;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,WAAW,CAMjG","sourcesContent":["import { createWriteStream, type WriteStream } from \"node:fs\";\n\n/**\n * Create a WriteStream whose \"error\" event is always handled.\n *\n * Best-effort artifact writes (full-output temp files, overflow spills) must never\n * crash the host process: an fs.WriteStream \"error\" event with no listener becomes\n * an uncaught exception. Errors are reported through the optional callback instead.\n */\nexport function createSafeWriteStream(path: string, onError?: (error: Error) => void): WriteStream {\n\tconst stream = createWriteStream(path);\n\tstream.on(\"error\", (error: Error) => {\n\t\tonError?.(error);\n\t});\n\treturn stream;\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { createWriteStream } from "node:fs";
2
+ /**
3
+ * Create a WriteStream whose "error" event is always handled.
4
+ *
5
+ * Best-effort artifact writes (full-output temp files, overflow spills) must never
6
+ * crash the host process: an fs.WriteStream "error" event with no listener becomes
7
+ * an uncaught exception. Errors are reported through the optional callback instead.
8
+ */
9
+ export function createSafeWriteStream(path, onError) {
10
+ const stream = createWriteStream(path);
11
+ stream.on("error", (error) => {
12
+ onError?.(error);
13
+ });
14
+ return stream;
15
+ }
16
+ //# sourceMappingURL=safe-write-stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-write-stream.js","sourceRoot":"","sources":["../../src/utils/safe-write-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAoB,MAAM,SAAS,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,OAAgC,EAAe;IAClG,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE,CAAC;QACpC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IAAA,CACjB,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAAA,CACd","sourcesContent":["import { createWriteStream, type WriteStream } from \"node:fs\";\n\n/**\n * Create a WriteStream whose \"error\" event is always handled.\n *\n * Best-effort artifact writes (full-output temp files, overflow spills) must never\n * crash the host process: an fs.WriteStream \"error\" event with no listener becomes\n * an uncaught exception. Errors are reported through the optional callback instead.\n */\nexport function createSafeWriteStream(path: string, onError?: (error: Error) => void): WriteStream {\n\tconst stream = createWriteStream(path);\n\tstream.on(\"error\", (error: Error) => {\n\t\tonError?.(error);\n\t});\n\treturn stream;\n}\n"]}
@@ -1,5 +1,7 @@
1
1
  /**
2
- * Sleep helper that respects abort signal.
2
+ * Sleep helper that respects abort signal. Always detaches its abort listener when
3
+ * settling, so repeated sleeps (e.g. retry backoff) on a long-lived signal do not
4
+ * accumulate listeners for the signal's lifetime.
3
5
  */
4
6
  export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
5
7
  //# sourceMappingURL=sleep.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../src/utils/sleep.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAcrE","sourcesContent":["/**\n * Sleep helper that respects abort signal.\n */\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal?.aborted) {\n\t\t\treject(new Error(\"Aborted\"));\n\t\t\treturn;\n\t\t}\n\n\t\tconst timeout = setTimeout(resolve, ms);\n\n\t\tsignal?.addEventListener(\"abort\", () => {\n\t\t\tclearTimeout(timeout);\n\t\t\treject(new Error(\"Aborted\"));\n\t\t});\n\t});\n}\n"]}
1
+ {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../src/utils/sleep.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBrE","sourcesContent":["/**\n * Sleep helper that respects abort signal. Always detaches its abort listener when\n * settling, so repeated sleeps (e.g. retry backoff) on a long-lived signal do not\n * accumulate listeners for the signal's lifetime.\n */\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal?.aborted) {\n\t\t\treject(new Error(\"Aborted\"));\n\t\t\treturn;\n\t\t}\n\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(timeout);\n\t\t\treject(new Error(\"Aborted\"));\n\t\t};\n\n\t\tconst timeout = setTimeout(() => {\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve();\n\t\t}, ms);\n\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n}\n"]}
@@ -1,5 +1,7 @@
1
1
  /**
2
- * Sleep helper that respects abort signal.
2
+ * Sleep helper that respects abort signal. Always detaches its abort listener when
3
+ * settling, so repeated sleeps (e.g. retry backoff) on a long-lived signal do not
4
+ * accumulate listeners for the signal's lifetime.
3
5
  */
4
6
  export function sleep(ms, signal) {
5
7
  return new Promise((resolve, reject) => {
@@ -7,11 +9,15 @@ export function sleep(ms, signal) {
7
9
  reject(new Error("Aborted"));
8
10
  return;
9
11
  }
10
- const timeout = setTimeout(resolve, ms);
11
- signal?.addEventListener("abort", () => {
12
+ const onAbort = () => {
12
13
  clearTimeout(timeout);
13
14
  reject(new Error("Aborted"));
14
- });
15
+ };
16
+ const timeout = setTimeout(() => {
17
+ signal?.removeEventListener("abort", onAbort);
18
+ resolve();
19
+ }, ms);
20
+ signal?.addEventListener("abort", onAbort, { once: true });
15
21
  });
16
22
  }
17
23
  //# sourceMappingURL=sleep.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/utils/sleep.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,EAAU,EAAE,MAAoB,EAAiB;IACtE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;QACvC,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACrB,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;YAC7B,OAAO;QACR,CAAC;QAED,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAExC,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC;YACvC,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;QAAA,CAC7B,CAAC,CAAC;IAAA,CACH,CAAC,CAAC;AAAA,CACH","sourcesContent":["/**\n * Sleep helper that respects abort signal.\n */\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal?.aborted) {\n\t\t\treject(new Error(\"Aborted\"));\n\t\t\treturn;\n\t\t}\n\n\t\tconst timeout = setTimeout(resolve, ms);\n\n\t\tsignal?.addEventListener(\"abort\", () => {\n\t\t\tclearTimeout(timeout);\n\t\t\treject(new Error(\"Aborted\"));\n\t\t});\n\t});\n}\n"]}
1
+ {"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/utils/sleep.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,EAAU,EAAE,MAAoB,EAAiB;IACtE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;QACvC,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACrB,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;YAC7B,OAAO;QACR,CAAC;QAED,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC;YACrB,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;QAAA,CAC7B,CAAC;QAEF,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC;YAChC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,OAAO,EAAE,CAAC;QAAA,CACV,EAAE,EAAE,CAAC,CAAC;QAEP,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAAA,CAC3D,CAAC,CAAC;AAAA,CACH","sourcesContent":["/**\n * Sleep helper that respects abort signal. Always detaches its abort listener when\n * settling, so repeated sleeps (e.g. retry backoff) on a long-lived signal do not\n * accumulate listeners for the signal's lifetime.\n */\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n\treturn new Promise((resolve, reject) => {\n\t\tif (signal?.aborted) {\n\t\t\treject(new Error(\"Aborted\"));\n\t\t\treturn;\n\t\t}\n\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(timeout);\n\t\t\treject(new Error(\"Aborted\"));\n\t\t};\n\n\t\tconst timeout = setTimeout(() => {\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve();\n\t\t}, ms);\n\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n}\n"]}
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider",
3
- "version": "0.80.19",
3
+ "version": "0.80.20",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-custom-provider",
9
- "version": "0.80.19",
9
+ "version": "0.80.20",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.52.0"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-anthropic",
3
3
  "private": true,
4
- "version": "0.80.19",
4
+ "version": "0.80.20",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-gitlab-duo",
3
3
  "private": true,
4
- "version": "0.80.19",
4
+ "version": "0.80.20",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
- "version": "0.80.19",
3
+ "version": "0.80.20",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-sandbox",
9
- "version": "0.80.19",
9
+ "version": "0.80.20",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sandbox-runtime": "^0.0.26"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
3
  "private": true,
4
- "version": "0.80.19",
4
+ "version": "0.80.20",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
- "version": "0.80.19",
3
+ "version": "0.80.20",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-with-deps",
9
- "version": "0.80.19",
9
+ "version": "0.80.20",
10
10
  "dependencies": {
11
11
  "ms": "^2.1.3"
12
12
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
3
  "private": true,
4
- "version": "0.80.19",
4
+ "version": "0.80.20",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@caupulican/pi-adaptative",
3
- "version": "0.80.22",
3
+ "version": "0.80.23",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@caupulican/pi-adaptative",
9
- "version": "0.80.22",
9
+ "version": "0.80.23",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@caupulican/pi-agent-core": "^0.80.22",
13
- "@caupulican/pi-ai": "^0.80.22",
14
- "@caupulican/pi-tui": "^0.80.22",
12
+ "@caupulican/pi-agent-core": "^0.80.23",
13
+ "@caupulican/pi-ai": "^0.80.23",
14
+ "@caupulican/pi-tui": "^0.80.23",
15
15
  "@silvia-odwyer/photon-node": "0.3.4",
16
16
  "chalk": "5.6.2",
17
17
  "cross-spawn": "7.0.6",
@@ -474,11 +474,11 @@
474
474
  }
475
475
  },
476
476
  "node_modules/@caupulican/pi-agent-core": {
477
- "version": "0.80.22",
478
- "resolved": "https://registry.npmjs.org/@caupulican/pi-agent-core/-/pi-agent-core-0.80.22.tgz",
477
+ "version": "0.80.23",
478
+ "resolved": "https://registry.npmjs.org/@caupulican/pi-agent-core/-/pi-agent-core-0.80.23.tgz",
479
479
  "license": "MIT",
480
480
  "dependencies": {
481
- "@caupulican/pi-ai": "^0.80.22",
481
+ "@caupulican/pi-ai": "^0.80.23",
482
482
  "ignore": "7.0.5",
483
483
  "typebox": "1.1.38",
484
484
  "yaml": "2.9.0"
@@ -488,8 +488,8 @@
488
488
  }
489
489
  },
490
490
  "node_modules/@caupulican/pi-ai": {
491
- "version": "0.80.22",
492
- "resolved": "https://registry.npmjs.org/@caupulican/pi-ai/-/pi-ai-0.80.22.tgz",
491
+ "version": "0.80.23",
492
+ "resolved": "https://registry.npmjs.org/@caupulican/pi-ai/-/pi-ai-0.80.23.tgz",
493
493
  "license": "MIT",
494
494
  "dependencies": {
495
495
  "@anthropic-ai/sdk": "0.91.1",
@@ -511,8 +511,8 @@
511
511
  }
512
512
  },
513
513
  "node_modules/@caupulican/pi-tui": {
514
- "version": "0.80.22",
515
- "resolved": "https://registry.npmjs.org/@caupulican/pi-tui/-/pi-tui-0.80.22.tgz",
514
+ "version": "0.80.23",
515
+ "resolved": "https://registry.npmjs.org/@caupulican/pi-tui/-/pi-tui-0.80.23.tgz",
516
516
  "license": "MIT",
517
517
  "dependencies": {
518
518
  "get-east-asian-width": "1.6.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caupulican/pi-adaptative",
3
- "version": "0.80.22",
3
+ "version": "0.80.23",
4
4
  "description": "Adaptive fork of Pi coding agent for self-evolving agent harness experiments",
5
5
  "type": "module",
6
6
  "piConfig": {
@@ -41,9 +41,9 @@
41
41
  "prepublishOnly": "npm run clean && npm run build && npm run shrinkwrap"
42
42
  },
43
43
  "dependencies": {
44
- "@caupulican/pi-agent-core": "^0.80.22",
45
- "@caupulican/pi-ai": "^0.80.22",
46
- "@caupulican/pi-tui": "^0.80.22",
44
+ "@caupulican/pi-agent-core": "^0.80.23",
45
+ "@caupulican/pi-ai": "^0.80.23",
46
+ "@caupulican/pi-tui": "^0.80.23",
47
47
  "@silvia-odwyer/photon-node": "0.3.4",
48
48
  "chalk": "5.6.2",
49
49
  "cross-spawn": "7.0.6",