indusagi-coding-agent 0.1.23 → 0.1.24

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 (213) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +2 -0
  3. package/dist/cli/args.d.ts +117 -1
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +221 -52
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/cli/config-selector.d.ts +58 -2
  8. package/dist/cli/config-selector.d.ts.map +1 -1
  9. package/dist/cli/config-selector.js +130 -12
  10. package/dist/cli/config-selector.js.map +1 -1
  11. package/dist/cli/file-processor.d.ts +70 -2
  12. package/dist/cli/file-processor.d.ts.map +1 -1
  13. package/dist/cli/file-processor.js +240 -15
  14. package/dist/cli/file-processor.js.map +1 -1
  15. package/dist/cli/list-models.d.ts +63 -3
  16. package/dist/cli/list-models.d.ts.map +1 -1
  17. package/dist/cli/list-models.js +202 -27
  18. package/dist/cli/list-models.js.map +1 -1
  19. package/dist/cli/login-handler.d.ts +82 -8
  20. package/dist/cli/login-handler.d.ts.map +1 -1
  21. package/dist/cli/login-handler.js +410 -77
  22. package/dist/cli/login-handler.js.map +1 -1
  23. package/dist/cli/session-picker.d.ts +74 -2
  24. package/dist/cli/session-picker.d.ts.map +1 -1
  25. package/dist/cli/session-picker.js +236 -12
  26. package/dist/cli/session-picker.js.map +1 -1
  27. package/dist/core/agent-session.d.ts +214 -9
  28. package/dist/core/agent-session.d.ts.map +1 -1
  29. package/dist/core/agent-session.js +214 -9
  30. package/dist/core/agent-session.js.map +1 -1
  31. package/dist/core/bash-executor.d.ts +302 -12
  32. package/dist/core/bash-executor.d.ts.map +1 -1
  33. package/dist/core/bash-executor.js +302 -12
  34. package/dist/core/bash-executor.js.map +1 -1
  35. package/dist/core/diagnostics.d.ts +191 -0
  36. package/dist/core/diagnostics.d.ts.map +1 -1
  37. package/dist/core/diagnostics.js +142 -0
  38. package/dist/core/diagnostics.js.map +1 -1
  39. package/dist/core/event-bus.d.ts +146 -0
  40. package/dist/core/event-bus.d.ts.map +1 -1
  41. package/dist/core/event-bus.js +93 -0
  42. package/dist/core/event-bus.js.map +1 -1
  43. package/dist/core/export-html/ansi-to-html.d.ts +4 -0
  44. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  45. package/dist/core/export-html/ansi-to-html.js +4 -0
  46. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  47. package/dist/core/export-html/index.d.ts +128 -0
  48. package/dist/core/export-html/index.d.ts.map +1 -1
  49. package/dist/core/export-html/index.js +128 -0
  50. package/dist/core/export-html/index.js.map +1 -1
  51. package/dist/core/export-html/tool-renderer.d.ts +4 -0
  52. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  53. package/dist/core/export-html/tool-renderer.js +4 -0
  54. package/dist/core/export-html/tool-renderer.js.map +1 -1
  55. package/dist/core/keybindings.d.ts +142 -0
  56. package/dist/core/keybindings.d.ts.map +1 -1
  57. package/dist/core/keybindings.js +142 -0
  58. package/dist/core/keybindings.js.map +1 -1
  59. package/dist/core/model-registry.d.ts +98 -1
  60. package/dist/core/model-registry.d.ts.map +1 -1
  61. package/dist/core/model-registry.js +98 -1
  62. package/dist/core/model-registry.js.map +1 -1
  63. package/dist/core/model-resolver.d.ts +99 -1
  64. package/dist/core/model-resolver.d.ts.map +1 -1
  65. package/dist/core/model-resolver.js +99 -1
  66. package/dist/core/model-resolver.js.map +1 -1
  67. package/dist/core/prompt-templates.js.map +1 -1
  68. package/dist/core/session-manager.d.ts +127 -0
  69. package/dist/core/session-manager.d.ts.map +1 -1
  70. package/dist/core/session-manager.js +125 -0
  71. package/dist/core/session-manager.js.map +1 -1
  72. package/dist/core/skills.js.map +1 -1
  73. package/dist/core/subagents.js.map +1 -1
  74. package/dist/core/tools/bash.d.ts +391 -11
  75. package/dist/core/tools/bash.d.ts.map +1 -1
  76. package/dist/core/tools/bash.js +269 -2
  77. package/dist/core/tools/bash.js.map +1 -1
  78. package/dist/core/tools/edit.d.ts +284 -6
  79. package/dist/core/tools/edit.d.ts.map +1 -1
  80. package/dist/core/tools/edit.js +238 -0
  81. package/dist/core/tools/edit.js.map +1 -1
  82. package/dist/core/tools/find.d.ts +169 -5
  83. package/dist/core/tools/find.d.ts.map +1 -1
  84. package/dist/core/tools/find.js +136 -0
  85. package/dist/core/tools/find.js.map +1 -1
  86. package/dist/core/tools/grep.d.ts +285 -5
  87. package/dist/core/tools/grep.d.ts.map +1 -1
  88. package/dist/core/tools/grep.js +247 -0
  89. package/dist/core/tools/grep.js.map +1 -1
  90. package/dist/core/tools/ls.d.ts +6 -0
  91. package/dist/core/tools/ls.d.ts.map +1 -1
  92. package/dist/core/tools/ls.js +6 -0
  93. package/dist/core/tools/ls.js.map +1 -1
  94. package/dist/core/tools/read.d.ts +308 -7
  95. package/dist/core/tools/read.d.ts.map +1 -1
  96. package/dist/core/tools/read.js +231 -0
  97. package/dist/core/tools/read.js.map +1 -1
  98. package/dist/core/tools/webfetch.d.ts +118 -3
  99. package/dist/core/tools/webfetch.d.ts.map +1 -1
  100. package/dist/core/tools/webfetch.js +118 -3
  101. package/dist/core/tools/webfetch.js.map +1 -1
  102. package/dist/core/tools/websearch.d.ts +130 -3
  103. package/dist/core/tools/websearch.d.ts.map +1 -1
  104. package/dist/core/tools/websearch.js +130 -3
  105. package/dist/core/tools/websearch.js.map +1 -1
  106. package/dist/core/tools/write.d.ts +251 -5
  107. package/dist/core/tools/write.d.ts.map +1 -1
  108. package/dist/core/tools/write.js +210 -0
  109. package/dist/core/tools/write.js.map +1 -1
  110. package/dist/modes/interactive/components/assistant-message.d.ts +164 -1
  111. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  112. package/dist/modes/interactive/components/assistant-message.js +164 -1
  113. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  114. package/dist/modes/interactive/components/bash-execution.d.ts +297 -1
  115. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  116. package/dist/modes/interactive/components/bash-execution.js +297 -1
  117. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  118. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  119. package/dist/modes/interactive/components/tool-execution.js +251 -1
  120. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  121. package/dist/modes/interactive/components/user-message.d.ts +186 -1
  122. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  123. package/dist/modes/interactive/components/user-message.js +186 -1
  124. package/dist/modes/interactive/components/user-message.js.map +1 -1
  125. package/dist/modes/interactive/interactive-mode.d.ts +1567 -13
  126. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  127. package/dist/modes/interactive/interactive-mode.js +1567 -13
  128. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  129. package/dist/modes/interactive/theme/theme.d.ts +422 -0
  130. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  131. package/dist/modes/interactive/theme/theme.js +422 -0
  132. package/dist/modes/interactive/theme/theme.js.map +1 -1
  133. package/dist/modes/print-mode.d.ts +538 -5
  134. package/dist/modes/print-mode.d.ts.map +1 -1
  135. package/dist/modes/print-mode.js +538 -5
  136. package/dist/modes/print-mode.js.map +1 -1
  137. package/dist/modes/rpc/rpc-client.d.ts +921 -8
  138. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  139. package/dist/modes/rpc/rpc-client.js +921 -8
  140. package/dist/modes/rpc/rpc-client.js.map +1 -1
  141. package/dist/modes/rpc/rpc-mode.d.ts +802 -9
  142. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  143. package/dist/modes/rpc/rpc-mode.js +802 -9
  144. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  145. package/dist/modes/rpc/rpc-types.d.ts +356 -3
  146. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  147. package/dist/modes/rpc/rpc-types.js +356 -3
  148. package/dist/modes/rpc/rpc-types.js.map +1 -1
  149. package/dist/modes/shared.d.ts +386 -0
  150. package/dist/modes/shared.d.ts.map +1 -0
  151. package/dist/modes/shared.js +543 -0
  152. package/dist/modes/shared.js.map +1 -0
  153. package/dist/utils/array.d.ts +389 -0
  154. package/dist/utils/array.d.ts.map +1 -0
  155. package/dist/utils/array.js +585 -0
  156. package/dist/utils/array.js.map +1 -0
  157. package/dist/utils/color-formatter.d.ts +318 -0
  158. package/dist/utils/color-formatter.d.ts.map +1 -0
  159. package/dist/utils/color-formatter.js +442 -0
  160. package/dist/utils/color-formatter.js.map +1 -0
  161. package/dist/utils/data-transformer.d.ts +326 -0
  162. package/dist/utils/data-transformer.d.ts.map +1 -0
  163. package/dist/utils/data-transformer.js +512 -0
  164. package/dist/utils/data-transformer.js.map +1 -0
  165. package/dist/utils/date-formatter.d.ts +281 -0
  166. package/dist/utils/date-formatter.d.ts.map +1 -0
  167. package/dist/utils/date-formatter.js +503 -0
  168. package/dist/utils/date-formatter.js.map +1 -0
  169. package/dist/utils/error-handler.d.ts +541 -0
  170. package/dist/utils/error-handler.d.ts.map +1 -0
  171. package/dist/utils/error-handler.js +726 -0
  172. package/dist/utils/error-handler.js.map +1 -0
  173. package/dist/utils/file-operations.d.ts +297 -0
  174. package/dist/utils/file-operations.d.ts.map +1 -0
  175. package/dist/utils/file-operations.js +505 -0
  176. package/dist/utils/file-operations.js.map +1 -0
  177. package/dist/utils/frontmatter.d.ts +268 -6
  178. package/dist/utils/frontmatter.d.ts.map +1 -1
  179. package/dist/utils/frontmatter.js +500 -21
  180. package/dist/utils/frontmatter.js.map +1 -1
  181. package/dist/utils/json-formatter.d.ts +259 -0
  182. package/dist/utils/json-formatter.d.ts.map +1 -0
  183. package/dist/utils/json-formatter.js +517 -0
  184. package/dist/utils/json-formatter.js.map +1 -0
  185. package/dist/utils/logger.d.ts +176 -0
  186. package/dist/utils/logger.d.ts.map +1 -0
  187. package/dist/utils/logger.js +346 -0
  188. package/dist/utils/logger.js.map +1 -0
  189. package/dist/utils/markdown-formatter.d.ts +211 -0
  190. package/dist/utils/markdown-formatter.d.ts.map +1 -0
  191. package/dist/utils/markdown-formatter.js +482 -0
  192. package/dist/utils/markdown-formatter.js.map +1 -0
  193. package/dist/utils/path-validator.d.ts +603 -0
  194. package/dist/utils/path-validator.d.ts.map +1 -0
  195. package/dist/utils/path-validator.js +870 -0
  196. package/dist/utils/path-validator.js.map +1 -0
  197. package/dist/utils/string-formatter.d.ts +609 -0
  198. package/dist/utils/string-formatter.d.ts.map +1 -0
  199. package/dist/utils/string-formatter.js +806 -0
  200. package/dist/utils/string-formatter.js.map +1 -0
  201. package/dist/utils/type-guards.d.ts +629 -0
  202. package/dist/utils/type-guards.d.ts.map +1 -0
  203. package/dist/utils/type-guards.js +662 -0
  204. package/dist/utils/type-guards.js.map +1 -0
  205. package/docs/COMPLETE-GUIDE.md +300 -0
  206. package/docs/MODES-ARCHITECTURE.md +565 -0
  207. package/docs/PRINT-MODE-GUIDE.md +456 -0
  208. package/docs/RPC-GUIDE.md +705 -0
  209. package/docs/UTILS-IMPLEMENTATION-SUMMARY.md +647 -0
  210. package/docs/UTILS-MODULE-OVERVIEW.md +1480 -0
  211. package/docs/UTILS-QA-CHECKLIST.md +1061 -0
  212. package/docs/UTILS-USAGE-GUIDE.md +1419 -0
  213. package/package.json +1 -1
@@ -1,13 +1,546 @@
1
1
  /**
2
- * Print mode (single-shot): Send prompts, output result, exit.
2
+ * Print Mode - Non-interactive output mode for scripting and CI/CD
3
3
  *
4
- * Used for:
5
- * - `indusagi -p "prompt"` - text output
6
- * - `indusagi --mode json "prompt"` - JSON event stream
4
+ * ============================================================================
5
+ * PURPOSE
6
+ * ============================================================================
7
+ *
8
+ * Provides non-interactive execution mode for scripting, automation, and CI/CD
9
+ * pipelines. Accepts prompts via command-line arguments, executes the agent,
10
+ * and outputs results to stdout in machine or human-readable formats.
11
+ *
12
+ * This mode is ideal for:
13
+ * - Automated workflows and CI/CD pipelines
14
+ * - Batch processing of multiple prompts
15
+ * - Integration with shell scripts and other tools
16
+ * - Programmatic access via JSON output
17
+ * - Server-side execution without terminal UI
18
+ *
19
+ * ============================================================================
20
+ * OUTPUT FORMATS
21
+ * ============================================================================
22
+ *
23
+ * JSON Mode (--mode json):
24
+ * Output Structure:
25
+ * {
26
+ * "type": "session_header",
27
+ * "sessionFile": "path/to/session.jsonl",
28
+ * "model": { "provider": "anthropic", "id": "claude-3-5-sonnet" },
29
+ * ...
30
+ * }
31
+ * { "type": "message", "role": "user", "content": [...] }
32
+ * { "type": "message", "role": "assistant", "content": [...], "stopReason": "max_tokens" }
33
+ * { "type": "tool_call", "toolName": "bash", "toolInput": { "command": "ls" } }
34
+ * { "type": "tool_output", "output": "file1.txt\nfile2.txt" }
35
+ * { "type": "compaction_start", "reason": "context_limit" }
36
+ * { "type": "compaction_complete", "removedMessages": 5, "summary": "..." }
37
+ *
38
+ * Benefits:
39
+ * - Machine-parseable format
40
+ * - Contains all event details
41
+ * - Can be piped to jq for filtering/processing
42
+ * - Preserves streaming events in order
43
+ * - Exit code 0 on success, non-zero on error
44
+ *
45
+ * TEXT Mode (--mode text or default):
46
+ * Output Format:
47
+ * - Outputs only the final assistant message content
48
+ * - Suppresses all intermediate events
49
+ * - Clean output suitable for piping to other commands
50
+ * - Error messages printed to stderr
51
+ *
52
+ * Example:
53
+ * $ indusagi --mode text "What is 2+2?"
54
+ * The sum of 2+2 is 4.
55
+ *
56
+ * Exit Codes:
57
+ * 0: Success
58
+ * 1: Execution error
59
+ * 2: Invalid arguments
60
+ * Other: API or system errors
61
+ *
62
+ * COMPACT Mode (--mode compact):
63
+ * Output Format:
64
+ * - Minimal output (status only)
65
+ * - Useful when only success/failure matters
66
+ * - Best for monitoring and health checks
67
+ *
68
+ * ============================================================================
69
+ * USAGE EXAMPLES
70
+ * ============================================================================
71
+ *
72
+ * Single Prompt (Text Output):
73
+ * $ indusagi --mode text "Explain quantum computing"
74
+ *
75
+ * Single Prompt (JSON Events):
76
+ * $ indusagi --mode json "List all files" > output.jsonl
77
+ * $ cat output.jsonl | jq 'select(.type == "message")'
78
+ *
79
+ * Multiple Prompts (Sequential):
80
+ * $ indusagi --mode text "Setup project" "Run tests" "Deploy"
81
+ *
82
+ * With Session:
83
+ * $ indusagi --session existing-session "Continue conversation"
84
+ *
85
+ * File Attachment (@file syntax):
86
+ * $ indusagi --mode text "Review this:" "@src/main.ts"
87
+ *
88
+ * Image Attachment:
89
+ * $ indusagi --mode text "Analyze image" --image=/path/to/image.png
90
+ *
91
+ * Pipe to jq (Extract only assistant messages):
92
+ * $ indusagi --mode json "prompt" | jq 'select(.type == "message" and .role == "assistant")'
93
+ *
94
+ * Shell Integration:
95
+ * # Capture tool output
96
+ * result=$(indusagi --mode text "Run shell command" "ls -la")
97
+ * echo "Result: $result"
98
+ *
99
+ * # Check success
100
+ * if indusagi --mode text "Check status"; then
101
+ * echo "Success"
102
+ * else
103
+ * echo "Failed with exit code: $?"
104
+ * fi
105
+ *
106
+ * ============================================================================
107
+ * ERROR HANDLING
108
+ * ============================================================================
109
+ *
110
+ * Exit Codes:
111
+ * 0: All prompts processed successfully
112
+ * 1: Execution error (agent error, tool failure)
113
+ * 2: Invalid arguments or invalid prompt format
114
+ * 3: Session not found
115
+ * 4: Model not found or model error
116
+ * 5: API error (rate limit, auth, etc.)
117
+ * 6: Timeout
118
+ * 127: Unknown/unexpected error
119
+ *
120
+ * Error Output:
121
+ * - Errors printed to stderr
122
+ * - JSON mode: error event included in output
123
+ * - Text mode: error message printed to stderr
124
+ * - Process exits with appropriate code
125
+ *
126
+ * Handling Tool Failures:
127
+ * - Tool errors result in exit code 1
128
+ * - Error details in assistant message or JSON event
129
+ * - Can be retried with same prompt
130
+ *
131
+ * ============================================================================
132
+ * SESSION PERSISTENCE
133
+ * ============================================================================
134
+ *
135
+ * Session Files:
136
+ * - Automatically saved to ~/.indusagi/sessions/[id].jsonl
137
+ * - Can be resumed with --session flag
138
+ * - Each prompt appended to session history
139
+ *
140
+ * Continuing Sessions:
141
+ * $ indusagi --session abc123 --mode text "Continue conversation"
142
+ * # Loads previous messages and continues from there
143
+ *
144
+ * New Session:
145
+ * $ indusagi --mode text "First prompt"
146
+ * # Creates new session automatically
147
+ *
148
+ * ============================================================================
149
+ * EXTENSION SYSTEM
150
+ * ============================================================================
151
+ *
152
+ * Extensions in Print Mode:
153
+ * - Extensions are initialized but have limited UI capabilities
154
+ * - Custom commands (registered via extension) work normally
155
+ * - UI dialogs not supported (extensions should handle gracefully)
156
+ * - Hooks (before/after) are executed
157
+ * - Extension errors are logged to stderr
158
+ *
159
+ * ============================================================================
160
+ * IMPLEMENTATION NOTES
161
+ * ============================================================================
162
+ *
163
+ * Session Event Subscription:
164
+ * - Subscribes to all agent events for session persistence
165
+ * - Events stored in session JSONL file
166
+ * - Allows session resumption and history
167
+ *
168
+ * Output Ordering:
169
+ * - JSON mode: Events output in order as they occur
170
+ * - Text mode: Only final response output
171
+ * - Ensures proper ordering of async operations
172
+ *
173
+ * Stdout Flushing:
174
+ * - Final Promise ensures stdout is flushed before exit
175
+ * - Prevents race conditions where output is lost
176
+ * - Critical for data integrity in piped commands
177
+ *
178
+ * ============================================================================
179
+ * BASED ON PRINT MODE IMPLEMENTATION
180
+ * ============================================================================
181
+ *
182
+ * This non-interactive mode provides reliable output for automation and
183
+ * integration with other tools. It complements the interactive mode by
184
+ * enabling programmatic access to the agent's capabilities.
7
185
  */
8
186
  /**
9
187
  * Run in print (single-shot) mode.
10
- * Sends prompts to the agent and outputs the result.
188
+ * Sends prompts to the agent and outputs the result to stdout in either text or JSON format.
189
+ * This is the primary non-interactive execution mode for automation, CI/CD, and scripting.
190
+ *
191
+ * ============================================================================
192
+ * FUNCTION SIGNATURE
193
+ * ============================================================================
194
+ *
195
+ * async runPrintMode(session: AgentSession, options: PrintModeOptions): Promise<void>
196
+ *
197
+ * ============================================================================
198
+ * PARAMETERS
199
+ * ============================================================================
200
+ *
201
+ * @param session - AgentSession instance with model, tools, and extensions configured
202
+ * Must be initialized before calling runPrintMode
203
+ *
204
+ * @param options - PrintModeOptions object controlling behavior
205
+ * - mode: "text" | "json" - Output format (see OUTPUT FORMATS below)
206
+ * - initialMessage?: string - First prompt to send (supports @file inclusion)
207
+ * - initialImages?: ImageContent[] - Images to attach to initial message
208
+ * - messages?: string[] - Additional prompts to send sequentially after initialMessage
209
+ *
210
+ * ============================================================================
211
+ * OUTPUT FORMATS & STRUCTURE
212
+ * ============================================================================
213
+ *
214
+ * TEXT MODE (mode: "text")
215
+ * ────────────────────────────────────────────────────────────────────────
216
+ *
217
+ * Description:
218
+ * - Outputs only the final assistant message content
219
+ * - All intermediate events suppressed
220
+ * - Suitable for piping to other commands
221
+ * - Errors printed to stderr, not stdout
222
+ *
223
+ * Output Structure:
224
+ * Plain text content of the final assistant response
225
+ * May span multiple lines
226
+ *
227
+ * Example Output:
228
+ * $ indusagi --mode text "What is 2+2?"
229
+ * The sum of 2+2 is 4.
230
+ *
231
+ * Processing Flow:
232
+ * 1. Initializes session and extensions
233
+ * 2. Sends initialMessage to agent (with optional images)
234
+ * 3. Agent processes and streams events (internally captured)
235
+ * 4. Sends any additional messages from messages array
236
+ * 5. Extracts final assistant message
237
+ * 6. Outputs text content to stdout
238
+ * 7. Exits with appropriate exit code
239
+ *
240
+ * Character Encoding:
241
+ * - UTF-8 text output
242
+ * - Preserves newlines and formatting
243
+ * - Control characters passed through as-is
244
+ * - Binary content (from tool output) encoded as text
245
+ *
246
+ * JSON MODE (mode: "json")
247
+ * ────────────────────────────────────────────────────────────────────────
248
+ *
249
+ * Description:
250
+ * - Streams all agent events as newline-delimited JSON (JSONL)
251
+ * - Each line is a valid JSON object
252
+ * - Machine-parseable and processable by jq, etc.
253
+ * - Contains complete event information for reconstruction
254
+ *
255
+ * Output Structure (JSONL format):
256
+ * Each line is a separate JSON object, one of the following types:
257
+ *
258
+ * 1. Session Header Event:
259
+ * {
260
+ * "type": "session_header",
261
+ * "sessionFile": "~/.indusagi/sessions/abc123.jsonl",
262
+ * "model": {
263
+ * "provider": "anthropic",
264
+ * "id": "claude-3-5-sonnet",
265
+ * "contextWindow": 200000,
266
+ * "reasoning": true
267
+ * },
268
+ * "createdAt": "2025-02-21T14:32:31Z",
269
+ * "updatedAt": "2025-02-21T14:32:31Z"
270
+ * }
271
+ *
272
+ * 2. Message Event (User or Assistant):
273
+ * {
274
+ * "type": "message",
275
+ * "role": "user" | "assistant",
276
+ * "content": [
277
+ * {
278
+ * "type": "text",
279
+ * "text": "Tell me about X"
280
+ * },
281
+ * {
282
+ * "type": "image",
283
+ * "mimeType": "image/png",
284
+ * "data": "base64-encoded-image-data"
285
+ * }
286
+ * ],
287
+ * "stopReason": "max_tokens" | "end_turn" | "tool_use" | "error" | "aborted",
288
+ * "errorMessage": "Optional error message if stopReason is 'error'"
289
+ * }
290
+ *
291
+ * 3. Tool Call Event:
292
+ * {
293
+ * "type": "tool_call",
294
+ * "toolName": "bash",
295
+ * "toolUse": {
296
+ * "id": "tool_use_123",
297
+ * "name": "bash",
298
+ * "input": {
299
+ * "command": "ls -la"
300
+ * }
301
+ * }
302
+ * }
303
+ *
304
+ * 4. Tool Output Event:
305
+ * {
306
+ * "type": "tool_output",
307
+ * "toolUseId": "tool_use_123",
308
+ * "output": "file1.txt\nfile2.txt\n",
309
+ * "isError": false
310
+ * }
311
+ *
312
+ * 5. Context Compaction Events:
313
+ * {
314
+ * "type": "compaction_start",
315
+ * "reason": "context_limit" | "manual" | "auto"
316
+ * }
317
+ *
318
+ * {
319
+ * "type": "compaction_complete",
320
+ * "removedMessages": 5,
321
+ * "summary": "Previous conversation about X and Y was compacted..."
322
+ * }
323
+ *
324
+ * 6. Agent Lifecycle Events:
325
+ * {
326
+ * "type": "agent_start",
327
+ * "model": {...}
328
+ * }
329
+ *
330
+ * {
331
+ * "type": "agent_end"
332
+ * }
333
+ *
334
+ * Example Output (jq filtering):
335
+ * # Extract only assistant messages
336
+ * $ indusagi --mode json "prompt" | jq 'select(.type == "message" and .role == "assistant")'
337
+ *
338
+ * # Extract only tool calls
339
+ * $ indusagi --mode json "prompt" | jq 'select(.type == "tool_call")'
340
+ *
341
+ * # Count messages
342
+ * $ indusagi --mode json "prompt" | jq -s '[.[] | select(.type == "message")] | length'
343
+ *
344
+ * Use Cases:
345
+ * - Automated test verification
346
+ * - Event auditing and logging
347
+ * - Integration with JSON processing tools
348
+ * - CI/CD pipelines that need detailed output
349
+ * - Performance analysis (tool execution time, etc.)
350
+ *
351
+ * ============================================================================
352
+ * EXIT CODES
353
+ * ============================================================================
354
+ *
355
+ * SUCCESS CODES:
356
+ * ─────────────
357
+ * 0 - All prompts executed successfully
358
+ * - Agent completed without errors
359
+ * - All tools executed successfully
360
+ * - Final response contains valid content
361
+ *
362
+ * ERROR CODES:
363
+ * ──────────
364
+ * 1 - Execution Error
365
+ * - Agent loop error during processing
366
+ * - Tool execution failure (bash, read, write, etc.)
367
+ * - Model returned error or aborted response
368
+ * - Session error or state inconsistency
369
+ *
370
+ * 2 - Invalid Arguments
371
+ * - Missing required option
372
+ * - Invalid mode value (not "text" or "json")
373
+ * - Malformed prompt or message array
374
+ * - Invalid image content
375
+ * - Invalid flag combination
376
+ *
377
+ * 3 - Session Not Found
378
+ * - Session file doesn't exist (--session)
379
+ * - Session file corrupted
380
+ * - Session ID doesn't resolve to valid file
381
+ * - Parent session doesn't exist (for branching)
382
+ *
383
+ * 4 - Tool Failed
384
+ * - Tool setup failed (bash executor initialization)
385
+ * - File system tool failures (read/write permissions)
386
+ * - Tool configuration missing
387
+ * - Tool subprocess crashed
388
+ *
389
+ * 5 - Model Error
390
+ * - Model not found in registry
391
+ * - Model provider unreachable
392
+ * - Model API authentication failed
393
+ * - Model rate limit exceeded
394
+ * - Model context window exceeded
395
+ *
396
+ * 6 - Timeout
397
+ * - Agent processing exceeded timeout
398
+ * - Tool execution timeout
399
+ * - Network request timeout
400
+ * - Model response timeout
401
+ *
402
+ * 127 - Unknown/Unexpected Error
403
+ * - Unhandled exception in agent
404
+ * - Assertion failure
405
+ * - Out of memory
406
+ * - Unexpected state
407
+ *
408
+ * INTERPRETATION GUIDE:
409
+ * ──────────────────
410
+ * - Exit codes 1-6 indicate specific categories of failures
411
+ * - Exit code 127 indicates unexpected error requiring investigation
412
+ * - Check stderr output for detailed error message
413
+ * - In CI/CD: exit code 0 is success, any other is failure
414
+ *
415
+ * ============================================================================
416
+ * EVENT SUBSCRIPTION & SESSION PERSISTENCE
417
+ * ============================================================================
418
+ *
419
+ * Session Event Handling:
420
+ * - All agent events automatically subscribed to
421
+ * - Events written to session JSONL file for history
422
+ * - Enables session resumption and branching
423
+ * - Session files located at ~/.indusagi/sessions/[id].jsonl
424
+ *
425
+ * Event Recording:
426
+ * - Each event is appended to session file as single JSON line
427
+ * - Ordering preserved (chronological)
428
+ * - Message content and tool output recorded
429
+ * - Allows reconstruction of full conversation
430
+ *
431
+ * Session Resumption:
432
+ * $ indusagi --session abc123 --mode text "Continue the conversation"
433
+ * # Loads all previous messages from session file
434
+ * # Continues with new prompt in context
435
+ *
436
+ * ============================================================================
437
+ * EXTENSION SYSTEM BEHAVIOR
438
+ * ============================================================================
439
+ *
440
+ * Extension Initialization:
441
+ * - Extensions are loaded and initialized
442
+ * - But limited UI capabilities (no terminal dialogs)
443
+ * - Hooks (before_prompt, after_prompt) are executed
444
+ * - Custom commands work if they don't require UI
445
+ *
446
+ * UI Limitations:
447
+ * - Extension dialogs not supported
448
+ * - select(), confirm(), input() - not available
449
+ * - Custom UI components - not available
450
+ * - Errors from UI calls logged to stderr
451
+ *
452
+ * Hook Execution:
453
+ * 1. before_prompt: Runs before agent loop (can modify prompt)
454
+ * 2. after_prompt: Runs after agent completes
455
+ * 3. Error handling: Extension errors logged, not fatal
456
+ *
457
+ * Extension Error Handling:
458
+ * - Errors printed to stderr with format:
459
+ * "Extension error (ext-path): error message"
460
+ * - Process continues despite extension error
461
+ * - Use for debugging extension issues
462
+ *
463
+ * ============================================================================
464
+ * IMPLEMENTATION DETAILS
465
+ * ============================================================================
466
+ *
467
+ * Processing Steps:
468
+ * 1. Extract mode and messages from options
469
+ * 2. Initialize extension runner with limited UI (no dialogs)
470
+ * 3. Subscribe to all agent events for session persistence
471
+ * 4. Send initialMessage (with images if provided)
472
+ * 5. Send each message in messages array sequentially
473
+ * 6. In JSON mode: stream all events to stdout
474
+ * 7. In TEXT mode: extract final assistant message text
475
+ * 8. Output result to stdout
476
+ * 9. Flush stdout buffer (critical for piped commands)
477
+ * 10. Return promise (process.exit() called by caller)
478
+ *
479
+ * JSON Mode Output Order:
480
+ * - Session header (first)
481
+ * - agent_start event
482
+ * - Message events (user/assistant)
483
+ * - Tool events (tool_call, tool_output)
484
+ * - Compaction events (if applicable)
485
+ * - agent_end event
486
+ * - Subsequent events from additional messages
487
+ *
488
+ * Text Mode Output:
489
+ * - Suppresses all intermediate output
490
+ * - Extracts last message with role = "assistant"
491
+ * - Outputs only text content type (ignores images)
492
+ * - Handles error stop reasons by outputting error and exiting 1
493
+ *
494
+ * Stdout Flushing:
495
+ * - Critical for preventing data loss in piped commands
496
+ * - Final operation before returning promise
497
+ * - Ensures all content written before process exit
498
+ * - Uses process.stdout.write('') callback mechanism
499
+ *
500
+ * ============================================================================
501
+ * USAGE EXAMPLES
502
+ * ============================================================================
503
+ *
504
+ * Basic Prompt (Text Output):
505
+ * $ indusagi --mode text "What is 2+2?"
506
+ * 4
507
+ * $ echo $?
508
+ * 0
509
+ *
510
+ * Multiple Prompts:
511
+ * $ indusagi --mode text "First prompt" "Second prompt"
512
+ * # Outputs final response from second prompt
513
+ *
514
+ * With Image Attachment:
515
+ * $ indusagi --mode text "Describe this image" --image=/path/to/image.png
516
+ * # Image content included in context
517
+ *
518
+ * File Inclusion:
519
+ * $ indusagi --mode text "Review this code:" "@src/main.ts"
520
+ * # File content loaded and sent with prompt
521
+ *
522
+ * JSON Output for Testing:
523
+ * $ indusagi --mode json "Test prompt" > output.jsonl
524
+ * $ cat output.jsonl | jq 'select(.type == "message" and .role == "assistant") | .content[0].text'
525
+ *
526
+ * Piping to Other Tools:
527
+ * $ indusagi --mode text "List files in /usr/bin" | wc -l
528
+ * $ indusagi --mode text "Generate JSON" | jq '.key'
529
+ *
530
+ * Error Handling in Scripts:
531
+ * if indusagi --mode text "Check something"; then
532
+ * echo "Success"
533
+ * else
534
+ * exitCode=$?
535
+ * echo "Failed with exit code: $exitCode"
536
+ * fi
537
+ *
538
+ * CI/CD Integration:
539
+ * # In GitHub Actions, GitLab CI, etc.
540
+ * - name: Run agent
541
+ * run: indusagi --mode text "Run tests" || exit $?
542
+ *
543
+ * ============================================================================
11
544
  */
12
545
  export async function runPrintMode(session, options) {
13
546
  const { mode, messages = [], initialMessage, initialImages } = options;
@@ -1 +1 @@
1
- {"version":3,"file":"print-mode.js","sourceRoot":"","sources":["../../src/modes/print-mode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAmBH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAqB,EAAE,OAAyB;IAClF,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IACvE,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACrB,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC;QAClD,IAAI,MAAM,EAAE,CAAC;YACZ,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QACrC,CAAC;IACF,CAAC;IACD,2CAA2C;IAC3C,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAChD,IAAI,eAAe,EAAE,CAAC;QACrB,MAAM,OAAO,CAAC,cAAc,CAAC;YAC5B,qBAAqB,EAAE;gBACtB,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE;gBAC9C,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;oBAC7B,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,EAAE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