background-agents 0.1.1 → 0.1.2

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 (210) hide show
  1. package/README.md +173 -241
  2. package/dist/agents/claude/index.d.ts +11 -0
  3. package/dist/agents/claude/index.d.ts.map +1 -0
  4. package/dist/agents/claude/index.js +78 -0
  5. package/dist/agents/claude/index.js.map +1 -0
  6. package/dist/agents/claude/parser.d.ts +16 -0
  7. package/dist/agents/claude/parser.d.ts.map +1 -0
  8. package/dist/agents/claude/parser.js +87 -0
  9. package/dist/agents/claude/parser.js.map +1 -0
  10. package/dist/agents/claude/tools.d.ts +7 -0
  11. package/dist/agents/claude/tools.d.ts.map +1 -0
  12. package/dist/agents/claude/tools.js +15 -0
  13. package/dist/agents/claude/tools.js.map +1 -0
  14. package/dist/agents/codex/index.d.ts +11 -0
  15. package/dist/agents/codex/index.d.ts.map +1 -0
  16. package/dist/agents/codex/index.js +60 -0
  17. package/dist/agents/codex/index.js.map +1 -0
  18. package/dist/agents/codex/parser.d.ts +12 -0
  19. package/dist/agents/codex/parser.d.ts.map +1 -0
  20. package/dist/agents/codex/parser.js +108 -0
  21. package/dist/agents/codex/parser.js.map +1 -0
  22. package/dist/agents/codex/tools.d.ts +11 -0
  23. package/dist/agents/codex/tools.d.ts.map +1 -0
  24. package/dist/agents/codex/tools.js +40 -0
  25. package/dist/agents/codex/tools.js.map +1 -0
  26. package/dist/agents/eliza/bundle-content.d.ts +6 -0
  27. package/dist/agents/eliza/bundle-content.d.ts.map +1 -0
  28. package/dist/agents/eliza/bundle-content.js +7 -0
  29. package/dist/agents/eliza/bundle-content.js.map +1 -0
  30. package/dist/agents/eliza/cli.bundle.js +579 -0
  31. package/dist/agents/eliza/cli.d.ts +10 -0
  32. package/dist/agents/eliza/cli.d.ts.map +1 -0
  33. package/dist/agents/eliza/cli.js +342 -0
  34. package/dist/agents/eliza/cli.js.map +1 -0
  35. package/dist/agents/eliza/index.d.ts +22 -0
  36. package/dist/agents/eliza/index.d.ts.map +1 -0
  37. package/dist/agents/eliza/index.js +54 -0
  38. package/dist/agents/eliza/index.js.map +1 -0
  39. package/dist/agents/eliza/parser.d.ts +16 -0
  40. package/dist/agents/eliza/parser.d.ts.map +1 -0
  41. package/dist/agents/eliza/parser.js +67 -0
  42. package/dist/agents/eliza/parser.js.map +1 -0
  43. package/dist/agents/eliza/patterns.d.ts +41 -0
  44. package/dist/agents/eliza/patterns.d.ts.map +1 -0
  45. package/dist/agents/eliza/patterns.js +259 -0
  46. package/dist/agents/eliza/patterns.js.map +1 -0
  47. package/dist/agents/eliza/tools.d.ts +7 -0
  48. package/dist/agents/eliza/tools.d.ts.map +1 -0
  49. package/dist/agents/eliza/tools.js +14 -0
  50. package/dist/agents/eliza/tools.js.map +1 -0
  51. package/dist/agents/gemini/index.d.ts +11 -0
  52. package/dist/agents/gemini/index.d.ts.map +1 -0
  53. package/dist/agents/gemini/index.js +46 -0
  54. package/dist/agents/gemini/index.js.map +1 -0
  55. package/dist/agents/gemini/parser.d.ts +31 -0
  56. package/dist/agents/gemini/parser.d.ts.map +1 -0
  57. package/dist/agents/gemini/parser.js +106 -0
  58. package/dist/agents/gemini/parser.js.map +1 -0
  59. package/dist/agents/gemini/tools.d.ts +7 -0
  60. package/dist/agents/gemini/tools.d.ts.map +1 -0
  61. package/dist/agents/gemini/tools.js +23 -0
  62. package/dist/agents/gemini/tools.js.map +1 -0
  63. package/dist/agents/goose/index.d.ts +11 -0
  64. package/dist/agents/goose/index.d.ts.map +1 -0
  65. package/dist/agents/goose/index.js +73 -0
  66. package/dist/agents/goose/index.js.map +1 -0
  67. package/dist/agents/goose/parser.d.ts +24 -0
  68. package/dist/agents/goose/parser.d.ts.map +1 -0
  69. package/dist/agents/goose/parser.js +86 -0
  70. package/dist/agents/goose/parser.js.map +1 -0
  71. package/dist/agents/goose/tools.d.ts +10 -0
  72. package/dist/agents/goose/tools.d.ts.map +1 -0
  73. package/dist/agents/goose/tools.js +30 -0
  74. package/dist/agents/goose/tools.js.map +1 -0
  75. package/dist/agents/index.d.ts +27 -0
  76. package/dist/agents/index.d.ts.map +1 -0
  77. package/dist/agents/index.js +46 -0
  78. package/dist/agents/index.js.map +1 -0
  79. package/dist/agents/opencode/index.d.ts +12 -0
  80. package/dist/agents/opencode/index.d.ts.map +1 -0
  81. package/dist/agents/opencode/index.js +53 -0
  82. package/dist/agents/opencode/index.js.map +1 -0
  83. package/dist/agents/opencode/parser.d.ts +15 -0
  84. package/dist/agents/opencode/parser.d.ts.map +1 -0
  85. package/dist/agents/opencode/parser.js +71 -0
  86. package/dist/agents/opencode/parser.js.map +1 -0
  87. package/dist/agents/opencode/tools.d.ts +7 -0
  88. package/dist/agents/opencode/tools.d.ts.map +1 -0
  89. package/dist/agents/opencode/tools.js +10 -0
  90. package/dist/agents/opencode/tools.js.map +1 -0
  91. package/dist/agents/openhands/index.d.ts +17 -0
  92. package/dist/agents/openhands/index.d.ts.map +1 -0
  93. package/dist/agents/openhands/index.js +67 -0
  94. package/dist/agents/openhands/index.js.map +1 -0
  95. package/dist/agents/openhands/parser.d.ts +16 -0
  96. package/dist/agents/openhands/parser.d.ts.map +1 -0
  97. package/dist/agents/openhands/parser.js +93 -0
  98. package/dist/agents/openhands/parser.js.map +1 -0
  99. package/dist/agents/openhands/tools.d.ts +7 -0
  100. package/dist/agents/openhands/tools.d.ts.map +1 -0
  101. package/dist/agents/openhands/tools.js +24 -0
  102. package/dist/agents/openhands/tools.js.map +1 -0
  103. package/dist/agents/pi/index.d.ts +14 -0
  104. package/dist/agents/pi/index.d.ts.map +1 -0
  105. package/dist/agents/pi/index.js +54 -0
  106. package/dist/agents/pi/index.js.map +1 -0
  107. package/dist/agents/pi/parser.d.ts +21 -0
  108. package/dist/agents/pi/parser.d.ts.map +1 -0
  109. package/dist/agents/pi/parser.js +91 -0
  110. package/dist/agents/pi/parser.js.map +1 -0
  111. package/dist/agents/pi/tools.d.ts +8 -0
  112. package/dist/agents/pi/tools.d.ts.map +1 -0
  113. package/dist/agents/pi/tools.js +16 -0
  114. package/dist/agents/pi/tools.js.map +1 -0
  115. package/dist/agents/picocode/index.d.ts +18 -0
  116. package/dist/agents/picocode/index.d.ts.map +1 -0
  117. package/dist/agents/picocode/index.js +68 -0
  118. package/dist/agents/picocode/index.js.map +1 -0
  119. package/dist/agents/picocode/parser.d.ts +19 -0
  120. package/dist/agents/picocode/parser.d.ts.map +1 -0
  121. package/dist/agents/picocode/parser.js +104 -0
  122. package/dist/agents/picocode/parser.js.map +1 -0
  123. package/dist/agents/picocode/tools.d.ts +9 -0
  124. package/dist/agents/picocode/tools.d.ts.map +1 -0
  125. package/dist/agents/picocode/tools.js +27 -0
  126. package/dist/agents/picocode/tools.js.map +1 -0
  127. package/dist/background/index.d.ts +6 -0
  128. package/dist/background/index.d.ts.map +1 -0
  129. package/dist/background/index.js +5 -0
  130. package/dist/background/index.js.map +1 -0
  131. package/dist/background/session.d.ts +47 -0
  132. package/dist/background/session.d.ts.map +1 -0
  133. package/dist/background/session.js +481 -0
  134. package/dist/background/session.js.map +1 -0
  135. package/dist/background/types.d.ts +55 -0
  136. package/dist/background/types.d.ts.map +1 -0
  137. package/dist/background/types.js +5 -0
  138. package/dist/background/types.js.map +1 -0
  139. package/dist/core/agent.d.ts +95 -0
  140. package/dist/core/agent.d.ts.map +1 -0
  141. package/dist/core/agent.js +8 -0
  142. package/dist/core/agent.js.map +1 -0
  143. package/dist/core/index.d.ts +7 -0
  144. package/dist/core/index.d.ts.map +1 -0
  145. package/dist/core/index.js +6 -0
  146. package/dist/core/index.js.map +1 -0
  147. package/dist/core/registry.d.ts +48 -0
  148. package/dist/core/registry.d.ts.map +1 -0
  149. package/dist/core/registry.js +68 -0
  150. package/dist/core/registry.js.map +1 -0
  151. package/dist/core/tools.d.ts +31 -0
  152. package/dist/core/tools.d.ts.map +1 -0
  153. package/dist/core/tools.js +82 -0
  154. package/dist/core/tools.js.map +1 -0
  155. package/dist/debug.js +1 -1
  156. package/dist/debug.js.map +1 -1
  157. package/dist/factory.d.ts +1 -4
  158. package/dist/factory.d.ts.map +1 -1
  159. package/dist/factory.js +1 -4
  160. package/dist/factory.js.map +1 -1
  161. package/dist/index.d.ts +29 -11
  162. package/dist/index.d.ts.map +1 -1
  163. package/dist/index.js +41 -14
  164. package/dist/index.js.map +1 -1
  165. package/dist/providers/base.d.ts +45 -18
  166. package/dist/providers/base.d.ts.map +1 -1
  167. package/dist/providers/base.js +228 -265
  168. package/dist/providers/base.js.map +1 -1
  169. package/dist/providers/gemini.d.ts.map +1 -1
  170. package/dist/providers/gemini.js +18 -8
  171. package/dist/providers/gemini.js.map +1 -1
  172. package/dist/sandbox/daytona.d.ts +5 -1
  173. package/dist/sandbox/daytona.d.ts.map +1 -1
  174. package/dist/sandbox/daytona.js +157 -214
  175. package/dist/sandbox/daytona.js.map +1 -1
  176. package/dist/sandbox/index.d.ts +3 -3
  177. package/dist/sandbox/index.d.ts.map +1 -1
  178. package/dist/sandbox/index.js +2 -2
  179. package/dist/sandbox/index.js.map +1 -1
  180. package/dist/session.d.ts +62 -51
  181. package/dist/session.d.ts.map +1 -1
  182. package/dist/session.js +94 -90
  183. package/dist/session.js.map +1 -1
  184. package/dist/types/index.d.ts +2 -2
  185. package/dist/types/index.d.ts.map +1 -1
  186. package/dist/types/index.js +2 -2
  187. package/dist/types/index.js.map +1 -1
  188. package/dist/types/provider.d.ts +37 -94
  189. package/dist/types/provider.d.ts.map +1 -1
  190. package/dist/types/provider.js +3 -0
  191. package/dist/types/provider.js.map +1 -1
  192. package/dist/utils/index.d.ts +2 -3
  193. package/dist/utils/index.d.ts.map +1 -1
  194. package/dist/utils/index.js +2 -3
  195. package/dist/utils/index.js.map +1 -1
  196. package/dist/utils/install.d.ts +12 -2
  197. package/dist/utils/install.d.ts.map +1 -1
  198. package/dist/utils/install.js +40 -4
  199. package/dist/utils/install.js.map +1 -1
  200. package/package.json +24 -13
  201. package/src/index.ts +156 -0
  202. package/dist/sandbox/daytona-ssh.d.ts +0 -9
  203. package/dist/sandbox/daytona-ssh.d.ts.map +0 -1
  204. package/dist/sandbox/daytona-ssh.js +0 -113
  205. package/dist/sandbox/daytona-ssh.js.map +0 -1
  206. package/dist/utils/session.d.ts +0 -17
  207. package/dist/utils/session.d.ts.map +0 -1
  208. package/dist/utils/session.js +0 -59
  209. package/dist/utils/session.js.map +0 -1
  210. package/next.config.codeagentsdk.cjs +0 -22
@@ -0,0 +1,93 @@
1
+ /**
2
+ * OpenHands CLI output parser
3
+ *
4
+ * Pure function for parsing OpenHands CLI JSON output.
5
+ * The OpenHands CLI with --json flag outputs JSONL events with
6
+ * "type": "action" or "type": "observation" fields.
7
+ */
8
+ import { createToolStartEvent, normalizeToolName } from "../../core/tools.js";
9
+ import { safeJsonParse } from "../../utils/json.js";
10
+ /**
11
+ * Parse a line of OpenHands CLI output into event(s).
12
+ *
13
+ * Uses context.sessionId to track if session event was already emitted.
14
+ */
15
+ export function parseOpenhandsLine(line, toolMappings, context) {
16
+ const json = safeJsonParse(line);
17
+ if (!json) {
18
+ return null;
19
+ }
20
+ // Status event - may contain session/conversation ID
21
+ if (json.type === "status") {
22
+ const statusEvent = json;
23
+ const sessionId = statusEvent.session_id || statusEvent.conversation_id;
24
+ if (sessionId && context.sessionId !== sessionId) {
25
+ context.sessionId = sessionId;
26
+ return { type: "session", id: sessionId };
27
+ }
28
+ return null;
29
+ }
30
+ // Message event - assistant text output
31
+ if (json.type === "message") {
32
+ const messageEvent = json;
33
+ if (messageEvent.role === "assistant" && (messageEvent.content || messageEvent.message)) {
34
+ return { type: "token", text: messageEvent.content || messageEvent.message || "" };
35
+ }
36
+ return null;
37
+ }
38
+ // Action event - tool invocation
39
+ if (json.type === "action") {
40
+ const actionEvent = json;
41
+ const actionName = actionEvent.action?.toLowerCase() || "unknown";
42
+ // Skip "think" or "message" actions - they're just thoughts/messages
43
+ if (actionName === "think" || actionName === "message") {
44
+ const thought = actionEvent.args?.thought || actionEvent.message;
45
+ if (thought) {
46
+ return { type: "token", text: thought };
47
+ }
48
+ return null;
49
+ }
50
+ // Skip "finish" action - it's handled by finish event type
51
+ if (actionName === "finish") {
52
+ return null;
53
+ }
54
+ const normalized = normalizeToolName(actionName, toolMappings);
55
+ // Build input from args
56
+ const input = {};
57
+ if (actionEvent.args) {
58
+ if (actionEvent.args.command) {
59
+ input.command = actionEvent.args.command;
60
+ }
61
+ if (actionEvent.args.path || actionEvent.args.file_path) {
62
+ input.file_path = actionEvent.args.path || actionEvent.args.file_path;
63
+ }
64
+ if (actionEvent.args.content) {
65
+ input.content = actionEvent.args.content;
66
+ }
67
+ }
68
+ return createToolStartEvent(normalized, Object.keys(input).length > 0 ? input : undefined, toolMappings);
69
+ }
70
+ // Observation event - tool result
71
+ if (json.type === "observation") {
72
+ const obsEvent = json;
73
+ const output = obsEvent.content || undefined;
74
+ return { type: "tool_end", output };
75
+ }
76
+ // Error event - emit as end with error
77
+ if (json.type === "error") {
78
+ const errorEvent = json;
79
+ const errorMsg = errorEvent.message || errorEvent.error || "Unknown error";
80
+ return { type: "end", error: errorMsg };
81
+ }
82
+ // Finish event - marks end of interaction
83
+ if (json.type === "finish") {
84
+ const finishEvent = json;
85
+ // Check if it's a failure state
86
+ if (finishEvent.state === "error" || finishEvent.state === "failed") {
87
+ return { type: "end", error: finishEvent.message || "Task failed" };
88
+ }
89
+ return { type: "end" };
90
+ }
91
+ return null;
92
+ }
93
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/agents/openhands/parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAqEnD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAY,EACZ,YAAoC,EACpC,OAAqB;IAErB,MAAM,IAA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,CAAC,OAAO,IAAI,SAAS,CAAA;QAC5C,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;IACrC,CAAC;IAED,uCAAuC;IACvC,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC1B,MAAM,UAAU,GAAG,IAA2B,CAAA;QAC9C,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,IAAI,UAAU,CAAC,KAAK,IAAI,eAAe,CAAA;QAC1E,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;IACzC,CAAC;IAED,0CAA0C;IAC1C,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC3B,MAAM,WAAW,GAAG,IAA4B,CAAA;QAChD,gCAAgC;QAChC,IAAI,WAAW,CAAC,KAAK,KAAK,OAAO,IAAI,WAAW,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACpE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,CAAC,OAAO,IAAI,aAAa,EAAE,CAAA;QACrE,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;IACxB,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * OpenHands tool name mappings
3
+ *
4
+ * Maps OpenHands CLI tool names to canonical tool names.
5
+ */
6
+ export declare const OPENHANDS_TOOL_MAPPINGS: Record<string, string>;
7
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/agents/openhands/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAiB1D,CAAA"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * OpenHands tool name mappings
3
+ *
4
+ * Maps OpenHands CLI tool names to canonical tool names.
5
+ */
6
+ export const OPENHANDS_TOOL_MAPPINGS = {
7
+ // File operations
8
+ write: "write",
9
+ read: "read",
10
+ edit: "edit",
11
+ str_replace_editor: "edit",
12
+ // Shell/command execution
13
+ run: "shell",
14
+ bash: "shell",
15
+ execute_bash: "shell",
16
+ // Search operations
17
+ find_file: "glob",
18
+ search_dir: "grep",
19
+ search_file: "grep",
20
+ // Web operations
21
+ browse: "web_search",
22
+ web_browse: "web_search",
23
+ };
24
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/agents/openhands/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAA2B;IAC7D,kBAAkB;IAClB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,kBAAkB,EAAE,MAAM;IAC1B,0BAA0B;IAC1B,GAAG,EAAE,OAAO;IACZ,IAAI,EAAE,OAAO;IACb,YAAY,EAAE,OAAO;IACrB,oBAAoB;IACpB,SAAS,EAAE,MAAM;IACjB,UAAU,EAAE,MAAM;IAClB,WAAW,EAAE,MAAM;IACnB,iBAAiB;IACjB,MAAM,EAAE,YAAY;IACpB,UAAU,EAAE,YAAY;CACzB,CAAA"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Pi Coding Agent CLI Agent Definition
3
+ *
4
+ * Pi is a minimal terminal coding harness from @mariozechner/pi-coding-agent.
5
+ * https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent
6
+ */
7
+ import type { AgentDefinition } from "../../core/agent";
8
+ /**
9
+ * Pi Coding Agent CLI agent definition.
10
+ *
11
+ * Interacts with the Pi CLI tool which outputs JSON lines in --mode json format.
12
+ */
13
+ export declare const piAgent: AgentDefinition;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/pi/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,kBAAkB,CAAA;AAKzB;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,eAiDrB,CAAA"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Pi Coding Agent CLI Agent Definition
3
+ *
4
+ * Pi is a minimal terminal coding harness from @mariozechner/pi-coding-agent.
5
+ * https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent
6
+ */
7
+ import { parsePiLine } from "./parser";
8
+ import { PI_TOOL_MAPPINGS } from "./tools";
9
+ /**
10
+ * Pi Coding Agent CLI agent definition.
11
+ *
12
+ * Interacts with the Pi CLI tool which outputs JSON lines in --mode json format.
13
+ */
14
+ export const piAgent = {
15
+ name: "pi",
16
+ toolMappings: PI_TOOL_MAPPINGS,
17
+ capabilities: {
18
+ supportsSystemPrompt: true,
19
+ supportsResume: true,
20
+ },
21
+ buildCommand(options) {
22
+ const args = [];
23
+ // Use JSON mode for structured output
24
+ args.push("--mode", "json");
25
+ // Apply system prompt via native CLI flag when provided
26
+ if (options.systemPrompt) {
27
+ args.push("--system-prompt", options.systemPrompt);
28
+ }
29
+ // Add model if specified (e.g., "sonnet", "gpt-4o", "claude-sonnet-4-5-20250929")
30
+ // Pi supports provider/model format like "openai/gpt-4o" or model patterns
31
+ if (options.model) {
32
+ args.push("--model", options.model);
33
+ }
34
+ // Continue the most recent session in the current directory
35
+ // Pi's --continue flag resumes the last session in cwd
36
+ if (options.sessionId) {
37
+ args.push("--continue");
38
+ }
39
+ // Add the prompt if provided
40
+ if (options.prompt) {
41
+ args.push("-p");
42
+ args.push(options.prompt);
43
+ }
44
+ return {
45
+ cmd: "pi",
46
+ args,
47
+ env: options.env,
48
+ };
49
+ },
50
+ parse(line, context) {
51
+ return parsePiLine(line, this.toolMappings, context);
52
+ },
53
+ };
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 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AC,IAAY,EAAE,OAAqB;QACvC,OAAO,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IACtD,CAAC;CACF,CAAA"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Pi Coding Agent CLI output parser
3
+ *
4
+ * Pure function for parsing Pi CLI JSON output (--mode json).
5
+ * No state, no side effects - easily testable.
6
+ *
7
+ * Pi JSON output events are documented at:
8
+ * https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent#cli-reference
9
+ */
10
+ import type { Event } from "../../types/events";
11
+ import type { ParseContext } from "../../core/agent";
12
+ /**
13
+ * Parse a line of Pi CLI output into event(s).
14
+ *
15
+ * @param line - Raw line from CLI output
16
+ * @param toolMappings - Tool name mappings for this agent
17
+ * @param context - Parse context for stateful parsing
18
+ * @returns Event, array of events, or null if line should be ignored
19
+ */
20
+ export declare function parsePiLine(line: string, toolMappings: Record<string, string>, _context: ParseContext): Event | Event[] | null;
21
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/agents/pi/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAsJpD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,QAAQ,EAAE,YAAY,GACrB,KAAK,GAAG,KAAK,EAAE,GAAG,IAAI,CAkFxB"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Pi Coding Agent CLI output parser
3
+ *
4
+ * Pure function for parsing Pi CLI JSON output (--mode json).
5
+ * No state, no side effects - easily testable.
6
+ *
7
+ * Pi JSON output events are documented at:
8
+ * https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent#cli-reference
9
+ */
10
+ import { createToolStartEvent } from "../../core/tools";
11
+ import { safeJsonParse } from "../../utils/json";
12
+ /**
13
+ * Parse a line of Pi CLI output into event(s).
14
+ *
15
+ * @param line - Raw line from CLI output
16
+ * @param toolMappings - Tool name mappings for this agent
17
+ * @param context - Parse context for stateful parsing
18
+ * @returns Event, array of events, or null if line should be ignored
19
+ */
20
+ export function parsePiLine(line, toolMappings, _context) {
21
+ const json = safeJsonParse(line);
22
+ if (!json) {
23
+ return null;
24
+ }
25
+ // Session header - first line contains session info
26
+ if (json.type === "session" && "id" in json) {
27
+ return { type: "session", id: json.id };
28
+ }
29
+ // Message update with text delta - this is the main token stream
30
+ if (json.type === "message_update" && "assistantMessageEvent" in json) {
31
+ const event = json.assistantMessageEvent;
32
+ if (event) {
33
+ // text_delta events contain the actual response text
34
+ if (event.type === "text_delta" && event.delta) {
35
+ return { type: "token", text: event.delta };
36
+ }
37
+ // Some versions may use 'text' instead of 'delta'
38
+ if (event.type === "text_delta" && event.text) {
39
+ return { type: "token", text: event.text };
40
+ }
41
+ }
42
+ return null;
43
+ }
44
+ // Tool execution start
45
+ if (json.type === "tool_execution_start") {
46
+ const toolName = json.toolName ?? "unknown";
47
+ return createToolStartEvent(toolName, json.args, toolMappings);
48
+ }
49
+ // Tool execution update - partial results (emit as tool_delta)
50
+ if (json.type === "tool_execution_update") {
51
+ const partialResult = json.partialResult;
52
+ if (partialResult !== undefined && partialResult !== null) {
53
+ const text = typeof partialResult === "string"
54
+ ? partialResult
55
+ : JSON.stringify(partialResult);
56
+ return { type: "tool_delta", text };
57
+ }
58
+ return null;
59
+ }
60
+ // Tool execution end
61
+ if (json.type === "tool_execution_end") {
62
+ const result = json.result;
63
+ const output = result !== undefined && result !== null
64
+ ? typeof result === "string"
65
+ ? result
66
+ : JSON.stringify(result)
67
+ : undefined;
68
+ return { type: "tool_end", output };
69
+ }
70
+ // Agent end - signals completion
71
+ if (json.type === "agent_end") {
72
+ return { type: "end" };
73
+ }
74
+ // Error events
75
+ if (json.type === "error") {
76
+ const errorMsg = json.error ?? json.message ?? "Unknown error";
77
+ return { type: "end", error: errorMsg };
78
+ }
79
+ // Auto retry end with failure
80
+ if (json.type === "auto_retry_end" && !json.success) {
81
+ return { type: "end", error: json.finalError ?? "Auto retry failed" };
82
+ }
83
+ // These events are informational, we can ignore them:
84
+ // - agent_start, turn_start, turn_end
85
+ // - message_start, message_end
86
+ // - compaction_start, compaction_end
87
+ // - auto_retry_start
88
+ // - queue_update
89
+ return null;
90
+ }
91
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/agents/pi/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAoJhD;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CACzB,IAAY,EACZ,YAAoC,EACpC,QAAsB;IAEtB,MAAM,IAAI,GAAG,aAAa,CAAU,IAAI,CAAC,CAAA;IACzC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAA;IACb,CAAC;IAED,oDAAoD;IACpD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QAC5C,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAA;IACzC,CAAC;IAED,iEAAiE;IACjE,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,IAAI,uBAAuB,IAAI,IAAI,EAAE,CAAC;QACtE,MAAM,KAAK,GAAG,IAAI,CAAC,qBAAqB,CAAA;QACxC,IAAI,KAAK,EAAE,CAAC;YACV,qDAAqD;YACrD,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,IAAI,KAAK,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AK,QAAQ;gBAC1B,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;YAC1B,CAAC,CAAC,SAAS,CAAA;QACf,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;IACrC,CAAC;IAED,iCAAiC;IACjC,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAC9B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;IACxB,CAAC;IAED,eAAe;IACf,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,IAAI,eAAe,CAAA;QAC9D,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;IACzC,CAAC;IAED,8BAA8B;IAC9B,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACpD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,IAAI,mBAAmB,EAAE,CAAA;IACvE,CAAC;IAED,sDAAsD;IACtD,sCAAsC;IACtC,+BAA+B;IAC/B,qCAAqC;IACrC,qBAAqB;IACrB,iBAAiB;IAEjB,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Pi Coding Agent tool name mappings
3
+ *
4
+ * Maps Pi CLI tool names to canonical tool names.
5
+ * Pi uses: read, bash, edit, write, grep, find, ls by default.
6
+ */
7
+ export declare const PI_TOOL_MAPPINGS: Record<string, string>;
8
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/agents/pi/tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAQnD,CAAA"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Pi Coding Agent tool name mappings
3
+ *
4
+ * Maps Pi CLI tool names to canonical tool names.
5
+ * Pi uses: read, bash, edit, write, grep, find, ls by default.
6
+ */
7
+ export const PI_TOOL_MAPPINGS = {
8
+ read: "read",
9
+ write: "write",
10
+ edit: "edit",
11
+ bash: "shell",
12
+ grep: "grep",
13
+ find: "glob",
14
+ ls: "glob",
15
+ };
16
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/agents/pi/tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAA2B;IACtD,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,EAAE,EAAE,MAAM;CACX,CAAA"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Picocode CLI Agent Definition
3
+ *
4
+ * Picocode is a minimal, high-performance Rust-based coding agent.
5
+ * https://github.com/jondot/picocode
6
+ *
7
+ * Since Picocode doesn't have native JSON streaming output, this agent
8
+ * captures its console output and parses it to extract events.
9
+ */
10
+ import type { AgentDefinition } from "../../core/agent.js";
11
+ /**
12
+ * Picocode CLI agent definition.
13
+ *
14
+ * Interacts with the Picocode CLI tool.
15
+ * Runs with --yolo flag to skip confirmation prompts in sandbox.
16
+ */
17
+ export declare const picocodeAgent: AgentDefinition;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/picocode/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,qBAAqB,CAAA;AAK5B;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,eAwD3B,CAAA"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Picocode CLI Agent Definition
3
+ *
4
+ * Picocode is a minimal, high-performance Rust-based coding agent.
5
+ * https://github.com/jondot/picocode
6
+ *
7
+ * Since Picocode doesn't have native JSON streaming output, this agent
8
+ * captures its console output and parses it to extract events.
9
+ */
10
+ import { parsePicocodeLine } from "./parser.js";
11
+ import { PICOCODE_TOOL_MAPPINGS } from "./tools.js";
12
+ /**
13
+ * Picocode CLI agent definition.
14
+ *
15
+ * Interacts with the Picocode CLI tool.
16
+ * Runs with --yolo flag to skip confirmation prompts in sandbox.
17
+ */
18
+ export const picocodeAgent = {
19
+ name: "picocode",
20
+ toolMappings: PICOCODE_TOOL_MAPPINGS,
21
+ capabilities: {
22
+ supportsSystemPrompt: false, // Picocode uses persona system, not direct system prompts
23
+ supportsResume: false, // No session resumption support
24
+ plainTextOutput: true, // Picocode outputs plain text, not JSON lines
25
+ },
26
+ buildCommand(options) {
27
+ // Build the picocode command arguments
28
+ // Using 'input' subcommand for single prompt execution
29
+ const args = [];
30
+ // Model selection via provider
31
+ // Picocode supports: anthropic, openai, azure, cohere, deepseek, galadriel,
32
+ // gemini, groq, huggingface, hyperbolic, mira, mistral, moonshot, ollama,
33
+ // openrouter, perplexity, together, xai
34
+ if (options.model) {
35
+ // If model contains a provider prefix (e.g., "anthropic/claude-3-opus"),
36
+ // extract and use it
37
+ const modelParts = options.model.split("/");
38
+ if (modelParts.length > 1) {
39
+ args.push("-p", modelParts[0]);
40
+ args.push("-m", modelParts.slice(1).join("/"));
41
+ }
42
+ else {
43
+ // Assume it's just a model name for the default provider (anthropic)
44
+ args.push("-m", options.model);
45
+ }
46
+ }
47
+ // Enable yolo mode to skip confirmation prompts (safe in sandbox)
48
+ args.push("--yolo", "true");
49
+ // Add the prompt using the 'input' subcommand
50
+ if (options.prompt) {
51
+ args.push("input", options.prompt);
52
+ }
53
+ return {
54
+ cmd: "picocode",
55
+ args,
56
+ env: {
57
+ // Set provider API keys from environment
58
+ // Picocode will use the appropriate one based on --provider flag
59
+ ...options.env,
60
+ },
61
+ wrapInBash: true, // Wrap in bash to handle stderr
62
+ };
63
+ },
64
+ parse(line, context) {
65
+ return parsePicocodeLine(line, this.toolMappings, context);
66
+ },
67
+ };
68
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agents/picocode/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAEnD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAoB;IAC5C,IAAI,EAAE,UAAU;IAEhB,YAAY,EAAE,sBAAsB;IAEpC,YAAY,EAAE;QACZ,oBAAoB,EAAE,KAAK,EAAE,0DAA0D;QACvF,cAAc,EAAE,KAAK,EAAE,gCAAgC;QACvD,eAAe,EAAE,IAAI,EAAE,8CAA8C;KACtE;IAED,YAAY,CAAC,OAAmB;QAC9B,uCAAuC;QACvC,uDAAuD;QACvD,MAAM,IAAI,GAAa,EAAE,CAAA;QAEzB,+BAA+B;QAC/B,4EAA4E;QAC5E,0EAA0E;QAC1E,wCAAwC;QACxC,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,yEAAyE;YACzE,qBAAqB;YACrB,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAC3C,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC1B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;gBAC9B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;YAChD,CAAC;iBAAM,CAAC;gBACN,qEAAqE;gBACrE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;YAChC,CAAC;QACH,CAAC;QAED,kEAAkE;QAClE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAE3B,8CAA8C;QAC9C,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;QACpC,CAAC;QAED,OAAO;YACL,GAAG,EAAE,UAAU;YACf,IAAI;YACJ,GAAG,EAAE;gBACH,yCAAyC;gBACzC,iEAAiE;gBACjE,GAAG,OAAO,CAAC,GAAG;aACf;YACD,UAAU,EAAE,IAAI,EAAE,gCAAgC;SACnD,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAY,EAAE,OAAqB;QACvC,OAAO,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IAC5D,CAAC;CACF,CAAA"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Picocode CLI output parser
3
+ *
4
+ * Parses Picocode CLI plain text output. Picocode outputs:
5
+ * 1. ASCII art banner with version/model info
6
+ * 2. A separator line
7
+ * 3. The response text
8
+ * 4. Then exits (no explicit end marker)
9
+ *
10
+ * Since picocode doesn't emit an "end" event, the SDK will detect completion
11
+ * via the process exiting. We need to emit session and token events.
12
+ */
13
+ import type { Event } from "../../types/events.js";
14
+ import type { ParseContext } from "../../core/agent.js";
15
+ /**
16
+ * Parse a line of Picocode CLI output into event(s).
17
+ */
18
+ export declare function parsePicocodeLine(line: string, toolMappings: Record<string, string>, context: ParseContext): Event | Event[] | null;
19
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/agents/picocode/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AA2BvD;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,OAAO,EAAE,YAAY,GACpB,KAAK,GAAG,KAAK,EAAE,GAAG,IAAI,CAiFxB"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Picocode CLI output parser
3
+ *
4
+ * Parses Picocode CLI plain text output. Picocode outputs:
5
+ * 1. ASCII art banner with version/model info
6
+ * 2. A separator line
7
+ * 3. The response text
8
+ * 4. Then exits (no explicit end marker)
9
+ *
10
+ * Since picocode doesn't emit an "end" event, the SDK will detect completion
11
+ * via the process exiting. We need to emit session and token events.
12
+ */
13
+ import { createToolStartEvent, normalizeToolName } from "../../core/tools.js";
14
+ // Pattern for tool invocation header (e.g., "── read_file ──────────────────────")
15
+ const TOOL_HEADER_REGEX = /^──\s+(\w+)\s+─+$/;
16
+ // Pattern for the picocode banner line (contains "picocode |")
17
+ const BANNER_REGEX = /picocode\s*\|/;
18
+ // Pattern for error messages (picocode outputs "Error: ..." for errors)
19
+ const ERROR_REGEX = /^Error:\s*(.+)$/i;
20
+ // Pattern for API/HTTP errors (often multiline, check for key phrases)
21
+ const API_ERROR_PATTERNS = [
22
+ /invalid.*api.*key/i,
23
+ /unauthorized/i,
24
+ /authentication.*error/i,
25
+ /credit.*balance/i,
26
+ /rate.*limit/i,
27
+ ];
28
+ // Pattern for separator lines (used after banner and between sections)
29
+ const SEPARATOR_REGEX = /^[─═]{10,}$/;
30
+ // Pattern for the ASCII art (contains box-drawing characters in specific pattern)
31
+ const ASCII_ART_REGEX = /^[\s▄█░▀│┌┐└┘├┤┬┴┼]+$/;
32
+ /**
33
+ * Parse a line of Picocode CLI output into event(s).
34
+ */
35
+ export function parsePicocodeLine(line, toolMappings, context) {
36
+ const trimmedLine = line.trim();
37
+ if (!trimmedLine)
38
+ return null;
39
+ // Initialize state
40
+ if (!context.state.initialized) {
41
+ context.state.initialized = true;
42
+ context.state.seenBanner = false;
43
+ context.state.seenSeparator = false;
44
+ context.state.inResponse = false;
45
+ }
46
+ // Check for error first (highest priority)
47
+ const errorMatch = ERROR_REGEX.exec(trimmedLine);
48
+ if (errorMatch) {
49
+ return { type: "end", error: errorMatch[1] };
50
+ }
51
+ // Check for API error patterns in any line
52
+ for (const pattern of API_ERROR_PATTERNS) {
53
+ if (pattern.test(trimmedLine)) {
54
+ return { type: "end", error: trimmedLine };
55
+ }
56
+ }
57
+ // Skip ASCII art lines
58
+ if (ASCII_ART_REGEX.test(trimmedLine)) {
59
+ return null;
60
+ }
61
+ // Check for the banner line (contains "picocode |")
62
+ if (BANNER_REGEX.test(trimmedLine)) {
63
+ context.state.seenBanner = true;
64
+ // Emit session event when we see the banner
65
+ if (!context.sessionId) {
66
+ const sessionId = `picocode-${Date.now()}`;
67
+ context.sessionId = sessionId;
68
+ return { type: "session", id: sessionId };
69
+ }
70
+ return null;
71
+ }
72
+ // Check for separator line
73
+ if (SEPARATOR_REGEX.test(trimmedLine)) {
74
+ if (context.state.seenBanner && !context.state.seenSeparator) {
75
+ context.state.seenSeparator = true;
76
+ context.state.inResponse = true;
77
+ }
78
+ return null;
79
+ }
80
+ // Check for tool header (e.g., "── read_file ──────────────────────")
81
+ const toolMatch = TOOL_HEADER_REGEX.exec(trimmedLine);
82
+ if (toolMatch) {
83
+ const toolName = toolMatch[1];
84
+ context.state.lastToolStarted = true;
85
+ return createToolStartEvent(normalizeToolName(toolName, toolMappings), undefined, toolMappings);
86
+ }
87
+ // If we're in the response section, emit tokens
88
+ if (context.state.inResponse) {
89
+ // Skip lines that look like UI elements
90
+ if (trimmedLine.startsWith(">") || trimmedLine.startsWith("─")) {
91
+ return null;
92
+ }
93
+ context.state.hasOutput = true;
94
+ return { type: "token", text: trimmedLine + "\n" };
95
+ }
96
+ // Before the separator, check if this might be an early response
97
+ // (some simple prompts might not have much header)
98
+ if (context.state.seenBanner && !context.state.seenSeparator) {
99
+ // This could be part of the banner info, skip it
100
+ return null;
101
+ }
102
+ return null;
103
+ }
104
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/agents/picocode/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE7E,mFAAmF;AACnF,MAAM,iBAAiB,GAAG,mBAAmB,CAAA;AAE7C,+DAA+D;AAC/D,MAAM,YAAY,GAAG,eAAe,CAAA;AAEpC,wEAAwE;AACxE,MAAM,WAAW,GAAG,kBAAkB,CAAA;AAEtC,uEAAuE;AACvE,MAAM,kBAAkB,GAAG;IACzB,oBAAoB;IACpB,eAAe;IACf,wBAAwB;IACxB,kBAAkB;IAClB,cAAc;CACf,CAAA;AAED,uEAAuE;AACvE,MAAM,eAAe,GAAG,aAAa,CAAA;AAErC,kFAAkF;AAClF,MAAM,eAAe,GAAG,uBAAuB,CAAA;AAE/C;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,IAAY,EACZ,YAAoC,EACpC,OAAqB;IAErB,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;IAC/B,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAA;IAE7B,mBAAmB;IACnB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QAC/B,OAAO,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAA;QAChC,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAA;QAChC,OAAO,CAAC,KAAK,CAAC,aAAa,GAAG,KAAK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AK,CAAC,aAAa,GAAG,IAAI,CAAA;YAClC,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,IAAI,CAAA;QACjC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,sEAAsE;IACtE,MAAM,SAAS,GAAG,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IACrD,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;QAC7B,OAAO,CAAC,KAAK,CAAC,eAAe,GAAG,IAAI,CAAA;QACpC,OAAO,oBAAoB,CACzB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,CAAC,EACzC,SAAS,EACT,YAAY,CACb,CAAA;IACH,CAAC;IAED,gDAAgD;IAChD,IAAI,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QAC7B,wCAAwC;QACxC,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/D,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAA;QAC9B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,EAAE,CAAA;IACpD,CAAC;IAED,iEAAiE;IACjE,mDAAmD;IACnD,IAAI,OAAO,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;QAC7D,iDAAiD;QACjD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Picocode tool name mappings
3
+ *
4
+ * Maps Picocode tool names to canonical tool names.
5
+ * Picocode tool names (from tools.rs): read_file, write_file, edit_file,
6
+ * copy_file, move_file, list_dir, make_dir, remove, glob_files, grep_text, bash, agent_browser
7
+ */
8
+ export declare const PICOCODE_TOOL_MAPPINGS: Record<string, string>;
9
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/agents/picocode/tools.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsBzD,CAAA"}