@prestyj/cli 5.30.2 → 5.31.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/dist/app-sidecar/app-settings.d.ts +6 -2
- package/dist/app-sidecar/app-settings.js +39 -20
- package/dist/app-sidecar/app-settings.js.map +1 -1
- package/dist/app-sidecar/git-target.d.ts +17 -0
- package/dist/app-sidecar/git-target.js +31 -0
- package/dist/app-sidecar/git-target.js.map +1 -0
- package/dist/app-sidecar/goal-routes.d.ts +6 -0
- package/dist/app-sidecar/goal-routes.js +360 -0
- package/dist/app-sidecar/goal-routes.js.map +1 -0
- package/dist/app-sidecar/history-routes.d.ts +13 -0
- package/dist/app-sidecar/history-routes.js +37 -27
- package/dist/app-sidecar/history-routes.js.map +1 -1
- package/dist/app-sidecar/mcp-routes.js +1 -2
- package/dist/app-sidecar/mcp-routes.js.map +1 -1
- package/dist/app-sidecar/prompt-routes.js +1 -2
- package/dist/app-sidecar/prompt-routes.js.map +1 -1
- package/dist/app-sidecar/route-context.d.ts +12 -0
- package/dist/app-sidecar/run-control-routes.js +2 -1
- package/dist/app-sidecar/run-control-routes.js.map +1 -1
- package/dist/app-sidecar/session-routes.js +41 -0
- package/dist/app-sidecar/session-routes.js.map +1 -1
- package/dist/app-sidecar/session-types.d.ts +2 -0
- package/dist/app-sidecar/workspace-routes.js +13 -95
- package/dist/app-sidecar/workspace-routes.js.map +1 -1
- package/dist/app-sidecar.js +219 -67
- package/dist/app-sidecar.js.map +1 -1
- package/dist/cli/shared.js +1 -1
- package/dist/cli/shared.js.map +1 -1
- package/dist/core/acceptance-checks.js +17 -4
- package/dist/core/acceptance-checks.js.map +1 -1
- package/dist/core/agent-notifications.d.ts +1 -1
- package/dist/core/agent-session.d.ts +90 -5
- package/dist/core/agent-session.js +185 -63
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/ask-user.d.ts +11 -0
- package/dist/core/ask-user.js +6 -1
- package/dist/core/ask-user.js.map +1 -1
- package/dist/core/auth-providers.d.ts +2 -80
- package/dist/core/auth-providers.js +4 -183
- package/dist/core/auth-providers.js.map +1 -1
- package/dist/core/cache-diagnostics.d.ts +1 -1
- package/dist/core/cache-diagnostics.js +2 -1
- package/dist/core/cache-diagnostics.js.map +1 -1
- package/dist/core/compaction/tool-result-pruner.d.ts +10 -0
- package/dist/core/compaction/tool-result-pruner.js +12 -0
- package/dist/core/compaction/tool-result-pruner.js.map +1 -1
- package/dist/core/context-files.d.ts +8 -0
- package/dist/core/context-files.js +46 -0
- package/dist/core/context-files.js.map +1 -0
- package/dist/core/custom-commands.d.ts +6 -0
- package/dist/core/custom-commands.js +17 -0
- package/dist/core/custom-commands.js.map +1 -1
- package/dist/core/env-delta.d.ts +9 -1
- package/dist/core/env-delta.js +20 -0
- package/dist/core/env-delta.js.map +1 -1
- package/dist/core/goal-summary.d.ts +32 -0
- package/dist/core/goal-summary.js +104 -0
- package/dist/core/goal-summary.js.map +1 -0
- package/dist/core/goals-store.d.ts +208 -0
- package/dist/core/goals-store.js +521 -0
- package/dist/core/goals-store.js.map +1 -0
- package/dist/core/local-endpoint-store.js +15 -11
- package/dist/core/local-endpoint-store.js.map +1 -1
- package/dist/core/plan-handoff.d.ts +8 -0
- package/dist/core/plan-handoff.js +11 -0
- package/dist/core/plan-handoff.js.map +1 -1
- package/dist/core/project-discovery.d.ts +7 -0
- package/dist/core/project-discovery.js +9 -3
- package/dist/core/project-discovery.js.map +1 -1
- package/dist/core/radio.d.ts +2 -3
- package/dist/core/radio.js.map +1 -1
- package/dist/core/session-manager.d.ts +7 -1
- package/dist/core/session-manager.js +17 -7
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-storage.d.ts +3 -0
- package/dist/core/session-storage.js +8 -2
- package/dist/core/session-storage.js.map +1 -1
- package/dist/core/steroids.d.ts +8 -0
- package/dist/core/steroids.js +19 -3
- package/dist/core/steroids.js.map +1 -1
- package/dist/core/subagent-manager.d.ts +51 -0
- package/dist/core/subagent-manager.js +103 -16
- package/dist/core/subagent-manager.js.map +1 -1
- package/dist/core/subagent-store.js +2 -1
- package/dist/core/subagent-store.js.map +1 -1
- package/dist/goals-agent/goal-team.d.ts +2 -0
- package/dist/goals-agent/goal-team.js +83 -0
- package/dist/goals-agent/goal-team.js.map +1 -0
- package/dist/goals-agent/goals-agent.d.ts +90 -0
- package/dist/goals-agent/goals-agent.js +246 -0
- package/dist/goals-agent/goals-agent.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interactive.js +4 -3
- package/dist/interactive.js.map +1 -1
- package/dist/modes/acp-autopilot.d.ts +27 -0
- package/dist/modes/acp-autopilot.js +54 -0
- package/dist/modes/acp-autopilot.js.map +1 -0
- package/dist/modes/acp-goals.d.ts +48 -0
- package/dist/modes/acp-goals.js +103 -0
- package/dist/modes/acp-goals.js.map +1 -0
- package/dist/modes/acp-mode.d.ts +128 -3
- package/dist/modes/acp-mode.js +1082 -52
- package/dist/modes/acp-mode.js.map +1 -1
- package/dist/modes/subagent-worker-mode.d.ts +14 -0
- package/dist/modes/subagent-worker-mode.js +32 -1
- package/dist/modes/subagent-worker-mode.js.map +1 -1
- package/dist/system-prompt.d.ts +8 -0
- package/dist/system-prompt.js +21 -9
- package/dist/system-prompt.js.map +1 -1
- package/dist/tools/bash-read-evidence.d.ts +13 -0
- package/dist/tools/bash-read-evidence.js +48 -1
- package/dist/tools/bash-read-evidence.js.map +1 -1
- package/dist/tools/grep-scan.d.ts +96 -0
- package/dist/tools/grep-scan.js +283 -0
- package/dist/tools/grep-scan.js.map +1 -0
- package/dist/tools/grep.d.ts +10 -0
- package/dist/tools/grep.js +418 -10
- package/dist/tools/grep.js.map +1 -1
- package/dist/tools/index.d.ts +7 -1
- package/dist/tools/index.js +10 -2
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/read-tracker.d.ts +6 -12
- package/dist/tools/read-tracker.js +21 -36
- package/dist/tools/read-tracker.js.map +1 -1
- package/dist/tools/read.js +2 -2
- package/dist/tools/read.js.map +1 -1
- package/dist/tools/subagent-control.js +22 -3
- package/dist/tools/subagent-control.js.map +1 -1
- package/dist/tools/write.js +110 -8
- package/dist/tools/write.js.map +1 -1
- package/dist/ui/components/ActivityIndicator.d.ts +5 -5
- package/dist/ui/components/InputArea.d.ts +2 -2
- package/dist/ui/components/InputArea.js +3 -3
- package/dist/ui/components/InputArea.js.map +1 -1
- package/dist/ui/components/ToolExecution.d.ts +2 -2
- package/dist/ui/hooks/useContextCompaction.js +38 -31
- package/dist/ui/hooks/useContextCompaction.js.map +1 -1
- package/dist/utils/format.d.ts +0 -4
- package/dist/utils/format.js +0 -7
- package/dist/utils/format.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { AgentSession } from "../core/agent-session.js";
|
|
2
|
+
import { readGoalMemory, renderGoalPrompt, } from "../core/goals-store.js";
|
|
3
|
+
import { collectProjectContext } from "../system-prompt.js";
|
|
4
|
+
import { getModel } from "../core/model-registry.js";
|
|
5
|
+
import { GOAL_TEAM } from "./goal-team.js";
|
|
6
|
+
/**
|
|
7
|
+
* Little Nolan's faces in the Workers view's dialogue box. EZ Goals picks one
|
|
8
|
+
* for the spoken line it ends a message with (`[nolan:face] …`). Must match
|
|
9
|
+
* KEN_FACES in ezcoder-app/src/goal-nolan-talk.ts, which reads the line (an unknown
|
|
10
|
+
* face falls back to neutral there).
|
|
11
|
+
*/
|
|
12
|
+
export const KEN_FACES = [
|
|
13
|
+
"neutral",
|
|
14
|
+
"happy",
|
|
15
|
+
"excited",
|
|
16
|
+
"thinking",
|
|
17
|
+
"focused",
|
|
18
|
+
"surprised",
|
|
19
|
+
"worried",
|
|
20
|
+
"sad",
|
|
21
|
+
"proud",
|
|
22
|
+
"wink",
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* EZ Goals: the orchestrator a Goal window talks to. It is its own agent, not
|
|
26
|
+
* EZ Coder with a note attached: its identity and the goal brief form its
|
|
27
|
+
* system prompt, it has no plan mode (it plans in the conversation), and its
|
|
28
|
+
* prompt cache is keyed apart from coding sessions.
|
|
29
|
+
*/
|
|
30
|
+
export const GOALS_SYSTEM_PROMPT = `You are EZ Goals, inside EZ Coder. The user hands you a goal and may walk away until it's done, and you own it end to end: you understand it, agree the approach with the user up front, get the work done (yourself, or with a team of workers when the work splits into big independent parts), and keep the user informed until the goal is met.
|
|
31
|
+
|
|
32
|
+
## How you work
|
|
33
|
+
|
|
34
|
+
- One goal, one ongoing conversation. Treat earlier messages as shared history, not as a fresh request.
|
|
35
|
+
- Before the goal starts you only read (read, ls, find, web search) and ask; editing, writing, running commands and starting workers open once the user starts it.
|
|
36
|
+
- Do the work yourself by default: you already know the goal and have read what matters, while a worker starts cold and re-reads everything. That covers anything connected (one project, one document, one report), anything you can finish in a few minutes, and research you can do with a few searches. Never start a single worker for work you could do yourself.
|
|
37
|
+
- Start workers only for parts that are big and independent of each other, two or more at once so they run side by side: separate projects or repos, separate research topics that each need many searches, separate large documents. Do any small or connected part yourself while they run.
|
|
38
|
+
- When you do the work yourself, work like your team does: change files in place (never branch, commit or push), never change the machine itself (no global installs or logins), don't read a file back after editing it, prove it with the narrowest check (a test, a build, the command itself) run as a plain command (chain checks only with &&: a check behind ; or || or in a loop can hide a failure, so it doesn't count and has to be run again), and give the URL of every source you rely on in research.
|
|
39
|
+
- Your team (spawn_agent's agent): builder makes changes (writes, edits, runs commands); scout looks around the attached folders without changing anything; researcher finds things out on the web, with sources; checker checks a finished task and fixes what's wrong in the same pass. Workers change files in place for the user to review; they never branch or commit.
|
|
40
|
+
- Size the team to the work: every extra worker costs a fresh start and re-reads, so split only into parts that are independent and each substantial, and start those workers together in one spawn_agent call. Give each worker everything its part needs (its tests, its section of the docs, its piece of a shared file) rather than saving that for a final worker after the rest: a final step waits for every other worker and then starts from scratch. Keep a final worker only for work that truly needs all the parts done, like a write-up drawing on all the research. Brief each worker fully, as it sees nothing of this conversation: the goal, the exact files or area, constraints, and what to report back. Set each worker's cwd to the attached folder it mostly works in; every worker can also reach the goal's other attached folders. List the files a worker needs that you've already read in its context_files, so it starts with their contents instead of reading them again; name any others by full path in the brief. Attached files are for reading (to change one, the user attaches its folder). Keep briefs to what to do and what done looks like, at the size the user asked for: never raise a target or widen the scope in a brief (a minimum stays the minimum, not a floor to aim past; a "cover the states" answer is not a 50-state table), since every extra is paid for in time and tokens, and a fix round should only close a real gap against what was asked. Workers already know to stop and report a blocker rather than guess.
|
|
41
|
+
- Handle each worker the moment it finishes, not when they all have. Wait with wait_agent using condition "any" (never "all" while there is other work to hand out): check that worker's report, give it its next task with followup_task or start a new worker, then wait again for the rest. Steer a running worker with send_message, and stop one that has gone off track with interrupt_agent.
|
|
42
|
+
- Check what a worker reports before you rely on it. When its checks passed and the report is clear, rely on it; read its output yourself only when something wasn't verified or you need its content for your summary. Send a checker only for important work you can't check by reading. When a task has a check that proves it (a test suite, a build, a command), name it in spawn_agent's checks (command_passed, written as the worker runs it in its cwd, like \`npm test\`; plus file_exists or file_changed for what it makes), so it's verified when the worker finishes; never send a checker just to re-run a command the builder already ran. A checker fixes what it finds itself, so never send a builder after a checker to fix its findings.
|
|
43
|
+
- Keep rounds few: each task gets at most one fix round (a followup_task to the same worker, which keeps what it learned, or one checker). If it still isn't right after that, stop and tell the user what's wrong rather than going back and forth.
|
|
44
|
+
- When a worker fails, times out or reports it couldn't finish, find out why from its report. If it was a passing error or a weak brief, retry once: followup_task on the same worker if it stopped normally (it keeps what it learned), or a fresh worker with a sharper brief if it crashed or timed out (a crashed worker is closed and can't take a follow-up). If it fails again, or only the user can fix the cause, stop that piece of work and tell the user plainly what failed and what you need. Never drop failed work quietly or count it as done.
|
|
45
|
+
- When a worker reports a blocker, settle it yourself if the goal and this conversation already answer it, and send the answer with followup_task. Otherwise ask the user with ask_user, and keep the other workers going while you wait for their answer.
|
|
46
|
+
- Work that needs the user's own accounts or machine (a login, credentials, installing software system-wide, payments) belongs in the briefing, before the start: find out then what's installed and whether they're signed in, by asking. If after the start it turns out to be missing, stop that piece of work and tell the user what they need to do; never have a worker install or sign in on their behalf.
|
|
47
|
+
- Once the goal has started, the user may be away: ask them only when work can't go on without a decision only they can make. Settle small follow-on choices yourself (tidying, naming, an obvious next step inside the goal) and say what you chose in your summary; offer optional extras in the summary instead of asking.
|
|
48
|
+
- When the user messages you while workers are running, answer them first in a short message (where each piece of work stands), then go back to waiting. Never leave a message unanswered until the end.
|
|
49
|
+
- Before your final summary, collect every finished worker's report (wait_agent with their agent_ids), so you write the summary once, complete.
|
|
50
|
+
- Ask the user only for what you cannot look up.
|
|
51
|
+
- Be exact about status. Never say something is done, fixed or verified unless you checked it, and say plainly when something could not be checked.
|
|
52
|
+
- Keep the user in the loop without flooding them: short updates when something finishes, needs a decision, or is blocked.
|
|
53
|
+
|
|
54
|
+
## Talking to the user
|
|
55
|
+
|
|
56
|
+
Plain words, short paragraphs, no jargon the user did not use. Lead with the answer or the outcome. Use ask_user for real decisions, with your recommendation marked; never ask in prose what a clickable choice can answer.
|
|
57
|
+
|
|
58
|
+
## Your line on the farm
|
|
59
|
+
|
|
60
|
+
Once the goal has started, the user often watches the Workers view instead of the chat, where you are little Nolan on a farm with a dialogue box that pops up now and then. Short progress notes between tool calls are said there as they are, so keep those to one plain sentence or two. After the start, the message that ends your turn (your summary, a blocker, a question) always ends with one spoken line for it, as its very last line and nowhere else, in exactly this form:
|
|
61
|
+
|
|
62
|
+
[nolan:face] what you'd say out loud
|
|
63
|
+
|
|
64
|
+
- face is one of: ${KEN_FACES.join(", ")}. Match the moment: focused while working, happy when a part is done, proud when a result beats the target, surprised when you find something, worried about a risk, sad when something failed, excited when the goal is reached, thinking when weighing a choice, wink for a tip, neutral otherwise.
|
|
65
|
+
- The line is one or two short sentences (under 120 characters) of plain speech, the gist for someone glancing over: no Markdown, tables, code, file paths or links. For example: [nolan:happy] Images done. Mobile load is down to 1.4 seconds.
|
|
66
|
+
- The chat hides this line, so never refer to it, and keep everything the user needs in the message itself. Skip it before the start.`;
|
|
67
|
+
/** Agent tools EZ Goals always has, instead of finding them via tool_search. */
|
|
68
|
+
export const GOALS_CORE_TOOLS = [
|
|
69
|
+
"spawn_agent",
|
|
70
|
+
"wait_agent",
|
|
71
|
+
"send_message",
|
|
72
|
+
"followup_task",
|
|
73
|
+
"list_agents",
|
|
74
|
+
"interrupt_agent",
|
|
75
|
+
"web_search",
|
|
76
|
+
"web_fetch",
|
|
77
|
+
// Reading the attached context without a shell.
|
|
78
|
+
"find",
|
|
79
|
+
"ls",
|
|
80
|
+
];
|
|
81
|
+
/**
|
|
82
|
+
* The model EZ Goals' workers ("critters") run on, from the goal's pick. A
|
|
83
|
+
* pick whose model is gone from the registry, or now belongs to a different
|
|
84
|
+
* provider, is ignored, so workers fall back to EZ Goals' own model.
|
|
85
|
+
*/
|
|
86
|
+
export function goalCritterPick(record) {
|
|
87
|
+
const pick = record?.critterModel;
|
|
88
|
+
if (!pick)
|
|
89
|
+
return undefined;
|
|
90
|
+
const model = getModel(pick.model);
|
|
91
|
+
if (!model || model.provider !== pick.provider)
|
|
92
|
+
return undefined;
|
|
93
|
+
return { provider: model.provider, model: model.id };
|
|
94
|
+
}
|
|
95
|
+
/** EZ Goals' full prompt body: identity first, then this goal's brief. */
|
|
96
|
+
export function buildGoalsAgentPrompt(goal, extras = {}) {
|
|
97
|
+
return `${GOALS_SYSTEM_PROMPT}\n\n${renderGoalPrompt(goal.dir, goal.record, extras)}`;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Read what EZ Goals' brief carries besides the goal, once per session: its
|
|
101
|
+
* memory, and each attached folder's instruction files (AGENTS.md, CLAUDE.md…).
|
|
102
|
+
* EZ Goals' own cwd is the goal folder, so without this it never saw the rules
|
|
103
|
+
* of the projects it works in. A folder that can't be read just has no rules.
|
|
104
|
+
*/
|
|
105
|
+
export async function loadGoalBriefExtras(goal) {
|
|
106
|
+
const folders = goal.record.context.filter((item) => item.kind === "folder");
|
|
107
|
+
const [memory, projectRules] = await Promise.all([
|
|
108
|
+
readGoalMemory(goal.dir),
|
|
109
|
+
Promise.all(folders.map(async (item) => ({
|
|
110
|
+
folder: item.path,
|
|
111
|
+
rules: await collectProjectContext(item.path).catch(() => []),
|
|
112
|
+
}))),
|
|
113
|
+
]);
|
|
114
|
+
return { memory, projectRules };
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Tools that do or start work: held until the user starts the goal, then
|
|
118
|
+
* EZ Goals' own. It does small and connected work itself (a worker starts
|
|
119
|
+
* cold and re-reads everything; live runs showed one session beating a
|
|
120
|
+
* single worker on every such goal), and starts workers for big independent
|
|
121
|
+
* parts. Same tool schemas either way, so the cached tool block never changes.
|
|
122
|
+
*/
|
|
123
|
+
export const GOALS_START_TOOLS = new Set([
|
|
124
|
+
"edit",
|
|
125
|
+
"write",
|
|
126
|
+
"bash",
|
|
127
|
+
"spawn_agent",
|
|
128
|
+
"followup_task",
|
|
129
|
+
]);
|
|
130
|
+
/**
|
|
131
|
+
* Tools EZ Goals never has: UI component adoption and image generation (not
|
|
132
|
+
* part of a goal's work), and the one-shot \`subagent\`, which always runs in
|
|
133
|
+
* EZ Goals' own goal folder and can't be pointed at an attached folder;
|
|
134
|
+
* spawn_agent is the only way it starts workers.
|
|
135
|
+
*/
|
|
136
|
+
export const GOALS_WITHOUT_TOOLS = ["ui_adopt", "generate_image", "subagent"];
|
|
137
|
+
/** What editing, running or starting work returns during the briefing. */
|
|
138
|
+
export const BRIEFING_ERROR = "Not yet: the goal hasn't started. During the briefing you only read (read, ls, find, web search) and ask. Editing, running commands and starting workers open once the user starts the goal. If the user has told you to go ahead, ask the start question now with ask_user (the goal starts when they pick it); never begin the work before that.";
|
|
139
|
+
/** Error text ask_user returns while EZ Goals has not spoken yet. */
|
|
140
|
+
export const GREET_FIRST_ERROR = "Not yet: write to the user first. Greet them and say the goal back in your own words as a normal message, then ask.";
|
|
141
|
+
function hasAssistantText(messages) {
|
|
142
|
+
return messages.some((m) => m.role === "assistant" &&
|
|
143
|
+
(typeof m.content === "string"
|
|
144
|
+
? m.content.trim().length > 0
|
|
145
|
+
: Array.isArray(m.content) &&
|
|
146
|
+
m.content.some((part) => typeof part === "object" &&
|
|
147
|
+
part !== null &&
|
|
148
|
+
part.type === "text" &&
|
|
149
|
+
typeof part.text === "string" &&
|
|
150
|
+
part.text.trim().length > 0)));
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Hold ask_user until EZ Goals has written something to the user. A question
|
|
154
|
+
* card as the very first thing in a new goal reads as an interrogation, and a
|
|
155
|
+
* card shown before the turn's text would sit above the greeting. Once there
|
|
156
|
+
* is any assistant text (this run or an earlier one), the tool is untouched.
|
|
157
|
+
*/
|
|
158
|
+
/**
|
|
159
|
+
* Added to the answer that starts the goal. The kickoff told EZ Goals not to
|
|
160
|
+
* start work in its first reply, and the start question usually rides on that
|
|
161
|
+
* same reply's card: without this it stopped right after the user started the
|
|
162
|
+
* goal (live run, "Add a blog"), and the goal sat idle.
|
|
163
|
+
*/
|
|
164
|
+
export const GOAL_STARTED_NOTE = "\n\nThe goal has started. Start the work now, in this reply: do it yourself, or start workers for its big independent parts.";
|
|
165
|
+
/**
|
|
166
|
+
* EZ Goals' ask_user: never before it has greeted the user, and the answer
|
|
167
|
+
* that starts the goal comes back with GOAL_STARTED_NOTE.
|
|
168
|
+
*/
|
|
169
|
+
function goalAskUser(tools, hasSpoken, isActive) {
|
|
170
|
+
return tools.map((tool) => tool.name !== "ask_user"
|
|
171
|
+
? tool
|
|
172
|
+
: {
|
|
173
|
+
...tool,
|
|
174
|
+
execute: async (args, context) => {
|
|
175
|
+
if (!hasSpoken())
|
|
176
|
+
throw new Error(GREET_FIRST_ERROR);
|
|
177
|
+
const wasActive = isActive();
|
|
178
|
+
const result = await tool.execute(args, context);
|
|
179
|
+
if (wasActive || !isActive())
|
|
180
|
+
return result;
|
|
181
|
+
if (typeof result === "string")
|
|
182
|
+
return result + GOAL_STARTED_NOTE;
|
|
183
|
+
const { content } = result;
|
|
184
|
+
return {
|
|
185
|
+
...result,
|
|
186
|
+
content: typeof content === "string"
|
|
187
|
+
? content + GOAL_STARTED_NOTE
|
|
188
|
+
: [...content, { type: "text", text: GOAL_STARTED_NOTE.trim() }],
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Create a EZ Goals session. Sessions are stored like coding sessions, keyed by
|
|
195
|
+
* the goal folder, so the goal list and goal deletion find them there.
|
|
196
|
+
*/
|
|
197
|
+
export function createGoalsAgentSession(options) {
|
|
198
|
+
const { goal, extras, additionalTools = [], isActive = () => false, ...sessionOptions } = options;
|
|
199
|
+
let spokeThisSession = false;
|
|
200
|
+
// `getMessages()` is the conversation as of the last finished run, so text
|
|
201
|
+
// streamed in the current run is tracked live alongside it.
|
|
202
|
+
const hasSpoken = () => spokeThisSession || hasAssistantText(session.getMessages());
|
|
203
|
+
const session = new AgentSession({
|
|
204
|
+
...sessionOptions,
|
|
205
|
+
additionalTools: goalAskUser(additionalTools, hasSpoken, isActive),
|
|
206
|
+
// The goal is static for a session, so its brief belongs in the cached
|
|
207
|
+
// prefix rather than a per-run tail.
|
|
208
|
+
agentPrompt: buildGoalsAgentPrompt(goal, extras),
|
|
209
|
+
// Talks to the user directly, so no sub-agent return contract.
|
|
210
|
+
agentRole: "primary",
|
|
211
|
+
// The goal folder holds notes, not a codebase; attached folders are added
|
|
212
|
+
// as workspace roots and read on demand.
|
|
213
|
+
agentContext: "none",
|
|
214
|
+
promptCacheKeyPrefix: "gggoals",
|
|
215
|
+
// Orchestrating is the job: bringing in workers, steering them and
|
|
216
|
+
// waiting on them must not need a tool_search first.
|
|
217
|
+
coreTools: GOALS_CORE_TOOLS,
|
|
218
|
+
withoutTools: GOALS_WITHOUT_TOOLS,
|
|
219
|
+
// Its own team (goal-team.ts), never EZ Coder's or the user's agents,
|
|
220
|
+
// and each worker can reach every attached folder, not only its own.
|
|
221
|
+
subAgents: GOAL_TEAM,
|
|
222
|
+
shareRootsWithSubAgents: true,
|
|
223
|
+
// A worker started without naming an agent is still a team member.
|
|
224
|
+
defaultSubAgent: "builder",
|
|
225
|
+
// The team only starts once the user starts the goal. Same tool schemas
|
|
226
|
+
// either way, so the cached tool block never changes.
|
|
227
|
+
wrapTool: (tool) => {
|
|
228
|
+
if (!GOALS_START_TOOLS.has(tool.name))
|
|
229
|
+
return tool;
|
|
230
|
+
return {
|
|
231
|
+
...tool,
|
|
232
|
+
execute: async (args, context) => {
|
|
233
|
+
if (!isActive())
|
|
234
|
+
throw new Error(BRIEFING_ERROR);
|
|
235
|
+
return tool.execute(args, context);
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
session.eventBus.on("text_delta", ({ text }) => {
|
|
241
|
+
if (text.trim())
|
|
242
|
+
spokeThisSession = true;
|
|
243
|
+
});
|
|
244
|
+
return session;
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=goals-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"goals-agent.js","sourceRoot":"","sources":["../../src/goals-agent/goals-agent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAA4B,MAAM,0BAA0B,CAAC;AAClF,OAAO,EACL,cAAc,EACd,gBAAgB,GAGjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,SAAS;IACT,OAAO;IACP,SAAS;IACT,UAAU;IACV,SAAS;IACT,WAAW;IACX,SAAS;IACT,KAAK;IACL,OAAO;IACP,MAAM;CACE,CAAC;AAEX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAA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,EAAE;wBAAE,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;oBACjD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBACrC,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;QAC7C,IAAI,IAAI,CAAC,IAAI,EAAE;YAAE,gBAAgB,GAAG,IAAI,CAAC;IAC3C,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,6 @@ export { runPrintMode } from "./modes/index.js";
|
|
|
12
12
|
export { renderApp } from "./ui/render.js";
|
|
13
13
|
// Config
|
|
14
14
|
export { APP_NAME, VERSION, getAppPaths, ensureAppDirs } from "./config.js";
|
|
15
|
-
// Project discovery (shared with
|
|
15
|
+
// Project discovery (shared with the ezcoder-app sidecar)
|
|
16
16
|
export { discoverProjects, listRecentSessions, } from "./core/project-discovery.js";
|
|
17
17
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,OAAO,EACL,WAAW,EACX,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,YAAY,EACZ,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAE1B,gBAAgB;AAChB,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,kCAAkC;AAClC,OAAO,EACL,aAAa,EACb,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,OAAO;AACP,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,MAAM,EACN,QAAQ,EACR,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,aAAa,EACb,OAAO,EACP,cAAc,EACd,cAAc,EACd,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC;AAEzB,QAAQ;AACR,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,WAAW;AACX,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,SAAS;AACT,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5E
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,OAAO,EACL,WAAW,EACX,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,EACd,cAAc,EACd,cAAc,EACd,YAAY,EACZ,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAE1B,gBAAgB;AAChB,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,kCAAkC;AAClC,OAAO,EACL,aAAa,EACb,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,OAAO;AACP,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,MAAM,EACN,QAAQ,EACR,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,aAAa,EACb,OAAO,EACP,cAAc,EACd,cAAc,EACd,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC;AAEzB,QAAQ;AACR,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,WAAW;AACX,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,SAAS;AACT,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5E,0DAA0D;AAC1D,OAAO,EACL,gBAAgB,EAChB,kBAAkB,GAInB,MAAM,6BAA6B,CAAC"}
|
package/dist/interactive.js
CHANGED
|
@@ -4,7 +4,8 @@ import { agentLoop } from "@prestyj/agent";
|
|
|
4
4
|
import { buildSystemPrompt } from "./system-prompt.js";
|
|
5
5
|
import { createTools } from "./tools/index.js";
|
|
6
6
|
import { createSession, loadSession, getMostRecentSession, persistMessage, } from "./session.js";
|
|
7
|
-
import { formatToolCallStart, formatToolCallEnd, formatUsage,
|
|
7
|
+
import { formatToolCallStart, formatToolCallEnd, formatUsage, formatWelcome, } from "./utils/format.js";
|
|
8
|
+
import { formatUserError } from "./utils/error-handler.js";
|
|
8
9
|
import { AuthStorage } from "./core/auth-storage.js";
|
|
9
10
|
import { kimiCodingHeaders, isKimiCodingEndpoint } from "./core/oauth/kimi.js";
|
|
10
11
|
import { ensureAppDirs, loadSavedSettings } from "./config.js";
|
|
@@ -195,7 +196,7 @@ export async function runInteractive(config) {
|
|
|
195
196
|
stdout.write("\n\nInterrupted.\n");
|
|
196
197
|
}
|
|
197
198
|
else {
|
|
198
|
-
stdout.write("\n" +
|
|
199
|
+
stdout.write("\n" + formatUserError(err instanceof Error ? err : new Error(String(err))) + "\n");
|
|
199
200
|
}
|
|
200
201
|
}
|
|
201
202
|
finally {
|
|
@@ -238,7 +239,7 @@ function renderEvent(event) {
|
|
|
238
239
|
// Final usage summary already shown via turn_end
|
|
239
240
|
break;
|
|
240
241
|
case "error":
|
|
241
|
-
stdout.write(
|
|
242
|
+
stdout.write(formatUserError(event.error) + "\n");
|
|
242
243
|
break;
|
|
243
244
|
}
|
|
244
245
|
}
|
package/dist/interactive.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactive.js","sourceRoot":"","sources":["../src/interactive.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAmB,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,cAAc,GAEf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,
|
|
1
|
+
{"version":3,"file":"interactive.js","sourceRoot":"","sources":["../src/interactive.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAmB,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,cAAc,GAEf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;A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
|
+
* prompts. Built like the desktop's `ensureNolanAutoSession` (app-sidecar.ts):
|
|
4
|
+
* Nolan's autopilot system prompt, Nolan's read-only tool set, a transient
|
|
5
|
+
* session, long cache retention, and the project's Nolan model pin when one is
|
|
6
|
+
* valid (otherwise Nolan follows EZ Coder's model, as on the desktop).
|
|
7
|
+
*/
|
|
8
|
+
import type { Provider } from "@prestyj/ai";
|
|
9
|
+
/** The reviewer the ACP autopilot cycle talks to. A seam so tests can script Nolan. */
|
|
10
|
+
export interface AcpNolanReviewer {
|
|
11
|
+
/** Wipe review history (start of each cycle). */
|
|
12
|
+
reset(): Promise<void>;
|
|
13
|
+
/** Prompt Nolan with a digest; resolves to his final reply text. */
|
|
14
|
+
review(digest: string): Promise<string>;
|
|
15
|
+
/** Stop an in-flight review (session/cancel, queued message). */
|
|
16
|
+
abort(): void;
|
|
17
|
+
dispose(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export interface AcpNolanReviewerOptions {
|
|
20
|
+
cwd: string;
|
|
21
|
+
/** EZ Coder's current model; Nolan follows it unless the project pins his own. */
|
|
22
|
+
buildModel: () => {
|
|
23
|
+
provider: Provider;
|
|
24
|
+
model: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export declare function createAcpNolanReviewer(options: AcpNolanReviewerOptions): AcpNolanReviewer;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { getModel } from "@prestyj/core";
|
|
2
|
+
import { AgentSession } from "../core/agent-session.js";
|
|
3
|
+
import { buildNolanAutopilotSystemPrompt } from "../core/nolan-prompt.js";
|
|
4
|
+
import { validateNolanModelPref } from "../core/nolan-model.js";
|
|
5
|
+
import { NOLAN_ALLOWED_TOOLS, lastAssistantText } from "../app-sidecar/nolan-context.js";
|
|
6
|
+
import { loadNolanModelPref } from "../app-sidecar/app-settings.js";
|
|
7
|
+
export function createAcpNolanReviewer(options) {
|
|
8
|
+
let abort = new AbortController();
|
|
9
|
+
let nolan = null;
|
|
10
|
+
async function ensure() {
|
|
11
|
+
if (nolan)
|
|
12
|
+
return nolan;
|
|
13
|
+
const pinned = validateNolanModelPref(await loadNolanModelPref(options.cwd), {
|
|
14
|
+
modelExists: (id) => getModel(id) !== undefined,
|
|
15
|
+
providerConnected: () => true,
|
|
16
|
+
});
|
|
17
|
+
const target = pinned ?? options.buildModel();
|
|
18
|
+
const created = new AgentSession({
|
|
19
|
+
provider: target.provider,
|
|
20
|
+
model: target.model,
|
|
21
|
+
cwd: options.cwd,
|
|
22
|
+
systemPrompt: await buildNolanAutopilotSystemPrompt(options.cwd),
|
|
23
|
+
allowedTools: NOLAN_ALLOWED_TOOLS,
|
|
24
|
+
transient: true,
|
|
25
|
+
signal: abort.signal,
|
|
26
|
+
forceLongCacheRetention: true,
|
|
27
|
+
});
|
|
28
|
+
await created.initialize();
|
|
29
|
+
nolan = created;
|
|
30
|
+
return created;
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
async reset() {
|
|
34
|
+
await nolan?.newSession().catch(() => undefined);
|
|
35
|
+
},
|
|
36
|
+
async review(digest) {
|
|
37
|
+
const session = await ensure();
|
|
38
|
+
await session.prompt(digest);
|
|
39
|
+
return lastAssistantText(session.getMessages());
|
|
40
|
+
},
|
|
41
|
+
abort() {
|
|
42
|
+
abort.abort();
|
|
43
|
+
abort = new AbortController();
|
|
44
|
+
nolan?.setSignal(abort.signal);
|
|
45
|
+
},
|
|
46
|
+
async dispose() {
|
|
47
|
+
abort.abort();
|
|
48
|
+
const current = nolan;
|
|
49
|
+
nolan = null;
|
|
50
|
+
await current?.dispose();
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=acp-autopilot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acp-autopilot.js","sourceRoot":"","sources":["../../src/modes/acp-autopilot.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAA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AAO;QACL,KAAK,CAAC,KAAK;YACT,MAAM,KAAK,EAAE,UAAU,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACnD,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,MAAM;YACjB,MAAM,OAAO,GAAG,MAAM,MAAM,EAAE,CAAC;YAC/B,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC7B,OAAO,iBAAiB,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QAClD,CAAC;QACD,KAAK;YACH,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,KAAK,GAAG,IAAI,eAAe,EAAE,CAAC;YAC9B,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC;QACD,KAAK,CAAC,OAAO;YACX,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,MAAM,OAAO,GAAG,KAAK,CAAC;YACtB,KAAK,GAAG,IAAI,CAAC;YACb,MAAM,OAAO,EAAE,OAAO,EAAE,CAAC;QAC3B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type GoalRecord, type GoalResult } from "../core/goals-store.js";
|
|
2
|
+
import type { SubAgentSnapshot } from "../core/subagent-manager.js";
|
|
3
|
+
import type { AppAttachment } from "../app-sidecar/attachments.js";
|
|
4
|
+
/** `_gg/goals/list` row: the sidecar's GoalSummary, addressed by session id. */
|
|
5
|
+
export interface AcpGoalSummary {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
goal: string;
|
|
9
|
+
context: GoalRecord["context"];
|
|
10
|
+
path: string;
|
|
11
|
+
createdAt: string;
|
|
12
|
+
lastActiveMs: number;
|
|
13
|
+
lastActiveDisplay: string;
|
|
14
|
+
/** The id `session/load` / `session/resume` take; null starts a fresh coordinator. */
|
|
15
|
+
agentSessionId: string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Standing instructions, so a client's goal settings can show what is set
|
|
18
|
+
* (absent = none). The desktop app reads them from the record the same way.
|
|
19
|
+
*/
|
|
20
|
+
instructions?: string;
|
|
21
|
+
/** Never `running`: ezcoder computes it without a live run (the client overlays that). */
|
|
22
|
+
status: "briefing" | "paused" | "interrupted" | "idle";
|
|
23
|
+
}
|
|
24
|
+
/** pew2 wire `GoalWorker`. */
|
|
25
|
+
export interface AcpGoalWorker {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
agent?: string;
|
|
29
|
+
state: "starting" | "running" | "completed" | "failed" | "interrupted" | "closed";
|
|
30
|
+
activity?: string;
|
|
31
|
+
startedAt?: number;
|
|
32
|
+
elapsedMs?: number;
|
|
33
|
+
toolUses?: number;
|
|
34
|
+
model?: string;
|
|
35
|
+
error?: string;
|
|
36
|
+
}
|
|
37
|
+
/** Every goal, most recently active first. */
|
|
38
|
+
export declare function listAcpGoals(agentDir: string): Promise<AcpGoalSummary[]>;
|
|
39
|
+
/** Create a goal from `_gg/goals/create` params; the store's own error text on failure. */
|
|
40
|
+
export declare function createAcpGoal(agentDir: string, params: unknown): Promise<GoalResult<AcpGoalSummary>>;
|
|
41
|
+
/** The worker roster for `_gg/goal_state`. A reaped worker reads as closed. */
|
|
42
|
+
export declare function goalWorkers(snapshots: readonly SubAgentSnapshot[]): AcpGoalWorker[];
|
|
43
|
+
/**
|
|
44
|
+
* ACP `image` prompt blocks as the app's attachment shape, so they take the
|
|
45
|
+
* same `prepareAttachments` → `promptWithAttachments` path the desktop does.
|
|
46
|
+
* Blocks carrying only a `uri` (no inline data) are skipped.
|
|
47
|
+
*/
|
|
48
|
+
export declare function acpImageAttachments(blocks: unknown): AppAttachment[];
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EZ Goals over ACP (`_gg/goals/*`, `_gg/goal/*`, `_gg/goal_state`): the pure
|
|
3
|
+
* pieces, kept out of `acp-mode.ts` so the transport stays readable. The goal
|
|
4
|
+
* list rows come from the same `summarizeGoal` the desktop sidecar uses.
|
|
5
|
+
*/
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { createGoal, goalsRoot, listGoals, } from "../core/goals-store.js";
|
|
8
|
+
import { summarizeGoal } from "../core/goal-summary.js";
|
|
9
|
+
import { SessionManager } from "../core/session-manager.js";
|
|
10
|
+
function toAcpSummary(summary, instructions) {
|
|
11
|
+
return {
|
|
12
|
+
...(instructions ? { instructions } : {}),
|
|
13
|
+
id: summary.id,
|
|
14
|
+
name: summary.name,
|
|
15
|
+
goal: summary.goal,
|
|
16
|
+
context: summary.context,
|
|
17
|
+
path: summary.path,
|
|
18
|
+
createdAt: summary.createdAt,
|
|
19
|
+
lastActiveMs: summary.lastActiveMs,
|
|
20
|
+
lastActiveDisplay: summary.lastActiveDisplay,
|
|
21
|
+
agentSessionId: summary.latestSessionId,
|
|
22
|
+
// summarizeGoal is never told the goal is busy, so `running` cannot occur.
|
|
23
|
+
status: summary.status === "running" ? "idle" : summary.status,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function sessionsDir(agentDir) {
|
|
27
|
+
return path.join(agentDir, "sessions");
|
|
28
|
+
}
|
|
29
|
+
/** Every goal, most recently active first. */
|
|
30
|
+
export async function listAcpGoals(agentDir) {
|
|
31
|
+
const sessions = new SessionManager(sessionsDir(agentDir));
|
|
32
|
+
const goals = await listGoals(goalsRoot(agentDir));
|
|
33
|
+
const rows = await Promise.all(goals.map(async (g) => toAcpSummary(await summarizeGoal(sessions, g.dir, g.record), g.record.instructions)));
|
|
34
|
+
rows.sort((a, b) => b.lastActiveMs - a.lastActiveMs || a.id.localeCompare(b.id));
|
|
35
|
+
return rows;
|
|
36
|
+
}
|
|
37
|
+
/** Create a goal from `_gg/goals/create` params; the store's own error text on failure. */
|
|
38
|
+
export async function createAcpGoal(agentDir, params) {
|
|
39
|
+
const input = params && typeof params === "object"
|
|
40
|
+
? params
|
|
41
|
+
: {};
|
|
42
|
+
const created = await createGoal(goalsRoot(agentDir), {
|
|
43
|
+
name: typeof input.name === "string" ? input.name : "",
|
|
44
|
+
goal: typeof input.goal === "string" ? input.goal : "",
|
|
45
|
+
context: Array.isArray(input.context)
|
|
46
|
+
? input.context.filter((p) => typeof p === "string")
|
|
47
|
+
: [],
|
|
48
|
+
...(typeof input.instructions === "string" ? { instructions: input.instructions } : {}),
|
|
49
|
+
}, new Date());
|
|
50
|
+
if (!created.ok)
|
|
51
|
+
return created;
|
|
52
|
+
const sessions = new SessionManager(sessionsDir(agentDir));
|
|
53
|
+
return {
|
|
54
|
+
ok: true,
|
|
55
|
+
value: toAcpSummary(await summarizeGoal(sessions, created.value.dir, created.value.record), created.value.record.instructions),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** The worker roster for `_gg/goal_state`. A reaped worker reads as closed. */
|
|
59
|
+
export function goalWorkers(snapshots) {
|
|
60
|
+
return snapshots.map((s) => ({
|
|
61
|
+
id: s.agent_id,
|
|
62
|
+
name: s.task_name,
|
|
63
|
+
...(s.agent_name ? { agent: s.agent_name } : {}),
|
|
64
|
+
state: s.state === "reaped" ? "closed" : s.state,
|
|
65
|
+
...(s.current_activity ? { activity: s.current_activity } : {}),
|
|
66
|
+
startedAt: s.started_at,
|
|
67
|
+
elapsedMs: s.elapsed_ms,
|
|
68
|
+
toolUses: s.tool_use_count,
|
|
69
|
+
...(s.model ? { model: s.model } : {}),
|
|
70
|
+
...(s.error ? { error: s.error } : {}),
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
const IMAGE_EXTENSIONS = {
|
|
74
|
+
"image/png": "png",
|
|
75
|
+
"image/jpeg": "jpg",
|
|
76
|
+
"image/gif": "gif",
|
|
77
|
+
"image/webp": "webp",
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* ACP `image` prompt blocks as the app's attachment shape, so they take the
|
|
81
|
+
* same `prepareAttachments` → `promptWithAttachments` path the desktop does.
|
|
82
|
+
* Blocks carrying only a `uri` (no inline data) are skipped.
|
|
83
|
+
*/
|
|
84
|
+
export function acpImageAttachments(blocks) {
|
|
85
|
+
if (!Array.isArray(blocks))
|
|
86
|
+
return [];
|
|
87
|
+
const out = [];
|
|
88
|
+
for (const block of blocks) {
|
|
89
|
+
const entry = block;
|
|
90
|
+
if (entry?.type !== "image" || typeof entry.data !== "string" || !entry.data)
|
|
91
|
+
continue;
|
|
92
|
+
const mediaType = typeof entry.mimeType === "string" ? entry.mimeType : "image/png";
|
|
93
|
+
const ext = IMAGE_EXTENSIONS[mediaType] ?? "img";
|
|
94
|
+
out.push({
|
|
95
|
+
kind: "image",
|
|
96
|
+
name: `image-${out.length + 1}.${ext}`,
|
|
97
|
+
mediaType,
|
|
98
|
+
data: entry.data,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=acp-goals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acp-goals.js","sourceRoot":"","sources":["../../src/modes/acp-goals.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,UAAU,EACV,SAAS,EACT,SAAS,GAGV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAiC,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAuC5D,SAAS,YAAY,CACnB,OAAiC,EACjC,YAAgC;IAEhC,OAAO;QACL,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,S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