@vtstech/pi-react-fallback 1.0.3 → 1.0.4-1
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 +29 -0
- package/package.json +3 -2
- package/react-fallback.js +25 -45
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @vtstech/pi-react-fallback
|
|
2
|
+
|
|
3
|
+
ReAct fallback extension for the [Pi Coding Agent](https://github.com/badlogic/pi-mono).
|
|
4
|
+
|
|
5
|
+
Text-based tool calling bridge for models without native function calling support.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pi install "npm:@vtstech/pi-react-fallback"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## How It Works
|
|
14
|
+
|
|
15
|
+
Automatically loaded — no commands needed. When a model lacks native tool calling:
|
|
16
|
+
|
|
17
|
+
- Parses `Thought:`, `Action:`, `Action Input:` patterns from model output
|
|
18
|
+
- Multiple regex strategies including parenthetical style and loose matching
|
|
19
|
+
- Bridges text-based tool calls into Pi's native tool execution pipeline
|
|
20
|
+
- Falls back when native tool calls fail
|
|
21
|
+
|
|
22
|
+
## Links
|
|
23
|
+
|
|
24
|
+
- [Full Documentation](https://github.com/VTSTech/pi-coding-agent#react-fallback-react-fallbackts)
|
|
25
|
+
- [Changelog](https://github.com/VTSTech/pi-coding-agent/blob/main/CHANGELOG.md)
|
|
26
|
+
|
|
27
|
+
## License
|
|
28
|
+
|
|
29
|
+
MIT — [VTSTech](https://www.vts-tech.org)
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtstech/pi-react-fallback",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4-1",
|
|
4
4
|
"description": "ReAct fallback extension for Pi Coding Agent",
|
|
5
5
|
"main": "react-fallback.js",
|
|
6
6
|
"keywords": ["pi-package", "pi-extensions"],
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"access": "public",
|
|
9
|
+
"type": "module",
|
|
9
10
|
"author": "VTSTech",
|
|
10
11
|
"homepage": "https://www.vts-tech.org",
|
|
11
12
|
"repository": {
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
"url": "https://github.com/VTSTech/pi-coding-agent"
|
|
14
15
|
},
|
|
15
16
|
"dependencies": {
|
|
16
|
-
"@vtstech/pi-shared": "1.0.
|
|
17
|
+
"@vtstech/pi-shared": "1.0.4-1"
|
|
17
18
|
},
|
|
18
19
|
"peerDependencies": {
|
|
19
20
|
"@mariozechner/pi-coding-agent": ">=0.66"
|
package/react-fallback.js
CHANGED
|
@@ -1,28 +1,5 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
1
|
// .build-npm/react-fallback/react-fallback.temp.ts
|
|
20
|
-
|
|
21
|
-
__export(react_fallback_temp_exports, {
|
|
22
|
-
default: () => react_fallback_temp_default
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(react_fallback_temp_exports);
|
|
25
|
-
var import_format = require("@vtstech/pi-shared/format");
|
|
2
|
+
import { section, ok, fail, warn, info } from "@vtstech/pi-shared/format";
|
|
26
3
|
function sanitizeModelJson(text) {
|
|
27
4
|
text = text.replace(/:\s*True\b/g, ": true");
|
|
28
5
|
text = text.replace(/:\s*False\b/g, ": false");
|
|
@@ -393,15 +370,15 @@ ${argsJson}`
|
|
|
393
370
|
const status = reactModeEnabled ? "ENABLED" : "DISABLED";
|
|
394
371
|
ctx.ui.notify(`ReAct mode ${status}`, "success");
|
|
395
372
|
const lines = [branding];
|
|
396
|
-
lines.push(
|
|
397
|
-
lines.push(
|
|
398
|
-
lines.push(
|
|
399
|
-
lines.push(
|
|
400
|
-
lines.push(
|
|
401
|
-
lines.push(
|
|
373
|
+
lines.push(section("REACT FALLBACK MODE"));
|
|
374
|
+
lines.push(info(`Status: ${status}`));
|
|
375
|
+
lines.push(info(`Bridge calls: ${stats.bridgeCalls}`));
|
|
376
|
+
lines.push(info(`Fuzzy matches: ${stats.fuzzyMatches}`));
|
|
377
|
+
lines.push(info(`Argument normalizations: ${stats.argNormalizations}`));
|
|
378
|
+
lines.push(info(`Parse failures: ${stats.parseFailures}`));
|
|
402
379
|
if (reactModeEnabled) {
|
|
403
|
-
lines.push(
|
|
404
|
-
lines.push(
|
|
380
|
+
lines.push(ok("The tool_call bridge tool is now available to the model"));
|
|
381
|
+
lines.push(info("ReAct system prompt instructions have been added"));
|
|
405
382
|
}
|
|
406
383
|
const report = lines.join("\n");
|
|
407
384
|
pi2.sendMessage({
|
|
@@ -420,17 +397,17 @@ ${argsJson}`
|
|
|
420
397
|
return;
|
|
421
398
|
}
|
|
422
399
|
const lines = [branding];
|
|
423
|
-
lines.push(
|
|
424
|
-
lines.push(
|
|
400
|
+
lines.push(section("REACT PARSER TEST"));
|
|
401
|
+
lines.push(info(`Input: ${text.slice(0, 100)}${text.length > 100 ? "..." : ""}`));
|
|
425
402
|
const reactResult = parseReact(text);
|
|
426
403
|
if (reactResult) {
|
|
427
|
-
lines.push(
|
|
428
|
-
lines.push(
|
|
429
|
-
lines.push(
|
|
430
|
-
if (reactResult.thought) lines.push(
|
|
431
|
-
if (reactResult.finalAnswer) lines.push(
|
|
404
|
+
lines.push(ok("ReAct format detected!"));
|
|
405
|
+
lines.push(info(`Tool: ${reactResult.name}`));
|
|
406
|
+
lines.push(info(`Args: ${JSON.stringify(reactResult.args)}`));
|
|
407
|
+
if (reactResult.thought) lines.push(info(`Thought: ${reactResult.thought}`));
|
|
408
|
+
if (reactResult.finalAnswer) lines.push(info(`Final Answer: ${reactResult.finalAnswer}`));
|
|
432
409
|
} else {
|
|
433
|
-
lines.push(
|
|
410
|
+
lines.push(fail("No ReAct format detected"));
|
|
434
411
|
}
|
|
435
412
|
try {
|
|
436
413
|
const firstBrace = text.indexOf("{");
|
|
@@ -441,20 +418,20 @@ ${argsJson}`
|
|
|
441
418
|
const parsed = JSON.parse(sanitizeModelJson(jsonStr));
|
|
442
419
|
const toolResult = extractToolFromJson(parsed);
|
|
443
420
|
if (toolResult) {
|
|
444
|
-
lines.push(
|
|
445
|
-
lines.push(
|
|
446
|
-
lines.push(
|
|
421
|
+
lines.push(ok("JSON tool call detected!"));
|
|
422
|
+
lines.push(info(`Tool: ${toolResult.name}`));
|
|
423
|
+
lines.push(info(`Args: ${JSON.stringify(toolResult.args)}`));
|
|
447
424
|
}
|
|
448
425
|
}
|
|
449
426
|
}
|
|
450
427
|
} catch {
|
|
451
428
|
}
|
|
452
429
|
if (looksLikeSchemaDump(text)) {
|
|
453
|
-
lines.push(
|
|
430
|
+
lines.push(warn("Text appears to be a tool schema dump (not a tool call)"));
|
|
454
431
|
}
|
|
455
432
|
if (FINAL_ANSWER_RE.test(text)) {
|
|
456
433
|
const fa = FINAL_ANSWER_RE.exec(text)[1].trim();
|
|
457
|
-
lines.push(
|
|
434
|
+
lines.push(ok(`Final Answer: ${fa}`));
|
|
458
435
|
}
|
|
459
436
|
pi2.sendMessage({
|
|
460
437
|
customType: "react-parse-report",
|
|
@@ -472,3 +449,6 @@ ${argsJson}`
|
|
|
472
449
|
looksLikeSchemaDump
|
|
473
450
|
};
|
|
474
451
|
}
|
|
452
|
+
export {
|
|
453
|
+
react_fallback_temp_default as default
|
|
454
|
+
};
|