@vietor/easy-agent 0.5.1 → 0.5.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.
- package/README.md +1 -1
- package/dist/commands/dispatch.js +3 -2
- package/dist/main.js +1 -0
- package/dist/tui/app.js +5 -4
- package/dist/tui/todo-view.js +2 -2
- package/dist/util/session-store.js +4 -16
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -155,7 +155,7 @@ A status bar at the bottom shows the context token usage with a progress bar and
|
|
|
155
155
|
- **WebFetch** — fetch a URL as markdown or text.
|
|
156
156
|
- **AskUser** — ask the user a question and wait for their answer.
|
|
157
157
|
- **TodoWrite** — track multi-step work as a task list (pending / in_progress / completed), shown live as a panel in the TUI.
|
|
158
|
-
- **SubAgent** — delegate investigation (`explore`)
|
|
158
|
+
- **SubAgent** — delegate investigation (`explore`), implementation-planning (`plan`), or full-tool execution (`generic`) subtasks to a nested sub-agent.
|
|
159
159
|
|
|
160
160
|
### Slash commands
|
|
161
161
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { errorMessage } from "@vietor/easy-agent-core";
|
|
1
2
|
import { builtinCommands } from "./builtin.js";
|
|
2
3
|
const commands = new Map(builtinCommands.map((c) => [c.name, c]));
|
|
3
4
|
export async function executeCommand(name, session) {
|
|
@@ -8,7 +9,7 @@ export async function executeCommand(name, session) {
|
|
|
8
9
|
await cmd.execute(ctx);
|
|
9
10
|
}
|
|
10
11
|
catch (e) {
|
|
11
|
-
ctx.error(e
|
|
12
|
+
ctx.error(errorMessage(e));
|
|
12
13
|
}
|
|
13
14
|
return;
|
|
14
15
|
}
|
|
@@ -17,7 +18,7 @@ export async function executeCommand(name, session) {
|
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
20
|
catch (e) {
|
|
20
|
-
session.timelineError(e
|
|
21
|
+
session.timelineError(errorMessage(e));
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
24
|
session.timelineError(`unknown command: /${name}`);
|
package/dist/main.js
CHANGED
|
@@ -109,6 +109,7 @@ export async function main(argv = []) {
|
|
|
109
109
|
};
|
|
110
110
|
process.once("SIGINT", shutdown);
|
|
111
111
|
process.once("SIGTERM", shutdown);
|
|
112
|
+
process.stdout.write("[2J[H");
|
|
112
113
|
const app = startApp(session);
|
|
113
114
|
await app.waitUntilExit().finally(async () => {
|
|
114
115
|
session.dispose();
|
package/dist/tui/app.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
3
3
|
import { Box, render, Text, useApp, useInput, useWindowSize } from "ink";
|
|
4
|
+
import { createSessionRunState, errorMessage } from "@vietor/easy-agent-core";
|
|
4
5
|
import { executeCommand, commandSchemas } from "../commands/dispatch.js";
|
|
5
6
|
import { Markdown } from "./components/markdown.js";
|
|
6
7
|
import { TimelineView } from "./timeline-view.js";
|
|
@@ -34,7 +35,7 @@ export function App({ session }) {
|
|
|
34
35
|
const { exit } = useApp();
|
|
35
36
|
const { columns } = useWindowSize();
|
|
36
37
|
const view = useSyncExternalStore(session.subscribe, session.getSnapshot);
|
|
37
|
-
const [runState, setRunState] = useState(
|
|
38
|
+
const [runState, setRunState] = useState(createSessionRunState);
|
|
38
39
|
const streaming = useThrottledText(STREAM_FRAME_MS);
|
|
39
40
|
const reasoning = useThrottledText(STREAM_FRAME_MS);
|
|
40
41
|
const [showReasoning, setShowReasoning] = useState(false);
|
|
@@ -56,6 +57,7 @@ export function App({ session }) {
|
|
|
56
57
|
streaming.reset();
|
|
57
58
|
break;
|
|
58
59
|
case "retry":
|
|
60
|
+
case "interrupted":
|
|
59
61
|
streaming.reset();
|
|
60
62
|
break;
|
|
61
63
|
case "state":
|
|
@@ -95,7 +97,7 @@ export function App({ session }) {
|
|
|
95
97
|
await session.startPrompt(text);
|
|
96
98
|
}
|
|
97
99
|
catch (e) {
|
|
98
|
-
session.timelineError(e
|
|
100
|
+
session.timelineError(errorMessage(e));
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
103
|
let runningView = null;
|
|
@@ -105,7 +107,7 @@ export function App({ session }) {
|
|
|
105
107
|
}
|
|
106
108
|
else {
|
|
107
109
|
const spinnerLabel = streaming.text ? "replying" : "working";
|
|
108
|
-
runningView = (_jsxs(_Fragment, { children: [reasoning.text ? renderReasoning(reasoning.text, showReasoning) : null, streaming.text ? (_jsx(Box, { marginTop: 1, paddingLeft: 1, paddingRight: 1,
|
|
110
|
+
runningView = (_jsxs(_Fragment, { children: [reasoning.text ? renderReasoning(reasoning.text, showReasoning) : null, streaming.text ? (_jsx(Box, { marginTop: 1, paddingLeft: 1, paddingRight: 1, children: _jsx(Markdown, { children: streaming.text }) })) : null, _jsx(Box, { marginTop: 1, paddingLeft: 1, children: _jsx(Spinner, { label: spinnerLabel, thinkingElapsed: runState.thinkingElapsed, replyElapsed: runState.replyElapsed, inputTokens: runState.inputTokens, outputTokens: runState.outputTokens }) })] }));
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
return (_jsxs(Box, { width: columns, flexDirection: "column", children: [_jsx(AppHeader, { cwd: session.cwd, model: session.model, reasoningEffort: session.reasoningEffort }), view.timeline.length > 0 ? (_jsx(Box, { flexDirection: "column", paddingLeft: 1, paddingRight: 1, children: view.timeline.map((entry, i) => (_jsx(TimelineView, { entry: entry }, i))) })) : null, runningView, view.todos.length > 0 ? _jsx(TodoView, { todos: view.todos }) : null, !runState.running ? (_jsx(PromptOrCommandInput, { commands: allCmds, onCommand: handleCommand, onPrompt: handlePrompt })) : null, _jsx(StatusBar, { contextTokens: session.contextTokens, contextLimit: session.compactThreshold, running: runState.running, questionPending: !!pendingQuestion, reasoningAvailable: !!reasoning.text })] }));
|
|
@@ -120,6 +122,5 @@ function renderReasoning(text, expanded) {
|
|
|
120
122
|
return (_jsx(Box, { marginTop: 1, paddingLeft: 1, children: _jsxs(Text, { dimColor: true, children: ["\u250A ", firstLine, extra, " (t to expand)"] }) }));
|
|
121
123
|
}
|
|
122
124
|
export function startApp(session) {
|
|
123
|
-
process.stdout.write("[2J[H");
|
|
124
125
|
return render(_jsx(App, { session: session }), { exitOnCtrlC: false, incrementalRendering: true });
|
|
125
126
|
}
|
package/dist/tui/todo-view.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { memo } from "react";
|
|
3
3
|
import { Box, Text } from "ink";
|
|
4
|
-
const
|
|
4
|
+
const GLYPHS = {
|
|
5
5
|
pending: "○",
|
|
6
6
|
in_progress: "◐",
|
|
7
7
|
completed: "✓",
|
|
@@ -14,5 +14,5 @@ const COLORS = {
|
|
|
14
14
|
export const TodoView = memo(function TodoView({ todos }) {
|
|
15
15
|
const done = todos.filter((t) => t.status === "completed").length;
|
|
16
16
|
const headerColor = done === todos.length ? "green" : "cyan";
|
|
17
|
-
return (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, paddingRight: 1, children: [_jsx(Box, { borderStyle: "single", borderTop: true, borderBottom: false, borderLeft: false, borderRight: false, borderColor: "gray" }), _jsx(Text, { color: headerColor, children: `Tasks [${done}/${todos.length}]` }), todos.map((t, i) => (_jsx(Text, { color: COLORS[t.status], strikethrough: t.status === "completed", children: `${
|
|
17
|
+
return (_jsxs(Box, { flexDirection: "column", paddingLeft: 1, paddingRight: 1, children: [_jsx(Box, { borderStyle: "single", borderTop: true, borderBottom: false, borderLeft: false, borderRight: false, borderColor: "gray" }), _jsx(Text, { color: headerColor, children: `Tasks [${done}/${todos.length}]` }), todos.map((t, i) => (_jsx(Text, { color: COLORS[t.status], strikethrough: t.status === "completed", children: `${GLYPHS[t.status]} ${t.content}` }, i)))] }));
|
|
18
18
|
});
|
|
@@ -2,8 +2,7 @@ import { appendFile, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
-
import { ellipsisText } from "@vietor/easy-agent-core";
|
|
6
|
-
const MAX_PREVIEW_LEN = 75;
|
|
5
|
+
import { ellipsisText, MAX_PREVIEW_LEN } from "@vietor/easy-agent-core";
|
|
7
6
|
function encodeCwd(cwd) {
|
|
8
7
|
return cwd.replace(/[\/\\:]/g, "-");
|
|
9
8
|
}
|
|
@@ -96,19 +95,8 @@ export class FileSessionPersistence {
|
|
|
96
95
|
return ellipsisText(first, MAX_PREVIEW_LEN);
|
|
97
96
|
}
|
|
98
97
|
readFirstUser(path) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
let r;
|
|
103
|
-
try {
|
|
104
|
-
r = JSON.parse(line);
|
|
105
|
-
}
|
|
106
|
-
catch {
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
if (r.t === "message" && r.m && r.m.role === "user" && typeof r.m.content === "string")
|
|
110
|
-
return r.m.content;
|
|
111
|
-
}
|
|
112
|
-
return undefined;
|
|
98
|
+
const first = parseJsonLines(readFileSync(path, "utf-8"))
|
|
99
|
+
.find((r) => r.t === "message" && r.m && r.m.role === "user" && typeof r.m.content === "string");
|
|
100
|
+
return first?.m?.content;
|
|
113
101
|
}
|
|
114
102
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vietor/easy-agent",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"react": "^19.2.8",
|
|
24
24
|
"string-width": "^8.2.2",
|
|
25
25
|
"zod": "^4.4.3",
|
|
26
|
-
"@vietor/easy-agent-core": "0.5.
|
|
26
|
+
"@vietor/easy-agent-core": "0.5.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^22.20.1",
|