duclaw-cli 1.8.3 → 1.8.4

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/bundle.js CHANGED
@@ -30242,7 +30242,7 @@ function printHelp() {
30242
30242
  `);
30243
30243
  }
30244
30244
  function printVersion() {
30245
- console.log(`duclaw-cli v${true ? "1.8.3" : "unknown"}`);
30245
+ console.log(`duclaw-cli v${true ? "1.8.4" : "unknown"}`);
30246
30246
  }
30247
30247
  function getDuclawTemplate() {
30248
30248
  return {
@@ -50206,6 +50206,7 @@ var userKeyPatterns = [
50206
50206
  ];
50207
50207
  var conversationKeyPattern = { match: "agent:mem:*", prefix: "agent:mem:" };
50208
50208
  var dateSegmentPattern = /^\d{8}$/;
50209
+ var MAIN_MANAGER_USER_ID = "__main_manager__";
50209
50210
  var isPlausibleUserId = (userId) => {
50210
50211
  if (!userId) return false;
50211
50212
  if (userId.length > 240) return false;
@@ -50332,6 +50333,13 @@ var collectCompactSummaries = async (userId) => {
50332
50333
  return records.sort((a, b) => b.createdAt - a.createdAt);
50333
50334
  };
50334
50335
  var isMailboxScopedUserId = (userId) => userId === "manager" || userId.includes("::") || userId.startsWith("cron-") || userId.startsWith("kanban:goal:");
50336
+ var classifyMemoryUser = (userId) => {
50337
+ if (userId === MAIN_MANAGER_USER_ID) return "main-manager";
50338
+ if (userId.startsWith("kanban:")) return "kanban";
50339
+ if (userId.includes("::")) return "department";
50340
+ if (userId.startsWith("oc_") || userId.startsWith("chat_")) return "chat";
50341
+ return "user";
50342
+ };
50335
50343
  var collectManagerRelatedUserIds = (userId) => {
50336
50344
  if (isMailboxScopedUserId(userId)) return [userId];
50337
50345
  try {
@@ -50354,10 +50362,17 @@ var collectManagerRelatedUserIds = (userId) => {
50354
50362
  return [userId];
50355
50363
  }
50356
50364
  };
50357
- var collectMemoryScopeUserIds = (userId) => collectManagerRelatedUserIds(userId);
50365
+ var collectMainManagerScopeUserIds = async () => {
50366
+ const { userIds } = await collectUserIds();
50367
+ return Array.from(new Set(userIds.filter((id) => id !== MAIN_MANAGER_USER_ID && !isMailboxScopedUserId(id))));
50368
+ };
50369
+ var collectMemoryScopeUserIds = async (userId) => {
50370
+ if (userId === MAIN_MANAGER_USER_ID) return collectMainManagerScopeUserIds();
50371
+ return collectManagerRelatedUserIds(userId);
50372
+ };
50358
50373
  var aggregateMemorySummaries = async (userId, localConversationUserIds) => {
50359
50374
  const { memoryEngine, dreamStorage, dreamStateStorage, topicStorage } = getSharedDeps();
50360
- const relatedUserIds = collectMemoryScopeUserIds(userId);
50375
+ const relatedUserIds = await collectMemoryScopeUserIds(userId);
50361
50376
  const details = await Promise.all(relatedUserIds.map(async (scopeUserId) => {
50362
50377
  const [memories, dreamContent, dreamState, topics] = await Promise.all([
50363
50378
  memoryEngine.list(scopeUserId),
@@ -50377,13 +50392,16 @@ var aggregateMemorySummaries = async (userId, localConversationUserIds) => {
50377
50392
  const memoryCount = details.reduce((sum, detail) => sum + detail.memoryCount, 0);
50378
50393
  return {
50379
50394
  userId,
50395
+ displayName: userId === MAIN_MANAGER_USER_ID ? "Main Manager \u6C47\u603B" : void 0,
50396
+ kind: classifyMemoryUser(userId),
50380
50397
  memoryCount,
50381
50398
  hasMemory: memoryCount > 0,
50382
50399
  hasDream: details.some((detail) => detail.hasDream),
50383
50400
  hasConversation: details.some((detail) => detail.hasConversation),
50384
50401
  lastDreamAt: Math.max(0, ...details.map((detail) => detail.lastDreamAt ?? 0)) || null,
50385
50402
  lastActivityAt: Math.max(0, ...details.map((detail) => detail.lastActivityAt ?? 0)) || null,
50386
- relatedUserIds: relatedUserIds.length > 1 ? relatedUserIds : void 0
50403
+ relatedUserIds: relatedUserIds.length > 0 && (userId === MAIN_MANAGER_USER_ID || relatedUserIds.length > 1) ? relatedUserIds : void 0,
50404
+ isAggregate: userId === MAIN_MANAGER_USER_ID || relatedUserIds.length > 1 || void 0
50387
50405
  };
50388
50406
  };
50389
50407
  var collectUserIds = async () => {
@@ -50411,8 +50429,11 @@ memoryRoutes.get("/memory/users", async (c) => {
50411
50429
  const summaries = await Promise.all(userIds.map(
50412
50430
  (userId) => aggregateMemorySummaries(userId, localConversationUserIds)
50413
50431
  ));
50432
+ if (userIds.length > 0) {
50433
+ summaries.unshift(await aggregateMemorySummaries(MAIN_MANAGER_USER_ID, localConversationUserIds));
50434
+ }
50414
50435
  summaries.sort(
50415
- (a, b) => (b.lastActivityAt ?? 0) - (a.lastActivityAt ?? 0) || a.userId.localeCompare(b.userId)
50436
+ (a, b) => Number(b.userId === MAIN_MANAGER_USER_ID) - Number(a.userId === MAIN_MANAGER_USER_ID) || (b.lastActivityAt ?? 0) - (a.lastActivityAt ?? 0) || a.userId.localeCompare(b.userId)
50416
50437
  );
50417
50438
  return c.json(summaries);
50418
50439
  } catch (err) {
@@ -50424,8 +50445,9 @@ memoryRoutes.get("/memory", async (c) => {
50424
50445
  if (!userId) return c.json({ error: "userId is required" }, 400);
50425
50446
  try {
50426
50447
  const { memoryEngine } = getSharedDeps();
50448
+ const scopeUserIds = await collectMemoryScopeUserIds(userId);
50427
50449
  const memories = (await Promise.all(
50428
- collectMemoryScopeUserIds(userId).map((scopeUserId) => memoryEngine.list(scopeUserId))
50450
+ scopeUserIds.map((scopeUserId) => memoryEngine.list(scopeUserId))
50429
50451
  )).flat();
50430
50452
  return c.json(sortMemories(memories));
50431
50453
  } catch (err) {
@@ -50489,7 +50511,8 @@ memoryRoutes.get("/memory/dream", async (c) => {
50489
50511
  if (!userId) return c.json({ error: "userId is required" }, 400);
50490
50512
  try {
50491
50513
  const { dreamStorage, dreamHistoryStorage, dreamStateStorage } = getSharedDeps();
50492
- const scoped = await Promise.all(collectMemoryScopeUserIds(userId).map(async (scopeUserId) => {
50514
+ const scopeUserIds = await collectMemoryScopeUserIds(userId);
50515
+ const scoped = await Promise.all(scopeUserIds.map(async (scopeUserId) => {
50493
50516
  const [dreamContent2, dreamHistory2, state2] = await Promise.all([
50494
50517
  dreamStorage.get(`dream:latest:${scopeUserId}`),
50495
50518
  dreamHistoryStorage.get(`dream:history:${scopeUserId}`),
@@ -50520,7 +50543,7 @@ memoryRoutes.get("/memory/compact", async (c) => {
50520
50543
  if (!userId) return c.json({ error: "userId is required" }, 400);
50521
50544
  try {
50522
50545
  const summaries = (await Promise.all(
50523
- collectMemoryScopeUserIds(userId).map((scopeUserId) => collectCompactSummaries(scopeUserId))
50546
+ (await collectMemoryScopeUserIds(userId)).map((scopeUserId) => collectCompactSummaries(scopeUserId))
50524
50547
  )).flat().sort((a, b) => b.createdAt - a.createdAt);
50525
50548
  return c.json({
50526
50549
  userId,
@@ -50538,7 +50561,7 @@ memoryRoutes.get("/memory/recall", async (c) => {
50538
50561
  const limit = Math.min(Number(c.req.query("limit")) || 20, 50);
50539
50562
  try {
50540
50563
  const { recallIndexStorage } = getSharedDeps();
50541
- const scopeUserIds = collectMemoryScopeUserIds(userId);
50564
+ const scopeUserIds = await collectMemoryScopeUserIds(userId);
50542
50565
  if (query) {
50543
50566
  const scopedResults = await Promise.all(scopeUserIds.map(
50544
50567
  (scopeUserId) => searchRecallIndex(recallIndexStorage, scopeUserId, query, date, limit)
@@ -50574,7 +50597,8 @@ memoryRoutes.get("/memory/context", async (c) => {
50574
50597
  if (!userId) return c.json({ error: "userId is required" }, 400);
50575
50598
  try {
50576
50599
  const { memoryEngine, dreamStorage } = getSharedDeps();
50577
- const scoped = await Promise.all(collectMemoryScopeUserIds(userId).map(async (scopeUserId) => {
50600
+ const scopeUserIds = await collectMemoryScopeUserIds(userId);
50601
+ const scoped = await Promise.all(scopeUserIds.map(async (scopeUserId) => {
50578
50602
  const [memoryContextBlock2, dreamContent2] = await Promise.all([
50579
50603
  memoryEngine.buildContextBlock(scopeUserId),
50580
50604
  dreamStorage.get(`dream:latest:${scopeUserId}`)
@@ -50658,7 +50682,7 @@ var systemRoutes = new Hono2();
50658
50682
  var startTime = Date.now();
50659
50683
  systemRoutes.get("/system/info", (c) => {
50660
50684
  return c.json({
50661
- version: true ? "1.8.3" : "unknown",
50685
+ version: true ? "1.8.4" : "unknown",
50662
50686
  uptime: Math.floor((Date.now() - startTime) / 1e3),
50663
50687
  env: process.env.NODE_ENV || "development",
50664
50688
  nodeVersion: process.version