@miller-tech/uap 1.10.0 → 1.11.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/.tsbuildinfo +1 -1
- package/dist/benchmarks/benchmark.d.ts +14 -14
- package/dist/bin/cli.js +5 -0
- package/dist/bin/cli.js.map +1 -1
- package/dist/bin/llama-server-optimize.js +0 -0
- package/dist/bin/policy.js +0 -0
- package/dist/cli/task.d.ts +1 -1
- package/dist/cli/task.d.ts.map +1 -1
- package/dist/cli/task.js +65 -0
- package/dist/cli/task.js.map +1 -1
- package/dist/dashboard/data-service.d.ts +10 -0
- package/dist/dashboard/data-service.d.ts.map +1 -1
- package/dist/dashboard/data-service.js +22 -1
- package/dist/dashboard/data-service.js.map +1 -1
- package/dist/dashboard/server.d.ts.map +1 -1
- package/dist/dashboard/server.js +51 -5
- package/dist/dashboard/server.js.map +1 -1
- package/dist/models/profile-loader.d.ts +1 -1
- package/dist/models/types.d.ts +45 -45
- package/dist/policies/schemas/policy.d.ts +5 -5
- package/dist/tasks/types.d.ts +22 -22
- package/dist/types/config.d.ts +170 -170
- package/dist/types/coordination.d.ts +22 -22
- package/dist/uap-droids-strict.d.ts +4 -4
- package/package.json +1 -1
- package/scripts/maintenance/verify-compliance.sh +12 -12
- package/templates/hooks/session-start.sh +1 -1
- package/dist/bin/tool-calls.d.ts +0 -3
- package/dist/bin/tool-calls.d.ts.map +0 -1
- package/dist/bin/tool-calls.js +0 -4
- package/dist/bin/tool-calls.js.map +0 -1
- package/dist/cli/completion-gates.d.ts +0 -51
- package/dist/cli/completion-gates.d.ts.map +0 -1
- package/dist/cli/completion-gates.js +0 -201
- package/dist/cli/completion-gates.js.map +0 -1
- package/dist/cli/rtk-validation.d.ts +0 -24
- package/dist/cli/rtk-validation.d.ts.map +0 -1
- package/dist/cli/rtk-validation.js +0 -138
- package/dist/cli/rtk-validation.js.map +0 -1
- package/dist/cli/uap.d.ts +0 -10
- package/dist/cli/uap.d.ts.map +0 -1
- package/dist/cli/uap.js +0 -457
- package/dist/cli/uap.js.map +0 -1
- package/dist/coordination/droid-validator.d.ts +0 -59
- package/dist/coordination/droid-validator.d.ts.map +0 -1
- package/dist/coordination/droid-validator.js +0 -142
- package/dist/coordination/droid-validator.js.map +0 -1
- package/dist/coordination/worktree-enforcer.d.ts +0 -22
- package/dist/coordination/worktree-enforcer.d.ts.map +0 -1
- package/dist/coordination/worktree-enforcer.js +0 -71
- package/dist/coordination/worktree-enforcer.js.map +0 -1
- package/dist/generators/template-loader.d.ts +0 -105
- package/dist/generators/template-loader.d.ts.map +0 -1
- package/dist/generators/template-loader.js +0 -291
- package/dist/generators/template-loader.js.map +0 -1
- package/dist/memory/active-context.d.ts +0 -65
- package/dist/memory/active-context.d.ts.map +0 -1
- package/dist/memory/active-context.js +0 -126
- package/dist/memory/active-context.js.map +0 -1
- package/dist/memory/agent-scoped-memory.d.ts +0 -67
- package/dist/memory/agent-scoped-memory.d.ts.map +0 -1
- package/dist/memory/agent-scoped-memory.js +0 -126
- package/dist/memory/agent-scoped-memory.js.map +0 -1
- package/dist/memory/dedup-detector.d.ts +0 -57
- package/dist/memory/dedup-detector.d.ts.map +0 -1
- package/dist/memory/dedup-detector.js +0 -107
- package/dist/memory/dedup-detector.js.map +0 -1
- package/dist/memory/dedup-memory.d.ts +0 -89
- package/dist/memory/dedup-memory.d.ts.map +0 -1
- package/dist/memory/dedup-memory.js +0 -173
- package/dist/memory/dedup-memory.js.map +0 -1
- package/dist/memory/generic-uap-patterns.d.ts +0 -7
- package/dist/memory/generic-uap-patterns.d.ts.map +0 -1
- package/dist/memory/generic-uap-patterns.js +0 -43
- package/dist/memory/generic-uap-patterns.js.map +0 -1
- package/dist/memory/merge-claude-md.d.ts +0 -45
- package/dist/memory/merge-claude-md.d.ts.map +0 -1
- package/dist/memory/merge-claude-md.js +0 -118
- package/dist/memory/merge-claude-md.js.map +0 -1
- package/dist/memory/multi-view-memory.d.ts +0 -134
- package/dist/memory/multi-view-memory.d.ts.map +0 -1
- package/dist/memory/multi-view-memory.js +0 -430
- package/dist/memory/multi-view-memory.js.map +0 -1
- package/dist/memory/patterns.d.ts +0 -37
- package/dist/memory/patterns.d.ts.map +0 -1
- package/dist/memory/patterns.js +0 -81
- package/dist/memory/patterns.js.map +0 -1
- package/dist/memory/semantic-edge-graph.d.ts +0 -86
- package/dist/memory/semantic-edge-graph.d.ts.map +0 -1
- package/dist/memory/semantic-edge-graph.js +0 -168
- package/dist/memory/semantic-edge-graph.js.map +0 -1
- package/dist/memory/semantic-retrieval.d.ts +0 -70
- package/dist/memory/semantic-retrieval.d.ts.map +0 -1
- package/dist/memory/semantic-retrieval.js +0 -112
- package/dist/memory/semantic-retrieval.js.map +0 -1
- package/dist/memory/short-term/factory.d.ts +0 -26
- package/dist/memory/short-term/factory.d.ts.map +0 -1
- package/dist/memory/short-term/factory.js +0 -28
- package/dist/memory/short-term/factory.js.map +0 -1
- package/dist/memory/short-term/indexeddb.d.ts +0 -25
- package/dist/memory/short-term/indexeddb.d.ts.map +0 -1
- package/dist/memory/short-term/indexeddb.js +0 -64
- package/dist/memory/short-term/indexeddb.js.map +0 -1
- package/dist/memory/smart-consolidator.d.ts +0 -53
- package/dist/memory/smart-consolidator.d.ts.map +0 -1
- package/dist/memory/smart-consolidator.js +0 -144
- package/dist/memory/smart-consolidator.js.map +0 -1
- package/dist/memory/view-memory.d.ts +0 -80
- package/dist/memory/view-memory.d.ts.map +0 -1
- package/dist/memory/view-memory.js +0 -130
- package/dist/memory/view-memory.js.map +0 -1
- package/dist/memory/wrapped-memory.d.ts +0 -77
- package/dist/memory/wrapped-memory.d.ts.map +0 -1
- package/dist/memory/wrapped-memory.js +0 -127
- package/dist/memory/wrapped-memory.js.map +0 -1
- package/dist/models/api-client.d.ts +0 -46
- package/dist/models/api-client.d.ts.map +0 -1
- package/dist/models/api-client.js +0 -182
- package/dist/models/api-client.js.map +0 -1
- package/dist/utils/config-manager.d.ts +0 -30
- package/dist/utils/config-manager.d.ts.map +0 -1
- package/dist/utils/config-manager.js +0 -41
- package/dist/utils/config-manager.js.map +0 -1
- package/dist/utils/fetch-with-retry.d.ts +0 -5
- package/dist/utils/fetch-with-retry.d.ts.map +0 -1
- package/dist/utils/fetch-with-retry.js +0 -61
- package/dist/utils/fetch-with-retry.js.map +0 -1
- package/dist/utils/file-discovery.d.ts +0 -38
- package/dist/utils/file-discovery.d.ts.map +0 -1
- package/dist/utils/file-discovery.js +0 -100
- package/dist/utils/file-discovery.js.map +0 -1
- package/dist/utils/validate-json.d.ts +0 -51
- package/dist/utils/validate-json.d.ts.map +0 -1
- package/dist/utils/validate-json.js +0 -94
- package/dist/utils/validate-json.js.map +0 -1
- package/tools/agents/scripts/__pycache__/tool_call_wrapper.cpython-313.pyc +0 -0
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import Handlebars from 'handlebars';
|
|
2
|
-
import { existsSync, readFileSync, readdirSync } from 'fs';
|
|
3
|
-
import { join, dirname } from 'path';
|
|
4
|
-
import { fileURLToPath } from 'url';
|
|
5
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
-
const __dirname = dirname(__filename);
|
|
7
|
-
/**
|
|
8
|
-
* Default section definitions.
|
|
9
|
-
*/
|
|
10
|
-
export const DEFAULT_SECTIONS = [
|
|
11
|
-
{ id: 'header', file: 'header.hbs', required: true, tokenEstimate: 50 },
|
|
12
|
-
{ id: 'directives', file: 'directives.hbs', required: true, tokenEstimate: 200 },
|
|
13
|
-
{ id: 'session-start', file: 'session-start.hbs', required: true, tokenEstimate: 150 },
|
|
14
|
-
{ id: 'coordination', file: 'coordination.hbs', required: true, tokenEstimate: 400 },
|
|
15
|
-
{ id: 'decision-loop', file: 'decision-loop.hbs', required: true, tokenEstimate: 300 },
|
|
16
|
-
{ id: 'memory-system', file: 'memory-system.hbs', required: true, tokenEstimate: 500 },
|
|
17
|
-
{ id: 'worktree', file: 'worktree.hbs', required: true, tokenEstimate: 200 },
|
|
18
|
-
{ id: 'parallel-review', file: 'parallel-review.hbs', required: true, tokenEstimate: 250 },
|
|
19
|
-
{ id: 'triggers', file: 'triggers.hbs', required: true, tokenEstimate: 150 },
|
|
20
|
-
{
|
|
21
|
-
id: 'repository',
|
|
22
|
-
file: 'repository.hbs',
|
|
23
|
-
required: false,
|
|
24
|
-
condition: (a) => !!a.components?.length,
|
|
25
|
-
tokenEstimate: 300
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
id: 'architecture',
|
|
29
|
-
file: 'architecture.hbs',
|
|
30
|
-
required: false,
|
|
31
|
-
condition: (analysis) => !!analysis.infrastructure?.iac || analysis.components?.length > 3,
|
|
32
|
-
tokenEstimate: 400
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
id: 'components',
|
|
36
|
-
file: 'components.hbs',
|
|
37
|
-
required: false,
|
|
38
|
-
condition: (a) => (a.components?.length || 0) > 0,
|
|
39
|
-
tokenEstimate: 300
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
id: 'auth',
|
|
43
|
-
file: 'auth.hbs',
|
|
44
|
-
required: false,
|
|
45
|
-
condition: (a) => !!a.authentication,
|
|
46
|
-
tokenEstimate: 200
|
|
47
|
-
},
|
|
48
|
-
{ id: 'quick-reference', file: 'quick-reference.hbs', required: false, tokenEstimate: 250 },
|
|
49
|
-
{
|
|
50
|
-
id: 'skills-droids',
|
|
51
|
-
file: 'skills-droids.hbs',
|
|
52
|
-
required: false,
|
|
53
|
-
condition: () => existsSync(join(process.cwd(), '.factory/skills')) || existsSync(join(process.cwd(), '.factory/droids')),
|
|
54
|
-
tokenEstimate: 400
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: 'infrastructure',
|
|
58
|
-
file: 'infrastructure.hbs',
|
|
59
|
-
required: false,
|
|
60
|
-
condition: (analysis) => (analysis.directories?.infrastructure?.length || 0) > 0,
|
|
61
|
-
tokenEstimate: 300
|
|
62
|
-
},
|
|
63
|
-
{ id: 'testing', file: 'testing.hbs', required: false, tokenEstimate: 150 },
|
|
64
|
-
{
|
|
65
|
-
id: 'troubleshooting',
|
|
66
|
-
file: 'troubleshooting.hbs',
|
|
67
|
-
required: false,
|
|
68
|
-
condition: () => false, // Only include if explicitly requested
|
|
69
|
-
tokenEstimate: 300
|
|
70
|
-
},
|
|
71
|
-
{ id: 'config-files', file: 'config-files.hbs', required: false, tokenEstimate: 200 },
|
|
72
|
-
{ id: 'checklist', file: 'checklist.hbs', required: true, tokenEstimate: 100 },
|
|
73
|
-
{
|
|
74
|
-
id: 'knowledge',
|
|
75
|
-
file: 'knowledge.hbs',
|
|
76
|
-
required: false,
|
|
77
|
-
condition: () => false, // Only include if memory has content
|
|
78
|
-
tokenEstimate: 400
|
|
79
|
-
},
|
|
80
|
-
{ id: 'footer', file: 'footer.hbs', required: true, tokenEstimate: 20 },
|
|
81
|
-
];
|
|
82
|
-
/**
|
|
83
|
-
* Modular template loader with lazy-loading support.
|
|
84
|
-
*/
|
|
85
|
-
export class TemplateLoader {
|
|
86
|
-
sectionsDir;
|
|
87
|
-
maxTokens;
|
|
88
|
-
sections;
|
|
89
|
-
compiledSections;
|
|
90
|
-
analysis = null;
|
|
91
|
-
constructor(config = {}) {
|
|
92
|
-
this.sectionsDir = config.sectionsDir || this.findSectionsDir();
|
|
93
|
-
this.maxTokens = config.maxTokens || 8000; // Conservative default
|
|
94
|
-
this.sections = [...DEFAULT_SECTIONS];
|
|
95
|
-
this.compiledSections = new Map();
|
|
96
|
-
// Apply include/exclude filters
|
|
97
|
-
if (config.includeSections) {
|
|
98
|
-
this.sections = this.sections.filter(s => s.required || config.includeSections.includes(s.id));
|
|
99
|
-
}
|
|
100
|
-
if (config.excludeSections) {
|
|
101
|
-
this.sections = this.sections.filter(s => s.required || !config.excludeSections.includes(s.id));
|
|
102
|
-
}
|
|
103
|
-
if (config.forceInclude) {
|
|
104
|
-
for (const id of config.forceInclude) {
|
|
105
|
-
const existing = this.sections.find(s => s.id === id);
|
|
106
|
-
if (existing) {
|
|
107
|
-
existing.required = true;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
this.registerHelpers();
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Find the sections directory.
|
|
115
|
-
*/
|
|
116
|
-
findSectionsDir() {
|
|
117
|
-
const locations = [
|
|
118
|
-
join(process.cwd(), 'templates/sections'),
|
|
119
|
-
join(__dirname, '../../templates/sections'),
|
|
120
|
-
];
|
|
121
|
-
for (const loc of locations) {
|
|
122
|
-
if (existsSync(loc)) {
|
|
123
|
-
return loc;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
// Fall back to main template if no sections exist
|
|
127
|
-
return join(__dirname, '../../templates');
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Register Handlebars helpers.
|
|
131
|
-
*/
|
|
132
|
-
registerHelpers() {
|
|
133
|
-
// Conditional section helper
|
|
134
|
-
Handlebars.registerHelper('section', (sectionId, options) => {
|
|
135
|
-
const section = this.sections.find(s => s.id === sectionId);
|
|
136
|
-
if (!section)
|
|
137
|
-
return '';
|
|
138
|
-
if (!this.shouldIncludeSection(section)) {
|
|
139
|
-
return '';
|
|
140
|
-
}
|
|
141
|
-
return options.fn(this);
|
|
142
|
-
});
|
|
143
|
-
// Token budget helper
|
|
144
|
-
Handlebars.registerHelper('withinBudget', (tokens, options) => {
|
|
145
|
-
if (this.getRemainingTokenBudget() >= tokens) {
|
|
146
|
-
return options.fn(this);
|
|
147
|
-
}
|
|
148
|
-
return options.inverse(this);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Set the project analysis for conditional loading.
|
|
153
|
-
*/
|
|
154
|
-
setAnalysis(analysis) {
|
|
155
|
-
this.analysis = analysis;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Check if a section should be included based on conditions.
|
|
159
|
-
*/
|
|
160
|
-
shouldIncludeSection(section) {
|
|
161
|
-
if (section.required)
|
|
162
|
-
return true;
|
|
163
|
-
if (section.condition && this.analysis) {
|
|
164
|
-
return section.condition(this.analysis);
|
|
165
|
-
}
|
|
166
|
-
return true; // Include by default if no condition
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Get sections that should be included.
|
|
170
|
-
*/
|
|
171
|
-
getIncludedSections() {
|
|
172
|
-
return this.sections.filter(s => this.shouldIncludeSection(s));
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Estimate total tokens for included sections.
|
|
176
|
-
*/
|
|
177
|
-
estimateTotalTokens() {
|
|
178
|
-
return this.getIncludedSections()
|
|
179
|
-
.reduce((sum, s) => sum + s.tokenEstimate, 0);
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Get remaining token budget.
|
|
183
|
-
*/
|
|
184
|
-
getRemainingTokenBudget() {
|
|
185
|
-
return this.maxTokens - this.estimateTotalTokens();
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Load and compile a section template.
|
|
189
|
-
*/
|
|
190
|
-
loadSection(sectionId) {
|
|
191
|
-
if (this.compiledSections.has(sectionId)) {
|
|
192
|
-
return this.compiledSections.get(sectionId);
|
|
193
|
-
}
|
|
194
|
-
const section = this.sections.find(s => s.id === sectionId);
|
|
195
|
-
if (!section)
|
|
196
|
-
return null;
|
|
197
|
-
const filePath = join(this.sectionsDir, section.file);
|
|
198
|
-
if (!existsSync(filePath)) {
|
|
199
|
-
return null;
|
|
200
|
-
}
|
|
201
|
-
try {
|
|
202
|
-
const content = readFileSync(filePath, 'utf-8');
|
|
203
|
-
const compiled = Handlebars.compile(content);
|
|
204
|
-
this.compiledSections.set(sectionId, compiled);
|
|
205
|
-
return compiled;
|
|
206
|
-
}
|
|
207
|
-
catch {
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Load all sections and assemble the full template.
|
|
213
|
-
*/
|
|
214
|
-
loadFullTemplate() {
|
|
215
|
-
// Check if sections directory exists
|
|
216
|
-
if (!existsSync(this.sectionsDir) || !this.hasSectionFiles()) {
|
|
217
|
-
// Fall back to monolithic template
|
|
218
|
-
return this.loadMonolithicTemplate();
|
|
219
|
-
}
|
|
220
|
-
const parts = [];
|
|
221
|
-
for (const section of this.getIncludedSections()) {
|
|
222
|
-
const filePath = join(this.sectionsDir, section.file);
|
|
223
|
-
if (existsSync(filePath)) {
|
|
224
|
-
parts.push(readFileSync(filePath, 'utf-8'));
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return parts.join('\n\n');
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Check if section files exist.
|
|
231
|
-
*/
|
|
232
|
-
hasSectionFiles() {
|
|
233
|
-
try {
|
|
234
|
-
const files = readdirSync(this.sectionsDir);
|
|
235
|
-
return files.some(f => f.endsWith('.hbs'));
|
|
236
|
-
}
|
|
237
|
-
catch {
|
|
238
|
-
return false;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Load the monolithic template as fallback.
|
|
243
|
-
*/
|
|
244
|
-
loadMonolithicTemplate() {
|
|
245
|
-
const locations = [
|
|
246
|
-
join(process.cwd(), 'templates/CLAUDE.template.md'),
|
|
247
|
-
join(__dirname, '../../templates/CLAUDE.template.md'),
|
|
248
|
-
];
|
|
249
|
-
for (const loc of locations) {
|
|
250
|
-
if (existsSync(loc)) {
|
|
251
|
-
return readFileSync(loc, 'utf-8');
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
throw new Error('No template found');
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Compile the full template with context.
|
|
258
|
-
*/
|
|
259
|
-
compile(context) {
|
|
260
|
-
const template = this.loadFullTemplate();
|
|
261
|
-
const compiled = Handlebars.compile(template);
|
|
262
|
-
return compiled(context);
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Get a summary of what will be included.
|
|
266
|
-
*/
|
|
267
|
-
getSummary() {
|
|
268
|
-
const included = this.getIncludedSections().map(s => s.id);
|
|
269
|
-
const excluded = this.sections
|
|
270
|
-
.filter(s => !this.shouldIncludeSection(s))
|
|
271
|
-
.map(s => s.id);
|
|
272
|
-
const estimatedTokens = this.estimateTotalTokens();
|
|
273
|
-
return {
|
|
274
|
-
includedSections: included,
|
|
275
|
-
excludedSections: excluded,
|
|
276
|
-
estimatedTokens,
|
|
277
|
-
withinBudget: estimatedTokens <= this.maxTokens,
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Create section template files from the monolithic template.
|
|
283
|
-
* This is a one-time migration utility.
|
|
284
|
-
*/
|
|
285
|
-
export async function splitTemplateIntoSections(templatePath, outputDir) {
|
|
286
|
-
// This would be implemented to parse the monolithic template
|
|
287
|
-
// and split it into section files based on markers.
|
|
288
|
-
// For now, we use the monolithic template directly.
|
|
289
|
-
console.log(`Would split ${templatePath} into sections at ${outputDir}`);
|
|
290
|
-
}
|
|
291
|
-
//# sourceMappingURL=template-loader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template-loader.js","sourceRoot":"","sources":["../../src/generators/template-loader.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAGpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAyCtC;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAsB;IACjD,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EA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C3E,CAAC"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Active Context Module for UAP
|
|
3
|
-
*
|
|
4
|
-
* Implements context-aware memory management with automatic activation/deactivation
|
|
5
|
-
* based on relevance scoring and temporal proximity.
|
|
6
|
-
*/
|
|
7
|
-
export interface ActiveContextConfig {
|
|
8
|
-
maxActiveEntries: number;
|
|
9
|
-
relevanceThreshold: number;
|
|
10
|
-
decayRate: number;
|
|
11
|
-
activationWindow: number;
|
|
12
|
-
}
|
|
13
|
-
export interface ActiveEntry {
|
|
14
|
-
id: string;
|
|
15
|
-
content: string;
|
|
16
|
-
relevance: number;
|
|
17
|
-
lastActive: Date;
|
|
18
|
-
accessCount: number;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Active Context Manager
|
|
22
|
-
* Manages a set of active memory entries based on relevance and recency
|
|
23
|
-
*/
|
|
24
|
-
export declare class ActiveContextManager {
|
|
25
|
-
private config;
|
|
26
|
-
private entries;
|
|
27
|
-
constructor(config?: Partial<ActiveContextConfig>);
|
|
28
|
-
/**
|
|
29
|
-
* Add or update an entry in active context
|
|
30
|
-
*/
|
|
31
|
-
activate(id: string, content: string, relevance: number): ActiveEntry;
|
|
32
|
-
/**
|
|
33
|
-
* Deactivate an entry (remove from active context)
|
|
34
|
-
*/
|
|
35
|
-
deactivate(id: string): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Get all active entries sorted by relevance
|
|
38
|
-
*/
|
|
39
|
-
getActiveEntries(limit?: number): ActiveEntry[];
|
|
40
|
-
/**
|
|
41
|
-
* Check if an entry is active
|
|
42
|
-
*/
|
|
43
|
-
isActive(id: string): boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Get relevance score for an entry
|
|
46
|
-
*/
|
|
47
|
-
getRelevance(id: string): number | null;
|
|
48
|
-
/**
|
|
49
|
-
* Decay relevance scores over time
|
|
50
|
-
*/
|
|
51
|
-
decay(): void;
|
|
52
|
-
/**
|
|
53
|
-
* Rebalance entries to maintain max size
|
|
54
|
-
*/
|
|
55
|
-
private rebalance;
|
|
56
|
-
/**
|
|
57
|
-
* Clear all active entries
|
|
58
|
-
*/
|
|
59
|
-
clear(): void;
|
|
60
|
-
/**
|
|
61
|
-
* Get count of active entries
|
|
62
|
-
*/
|
|
63
|
-
getCount(): number;
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=active-context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"active-context.d.ts","sourceRoot":"","sources":["../../src/memory/active-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AASD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,IAAI,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,OAAO,CAAuC;gBAE1C,MAAM,GAAE,OAAO,CAAC,mBAAmB,CAAM;IAIrD;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW;IA0BrE;;OAEG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI/B;;OAEG;IACH,gBAAgB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,EAAE;IAM/C;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI7B;;OAEG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAKvC;;OAEG;IACH,KAAK,IAAI,IAAI;IAmBb;;OAEG;IACH,OAAO,CAAC,SAAS;IAmBjB;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Active Context Module for UAP
|
|
3
|
-
*
|
|
4
|
-
* Implements context-aware memory management with automatic activation/deactivation
|
|
5
|
-
* based on relevance scoring and temporal proximity.
|
|
6
|
-
*/
|
|
7
|
-
const DEFAULT_CONFIG = {
|
|
8
|
-
maxActiveEntries: 20,
|
|
9
|
-
relevanceThreshold: 0.6,
|
|
10
|
-
decayRate: 0.95,
|
|
11
|
-
activationWindow: 24,
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Active Context Manager
|
|
15
|
-
* Manages a set of active memory entries based on relevance and recency
|
|
16
|
-
*/
|
|
17
|
-
export class ActiveContextManager {
|
|
18
|
-
config;
|
|
19
|
-
entries = new Map();
|
|
20
|
-
constructor(config = {}) {
|
|
21
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Add or update an entry in active context
|
|
25
|
-
*/
|
|
26
|
-
activate(id, content, relevance) {
|
|
27
|
-
const now = new Date();
|
|
28
|
-
let entry;
|
|
29
|
-
if (this.entries.has(id)) {
|
|
30
|
-
entry = this.entries.get(id);
|
|
31
|
-
entry.content = content;
|
|
32
|
-
entry.relevance = relevance;
|
|
33
|
-
entry.accessCount++;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
entry = {
|
|
37
|
-
id,
|
|
38
|
-
content,
|
|
39
|
-
relevance,
|
|
40
|
-
lastActive: now,
|
|
41
|
-
accessCount: 1,
|
|
42
|
-
};
|
|
43
|
-
this.entries.set(id, entry);
|
|
44
|
-
}
|
|
45
|
-
// Rebalance active entries
|
|
46
|
-
this.rebalance();
|
|
47
|
-
return entry;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Deactivate an entry (remove from active context)
|
|
51
|
-
*/
|
|
52
|
-
deactivate(id) {
|
|
53
|
-
return this.entries.delete(id);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Get all active entries sorted by relevance
|
|
57
|
-
*/
|
|
58
|
-
getActiveEntries(limit) {
|
|
59
|
-
const entries = Array.from(this.entries.values());
|
|
60
|
-
entries.sort((a, b) => b.relevance - a.relevance);
|
|
61
|
-
return limit ? entries.slice(0, limit) : entries;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Check if an entry is active
|
|
65
|
-
*/
|
|
66
|
-
isActive(id) {
|
|
67
|
-
return this.entries.has(id);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Get relevance score for an entry
|
|
71
|
-
*/
|
|
72
|
-
getRelevance(id) {
|
|
73
|
-
const entry = this.entries.get(id);
|
|
74
|
-
return entry ? entry.relevance : null;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Decay relevance scores over time
|
|
78
|
-
*/
|
|
79
|
-
decay() {
|
|
80
|
-
const now = Date.now();
|
|
81
|
-
const windowMs = this.config.activationWindow * 60 * 60 * 1000;
|
|
82
|
-
for (const [id, entry] of this.entries) {
|
|
83
|
-
const age = now - entry.lastActive.getTime();
|
|
84
|
-
// Decay based on age
|
|
85
|
-
if (age > windowMs) {
|
|
86
|
-
entry.relevance *= Math.pow(this.config.decayRate, age / (1000 * 60 * 60));
|
|
87
|
-
// Auto-deactivate if relevance drops below threshold
|
|
88
|
-
if (entry.relevance < this.config.relevanceThreshold) {
|
|
89
|
-
this.entries.delete(id);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Rebalance entries to maintain max size
|
|
96
|
-
*/
|
|
97
|
-
rebalance() {
|
|
98
|
-
const entries = Array.from(this.entries.values());
|
|
99
|
-
if (entries.length > this.config.maxActiveEntries) {
|
|
100
|
-
// Sort by relevance and access count
|
|
101
|
-
entries.sort((a, b) => {
|
|
102
|
-
const scoreA = a.relevance * 0.7 + (a.accessCount / Math.max(1, a.accessCount)) * 0.3;
|
|
103
|
-
const scoreB = b.relevance * 0.7 + (b.accessCount / Math.max(1, b.accessCount)) * 0.3;
|
|
104
|
-
return scoreA - scoreB;
|
|
105
|
-
});
|
|
106
|
-
// Remove lowest relevance entries
|
|
107
|
-
const toRemove = entries.slice(0, entries.length - this.config.maxActiveEntries);
|
|
108
|
-
for (const entry of toRemove) {
|
|
109
|
-
this.entries.delete(entry.id);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Clear all active entries
|
|
115
|
-
*/
|
|
116
|
-
clear() {
|
|
117
|
-
this.entries.clear();
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Get count of active entries
|
|
121
|
-
*/
|
|
122
|
-
getCount() {
|
|
123
|
-
return this.entries.size;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
//# sourceMappingURL=active-context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"active-context.js","sourceRoot":"","sources":["../../src/memory/active-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,MAAM,cAAc,GAAwB;IAC1C,gBAAgB,EAAE,EAAE;IACpB,kBAAkB,EAAE,GAAG;IACvB,SAAS,EAAE,IAAI;IACf,gBAAgB,EAAE,EAAE;CACrB,CAAC;AAUF;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IACvB,MAAM,CAAsB;IAC5B,OAAO,GAA6B,IAAI,GAAG,EAAE,CAAC;IAEtD,YAAY,SAAuC,EAAE;QACnD,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,MAAM,EAAE,CAAC;IACjD,CAAC;IAED;;OAEG;IACH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AgB,EAAE,CAAC;YAClD,qCAAqC;YACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;gBACpB,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,GAAG,CAAC;gBACtF,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,GAAG,GAAG,CAAC;gBACtF,OAAO,MAAM,GAAG,MAAM,CAAC;YACzB,CAAC,CAAC,CAAC;YAEH,kCAAkC;YAClC,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;YACjF,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;gBAC7B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-Agent Workspace Isolation
|
|
3
|
-
*
|
|
4
|
-
* Each registered agent gets its own working memory partition within the
|
|
5
|
-
* shared SQLite database. Agent-specific context stays isolated; shared
|
|
6
|
-
* memories require explicit cross-agent promotion.
|
|
7
|
-
*
|
|
8
|
-
* Inspired by Clawe's per-agent isolated workspaces.
|
|
9
|
-
*/
|
|
10
|
-
import Database from 'better-sqlite3';
|
|
11
|
-
export interface AgentMemoryPartition {
|
|
12
|
-
agentId: string;
|
|
13
|
-
agentName: string;
|
|
14
|
-
entryCount: number;
|
|
15
|
-
lastActivity: string;
|
|
16
|
-
}
|
|
17
|
-
export interface AgentScopedEntry {
|
|
18
|
-
id: number;
|
|
19
|
-
agentId: string;
|
|
20
|
-
timestamp: string;
|
|
21
|
-
type: string;
|
|
22
|
-
content: string;
|
|
23
|
-
importance: number;
|
|
24
|
-
shared: boolean;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Ensure the agent-scoped memory table exists.
|
|
28
|
-
*/
|
|
29
|
-
export declare function ensureAgentScopedSchema(db: Database.Database): void;
|
|
30
|
-
export declare class AgentScopedMemory {
|
|
31
|
-
private db;
|
|
32
|
-
constructor(dbPath: string);
|
|
33
|
-
/**
|
|
34
|
-
* Store a memory scoped to a specific agent.
|
|
35
|
-
*/
|
|
36
|
-
store(agentId: string, content: string, type?: string, importance?: number): number;
|
|
37
|
-
/**
|
|
38
|
-
* Query memories for a specific agent (includes shared memories).
|
|
39
|
-
*/
|
|
40
|
-
query(agentId: string, search: string, limit?: number): AgentScopedEntry[];
|
|
41
|
-
/**
|
|
42
|
-
* Get all memories for a specific agent (includes shared).
|
|
43
|
-
*/
|
|
44
|
-
getForAgent(agentId: string, limit?: number): AgentScopedEntry[];
|
|
45
|
-
/**
|
|
46
|
-
* Promote a memory to shared (visible to all agents).
|
|
47
|
-
*/
|
|
48
|
-
share(entryId: number): void;
|
|
49
|
-
/**
|
|
50
|
-
* Unshare a memory (make agent-private again).
|
|
51
|
-
*/
|
|
52
|
-
unshare(entryId: number): void;
|
|
53
|
-
/**
|
|
54
|
-
* Get partition statistics per agent.
|
|
55
|
-
*/
|
|
56
|
-
getPartitions(): AgentMemoryPartition[];
|
|
57
|
-
/**
|
|
58
|
-
* Count memories for a specific agent.
|
|
59
|
-
*/
|
|
60
|
-
countForAgent(agentId: string): number;
|
|
61
|
-
/**
|
|
62
|
-
* Delete all memories for a specific agent (used on deregister).
|
|
63
|
-
*/
|
|
64
|
-
clearAgent(agentId: string): number;
|
|
65
|
-
close(): void;
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=agent-scoped-memory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-scoped-memory.d.ts","sourceRoot":"","sources":["../../src/memory/agent-scoped-memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAItC,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAenE;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,EAAE,CAAoB;gBAElB,MAAM,EAAE,MAAM;IAS1B;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAsB,EAAE,UAAU,GAAE,MAAU,GAAG,MAAM;IASrG;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW,GAAG,gBAAgB,EAAE;IAW9E;;OAEG;IACH,WAAW,CAAC,OAAO,EAA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