@agentlensai/cli 0.3.0 → 0.5.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/commands/context.d.ts +2 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +105 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/lessons.d.ts +2 -0
- package/dist/commands/lessons.d.ts.map +1 -0
- package/dist/commands/lessons.js +373 -0
- package/dist/commands/lessons.js.map +1 -0
- package/dist/commands/recall.d.ts +2 -0
- package/dist/commands/recall.d.ts.map +1 -0
- package/dist/commands/recall.js +84 -0
- package/dist/commands/recall.js.map +1 -0
- package/dist/commands/reflect.d.ts +2 -0
- package/dist/commands/reflect.d.ts.map +1 -0
- package/dist/commands/reflect.js +210 -0
- package/dist/commands/reflect.js.map +1 -0
- package/dist/index.js +21 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/LICENSE +0 -21
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/commands/context.ts"],"names":[],"mappings":"AA2BA,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAyFrE"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentlens context — Cross-session context retrieval
|
|
3
|
+
*/
|
|
4
|
+
import { parseArgs } from 'node:util';
|
|
5
|
+
import { createClientFromConfig } from '../lib/client.js';
|
|
6
|
+
import { printJson, truncate, formatTimestamp } from '../lib/output.js';
|
|
7
|
+
const HELP = `Usage: agentlens context <topic> [options]
|
|
8
|
+
|
|
9
|
+
Retrieve cross-session context for a topic — session summaries with relevance scores and related lessons.
|
|
10
|
+
|
|
11
|
+
Arguments:
|
|
12
|
+
topic Topic to retrieve context for
|
|
13
|
+
|
|
14
|
+
Options:
|
|
15
|
+
--user <id> Filter by user ID
|
|
16
|
+
--agent <id> Filter by agent ID
|
|
17
|
+
--limit <n> Maximum number of sessions (default: 5)
|
|
18
|
+
--url <url> Server URL (overrides config)
|
|
19
|
+
-j, --json Output raw JSON
|
|
20
|
+
-h, --help Show help
|
|
21
|
+
|
|
22
|
+
Examples:
|
|
23
|
+
agentlens context "database migrations"
|
|
24
|
+
agentlens context "user authentication" --user user123
|
|
25
|
+
agentlens context "API rate limiting" --agent my-agent --limit 3`;
|
|
26
|
+
export async function runContextCommand(argv) {
|
|
27
|
+
const { values, positionals } = parseArgs({
|
|
28
|
+
args: argv,
|
|
29
|
+
options: {
|
|
30
|
+
user: { type: 'string', short: 'u' },
|
|
31
|
+
agent: { type: 'string', short: 'a' },
|
|
32
|
+
limit: { type: 'string', short: 'l' },
|
|
33
|
+
url: { type: 'string' },
|
|
34
|
+
json: { type: 'boolean', short: 'j', default: false },
|
|
35
|
+
help: { type: 'boolean', short: 'h', default: false },
|
|
36
|
+
},
|
|
37
|
+
allowPositionals: true,
|
|
38
|
+
});
|
|
39
|
+
if (values.help) {
|
|
40
|
+
console.log(HELP);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const topic = positionals[0];
|
|
44
|
+
if (!topic) {
|
|
45
|
+
console.error('Error: Topic argument is required.\n');
|
|
46
|
+
console.log(HELP);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
const client = createClientFromConfig(values.url);
|
|
50
|
+
const result = await client.getContext({
|
|
51
|
+
topic,
|
|
52
|
+
userId: values.user ?? undefined,
|
|
53
|
+
agentId: values.agent ?? undefined,
|
|
54
|
+
limit: values.limit ? parseInt(values.limit, 10) : undefined,
|
|
55
|
+
});
|
|
56
|
+
if (values.json) {
|
|
57
|
+
printJson(result);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
console.log(`\nContext for "${result.topic}"\n`);
|
|
61
|
+
if (result.summary) {
|
|
62
|
+
console.log(`Summary: ${result.summary}\n`);
|
|
63
|
+
}
|
|
64
|
+
// Sessions
|
|
65
|
+
if (result.sessions.length > 0) {
|
|
66
|
+
console.log(`Related Sessions (${result.sessions.length} of ${result.totalSessions ?? result.sessions.length}):\n`);
|
|
67
|
+
for (const session of result.sessions) {
|
|
68
|
+
const score = `${(session.relevanceScore * 100).toFixed(1)}%`;
|
|
69
|
+
const started = formatTimestamp(session.startedAt);
|
|
70
|
+
const agent = 'agentId' in session ? session.agentId : '';
|
|
71
|
+
console.log(` [${score}] Session ${truncate(session.sessionId, 20)}`);
|
|
72
|
+
if (agent) {
|
|
73
|
+
console.log(` Agent: ${agent}`);
|
|
74
|
+
}
|
|
75
|
+
console.log(` Started: ${started}`);
|
|
76
|
+
if (session.summary) {
|
|
77
|
+
console.log(` ${truncate(session.summary, 80)}`);
|
|
78
|
+
}
|
|
79
|
+
if (session.keyEvents && session.keyEvents.length > 0) {
|
|
80
|
+
console.log(' Key events:');
|
|
81
|
+
for (const event of session.keyEvents.slice(0, 3)) {
|
|
82
|
+
console.log(` - [${event.eventType}] ${truncate(event.summary, 60)}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
console.log('');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
console.log('No related sessions found.\n');
|
|
90
|
+
}
|
|
91
|
+
// Lessons
|
|
92
|
+
if (result.lessons.length > 0) {
|
|
93
|
+
console.log(`Related Lessons (${result.lessons.length}):\n`);
|
|
94
|
+
for (const lesson of result.lessons) {
|
|
95
|
+
const score = `${(lesson.relevanceScore * 100).toFixed(1)}%`;
|
|
96
|
+
console.log(` [${score}] ${lesson.title} (${lesson.category})`);
|
|
97
|
+
console.log(` ${truncate(lesson.content.replace(/\n/g, ' '), 80)}`);
|
|
98
|
+
console.log('');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
console.log('No related lessons found.\n');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 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,GAAG,CAAC,oBAAoB,MAAM,CAAC,OAAO,CAAC,MAAM,MAAM,CAAC,CAAC;QAE7D,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACpC,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;YAC7D,OAAO,CAAC,GAAG,CAAC,MAAM,KAAK,KAAK,MAAM,CAAC,KAAK,KAAK,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC;YACjE,OAAO,CAAC,GAAG,CAAC,aAAa,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;YAC7E,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lessons.d.ts","sourceRoot":"","sources":["../../src/commands/lessons.ts"],"names":[],"mappings":"AAqDA,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCrE"}
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentlens lessons — Manage agent lessons (CRUD + search)
|
|
3
|
+
*/
|
|
4
|
+
import { parseArgs } from 'node:util';
|
|
5
|
+
import { createClientFromConfig } from '../lib/client.js';
|
|
6
|
+
import { printTable, printJson, truncate, formatTimestamp } from '../lib/output.js';
|
|
7
|
+
const HELP = `Usage: agentlens lessons <subcommand> [options]
|
|
8
|
+
|
|
9
|
+
Manage agent lessons — distilled insights and knowledge.
|
|
10
|
+
|
|
11
|
+
Subcommands:
|
|
12
|
+
list List lessons
|
|
13
|
+
create Create a new lesson
|
|
14
|
+
get <id> Get a lesson by ID
|
|
15
|
+
update <id> Update a lesson
|
|
16
|
+
delete <id> Delete (archive) a lesson
|
|
17
|
+
search <query> Search lessons by text
|
|
18
|
+
|
|
19
|
+
Options (common):
|
|
20
|
+
--url <url> Server URL (overrides config)
|
|
21
|
+
-j, --json Output raw JSON
|
|
22
|
+
-h, --help Show help
|
|
23
|
+
|
|
24
|
+
Options (list):
|
|
25
|
+
--category <cat> Filter by category
|
|
26
|
+
--importance <level> Filter by importance: low|normal|high|critical
|
|
27
|
+
--agent <id> Filter by agent ID
|
|
28
|
+
--limit <n> Max results (default: 20)
|
|
29
|
+
--offset <n> Pagination offset
|
|
30
|
+
|
|
31
|
+
Options (create):
|
|
32
|
+
--title <title> Lesson title (required)
|
|
33
|
+
--content <text> Lesson content (required)
|
|
34
|
+
--category <cat> Category (default: general)
|
|
35
|
+
--importance <level> Importance: low|normal|high|critical (default: normal)
|
|
36
|
+
--agent <id> Agent ID to scope the lesson to
|
|
37
|
+
|
|
38
|
+
Options (update):
|
|
39
|
+
--title <title> New title
|
|
40
|
+
--content <text> New content
|
|
41
|
+
--category <cat> New category
|
|
42
|
+
--importance <level> New importance level
|
|
43
|
+
|
|
44
|
+
Examples:
|
|
45
|
+
agentlens lessons list
|
|
46
|
+
agentlens lessons list --category deployment --importance high
|
|
47
|
+
agentlens lessons create --title "Always run tests" --content "Run test suite before deploying" --category deployment
|
|
48
|
+
agentlens lessons get abc123
|
|
49
|
+
agentlens lessons update abc123 --content "updated content"
|
|
50
|
+
agentlens lessons delete abc123
|
|
51
|
+
agentlens lessons search "deployment best practices"`;
|
|
52
|
+
export async function runLessonsCommand(argv) {
|
|
53
|
+
const subcommand = argv[0];
|
|
54
|
+
const rest = argv.slice(1);
|
|
55
|
+
switch (subcommand) {
|
|
56
|
+
case 'list':
|
|
57
|
+
await runLessonsList(rest);
|
|
58
|
+
break;
|
|
59
|
+
case 'create':
|
|
60
|
+
await runLessonsCreate(rest);
|
|
61
|
+
break;
|
|
62
|
+
case 'get':
|
|
63
|
+
await runLessonsGet(rest);
|
|
64
|
+
break;
|
|
65
|
+
case 'update':
|
|
66
|
+
await runLessonsUpdate(rest);
|
|
67
|
+
break;
|
|
68
|
+
case 'delete':
|
|
69
|
+
await runLessonsDelete(rest);
|
|
70
|
+
break;
|
|
71
|
+
case 'search':
|
|
72
|
+
await runLessonsSearch(rest);
|
|
73
|
+
break;
|
|
74
|
+
case '--help':
|
|
75
|
+
case '-h':
|
|
76
|
+
case undefined:
|
|
77
|
+
console.log(HELP);
|
|
78
|
+
break;
|
|
79
|
+
default:
|
|
80
|
+
console.error(`Unknown lessons subcommand: ${subcommand}`);
|
|
81
|
+
console.log(HELP);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function parseLessonsArgs(argv) {
|
|
86
|
+
return parseArgs({
|
|
87
|
+
args: argv,
|
|
88
|
+
options: {
|
|
89
|
+
title: { type: 'string' },
|
|
90
|
+
content: { type: 'string' },
|
|
91
|
+
category: { type: 'string' },
|
|
92
|
+
importance: { type: 'string' },
|
|
93
|
+
agent: { type: 'string', short: 'a' },
|
|
94
|
+
limit: { type: 'string', short: 'l' },
|
|
95
|
+
offset: { type: 'string' },
|
|
96
|
+
url: { type: 'string' },
|
|
97
|
+
json: { type: 'boolean', short: 'j', default: false },
|
|
98
|
+
help: { type: 'boolean', short: 'h', default: false },
|
|
99
|
+
},
|
|
100
|
+
allowPositionals: true,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* agentlens lessons list
|
|
105
|
+
*/
|
|
106
|
+
async function runLessonsList(argv) {
|
|
107
|
+
const { values } = parseLessonsArgs(argv);
|
|
108
|
+
if (values.help) {
|
|
109
|
+
console.log(`Usage: agentlens lessons list [options]
|
|
110
|
+
|
|
111
|
+
List lessons with optional filters.
|
|
112
|
+
|
|
113
|
+
Options:
|
|
114
|
+
--category <cat> Filter by category
|
|
115
|
+
--importance <level> Filter by importance: low|normal|high|critical
|
|
116
|
+
--agent <id> Filter by agent ID
|
|
117
|
+
--limit <n> Max results (default: 20)
|
|
118
|
+
--offset <n> Pagination offset
|
|
119
|
+
--url <url> Server URL
|
|
120
|
+
-j, --json Output raw JSON
|
|
121
|
+
-h, --help Show help`);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const client = createClientFromConfig(values.url);
|
|
125
|
+
const result = await client.getLessons({
|
|
126
|
+
category: values.category ?? undefined,
|
|
127
|
+
importance: values.importance ?? undefined,
|
|
128
|
+
agentId: values.agent ?? undefined,
|
|
129
|
+
limit: values.limit ? parseInt(values.limit, 10) : 20,
|
|
130
|
+
offset: values.offset ? parseInt(values.offset, 10) : undefined,
|
|
131
|
+
});
|
|
132
|
+
if (values.json) {
|
|
133
|
+
printJson(result);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (result.lessons.length === 0) {
|
|
137
|
+
console.log('No lessons found.');
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const headers = ['ID', 'Category', 'Importance', 'Title', 'Created'];
|
|
141
|
+
const rows = result.lessons.map((l) => [
|
|
142
|
+
truncate(l.id, 16),
|
|
143
|
+
l.category,
|
|
144
|
+
l.importance,
|
|
145
|
+
truncate(l.title, 40),
|
|
146
|
+
formatTimestamp(l.createdAt),
|
|
147
|
+
]);
|
|
148
|
+
printTable(headers, rows);
|
|
149
|
+
console.log(`\n${result.lessons.length} of ${result.total} lesson(s).`);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* agentlens lessons create
|
|
153
|
+
*/
|
|
154
|
+
async function runLessonsCreate(argv) {
|
|
155
|
+
const { values } = parseLessonsArgs(argv);
|
|
156
|
+
if (values.help) {
|
|
157
|
+
console.log(`Usage: agentlens lessons create [options]
|
|
158
|
+
|
|
159
|
+
Create a new lesson.
|
|
160
|
+
|
|
161
|
+
Options:
|
|
162
|
+
--title <title> Lesson title (required)
|
|
163
|
+
--content <text> Lesson content (required)
|
|
164
|
+
--category <cat> Category (default: general)
|
|
165
|
+
--importance <level> Importance: low|normal|high|critical (default: normal)
|
|
166
|
+
--agent <id> Agent ID
|
|
167
|
+
--url <url> Server URL
|
|
168
|
+
-j, --json Output raw JSON
|
|
169
|
+
-h, --help Show help`);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (!values.title) {
|
|
173
|
+
console.error('Error: --title is required.');
|
|
174
|
+
process.exit(1);
|
|
175
|
+
}
|
|
176
|
+
if (!values.content) {
|
|
177
|
+
console.error('Error: --content is required.');
|
|
178
|
+
process.exit(1);
|
|
179
|
+
}
|
|
180
|
+
const client = createClientFromConfig(values.url);
|
|
181
|
+
const lesson = await client.createLesson({
|
|
182
|
+
title: values.title,
|
|
183
|
+
content: values.content,
|
|
184
|
+
category: values.category ?? undefined,
|
|
185
|
+
importance: values.importance ?? undefined,
|
|
186
|
+
agentId: values.agent ?? undefined,
|
|
187
|
+
});
|
|
188
|
+
if (values.json) {
|
|
189
|
+
printJson(lesson);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
console.log(`\nLesson created: ${lesson.id}`);
|
|
193
|
+
console.log(` Title: ${lesson.title}`);
|
|
194
|
+
console.log(` Category: ${lesson.category}`);
|
|
195
|
+
console.log(` Importance: ${lesson.importance}`);
|
|
196
|
+
console.log('');
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* agentlens lessons get <id>
|
|
200
|
+
*/
|
|
201
|
+
async function runLessonsGet(argv) {
|
|
202
|
+
const { values, positionals } = parseLessonsArgs(argv);
|
|
203
|
+
if (values.help) {
|
|
204
|
+
console.log(`Usage: agentlens lessons get <id> [options]
|
|
205
|
+
|
|
206
|
+
Get a lesson by ID with full details.
|
|
207
|
+
|
|
208
|
+
Options:
|
|
209
|
+
--url <url> Server URL
|
|
210
|
+
-j, --json Output raw JSON
|
|
211
|
+
-h, --help Show help`);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const id = positionals[0];
|
|
215
|
+
if (!id) {
|
|
216
|
+
console.error('Error: Lesson ID is required.');
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
219
|
+
const client = createClientFromConfig(values.url);
|
|
220
|
+
const lesson = await client.getLesson(id);
|
|
221
|
+
if (values.json) {
|
|
222
|
+
printJson(lesson);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
console.log('');
|
|
226
|
+
console.log(`Lesson: ${lesson.id}`);
|
|
227
|
+
console.log(` Title: ${lesson.title}`);
|
|
228
|
+
console.log(` Category: ${lesson.category}`);
|
|
229
|
+
console.log(` Importance: ${lesson.importance}`);
|
|
230
|
+
console.log(` Created: ${formatTimestamp(lesson.createdAt)}`);
|
|
231
|
+
console.log(` Updated: ${formatTimestamp(lesson.updatedAt)}`);
|
|
232
|
+
console.log(` Access Count: ${lesson.accessCount}`);
|
|
233
|
+
if (lesson.agentId) {
|
|
234
|
+
console.log(` Agent: ${lesson.agentId}`);
|
|
235
|
+
}
|
|
236
|
+
if (lesson.sourceSessionId) {
|
|
237
|
+
console.log(` Source Session: ${lesson.sourceSessionId}`);
|
|
238
|
+
}
|
|
239
|
+
console.log('');
|
|
240
|
+
console.log('Content:');
|
|
241
|
+
console.log(` ${lesson.content}`);
|
|
242
|
+
console.log('');
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* agentlens lessons update <id>
|
|
246
|
+
*/
|
|
247
|
+
async function runLessonsUpdate(argv) {
|
|
248
|
+
const { values, positionals } = parseLessonsArgs(argv);
|
|
249
|
+
if (values.help) {
|
|
250
|
+
console.log(`Usage: agentlens lessons update <id> [options]
|
|
251
|
+
|
|
252
|
+
Update an existing lesson.
|
|
253
|
+
|
|
254
|
+
Options:
|
|
255
|
+
--title <title> New title
|
|
256
|
+
--content <text> New content
|
|
257
|
+
--category <cat> New category
|
|
258
|
+
--importance <level> New importance level
|
|
259
|
+
--url <url> Server URL
|
|
260
|
+
-j, --json Output raw JSON
|
|
261
|
+
-h, --help Show help`);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
const id = positionals[0];
|
|
265
|
+
if (!id) {
|
|
266
|
+
console.error('Error: Lesson ID is required.');
|
|
267
|
+
process.exit(1);
|
|
268
|
+
}
|
|
269
|
+
const updates = {};
|
|
270
|
+
if (values.title)
|
|
271
|
+
updates.title = values.title;
|
|
272
|
+
if (values.content)
|
|
273
|
+
updates.content = values.content;
|
|
274
|
+
if (values.category)
|
|
275
|
+
updates.category = values.category;
|
|
276
|
+
if (values.importance)
|
|
277
|
+
updates.importance = values.importance;
|
|
278
|
+
if (Object.keys(updates).length === 0) {
|
|
279
|
+
console.error('Error: At least one field to update is required (--title, --content, --category, --importance).');
|
|
280
|
+
process.exit(1);
|
|
281
|
+
}
|
|
282
|
+
const client = createClientFromConfig(values.url);
|
|
283
|
+
const lesson = await client.updateLesson(id, updates);
|
|
284
|
+
if (values.json) {
|
|
285
|
+
printJson(lesson);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
console.log(`\nLesson updated: ${lesson.id}`);
|
|
289
|
+
console.log(` Title: ${lesson.title}`);
|
|
290
|
+
console.log(` Category: ${lesson.category}`);
|
|
291
|
+
console.log(` Importance: ${lesson.importance}`);
|
|
292
|
+
console.log('');
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* agentlens lessons delete <id>
|
|
296
|
+
*/
|
|
297
|
+
async function runLessonsDelete(argv) {
|
|
298
|
+
const { values, positionals } = parseLessonsArgs(argv);
|
|
299
|
+
if (values.help) {
|
|
300
|
+
console.log(`Usage: agentlens lessons delete <id> [options]
|
|
301
|
+
|
|
302
|
+
Delete (archive) a lesson.
|
|
303
|
+
|
|
304
|
+
Options:
|
|
305
|
+
--url <url> Server URL
|
|
306
|
+
-j, --json Output raw JSON
|
|
307
|
+
-h, --help Show help`);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const id = positionals[0];
|
|
311
|
+
if (!id) {
|
|
312
|
+
console.error('Error: Lesson ID is required.');
|
|
313
|
+
process.exit(1);
|
|
314
|
+
}
|
|
315
|
+
const client = createClientFromConfig(values.url);
|
|
316
|
+
const result = await client.deleteLesson(id);
|
|
317
|
+
if (values.json) {
|
|
318
|
+
printJson(result);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
console.log(`Lesson ${id} archived successfully.`);
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* agentlens lessons search <query>
|
|
325
|
+
*/
|
|
326
|
+
async function runLessonsSearch(argv) {
|
|
327
|
+
const { values, positionals } = parseLessonsArgs(argv);
|
|
328
|
+
if (values.help) {
|
|
329
|
+
console.log(`Usage: agentlens lessons search <query> [options]
|
|
330
|
+
|
|
331
|
+
Search lessons by text.
|
|
332
|
+
|
|
333
|
+
Options:
|
|
334
|
+
--category <cat> Filter by category
|
|
335
|
+
--agent <id> Filter by agent ID
|
|
336
|
+
--limit <n> Max results (default: 20)
|
|
337
|
+
--url <url> Server URL
|
|
338
|
+
-j, --json Output raw JSON
|
|
339
|
+
-h, --help Show help`);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
const query = positionals[0];
|
|
343
|
+
if (!query) {
|
|
344
|
+
console.error('Error: Search query is required.');
|
|
345
|
+
process.exit(1);
|
|
346
|
+
}
|
|
347
|
+
const client = createClientFromConfig(values.url);
|
|
348
|
+
const result = await client.getLessons({
|
|
349
|
+
search: query,
|
|
350
|
+
category: values.category ?? undefined,
|
|
351
|
+
agentId: values.agent ?? undefined,
|
|
352
|
+
limit: values.limit ? parseInt(values.limit, 10) : 20,
|
|
353
|
+
});
|
|
354
|
+
if (values.json) {
|
|
355
|
+
printJson(result);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
if (result.lessons.length === 0) {
|
|
359
|
+
console.log(`No lessons found matching "${query}".`);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const headers = ['ID', 'Category', 'Importance', 'Title', 'Preview'];
|
|
363
|
+
const rows = result.lessons.map((l) => [
|
|
364
|
+
truncate(l.id, 16),
|
|
365
|
+
l.category,
|
|
366
|
+
l.importance,
|
|
367
|
+
truncate(l.title, 30),
|
|
368
|
+
truncate(l.content.replace(/\n/g, ' '), 40),
|
|
369
|
+
]);
|
|
370
|
+
printTable(headers, rows);
|
|
371
|
+
console.log(`\n${result.lessons.length} of ${result.total} lesson(s) matching "${query}".`);
|
|
372
|
+
}
|
|
373
|
+
//# sourceMappingURL=lessons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lessons.js","sourceRoot":"","sources":["../../src/commands/lessons.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEpF,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uDA4C0C,CAAC;AAExD,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAc;IACpD,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE3B,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,MAAM;YACT,MAAM,cAAc,CAAC,IAAI,CAAC,CAAC;YAC3B,MAAM;QACR,KAAK,QAAQ;YACX,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;YAC7B,MAAM;QACR,KAAK,KAAK;YACR,MAAM,aAAa,CAAC,IAAI,CAAC,CAAC;YAC1B,MAAM;QACR,KAAK,QAAQ;YACX,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;YAC7B,MAAM;QACR,K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CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;QACrB,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;KAC5C,CAAC,CAAC;IAEH,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC1B,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,OAAO,CAAC,MAAM,OAAO,MAAM,CAAC,KAAK,wBAAwB,KAAK,IAAI,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recall.d.ts","sourceRoot":"","sources":["../../src/commands/recall.ts"],"names":[],"mappings":"AA+BA,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA6DpE"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentlens recall — Semantic search over agent memory
|
|
3
|
+
*/
|
|
4
|
+
import { parseArgs } from 'node:util';
|
|
5
|
+
import { createClientFromConfig } from '../lib/client.js';
|
|
6
|
+
import { printTable, printJson, truncate } from '../lib/output.js';
|
|
7
|
+
const HELP = `Usage: agentlens recall <query> [options]
|
|
8
|
+
|
|
9
|
+
Semantic search over agent memory — find past events, sessions, and lessons by meaning.
|
|
10
|
+
|
|
11
|
+
Arguments:
|
|
12
|
+
query Natural language search query
|
|
13
|
+
|
|
14
|
+
Options:
|
|
15
|
+
--scope <scope> Search scope: all|events|sessions|lessons (default: all)
|
|
16
|
+
--limit <n> Maximum results (default: 10)
|
|
17
|
+
--from <date> Start date (ISO 8601)
|
|
18
|
+
--to <date> End date (ISO 8601)
|
|
19
|
+
--agent <id> Filter by agent ID
|
|
20
|
+
--min-score <n> Minimum similarity score 0-1 (default: 0)
|
|
21
|
+
--url <url> Server URL (overrides config)
|
|
22
|
+
-j, --json Output raw JSON
|
|
23
|
+
-h, --help Show help
|
|
24
|
+
|
|
25
|
+
Examples:
|
|
26
|
+
agentlens recall "authentication errors"
|
|
27
|
+
agentlens recall "deployment failures" --scope events --limit 20
|
|
28
|
+
agentlens recall "user onboarding" --from 2026-01-01 --to 2026-02-01
|
|
29
|
+
agentlens recall "auth" --json`;
|
|
30
|
+
export async function runRecallCommand(argv) {
|
|
31
|
+
const { values, positionals } = parseArgs({
|
|
32
|
+
args: argv,
|
|
33
|
+
options: {
|
|
34
|
+
scope: { type: 'string' },
|
|
35
|
+
limit: { type: 'string', short: 'l' },
|
|
36
|
+
from: { type: 'string' },
|
|
37
|
+
to: { type: 'string' },
|
|
38
|
+
agent: { type: 'string', short: 'a' },
|
|
39
|
+
'min-score': { type: 'string' },
|
|
40
|
+
url: { type: 'string' },
|
|
41
|
+
json: { type: 'boolean', short: 'j', default: false },
|
|
42
|
+
help: { type: 'boolean', short: 'h', default: false },
|
|
43
|
+
},
|
|
44
|
+
allowPositionals: true,
|
|
45
|
+
});
|
|
46
|
+
if (values.help) {
|
|
47
|
+
console.log(HELP);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const query = positionals[0];
|
|
51
|
+
if (!query) {
|
|
52
|
+
console.error('Error: Query argument is required.\n');
|
|
53
|
+
console.log(HELP);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
const client = createClientFromConfig(values.url);
|
|
57
|
+
const result = await client.recall({
|
|
58
|
+
query,
|
|
59
|
+
scope: values.scope,
|
|
60
|
+
agentId: values.agent ?? undefined,
|
|
61
|
+
from: values.from ?? undefined,
|
|
62
|
+
to: values.to ?? undefined,
|
|
63
|
+
limit: values.limit ? parseInt(values.limit, 10) : undefined,
|
|
64
|
+
minScore: values['min-score'] ? parseFloat(values['min-score']) : undefined,
|
|
65
|
+
});
|
|
66
|
+
if (values.json) {
|
|
67
|
+
printJson(result);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (result.results.length === 0) {
|
|
71
|
+
console.log(`No results found for "${query}".`);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const headers = ['#', 'Source', 'Score', 'Text'];
|
|
75
|
+
const rows = result.results.map((r, i) => [
|
|
76
|
+
String(i + 1),
|
|
77
|
+
r.sourceType,
|
|
78
|
+
`${(r.score * 100).toFixed(1)}%`,
|
|
79
|
+
truncate(r.text.replace(/\n/g, ' '), 80),
|
|
80
|
+
]);
|
|
81
|
+
printTable(headers, rows);
|
|
82
|
+
console.log(`\n${result.totalResults} result(s) for "${query}".`);
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=recall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recall.js","sourceRoot":"","sources":["../../src/commands/recall.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEnE,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;iCAsBoB,CAAC;AAElC,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAc;IACnD,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,CAAC;QACxC,IAAI,EAAE,IAAI;QACV,OAAO,EAAE;YACP,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACzB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE;YACrC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACxB,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACtB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE;YACrC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC/B,GAAG,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;IAEH,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QAChB,SAAS,CAAC,MAAM,CAAC,CAAC;QAClB,OAAO;IACT,CAAC;IAED,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,yBAAyB,KAAK,IAAI,CAAC,CAAC;QAChD,OAAO;IACT,CAAC;IAED,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;QACb,CAAC,CAAC,UAAU;QACZ,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;QAChC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;KACzC,CAAC,CAAC;IAEH,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC1B,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,YAAY,mBAAmB,KAAK,IAAI,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflect.d.ts","sourceRoot":"","sources":["../../src/commands/reflect.ts"],"names":[],"mappings":"AAkCA,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8DrE"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agentlens reflect — Pattern analysis across agent sessions
|
|
3
|
+
*/
|
|
4
|
+
import { parseArgs } from 'node:util';
|
|
5
|
+
import { createClientFromConfig } from '../lib/client.js';
|
|
6
|
+
import { printTable, printJson, formatTimestamp, truncate } from '../lib/output.js';
|
|
7
|
+
const ANALYSIS_TYPES = ['error_patterns', 'cost_analysis', 'tool_sequences', 'performance_trends'];
|
|
8
|
+
const HELP = `Usage: agentlens reflect <analysis_type> [options]
|
|
9
|
+
|
|
10
|
+
Analyze behavioral patterns from agent sessions.
|
|
11
|
+
|
|
12
|
+
Analysis Types:
|
|
13
|
+
error_patterns Recurring error patterns across sessions
|
|
14
|
+
cost_analysis Cost breakdown and trends by model/agent
|
|
15
|
+
tool_sequences Common tool usage patterns and error rates
|
|
16
|
+
performance_trends Success rate and duration trends over time
|
|
17
|
+
|
|
18
|
+
Options:
|
|
19
|
+
--agent <id> Filter by agent ID
|
|
20
|
+
--from <date> Start date (ISO 8601)
|
|
21
|
+
--to <date> End date (ISO 8601)
|
|
22
|
+
--limit <n> Maximum results (default: 20)
|
|
23
|
+
--url <url> Server URL (overrides config)
|
|
24
|
+
-j, --json Output raw JSON
|
|
25
|
+
-h, --help Show help
|
|
26
|
+
|
|
27
|
+
Examples:
|
|
28
|
+
agentlens reflect error_patterns
|
|
29
|
+
agentlens reflect cost_analysis --agent my-agent --from 2026-01-01
|
|
30
|
+
agentlens reflect tool_sequences --limit 20
|
|
31
|
+
agentlens reflect performance_trends`;
|
|
32
|
+
export async function runReflectCommand(argv) {
|
|
33
|
+
const { values, positionals } = parseArgs({
|
|
34
|
+
args: argv,
|
|
35
|
+
options: {
|
|
36
|
+
agent: { type: 'string', short: 'a' },
|
|
37
|
+
from: { type: 'string' },
|
|
38
|
+
to: { type: 'string' },
|
|
39
|
+
limit: { type: 'string', short: 'l' },
|
|
40
|
+
url: { type: 'string' },
|
|
41
|
+
json: { type: 'boolean', short: 'j', default: false },
|
|
42
|
+
help: { type: 'boolean', short: 'h', default: false },
|
|
43
|
+
},
|
|
44
|
+
allowPositionals: true,
|
|
45
|
+
});
|
|
46
|
+
if (values.help || positionals.length === 0) {
|
|
47
|
+
console.log(HELP);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const analysis = positionals[0];
|
|
51
|
+
if (!ANALYSIS_TYPES.includes(analysis)) {
|
|
52
|
+
console.error(`Unknown analysis type: ${analysis}`);
|
|
53
|
+
console.error(`Valid types: ${ANALYSIS_TYPES.join(', ')}`);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
const client = createClientFromConfig(values.url);
|
|
57
|
+
const result = await client.reflect({
|
|
58
|
+
analysis,
|
|
59
|
+
agentId: values.agent ?? undefined,
|
|
60
|
+
from: values.from ?? undefined,
|
|
61
|
+
to: values.to ?? undefined,
|
|
62
|
+
limit: values.limit ? parseInt(values.limit, 10) : undefined,
|
|
63
|
+
});
|
|
64
|
+
if (values.json) {
|
|
65
|
+
printJson(result);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// Dispatch to per-analysis-type formatter
|
|
69
|
+
switch (analysis) {
|
|
70
|
+
case 'error_patterns':
|
|
71
|
+
formatErrorPatterns(result);
|
|
72
|
+
break;
|
|
73
|
+
case 'cost_analysis':
|
|
74
|
+
formatCostAnalysis(result);
|
|
75
|
+
break;
|
|
76
|
+
case 'tool_sequences':
|
|
77
|
+
formatToolSequences(result);
|
|
78
|
+
break;
|
|
79
|
+
case 'performance_trends':
|
|
80
|
+
formatPerformanceTrends(result);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
// Always show metadata
|
|
84
|
+
const m = result.metadata;
|
|
85
|
+
console.log(`\nAnalyzed ${m.sessionsAnalyzed} session(s), ${m.eventsAnalyzed} event(s).`);
|
|
86
|
+
console.log(`Time range: ${m.timeRange.from} → ${m.timeRange.to}`);
|
|
87
|
+
}
|
|
88
|
+
function formatErrorPatterns(result) {
|
|
89
|
+
console.log('\nError Patterns\n');
|
|
90
|
+
if (result.insights.length === 0) {
|
|
91
|
+
console.log('No error patterns found.');
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const headers = ['Pattern', 'Count', 'First Seen', 'Last Seen'];
|
|
95
|
+
const rows = result.insights.map((insight) => {
|
|
96
|
+
const d = insight.data;
|
|
97
|
+
return [
|
|
98
|
+
truncate(insight.summary, 50),
|
|
99
|
+
String(d.count ?? ''),
|
|
100
|
+
d.firstSeen ? formatTimestamp(String(d.firstSeen)) : '',
|
|
101
|
+
d.lastSeen ? formatTimestamp(String(d.lastSeen)) : '',
|
|
102
|
+
];
|
|
103
|
+
});
|
|
104
|
+
printTable(headers, rows);
|
|
105
|
+
}
|
|
106
|
+
function formatCostAnalysis(result) {
|
|
107
|
+
console.log('\nCost Analysis\n');
|
|
108
|
+
if (result.insights.length === 0) {
|
|
109
|
+
console.log('No cost data found.');
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
// Look for summary insight
|
|
113
|
+
const summaryInsight = result.insights.find((i) => i.type === 'summary' || i.type === 'cost_summary');
|
|
114
|
+
if (summaryInsight) {
|
|
115
|
+
const d = summaryInsight.data;
|
|
116
|
+
console.log(` Total Cost: $${Number(d.totalCost ?? 0).toFixed(4)}`);
|
|
117
|
+
console.log(` Avg/Session: $${Number(d.avgPerSession ?? 0).toFixed(4)}`);
|
|
118
|
+
console.log(` Total Sessions: ${d.totalSessions ?? ''}`);
|
|
119
|
+
console.log('');
|
|
120
|
+
}
|
|
121
|
+
// Look for model breakdown insights
|
|
122
|
+
const modelInsights = result.insights.filter((i) => i.type === 'model_breakdown' || i.type === 'by_model');
|
|
123
|
+
if (modelInsights.length > 0) {
|
|
124
|
+
console.log('Model Breakdown:');
|
|
125
|
+
const headers = ['Model', 'Calls', 'Cost', 'Avg/Call'];
|
|
126
|
+
const rows = modelInsights.map((insight) => {
|
|
127
|
+
const d = insight.data;
|
|
128
|
+
return [
|
|
129
|
+
truncate(String(d.model ?? insight.summary), 30),
|
|
130
|
+
String(d.callCount ?? d.calls ?? ''),
|
|
131
|
+
`$${Number(d.totalCost ?? d.costUsd ?? 0).toFixed(4)}`,
|
|
132
|
+
`$${Number(d.avgCostPerCall ?? 0).toFixed(4)}`,
|
|
133
|
+
];
|
|
134
|
+
});
|
|
135
|
+
printTable(headers, rows);
|
|
136
|
+
}
|
|
137
|
+
// If no structured data, show general insights
|
|
138
|
+
if (!summaryInsight && modelInsights.length === 0) {
|
|
139
|
+
for (const insight of result.insights) {
|
|
140
|
+
console.log(` [${insight.type}] ${insight.summary}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function formatToolSequences(result) {
|
|
145
|
+
console.log('\nTool Sequences\n');
|
|
146
|
+
if (result.insights.length === 0) {
|
|
147
|
+
console.log('No tool sequence patterns found.');
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const headers = ['Sequence', 'Frequency', 'Sessions', 'Error Rate'];
|
|
151
|
+
const rows = result.insights.map((insight) => {
|
|
152
|
+
const d = insight.data;
|
|
153
|
+
const tools = d.tools;
|
|
154
|
+
const seq = tools ? tools.join(' → ') : insight.summary;
|
|
155
|
+
return [
|
|
156
|
+
truncate(seq, 50),
|
|
157
|
+
String(d.frequency ?? ''),
|
|
158
|
+
String(d.sessions ?? ''),
|
|
159
|
+
d.errorRate !== undefined ? `${(Number(d.errorRate) * 100).toFixed(1)}%` : '',
|
|
160
|
+
];
|
|
161
|
+
});
|
|
162
|
+
printTable(headers, rows);
|
|
163
|
+
}
|
|
164
|
+
function formatPerformanceTrends(result) {
|
|
165
|
+
console.log('\nPerformance Trends\n');
|
|
166
|
+
if (result.insights.length === 0) {
|
|
167
|
+
console.log('No performance data found.');
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
// Look for current stats
|
|
171
|
+
const currentInsight = result.insights.find((i) => i.type === 'current' || i.type === 'performance_current');
|
|
172
|
+
if (currentInsight) {
|
|
173
|
+
const d = currentInsight.data;
|
|
174
|
+
console.log(` Success Rate: ${d.successRate !== undefined ? `${(Number(d.successRate) * 100).toFixed(1)}%` : 'N/A'}`);
|
|
175
|
+
console.log(` Avg Duration: ${d.avgDuration !== undefined ? `${Number(d.avgDuration).toFixed(0)}ms` : 'N/A'}`);
|
|
176
|
+
console.log(` Avg Tool Calls: ${d.avgToolCalls ?? 'N/A'}`);
|
|
177
|
+
console.log(` Avg Errors: ${d.avgErrors ?? 'N/A'}`);
|
|
178
|
+
console.log('');
|
|
179
|
+
}
|
|
180
|
+
// Look for assessment
|
|
181
|
+
const assessmentInsight = result.insights.find((i) => i.type === 'assessment' || i.type === 'trend_assessment');
|
|
182
|
+
if (assessmentInsight) {
|
|
183
|
+
const assessment = String(assessmentInsight.data.assessment ?? assessmentInsight.summary);
|
|
184
|
+
const icon = assessment === 'improving' ? '📈' : assessment === 'degrading' ? '📉' : '📊';
|
|
185
|
+
console.log(` Trend: ${icon} ${assessment}`);
|
|
186
|
+
console.log('');
|
|
187
|
+
}
|
|
188
|
+
// Show trend data if present
|
|
189
|
+
const trendInsights = result.insights.filter((i) => i.type === 'trend_bucket' || i.type === 'trend');
|
|
190
|
+
if (trendInsights.length > 0) {
|
|
191
|
+
const headers = ['Date', 'Success Rate', 'Duration', 'Errors'];
|
|
192
|
+
const rows = trendInsights.map((insight) => {
|
|
193
|
+
const d = insight.data;
|
|
194
|
+
return [
|
|
195
|
+
String(d.date ?? insight.summary),
|
|
196
|
+
d.successRate !== undefined ? `${(Number(d.successRate) * 100).toFixed(1)}%` : '',
|
|
197
|
+
d.duration !== undefined ? `${Number(d.duration).toFixed(0)}ms` : '',
|
|
198
|
+
String(d.errors ?? ''),
|
|
199
|
+
];
|
|
200
|
+
});
|
|
201
|
+
printTable(headers, rows);
|
|
202
|
+
}
|
|
203
|
+
// Fallback: show all insights
|
|
204
|
+
if (!currentInsight && !assessmentInsight && trendInsights.length === 0) {
|
|
205
|
+
for (const insight of result.insights) {
|
|
206
|
+
console.log(` [${insight.type}] ${insight.summary} (confidence: ${(insight.confidence * 100).toFixed(0)}%)`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=reflect.js.map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,KAAK,CAAC,EAAE,CAAC;QACxE,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACtC,OAAO,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,OAAO,iBAAiB,CAAC,OAAO,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAChH,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,12 @@
|
|
|
5
5
|
* Uses node:util parseArgs for lightweight argument parsing.
|
|
6
6
|
*/
|
|
7
7
|
import { runConfigCommand } from './commands/config.js';
|
|
8
|
+
import { runContextCommand } from './commands/context.js';
|
|
8
9
|
import { runEventsCommand } from './commands/events.js';
|
|
10
|
+
import { runLessonsCommand } from './commands/lessons.js';
|
|
9
11
|
import { runLlmCommand } from './commands/llm.js';
|
|
12
|
+
import { runRecallCommand } from './commands/recall.js';
|
|
13
|
+
import { runReflectCommand } from './commands/reflect.js';
|
|
10
14
|
import { runSessionsCommand } from './commands/sessions.js';
|
|
11
15
|
import { runTailCommand } from './commands/tail.js';
|
|
12
16
|
const HELP = `AgentLens CLI — Observability for AI agents
|
|
@@ -15,10 +19,14 @@ Usage: agentlens <command> [options]
|
|
|
15
19
|
|
|
16
20
|
Commands:
|
|
17
21
|
config Get or set configuration (url, api-key)
|
|
22
|
+
context Retrieve cross-session context for a topic
|
|
18
23
|
events Query events
|
|
24
|
+
lessons Manage agent lessons (list, create, get, update, delete, search)
|
|
25
|
+
llm LLM call tracking (stats, models, recent)
|
|
26
|
+
recall Semantic search over agent memory
|
|
27
|
+
reflect Pattern analysis across agent sessions
|
|
19
28
|
sessions List and inspect sessions
|
|
20
29
|
tail Stream live events (SSE)
|
|
21
|
-
llm LLM call tracking (stats, models, recent)
|
|
22
30
|
|
|
23
31
|
Run "agentlens <command> --help" for command-specific help.
|
|
24
32
|
|
|
@@ -35,12 +43,24 @@ async function main() {
|
|
|
35
43
|
case 'config':
|
|
36
44
|
runConfigCommand(rest);
|
|
37
45
|
break;
|
|
46
|
+
case 'context':
|
|
47
|
+
await runContextCommand(rest);
|
|
48
|
+
break;
|
|
38
49
|
case 'events':
|
|
39
50
|
await runEventsCommand(rest);
|
|
40
51
|
break;
|
|
52
|
+
case 'lessons':
|
|
53
|
+
await runLessonsCommand(rest);
|
|
54
|
+
break;
|
|
41
55
|
case 'llm':
|
|
42
56
|
await runLlmCommand(rest);
|
|
43
57
|
break;
|
|
58
|
+
case 'recall':
|
|
59
|
+
await runRecallCommand(rest);
|
|
60
|
+
break;
|
|
61
|
+
case 'reflect':
|
|
62
|
+
await runReflectCommand(rest);
|
|
63
|
+
break;
|
|
44
64
|
case 'sessions':
|
|
45
65
|
await runSessionsCommand(rest);
|
|
46
66
|
break;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,IAAI,GAAG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAu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OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentlensai/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Command-line interface for AgentLens — query events, sessions, and manage your observability server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"files": [
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
|
-
"dependencies": {
|
|
40
|
-
"@agentlensai/sdk": "0.3.0"
|
|
41
|
-
},
|
|
42
39
|
"scripts": {
|
|
43
40
|
"build": "tsc -b",
|
|
44
41
|
"dev": "tsc -b --watch",
|
|
45
42
|
"typecheck": "tsc --noEmit",
|
|
46
43
|
"test": "vitest run",
|
|
47
44
|
"test:watch": "vitest"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@agentlensai/sdk": "workspace:*"
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Amit Paz
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|