@mariozechner/pi-coding-agent 0.15.0 → 0.17.0
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/CHANGELOG.md +32 -0
- package/README.md +418 -1106
- package/dist/core/agent-session.d.ts +5 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +65 -18
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction.d.ts +30 -5
- package/dist/core/compaction.d.ts.map +1 -1
- package/dist/core/compaction.js +194 -61
- package/dist/core/compaction.js.map +1 -1
- package/dist/core/session-manager.d.ts +10 -3
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +78 -28
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/tools/truncate.d.ts +6 -2
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +11 -1
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/modes/index.d.ts +3 -1
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js +2 -2
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +17 -6
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +12 -7
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +18 -4
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +182 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +362 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +19 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-mode.js +205 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +255 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -0
- package/package.json +4 -4
- package/dist/modes/rpc-mode.d.ts +0 -21
- package/dist/modes/rpc-mode.d.ts.map +0 -1
- package/dist/modes/rpc-mode.js +0 -77
- package/dist/modes/rpc-mode.js.map +0 -1
package/dist/modes/rpc-mode.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RPC mode: Headless operation with JSON stdin/stdout protocol.
|
|
3
|
-
*
|
|
4
|
-
* Used for embedding the agent in other applications.
|
|
5
|
-
* Receives commands as JSON on stdin, outputs events as JSON on stdout.
|
|
6
|
-
*/
|
|
7
|
-
import * as readline from "readline";
|
|
8
|
-
/**
|
|
9
|
-
* Run in RPC mode.
|
|
10
|
-
* Listens for JSON commands on stdin, outputs events on stdout.
|
|
11
|
-
*
|
|
12
|
-
* Commands:
|
|
13
|
-
* - { type: "prompt", message: string, attachments?: Attachment[] }
|
|
14
|
-
* - { type: "abort" }
|
|
15
|
-
* - { type: "compact", customInstructions?: string }
|
|
16
|
-
* - { type: "bash", command: string }
|
|
17
|
-
*
|
|
18
|
-
* Events are output as JSON lines (same format as session manager).
|
|
19
|
-
*/
|
|
20
|
-
export async function runRpcMode(session) {
|
|
21
|
-
// Output all agent events as JSON
|
|
22
|
-
session.subscribe((event) => {
|
|
23
|
-
console.log(JSON.stringify(event));
|
|
24
|
-
});
|
|
25
|
-
// Listen for JSON input
|
|
26
|
-
const rl = readline.createInterface({
|
|
27
|
-
input: process.stdin,
|
|
28
|
-
output: process.stdout,
|
|
29
|
-
terminal: false,
|
|
30
|
-
});
|
|
31
|
-
rl.on("line", async (line) => {
|
|
32
|
-
try {
|
|
33
|
-
const input = JSON.parse(line);
|
|
34
|
-
switch (input.type) {
|
|
35
|
-
case "prompt":
|
|
36
|
-
if (input.message) {
|
|
37
|
-
await session.prompt(input.message, {
|
|
38
|
-
attachments: input.attachments,
|
|
39
|
-
expandSlashCommands: false, // RPC mode doesn't expand slash commands
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
break;
|
|
43
|
-
case "abort":
|
|
44
|
-
await session.abort();
|
|
45
|
-
break;
|
|
46
|
-
case "compact":
|
|
47
|
-
try {
|
|
48
|
-
const result = await session.compact(input.customInstructions);
|
|
49
|
-
console.log(JSON.stringify({ type: "compaction", ...result }));
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
console.log(JSON.stringify({ type: "error", error: `Compaction failed: ${error.message}` }));
|
|
53
|
-
}
|
|
54
|
-
break;
|
|
55
|
-
case "bash":
|
|
56
|
-
if (input.command) {
|
|
57
|
-
try {
|
|
58
|
-
const result = await session.executeBash(input.command);
|
|
59
|
-
console.log(JSON.stringify({ type: "bash_end", ...result }));
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
console.log(JSON.stringify({ type: "error", error: `Bash failed: ${error.message}` }));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
console.log(JSON.stringify({ type: "error", error: `Unknown command: ${input.type}` }));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
console.log(JSON.stringify({ type: "error", error: error.message }));
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
// Keep process alive forever
|
|
75
|
-
return new Promise(() => { });
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=rpc-mode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-mode.js","sourceRoot":"","sources":["../../src/modes/rpc-mode.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,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C,CAAC,CAAC;AAAA,CAC7B","sourcesContent":["/**\n * RPC mode: Headless operation with JSON stdin/stdout protocol.\n *\n * Used for embedding the agent in other applications.\n * Receives commands as JSON on stdin, outputs events as JSON on stdout.\n */\n\nimport * as readline from \"readline\";\nimport type { AgentSession } from \"../core/agent-session.js\";\n\n/**\n * Run in RPC mode.\n * Listens for JSON commands on stdin, outputs events on stdout.\n *\n * Commands:\n * - { type: \"prompt\", message: string, attachments?: Attachment[] }\n * - { type: \"abort\" }\n * - { type: \"compact\", customInstructions?: string }\n * - { type: \"bash\", command: string }\n *\n * Events are output as JSON lines (same format as session manager).\n */\nexport async function runRpcMode(session: AgentSession): Promise<never> {\n\t// Output all agent events as JSON\n\tsession.subscribe((event) => {\n\t\tconsole.log(JSON.stringify(event));\n\t});\n\n\t// Listen for JSON input\n\tconst rl = readline.createInterface({\n\t\tinput: process.stdin,\n\t\toutput: process.stdout,\n\t\tterminal: false,\n\t});\n\n\trl.on(\"line\", async (line: string) => {\n\t\ttry {\n\t\t\tconst input = JSON.parse(line);\n\n\t\t\tswitch (input.type) {\n\t\t\t\tcase \"prompt\":\n\t\t\t\t\tif (input.message) {\n\t\t\t\t\t\tawait session.prompt(input.message, {\n\t\t\t\t\t\t\tattachments: input.attachments,\n\t\t\t\t\t\t\texpandSlashCommands: false, // RPC mode doesn't expand slash commands\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"abort\":\n\t\t\t\t\tawait session.abort();\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"compact\":\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst result = await session.compact(input.customInstructions);\n\t\t\t\t\t\tconsole.log(JSON.stringify({ type: \"compaction\", ...result }));\n\t\t\t\t\t} catch (error: any) {\n\t\t\t\t\t\tconsole.log(JSON.stringify({ type: \"error\", error: `Compaction failed: ${error.message}` }));\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase \"bash\":\n\t\t\t\t\tif (input.command) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst result = await session.executeBash(input.command);\n\t\t\t\t\t\t\tconsole.log(JSON.stringify({ type: \"bash_end\", ...result }));\n\t\t\t\t\t\t} catch (error: any) {\n\t\t\t\t\t\t\tconsole.log(JSON.stringify({ type: \"error\", error: `Bash failed: ${error.message}` }));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tconsole.log(JSON.stringify({ type: \"error\", error: `Unknown command: ${input.type}` }));\n\t\t\t}\n\t\t} catch (error: any) {\n\t\t\tconsole.log(JSON.stringify({ type: \"error\", error: error.message }));\n\t\t}\n\t});\n\n\t// Keep process alive forever\n\treturn new Promise(() => {});\n}\n"]}
|