@project-ava-supernova/core 0.2.184 → 0.2.185

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 (83) hide show
  1. package/dist/agent/agent.d.ts.map +1 -1
  2. package/dist/agent/agent.js +4 -0
  3. package/dist/agent/agent.js.map +1 -1
  4. package/dist/agent/system-prompt.d.ts +6 -0
  5. package/dist/agent/system-prompt.d.ts.map +1 -1
  6. package/dist/agent/system-prompt.js +3 -1
  7. package/dist/agent/system-prompt.js.map +1 -1
  8. package/dist/index.d.ts +7 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +5 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/memory-v4/consolidate.d.ts +44 -0
  13. package/dist/memory-v4/consolidate.d.ts.map +1 -0
  14. package/dist/memory-v4/consolidate.js +241 -0
  15. package/dist/memory-v4/consolidate.js.map +1 -0
  16. package/dist/memory-v4/fact-cache.d.ts +38 -0
  17. package/dist/memory-v4/fact-cache.d.ts.map +1 -0
  18. package/dist/memory-v4/fact-cache.js +133 -0
  19. package/dist/memory-v4/fact-cache.js.map +1 -0
  20. package/dist/memory-v4/fact-file.d.ts +30 -0
  21. package/dist/memory-v4/fact-file.d.ts.map +1 -0
  22. package/dist/memory-v4/fact-file.js +133 -0
  23. package/dist/memory-v4/fact-file.js.map +1 -0
  24. package/dist/memory-v4/files.d.ts +30 -0
  25. package/dist/memory-v4/files.d.ts.map +1 -0
  26. package/dist/memory-v4/files.js +115 -0
  27. package/dist/memory-v4/files.js.map +1 -0
  28. package/dist/memory-v4/import-v3.d.ts +38 -0
  29. package/dist/memory-v4/import-v3.d.ts.map +1 -0
  30. package/dist/memory-v4/import-v3.js +148 -0
  31. package/dist/memory-v4/import-v3.js.map +1 -0
  32. package/dist/memory-v4/index.d.ts +20 -0
  33. package/dist/memory-v4/index.d.ts.map +1 -0
  34. package/dist/memory-v4/index.js +14 -0
  35. package/dist/memory-v4/index.js.map +1 -0
  36. package/dist/memory-v4/model.d.ts +26 -0
  37. package/dist/memory-v4/model.d.ts.map +1 -0
  38. package/dist/memory-v4/model.js +49 -0
  39. package/dist/memory-v4/model.js.map +1 -0
  40. package/dist/memory-v4/page.d.ts +57 -0
  41. package/dist/memory-v4/page.d.ts.map +1 -0
  42. package/dist/memory-v4/page.js +150 -0
  43. package/dist/memory-v4/page.js.map +1 -0
  44. package/dist/memory-v4/projects.d.ts +38 -0
  45. package/dist/memory-v4/projects.d.ts.map +1 -0
  46. package/dist/memory-v4/projects.js +135 -0
  47. package/dist/memory-v4/projects.js.map +1 -0
  48. package/dist/memory-v4/promotion.d.ts +17 -0
  49. package/dist/memory-v4/promotion.d.ts.map +1 -0
  50. package/dist/memory-v4/promotion.js +50 -0
  51. package/dist/memory-v4/promotion.js.map +1 -0
  52. package/dist/memory-v4/reader.d.ts +83 -0
  53. package/dist/memory-v4/reader.d.ts.map +1 -0
  54. package/dist/memory-v4/reader.js +270 -0
  55. package/dist/memory-v4/reader.js.map +1 -0
  56. package/dist/memory-v4/search-index.d.ts +43 -0
  57. package/dist/memory-v4/search-index.d.ts.map +1 -0
  58. package/dist/memory-v4/search-index.js +147 -0
  59. package/dist/memory-v4/search-index.js.map +1 -0
  60. package/dist/memory-v4/store.d.ts +168 -0
  61. package/dist/memory-v4/store.d.ts.map +1 -0
  62. package/dist/memory-v4/store.js +549 -0
  63. package/dist/memory-v4/store.js.map +1 -0
  64. package/dist/memory-v4/threads-episodes.d.ts +36 -0
  65. package/dist/memory-v4/threads-episodes.d.ts.map +1 -0
  66. package/dist/memory-v4/threads-episodes.js +119 -0
  67. package/dist/memory-v4/threads-episodes.js.map +1 -0
  68. package/dist/memory-v4/types.d.ts +84 -0
  69. package/dist/memory-v4/types.d.ts.map +1 -0
  70. package/dist/memory-v4/types.js +14 -0
  71. package/dist/memory-v4/types.js.map +1 -0
  72. package/dist/tools/learning.d.ts.map +1 -1
  73. package/dist/tools/learning.js +9 -3
  74. package/dist/tools/learning.js.map +1 -1
  75. package/dist/tools/memory-recall-v4.d.ts +20 -0
  76. package/dist/tools/memory-recall-v4.d.ts.map +1 -0
  77. package/dist/tools/memory-recall-v4.js +49 -0
  78. package/dist/tools/memory-recall-v4.js.map +1 -0
  79. package/dist/tools/memory-write-v4.d.ts +40 -0
  80. package/dist/tools/memory-write-v4.d.ts.map +1 -0
  81. package/dist/tools/memory-write-v4.js +176 -0
  82. package/dist/tools/memory-write-v4.js.map +1 -0
  83. package/package.json +1 -1
@@ -0,0 +1,49 @@
1
+ /**
2
+ * memory_recall over memory v4. Same name as the old tool, so prompts and
3
+ * mode allowlists are unchanged; a surface using v4 registers this one in
4
+ * its place and puts the session in sharedState.memorySession.
5
+ *
6
+ * The app already adds the most relevant memories to each message, so this
7
+ * is for deliberate searches: a different wording, another project, every
8
+ * project, or what happened on a day.
9
+ */
10
+ export class MemoryRecallV4Tool {
11
+ name = 'memory_recall';
12
+ description = 'Search long-term memory about the person and their projects: facts, preferences, decisions, and what happened on a given day.';
13
+ riskLevel = 'safe';
14
+ requiresConfirmation = false;
15
+ schema = {
16
+ name: 'memory_recall',
17
+ description: 'Search your long-term memory. The most relevant memories are already added to each message; call this before ever saying you don\'t know or don\'t remember something about them or their work. ' +
18
+ 'By default it searches facts about them and the open project. Set "project" to search another project by name, "reach":"all" for every project, or "date" (YYYY-MM-DD) to read what happened that day.',
19
+ parameters: {
20
+ type: 'object',
21
+ properties: {
22
+ query: { type: 'string', description: 'What to look for, in plain words. Try other words if the first search finds nothing.' },
23
+ project: { type: 'string', description: 'Another project to search, by its name (optional).' },
24
+ reach: { type: 'string', enum: ['here', 'linked', 'all'], description: '"here" (default): about them + the open project. "linked": also connected projects. "all": every project.' },
25
+ date: { type: 'string', description: 'A day to read, YYYY-MM-DD (optional). Still give a short query saying what you want from that day.' },
26
+ },
27
+ required: ['query'],
28
+ },
29
+ };
30
+ async execute(args, context) {
31
+ const session = context.sharedState?.memorySession;
32
+ if (!session)
33
+ return { success: false, output: 'Memory is not available in this context.' };
34
+ const reach = args.reach === 'linked' || args.reach === 'all' || args.reach === 'here' ? args.reach : undefined;
35
+ try {
36
+ const output = await session.recall({
37
+ query: typeof args.query === 'string' ? args.query : undefined,
38
+ project: typeof args.project === 'string' && args.project.trim() ? args.project.trim() : undefined,
39
+ reach,
40
+ date: typeof args.date === 'string' && args.date.trim() ? args.date.trim() : undefined,
41
+ });
42
+ return { success: true, output };
43
+ }
44
+ catch (err) {
45
+ return { success: false, output: `Memory search failed: ${err instanceof Error ? err.message : String(err)}` };
46
+ }
47
+ }
48
+ }
49
+ //# sourceMappingURL=memory-recall-v4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-recall-v4.js","sourceRoot":"","sources":["../../src/tools/memory-recall-v4.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAAkB;IACpB,IAAI,GAAG,eAAe,CAAC;IACvB,WAAW,GAAG,+HAA+H,CAAC;IAC9I,SAAS,GAAkB,MAAM,CAAC;IAClC,oBAAoB,GAAG,KAAK,CAAC;IAE7B,MAAM,GAAmB;QAChC,IAAI,EAAE,eAAe;QACrB,WAAW,EACT,kMAAkM;YAClM,wMAAwM;QAC1M,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sFAAsF,EAAE;gBAC9H,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,oDAAoD,EAAE;gBAC9F,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,WAAW,EAAE,2GAA2G,EAAE;gBACpL,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,oGAAoG,EAAE;aAC5I;YACD,QAAQ,EAAE,CAAC,OAAO,CAAC;SACpB;KACF,CA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G,CAAC,EAAE,EAAE,CAAC;QACjH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * memory_save / memory_update / memory_delete over memory v4.
3
+ *
4
+ * Same names as the old tools, so prompts and mode allowlists are unchanged; a
5
+ * surface using v4 registers these in their place (with MemoryRecallV4Tool).
6
+ *
7
+ * The rules they carry:
8
+ * - What the person SAID is saved at once, with their words.
9
+ * - What Ava NOTICED waits on the Memory page for their yes (decided
10
+ * 15 Nov: never asked mid-conversation).
11
+ * - A change in the world replaces the fact; the old one becomes history.
12
+ * - Never credentials.
13
+ */
14
+ import type { Tool, ToolResult, ToolExecutionContext, ToolRiskLevel } from './types.js';
15
+ import type { FunctionSchema } from '../providers/types.js';
16
+ export declare class MemorySaveV4Tool implements Tool {
17
+ readonly name = "memory_save";
18
+ readonly description = "Remember something about the person or their project for future conversations, or note something still to come back to.";
19
+ readonly riskLevel: ToolRiskLevel;
20
+ readonly requiresConfirmation = false;
21
+ readonly schema: FunctionSchema;
22
+ execute(args: Record<string, unknown>, context: ToolExecutionContext): Promise<ToolResult>;
23
+ }
24
+ export declare class MemoryUpdateV4Tool implements Tool {
25
+ readonly name = "memory_update";
26
+ readonly description = "Change a remembered fact when it has changed, fix its wording, or mark an open thread done.";
27
+ readonly riskLevel: ToolRiskLevel;
28
+ readonly requiresConfirmation = false;
29
+ readonly schema: FunctionSchema;
30
+ execute(args: Record<string, unknown>, context: ToolExecutionContext): Promise<ToolResult>;
31
+ }
32
+ export declare class MemoryDeleteV4Tool implements Tool {
33
+ readonly name = "memory_delete";
34
+ readonly description = "Delete a remembered fact or thread completely.";
35
+ readonly riskLevel: ToolRiskLevel;
36
+ readonly requiresConfirmation = false;
37
+ readonly schema: FunctionSchema;
38
+ execute(args: Record<string, unknown>, context: ToolExecutionContext): Promise<ToolResult>;
39
+ }
40
+ //# sourceMappingURL=memory-write-v4.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-write-v4.d.ts","source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AC,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC;CASjG"}
@@ -0,0 +1,176 @@
1
+ /**
2
+ * memory_save / memory_update / memory_delete over memory v4.
3
+ *
4
+ * Same names as the old tools, so prompts and mode allowlists are unchanged; a
5
+ * surface using v4 registers these in their place (with MemoryRecallV4Tool).
6
+ *
7
+ * The rules they carry:
8
+ * - What the person SAID is saved at once, with their words.
9
+ * - What Ava NOTICED waits on the Memory page for their yes (decided
10
+ * 15 Nov: never asked mid-conversation).
11
+ * - A change in the world replaces the fact; the old one becomes history.
12
+ * - Never credentials.
13
+ */
14
+ import { FACT_KINDS } from '../memory-v4/types.js';
15
+ import { containsCredentials } from './security.js';
16
+ import { suggestPromotion } from '../memory-v4/promotion.js';
17
+ const BLOCKED = 'Blocked: that looks like a key, token or password. Those never go in memory; keep them in the keychain or an environment variable.';
18
+ function sessionOf(context) {
19
+ return context.sharedState?.memorySession;
20
+ }
21
+ function scopeFor(session, scope) {
22
+ return scope === 'project' && session.project ? `project:${session.project.id}` : 'everywhere';
23
+ }
24
+ export class MemorySaveV4Tool {
25
+ name = 'memory_save';
26
+ description = 'Remember something about the person or their project for future conversations, or note something still to come back to.';
27
+ riskLevel = 'safe';
28
+ requiresConfirmation = false;
29
+ schema = {
30
+ name: 'memory_save',
31
+ description: 'Save one durable fact to long-term memory, or an open thread to come back to. ' +
32
+ 'Save what will change future help: who they are, how they like to work, decisions and their reasons, project facts that cost time to rediscover. ' +
33
+ 'Not passing moods, not chit-chat, not what is already in the code or the Decisions folder. One fact per call, in plain words. ' +
34
+ 'If they TOLD you, use source "said" and put their exact words in quote; it is saved at once. ' +
35
+ 'If you NOTICED or inferred it, use source "noticed"; it waits on their Memory page for a yes, so do not ask them about it in the chat. ' +
36
+ 'If a fact they already have has CHANGED, use memory_update on it instead. NEVER save keys, tokens or passwords.',
37
+ parameters: {
38
+ type: 'object',
39
+ properties: {
40
+ content: { type: 'string', description: 'The fact (or thread) in one or two plain sentences, with its specifics.' },
41
+ scope: { type: 'string', enum: ['everywhere', 'project'], description: '"everywhere": about them or how they work (follows them into every project). "project": true only for the open project.' },
42
+ kind: { type: 'string', enum: [...FACT_KINDS, 'thread'], description: 'person, preference, rule (how to work with them), project, event; or thread for something still to come back to.' },
43
+ source: { type: 'string', enum: ['said', 'noticed'], description: '"said": they told you (saved now). "noticed": you inferred it (waits for their yes).' },
44
+ quote: { type: 'string', description: 'Their own words that STATE the fact, copied exactly (e.g. "im not a great fan of bold"). Not their request to save it ("save that please"), and not your words. Leave it out if they only asked you to remember something you said.' },
45
+ due: { type: 'string', description: 'For a thread with a date: YYYY-MM-DD.' },
46
+ },
47
+ required: ['content', 'scope', 'source'],
48
+ },
49
+ };
50
+ async execute(args, context) {
51
+ const session = sessionOf(context);
52
+ if (!session)
53
+ return { success: false, output: 'Memory is not available in this context.' };
54
+ const content = String(args.content ?? '').trim();
55
+ if (!content)
56
+ return { success: false, output: 'Say what to remember (content).' };
57
+ if (containsCredentials(content) || containsCredentials(String(args.quote ?? '')))
58
+ return { success: false, output: BLOCKED };
59
+ const scope = scopeFor(session, args.scope);
60
+ if (args.kind === 'thread') {
61
+ const due = typeof args.due === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(args.due) ? args.due : undefined;
62
+ const thread = await session.mem.addThread({ text: content, project: scope === 'everywhere' ? undefined : session.project?.id, due });
63
+ return { success: true, output: `Open thread noted [${thread.id}]${due ? `, due ${due}` : ''}. It stays until it is done.` };
64
+ }
65
+ const kind = FACT_KINDS.includes(args.kind) ? args.kind : undefined;
66
+ const said = args.source === 'said';
67
+ // A request to save ("save that please") is not their words stating the fact.
68
+ const rawQuote = typeof args.quote === 'string' ? args.quote.trim() : '';
69
+ const quote = rawQuote && !/^(can you |could you |please )?(save|remember|note|store|log)\b|\b(save|remember) (that|this|it)\b/i.test(rawQuote) ? rawQuote : undefined;
70
+ const { fact, created } = await session.mem.addFact({
71
+ text: content,
72
+ kind,
73
+ scope,
74
+ source: said ? 'said' : 'inferred',
75
+ quote: said ? quote : undefined,
76
+ });
77
+ if (!created)
78
+ return { success: true, output: `Already remembered [${fact.id}].` };
79
+ // The same lesson in another project: suggest it, on the Memory page, as how they always work.
80
+ await suggestPromotion(session.mem, fact);
81
+ return {
82
+ success: true,
83
+ output: fact.state === 'pending'
84
+ ? `Noted for their yes on the Memory page [${fact.id}]. Do not ask them about it now.`
85
+ : `Remembered [${fact.id}]${scope === 'everywhere' ? '' : ` for ${session.project?.name ?? 'this project'}`}.`,
86
+ };
87
+ }
88
+ }
89
+ export class MemoryUpdateV4Tool {
90
+ name = 'memory_update';
91
+ description = 'Change a remembered fact when it has changed, fix its wording, or mark an open thread done.';
92
+ riskLevel = 'safe';
93
+ requiresConfirmation = false;
94
+ schema = {
95
+ name: 'memory_update',
96
+ description: 'Update a remembered fact by its id (the [id] shown in memories and recall results). ' +
97
+ 'Use "changed" when something changed in the world (they moved, the plan changed): the old version is kept as history, marked until today. ' +
98
+ 'Use "correction" only to fix wrong wording of the same fact. Set done:true to close an open thread.',
99
+ parameters: {
100
+ type: 'object',
101
+ properties: {
102
+ id: { type: 'string', description: 'The fact or thread id.' },
103
+ content: { type: 'string', description: 'The new fact, in plain words (not needed with done).' },
104
+ change: { type: 'string', enum: ['changed', 'correction'], description: 'Default "changed".' },
105
+ quote: { type: 'string', description: 'Their exact words, if they told you the change.' },
106
+ done: { type: 'boolean', description: 'Close an open thread.' },
107
+ },
108
+ required: ['id'],
109
+ },
110
+ };
111
+ async execute(args, context) {
112
+ const session = sessionOf(context);
113
+ if (!session)
114
+ return { success: false, output: 'Memory is not available in this context.' };
115
+ const id = String(args.id ?? '').replace(/^\[|\]$/g, '').trim();
116
+ if (!id)
117
+ return { success: false, output: 'Give the id of the memory to update.' };
118
+ if (args.done === true) {
119
+ return (await session.mem.closeThread(id))
120
+ ? { success: true, output: `Thread [${id}] closed.` }
121
+ : { success: false, output: `No open thread [${id}].` };
122
+ }
123
+ const content = String(args.content ?? '').trim();
124
+ if (!content)
125
+ return { success: false, output: 'Give the new content (or done:true for a thread).' };
126
+ if (containsCredentials(content))
127
+ return { success: false, output: BLOCKED };
128
+ if (args.change === 'correction') {
129
+ const fixed = await session.mem.editFact(id, { text: content });
130
+ return fixed ? { success: true, output: `Corrected [${id}].` } : { success: false, output: `No memory [${id}].` };
131
+ }
132
+ const quote = typeof args.quote === 'string' && args.quote.trim() ? args.quote.trim() : undefined;
133
+ const current = await session.mem.getFact(id);
134
+ if (!current || current.state !== 'fact')
135
+ return { success: false, output: `No current memory [${id}].` };
136
+ if (!quote) {
137
+ // Noticed, not told: the new version waits for their yes, and the old
138
+ // one stays current until then.
139
+ const { fact } = await session.mem.addFact({ text: content, kind: current.kind, scope: current.scope, source: 'inferred', replaces: id });
140
+ return { success: true, output: `The change waits for their yes on the Memory page [${fact.id}]; [${id}] stays current until then. Do not ask them about it now.` };
141
+ }
142
+ const res = await session.mem.replaceFact(id, { text: content, source: 'said', quote });
143
+ if (!res)
144
+ return { success: false, output: `No current memory [${id}].` };
145
+ return { success: true, output: `Updated [${res.fact.id}]; the old version is kept as history, true until today.` };
146
+ }
147
+ }
148
+ export class MemoryDeleteV4Tool {
149
+ name = 'memory_delete';
150
+ description = 'Delete a remembered fact or thread completely.';
151
+ riskLevel = 'safe';
152
+ requiresConfirmation = false;
153
+ schema = {
154
+ name: 'memory_delete',
155
+ description: 'Delete a memory by id when they ask you to forget it, or it was never true. It is gone completely: from memory, search and history. For something that merely changed, use memory_update instead.',
156
+ parameters: {
157
+ type: 'object',
158
+ properties: { id: { type: 'string', description: 'The fact or thread id.' } },
159
+ required: ['id'],
160
+ },
161
+ };
162
+ async execute(args, context) {
163
+ const session = sessionOf(context);
164
+ if (!session)
165
+ return { success: false, output: 'Memory is not available in this context.' };
166
+ const id = String(args.id ?? '').replace(/^\[|\]$/g, '').trim();
167
+ if (!id)
168
+ return { success: false, output: 'Give the id of the memory to delete.' };
169
+ if (await session.mem.deleteFact(id))
170
+ return { success: true, output: `Forgotten [${id}].` };
171
+ if (await session.mem.deleteThread(id))
172
+ return { success: true, output: `Thread [${id}] deleted.` };
173
+ return { success: false, output: `No memory [${id}].` };
174
+ }
175
+ }
176
+ //# sourceMappingURL=memory-write-v4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-write-v4.js","sourceRoot":"","sources":["../../src/tools/memory-write-v4.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,OAAO,GAAG,oIAAoI,CAAC;AAErJ,SAAS,SAAS,CAAC,OAA6B;IAC9C,OAAO,OAAO,CAAC,WAAW,EAAE,aAA0C,CAAC;AACzE,CAAC;AAED,SAAS,QAAQ,CAAC,OAAsB,EAAE,KAAc;IACtD,OAAO,KAAK,KAAK,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC;AACjG,CAAC;AAED,MAAM,OAAO,gBAAgB;IAClB,IAAI,GAAG,aAAa,CAAC;IACrB,WAAW,GAAG,yHAAyH,CAAC;IACxI,SAAS,GAAkB,MAAM,CAAC;IAClC,oBAAoB,GAAG,KAAK,CAAC;IAE7B,MAAM,GAAmB;QAChC,IAAI,EAAE,aAAa;QACnB,WAAW,EACT,gFAAgF;YAChF,mJAAmJ;YACnJ,gIAAgI;YAChI,+FAA+F;YAC/F,yIAAyI;YACzI,iHAAiH;QACnH,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yEAAyE,EAAE;gBACnH,KAAK,EAAE,EAAE,IAAI,EAAE,QA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M,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAChE,IAAI,CAAC,EAAE;YAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,sCAAsC,EAAE,CAAC;QACnF,IAAI,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;QAC7F,IAAI,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;YAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;QACpG,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC;IAC1D,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@project-ava-supernova/core",
3
- "version": "0.2.184",
3
+ "version": "0.2.185",
4
4
  "description": "Core engine for Ava Supernova — agent, providers, tools, config",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",