@ubundi/openclaw-cortex 2.8.2 → 2.9.1
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/README.md +21 -3
- package/dist/cortex/client.d.ts +2 -1
- package/dist/cortex/client.d.ts.map +1 -1
- package/dist/cortex/client.js +3 -1
- package/dist/cortex/client.js.map +1 -1
- package/dist/features/capture/compressor.d.ts +14 -0
- package/dist/features/capture/compressor.d.ts.map +1 -0
- package/dist/features/capture/compressor.js +317 -0
- package/dist/features/capture/compressor.js.map +1 -0
- package/dist/features/capture/handler.d.ts +2 -1
- package/dist/features/capture/handler.d.ts.map +1 -1
- package/dist/features/capture/handler.js +26 -23
- package/dist/features/capture/handler.js.map +1 -1
- package/dist/features/recall/formatter.d.ts +8 -1
- package/dist/features/recall/formatter.d.ts.map +1 -1
- package/dist/features/recall/formatter.js +79 -6
- package/dist/features/recall/formatter.js.map +1 -1
- package/dist/features/recall/handler.d.ts +2 -1
- package/dist/features/recall/handler.d.ts.map +1 -1
- package/dist/features/recall/handler.js +28 -2
- package/dist/features/recall/handler.js.map +1 -1
- package/dist/internal/agent-instructions.d.ts +1 -0
- package/dist/internal/agent-instructions.d.ts.map +1 -1
- package/dist/internal/agent-instructions.js +1 -0
- package/dist/internal/agent-instructions.js.map +1 -1
- package/dist/internal/agent-roles.d.ts +17 -0
- package/dist/internal/agent-roles.d.ts.map +1 -0
- package/dist/internal/agent-roles.js +142 -0
- package/dist/internal/agent-roles.js.map +1 -0
- package/dist/internal/session-goal.d.ts +12 -0
- package/dist/internal/session-goal.d.ts.map +1 -0
- package/dist/internal/session-goal.js +13 -0
- package/dist/internal/session-goal.js.map +1 -0
- package/dist/internal/session-state.d.ts +2 -0
- package/dist/internal/session-state.d.ts.map +1 -1
- package/dist/internal/session-state.js +5 -0
- package/dist/internal/session-state.js.map +1 -1
- package/dist/plugin/config.d.ts +10 -0
- package/dist/plugin/config.d.ts.map +1 -1
- package/dist/plugin/config.js +2 -0
- package/dist/plugin/config.js.map +1 -1
- package/dist/plugin/index.d.ts +4 -0
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +62 -6
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/tools.d.ts +4 -0
- package/dist/plugin/tools.d.ts.map +1 -1
- package/dist/plugin/tools.js +40 -0
- package/dist/plugin/tools.js.map +1 -1
- package/openclaw.plugin.json +25 -1
- package/package.json +1 -1
- package/skill/SKILL.md +33 -1
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
const PRESETS = {
|
|
2
|
+
developer: {
|
|
3
|
+
captureCategories: [
|
|
4
|
+
"Architecture decisions and trade-offs",
|
|
5
|
+
"Library and framework choices",
|
|
6
|
+
"API design patterns",
|
|
7
|
+
"Deployment and infrastructure config",
|
|
8
|
+
"Bug root causes and fixes",
|
|
9
|
+
"Code conventions and style preferences",
|
|
10
|
+
],
|
|
11
|
+
captureInstructions: "Focus on technical decisions with rationale, library/framework choices, architecture patterns, deployment configurations, and debugging insights. Skip routine code edits and command outputs.",
|
|
12
|
+
recallContext: "software engineering, technical decisions, code architecture",
|
|
13
|
+
},
|
|
14
|
+
researcher: {
|
|
15
|
+
captureCategories: [
|
|
16
|
+
"Research findings and data points",
|
|
17
|
+
"Hypotheses and assumptions",
|
|
18
|
+
"Methodology decisions",
|
|
19
|
+
"Source evaluations and references",
|
|
20
|
+
"Comparisons and trade-off analyses",
|
|
21
|
+
"Conclusions and recommendations",
|
|
22
|
+
],
|
|
23
|
+
captureInstructions: "Focus on research findings, data sources, methodology decisions, comparative analyses, and conclusions. Capture hypotheses and the evidence that supports or refutes them.",
|
|
24
|
+
recallContext: "research findings, analysis, methodology, evidence",
|
|
25
|
+
},
|
|
26
|
+
manager: {
|
|
27
|
+
captureCategories: [
|
|
28
|
+
"Project status and milestones",
|
|
29
|
+
"Team assignments and responsibilities",
|
|
30
|
+
"Deadlines and timelines",
|
|
31
|
+
"Stakeholder feedback and requests",
|
|
32
|
+
"Priority decisions and escalations",
|
|
33
|
+
"Resource constraints and blockers",
|
|
34
|
+
],
|
|
35
|
+
captureInstructions: "Focus on project status, team assignments, deadlines, stakeholder decisions, and priority changes. Capture who is responsible for what and when things are due.",
|
|
36
|
+
recallContext: "project status, team coordination, deadlines, priorities",
|
|
37
|
+
},
|
|
38
|
+
support: {
|
|
39
|
+
captureCategories: [
|
|
40
|
+
"Customer issues and resolutions",
|
|
41
|
+
"Troubleshooting steps and outcomes",
|
|
42
|
+
"Known issues and workarounds",
|
|
43
|
+
"Escalation paths and contacts",
|
|
44
|
+
"SLA and response time patterns",
|
|
45
|
+
"Configuration fixes",
|
|
46
|
+
],
|
|
47
|
+
captureInstructions: "Focus on customer issues, resolution steps, known workarounds, and escalation patterns. Capture what fixed the problem and how to reproduce it.",
|
|
48
|
+
recallContext: "customer issues, troubleshooting, resolutions, known problems",
|
|
49
|
+
},
|
|
50
|
+
generalist: {
|
|
51
|
+
captureCategories: [],
|
|
52
|
+
captureInstructions: "",
|
|
53
|
+
recallContext: "",
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
export function getRolePreset(role) {
|
|
57
|
+
return PRESETS[role];
|
|
58
|
+
}
|
|
59
|
+
// --- Auto-detection from bootstrap files ---
|
|
60
|
+
const BOOTSTRAP_FILES = ["SOUL.md", "AGENTS.md", "USER.md", "IDENTITY.md"];
|
|
61
|
+
const ROLE_SIGNALS = {
|
|
62
|
+
developer: [
|
|
63
|
+
/\b(engineer|developer|programmer|coder|software|coding|programming)\b/i,
|
|
64
|
+
/\b(code|deploy|debug|architecture|infrastructure|api|backend|frontend|fullstack)\b/i,
|
|
65
|
+
/\b(typescript|javascript|python|rust|go|react|node|docker|kubernetes|ci\/cd)\b/i,
|
|
66
|
+
/\b(repository|repo|git|branch|merge|pull request|commit)\b/i,
|
|
67
|
+
/\b(build|compile|lint|test suite|unit test|integration test)\b/i,
|
|
68
|
+
],
|
|
69
|
+
researcher: [
|
|
70
|
+
/\b(research|researcher|analyst|investigat|study|academic|scientist)\b/i,
|
|
71
|
+
/\b(hypothesis|methodology|findings|evidence|data|analysis|literature)\b/i,
|
|
72
|
+
/\b(compare|evaluate|assess|synthesize|review|survey|benchmark)\b/i,
|
|
73
|
+
/\b(paper|journal|citation|source|reference|publication)\b/i,
|
|
74
|
+
],
|
|
75
|
+
manager: [
|
|
76
|
+
/\b(manager|coordinator|lead|director|head of|team lead|project manager|scrum)\b/i,
|
|
77
|
+
/\b(project|milestone|deadline|timeline|roadmap|sprint|backlog)\b/i,
|
|
78
|
+
/\b(stakeholder|status update|standup|retro|planning|prioriti[sz])\b/i,
|
|
79
|
+
/\b(assign|delegate|resource|capacity|budget|schedule)\b/i,
|
|
80
|
+
],
|
|
81
|
+
support: [
|
|
82
|
+
/\b(support|helpdesk|help desk|customer service|customer success)\b/i,
|
|
83
|
+
/\b(ticket|incident|escalat|triage|sla|response time)\b/i,
|
|
84
|
+
/\b(troubleshoot|diagnos|workaround|known issue|resolution)\b/i,
|
|
85
|
+
/\b(customer|client|user complaint|user issue|bug report)\b/i,
|
|
86
|
+
],
|
|
87
|
+
};
|
|
88
|
+
function scoreText(text, signals) {
|
|
89
|
+
let hits = 0;
|
|
90
|
+
for (const pattern of signals) {
|
|
91
|
+
if (pattern.test(text))
|
|
92
|
+
hits++;
|
|
93
|
+
}
|
|
94
|
+
return hits;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Detects the agent's role by scanning bootstrap files for role-indicating
|
|
98
|
+
* keywords. Reads SOUL.md, AGENTS.md, USER.md, and IDENTITY.md in order,
|
|
99
|
+
* concatenates their content, and scores against role signal patterns.
|
|
100
|
+
*
|
|
101
|
+
* Returns the highest-scoring role, or undefined if no role scores above
|
|
102
|
+
* the minimum threshold (meaning the content is too generic to classify).
|
|
103
|
+
*/
|
|
104
|
+
export async function detectAgentRole(workspaceDir, agentDir) {
|
|
105
|
+
const { readFile } = await import("node:fs/promises");
|
|
106
|
+
const { join } = await import("node:path");
|
|
107
|
+
const texts = [];
|
|
108
|
+
// Check both workspace and agent-specific directories
|
|
109
|
+
const dirs = agentDir ? [agentDir, workspaceDir] : [workspaceDir];
|
|
110
|
+
for (const dir of dirs) {
|
|
111
|
+
for (const filename of BOOTSTRAP_FILES) {
|
|
112
|
+
try {
|
|
113
|
+
const content = await readFile(join(dir, filename), "utf-8");
|
|
114
|
+
if (content.trim())
|
|
115
|
+
texts.push(content);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// File doesn't exist — skip
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (texts.length === 0)
|
|
123
|
+
return undefined;
|
|
124
|
+
const combined = texts.join("\n");
|
|
125
|
+
const MIN_SCORE = 2; // need at least 2 signal hits to classify
|
|
126
|
+
const scores = [
|
|
127
|
+
["developer", scoreText(combined, ROLE_SIGNALS.developer)],
|
|
128
|
+
["researcher", scoreText(combined, ROLE_SIGNALS.researcher)],
|
|
129
|
+
["manager", scoreText(combined, ROLE_SIGNALS.manager)],
|
|
130
|
+
["support", scoreText(combined, ROLE_SIGNALS.support)],
|
|
131
|
+
];
|
|
132
|
+
scores.sort((a, b) => b[1] - a[1]);
|
|
133
|
+
const [topRole, topScore] = scores[0];
|
|
134
|
+
if (topScore < MIN_SCORE)
|
|
135
|
+
return undefined;
|
|
136
|
+
// Require clear winner — if top two are within 1 point, too ambiguous
|
|
137
|
+
const [, secondScore] = scores[1];
|
|
138
|
+
if (topScore - secondScore <= 1)
|
|
139
|
+
return undefined;
|
|
140
|
+
return topRole;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=agent-roles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-roles.js","sourceRoot":"","sources":["../../src/internal/agent-roles.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,GAAkC;IAC7C,SAAS,EAAE;QACT,iBAAiB,EAAE;YACjB,uCAAuC;YACvC,+BAA+B;YAC/B,qBAAqB;Y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AAC;IAEzC,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,SAAS,GAAG,CAAC,CAAC,CAAC,0CAA0C;IAE/D,MAAM,MAAM,GAA0B;QACpC,CAAC,WAAW,EAAE,SAAS,CAAC,QAAQ,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;QAC1D,CAAC,YAAY,EAAE,SAAS,CAAC,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC;QAC5D,CAAC,SAAS,EAAE,SAAS,CAAC,QAAQ,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;QACtD,CAAC,SAAS,EAAE,SAAS,CAAC,QAAQ,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;KACvD,CAAC;IAEF,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEnC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACtC,IAAI,QAAQ,GAAG,SAAS;QAAE,OAAO,SAAS,CAAC;IAE3C,sEAAsE;IACtE,MAAM,CAAC,EAAE,WAAW,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAClC,IAAI,QAAQ,GAAG,WAAW,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IAElD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface SessionGoal {
|
|
2
|
+
goal: string;
|
|
3
|
+
setAt: string;
|
|
4
|
+
setBy: "agent" | "user";
|
|
5
|
+
}
|
|
6
|
+
export declare class SessionGoalStore {
|
|
7
|
+
private current;
|
|
8
|
+
get(): SessionGoal | undefined;
|
|
9
|
+
set(goal: SessionGoal): void;
|
|
10
|
+
clear(): void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=session-goal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-goal.d.ts","sourceRoot":"","sources":["../../src/internal/session-goal.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;CACzB;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAA0B;IAEzC,GAAG,IAAI,WAAW,GAAG,SAAS;IAI9B,GAAG,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAI5B,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-goal.js","sourceRoot":"","sources":["../../src/internal/session-goal.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,gBAAgB;IACnB,OAAO,CAA0B;IAEzC,GAAG;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,GAAG,CAAC,IAAiB;QACnB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -4,6 +4,7 @@ export interface DirtySessionState {
|
|
|
4
4
|
sessionKey: string;
|
|
5
5
|
updatedAt: string;
|
|
6
6
|
summary?: string;
|
|
7
|
+
currentGoal?: string;
|
|
7
8
|
}
|
|
8
9
|
export declare function buildSessionSummaryFromMessages(messages: unknown[]): string | undefined;
|
|
9
10
|
export declare function formatRecoveryContext(state: DirtySessionState): string;
|
|
@@ -14,6 +15,7 @@ export declare class SessionStateStore {
|
|
|
14
15
|
pluginSessionId: string;
|
|
15
16
|
sessionKey: string;
|
|
16
17
|
summary?: string;
|
|
18
|
+
currentGoal?: string;
|
|
17
19
|
}): Promise<void>;
|
|
18
20
|
clear(): Promise<void>;
|
|
19
21
|
readDirtyFromPriorLifecycle(currentPluginSessionId: string): Promise<DirtySessionState | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-state.d.ts","sourceRoot":"","sources":["../../src/internal/session-state.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,IAAI,CAAC;IACZ,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"session-state.d.ts","sourceRoot":"","sources":["../../src/internal/session-state.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,IAAI,CAAC;IACZ,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA4BD,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,GAAG,SAAS,CAuBvF;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAgBtE;AAED,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,GAAE,MAA2B;IAE5D,SAAS,CAAC,KAAK,EAAE;QACrB,eAAe,EAAE,MAAM,CAAC;QACxB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,CAAC,IAAI,CAAC;IAaX,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAUtB,2BAA2B,CAAC,sBAAsB,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;YAetF,IAAI;CAUnB"}
|
|
@@ -51,6 +51,9 @@ export function formatRecoveryContext(state) {
|
|
|
51
51
|
`- Previous session: ${state.sessionKey}`,
|
|
52
52
|
`- Last activity: ${state.updatedAt}`,
|
|
53
53
|
];
|
|
54
|
+
if (state.currentGoal) {
|
|
55
|
+
lines.push(`- Session goal: ${state.currentGoal}`);
|
|
56
|
+
}
|
|
54
57
|
if (state.summary) {
|
|
55
58
|
lines.push(`- Last known focus: ${state.summary}`);
|
|
56
59
|
}
|
|
@@ -69,6 +72,7 @@ export class SessionStateStore {
|
|
|
69
72
|
sessionKey: state.sessionKey,
|
|
70
73
|
updatedAt: new Date().toISOString(),
|
|
71
74
|
summary: state.summary?.trim() || undefined,
|
|
75
|
+
currentGoal: state.currentGoal?.trim() || undefined,
|
|
72
76
|
};
|
|
73
77
|
await mkdir(dirname(this.filePath), { recursive: true });
|
|
74
78
|
await writeFile(this.filePath, JSON.stringify(payload, null, 2), "utf-8");
|
|
@@ -97,6 +101,7 @@ export class SessionStateStore {
|
|
|
97
101
|
sessionKey: state.sessionKey,
|
|
98
102
|
updatedAt: state.updatedAt,
|
|
99
103
|
summary: state.summary,
|
|
104
|
+
currentGoal: state.currentGoal,
|
|
100
105
|
};
|
|
101
106
|
}
|
|
102
107
|
async read() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-state.js","sourceRoot":"","sources":["../../src/internal/session-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,mCAAmC,EAAE,MAAM,yBAAyB,CAAC;AAE9E,MAAM,kBAAkB,GAAG,I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,EAAE,CAAC;gBACrD,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,2BAA2B,CAAC,sBAA8B;QAC9D,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAChC,IAAI,CAAC,KAAK,EAAE,KAAK;YAAE,OAAO,IAAI,CAAC;QAC/B,IAAI,CAAC,KAAK,CAAC,eAAe,IAAI,KAAK,CAAC,eAAe,KAAK,sBAAsB;YAAE,OAAO,IAAI,CAAC;QAC5F,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,CAAC,KAAK,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC;QACvD,OAAO;YACL,KAAK,EAAE,IAAI;YACX,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,WAAW,EAAE,KAAK,CAAC,WAAW;SAC/B,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,IAAI;QAChB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACnD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAY,CAAC;YAC1C,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;gBAAE,OAAO,IAAI,CAAC;YAC/D,OAAO,MAA+B,CAAC;QACzC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
package/dist/plugin/config.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export declare const CortexConfigSchema: z.ZodObject<{
|
|
|
19
19
|
namespace: z.ZodDefault<z.ZodString>;
|
|
20
20
|
captureInstructions: z.ZodOptional<z.ZodString>;
|
|
21
21
|
captureCategories: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
22
|
+
sessionGoal: z.ZodDefault<z.ZodBoolean>;
|
|
23
|
+
agentRole: z.ZodOptional<z.ZodEnum<["developer", "researcher", "manager", "support", "generalist"]>>;
|
|
22
24
|
/**
|
|
23
25
|
* Optional fixed reference date (ISO 8601) to use as the temporal anchor for
|
|
24
26
|
* all recall queries instead of `new Date()`. Useful when replaying historical
|
|
@@ -46,10 +48,12 @@ export declare const CortexConfigSchema: z.ZodObject<{
|
|
|
46
48
|
noveltyThreshold: number;
|
|
47
49
|
auditLog: boolean;
|
|
48
50
|
namespace: string;
|
|
51
|
+
sessionGoal: boolean;
|
|
49
52
|
apiKey?: string | undefined;
|
|
50
53
|
userId?: string | undefined;
|
|
51
54
|
captureInstructions?: string | undefined;
|
|
52
55
|
captureCategories?: string[] | undefined;
|
|
56
|
+
agentRole?: "developer" | "researcher" | "manager" | "support" | "generalist" | undefined;
|
|
53
57
|
recallReferenceDate?: string | undefined;
|
|
54
58
|
}, {
|
|
55
59
|
apiKey?: string | undefined;
|
|
@@ -71,6 +75,8 @@ export declare const CortexConfigSchema: z.ZodObject<{
|
|
|
71
75
|
namespace?: string | undefined;
|
|
72
76
|
captureInstructions?: string | undefined;
|
|
73
77
|
captureCategories?: string[] | undefined;
|
|
78
|
+
sessionGoal?: boolean | undefined;
|
|
79
|
+
agentRole?: "developer" | "researcher" | "manager" | "support" | "generalist" | undefined;
|
|
74
80
|
recallReferenceDate?: string | undefined;
|
|
75
81
|
}>;
|
|
76
82
|
export type CortexConfig = z.infer<typeof CortexConfigSchema>;
|
|
@@ -99,6 +105,8 @@ export declare const configSchema: {
|
|
|
99
105
|
namespace?: string | undefined;
|
|
100
106
|
captureInstructions?: string | undefined;
|
|
101
107
|
captureCategories?: string[] | undefined;
|
|
108
|
+
sessionGoal?: boolean | undefined;
|
|
109
|
+
agentRole?: "developer" | "researcher" | "manager" | "support" | "generalist" | undefined;
|
|
102
110
|
recallReferenceDate?: string | undefined;
|
|
103
111
|
}, {
|
|
104
112
|
baseUrl: string;
|
|
@@ -116,10 +124,12 @@ export declare const configSchema: {
|
|
|
116
124
|
noveltyThreshold: number;
|
|
117
125
|
auditLog: boolean;
|
|
118
126
|
namespace: string;
|
|
127
|
+
sessionGoal: boolean;
|
|
119
128
|
apiKey?: string | undefined;
|
|
120
129
|
userId?: string | undefined;
|
|
121
130
|
captureInstructions?: string | undefined;
|
|
122
131
|
captureCategories?: string[] | undefined;
|
|
132
|
+
agentRole?: "developer" | "researcher" | "manager" | "support" | "generalist" | undefined;
|
|
123
133
|
recallReferenceDate?: string | undefined;
|
|
124
134
|
}>;
|
|
125
135
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/plugin/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAwBxB,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/plugin/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAwBxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;IAwB7B;;;;;;;;;OASG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEH,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,YAAY;qBACN,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGzB,CAAC"}
|
package/dist/plugin/config.js
CHANGED
|
@@ -36,6 +36,8 @@ export const CortexConfigSchema = z.object({
|
|
|
36
36
|
namespace: z.string().min(1).default("openclaw"),
|
|
37
37
|
captureInstructions: z.string().max(2000).optional(),
|
|
38
38
|
captureCategories: z.array(z.string().min(1).max(100)).max(20).optional(),
|
|
39
|
+
sessionGoal: z.boolean().default(true),
|
|
40
|
+
agentRole: z.enum(["developer", "researcher", "manager", "support", "generalist"]).optional(),
|
|
39
41
|
/**
|
|
40
42
|
* Optional fixed reference date (ISO 8601) to use as the temporal anchor for
|
|
41
43
|
* all recall queries instead of `new Date()`. Useful when replaying historical
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/plugin/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,QAAQ,GAAG,CAAC;KACf,MAAM,EAAE;KACR,GAAG,CAAC,6BAA6B,CAAC;KAClC,MAAM,CACL,CAAC,GAAG,EAAE,EAAE;IACN,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC9C,wDAAwD;IACxD,IACE,MAAM,CAAC,QAAQ,KAAK,OAAO;QAC3B,CAAC,MAAM,CAAC,QAAQ,KAAK,WAAW,IAAI,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC,EACpE,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,EACD,EAAE,OAAO,EAAE,0DAA0D,EAAE,CACxE,CAAC;AAEJ,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACpC,OAAO,EAAE,QAAQ,CAAC,OAAO,CACvB,6DAA6D,CAC9D;IACD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACpC,UAAU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C,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IAChD,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;IACpD,iBAAiB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE;IACzE,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IACtC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC7F;;;;;;;;;OASG;IACH,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;CAClD,CAAC,CAAC;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,SAAS,CAAC,KAAc;QACtB,OAAO,kBAAkB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;CACF,CAAC"}
|
package/dist/plugin/index.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ declare const plugin: {
|
|
|
32
32
|
namespace?: string | undefined;
|
|
33
33
|
captureInstructions?: string | undefined;
|
|
34
34
|
captureCategories?: string[] | undefined;
|
|
35
|
+
sessionGoal?: boolean | undefined;
|
|
36
|
+
agentRole?: "developer" | "researcher" | "manager" | "support" | "generalist" | undefined;
|
|
35
37
|
recallReferenceDate?: string | undefined;
|
|
36
38
|
}, {
|
|
37
39
|
baseUrl: string;
|
|
@@ -49,10 +51,12 @@ declare const plugin: {
|
|
|
49
51
|
noveltyThreshold: number;
|
|
50
52
|
auditLog: boolean;
|
|
51
53
|
namespace: string;
|
|
54
|
+
sessionGoal: boolean;
|
|
52
55
|
apiKey?: string | undefined;
|
|
53
56
|
userId?: string | undefined;
|
|
54
57
|
captureInstructions?: string | undefined;
|
|
55
58
|
captureCategories?: string[] | undefined;
|
|
59
|
+
agentRole?: "developer" | "researcher" | "manager" | "support" | "generalist" | undefined;
|
|
56
60
|
recallReferenceDate?: string | undefined;
|
|
57
61
|
}>;
|
|
58
62
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAEV,SAAS,EAEV,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAEV,SAAS,EAEV,MAAM,YAAY,CAAC;AAiDpB,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;IACpD,WAAW,EAAE,MAAM,CAAC;CACrB;AA+RD,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBASI,SAAS;CA2gBxB,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/plugin/index.js
CHANGED
|
@@ -21,7 +21,9 @@ import { createHeartbeatHandler } from "../features/heartbeat/handler.js";
|
|
|
21
21
|
import { buildSessionSummaryFromMessages, formatRecoveryContext, SessionStateStore, } from "../internal/session-state.js";
|
|
22
22
|
import { sanitizeMessageForTranscript } from "../internal/message-sanitizer.js";
|
|
23
23
|
import { registerCliCommands } from "./cli.js";
|
|
24
|
-
import { buildSearchMemoryTool, buildSaveMemoryTool, buildForgetMemoryTool, buildGetMemoryTool } from "./tools.js";
|
|
24
|
+
import { buildSearchMemoryTool, buildSaveMemoryTool, buildForgetMemoryTool, buildGetMemoryTool, buildSetSessionGoalTool } from "./tools.js";
|
|
25
|
+
import { SessionGoalStore } from "../internal/session-goal.js";
|
|
26
|
+
import { getRolePreset, detectAgentRole } from "../internal/agent-roles.js";
|
|
25
27
|
import { buildCommands } from "./commands.js";
|
|
26
28
|
const version = packageJson.version;
|
|
27
29
|
const PACKAGE_NAME = packageJson.name;
|
|
@@ -191,6 +193,7 @@ const CORTEX_TOOL_NAMES = [
|
|
|
191
193
|
"cortex_get_memory",
|
|
192
194
|
"cortex_save_memory",
|
|
193
195
|
"cortex_forget",
|
|
196
|
+
"cortex_set_session_goal",
|
|
194
197
|
];
|
|
195
198
|
const PLUGIN_ID = "openclaw-cortex";
|
|
196
199
|
/**
|
|
@@ -341,6 +344,17 @@ const plugin = {
|
|
|
341
344
|
ensureToolsAllowlist(api.logger);
|
|
342
345
|
// Install the cortex-memory skill (idempotent, updates on version change)
|
|
343
346
|
installSkill(api.logger);
|
|
347
|
+
// Resolve agent role preset — fills in captureCategories and captureInstructions
|
|
348
|
+
// unless the user explicitly provided them in their config.
|
|
349
|
+
// Mutable: start() may update these via auto-detection from bootstrap files.
|
|
350
|
+
let resolvedRole = config.agentRole;
|
|
351
|
+
let rolePreset = resolvedRole ? getRolePreset(resolvedRole) : undefined;
|
|
352
|
+
let effectiveCaptureCategories = (Array.isArray(raw.captureCategories) ? raw.captureCategories : undefined)
|
|
353
|
+
?? rolePreset?.captureCategories
|
|
354
|
+
?? undefined;
|
|
355
|
+
let effectiveCaptureInstructions = (typeof raw.captureInstructions === "string" ? raw.captureInstructions : undefined)
|
|
356
|
+
?? rolePreset?.captureInstructions
|
|
357
|
+
?? undefined;
|
|
344
358
|
const client = new CortexClient(config.baseUrl, resolvedApiKey);
|
|
345
359
|
const retryQueue = new RetryQueue(api.logger);
|
|
346
360
|
const recallMetrics = new LatencyMetrics();
|
|
@@ -352,6 +366,7 @@ const plugin = {
|
|
|
352
366
|
maturity: "unknown",
|
|
353
367
|
lastChecked: 0,
|
|
354
368
|
};
|
|
369
|
+
const sessionGoalStore = new SessionGoalStore();
|
|
355
370
|
// Session ID for this plugin lifecycle — groups tool-saved memories into
|
|
356
371
|
// a single Cortex SESSION node so total_sessions increments properly.
|
|
357
372
|
const sessionId = randomUUID();
|
|
@@ -420,16 +435,24 @@ const plugin = {
|
|
|
420
435
|
// --- Hooks ---
|
|
421
436
|
// Track last messages for /checkpoint command (populated by agent_end wrapper)
|
|
422
437
|
let lastMessages = [];
|
|
438
|
+
let previousSessionKey;
|
|
423
439
|
const recoveryCheckedSessions = new Set();
|
|
424
440
|
const recallHandler = createRecallHandler(client, config, api.logger, recallMetrics, knowledgeState, () => userId, auditLoggerProxy, (stats) => {
|
|
425
441
|
sessionStats.recallCount++;
|
|
426
442
|
sessionStats.recallMemoriesTotal += stats.memoriesReturned;
|
|
427
443
|
sessionStats.recallDuplicatesCollapsed += stats.collapsedCount;
|
|
428
444
|
persistStats(sessionStats);
|
|
429
|
-
}, echoStore);
|
|
445
|
+
}, echoStore, sessionGoalStore, () => rolePreset?.recallContext);
|
|
430
446
|
// Auto-Recall: inject relevant memories before every agent turn
|
|
431
447
|
registerHookCompat(api, "before_agent_start", async (event, ctx) => {
|
|
432
448
|
const activeSessionKey = resolveSessionKey(ctx, sessionId);
|
|
449
|
+
// Clear session goal when switching to a new session (e.g. /new)
|
|
450
|
+
// so the previous chat's goal doesn't bias the new session's recall/capture.
|
|
451
|
+
if (previousSessionKey && previousSessionKey !== activeSessionKey) {
|
|
452
|
+
sessionGoalStore.clear();
|
|
453
|
+
api.logger.debug?.("Cortex session goal cleared (session changed)");
|
|
454
|
+
}
|
|
455
|
+
previousSessionKey = activeSessionKey;
|
|
433
456
|
currentSessionKey = activeSessionKey;
|
|
434
457
|
let recoveryContext;
|
|
435
458
|
if (!recoveryCheckedSessions.has(activeSessionKey)) {
|
|
@@ -438,6 +461,14 @@ const plugin = {
|
|
|
438
461
|
const dirty = await sessionState.readDirtyFromPriorLifecycle(sessionId);
|
|
439
462
|
if (dirty) {
|
|
440
463
|
recoveryContext = formatRecoveryContext(dirty);
|
|
464
|
+
if (dirty.currentGoal && !sessionGoalStore.get()) {
|
|
465
|
+
sessionGoalStore.set({
|
|
466
|
+
goal: dirty.currentGoal,
|
|
467
|
+
setAt: dirty.updatedAt,
|
|
468
|
+
setBy: "agent",
|
|
469
|
+
});
|
|
470
|
+
api.logger.info(`Cortex recovery: restored session goal "${dirty.currentGoal.slice(0, 60)}"`);
|
|
471
|
+
}
|
|
441
472
|
await sessionState.clear();
|
|
442
473
|
api.logger.warn(`Cortex recovery: detected unclean previous session (${dirty.sessionKey})`);
|
|
443
474
|
}
|
|
@@ -461,7 +492,7 @@ const plugin = {
|
|
|
461
492
|
// Auto-Capture: extract facts after agent responses
|
|
462
493
|
const watermarkStore = new CaptureWatermarkStore();
|
|
463
494
|
void watermarkStore.load().catch((err) => api.logger.debug?.(`Cortex watermark load failed: ${String(err)}`));
|
|
464
|
-
const captureHandler = createCaptureHandler(client, config, api.logger, retryQueue, knowledgeState, () => userId, userIdReady, sessionId, auditLoggerProxy, echoStore, watermarkStore);
|
|
495
|
+
const captureHandler = createCaptureHandler(client, config, api.logger, retryQueue, knowledgeState, () => userId, userIdReady, sessionId, auditLoggerProxy, echoStore, watermarkStore, sessionGoalStore);
|
|
465
496
|
registerHookCompat(api, "agent_end", async (event) => {
|
|
466
497
|
if (event.messages?.length) {
|
|
467
498
|
lastMessages = event.messages;
|
|
@@ -473,6 +504,7 @@ const plugin = {
|
|
|
473
504
|
pluginSessionId: sessionId,
|
|
474
505
|
sessionKey: activeSessionKey,
|
|
475
506
|
summary,
|
|
507
|
+
currentGoal: sessionGoalStore.get()?.goal,
|
|
476
508
|
});
|
|
477
509
|
}
|
|
478
510
|
catch (err) {
|
|
@@ -533,12 +565,15 @@ const plugin = {
|
|
|
533
565
|
auditLoggerProxy,
|
|
534
566
|
knowledgeState,
|
|
535
567
|
recentSaves,
|
|
568
|
+
sessionGoalStore,
|
|
569
|
+
getRoleContext: () => rolePreset?.recallContext,
|
|
536
570
|
};
|
|
537
571
|
api.registerTool(buildSearchMemoryTool(toolsDeps));
|
|
538
572
|
api.registerTool(buildGetMemoryTool(toolsDeps));
|
|
539
573
|
api.registerTool(buildSaveMemoryTool(toolsDeps));
|
|
540
574
|
api.registerTool(buildForgetMemoryTool(toolsDeps));
|
|
541
|
-
api.
|
|
575
|
+
api.registerTool(buildSetSessionGoalTool(toolsDeps));
|
|
576
|
+
api.logger.debug?.("Cortex tools registered: cortex_search_memory, cortex_get_memory, cortex_save_memory, cortex_forget, cortex_set_session_goal");
|
|
542
577
|
}
|
|
543
578
|
// --- Auto-Reply Commands ---
|
|
544
579
|
if (api.registerCommand) {
|
|
@@ -657,11 +692,32 @@ const plugin = {
|
|
|
657
692
|
namespace = deriveNamespace(ctx.workspaceDir);
|
|
658
693
|
api.logger.debug?.(`Cortex namespace: ${namespace}`);
|
|
659
694
|
}
|
|
695
|
+
// Auto-detect agent role from bootstrap files when not explicitly configured.
|
|
696
|
+
// Scans SOUL.md, AGENTS.md, USER.md, IDENTITY.md for role-indicating keywords.
|
|
697
|
+
if (!resolvedRole && ctx.workspaceDir) {
|
|
698
|
+
void detectAgentRole(ctx.workspaceDir).then((detected) => {
|
|
699
|
+
if (detected) {
|
|
700
|
+
resolvedRole = detected;
|
|
701
|
+
rolePreset = getRolePreset(detected);
|
|
702
|
+
// Only fill in capture settings if user didn't provide them explicitly
|
|
703
|
+
if (!effectiveCaptureCategories && rolePreset.captureCategories.length > 0) {
|
|
704
|
+
effectiveCaptureCategories = rolePreset.captureCategories;
|
|
705
|
+
}
|
|
706
|
+
if (!effectiveCaptureInstructions && rolePreset.captureInstructions) {
|
|
707
|
+
effectiveCaptureInstructions = rolePreset.captureInstructions;
|
|
708
|
+
}
|
|
709
|
+
api.logger.info(`Cortex: auto-detected agent role "${detected}" from bootstrap files`);
|
|
710
|
+
}
|
|
711
|
+
}).catch((err) => {
|
|
712
|
+
api.logger.debug?.(`Cortex: role auto-detection failed (non-fatal): ${String(err)}`);
|
|
713
|
+
});
|
|
714
|
+
}
|
|
660
715
|
// Inject Cortex instructions into AGENTS.md (idempotent)
|
|
661
716
|
if (ctx.workspaceDir) {
|
|
662
717
|
void injectAgentInstructions(ctx.workspaceDir, api.logger, {
|
|
663
|
-
captureInstructions:
|
|
664
|
-
captureCategories:
|
|
718
|
+
captureInstructions: effectiveCaptureInstructions,
|
|
719
|
+
captureCategories: effectiveCaptureCategories,
|
|
720
|
+
agentRole: resolvedRole,
|
|
665
721
|
});
|
|
666
722
|
}
|
|
667
723
|
api.logger.debug?.("Cortex services started");
|