@agi-cli/server 0.1.126 → 0.1.128

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agi-cli/server",
3
- "version": "0.1.126",
3
+ "version": "0.1.128",
4
4
  "description": "HTTP API server for AGI CLI",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -29,8 +29,8 @@
29
29
  "typecheck": "tsc --noEmit"
30
30
  },
31
31
  "dependencies": {
32
- "@agi-cli/sdk": "0.1.126",
33
- "@agi-cli/database": "0.1.126",
32
+ "@agi-cli/sdk": "0.1.128",
33
+ "@agi-cli/database": "0.1.128",
34
34
  "drizzle-orm": "^0.44.5",
35
35
  "hono": "^4.9.9",
36
36
  "zod": "^4.1.8"
@@ -233,50 +233,13 @@ export function registerResearchRoutes(app: Hono) {
233
233
 
234
234
  const injectedContext = `<research-context from="${researchSessionId}" label="${label}" injected-at="${new Date().toISOString()}">\n${contextContent}</research-context>`;
235
235
 
236
- const msgId = crypto.randomUUID();
237
- const partId = crypto.randomUUID();
238
- const now = Date.now();
239
-
240
- await db.insert(messages).values({
241
- id: msgId,
242
- sessionId: parentId,
243
- role: 'system',
244
- status: 'complete',
245
- agent: parentRows[0].agent,
246
- provider: parentRows[0].provider,
247
- model: parentRows[0].model,
248
- createdAt: now,
249
- completedAt: now,
250
- });
251
-
252
- await db.insert(messageParts).values({
253
- id: partId,
254
- messageId: msgId,
255
- index: 0,
256
- type: 'text',
257
- content: injectedContext,
258
- agent: parentRows[0].agent,
259
- provider: parentRows[0].provider,
260
- model: parentRows[0].model,
261
- });
262
-
263
- await db
264
- .update(sessions)
265
- .set({ lastActiveAt: now })
266
- .where(eq(sessions.id, parentId));
267
-
268
- publish({
269
- type: 'message.created',
270
- sessionId: parentId,
271
- payload: {
272
- id: msgId,
273
- role: 'system',
274
- content: injectedContext,
275
- },
276
- });
277
-
236
+ // Return the content to the client instead of creating a system message
237
+ // The client will store it in zustand and include it in the next user message
278
238
  return c.json({
279
- injectedMessageId: msgId,
239
+ content: injectedContext,
240
+ label,
241
+ sessionId: researchSessionId,
242
+ parentSessionId: parentId,
280
243
  tokenEstimate: Math.ceil(injectedContext.length / 4),
281
244
  });
282
245
  });
@@ -305,9 +305,10 @@ async function generateSessionTitle(args: {
305
305
  const promptText = String(content ?? '').slice(0, 2000);
306
306
 
307
307
  const titlePrompt = [
308
- "Create a short, descriptive session title from the user's request.",
309
- 'Max 6–8 words. No quotes. No trailing punctuation.',
310
- 'Avoid generic phrases like "help me"; be specific.',
308
+ 'Generate a brief title (6-8 words) summarizing what the user wants to do.',
309
+ 'Rules: Plain text only. No markdown, no quotes, no punctuation, no emojis.',
310
+ 'Focus on the core task or topic. Be specific but concise.',
311
+ 'Examples: "Fix TypeScript build errors", "Add dark mode toggle", "Refactor auth middleware"',
311
312
  ].join(' ');
312
313
 
313
314
  // Build system prompt and messages
@@ -409,8 +410,17 @@ async function generateSessionTitle(args: {
409
410
 
410
411
  function sanitizeTitle(raw: string): string {
411
412
  let s = raw.trim();
413
+ s = s.replace(/^#+\s*/, '');
414
+ s = s.replace(/\*\*([^*]+)\*\*/g, '$1');
415
+ s = s.replace(/\*([^*]+)\*/g, '$1');
416
+ s = s.replace(/__([^_]+)__/g, '$1');
417
+ s = s.replace(/_([^_]+)_/g, '$1');
418
+ s = s.replace(/`([^`]+)`/g, '$1');
419
+ s = s.replace(/~~([^~]+)~~/g, '$1');
420
+ s = s.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1');
412
421
  s = s.replace(/^["']|["']$/g, '');
413
- s = s.replace(/[.!?]+$/, '');
422
+ s = s.replace(/^[-–—•*]\s*/, '');
423
+ s = s.replace(/[.!?:;,]+$/, '');
414
424
  s = s.replace(/\s+/g, ' ');
415
425
  if (s.length > 80) s = s.slice(0, 80).trim();
416
426
  return s;
@@ -424,7 +434,7 @@ async function touchSessionLastActive(args: {
424
434
  try {
425
435
  await db
426
436
  .update(sessions)
427
- .set({ updatedAt: Date.now() })
437
+ .set({ lastActiveAt: Date.now() })
428
438
  .where(eq(sessions.id, sessionId))
429
439
  .run();
430
440
  } catch (err) {