@project-ava-supernova/core 0.2.150 → 0.2.151

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.
Files changed (89) hide show
  1. package/dist/agent/agent.d.ts +9 -0
  2. package/dist/agent/agent.d.ts.map +1 -1
  3. package/dist/agent/agent.js +35 -0
  4. package/dist/agent/agent.js.map +1 -1
  5. package/dist/agent/repair-history.d.ts +53 -0
  6. package/dist/agent/repair-history.d.ts.map +1 -0
  7. package/dist/agent/repair-history.js +124 -0
  8. package/dist/agent/repair-history.js.map +1 -0
  9. package/dist/i18n/locales/ar.d.ts.map +1 -1
  10. package/dist/i18n/locales/ar.js +1 -0
  11. package/dist/i18n/locales/ar.js.map +1 -1
  12. package/dist/i18n/locales/de.d.ts.map +1 -1
  13. package/dist/i18n/locales/de.js +1 -0
  14. package/dist/i18n/locales/de.js.map +1 -1
  15. package/dist/i18n/locales/en.d.ts +1 -0
  16. package/dist/i18n/locales/en.d.ts.map +1 -1
  17. package/dist/i18n/locales/en.js +1 -0
  18. package/dist/i18n/locales/en.js.map +1 -1
  19. package/dist/i18n/locales/es.d.ts.map +1 -1
  20. package/dist/i18n/locales/es.js +1 -0
  21. package/dist/i18n/locales/es.js.map +1 -1
  22. package/dist/i18n/locales/fr.d.ts.map +1 -1
  23. package/dist/i18n/locales/fr.js +1 -0
  24. package/dist/i18n/locales/fr.js.map +1 -1
  25. package/dist/i18n/locales/hi.d.ts.map +1 -1
  26. package/dist/i18n/locales/hi.js +1 -0
  27. package/dist/i18n/locales/hi.js.map +1 -1
  28. package/dist/i18n/locales/id.d.ts.map +1 -1
  29. package/dist/i18n/locales/id.js +1 -0
  30. package/dist/i18n/locales/id.js.map +1 -1
  31. package/dist/i18n/locales/it.d.ts.map +1 -1
  32. package/dist/i18n/locales/it.js +1 -0
  33. package/dist/i18n/locales/it.js.map +1 -1
  34. package/dist/i18n/locales/ja.d.ts.map +1 -1
  35. package/dist/i18n/locales/ja.js +1 -0
  36. package/dist/i18n/locales/ja.js.map +1 -1
  37. package/dist/i18n/locales/ko.d.ts.map +1 -1
  38. package/dist/i18n/locales/ko.js +1 -0
  39. package/dist/i18n/locales/ko.js.map +1 -1
  40. package/dist/i18n/locales/nl.d.ts.map +1 -1
  41. package/dist/i18n/locales/nl.js +1 -0
  42. package/dist/i18n/locales/nl.js.map +1 -1
  43. package/dist/i18n/locales/pl.d.ts.map +1 -1
  44. package/dist/i18n/locales/pl.js +1 -0
  45. package/dist/i18n/locales/pl.js.map +1 -1
  46. package/dist/i18n/locales/pt.d.ts.map +1 -1
  47. package/dist/i18n/locales/pt.js +1 -0
  48. package/dist/i18n/locales/pt.js.map +1 -1
  49. package/dist/i18n/locales/ru.d.ts.map +1 -1
  50. package/dist/i18n/locales/ru.js +1 -0
  51. package/dist/i18n/locales/ru.js.map +1 -1
  52. package/dist/i18n/locales/th.d.ts.map +1 -1
  53. package/dist/i18n/locales/th.js +1 -0
  54. package/dist/i18n/locales/th.js.map +1 -1
  55. package/dist/i18n/locales/tr.d.ts.map +1 -1
  56. package/dist/i18n/locales/tr.js +1 -0
  57. package/dist/i18n/locales/tr.js.map +1 -1
  58. package/dist/i18n/locales/uk.d.ts.map +1 -1
  59. package/dist/i18n/locales/uk.js +1 -0
  60. package/dist/i18n/locales/uk.js.map +1 -1
  61. package/dist/i18n/locales/vi.d.ts.map +1 -1
  62. package/dist/i18n/locales/vi.js +1 -0
  63. package/dist/i18n/locales/vi.js.map +1 -1
  64. package/dist/i18n/locales/zh-CN.d.ts.map +1 -1
  65. package/dist/i18n/locales/zh-CN.js +1 -0
  66. package/dist/i18n/locales/zh-CN.js.map +1 -1
  67. package/dist/i18n/locales/zh-TW.d.ts.map +1 -1
  68. package/dist/i18n/locales/zh-TW.js +1 -0
  69. package/dist/i18n/locales/zh-TW.js.map +1 -1
  70. package/dist/memory/memory-manager.d.ts +32 -0
  71. package/dist/memory/memory-manager.d.ts.map +1 -1
  72. package/dist/memory/memory-manager.js +165 -16
  73. package/dist/memory/memory-manager.js.map +1 -1
  74. package/dist/memory/mode-recall.d.ts.map +1 -1
  75. package/dist/memory/mode-recall.js +7 -0
  76. package/dist/memory/mode-recall.js.map +1 -1
  77. package/dist/memory/project-brain.d.ts.map +1 -1
  78. package/dist/memory/project-brain.js +71 -12
  79. package/dist/memory/project-brain.js.map +1 -1
  80. package/dist/memory/types.d.ts +23 -3
  81. package/dist/memory/types.d.ts.map +1 -1
  82. package/dist/memory/types.js +2 -2
  83. package/dist/memory/types.js.map +1 -1
  84. package/dist/tools/memory-recall.js +2 -2
  85. package/dist/tools/memory-recall.js.map +1 -1
  86. package/dist/tools/memory-save.d.ts.map +1 -1
  87. package/dist/tools/memory-save.js +3 -1
  88. package/dist/tools/memory-save.js.map +1 -1
  89. package/package.json +1 -1
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Repairing a conversation the provider has refused.
3
+ *
4
+ * A 400 from a model is usually a complaint about the HISTORY, not about the
5
+ * message just sent. That distinction is the whole problem: the user types
6
+ * something new, we replay the same malformed history behind it, and it fails
7
+ * identically. Every time. Forever. The only escape is starting a new chat,
8
+ * which throws away everything the conversation knew.
9
+ *
10
+ * On 2026-10-16 a DeepSeek thinking-mode conversation died exactly this way
11
+ * mid-stream, and the error text even said "that's ours to fix — try again",
12
+ * which was the one thing that could not work.
13
+ *
14
+ * So: when the provider names a structural fault, fix that fault in the
15
+ * history and send it once more.
16
+ *
17
+ * THREE RULES, and they matter more than the repairs themselves.
18
+ *
19
+ * 1. STRUCTURAL ONLY. A repair may change the SHAPE of the history, never its
20
+ * meaning. Dropping a tool call with no result is a repair. Dropping
21
+ * something the user said is data loss wearing a repair's clothes, and no
22
+ * provider complaint justifies it.
23
+ *
24
+ * 2. ONCE, AND NEVER THE SAME WAY TWICE. One retry per turn. If the second
25
+ * attempt fails with the same complaint, the repair did not take — stop and
26
+ * surface it. The difference between a self-healing system and one that
27
+ * burns an allowance in a circle is this rule.
28
+ *
29
+ * 3. SAY SO. A silent repair hides the bug that caused it. The DeepSeek fault
30
+ * above would have been absorbed invisibly and the two contradicting files
31
+ * that caused it would still be contradicting each other. Recovering is
32
+ * good; recovering quietly is how a product rots without anyone noticing.
33
+ */
34
+ import { logger } from '../core/logger.js';
35
+ /** Does this look like an assistant turn that asked for tools? */
36
+ function hasToolCalls(m) {
37
+ return m.role === 'assistant'
38
+ && Array.isArray(m.tool_calls)
39
+ && (m.tool_calls?.length ?? 0) > 0;
40
+ }
41
+ /**
42
+ * Pick a repair for what the provider actually said.
43
+ *
44
+ * Deliberately narrow. An unrecognised complaint gets no repair at all, which
45
+ * is correct: guessing at a fault we do not understand is how a "fix" deletes
46
+ * someone's conversation. Unknown stays unknown, and the error surfaces.
47
+ */
48
+ export function repairHistory(detail, messages) {
49
+ const d = (detail || '').toLowerCase();
50
+ // ── DeepSeek thinking mode: the reasoning must come back with the turn ──
51
+ // The field is stripped on the way out for every other provider, which is
52
+ // right for them and exactly wrong here.
53
+ if (d.includes('reasoning_content') && (d.includes('must be passed back') || d.includes('thinking mode'))) {
54
+ // We cannot invent reasoning we no longer hold. What we CAN do is remove
55
+ // the tool-call turns that are missing it, along with their results, so
56
+ // the conversation continues without the fragment the model objects to.
57
+ const keep = [];
58
+ let removed = 0;
59
+ for (let i = 0; i < messages.length; i++) {
60
+ const m = messages[i];
61
+ const rc = m.reasoning_content;
62
+ if (hasToolCalls(m) && (typeof rc !== 'string' || rc.length === 0)) {
63
+ const ids = new Set((m.tool_calls ?? []).map(c => c.id));
64
+ removed++;
65
+ // Its results go with it, or they become orphans and the next
66
+ // complaint is about those instead.
67
+ while (i + 1 < messages.length
68
+ && messages[i + 1].role === 'tool'
69
+ && ids.has(messages[i + 1].tool_call_id ?? '')) {
70
+ i++;
71
+ }
72
+ continue;
73
+ }
74
+ keep.push(m);
75
+ }
76
+ if (removed === 0)
77
+ return null;
78
+ return {
79
+ kind: 'reasoning-reattach',
80
+ summary: `dropped ${removed} tool exchange${removed === 1 ? '' : 's'} this model will not accept without its own reasoning`,
81
+ messages: keep,
82
+ };
83
+ }
84
+ // ── A tool call with no result, or a result with no call ────────────────
85
+ // Providers describe this a dozen ways; the shape is always the same.
86
+ if (d.includes('tool_call') || d.includes('tool call') || d.includes('last role')
87
+ || d.includes('invalid_request_message_order') || d.includes('tool_call_id')) {
88
+ const ids = new Set();
89
+ for (const m of messages) {
90
+ if (hasToolCalls(m))
91
+ for (const c of m.tool_calls ?? [])
92
+ ids.add(c.id);
93
+ }
94
+ // Orphan results first — they are the safer of the two to lose.
95
+ const withoutOrphans = messages.filter(m => m.role !== 'tool' || ids.has(m.tool_call_id ?? ''));
96
+ if (withoutOrphans.length !== messages.length) {
97
+ return {
98
+ kind: 'drop-orphan-tool-results',
99
+ summary: `dropped ${messages.length - withoutOrphans.length} tool result${messages.length - withoutOrphans.length === 1 ? '' : 's'} whose call was no longer in the conversation`,
100
+ messages: withoutOrphans,
101
+ };
102
+ }
103
+ // Then a trailing call that never got answered.
104
+ const answered = new Set();
105
+ for (const m of messages) {
106
+ if (m.role === 'tool')
107
+ answered.add(m.tool_call_id ?? '');
108
+ }
109
+ const keep = messages.filter(m => !(hasToolCalls(m) && (m.tool_calls ?? []).every(c => !answered.has(c.id))));
110
+ if (keep.length !== messages.length) {
111
+ return {
112
+ kind: 'drop-dangling-tool-calls',
113
+ summary: `dropped ${messages.length - keep.length} tool call${messages.length - keep.length === 1 ? '' : 's'} that never returned a result`,
114
+ messages: keep,
115
+ };
116
+ }
117
+ }
118
+ return null;
119
+ }
120
+ /** Log a repair the same way everywhere, so these are greppable in the wild. */
121
+ export function logRepair(repair, attempt) {
122
+ logger.warn(`[agent] history repair (${repair.kind}, attempt ${attempt}): ${repair.summary}`);
123
+ }
124
+ //# sourceMappingURL=repair-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repair-history.js","sourceRoot":"","sources":["../../src/agent/repair-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAG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CAAC,MAAM,aAAa,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,+BAA+B;gBAC3I,QAAQ,EAAE,IAAI;aACf,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,SAAS,CAAC,MAAqB,EAAE,OAAe;IAC9D,MAAM,CAAC,IAAI,CAAC,2BAA2B,MAAM,CAAC,IAAI,aAAa,OAAO,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AAChG,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ar.d.ts","sourceRoot":"","sources":["../../../src/i18n/locales/ar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,sEAAsE;AACtE,eAAO,MAAM,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAmtIxD,CAAC"}
1
+ {"version":3,"file":"ar.d.ts","sourceRoot":"","sources":["../../../src/i18n/locales/ar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,sEAAsE;AACtE,eAAO,MAAM,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAotIxD,CAAC"}
@@ -155,6 +155,7 @@ export const arStrings = {
155
155
  'compression.nothing': 'لا يوجد شيء لضغطه.',
156
156
  'compression.failed': 'فشل الضغط.',
157
157
  'compression.busy': 'لا يمكن الضغط أثناء عمل Ava.',
158
+ 'conversation.repaired': 'رفض النموذج هذه المحادثة، لذا أصلحتها وواصلت.',
158
159
  'compression.context_truncated': 'تم اقتطاع السياق: تم حذف {count} رسائل.',
159
160
  // ── Continue ──────────────────────────────────────────────────────────────
160
161
  'continue.prompt': 'تابع من حيث توقفت.',