@simonfestl/husky-cli 1.9.1 → 1.9.2
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const AGENT_TYPES: readonly ["support", "claude", "gotess", "supervisor", "worker"];
|
|
1
|
+
export declare const AGENT_TYPES: readonly ["support", "claude", "gotess", "supervisor", "worker", "reviewer", "e2e_agent", "pr_agent"];
|
|
2
2
|
export type AgentType = typeof AGENT_TYPES[number];
|
|
3
3
|
export type MemoryVisibility = 'private' | 'team' | 'public';
|
|
4
4
|
export interface Memory {
|
|
@@ -42,7 +42,9 @@ export declare class AgentBrain {
|
|
|
42
42
|
getDatabaseInfo(): {
|
|
43
43
|
agentType?: AgentType;
|
|
44
44
|
databaseName: string;
|
|
45
|
+
collectionName: string;
|
|
45
46
|
};
|
|
47
|
+
private getCollectionName;
|
|
46
48
|
private ensureCollection;
|
|
47
49
|
remember(content: string, tags?: string[], metadata?: Record<string, unknown>, visibility?: MemoryVisibility, allowPii?: boolean): Promise<string>;
|
|
48
50
|
recall(query: string, limit?: number, minScore?: number): Promise<RecallResult[]>;
|
|
@@ -3,9 +3,9 @@ import { EmbeddingService } from './embeddings.js';
|
|
|
3
3
|
import { getConfig } from '../../commands/config.js';
|
|
4
4
|
import { randomUUID } from 'crypto';
|
|
5
5
|
import { sanitizeForEmbedding } from './pii-filter.js';
|
|
6
|
-
const
|
|
6
|
+
const DEFAULT_COLLECTION = 'agent-memories';
|
|
7
7
|
const VECTOR_SIZE = 768;
|
|
8
|
-
export const AGENT_TYPES = ['support', 'claude', 'gotess', 'supervisor', 'worker'];
|
|
8
|
+
export const AGENT_TYPES = ['support', 'claude', 'gotess', 'supervisor', 'worker', 'reviewer', 'e2e_agent', 'pr_agent'];
|
|
9
9
|
export function isValidAgentType(value) {
|
|
10
10
|
return value !== undefined && AGENT_TYPES.includes(value);
|
|
11
11
|
}
|
|
@@ -45,17 +45,25 @@ export class AgentBrain {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
getDatabaseInfo() {
|
|
48
|
+
const collectionName = this.getCollectionName();
|
|
48
49
|
return {
|
|
49
50
|
agentType: this.agentType,
|
|
50
|
-
databaseName: `qdrant:${
|
|
51
|
+
databaseName: `qdrant:${collectionName}`,
|
|
52
|
+
collectionName,
|
|
51
53
|
};
|
|
52
54
|
}
|
|
55
|
+
getCollectionName() {
|
|
56
|
+
if (!this.agentType)
|
|
57
|
+
return DEFAULT_COLLECTION;
|
|
58
|
+
return `${this.agentType}-memories`;
|
|
59
|
+
}
|
|
53
60
|
async ensureCollection() {
|
|
61
|
+
const collection = this.getCollectionName();
|
|
54
62
|
try {
|
|
55
|
-
await this.qdrant.getCollection(
|
|
63
|
+
await this.qdrant.getCollection(collection);
|
|
56
64
|
}
|
|
57
65
|
catch {
|
|
58
|
-
await this.qdrant.createCollection(
|
|
66
|
+
await this.qdrant.createCollection(collection, VECTOR_SIZE);
|
|
59
67
|
}
|
|
60
68
|
}
|
|
61
69
|
async remember(content, tags = [], metadata, visibility = 'private', allowPii = false) {
|
|
@@ -69,7 +77,7 @@ export class AgentBrain {
|
|
|
69
77
|
const embedding = await this.embeddings.embed(sanitizeResult.sanitized);
|
|
70
78
|
const id = randomUUID();
|
|
71
79
|
const now = new Date().toISOString();
|
|
72
|
-
await this.qdrant.upsertOne(
|
|
80
|
+
await this.qdrant.upsertOne(this.getCollectionName(), id, embedding, {
|
|
73
81
|
agent: this.agentId,
|
|
74
82
|
agentType: this.agentType || 'default',
|
|
75
83
|
content: sanitizeResult.sanitized, // Store sanitized content
|
|
@@ -108,7 +116,7 @@ export class AgentBrain {
|
|
|
108
116
|
if (this.agentType) {
|
|
109
117
|
filter.must.push({ key: 'agentType', match: { value: this.agentType } });
|
|
110
118
|
}
|
|
111
|
-
const results = await this.qdrant.search(
|
|
119
|
+
const results = await this.qdrant.search(this.getCollectionName(), queryEmbedding, limit, {
|
|
112
120
|
filter,
|
|
113
121
|
scoreThreshold: minScore,
|
|
114
122
|
});
|
|
@@ -142,7 +150,7 @@ export class AgentBrain {
|
|
|
142
150
|
}
|
|
143
151
|
]
|
|
144
152
|
};
|
|
145
|
-
const results = await this.qdrant.scroll(
|
|
153
|
+
const results = await this.qdrant.scroll(this.getCollectionName(), {
|
|
146
154
|
filter,
|
|
147
155
|
limit,
|
|
148
156
|
with_payload: true,
|
|
@@ -162,7 +170,7 @@ export class AgentBrain {
|
|
|
162
170
|
}
|
|
163
171
|
async forget(memoryId) {
|
|
164
172
|
await this.ensureCollection();
|
|
165
|
-
await this.qdrant.deletePoints(
|
|
173
|
+
await this.qdrant.deletePoints(this.getCollectionName(), [memoryId]);
|
|
166
174
|
}
|
|
167
175
|
async listMemories(limit = 20) {
|
|
168
176
|
await this.ensureCollection();
|
|
@@ -174,7 +182,7 @@ export class AgentBrain {
|
|
|
174
182
|
if (this.agentType) {
|
|
175
183
|
filter.must.push({ key: 'agentType', match: { value: this.agentType } });
|
|
176
184
|
}
|
|
177
|
-
const results = await this.qdrant.scroll(
|
|
185
|
+
const results = await this.qdrant.scroll(this.getCollectionName(), {
|
|
178
186
|
filter,
|
|
179
187
|
limit,
|
|
180
188
|
with_payload: true,
|
|
@@ -202,7 +210,7 @@ export class AgentBrain {
|
|
|
202
210
|
if (this.agentType) {
|
|
203
211
|
filter.must.push({ key: 'agentType', match: { value: this.agentType } });
|
|
204
212
|
}
|
|
205
|
-
const results = await this.qdrant.scroll(
|
|
213
|
+
const results = await this.qdrant.scroll(this.getCollectionName(), {
|
|
206
214
|
filter,
|
|
207
215
|
limit: 1000,
|
|
208
216
|
with_payload: true,
|
|
@@ -228,7 +236,7 @@ export class AgentBrain {
|
|
|
228
236
|
async publish(memoryId, visibility) {
|
|
229
237
|
await this.ensureCollection();
|
|
230
238
|
const now = new Date().toISOString();
|
|
231
|
-
await this.qdrant.setPayload(
|
|
239
|
+
await this.qdrant.setPayload(this.getCollectionName(), memoryId, {
|
|
232
240
|
visibility,
|
|
233
241
|
publishedBy: this.agentId,
|
|
234
242
|
publishedAt: now,
|
|
@@ -241,7 +249,7 @@ export class AgentBrain {
|
|
|
241
249
|
async unpublish(memoryId) {
|
|
242
250
|
await this.ensureCollection();
|
|
243
251
|
const now = new Date().toISOString();
|
|
244
|
-
await this.qdrant.setPayload(
|
|
252
|
+
await this.qdrant.setPayload(this.getCollectionName(), memoryId, {
|
|
245
253
|
visibility: 'private',
|
|
246
254
|
publishedBy: undefined,
|
|
247
255
|
publishedAt: undefined,
|
|
@@ -269,7 +277,7 @@ export class AgentBrain {
|
|
|
269
277
|
{ key: 'status', match: { value: 'active' } },
|
|
270
278
|
],
|
|
271
279
|
};
|
|
272
|
-
const results = await this.qdrant.search(
|
|
280
|
+
const results = await this.qdrant.search(this.getCollectionName(), queryEmbedding, limit * 3, {
|
|
273
281
|
filter,
|
|
274
282
|
scoreThreshold: minScore,
|
|
275
283
|
});
|
|
@@ -312,7 +320,7 @@ export class AgentBrain {
|
|
|
312
320
|
{ key: 'status', match: { value: 'active' } },
|
|
313
321
|
],
|
|
314
322
|
};
|
|
315
|
-
const results = await this.qdrant.scroll(
|
|
323
|
+
const results = await this.qdrant.scroll(this.getCollectionName(), {
|
|
316
324
|
filter,
|
|
317
325
|
limit,
|
|
318
326
|
with_payload: true,
|
|
@@ -340,13 +348,13 @@ export class AgentBrain {
|
|
|
340
348
|
*/
|
|
341
349
|
async boost(memoryId) {
|
|
342
350
|
await this.ensureCollection();
|
|
343
|
-
const point = await this.qdrant.getPoint(
|
|
351
|
+
const point = await this.qdrant.getPoint(this.getCollectionName(), memoryId);
|
|
344
352
|
if (!point)
|
|
345
353
|
throw new Error('Memory not found');
|
|
346
354
|
const boostCount = Number(point.payload?.boostCount || 0) + 1;
|
|
347
355
|
const downvoteCount = Number(point.payload?.downvoteCount || 0);
|
|
348
356
|
const qualityScore = this.calculateQualityScore(boostCount, downvoteCount);
|
|
349
|
-
await this.qdrant.setPayload(
|
|
357
|
+
await this.qdrant.setPayload(this.getCollectionName(), memoryId, {
|
|
350
358
|
boostCount,
|
|
351
359
|
qualityScore,
|
|
352
360
|
updatedAt: new Date().toISOString(),
|
|
@@ -357,13 +365,13 @@ export class AgentBrain {
|
|
|
357
365
|
*/
|
|
358
366
|
async downvote(memoryId) {
|
|
359
367
|
await this.ensureCollection();
|
|
360
|
-
const point = await this.qdrant.getPoint(
|
|
368
|
+
const point = await this.qdrant.getPoint(this.getCollectionName(), memoryId);
|
|
361
369
|
if (!point)
|
|
362
370
|
throw new Error('Memory not found');
|
|
363
371
|
const boostCount = Number(point.payload?.boostCount || 0);
|
|
364
372
|
const downvoteCount = Number(point.payload?.downvoteCount || 0) + 1;
|
|
365
373
|
const qualityScore = this.calculateQualityScore(boostCount, downvoteCount);
|
|
366
|
-
await this.qdrant.setPayload(
|
|
374
|
+
await this.qdrant.setPayload(this.getCollectionName(), memoryId, {
|
|
367
375
|
downvoteCount,
|
|
368
376
|
qualityScore,
|
|
369
377
|
updatedAt: new Date().toISOString(),
|
|
@@ -374,7 +382,7 @@ export class AgentBrain {
|
|
|
374
382
|
*/
|
|
375
383
|
async getQuality(memoryId) {
|
|
376
384
|
await this.ensureCollection();
|
|
377
|
-
const point = await this.qdrant.getPoint(
|
|
385
|
+
const point = await this.qdrant.getPoint(this.getCollectionName(), memoryId);
|
|
378
386
|
if (!point)
|
|
379
387
|
throw new Error('Memory not found');
|
|
380
388
|
return {
|
|
@@ -434,7 +442,7 @@ export class AgentBrain {
|
|
|
434
442
|
}))
|
|
435
443
|
});
|
|
436
444
|
}
|
|
437
|
-
const results = await this.qdrant.scroll(
|
|
445
|
+
const results = await this.qdrant.scroll(this.getCollectionName(), {
|
|
438
446
|
filter,
|
|
439
447
|
limit: 1000,
|
|
440
448
|
with_payload: true,
|
|
@@ -468,7 +476,7 @@ export class AgentBrain {
|
|
|
468
476
|
boostCount,
|
|
469
477
|
});
|
|
470
478
|
if (!dryRun) {
|
|
471
|
-
await this.qdrant.setPayload(
|
|
479
|
+
await this.qdrant.setPayload(this.getCollectionName(), String(r.id), {
|
|
472
480
|
status: 'archived',
|
|
473
481
|
updatedAt: new Date().toISOString(),
|
|
474
482
|
});
|
|
@@ -488,7 +496,7 @@ export class AgentBrain {
|
|
|
488
496
|
{ key: 'status', match: { value: 'archived' } },
|
|
489
497
|
],
|
|
490
498
|
};
|
|
491
|
-
const results = await this.qdrant.scroll(
|
|
499
|
+
const results = await this.qdrant.scroll(this.getCollectionName(), {
|
|
492
500
|
filter,
|
|
493
501
|
limit: 1000,
|
|
494
502
|
with_payload: true,
|
|
@@ -503,7 +511,7 @@ export class AgentBrain {
|
|
|
503
511
|
}
|
|
504
512
|
}
|
|
505
513
|
if (toPurge.length > 0) {
|
|
506
|
-
await this.qdrant.deletePoints(
|
|
514
|
+
await this.qdrant.deletePoints(this.getCollectionName(), toPurge);
|
|
507
515
|
}
|
|
508
516
|
return toPurge.length;
|
|
509
517
|
}
|