@onmars/lunar-core 0.4.3 → 0.4.5

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": "@onmars/lunar-core",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -146,6 +146,11 @@ export class MemoryOrchestrator implements MemoryProvider {
146
146
  return this.currentSessionDate
147
147
  }
148
148
 
149
+ /** Number of diary context entries loaded at sessionStart */
150
+ get diaryCount(): number {
151
+ return this.diaryResults.length
152
+ }
153
+
149
154
  /**
150
155
  * Destroy all providers.
151
156
  */
package/src/lib/router.ts CHANGED
@@ -223,6 +223,9 @@ export class Router {
223
223
 
224
224
  // ─── Command interception (before system prompt — zero token cost) ───
225
225
  if (this.commandHandler.isCommand(message.text)) {
226
+ // Show typing indicator while command executes (especially /clear with hooks)
227
+ const typingInterval = this.startTyping(channel, message.channelId)
228
+
226
229
  const ctx: CommandContext = {
227
230
  sessionKey,
228
231
  message,
@@ -244,7 +247,16 @@ export class Router {
244
247
  scheduler: this.scheduler,
245
248
  }
246
249
 
250
+ // For /clear: send immediate ack before hooks run (they can take 15-30s)
251
+ const commandName = message.text.trim().slice(1).split(/\s+/)[0]?.toLowerCase()
252
+ if (commandName === 'clear' || commandName === 'reset') {
253
+ await channel.send(message.channelId, {
254
+ text: '🧠 Guardando memoria de la sesión...',
255
+ })
256
+ }
257
+
247
258
  const response = await this.commandHandler.handle(message.text, ctx)
259
+ clearInterval(typingInterval)
248
260
  if (response) {
249
261
  const outgoing: OutgoingMessage = { text: this.redact(response) }
250
262
  await channel.send(message.channelId, outgoing)
@@ -397,6 +409,22 @@ export class Router {
397
409
  'Routing message',
398
410
  )
399
411
 
412
+ // New session greeting: send memory context summary on first message
413
+ if (!session) {
414
+ const orchestrator = this.memory as import('./memory-orchestrator').MemoryOrchestrator | undefined
415
+ const episodeId = orchestrator?.episodeId
416
+ const diaryCount = orchestrator?.diaryCount ?? 0
417
+ const moonName = moon?.name ?? 'Lunar'
418
+ const channelName = channelPersona?.name ?? message.channelId
419
+
420
+ const parts: string[] = [`🌑 **${moonName}** — Nueva sesión · #${channelName}`]
421
+ if (episodeId) parts.push(`📎 Episodio: \`${episodeId.slice(0, 8)}\``)
422
+ if (diaryCount > 0) parts.push(`🧠 ${diaryCount} entries de memoria cargadas`)
423
+ parts.push('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
424
+
425
+ await channel.send(message.channelId, { text: parts.join('\n') })
426
+ }
427
+
400
428
  // Start typing
401
429
  const typingInterval = this.startTyping(channel, message.channelId)
402
430