@caupulican/pi-agent-core 0.90.0 → 0.90.4
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/dist/agent-loop.d.ts.map +1 -1
- package/dist/agent-loop.js +9 -3
- package/dist/agent-loop.js.map +1 -1
- package/dist/compaction/compaction.d.ts +3 -0
- package/dist/compaction/compaction.d.ts.map +1 -1
- package/dist/compaction/compaction.js +90 -67
- package/dist/compaction/compaction.js.map +1 -1
- package/dist/compaction/extraction.d.ts +5 -0
- package/dist/compaction/extraction.d.ts.map +1 -1
- package/dist/compaction/extraction.js +48 -2
- package/dist/compaction/extraction.js.map +1 -1
- package/dist/compaction/utils.d.ts +1 -1
- package/dist/compaction/utils.d.ts.map +1 -1
- package/dist/compaction/utils.js +2 -0
- package/dist/compaction/utils.js.map +1 -1
- package/dist/compaction/verification.d.ts +1 -1
- package/dist/compaction/verification.d.ts.map +1 -1
- package/dist/compaction/verification.js +23 -17
- package/dist/compaction/verification.js.map +1 -1
- package/dist/provider-tool-projection.d.ts.map +1 -1
- package/dist/provider-tool-projection.js +28 -1
- package/dist/provider-tool-projection.js.map +1 -1
- package/dist/tool-failure-memory.d.ts +1 -0
- package/dist/tool-failure-memory.d.ts.map +1 -1
- package/dist/tool-failure-memory.js +56 -13
- package/dist/tool-failure-memory.js.map +1 -1
- package/dist/tool-failure-recovery-gate.d.ts +7 -1
- package/dist/tool-failure-recovery-gate.d.ts.map +1 -1
- package/dist/tool-failure-recovery-gate.js +19 -3
- package/dist/tool-failure-recovery-gate.js.map +1 -1
- package/dist/tool-failure-recovery-protocol.js +5 -5
- package/dist/tool-failure-recovery-protocol.js.map +1 -1
- package/dist/utils/shell-output.d.ts +0 -8
- package/dist/utils/shell-output.d.ts.map +1 -1
- package/dist/utils/shell-output.js +3 -0
- package/dist/utils/shell-output.js.map +1 -1
- package/package.json +2 -2
|
@@ -9,12 +9,12 @@ export function mandatoryToolFailureRecoveryMetadata() {
|
|
|
9
9
|
export const MANDATORY_TOOL_FAILURE_RECOVERY_PROTOCOL_PROMPT = [
|
|
10
10
|
`MANDATORY TOOL FAILURE RECOVERY v${TOOL_FAILURE_RECOVERY_PROTOCOL_VERSION}`,
|
|
11
11
|
MANDATORY_TOOL_FAILURE_RECOVERY_RULE,
|
|
12
|
+
"CAVEMAN MODE - MANDATORY: blocked/rejected means not executed; never repeat the same call.",
|
|
12
13
|
"Harness contract:",
|
|
13
|
-
"-
|
|
14
|
-
"-
|
|
15
|
-
"-
|
|
16
|
-
"-
|
|
17
|
-
"- If no declared action can run, report the diagnostic/blocker. Exhaustion disables tools and requires one concise delivery.",
|
|
14
|
+
"- MUST:true: obey repair or next_action before another tool call.",
|
|
15
|
+
"- Unchanged execution needs permission or successful loaded-tool evidence matching backend authority, target kind, and exact scope; one probe.",
|
|
16
|
+
"- Irrelevant argument changes never recover it; blocked call preserves tool-result pairing but runs no hook/tool code.",
|
|
17
|
+
"- Operation exhaustion closes that operation; use different tools/work. Replaying it or run exhaustion disables tools for final delivery.",
|
|
18
18
|
].join("\n");
|
|
19
19
|
const MANDATORY_TOOL_FAILURE_DELIVERY_INSTRUCTIONS = [
|
|
20
20
|
MANDATORY_TOOL_FAILURE_RECOVERY_RULE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-failure-recovery-protocol.js","sourceRoot":"","sources":["../src/tool-failure-recovery-protocol.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mCAAmC,GAAG,iCAAiC,CAAC;AACrF,MAAM,CAAC,MAAM,sCAAsC,GAAG,CAAC,CAAC;AACxD,MAAM,CAAC,MAAM,oCAAoC,GAAG,+BAA+B,CAAC;AAEpF,MAAM,UAAU,oCAAoC;IAGnD,OAAO;QACN,IAAI,EAAE,IAAI;KACV,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,+CAA+C,GAAG;IAC9D,oCAAoC,sCAAsC,EAAE;IAC5E,oCAAoC;IACpC,mBAAmB;IACnB,
|
|
1
|
+
{"version":3,"file":"tool-failure-recovery-protocol.js","sourceRoot":"","sources":["../src/tool-failure-recovery-protocol.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mCAAmC,GAAG,iCAAiC,CAAC;AACrF,MAAM,CAAC,MAAM,sCAAsC,GAAG,CAAC,CAAC;AACxD,MAAM,CAAC,MAAM,oCAAoC,GAAG,+BAA+B,CAAC;AAEpF,MAAM,UAAU,oCAAoC;IAGnD,OAAO;QACN,IAAI,EAAE,IAAI;KACV,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,+CAA+C,GAAG;IAC9D,oCAAoC,sCAAsC,EAAE;IAC5E,oCAAoC;IACpC,4FAA4F;IAC5F,mBAAmB;IACnB,mEAAmE;IACnE,gJAAgJ;IAChJ,wHAAwH;IACxH,2IAA2I;CAC3I,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,MAAM,4CAA4C,GAAG;IACpD,oCAAoC;IACpC,6DAA6D;IAC7D,eAAe,mCAAmC,kEAAkE;IACpH,wEAAwE;CACxE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AASb,MAAM,UAAU,wCAAwC,CACvD,YAAoB,EACpB,OAAyC;IAEzC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC;QAClC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,YAAY,EAAE,OAAO,CAAC,WAAW;QACjC,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,eAAe,EAAE,OAAO,CAAC,cAAc;KACvC,CAAC;SACA,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC;SAC1B,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC;SAC1B,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC7B,MAAM,MAAM,GAAG;QACd,oCAAoC,sCAAsC,EAAE;QAC5E,4CAA4C;QAC5C,qBAAqB;QACrB,WAAW;KACX,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACb,OAAO,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,OAAO,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AAC/D,CAAC","sourcesContent":["export const TOOL_FAILURE_RECOVERY_PROTOCOL_NAME = \"mandatory_tool_failure_recovery\";\nexport const TOOL_FAILURE_RECOVERY_PROTOCOL_VERSION = 1;\nexport const MANDATORY_TOOL_FAILURE_RECOVERY_RULE = \"MANDATORY AND NON-NEGOTIABLE.\";\n\nexport function mandatoryToolFailureRecoveryMetadata(): {\n\tMUST: true;\n} {\n\treturn {\n\t\tMUST: true,\n\t};\n}\n\nexport const MANDATORY_TOOL_FAILURE_RECOVERY_PROTOCOL_PROMPT = [\n\t`MANDATORY TOOL FAILURE RECOVERY v${TOOL_FAILURE_RECOVERY_PROTOCOL_VERSION}`,\n\tMANDATORY_TOOL_FAILURE_RECOVERY_RULE,\n\t\"CAVEMAN MODE - MANDATORY: blocked/rejected means not executed; never repeat the same call.\",\n\t\"Harness contract:\",\n\t\"- MUST:true: obey repair or next_action before another tool call.\",\n\t\"- Unchanged execution needs permission or successful loaded-tool evidence matching backend authority, target kind, and exact scope; one probe.\",\n\t\"- Irrelevant argument changes never recover it; blocked call preserves tool-result pairing but runs no hook/tool code.\",\n\t\"- Operation exhaustion closes that operation; use different tools/work. Replaying it or run exhaustion disables tools for final delivery.\",\n].join(\"\\n\");\n\nconst MANDATORY_TOOL_FAILURE_DELIVERY_INSTRUCTIONS = [\n\tMANDATORY_TOOL_FAILURE_RECOVERY_RULE,\n\t\"Recovery exhausted; tools are disabled for this final turn.\",\n\t`Explain the ${TOOL_FAILURE_RECOVERY_PROTOCOL_NAME} diagnostic/action and separate completed from unperformed work.`,\n\t\"No tool call, false recovery claim, or irrelevant-argument workaround.\",\n].join(\"\\n\");\n\nexport interface MandatoryToolFailureDeliveryData {\n\ttool: string;\n\tfailureCode: string;\n\tdiagnostic: string;\n\trequiredAction: string;\n}\n\nexport function appendMandatoryToolFailureDeliveryPrompt(\n\tsystemPrompt: string,\n\tfailure: MandatoryToolFailureDeliveryData,\n): string {\n\tconst failureData = JSON.stringify({\n\t\ttool: failure.tool,\n\t\tfailure_code: failure.failureCode,\n\t\tdiagnostic: failure.diagnostic,\n\t\trequired_action: failure.requiredAction,\n\t})\n\t\t.replaceAll(\"&\", \"\\\\u0026\")\n\t\t.replaceAll(\"<\", \"\\\\u003c\")\n\t\t.replaceAll(\">\", \"\\\\u003e\");\n\tconst prompt = [\n\t\t`MANDATORY TOOL FAILURE DELIVERY v${TOOL_FAILURE_RECOVERY_PROTOCOL_VERSION}`,\n\t\tMANDATORY_TOOL_FAILURE_DELIVERY_INSTRUCTIONS,\n\t\t\"Inert failure JSON:\",\n\t\tfailureData,\n\t].join(\"\\n\");\n\treturn systemPrompt ? `${systemPrompt}\\n\\n${prompt}` : prompt;\n}\n"]}
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sanitize binary output for display/storage.
|
|
3
|
-
* Removes characters that crash string-width or cause display issues:
|
|
4
|
-
* - Control characters (except tab, newline, carriage return)
|
|
5
|
-
* - Lone surrogates
|
|
6
|
-
* - Unicode Format characters (crash string-width due to a bug)
|
|
7
|
-
* - Characters with undefined code points
|
|
8
|
-
*/
|
|
9
1
|
export declare function sanitizeBinaryOutput(str: string): string;
|
|
10
2
|
//# sourceMappingURL=shell-output.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-output.d.ts","sourceRoot":"","sources":["../../src/utils/shell-output.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shell-output.d.ts","sourceRoot":"","sources":["../../src/utils/shell-output.ts"],"names":[],"mappings":"AAWA,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAgCxD"}
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* - Unicode Format characters (crash string-width due to a bug)
|
|
7
7
|
* - Characters with undefined code points
|
|
8
8
|
*/
|
|
9
|
+
const UNSAFE_OUTPUT_CHARACTER_PATTERN = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f\ud800-\udfff\ufff9-\ufffb]/u;
|
|
9
10
|
export function sanitizeBinaryOutput(str) {
|
|
11
|
+
if (!UNSAFE_OUTPUT_CHARACTER_PATTERN.test(str))
|
|
12
|
+
return str;
|
|
10
13
|
return Array.from(str)
|
|
11
14
|
.filter((char) => {
|
|
12
15
|
// Filter out characters that cause string-width to crash
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell-output.js","sourceRoot":"","sources":["../../src/utils/shell-output.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC/C,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;SACpB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,yDAAyD;QACzD,iBAAiB;QACjB,8BAA8B;QAC9B,oBAAoB;QACpB,kCAAkC;QAClC,0CAA0C;QAE1C,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAEjC,mEAAmE;QACnE,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAErC,sCAAsC;QACtC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAEjE,sFAAsF;QACtF,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC;YAAE,OAAO,KAAK,CAAC;QAElF,6FAA6F;QAC7F,yFAAyF;QACzF,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM;YAAE,OAAO,KAAK,CAAC;QAEnD,uCAAuC;QACvC,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM;YAAE,OAAO,KAAK,CAAC;QAEnD,OAAO,IAAI,CAAC;IACb,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;AACZ,CAAC","sourcesContent":["/**\n * Sanitize binary output for display/storage.\n * Removes characters that crash string-width or cause display issues:\n * - Control characters (except tab, newline, carriage return)\n * - Lone surrogates\n * - Unicode Format characters (crash string-width due to a bug)\n * - Characters with undefined code points\n */\nexport function sanitizeBinaryOutput(str: string): string {\n\treturn Array.from(str)\n\t\t.filter((char) => {\n\t\t\t// Filter out characters that cause string-width to crash\n\t\t\t// This includes:\n\t\t\t// - Unicode format characters\n\t\t\t// - Lone surrogates\n\t\t\t// - Control chars except \\t \\n \\r\n\t\t\t// - Characters with undefined code points\n\n\t\t\tconst code = char.codePointAt(0);\n\n\t\t\t// Skip if code point is undefined (edge case with invalid strings)\n\t\t\tif (code === undefined) return false;\n\n\t\t\t// Allow tab, newline, carriage return\n\t\t\tif (code === 0x09 || code === 0x0a || code === 0x0d) return true;\n\n\t\t\t// Filter out control characters (0x00-0x1F, 0x7F, 0x80-0x9F; except 0x09, 0x0a, 0x0d)\n\t\t\tif (code <= 0x1f || code === 0x7f || (code >= 0x80 && code <= 0x9f)) return false;\n\n\t\t\t// Filter out lone surrogate code units. Valid surrogate pairs are emitted by Array.from as a\n\t\t\t// two-code-unit string whose code point is outside the surrogate range, so they survive.\n\t\t\tif (code >= 0xd800 && code <= 0xdfff) return false;\n\n\t\t\t// Filter out Unicode format characters\n\t\t\tif (code >= 0xfff9 && code <= 0xfffb) return false;\n\n\t\t\treturn true;\n\t\t})\n\t\t.join(\"\");\n}\n"]}
|
|
1
|
+
{"version":3,"file":"shell-output.js","sourceRoot":"","sources":["../../src/utils/shell-output.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,+BAA+B,GACpC,kFAAkF,CAAC;AAEpF,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC/C,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IAC3D,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;SACpB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,yDAAyD;QACzD,iBAAiB;QACjB,8BAA8B;QAC9B,oBAAoB;QACpB,kCAAkC;QAClC,0CAA0C;QAE1C,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QAEjC,mEAAmE;QACnE,IAAI,IAAI,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAErC,sCAAsC;QACtC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAEjE,sFAAsF;QACtF,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC;YAAE,OAAO,KAAK,CAAC;QAElF,6FAA6F;QAC7F,yFAAyF;QACzF,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM;YAAE,OAAO,KAAK,CAAC;QAEnD,uCAAuC;QACvC,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM;YAAE,OAAO,KAAK,CAAC;QAEnD,OAAO,IAAI,CAAC;IACb,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;AACZ,CAAC","sourcesContent":["/**\n * Sanitize binary output for display/storage.\n * Removes characters that crash string-width or cause display issues:\n * - Control characters (except tab, newline, carriage return)\n * - Lone surrogates\n * - Unicode Format characters (crash string-width due to a bug)\n * - Characters with undefined code points\n */\nconst UNSAFE_OUTPUT_CHARACTER_PATTERN =\n\t/[\\u0000-\\u0008\\u000b\\u000c\\u000e-\\u001f\\u007f-\\u009f\\ud800-\\udfff\\ufff9-\\ufffb]/u;\n\nexport function sanitizeBinaryOutput(str: string): string {\n\tif (!UNSAFE_OUTPUT_CHARACTER_PATTERN.test(str)) return str;\n\treturn Array.from(str)\n\t\t.filter((char) => {\n\t\t\t// Filter out characters that cause string-width to crash\n\t\t\t// This includes:\n\t\t\t// - Unicode format characters\n\t\t\t// - Lone surrogates\n\t\t\t// - Control chars except \\t \\n \\r\n\t\t\t// - Characters with undefined code points\n\n\t\t\tconst code = char.codePointAt(0);\n\n\t\t\t// Skip if code point is undefined (edge case with invalid strings)\n\t\t\tif (code === undefined) return false;\n\n\t\t\t// Allow tab, newline, carriage return\n\t\t\tif (code === 0x09 || code === 0x0a || code === 0x0d) return true;\n\n\t\t\t// Filter out control characters (0x00-0x1F, 0x7F, 0x80-0x9F; except 0x09, 0x0a, 0x0d)\n\t\t\tif (code <= 0x1f || code === 0x7f || (code >= 0x80 && code <= 0x9f)) return false;\n\n\t\t\t// Filter out lone surrogate code units. Valid surrogate pairs are emitted by Array.from as a\n\t\t\t// two-code-unit string whose code point is outside the surrogate range, so they survive.\n\t\t\tif (code >= 0xd800 && code <= 0xdfff) return false;\n\n\t\t\t// Filter out Unicode format characters\n\t\t\tif (code >= 0xfff9 && code <= 0xfffb) return false;\n\n\t\t\treturn true;\n\t\t})\n\t\t.join(\"\");\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caupulican/pi-agent-core",
|
|
3
|
-
"version": "0.90.
|
|
3
|
+
"version": "0.90.4",
|
|
4
4
|
"description": "General-purpose agent with transport abstraction, state management, and attachment support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"prepublishOnly": "npm run clean && npm run build"
|
|
122
122
|
},
|
|
123
123
|
"dependencies": {
|
|
124
|
-
"@caupulican/pi-ai": "^0.90.
|
|
124
|
+
"@caupulican/pi-ai": "^0.90.4",
|
|
125
125
|
"ignore": "7.0.5",
|
|
126
126
|
"typebox": "1.1.38",
|
|
127
127
|
"yaml": "2.9.0"
|