@project-ava-supernova/core 0.2.150 → 0.2.152
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/agent/agent.d.ts +32 -18
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.js +73 -24
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/repair-history.d.ts +53 -0
- package/dist/agent/repair-history.d.ts.map +1 -0
- package/dist/agent/repair-history.js +124 -0
- package/dist/agent/repair-history.js.map +1 -0
- package/dist/i18n/locales/ar.d.ts.map +1 -1
- package/dist/i18n/locales/ar.js +48 -0
- package/dist/i18n/locales/ar.js.map +1 -1
- package/dist/i18n/locales/de.d.ts.map +1 -1
- package/dist/i18n/locales/de.js +48 -0
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/en.d.ts +48 -0
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/en.js +48 -0
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts.map +1 -1
- package/dist/i18n/locales/es.js +48 -0
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts.map +1 -1
- package/dist/i18n/locales/fr.js +48 -0
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hi.d.ts.map +1 -1
- package/dist/i18n/locales/hi.js +48 -0
- package/dist/i18n/locales/hi.js.map +1 -1
- package/dist/i18n/locales/id.d.ts.map +1 -1
- package/dist/i18n/locales/id.js +48 -0
- package/dist/i18n/locales/id.js.map +1 -1
- package/dist/i18n/locales/it.d.ts.map +1 -1
- package/dist/i18n/locales/it.js +48 -0
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/ja.d.ts.map +1 -1
- package/dist/i18n/locales/ja.js +48 -0
- package/dist/i18n/locales/ja.js.map +1 -1
- package/dist/i18n/locales/ko.d.ts.map +1 -1
- package/dist/i18n/locales/ko.js +48 -0
- package/dist/i18n/locales/ko.js.map +1 -1
- package/dist/i18n/locales/nl.d.ts.map +1 -1
- package/dist/i18n/locales/nl.js +48 -0
- package/dist/i18n/locales/nl.js.map +1 -1
- package/dist/i18n/locales/pl.d.ts.map +1 -1
- package/dist/i18n/locales/pl.js +48 -0
- package/dist/i18n/locales/pl.js.map +1 -1
- package/dist/i18n/locales/pt.d.ts.map +1 -1
- package/dist/i18n/locales/pt.js +48 -0
- package/dist/i18n/locales/pt.js.map +1 -1
- package/dist/i18n/locales/ru.d.ts.map +1 -1
- package/dist/i18n/locales/ru.js +48 -0
- package/dist/i18n/locales/ru.js.map +1 -1
- package/dist/i18n/locales/th.d.ts.map +1 -1
- package/dist/i18n/locales/th.js +48 -0
- package/dist/i18n/locales/th.js.map +1 -1
- package/dist/i18n/locales/tr.d.ts.map +1 -1
- package/dist/i18n/locales/tr.js +48 -0
- package/dist/i18n/locales/tr.js.map +1 -1
- package/dist/i18n/locales/uk.d.ts.map +1 -1
- package/dist/i18n/locales/uk.js +48 -0
- package/dist/i18n/locales/uk.js.map +1 -1
- package/dist/i18n/locales/vi.d.ts.map +1 -1
- package/dist/i18n/locales/vi.js +48 -0
- package/dist/i18n/locales/vi.js.map +1 -1
- package/dist/i18n/locales/zh-CN.d.ts.map +1 -1
- package/dist/i18n/locales/zh-CN.js +48 -0
- package/dist/i18n/locales/zh-CN.js.map +1 -1
- package/dist/i18n/locales/zh-TW.d.ts.map +1 -1
- package/dist/i18n/locales/zh-TW.js +48 -0
- package/dist/i18n/locales/zh-TW.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/memory-manager.d.ts +32 -0
- package/dist/memory/memory-manager.d.ts.map +1 -1
- package/dist/memory/memory-manager.js +165 -16
- package/dist/memory/memory-manager.js.map +1 -1
- package/dist/memory/mode-recall.d.ts.map +1 -1
- package/dist/memory/mode-recall.js +7 -0
- package/dist/memory/mode-recall.js.map +1 -1
- package/dist/memory/project-brain.d.ts.map +1 -1
- package/dist/memory/project-brain.js +71 -12
- package/dist/memory/project-brain.js.map +1 -1
- package/dist/memory/types.d.ts +23 -3
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/memory/types.js +2 -2
- package/dist/memory/types.js.map +1 -1
- package/dist/portability/factory-reset.d.ts +136 -0
- package/dist/portability/factory-reset.d.ts.map +1 -0
- package/dist/portability/factory-reset.js +360 -0
- package/dist/portability/factory-reset.js.map +1 -0
- package/dist/portability/index.d.ts +1 -0
- package/dist/portability/index.d.ts.map +1 -1
- package/dist/portability/index.js +2 -0
- package/dist/portability/index.js.map +1 -1
- package/dist/social/index.d.ts +16 -0
- package/dist/social/index.d.ts.map +1 -1
- package/dist/tools/memory-recall.js +2 -2
- package/dist/tools/memory-recall.js.map +1 -1
- package/dist/tools/memory-save.d.ts.map +1 -1
- package/dist/tools/memory-save.js +3 -1
- package/dist/tools/memory-save.js.map +1 -1
- package/dist/tools/suggest-beats.d.ts.map +1 -1
- package/dist/tools/suggest-beats.js +27 -2
- package/dist/tools/suggest-beats.js.map +1 -1
- package/dist/tools/write-video-post.d.ts.map +1 -1
- package/dist/tools/write-video-post.js +58 -2
- package/dist/tools/write-video-post.js.map +1 -1
- package/package.json +1 -1
package/dist/agent/agent.d.ts
CHANGED
|
@@ -119,6 +119,15 @@ export type AgentEvent = {
|
|
|
119
119
|
type: 'context_truncated';
|
|
120
120
|
droppedCount: number;
|
|
121
121
|
}
|
|
122
|
+
/** The provider refused the conversation and we repaired it rather than
|
|
123
|
+
* ending the turn. NEVER silent: a quiet repair hides the bug that made
|
|
124
|
+
* it necessary, and the whole reason this exists is a fault that would
|
|
125
|
+
* otherwise have been absorbed invisibly. */
|
|
126
|
+
| {
|
|
127
|
+
type: 'history_repaired';
|
|
128
|
+
kind: string;
|
|
129
|
+
summary: string;
|
|
130
|
+
}
|
|
122
131
|
/** The model was cut off at its output limit mid-reply. Never silent: a
|
|
123
132
|
* truncated tool call simply never arrives, and the turn used to end as
|
|
124
133
|
* though she had chosen to stop. */
|
|
@@ -627,33 +636,38 @@ export declare class Agent {
|
|
|
627
636
|
private trimOldToolResults;
|
|
628
637
|
private truncateMessages;
|
|
629
638
|
/**
|
|
630
|
-
* Detect the "first turn after Stop"
|
|
639
|
+
* Detect the "first turn after Stop" and tell Ava not to resume — WITHOUT
|
|
640
|
+
* taking the conversation away from her.
|
|
631
641
|
*
|
|
632
|
-
* When cancelRun() fires
|
|
633
|
-
*
|
|
634
|
-
*
|
|
642
|
+
* When cancelRun() fires, a marker goes into the conversation:
|
|
643
|
+
* `[User pressed Stop — previous task terminated...]`. After the user's
|
|
644
|
+
* next real message the history looks like:
|
|
635
645
|
*
|
|
636
|
-
* [... prior task
|
|
646
|
+
* [... prior task ...]
|
|
637
647
|
* [User pressed Stop — ...] (meta user message)
|
|
638
648
|
* Actual new user message
|
|
639
649
|
*
|
|
640
|
-
*
|
|
641
|
-
*
|
|
642
|
-
*
|
|
650
|
+
* THIS USED TO DELETE EVERYTHING ABOVE THE MARKER. The reasoning was that
|
|
651
|
+
* the prior tokens were dead weight and re-sending them made the model drift
|
|
652
|
+
* back into the abandoned task. The cost was far worse than the saving: the
|
|
653
|
+
* operator pressed Stop meaning "that is going wrong, let me redirect you",
|
|
654
|
+
* and Ava answered as though the conversation had never happened — then
|
|
655
|
+
* remembered it again the turn after, which is more baffling still. He
|
|
656
|
+
* described it as "losing massive chunks", and he was right to.
|
|
643
657
|
*
|
|
644
|
-
*
|
|
645
|
-
*
|
|
658
|
+
* Stop means stop generating. It does not mean forget. Every other tool he
|
|
659
|
+
* uses works that way, and the marker below already carries the "do not
|
|
660
|
+
* resume" instruction — enforcing it with amnesia was never necessary.
|
|
646
661
|
*
|
|
647
|
-
*
|
|
648
|
-
*
|
|
649
|
-
*
|
|
650
|
-
* turn — restrict.
|
|
662
|
+
* So this now injects the directive into the system prompt and returns the
|
|
663
|
+
* history intact. Compression still applies downstream, which is the right
|
|
664
|
+
* place to deal with size.
|
|
651
665
|
*
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
*
|
|
666
|
+
* Detection: the most recent stop marker, with exactly one non-meta user
|
|
667
|
+
* message after it and no real assistant reply yet. Later turns need no
|
|
668
|
+
* directive — the task is well and truly abandoned by then.
|
|
655
669
|
*/
|
|
656
|
-
private
|
|
670
|
+
private applyPostStopDirective;
|
|
657
671
|
/**
|
|
658
672
|
* Age out old images and old tool results to cut per-turn token cost.
|
|
659
673
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAqC,MAAM,uBAAuB,CAAC;AAEzF,OAAO,KAAK,EACV,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,UAAU,EAEX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAqC,MAAM,uBAAuB,CAAC;AAEzF,OAAO,KAAK,EACV,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,UAAU,EAEX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA+BhD,OAAO,KAAK,EAAE,UAAU,EAAW,MAAM,sBAAsB,CAAC;AA8IhE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,kBAAkB,kQAarB,CAAC;AA0eX;;;;;;;;;GASG;AACH,wBAAgB,sB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C,OAAO,EAAE,CAAC;IAmQrB,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAMjC,OAAO,CAAC,qBAAqB;IA4B7B,8DAA8D;IAC9D,kBAAkB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM;IAM/C;;;;OAIG;IACH;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,OAAO,CAAC,kBAAkB;IAyE1B,OAAO,CAAC,gBAAgB;IAyDxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,OAAO,CAAC,sBAAsB;IAkE9B;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,iBAAiB;IA8DzB;;;;;;;OAOG;IACH,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE;IAI9C;;;;OAIG;IACH,OAAO,CAAC,cAAc;CAoDvB"}
|
package/dist/agent/agent.js
CHANGED
|
@@ -8,6 +8,7 @@ import { buildToolPrompt, parseToolCalls, formatToolResult } from './text-tool-p
|
|
|
8
8
|
import { bridgeImagesForTextModel } from './vision-bridge.js';
|
|
9
9
|
import { auditClaims } from './claims-auditor.js';
|
|
10
10
|
import { parseJsonForgivingly } from '../utils/json-repair.js';
|
|
11
|
+
import { repairHistory, logRepair } from './repair-history.js';
|
|
11
12
|
import { autoExtractAndSave } from '../memory/auto-extract.js';
|
|
12
13
|
import { maybeBuildDesignReinjection, isUIFilePath as isUIFilePathLocal } from './design-reinjection.js';
|
|
13
14
|
import { isStopCommand } from './stop-command.js';
|
|
@@ -1376,7 +1377,7 @@ export class Agent {
|
|
|
1376
1377
|
// short/conversational, the intent gate will disable tools too.
|
|
1377
1378
|
// Combined effect: user presses Stop → types something → Ava responds
|
|
1378
1379
|
// on the user's actual terms, not the prior task's terms.
|
|
1379
|
-
messages = this.
|
|
1380
|
+
messages = this.applyPostStopDirective(messages);
|
|
1380
1381
|
// ─── Classify this task for directness discipline ─────────────────────
|
|
1381
1382
|
// Find the latest non-meta user message and run the lightweight
|
|
1382
1383
|
// classifier. The result sets the exploration budget for this run and
|
|
@@ -1525,6 +1526,10 @@ export class Agent {
|
|
|
1525
1526
|
// Pass signal to tool execution context so tools (esp. bash) can be cancelled
|
|
1526
1527
|
const runContext = { ...this.toolContext, signal };
|
|
1527
1528
|
let iterations = 0;
|
|
1529
|
+
// One repair per turn. If a repaired history fails again the repair did
|
|
1530
|
+
// not take, and retrying becomes a loop that spends an allowance going
|
|
1531
|
+
// nowhere. See repair-history.ts.
|
|
1532
|
+
let repairAttempted = false;
|
|
1528
1533
|
this.pauseRequested = false; // clear any stale pause from a prior run
|
|
1529
1534
|
this._inThinkTag = false;
|
|
1530
1535
|
let warningInjected = false;
|
|
@@ -1941,6 +1946,36 @@ export class Agent {
|
|
|
1941
1946
|
}
|
|
1942
1947
|
catch (error) {
|
|
1943
1948
|
logger.error(`[agent] streamResponse THREW: ${error instanceof Error ? error.message : String(error)}`);
|
|
1949
|
+
// ── Repair a refused conversation, once ───────────────────────────
|
|
1950
|
+
//
|
|
1951
|
+
// A 400 is usually a complaint about the HISTORY, not about what was
|
|
1952
|
+
// just typed. Before this, the error surfaced and the turn ended; the
|
|
1953
|
+
// next message replayed the same malformed history and failed the
|
|
1954
|
+
// same way, forever, and a new chat was the only escape. A DeepSeek
|
|
1955
|
+
// thinking-mode conversation died exactly like that on 16 Oct, under
|
|
1956
|
+
// an error message that said "that's ours to fix — try again".
|
|
1957
|
+
//
|
|
1958
|
+
// So when the provider names a structural fault we fix that fault and
|
|
1959
|
+
// send once more. Only once, and only if the repair actually changed
|
|
1960
|
+
// something: see repair-history.ts for why those two rules carry more
|
|
1961
|
+
// weight than the repairs do.
|
|
1962
|
+
const provErr = error;
|
|
1963
|
+
if (!repairAttempted && provErr?.statusCode === 400) {
|
|
1964
|
+
const detail = typeof provErr.responseBody === 'string'
|
|
1965
|
+
? provErr.responseBody
|
|
1966
|
+
: JSON.stringify(provErr.responseBody ?? '');
|
|
1967
|
+
const repair = repairHistory(detail, messages);
|
|
1968
|
+
if (repair && repair.messages.length !== messages.length) {
|
|
1969
|
+
repairAttempted = true;
|
|
1970
|
+
logRepair(repair, 1);
|
|
1971
|
+
messages = repair.messages;
|
|
1972
|
+
// Said out loud on purpose. A silent repair hides the bug that
|
|
1973
|
+
// caused it — this very fault would have been absorbed invisibly
|
|
1974
|
+
// and the two files that disagreed would still disagree.
|
|
1975
|
+
onEvent({ type: 'history_repaired', kind: repair.kind, summary: repair.summary });
|
|
1976
|
+
continue;
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1944
1979
|
// Surface the error through the event system so CLI/extension handle it consistently
|
|
1945
1980
|
onEvent({ type: 'error', error: error instanceof Error ? error : new Error(String(error)) });
|
|
1946
1981
|
// Always emit done so UI clears isStreaming/isThinking
|
|
@@ -3781,33 +3816,38 @@ ${transcript}`;
|
|
|
3781
3816
|
return enrichedSystem ? [enrichedSystem, ...fixed] : fixed;
|
|
3782
3817
|
}
|
|
3783
3818
|
/**
|
|
3784
|
-
* Detect the "first turn after Stop"
|
|
3819
|
+
* Detect the "first turn after Stop" and tell Ava not to resume — WITHOUT
|
|
3820
|
+
* taking the conversation away from her.
|
|
3785
3821
|
*
|
|
3786
|
-
* When cancelRun() fires
|
|
3787
|
-
*
|
|
3788
|
-
*
|
|
3822
|
+
* When cancelRun() fires, a marker goes into the conversation:
|
|
3823
|
+
* `[User pressed Stop — previous task terminated...]`. After the user's
|
|
3824
|
+
* next real message the history looks like:
|
|
3789
3825
|
*
|
|
3790
|
-
* [... prior task
|
|
3826
|
+
* [... prior task ...]
|
|
3791
3827
|
* [User pressed Stop — ...] (meta user message)
|
|
3792
3828
|
* Actual new user message
|
|
3793
3829
|
*
|
|
3794
|
-
*
|
|
3795
|
-
*
|
|
3796
|
-
*
|
|
3830
|
+
* THIS USED TO DELETE EVERYTHING ABOVE THE MARKER. The reasoning was that
|
|
3831
|
+
* the prior tokens were dead weight and re-sending them made the model drift
|
|
3832
|
+
* back into the abandoned task. The cost was far worse than the saving: the
|
|
3833
|
+
* operator pressed Stop meaning "that is going wrong, let me redirect you",
|
|
3834
|
+
* and Ava answered as though the conversation had never happened — then
|
|
3835
|
+
* remembered it again the turn after, which is more baffling still. He
|
|
3836
|
+
* described it as "losing massive chunks", and he was right to.
|
|
3797
3837
|
*
|
|
3798
|
-
*
|
|
3799
|
-
*
|
|
3838
|
+
* Stop means stop generating. It does not mean forget. Every other tool he
|
|
3839
|
+
* uses works that way, and the marker below already carries the "do not
|
|
3840
|
+
* resume" instruction — enforcing it with amnesia was never necessary.
|
|
3800
3841
|
*
|
|
3801
|
-
*
|
|
3802
|
-
*
|
|
3803
|
-
*
|
|
3804
|
-
* turn — restrict.
|
|
3842
|
+
* So this now injects the directive into the system prompt and returns the
|
|
3843
|
+
* history intact. Compression still applies downstream, which is the right
|
|
3844
|
+
* place to deal with size.
|
|
3805
3845
|
*
|
|
3806
|
-
*
|
|
3807
|
-
*
|
|
3808
|
-
*
|
|
3846
|
+
* Detection: the most recent stop marker, with exactly one non-meta user
|
|
3847
|
+
* message after it and no real assistant reply yet. Later turns need no
|
|
3848
|
+
* directive — the task is well and truly abandoned by then.
|
|
3809
3849
|
*/
|
|
3810
|
-
|
|
3850
|
+
applyPostStopDirective(messages) {
|
|
3811
3851
|
// Find the most recent stop marker (a user-role message starting with the marker prefix).
|
|
3812
3852
|
let markerIdx = -1;
|
|
3813
3853
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
@@ -3848,17 +3888,26 @@ ${transcript}`;
|
|
|
3848
3888
|
if (nonMetaUsers.length !== 1 || hasRealAssistantResponse) {
|
|
3849
3889
|
return messages;
|
|
3850
3890
|
}
|
|
3851
|
-
|
|
3891
|
+
// (The new user message itself needs no special handling now that the
|
|
3892
|
+
// history stays — it is already in `messages` where it belongs.)
|
|
3852
3893
|
const systemMsg = messages.find(m => m.role === 'system');
|
|
3853
3894
|
// Merge the stop directive into the system prompt so the model sees
|
|
3854
3895
|
// it at the highest-authority layer, not as a floating user message
|
|
3855
3896
|
// (which some providers reject when followed by another user msg).
|
|
3856
|
-
|
|
3857
|
-
|
|
3897
|
+
// The directive used to end with "you do not have the prior context",
|
|
3898
|
+
// which was true only because this function had just deleted it. Both
|
|
3899
|
+
// halves are gone now: the history stays, and Ava is told plainly that
|
|
3900
|
+
// she still has it.
|
|
3901
|
+
const stopDirective = `\n\n[Post-stop] The user stopped the previous task. Do NOT resume it or pick it back up on your own — answer the message below on its own terms.\n\nThe conversation above is still yours to use. If their message leans on it ("fix that instead", "same thing but…", "carry on from the bit that worked"), use it. Stopping a task does not undo the discussion that led to it.`;
|
|
3902
|
+
const withDirective = systemMsg
|
|
3858
3903
|
? { ...systemMsg, content: (typeof systemMsg.content === 'string' ? systemMsg.content : '') + stopDirective }
|
|
3859
3904
|
: { role: 'system', content: stopDirective.trimStart() };
|
|
3860
|
-
logger.debug(
|
|
3861
|
-
|
|
3905
|
+
logger.debug('[agent] Post-stop directive applied; history kept intact');
|
|
3906
|
+
// History intact — only the system message is swapped for its annotated
|
|
3907
|
+
// copy. Size is compression's job, not this function's.
|
|
3908
|
+
if (!withDirective)
|
|
3909
|
+
return messages;
|
|
3910
|
+
return messages.map(m => (m === systemMsg ? withDirective : m));
|
|
3862
3911
|
}
|
|
3863
3912
|
/**
|
|
3864
3913
|
* Age out old images and old tool results to cut per-turn token cost.
|