@yuaone/cli 0.1.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/LICENSE +663 -0
- package/dist/auth.d.ts +71 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +240 -0
- package/dist/auth.js.map +1 -0
- package/dist/cli.d.ts +16 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +212 -0
- package/dist/cli.js.map +1 -0
- package/dist/cloud-client.d.ts +179 -0
- package/dist/cloud-client.d.ts.map +1 -0
- package/dist/cloud-client.js +369 -0
- package/dist/cloud-client.js.map +1 -0
- package/dist/config.d.ts +59 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +214 -0
- package/dist/config.js.map +1 -0
- package/dist/design-renderer.d.ts +16 -0
- package/dist/design-renderer.d.ts.map +1 -0
- package/dist/design-renderer.js +78 -0
- package/dist/design-renderer.js.map +1 -0
- package/dist/design.d.ts +18 -0
- package/dist/design.d.ts.map +1 -0
- package/dist/design.js +190 -0
- package/dist/design.js.map +1 -0
- package/dist/diff-renderer.d.ts +56 -0
- package/dist/diff-renderer.d.ts.map +1 -0
- package/dist/diff-renderer.js +133 -0
- package/dist/diff-renderer.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/interactive.d.ts +73 -0
- package/dist/interactive.d.ts.map +1 -0
- package/dist/interactive.js +638 -0
- package/dist/interactive.js.map +1 -0
- package/dist/oneshot.d.ts +17 -0
- package/dist/oneshot.d.ts.map +1 -0
- package/dist/oneshot.js +281 -0
- package/dist/oneshot.js.map +1 -0
- package/dist/progress-renderer.d.ts +116 -0
- package/dist/progress-renderer.d.ts.map +1 -0
- package/dist/progress-renderer.js +249 -0
- package/dist/progress-renderer.js.map +1 -0
- package/dist/renderer.d.ts +67 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +182 -0
- package/dist/renderer.js.map +1 -0
- package/dist/session.d.ts +71 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +246 -0
- package/dist/session.js.map +1 -0
- package/dist/y-spinner.d.ts +34 -0
- package/dist/y-spinner.d.ts.map +1 -0
- package/dist/y-spinner.js +93 -0
- package/dist/y-spinner.js.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,638 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YUAN CLI — Interactive Mode
|
|
3
|
+
*
|
|
4
|
+
* REPL loop for interactive agent sessions.
|
|
5
|
+
* Supports slash commands, multiline input, and streaming responses.
|
|
6
|
+
* Wired to @yuaone/core AgentLoop + @yuaone/tools for real LLM-powered execution.
|
|
7
|
+
*/
|
|
8
|
+
import * as fs from "node:fs";
|
|
9
|
+
import * as readline from "node:readline";
|
|
10
|
+
import { execFileSync } from "node:child_process";
|
|
11
|
+
import { colors } from "./renderer.js";
|
|
12
|
+
import { DiffRenderer } from "./diff-renderer.js";
|
|
13
|
+
import { AgentLoop, DEFAULT_LOOP_CONFIG, } from "@yuaone/core";
|
|
14
|
+
import { createDefaultRegistry } from "@yuaone/tools";
|
|
15
|
+
import { CloudClient } from "./cloud-client.js";
|
|
16
|
+
const ESC = "\x1b[";
|
|
17
|
+
function c(color, text) {
|
|
18
|
+
return `${color}${text}${ESC}0m`;
|
|
19
|
+
}
|
|
20
|
+
/** Slash commands available in interactive mode */
|
|
21
|
+
const SLASH_COMMANDS = {
|
|
22
|
+
"/help": "Show this help message",
|
|
23
|
+
"/clear": "Clear the screen",
|
|
24
|
+
"/undo": "Undo the last agent action",
|
|
25
|
+
"/diff": "Show current file changes",
|
|
26
|
+
"/quit": "Exit YUAN (also: Ctrl+C)",
|
|
27
|
+
"/config": "Show current configuration",
|
|
28
|
+
"/session": "Show session info",
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* InteractiveSession — the main REPL for `yuan` interactive mode
|
|
32
|
+
*/
|
|
33
|
+
export class InteractiveSession {
|
|
34
|
+
renderer;
|
|
35
|
+
diffRenderer;
|
|
36
|
+
sessionManager;
|
|
37
|
+
configManager;
|
|
38
|
+
session;
|
|
39
|
+
rl = null;
|
|
40
|
+
isRunning = false;
|
|
41
|
+
isStreaming = false;
|
|
42
|
+
/** Track files changed during the session for /diff and /undo */
|
|
43
|
+
changedFiles = [];
|
|
44
|
+
constructor(renderer, sessionManager, configManager, existingSession) {
|
|
45
|
+
this.renderer = renderer;
|
|
46
|
+
this.diffRenderer = new DiffRenderer();
|
|
47
|
+
this.sessionManager = sessionManager;
|
|
48
|
+
this.configManager = configManager;
|
|
49
|
+
const config = this.configManager.get();
|
|
50
|
+
this.session =
|
|
51
|
+
existingSession ??
|
|
52
|
+
this.sessionManager.create(process.cwd(), config.provider, this.configManager.getModel());
|
|
53
|
+
}
|
|
54
|
+
/** Start the interactive REPL */
|
|
55
|
+
async start() {
|
|
56
|
+
this.isRunning = true;
|
|
57
|
+
this.renderer.banner();
|
|
58
|
+
this.renderer.info(`Provider: ${c(colors.cyan, this.session.provider)} | Model: ${c(colors.cyan, this.session.model)}`);
|
|
59
|
+
this.renderer.info(`Working directory: ${c(colors.dim, this.session.workDir)}`);
|
|
60
|
+
this.renderer.info(`Session: ${c(colors.dim, this.session.id.slice(0, 8))}`);
|
|
61
|
+
console.log(c(colors.dim, " Type /help for commands, Ctrl+C to exit\n"));
|
|
62
|
+
this.rl = readline.createInterface({
|
|
63
|
+
input: process.stdin,
|
|
64
|
+
output: process.stdout,
|
|
65
|
+
prompt: c(colors.cyan + colors.bold, ">>> "),
|
|
66
|
+
});
|
|
67
|
+
// Handle Ctrl+C gracefully
|
|
68
|
+
this.rl.on("close", () => {
|
|
69
|
+
this.stop();
|
|
70
|
+
});
|
|
71
|
+
this.rl.on("SIGINT", () => {
|
|
72
|
+
console.log(c(colors.dim, "\n (Ctrl+C) Stopping..."));
|
|
73
|
+
this.stop();
|
|
74
|
+
});
|
|
75
|
+
// REPL loop
|
|
76
|
+
return new Promise((resolve) => {
|
|
77
|
+
const promptNext = () => {
|
|
78
|
+
if (!this.isRunning || !this.rl) {
|
|
79
|
+
resolve();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this.rl.question(c(colors.cyan + colors.bold, ">>> "), async (input) => {
|
|
83
|
+
const trimmed = input.trim();
|
|
84
|
+
if (!trimmed) {
|
|
85
|
+
promptNext();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
// Handle slash commands
|
|
89
|
+
if (trimmed.startsWith("/")) {
|
|
90
|
+
const shouldContinue = this.handleSlashCommand(trimmed);
|
|
91
|
+
if (!shouldContinue) {
|
|
92
|
+
resolve();
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
promptNext();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
// Process user input as agent message
|
|
99
|
+
await this.processMessage(trimmed);
|
|
100
|
+
promptNext();
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
promptNext();
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/** Handle a slash command. Returns false if session should end. */
|
|
107
|
+
handleSlashCommand(command) {
|
|
108
|
+
const cmd = command.toLowerCase().split(" ")[0];
|
|
109
|
+
switch (cmd) {
|
|
110
|
+
case "/help":
|
|
111
|
+
this.showHelp();
|
|
112
|
+
return true;
|
|
113
|
+
case "/clear":
|
|
114
|
+
console.clear();
|
|
115
|
+
this.renderer.banner();
|
|
116
|
+
return true;
|
|
117
|
+
case "/undo":
|
|
118
|
+
this.handleUndo();
|
|
119
|
+
return true;
|
|
120
|
+
case "/diff":
|
|
121
|
+
this.handleDiff();
|
|
122
|
+
return true;
|
|
123
|
+
case "/quit":
|
|
124
|
+
case "/exit":
|
|
125
|
+
case "/q":
|
|
126
|
+
this.stop();
|
|
127
|
+
return false;
|
|
128
|
+
case "/config":
|
|
129
|
+
console.log();
|
|
130
|
+
console.log(this.configManager.show());
|
|
131
|
+
console.log();
|
|
132
|
+
return true;
|
|
133
|
+
case "/session":
|
|
134
|
+
this.showSessionInfo();
|
|
135
|
+
return true;
|
|
136
|
+
default:
|
|
137
|
+
this.renderer.warn(`Unknown command: ${cmd}. Type /help for available commands.`);
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** Show available slash commands */
|
|
142
|
+
showHelp() {
|
|
143
|
+
console.log();
|
|
144
|
+
console.log(c(colors.bold, " Available Commands"));
|
|
145
|
+
console.log(c(colors.dim, " " + "-".repeat(40)));
|
|
146
|
+
for (const [cmd, desc] of Object.entries(SLASH_COMMANDS)) {
|
|
147
|
+
console.log(` ${c(colors.cyan, cmd.padEnd(12))} ${c(colors.dim, desc)}`);
|
|
148
|
+
}
|
|
149
|
+
console.log();
|
|
150
|
+
}
|
|
151
|
+
/** Show current session info */
|
|
152
|
+
showSessionInfo() {
|
|
153
|
+
const s = this.session;
|
|
154
|
+
console.log();
|
|
155
|
+
console.log(c(colors.bold, " Session Info"));
|
|
156
|
+
console.log(c(colors.dim, " " + "-".repeat(40)));
|
|
157
|
+
console.log(` ID : ${c(colors.dim, s.id)}`);
|
|
158
|
+
console.log(` Created : ${c(colors.dim, new Date(s.createdAt).toLocaleString())}`);
|
|
159
|
+
console.log(` Messages : ${c(colors.dim, String(s.messages.length))}`);
|
|
160
|
+
console.log(` Work Dir : ${c(colors.dim, s.workDir)}`);
|
|
161
|
+
console.log();
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Handle /undo command.
|
|
165
|
+
* Reverts the last file change using git checkout or .yuan-backup files.
|
|
166
|
+
*/
|
|
167
|
+
handleUndo() {
|
|
168
|
+
if (this.changedFiles.length === 0) {
|
|
169
|
+
this.renderer.warn("No file changes to undo in this session.");
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const lastFile = this.changedFiles[this.changedFiles.length - 1];
|
|
173
|
+
try {
|
|
174
|
+
// Try git checkout first (most reliable)
|
|
175
|
+
execFileSync("git", ["checkout", "--", lastFile], {
|
|
176
|
+
cwd: this.session.workDir,
|
|
177
|
+
stdio: "pipe",
|
|
178
|
+
});
|
|
179
|
+
this.changedFiles.pop();
|
|
180
|
+
this.renderer.success(`Reverted: ${lastFile}`);
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
// If git checkout fails, try .yuan-backup
|
|
184
|
+
try {
|
|
185
|
+
const backupPath = `${lastFile}.yuan-backup`;
|
|
186
|
+
fs.renameSync(backupPath, lastFile);
|
|
187
|
+
this.changedFiles.pop();
|
|
188
|
+
this.renderer.success(`Restored from backup: ${lastFile}`);
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
this.renderer.error(`Cannot undo: ${lastFile} — not in git and no backup found.`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Handle /diff command.
|
|
197
|
+
* Shows git diff for files changed during this session.
|
|
198
|
+
*/
|
|
199
|
+
handleDiff() {
|
|
200
|
+
try {
|
|
201
|
+
// Show git diff of working directory changes
|
|
202
|
+
const diffOutput = execFileSync("git", ["diff"], {
|
|
203
|
+
cwd: this.session.workDir,
|
|
204
|
+
stdio: "pipe",
|
|
205
|
+
encoding: "utf-8",
|
|
206
|
+
maxBuffer: 1024 * 1024,
|
|
207
|
+
});
|
|
208
|
+
if (!diffOutput.trim()) {
|
|
209
|
+
// Also check staged changes
|
|
210
|
+
const stagedOutput = execFileSync("git", ["diff", "--cached"], {
|
|
211
|
+
cwd: this.session.workDir,
|
|
212
|
+
stdio: "pipe",
|
|
213
|
+
encoding: "utf-8",
|
|
214
|
+
maxBuffer: 1024 * 1024,
|
|
215
|
+
});
|
|
216
|
+
if (!stagedOutput.trim()) {
|
|
217
|
+
this.renderer.info("No file changes detected (working tree clean).");
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
console.log();
|
|
221
|
+
console.log(c(colors.bold, " Staged Changes"));
|
|
222
|
+
this.diffRenderer.renderRawDiff(stagedOutput);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
console.log();
|
|
226
|
+
console.log(c(colors.bold, " Working Directory Changes"));
|
|
227
|
+
this.diffRenderer.renderRawDiff(diffOutput);
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
this.renderer.warn("Not a git repository or git not available. Cannot show diff.");
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Process a user message — dispatches to local or cloud mode.
|
|
235
|
+
*/
|
|
236
|
+
async processMessage(message) {
|
|
237
|
+
if (this.configManager.isCloudMode()) {
|
|
238
|
+
return this.processMessageCloud(message);
|
|
239
|
+
}
|
|
240
|
+
return this.processMessageLocal(message);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Process a user message via CloudClient (cloud mode).
|
|
244
|
+
* Starts a remote session, streams SSE events, handles approvals.
|
|
245
|
+
*/
|
|
246
|
+
async processMessageCloud(message) {
|
|
247
|
+
this.sessionManager.addMessage(this.session, "user", message);
|
|
248
|
+
const config = this.configManager.get();
|
|
249
|
+
if (!config.apiKey) {
|
|
250
|
+
this.renderer.error("No API key configured. Run `yuan config` to set up.");
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const client = new CloudClient(config.serverUrl, config.apiKey);
|
|
254
|
+
const abortController = new AbortController();
|
|
255
|
+
// Handle SIGINT during cloud streaming
|
|
256
|
+
const sigintHandler = () => {
|
|
257
|
+
abortController.abort();
|
|
258
|
+
};
|
|
259
|
+
process.on("SIGINT", sigintHandler);
|
|
260
|
+
const spinner = this.renderer.thinking();
|
|
261
|
+
this.isStreaming = false;
|
|
262
|
+
let cloudSessionId;
|
|
263
|
+
try {
|
|
264
|
+
// Start remote session
|
|
265
|
+
const { sessionId } = await client.startSession(message, {
|
|
266
|
+
workDir: this.session.workDir,
|
|
267
|
+
model: config.model,
|
|
268
|
+
});
|
|
269
|
+
cloudSessionId = sessionId;
|
|
270
|
+
// Stream events
|
|
271
|
+
await client.streamEvents(sessionId, (event) => {
|
|
272
|
+
switch (event.kind) {
|
|
273
|
+
case "thinking":
|
|
274
|
+
if (!this.isStreaming) {
|
|
275
|
+
spinner.update(event.content);
|
|
276
|
+
}
|
|
277
|
+
break;
|
|
278
|
+
case "text_delta":
|
|
279
|
+
if (!this.isStreaming) {
|
|
280
|
+
spinner.stop();
|
|
281
|
+
this.isStreaming = true;
|
|
282
|
+
console.log();
|
|
283
|
+
}
|
|
284
|
+
this.renderer.streamToken(event.text);
|
|
285
|
+
break;
|
|
286
|
+
case "tool_call":
|
|
287
|
+
if (this.isStreaming) {
|
|
288
|
+
this.renderer.endStream();
|
|
289
|
+
this.isStreaming = false;
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
spinner.stop();
|
|
293
|
+
}
|
|
294
|
+
this.renderer.toolCall(event.tool, typeof event.input === "string"
|
|
295
|
+
? event.input.slice(0, 100)
|
|
296
|
+
: JSON.stringify(event.input, null, 0).slice(0, 100));
|
|
297
|
+
break;
|
|
298
|
+
case "tool_result":
|
|
299
|
+
this.renderer.toolResult(event.output);
|
|
300
|
+
break;
|
|
301
|
+
case "approval_needed":
|
|
302
|
+
if (this.isStreaming) {
|
|
303
|
+
this.renderer.endStream();
|
|
304
|
+
this.isStreaming = false;
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
spinner.stop();
|
|
308
|
+
}
|
|
309
|
+
this.renderer.warn(`Approval required: ${event.description} [${event.risk}]`);
|
|
310
|
+
// Prompt user and send approval
|
|
311
|
+
void this.promptCloudApproval(client, sessionId, event.actionId, event.tool).then(() => {
|
|
312
|
+
// Approval sent — stream will continue via SSE
|
|
313
|
+
});
|
|
314
|
+
break;
|
|
315
|
+
case "error":
|
|
316
|
+
if (this.isStreaming) {
|
|
317
|
+
this.renderer.endStream();
|
|
318
|
+
this.isStreaming = false;
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
spinner.stop();
|
|
322
|
+
}
|
|
323
|
+
this.renderer.error(event.message);
|
|
324
|
+
break;
|
|
325
|
+
case "done":
|
|
326
|
+
if (this.isStreaming) {
|
|
327
|
+
this.renderer.endStream();
|
|
328
|
+
this.isStreaming = false;
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
spinner.stop();
|
|
332
|
+
}
|
|
333
|
+
break;
|
|
334
|
+
case "status_change":
|
|
335
|
+
// Silent — could log if verbose
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
}, { signal: abortController.signal });
|
|
339
|
+
spinner.stop();
|
|
340
|
+
if (this.isStreaming) {
|
|
341
|
+
this.renderer.endStream();
|
|
342
|
+
this.isStreaming = false;
|
|
343
|
+
}
|
|
344
|
+
this.sessionManager.addMessage(this.session, "assistant", "[cloud session completed]");
|
|
345
|
+
}
|
|
346
|
+
catch (err) {
|
|
347
|
+
spinner.stop();
|
|
348
|
+
if (this.isStreaming) {
|
|
349
|
+
this.renderer.endStream();
|
|
350
|
+
this.isStreaming = false;
|
|
351
|
+
}
|
|
352
|
+
// If aborted (SIGINT), try to stop remote session
|
|
353
|
+
if (err instanceof DOMException && err.name === "AbortError") {
|
|
354
|
+
if (cloudSessionId) {
|
|
355
|
+
await client.stop(cloudSessionId).catch(() => { });
|
|
356
|
+
}
|
|
357
|
+
this.renderer.info("Cancelled.");
|
|
358
|
+
this.sessionManager.addMessage(this.session, "assistant", "[cancelled]");
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
362
|
+
this.renderer.error(`Cloud error: ${errorMsg}`);
|
|
363
|
+
this.sessionManager.addMessage(this.session, "assistant", `[ERROR] ${errorMsg}`);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
finally {
|
|
367
|
+
process.removeListener("SIGINT", sigintHandler);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Prompt the user for cloud-mode approval and send response to server.
|
|
372
|
+
*/
|
|
373
|
+
async promptCloudApproval(client, sessionId, actionId, toolName) {
|
|
374
|
+
return new Promise((resolve) => {
|
|
375
|
+
const approvalRl = readline.createInterface({
|
|
376
|
+
input: process.stdin,
|
|
377
|
+
output: process.stdout,
|
|
378
|
+
});
|
|
379
|
+
approvalRl.question(`\x1b[33m\x1b[1m Approve? [Y/n] \x1b[0m`, async (answer) => {
|
|
380
|
+
approvalRl.close();
|
|
381
|
+
const trimmed = answer.trim().toLowerCase();
|
|
382
|
+
const approved = trimmed !== "n" && trimmed !== "no";
|
|
383
|
+
try {
|
|
384
|
+
await client.approve(sessionId, actionId, {
|
|
385
|
+
approved,
|
|
386
|
+
message: approved ? undefined : "User rejected",
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
catch (err) {
|
|
390
|
+
this.renderer.error(`Approval send failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
391
|
+
}
|
|
392
|
+
resolve();
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Process a user message through the local AgentLoop.
|
|
398
|
+
* Creates BYOKClient + ToolExecutor, runs AgentLoop.run(), and renders events.
|
|
399
|
+
*/
|
|
400
|
+
async processMessageLocal(message) {
|
|
401
|
+
// Save user message
|
|
402
|
+
this.sessionManager.addMessage(this.session, "user", message);
|
|
403
|
+
const config = this.configManager.get();
|
|
404
|
+
// Check API key
|
|
405
|
+
if (!config.apiKey) {
|
|
406
|
+
this.renderer.error("No API key configured. Run `yuan config` to set up.");
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
// Build BYOK config
|
|
410
|
+
const byokConfig = {
|
|
411
|
+
provider: config.provider,
|
|
412
|
+
apiKey: config.apiKey,
|
|
413
|
+
model: config.model,
|
|
414
|
+
baseUrl: config.baseUrl,
|
|
415
|
+
};
|
|
416
|
+
// Create tool registry and executor
|
|
417
|
+
const registry = createDefaultRegistry();
|
|
418
|
+
const workDir = this.session.workDir;
|
|
419
|
+
const toolExecutor = registry.toExecutor(workDir);
|
|
420
|
+
// Build agent config
|
|
421
|
+
const agentConfig = {
|
|
422
|
+
byok: byokConfig,
|
|
423
|
+
loop: {
|
|
424
|
+
model: "coding",
|
|
425
|
+
maxIterations: DEFAULT_LOOP_CONFIG.maxIterations,
|
|
426
|
+
maxTokensPerIteration: DEFAULT_LOOP_CONFIG.maxTokensPerIteration,
|
|
427
|
+
totalTokenBudget: DEFAULT_LOOP_CONFIG.totalTokenBudget,
|
|
428
|
+
tools: toolExecutor.definitions,
|
|
429
|
+
systemPrompt: "You are YUAN, an autonomous coding agent. " +
|
|
430
|
+
"You have access to tools for reading, writing, editing files, running shell commands, and searching code. " +
|
|
431
|
+
"Complete the user's coding tasks efficiently and correctly.",
|
|
432
|
+
projectPath: workDir,
|
|
433
|
+
},
|
|
434
|
+
};
|
|
435
|
+
// Create and run AgentLoop with approval handler
|
|
436
|
+
const loop = new AgentLoop({
|
|
437
|
+
config: agentConfig,
|
|
438
|
+
toolExecutor,
|
|
439
|
+
governorConfig: { planTier: "FREE" },
|
|
440
|
+
approvalHandler: (request) => this.promptApproval(request),
|
|
441
|
+
autoFixConfig: { maxRetries: 3, autoLint: true, autoBuild: true, autoTest: false },
|
|
442
|
+
});
|
|
443
|
+
// Listen to events for rendering
|
|
444
|
+
const spinner = this.renderer.thinking();
|
|
445
|
+
this.isStreaming = false;
|
|
446
|
+
loop.on("event", (event) => {
|
|
447
|
+
switch (event.kind) {
|
|
448
|
+
case "agent:thinking":
|
|
449
|
+
if (!this.isStreaming) {
|
|
450
|
+
spinner.update(event.content);
|
|
451
|
+
}
|
|
452
|
+
break;
|
|
453
|
+
case "agent:text_delta":
|
|
454
|
+
// Real-time streaming: stop spinner, write tokens directly
|
|
455
|
+
if (!this.isStreaming) {
|
|
456
|
+
spinner.stop();
|
|
457
|
+
this.isStreaming = true;
|
|
458
|
+
console.log(); // blank line before streaming output
|
|
459
|
+
}
|
|
460
|
+
this.renderer.streamToken(event.text);
|
|
461
|
+
break;
|
|
462
|
+
case "agent:tool_call":
|
|
463
|
+
if (this.isStreaming) {
|
|
464
|
+
this.renderer.endStream();
|
|
465
|
+
this.isStreaming = false;
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
spinner.stop();
|
|
469
|
+
}
|
|
470
|
+
this.renderer.toolCall(event.tool, typeof event.input === "string"
|
|
471
|
+
? event.input.slice(0, 100)
|
|
472
|
+
: JSON.stringify(event.input, null, 0).slice(0, 100));
|
|
473
|
+
break;
|
|
474
|
+
case "agent:tool_result":
|
|
475
|
+
this.renderer.toolResult(event.output);
|
|
476
|
+
break;
|
|
477
|
+
case "agent:file_change":
|
|
478
|
+
// Track changed files for /undo and /diff
|
|
479
|
+
if (!this.changedFiles.includes(event.path)) {
|
|
480
|
+
this.changedFiles.push(event.path);
|
|
481
|
+
}
|
|
482
|
+
break;
|
|
483
|
+
case "agent:error":
|
|
484
|
+
if (this.isStreaming) {
|
|
485
|
+
this.renderer.endStream();
|
|
486
|
+
this.isStreaming = false;
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
spinner.stop();
|
|
490
|
+
}
|
|
491
|
+
this.renderer.error(event.message);
|
|
492
|
+
break;
|
|
493
|
+
case "agent:completed": {
|
|
494
|
+
const wasStreaming = this.isStreaming;
|
|
495
|
+
if (this.isStreaming) {
|
|
496
|
+
this.renderer.endStream();
|
|
497
|
+
this.isStreaming = false;
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
spinner.stop();
|
|
501
|
+
}
|
|
502
|
+
if (!wasStreaming) {
|
|
503
|
+
console.log();
|
|
504
|
+
}
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
case "agent:approval_needed":
|
|
508
|
+
if (this.isStreaming) {
|
|
509
|
+
this.renderer.endStream();
|
|
510
|
+
this.isStreaming = false;
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
spinner.stop();
|
|
514
|
+
}
|
|
515
|
+
this.renderer.warn(`Approval required: ${event.action.description} [${event.action.risk}]`);
|
|
516
|
+
break;
|
|
517
|
+
case "agent:token_usage":
|
|
518
|
+
// Silent tracking — could display in /session later
|
|
519
|
+
break;
|
|
520
|
+
default:
|
|
521
|
+
break;
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
try {
|
|
525
|
+
const result = await loop.run(message);
|
|
526
|
+
// Ensure spinner/stream is stopped
|
|
527
|
+
if (this.isStreaming) {
|
|
528
|
+
this.renderer.endStream();
|
|
529
|
+
this.isStreaming = false;
|
|
530
|
+
}
|
|
531
|
+
spinner.stop();
|
|
532
|
+
// Handle non-completed results
|
|
533
|
+
if (result.reason !== "GOAL_ACHIEVED") {
|
|
534
|
+
switch (result.reason) {
|
|
535
|
+
case "MAX_ITERATIONS":
|
|
536
|
+
this.renderer.warn(`Reached iteration limit: ${result.lastState}`);
|
|
537
|
+
break;
|
|
538
|
+
case "BUDGET_EXHAUSTED":
|
|
539
|
+
this.renderer.warn(`Token budget exhausted: ${result.tokensUsed} tokens used`);
|
|
540
|
+
break;
|
|
541
|
+
case "USER_CANCELLED":
|
|
542
|
+
this.renderer.info("Cancelled.");
|
|
543
|
+
break;
|
|
544
|
+
case "ERROR":
|
|
545
|
+
this.renderer.error(`Agent error: ${result.error}`);
|
|
546
|
+
break;
|
|
547
|
+
case "NEEDS_APPROVAL":
|
|
548
|
+
this.renderer.warn(`Approval needed: ${result.action.description}`);
|
|
549
|
+
break;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
// Save assistant response summary
|
|
553
|
+
const summary = result.reason === "GOAL_ACHIEVED"
|
|
554
|
+
? result.summary
|
|
555
|
+
: `[${result.reason}]`;
|
|
556
|
+
this.sessionManager.addMessage(this.session, "assistant", summary);
|
|
557
|
+
}
|
|
558
|
+
catch (err) {
|
|
559
|
+
if (this.isStreaming) {
|
|
560
|
+
this.renderer.endStream();
|
|
561
|
+
this.isStreaming = false;
|
|
562
|
+
}
|
|
563
|
+
spinner.stop();
|
|
564
|
+
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
565
|
+
this.renderer.error(`Unexpected error: ${errorMsg}`);
|
|
566
|
+
this.sessionManager.addMessage(this.session, "assistant", `[ERROR] ${errorMsg}`);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Prompt the user for approval of a dangerous action.
|
|
571
|
+
* Shows the action details and waits for Y/N/A input.
|
|
572
|
+
*
|
|
573
|
+
* @param request The approval request from ApprovalManager
|
|
574
|
+
* @returns 'approve', 'reject', or 'always_approve'
|
|
575
|
+
*/
|
|
576
|
+
async promptApproval(request) {
|
|
577
|
+
const riskColor = request.riskLevel === "critical"
|
|
578
|
+
? colors.red
|
|
579
|
+
: request.riskLevel === "high"
|
|
580
|
+
? colors.yellow
|
|
581
|
+
: colors.cyan;
|
|
582
|
+
console.log();
|
|
583
|
+
console.log(c(colors.bold + riskColor, ` [${request.riskLevel.toUpperCase()}] Approval Required`));
|
|
584
|
+
console.log(c(colors.dim, " " + "-".repeat(50)));
|
|
585
|
+
console.log(` ${c(colors.bold, "Tool:")} ${c(colors.yellow, request.toolName)}`);
|
|
586
|
+
console.log(` ${c(colors.bold, "Reason:")} ${request.reason}`);
|
|
587
|
+
if (request.diff) {
|
|
588
|
+
console.log(c(colors.dim, " Preview:"));
|
|
589
|
+
const diffLines = request.diff.split("\n").slice(0, 10);
|
|
590
|
+
for (const line of diffLines) {
|
|
591
|
+
const lineColor = line.startsWith("+")
|
|
592
|
+
? colors.green
|
|
593
|
+
: line.startsWith("-")
|
|
594
|
+
? colors.red
|
|
595
|
+
: colors.dim;
|
|
596
|
+
console.log(` ${c(colors.dim, "|")} ${c(lineColor, line)}`);
|
|
597
|
+
}
|
|
598
|
+
if (request.diff.split("\n").length > 10) {
|
|
599
|
+
console.log(c(colors.dim, " | ... (truncated)"));
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
console.log();
|
|
603
|
+
console.log(c(colors.dim, " [Y] Approve [N] Reject [A] Always approve this tool"));
|
|
604
|
+
return new Promise((resolve) => {
|
|
605
|
+
// Create a temporary readline interface for approval prompt
|
|
606
|
+
const approvalRl = readline.createInterface({
|
|
607
|
+
input: process.stdin,
|
|
608
|
+
output: process.stdout,
|
|
609
|
+
});
|
|
610
|
+
approvalRl.question(c(colors.yellow + colors.bold, " Approve? [Y/n/a] "), (answer) => {
|
|
611
|
+
approvalRl.close();
|
|
612
|
+
const trimmed = answer.trim().toLowerCase();
|
|
613
|
+
if (trimmed === "n" || trimmed === "no") {
|
|
614
|
+
this.renderer.info("Action rejected.");
|
|
615
|
+
resolve("reject");
|
|
616
|
+
}
|
|
617
|
+
else if (trimmed === "a" || trimmed === "always") {
|
|
618
|
+
this.renderer.success(`Always approving '${request.toolName}' for this session.`);
|
|
619
|
+
resolve("always_approve");
|
|
620
|
+
}
|
|
621
|
+
else {
|
|
622
|
+
this.renderer.success("Action approved.");
|
|
623
|
+
resolve("approve");
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
/** Stop the interactive session */
|
|
629
|
+
stop() {
|
|
630
|
+
this.isRunning = false;
|
|
631
|
+
if (this.rl) {
|
|
632
|
+
this.rl.close();
|
|
633
|
+
this.rl = null;
|
|
634
|
+
}
|
|
635
|
+
console.log(c(colors.dim, "\n Session saved. Run `yuan resume` to continue.\n"));
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
//# sourceMappingURL=interactive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactive.js","sourceRoot":"","sources":["../src/interactive.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAoB,MAAM,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,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