crewly 1.4.41 → 1.4.42
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/config/roles/orchestrator/fragments/communication.md +117 -0
- package/config/roles/orchestrator/fragments/lifecycle.md +112 -0
- package/config/roles/orchestrator/fragments/recovery.md +47 -0
- package/dist/backend/backend/src/services/agent/agent-registration.service.d.ts.map +1 -1
- package/dist/backend/backend/src/services/agent/agent-registration.service.js +6 -0
- package/dist/backend/backend/src/services/agent/agent-registration.service.js.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-builder.service.d.ts.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-builder.service.js +5 -0
- package/dist/backend/backend/src/services/ai/prompt-builder.service.js.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/communication.module.d.ts.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/communication.module.js +6 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/communication.module.js.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/context-assembly.service.d.ts +16 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/context-assembly.service.d.ts.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/context-assembly.service.js +30 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/context-assembly.service.js.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/index.d.ts +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/index.d.ts.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/index.js +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/index.js.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/lifecycle.module.d.ts.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/lifecycle.module.js +8 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/lifecycle.module.js.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/prompt-assembly.service.d.ts +29 -12
- package/dist/backend/backend/src/services/ai/prompt-modules/prompt-assembly.service.d.ts.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/prompt-assembly.service.js +159 -66
- package/dist/backend/backend/src/services/ai/prompt-modules/prompt-assembly.service.js.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/prompt-module.interface.d.ts +35 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/prompt-module.interface.d.ts.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/prompt-module.interface.js +23 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/prompt-module.interface.js.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/recovery.module.d.ts.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/recovery.module.js +8 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/recovery.module.js.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/soul.module.d.ts +10 -0
- package/dist/backend/backend/src/services/ai/prompt-modules/soul.module.d.ts.map +1 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/soul.module.js +55 -1
- package/dist/backend/backend/src/services/ai/prompt-modules/soul.module.js.map +1 -1
- package/dist/backend/backend/src/services/ai/self-improvement/attention.service.d.ts +74 -0
- package/dist/backend/backend/src/services/ai/self-improvement/attention.service.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/self-improvement/attention.service.js +132 -0
- package/dist/backend/backend/src/services/ai/self-improvement/attention.service.js.map +1 -0
- package/dist/backend/backend/src/services/ai/self-improvement/growth-areas.service.d.ts +81 -0
- package/dist/backend/backend/src/services/ai/self-improvement/growth-areas.service.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/self-improvement/growth-areas.service.js +135 -0
- package/dist/backend/backend/src/services/ai/self-improvement/growth-areas.service.js.map +1 -0
- package/dist/backend/backend/src/services/ai/self-improvement/index.d.ts +13 -0
- package/dist/backend/backend/src/services/ai/self-improvement/index.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/self-improvement/index.js +13 -0
- package/dist/backend/backend/src/services/ai/self-improvement/index.js.map +1 -0
- package/dist/backend/backend/src/services/ai/self-improvement/memory-consolidation.service.d.ts +107 -0
- package/dist/backend/backend/src/services/ai/self-improvement/memory-consolidation.service.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/self-improvement/memory-consolidation.service.js +183 -0
- package/dist/backend/backend/src/services/ai/self-improvement/memory-consolidation.service.js.map +1 -0
- package/dist/backend/backend/src/services/ai/self-improvement/prediction-calibration.service.d.ts +97 -0
- package/dist/backend/backend/src/services/ai/self-improvement/prediction-calibration.service.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/self-improvement/prediction-calibration.service.js +128 -0
- package/dist/backend/backend/src/services/ai/self-improvement/prediction-calibration.service.js.map +1 -0
- package/dist/backend/backend/src/services/ai/self-improvement/self-model.service.d.ts +95 -0
- package/dist/backend/backend/src/services/ai/self-improvement/self-model.service.d.ts.map +1 -0
- package/dist/backend/backend/src/services/ai/self-improvement/self-model.service.js +116 -0
- package/dist/backend/backend/src/services/ai/self-improvement/self-model.service.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persisted attention management data structure.
|
|
3
|
+
*/
|
|
4
|
+
export interface AttentionData {
|
|
5
|
+
/** Current focus items — topics the agent should prioritize */
|
|
6
|
+
focus: string[];
|
|
7
|
+
/** Suppressed items — topics the agent should deprioritize */
|
|
8
|
+
suppressed: string[];
|
|
9
|
+
/** Last time focus items were pruned (ISO date string) */
|
|
10
|
+
lastPruned: string;
|
|
11
|
+
/** Timestamps for each focus item (for pruning stale items) */
|
|
12
|
+
focusTimestamps?: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Service for managing agent attention — what to focus on and what to suppress.
|
|
16
|
+
*
|
|
17
|
+
* Focus items direct the agent's attention toward high-priority topics.
|
|
18
|
+
* Suppressed items filter out noise from irrelevant past context.
|
|
19
|
+
* Pruning removes stale focus items that haven't been updated in 2+ weeks.
|
|
20
|
+
*
|
|
21
|
+
* Storage: ~/.crewly/agents/{sessionName}/attention.json
|
|
22
|
+
*/
|
|
23
|
+
export declare class AttentionService {
|
|
24
|
+
/**
|
|
25
|
+
* Get the file path for an agent's attention data.
|
|
26
|
+
*
|
|
27
|
+
* @param sessionName - Agent session name
|
|
28
|
+
* @returns Absolute path to attention.json
|
|
29
|
+
*/
|
|
30
|
+
private getFilePath;
|
|
31
|
+
/**
|
|
32
|
+
* Read attention data from disk.
|
|
33
|
+
*
|
|
34
|
+
* @param sessionName - Agent session name
|
|
35
|
+
* @returns Attention data, or empty default if file doesn't exist
|
|
36
|
+
*/
|
|
37
|
+
getAttention(sessionName: string): Promise<AttentionData>;
|
|
38
|
+
/**
|
|
39
|
+
* Get the current focus items for an agent.
|
|
40
|
+
*
|
|
41
|
+
* @param sessionName - Agent session name
|
|
42
|
+
* @returns Array of focus item strings
|
|
43
|
+
*/
|
|
44
|
+
getFocus(sessionName: string): Promise<string[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Set the focus items for an agent (replaces existing focus).
|
|
47
|
+
*
|
|
48
|
+
* @param sessionName - Agent session name
|
|
49
|
+
* @param items - New focus items
|
|
50
|
+
*/
|
|
51
|
+
setFocus(sessionName: string, items: string[]): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Add a single item to the suppressed list.
|
|
54
|
+
*
|
|
55
|
+
* @param sessionName - Agent session name
|
|
56
|
+
* @param item - Item to suppress
|
|
57
|
+
*/
|
|
58
|
+
suppress(sessionName: string, item: string): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Prune stale focus items that haven't been updated in PRUNE_THRESHOLD_DAYS.
|
|
61
|
+
*
|
|
62
|
+
* @param sessionName - Agent session name
|
|
63
|
+
* @returns Number of items pruned
|
|
64
|
+
*/
|
|
65
|
+
prune(sessionName: string): Promise<number>;
|
|
66
|
+
/**
|
|
67
|
+
* Persist attention data to disk.
|
|
68
|
+
*
|
|
69
|
+
* @param sessionName - Agent session name
|
|
70
|
+
* @param data - Attention data to save
|
|
71
|
+
*/
|
|
72
|
+
private save;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=attention.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attention.service.d.ts","sourceRoot":"","sources":["../../../../../../../backend/src/services/ai/self-improvement/attention.service.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,+DAA+D;IAC/D,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,8DAA8D;IAC9D,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAOD;;;;;;;;GAQG;AACH,qBAAa,gBAAgB;IAC5B;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAKnB;;;;;OAKG;IACG,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAU/D;;;;;OAKG;IACG,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAKtD;;;;;OAKG;IACG,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAanE;;;;;OAKG;IACG,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBhE;;;;;OAKG;IACG,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAgCjD;;;;;OAKG;YACW,IAAI;CAMlB"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Number of days after which a focus item is considered stale.
|
|
5
|
+
*/
|
|
6
|
+
const PRUNE_THRESHOLD_DAYS = 14;
|
|
7
|
+
/**
|
|
8
|
+
* Service for managing agent attention — what to focus on and what to suppress.
|
|
9
|
+
*
|
|
10
|
+
* Focus items direct the agent's attention toward high-priority topics.
|
|
11
|
+
* Suppressed items filter out noise from irrelevant past context.
|
|
12
|
+
* Pruning removes stale focus items that haven't been updated in 2+ weeks.
|
|
13
|
+
*
|
|
14
|
+
* Storage: ~/.crewly/agents/{sessionName}/attention.json
|
|
15
|
+
*/
|
|
16
|
+
export class AttentionService {
|
|
17
|
+
/**
|
|
18
|
+
* Get the file path for an agent's attention data.
|
|
19
|
+
*
|
|
20
|
+
* @param sessionName - Agent session name
|
|
21
|
+
* @returns Absolute path to attention.json
|
|
22
|
+
*/
|
|
23
|
+
getFilePath(sessionName) {
|
|
24
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || '/tmp';
|
|
25
|
+
return path.join(homeDir, '.crewly', 'agents', sessionName, 'attention.json');
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Read attention data from disk.
|
|
29
|
+
*
|
|
30
|
+
* @param sessionName - Agent session name
|
|
31
|
+
* @returns Attention data, or empty default if file doesn't exist
|
|
32
|
+
*/
|
|
33
|
+
async getAttention(sessionName) {
|
|
34
|
+
try {
|
|
35
|
+
const filePath = this.getFilePath(sessionName);
|
|
36
|
+
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
37
|
+
return JSON.parse(raw);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return { focus: [], suppressed: [], lastPruned: '', focusTimestamps: {} };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get the current focus items for an agent.
|
|
45
|
+
*
|
|
46
|
+
* @param sessionName - Agent session name
|
|
47
|
+
* @returns Array of focus item strings
|
|
48
|
+
*/
|
|
49
|
+
async getFocus(sessionName) {
|
|
50
|
+
const data = await this.getAttention(sessionName);
|
|
51
|
+
return data.focus;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Set the focus items for an agent (replaces existing focus).
|
|
55
|
+
*
|
|
56
|
+
* @param sessionName - Agent session name
|
|
57
|
+
* @param items - New focus items
|
|
58
|
+
*/
|
|
59
|
+
async setFocus(sessionName, items) {
|
|
60
|
+
const data = await this.getAttention(sessionName);
|
|
61
|
+
const now = new Date().toISOString().split('T')[0];
|
|
62
|
+
data.focus = items;
|
|
63
|
+
data.focusTimestamps = {};
|
|
64
|
+
for (const item of items) {
|
|
65
|
+
data.focusTimestamps[item] = now;
|
|
66
|
+
}
|
|
67
|
+
await this.save(sessionName, data);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Add a single item to the suppressed list.
|
|
71
|
+
*
|
|
72
|
+
* @param sessionName - Agent session name
|
|
73
|
+
* @param item - Item to suppress
|
|
74
|
+
*/
|
|
75
|
+
async suppress(sessionName, item) {
|
|
76
|
+
const data = await this.getAttention(sessionName);
|
|
77
|
+
if (!data.suppressed.includes(item)) {
|
|
78
|
+
data.suppressed.push(item);
|
|
79
|
+
}
|
|
80
|
+
// Also remove from focus if present
|
|
81
|
+
data.focus = data.focus.filter((f) => f !== item);
|
|
82
|
+
if (data.focusTimestamps) {
|
|
83
|
+
delete data.focusTimestamps[item];
|
|
84
|
+
}
|
|
85
|
+
await this.save(sessionName, data);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Prune stale focus items that haven't been updated in PRUNE_THRESHOLD_DAYS.
|
|
89
|
+
*
|
|
90
|
+
* @param sessionName - Agent session name
|
|
91
|
+
* @returns Number of items pruned
|
|
92
|
+
*/
|
|
93
|
+
async prune(sessionName) {
|
|
94
|
+
const data = await this.getAttention(sessionName);
|
|
95
|
+
const now = new Date();
|
|
96
|
+
const timestamps = data.focusTimestamps || {};
|
|
97
|
+
let pruned = 0;
|
|
98
|
+
data.focus = data.focus.filter((item) => {
|
|
99
|
+
const ts = timestamps[item];
|
|
100
|
+
if (!ts) {
|
|
101
|
+
// No timestamp — prune it
|
|
102
|
+
pruned++;
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
const itemDate = new Date(ts);
|
|
106
|
+
const daysDiff = (now.getTime() - itemDate.getTime()) / (1000 * 60 * 60 * 24);
|
|
107
|
+
if (daysDiff > PRUNE_THRESHOLD_DAYS) {
|
|
108
|
+
pruned++;
|
|
109
|
+
delete timestamps[item];
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
});
|
|
114
|
+
data.focusTimestamps = timestamps;
|
|
115
|
+
data.lastPruned = now.toISOString().split('T')[0];
|
|
116
|
+
await this.save(sessionName, data);
|
|
117
|
+
return pruned;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Persist attention data to disk.
|
|
121
|
+
*
|
|
122
|
+
* @param sessionName - Agent session name
|
|
123
|
+
* @param data - Attention data to save
|
|
124
|
+
*/
|
|
125
|
+
async save(sessionName, data) {
|
|
126
|
+
const filePath = this.getFilePath(sessionName);
|
|
127
|
+
const dir = path.dirname(filePath);
|
|
128
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
129
|
+
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=attention.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attention.service.js","sourceRoot":"","sources":["../../../../../../../backend/src/services/ai/self-improvement/attention.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAgB7B;;GAEG;AACH,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC;;;;;;;;GAQG;AACH,MAAM,OAAO,gBAAgB;IAC5B;;;;;OAKG;IACK,WAAW,CAAC,WAAmB;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ked for an agent.
|
|
3
|
+
*/
|
|
4
|
+
export interface GrowthArea {
|
|
5
|
+
/** Description of the growth area */
|
|
6
|
+
area: string;
|
|
7
|
+
/** Date the area was identified (ISO date string) */
|
|
8
|
+
identifiedAt: string;
|
|
9
|
+
/** Current progress status */
|
|
10
|
+
progress: 'identified' | 'improving' | 'proficient';
|
|
11
|
+
/** Evidence of progress or regression */
|
|
12
|
+
evidence: string[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Persisted growth areas data structure.
|
|
16
|
+
*/
|
|
17
|
+
export interface GrowthAreasData {
|
|
18
|
+
/** List of tracked growth areas */
|
|
19
|
+
areas: GrowthArea[];
|
|
20
|
+
/** Last time the areas were reviewed (ISO date string) */
|
|
21
|
+
lastReviewedAt: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Service for tracking agent growth areas over time.
|
|
25
|
+
*
|
|
26
|
+
* Each agent maintains a growth-areas.json file that records areas
|
|
27
|
+
* where the agent is actively improving. Growth areas can be manually
|
|
28
|
+
* added or auto-extracted from learnings and failures.
|
|
29
|
+
*
|
|
30
|
+
* Storage: ~/.crewly/agents/{sessionName}/growth-areas.json
|
|
31
|
+
*/
|
|
32
|
+
export declare class GrowthAreasService {
|
|
33
|
+
/**
|
|
34
|
+
* Get the file path for an agent's growth areas.
|
|
35
|
+
*
|
|
36
|
+
* @param sessionName - Agent session name
|
|
37
|
+
* @returns Absolute path to growth-areas.json
|
|
38
|
+
*/
|
|
39
|
+
private getFilePath;
|
|
40
|
+
/**
|
|
41
|
+
* Read growth areas data from disk.
|
|
42
|
+
*
|
|
43
|
+
* @param sessionName - Agent session name
|
|
44
|
+
* @returns Growth areas data, or empty default if file doesn't exist
|
|
45
|
+
*/
|
|
46
|
+
getGrowthAreas(sessionName: string): Promise<GrowthAreasData>;
|
|
47
|
+
/**
|
|
48
|
+
* Add a new growth area for an agent.
|
|
49
|
+
*
|
|
50
|
+
* @param sessionName - Agent session name
|
|
51
|
+
* @param area - Description of the growth area
|
|
52
|
+
* @returns The created growth area
|
|
53
|
+
*/
|
|
54
|
+
addGrowthArea(sessionName: string, area: string): Promise<GrowthArea>;
|
|
55
|
+
/**
|
|
56
|
+
* Update the progress of an existing growth area.
|
|
57
|
+
*
|
|
58
|
+
* @param sessionName - Agent session name
|
|
59
|
+
* @param area - Growth area description to update
|
|
60
|
+
* @param progress - New progress status
|
|
61
|
+
* @param evidence - Evidence supporting the progress update
|
|
62
|
+
* @returns Updated growth area or null if not found
|
|
63
|
+
*/
|
|
64
|
+
updateProgress(sessionName: string, area: string, progress: 'identified' | 'improving' | 'proficient', evidence: string): Promise<GrowthArea | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Auto-extract potential growth areas from a learning or failure text.
|
|
67
|
+
*
|
|
68
|
+
* @param sessionName - Agent session name
|
|
69
|
+
* @param text - Learning or failure text to analyze
|
|
70
|
+
* @returns Array of newly added growth areas (empty if no new areas found)
|
|
71
|
+
*/
|
|
72
|
+
extractFromText(sessionName: string, text: string): Promise<GrowthArea[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Persist growth areas data to disk.
|
|
75
|
+
*
|
|
76
|
+
* @param sessionName - Agent session name
|
|
77
|
+
* @param data - Growth areas data to save
|
|
78
|
+
*/
|
|
79
|
+
private save;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=growth-areas.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"growth-areas.service.d.ts","sourceRoot":"","sources":["../../../../../../../backend/src/services/ai/self-improvement/growth-areas.service.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,YAAY,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,QAAQ,EAAE,YAAY,GAAG,WAAW,GAAG,YAAY,CAAC;IACpD,yCAAyC;IACzC,QAAQ,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,mCAAmC;IACnC,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,0DAA0D;IAC1D,cAAc,EAAE,MAAM,CAAC;CACvB;AAkBD;;;;;;;;GAQG;AACH,qBAAa,kBAAkB;IAC9B;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAKnB;;;;;OAKG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAUnE;;;;;;OAMG;IACG,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAyB3E;;;;;;;;OAQG;IACG,cAAc,CACnB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,YAAY,GAAG,WAAW,GAAG,YAAY,EACnD,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAkB7B;;;;;;OAMG;IACG,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAoB/E;;;;;OAKG;YACW,IAAI;CAMlB"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Keywords that indicate potential growth areas when found in learnings/failures.
|
|
5
|
+
*/
|
|
6
|
+
const GROWTH_KEYWORDS = {
|
|
7
|
+
'error handling': 'error handling patterns',
|
|
8
|
+
'async': 'async/await best practices',
|
|
9
|
+
'test': 'test coverage and quality',
|
|
10
|
+
'type': 'TypeScript type system',
|
|
11
|
+
'performance': 'performance optimization',
|
|
12
|
+
'security': 'security awareness',
|
|
13
|
+
'edge case': 'edge case handling',
|
|
14
|
+
'timeout': 'timeout and retry patterns',
|
|
15
|
+
'memory leak': 'memory management',
|
|
16
|
+
'race condition': 'concurrency handling',
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Service for tracking agent growth areas over time.
|
|
20
|
+
*
|
|
21
|
+
* Each agent maintains a growth-areas.json file that records areas
|
|
22
|
+
* where the agent is actively improving. Growth areas can be manually
|
|
23
|
+
* added or auto-extracted from learnings and failures.
|
|
24
|
+
*
|
|
25
|
+
* Storage: ~/.crewly/agents/{sessionName}/growth-areas.json
|
|
26
|
+
*/
|
|
27
|
+
export class GrowthAreasService {
|
|
28
|
+
/**
|
|
29
|
+
* Get the file path for an agent's growth areas.
|
|
30
|
+
*
|
|
31
|
+
* @param sessionName - Agent session name
|
|
32
|
+
* @returns Absolute path to growth-areas.json
|
|
33
|
+
*/
|
|
34
|
+
getFilePath(sessionName) {
|
|
35
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || '/tmp';
|
|
36
|
+
return path.join(homeDir, '.crewly', 'agents', sessionName, 'growth-areas.json');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Read growth areas data from disk.
|
|
40
|
+
*
|
|
41
|
+
* @param sessionName - Agent session name
|
|
42
|
+
* @returns Growth areas data, or empty default if file doesn't exist
|
|
43
|
+
*/
|
|
44
|
+
async getGrowthAreas(sessionName) {
|
|
45
|
+
try {
|
|
46
|
+
const filePath = this.getFilePath(sessionName);
|
|
47
|
+
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
48
|
+
return JSON.parse(raw);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return { areas: [], lastReviewedAt: '' };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Add a new growth area for an agent.
|
|
56
|
+
*
|
|
57
|
+
* @param sessionName - Agent session name
|
|
58
|
+
* @param area - Description of the growth area
|
|
59
|
+
* @returns The created growth area
|
|
60
|
+
*/
|
|
61
|
+
async addGrowthArea(sessionName, area) {
|
|
62
|
+
const data = await this.getGrowthAreas(sessionName);
|
|
63
|
+
// Don't add duplicates
|
|
64
|
+
const existing = data.areas.find((a) => a.area.toLowerCase() === area.toLowerCase());
|
|
65
|
+
if (existing) {
|
|
66
|
+
return existing;
|
|
67
|
+
}
|
|
68
|
+
const newArea = {
|
|
69
|
+
area,
|
|
70
|
+
identifiedAt: new Date().toISOString().split('T')[0],
|
|
71
|
+
progress: 'identified',
|
|
72
|
+
evidence: [],
|
|
73
|
+
};
|
|
74
|
+
data.areas.push(newArea);
|
|
75
|
+
data.lastReviewedAt = new Date().toISOString().split('T')[0];
|
|
76
|
+
await this.save(sessionName, data);
|
|
77
|
+
return newArea;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Update the progress of an existing growth area.
|
|
81
|
+
*
|
|
82
|
+
* @param sessionName - Agent session name
|
|
83
|
+
* @param area - Growth area description to update
|
|
84
|
+
* @param progress - New progress status
|
|
85
|
+
* @param evidence - Evidence supporting the progress update
|
|
86
|
+
* @returns Updated growth area or null if not found
|
|
87
|
+
*/
|
|
88
|
+
async updateProgress(sessionName, area, progress, evidence) {
|
|
89
|
+
const data = await this.getGrowthAreas(sessionName);
|
|
90
|
+
const found = data.areas.find((a) => a.area.toLowerCase() === area.toLowerCase());
|
|
91
|
+
if (!found) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
found.progress = progress;
|
|
95
|
+
found.evidence.push(evidence);
|
|
96
|
+
data.lastReviewedAt = new Date().toISOString().split('T')[0];
|
|
97
|
+
await this.save(sessionName, data);
|
|
98
|
+
return found;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Auto-extract potential growth areas from a learning or failure text.
|
|
102
|
+
*
|
|
103
|
+
* @param sessionName - Agent session name
|
|
104
|
+
* @param text - Learning or failure text to analyze
|
|
105
|
+
* @returns Array of newly added growth areas (empty if no new areas found)
|
|
106
|
+
*/
|
|
107
|
+
async extractFromText(sessionName, text) {
|
|
108
|
+
const lowerText = text.toLowerCase();
|
|
109
|
+
const added = [];
|
|
110
|
+
for (const [keyword, areaName] of Object.entries(GROWTH_KEYWORDS)) {
|
|
111
|
+
if (lowerText.includes(keyword)) {
|
|
112
|
+
const data = await this.getGrowthAreas(sessionName);
|
|
113
|
+
const exists = data.areas.some((a) => a.area.toLowerCase() === areaName.toLowerCase());
|
|
114
|
+
if (!exists) {
|
|
115
|
+
const newArea = await this.addGrowthArea(sessionName, areaName);
|
|
116
|
+
added.push(newArea);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return added;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Persist growth areas data to disk.
|
|
124
|
+
*
|
|
125
|
+
* @param sessionName - Agent session name
|
|
126
|
+
* @param data - Growth areas data to save
|
|
127
|
+
*/
|
|
128
|
+
async save(sessionName, data) {
|
|
129
|
+
const filePath = this.getFilePath(sessionName);
|
|
130
|
+
const dir = path.dirname(filePath);
|
|
131
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
132
|
+
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf-8');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=growth-areas.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"growth-areas.service.js","sourceRoot":"","sources":["../../../../../../../backend/src/services/ai/self-improvement/growth-areas.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AA0B7B;;GAEG;AACH,MAAM,eAAe,GAA2B;IAC/C,gBAAgB,EAAE,yBAAyB;IAC3C,OAAO,EAAE,4BAA4B;IACrC,MAAM,EAAE,2BAA2B;IACnC,MAAM,EAAE,wBAAwB;IAChC,aAAa,EAAE,0BAA0B;IACzC,UAAU,EAAE,oBAAoB;IAChC,WAAW,EAAE,oBAAoB;IACjC,SAAS,EAAE,4BAA4B;IACvC,aAAa,EAAE,mBAAmB;IAClC,gBA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
*
|
|
4
|
+
* Provides services for agents to track their own growth,
|
|
5
|
+
* recognize patterns in their behavior, calibrate predictions,
|
|
6
|
+
* manage attention, and consolidate memories.
|
|
7
|
+
*/
|
|
8
|
+
export { GrowthAreasService, GrowthArea, GrowthAreasData } from './growth-areas.service.js';
|
|
9
|
+
export { SelfModelService, DecisionPattern, CognitiveBias, BlindSpot, SelfModelData } from './self-model.service.js';
|
|
10
|
+
export { PredictionCalibrationService, Prediction, PredictionsData, } from './prediction-calibration.service.js';
|
|
11
|
+
export { AttentionService, AttentionData } from './attention.service.js';
|
|
12
|
+
export { MemoryConsolidationService, ConsolidatedPattern, ConsolidatedInsight, ConsolidationReport, MemoryProvider, } from './memory-consolidation.service.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../backend/src/services/ai/self-improvement/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACrH,OAAO,EACN,4BAA4B,EAC5B,UAAU,EACV,eAAe,GACf,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EACN,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,GACd,MAAM,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-Improvement System — Agent metacognitive capabilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides services for agents to track their own growth,
|
|
5
|
+
* recognize patterns in their behavior, calibrate predictions,
|
|
6
|
+
* manage attention, and consolidate memories.
|
|
7
|
+
*/
|
|
8
|
+
export { GrowthAreasService } from './growth-areas.service.js';
|
|
9
|
+
export { SelfModelService } from './self-model.service.js';
|
|
10
|
+
export { PredictionCalibrationService, } from './prediction-calibration.service.js';
|
|
11
|
+
export { AttentionService } from './attention.service.js';
|
|
12
|
+
export { MemoryConsolidationService, } from './memory-consolidation.service.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../backend/src/services/ai/self-improvement/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAA+B,MAAM,2BAA2B,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAA4D,MAAM,yBAAyB,CAAC;AACrH,OAAO,EACN,4BAA4B,GAG5B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAiB,MAAM,wBAAwB,CAAC;AACzE,OAAO,EACN,0BAA0B,GAK1B,MAAM,mCAAmC,CAAC"}
|
package/dist/backend/backend/src/services/ai/self-improvement/memory-consolidation.service.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A pattern identified across multiple memories.
|
|
3
|
+
*/
|
|
4
|
+
export interface ConsolidatedPattern {
|
|
5
|
+
/** Description of the pattern */
|
|
6
|
+
pattern: string;
|
|
7
|
+
/** How many memories support this pattern */
|
|
8
|
+
occurrences: number;
|
|
9
|
+
/** Source categories (e.g., 'learning', 'failure', 'success') */
|
|
10
|
+
sources: string[];
|
|
11
|
+
/** When this pattern was identified (ISO date string) */
|
|
12
|
+
identifiedAt: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* An insight derived from cross-memory analysis.
|
|
16
|
+
*/
|
|
17
|
+
export interface ConsolidatedInsight {
|
|
18
|
+
/** The insight text */
|
|
19
|
+
insight: string;
|
|
20
|
+
/** Confidence level */
|
|
21
|
+
confidence: 'low' | 'medium' | 'high';
|
|
22
|
+
/** Related memory snippets that support this insight */
|
|
23
|
+
relatedMemories: string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Persisted consolidation report structure.
|
|
27
|
+
*/
|
|
28
|
+
export interface ConsolidationReport {
|
|
29
|
+
/** Patterns identified across memories */
|
|
30
|
+
patterns: ConsolidatedPattern[];
|
|
31
|
+
/** Insights derived from analysis */
|
|
32
|
+
insights: ConsolidatedInsight[];
|
|
33
|
+
/** When this consolidation was run (ISO string) */
|
|
34
|
+
consolidatedAt: string;
|
|
35
|
+
/** Number of memories analyzed */
|
|
36
|
+
memoriesAnalyzed: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Provider function type for retrieving agent memories.
|
|
40
|
+
* Allows dependency injection for testing.
|
|
41
|
+
*/
|
|
42
|
+
export type MemoryProvider = (sessionName: string) => Promise<string[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Service for cross-layer memory consolidation.
|
|
45
|
+
*
|
|
46
|
+
* Reads all agent memories (learnings, failures, successes), identifies
|
|
47
|
+
* recurring patterns, and generates a consolidation report. Can be run
|
|
48
|
+
* periodically (e.g., weekly) to keep insights fresh.
|
|
49
|
+
*
|
|
50
|
+
* Storage: ~/.crewly/agents/{sessionName}/consolidation.json
|
|
51
|
+
*/
|
|
52
|
+
export declare class MemoryConsolidationService {
|
|
53
|
+
private memoryProvider;
|
|
54
|
+
/**
|
|
55
|
+
* Create a new MemoryConsolidationService.
|
|
56
|
+
*
|
|
57
|
+
* @param memoryProvider - Function that retrieves agent memories
|
|
58
|
+
*/
|
|
59
|
+
constructor(memoryProvider: MemoryProvider);
|
|
60
|
+
/**
|
|
61
|
+
* Get the file path for an agent's consolidation report.
|
|
62
|
+
*
|
|
63
|
+
* @param sessionName - Agent session name
|
|
64
|
+
* @returns Absolute path to consolidation.json
|
|
65
|
+
*/
|
|
66
|
+
private getFilePath;
|
|
67
|
+
/**
|
|
68
|
+
* Read the most recent consolidation report from disk.
|
|
69
|
+
*
|
|
70
|
+
* @param sessionName - Agent session name
|
|
71
|
+
* @returns Consolidation report, or empty default if none exists
|
|
72
|
+
*/
|
|
73
|
+
getReport(sessionName: string): Promise<ConsolidationReport>;
|
|
74
|
+
/**
|
|
75
|
+
* Run consolidation analysis on all agent memories.
|
|
76
|
+
*
|
|
77
|
+
* Identifies recurring patterns by counting word/phrase frequency
|
|
78
|
+
* across memories and extracting common themes.
|
|
79
|
+
*
|
|
80
|
+
* @param sessionName - Agent session name
|
|
81
|
+
* @returns The generated consolidation report
|
|
82
|
+
*/
|
|
83
|
+
consolidate(sessionName: string): Promise<ConsolidationReport>;
|
|
84
|
+
/**
|
|
85
|
+
* Extract recurring patterns from memories by analyzing keyword frequency.
|
|
86
|
+
*
|
|
87
|
+
* @param memories - Array of memory text strings
|
|
88
|
+
* @returns Identified patterns sorted by occurrence count
|
|
89
|
+
*/
|
|
90
|
+
private extractPatterns;
|
|
91
|
+
/**
|
|
92
|
+
* Derive insights from memories and patterns.
|
|
93
|
+
*
|
|
94
|
+
* @param memories - Array of memory text strings
|
|
95
|
+
* @param patterns - Previously extracted patterns
|
|
96
|
+
* @returns Array of derived insights
|
|
97
|
+
*/
|
|
98
|
+
private deriveInsights;
|
|
99
|
+
/**
|
|
100
|
+
* Persist consolidation report to disk.
|
|
101
|
+
*
|
|
102
|
+
* @param sessionName - Agent session name
|
|
103
|
+
* @param report - Consolidation report to save
|
|
104
|
+
*/
|
|
105
|
+
private save;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=memory-consolidation.service.d.ts.map
|
package/dist/backend/backend/src/services/ai/self-improvement/memory-consolidation.service.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-consolidation.service.d.ts","sourceRoot":"","sources":["../../../../../../../backend/src/services/ai/self-improvement/memory-consolidation.service.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,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