aegiscode 6.6.1 → 6.7.1
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 +46 -0
- package/bin/aegiscode.js +87 -0
- package/package.json +1 -1
- package/src/app.js +156 -11
- package/src/art.js +114 -60
- package/src/autonomous.js +8 -2
- package/src/caps.js +597 -0
- package/src/chatflow.js +59 -6
- package/src/cloudsync.js +86 -6
- package/src/commands.js +243 -23
- package/src/config.js +87 -0
- package/src/diff.js +330 -0
- package/src/diffview.js +286 -0
- package/src/events.js +21 -10
- package/src/panels.js +59 -1
- package/src/render.js +39 -17
- package/src/screen.js +20 -20
- package/src/theme.js +334 -125
- package/vendor/desktop/lib/local/autonomous.js +45 -4
- package/vendor/desktop/lib/local/engine.js +38 -0
- package/vendor/desktop/lib/local/queue.js +4 -0
- package/vendor/desktop/lib/local/session-rounds.js +19 -2
|
@@ -945,6 +945,11 @@ function createLocalEngine({ aegis, settings, ollama, providers, tools, promptBu
|
|
|
945
945
|
|
|
946
946
|
const system = (payload && payload.system) || buildSystemPrompt(envFor(payload));
|
|
947
947
|
const history = Array.isArray(payload && payload.messages) ? payload.messages.filter(Boolean).slice() : [];
|
|
948
|
+
// Index into `history` of everything THIS turn added as opposed to what the
|
|
949
|
+
// caller brought with it. Reset after the resume rehydration below, so a
|
|
950
|
+
// restored transcript is never re-recorded as if this turn had produced it
|
|
951
|
+
// (which would double it on every interruption in a chain).
|
|
952
|
+
let historyStart = history.length;
|
|
948
953
|
let prompt = (payload && payload.prompt) || '';
|
|
949
954
|
|
|
950
955
|
// Lazily start ONE shell session for this turn; the exec tool shares it so
|
|
@@ -1053,6 +1058,26 @@ function createLocalEngine({ aegis, settings, ollama, providers, tools, promptBu
|
|
|
1053
1058
|
}
|
|
1054
1059
|
if (resumed) {
|
|
1055
1060
|
const preamble = sessionRounds.resumePreamble(resumed);
|
|
1061
|
+
// Restore the interrupted turn's transcript, because the preamble alone
|
|
1062
|
+
// says HOW MUCH was done, not WHAT. The two callers need different
|
|
1063
|
+
// halves of it, so `session-rounds` files both (see `record`):
|
|
1064
|
+
//
|
|
1065
|
+
// · a caller who brings no conversation of its own — the queue
|
|
1066
|
+
// worker's fresh dispatch; autonomous.js never sends `messages` —
|
|
1067
|
+
// has nothing, so it gets the FULL transcript;
|
|
1068
|
+
// · an interactive chat already carries the prior turns (and the
|
|
1069
|
+
// "stopped at N rounds" note), so it gets only what THIS turn added
|
|
1070
|
+
// that the caller never saw: the tool calls and their results. Full
|
|
1071
|
+
// restore here would duplicate the caller's own text.
|
|
1072
|
+
//
|
|
1073
|
+
// The old `history.length === 0` guard did the first and not the second,
|
|
1074
|
+
// so the resume it was written for a queue task never reached the
|
|
1075
|
+
// interactive sessions this feature is actually used from.
|
|
1076
|
+
if (history.length === 0) {
|
|
1077
|
+
if (Array.isArray(resumed.messages) && resumed.messages.length) history.push(...resumed.messages);
|
|
1078
|
+
} else if (Array.isArray(resumed.added) && resumed.added.length) {
|
|
1079
|
+
history.push(...resumed.added);
|
|
1080
|
+
}
|
|
1056
1081
|
// Round 1's ask travels as `prompt`; a follow-up dispatch (and every
|
|
1057
1082
|
// turn that skips the shorthand) has to receive it through history.
|
|
1058
1083
|
if (prompt) prompt = `${preamble}\n\n${prompt}`;
|
|
@@ -1117,6 +1142,11 @@ function createLocalEngine({ aegis, settings, ollama, providers, tools, promptBu
|
|
|
1117
1142
|
prompt = '';
|
|
1118
1143
|
};
|
|
1119
1144
|
|
|
1145
|
+
// From here on, everything pushed into `history` is this turn's own work:
|
|
1146
|
+
// the restored transcript above (if any) belongs to the turn it came from,
|
|
1147
|
+
// and re-recording it would double the ledger on every interruption.
|
|
1148
|
+
historyStart = history.length;
|
|
1149
|
+
|
|
1120
1150
|
for (;;) {
|
|
1121
1151
|
// Stop and SAY so. A turn that reaches its horizon has usually done
|
|
1122
1152
|
// real work; ending silently would paint an empty answer over it,
|
|
@@ -1136,6 +1166,14 @@ function createLocalEngine({ aegis, settings, ollama, providers, tools, promptBu
|
|
|
1136
1166
|
tokens: turnUsage.total_tokens || 0,
|
|
1137
1167
|
note,
|
|
1138
1168
|
chain: resumed ? resumed.interruptions : 0,
|
|
1169
|
+
// The actual tool-call/tool-result transcript built up this turn —
|
|
1170
|
+
// everything folded/pushed into `history` by completed rounds — so
|
|
1171
|
+
// a resume can restore real memory of the work, not just a count
|
|
1172
|
+
// of it (see the `resumed.messages` rehydration above).
|
|
1173
|
+
messages: history,
|
|
1174
|
+
// …and only what this turn itself added, for the caller that
|
|
1175
|
+
// already has the rest of `history` in its own conversation.
|
|
1176
|
+
added: history.slice(historyStart),
|
|
1139
1177
|
});
|
|
1140
1178
|
if (rootOnDelta) rootOnDelta({ delta: `\n\n${note}` });
|
|
1141
1179
|
return withTurnUsage({
|
|
@@ -266,6 +266,10 @@ function retryTask(env, id, opts = {}) {
|
|
|
266
266
|
item.updated = opts.now || Date.now();
|
|
267
267
|
delete item.error;
|
|
268
268
|
delete item.pid;
|
|
269
|
+
// A manual retry is a fresh deliberate ask, so it gets its own full run of
|
|
270
|
+
// MAX_ROUND_STOPS chances (autonomous.js) rather than inheriting whatever
|
|
271
|
+
// count a previous, unrelated failure left behind.
|
|
272
|
+
delete item.roundStops;
|
|
269
273
|
saveQueue(env, items);
|
|
270
274
|
return item;
|
|
271
275
|
}
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* This makes the cap *session* state instead of turn state:
|
|
14
14
|
*
|
|
15
15
|
* - a turn that reaches its horizon records the unfinished work against the
|
|
16
|
-
* session key (rounds spent, tokens, the note the user saw
|
|
16
|
+
* session key (rounds spent, tokens, the note the user saw, and the
|
|
17
|
+
* tool-call transcript itself — see `record`'s `messages`);
|
|
17
18
|
* - the next turn in that session takes the record — consuming it, so one
|
|
18
19
|
* resume per interruption and a chain of interruptions is a chain of
|
|
19
20
|
* deliberate asks, never an automatic loop — and gets a continuation
|
|
@@ -126,8 +127,17 @@ function adopt({ now = Date.now(), maxAgeMs = 10 * 60 * 1000 } = {}) {
|
|
|
126
127
|
* File an interruption. `chain` carries the count forward from the entry this
|
|
127
128
|
* turn resumed, so `interruptions` reports how many times one job has been cut
|
|
128
129
|
* off — visible in the note and useful when deciding to raise the horizon.
|
|
130
|
+
*
|
|
131
|
+
* `messages` is the interrupted turn's own tool-call transcript (its live
|
|
132
|
+
* `history` array at the moment it hit the horizon) — real memory of what was
|
|
133
|
+
* already done, not just a rounds/tokens count of it. Without it a caller
|
|
134
|
+
* that supplies no conversation of its own (a queue task's fresh dispatch)
|
|
135
|
+
* resumes with an empty history: the model is told "continue, don't restart"
|
|
136
|
+
* with nothing to continue FROM, which is a cold start wearing a note.
|
|
137
|
+
* Stored as a defensive copy — the caller's `history` array keeps being
|
|
138
|
+
* mutated by the turn that is returning it.
|
|
129
139
|
*/
|
|
130
|
-
function record(key, { rounds, tokens, note, chain } = {}, now = Date.now()) {
|
|
140
|
+
function record(key, { rounds, tokens, note, chain, messages, added } = {}, now = Date.now()) {
|
|
131
141
|
prune(now);
|
|
132
142
|
const prior = entries.get(key);
|
|
133
143
|
const entry = {
|
|
@@ -136,6 +146,13 @@ function record(key, { rounds, tokens, note, chain } = {}, now = Date.now()) {
|
|
|
136
146
|
note: typeof note === 'string' ? note : '',
|
|
137
147
|
at: now,
|
|
138
148
|
interruptions: (Number.isFinite(chain) ? chain : prior && prior.interruptions) || 0,
|
|
149
|
+
messages: Array.isArray(messages) ? messages.slice() : [],
|
|
150
|
+
// And what the interrupted turn added on TOP of what its caller already
|
|
151
|
+
// had. A resuming caller who brings its own conversation (an interactive
|
|
152
|
+
// chat) must get this half, not `messages` — pushing the full transcript
|
|
153
|
+
// into a history that already holds its first half duplicates the user's
|
|
154
|
+
// own turns back to the model.
|
|
155
|
+
added: Array.isArray(added) ? added.slice() : [],
|
|
139
156
|
};
|
|
140
157
|
entry.interruptions += 1;
|
|
141
158
|
entries.delete(key);
|