duclaw-cli 1.8.29 → 1.8.31

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.29" : "unknown"}`);
30245
+ console.log(`duclaw-cli v${true ? "1.8.31" : "unknown"}`);
30246
30246
  }
30247
30247
  function getDuclawTemplate() {
30248
30248
  return {
@@ -45258,6 +45258,13 @@ The user will primarily request you perform software engineering tasks. This inc
45258
45258
  - \u9ED8\u8BA4\u4E0D\u66B4\u9732\u8DE8\u5C42\u7EA7/\u8DE8\u90E8\u95E8\u901A\u4FE1\u5730\u5740\uFF1B\u5982\u679C agent \u5DF2\u77E5\u5730\u5740\uFF0C\u901A\u4FE1\u4E0D\u5E94\u88AB\u786C\u6027\u963B\u6B62\uFF0C\u4F46\u8981\u5C0A\u91CD\u7EC4\u7EC7\u8D23\u4EFB\u5E76\u7559\u4E0B\u5BA1\u8BA1\u8BB0\u5F55
45259
45259
  - \u4FDD\u6301\u8D23\u4EFB\u5F52\u5C5E\u7A33\u5B9A\uFF1A\u67D0\u4E2A Department Head \u5DF2\u7ECF\u8D1F\u8D23\u7684\u4EA7\u51FA\uFF0C\u540E\u7EED\u4FEE\u8BA2\u3001\u8FD4\u5DE5\u3001bug \u4FEE\u590D\u9ED8\u8BA4\u4ECD\u7531\u8BE5 Department Head \u8D1F\u8D23\uFF0C\u901A\u5E38\u5E94\u901A\u8FC7 mailbox_followup \u63A5\u56DE\u539F\u7EBF\u7A0B
45260
45260
 
45261
+ ## \u4E13\u4E1A\u56E2\u961F\u4F18\u5148\u786C\u89C4\u5219
45262
+ - \u53EA\u8981\u7EC4\u7EC7\u91CC\u5DF2\u7ECF\u5B58\u5728\u804C\u8D23\u5339\u914D\u7684 Department \u6216 Department Head\uFF0CCEO \u9ED8\u8BA4\u4E0D\u4EB2\u81EA\u505A\u8BE5\u4E13\u4E1A\u56E2\u961F\u8986\u76D6\u7684\u6267\u884C\u5DE5\u4F5C\u3002
45263
+ - \u201C\u4E13\u4E1A\u56E2\u961F\u8986\u76D6\u201D\u5305\u62EC\u4F46\u4E0D\u9650\u4E8E\uFF1A\u5199\u4EE3\u7801\u3001\u8BFB\u4EE3\u7801\u5B9A\u4F4D\u95EE\u9898\u3001\u6539\u6587\u4EF6\u3001\u8DD1\u6D4B\u8BD5\u3001\u8C03\u8BD5\u3001\u90E8\u7F72\u3001\u6570\u636E\u5904\u7406\u3001\u6587\u6863/\u97F3\u9891/\u56FE\u7247\u5904\u7406\u3001\u5916\u90E8 API \u9A8C\u8BC1\u3001\u62A5\u544A\u751F\u6210\u7B49\u3002
45264
+ - CEO \u7684\u6B63\u786E\u52A8\u4F5C\u662F department_list \u5B9A\u4F4D\u56E2\u961F\uFF0Cdepartment_communicate \u59D4\u6D3E\u6216\u8FFD\u95EE\uFF0Cmailbox_followup \u50AC\u529E/\u8865\u5145\u4E0A\u4E0B\u6587\uFF0Ccheck_department_replies \u6536\u96C6\u7ED3\u679C\uFF0C\u7136\u540E\u6C47\u603B\u7ED9\u7528\u6237\u3002
45265
+ - Department Head \u6682\u65E0\u56DE\u4FE1\u3001\u56DE\u590D\u6162\u3001\u6216 check_department_replies \u8FD4\u56DE\u7A7A\uFF0C\u4E0D\u6784\u6210 CEO \u4E0B\u573A\u5E72\u6D3B\u7684\u7406\u7531\uFF1B\u5E94\u8BE5\u7A0D\u540E\u518D\u67E5\u3001\u50AC\u95EE\u8D1F\u8D23\u4EBA\uFF0C\u6216\u7528 send_message \u544A\u8BC9\u7528\u6237\u201C\u56E2\u961F\u4ECD\u5728\u5904\u7406\uFF0C\u6211\u7A0D\u540E\u540C\u6B65\u201D\u3002
45266
+ - \u53EA\u6709\u5728\u7528\u6237\u660E\u786E\u8981\u6C42\u201CCEO/\u4F60\u4EB2\u81EA\u505A\u201D\u3001\u6CA1\u6709\u4EFB\u4F55\u804C\u8D23\u5339\u914D\u56E2\u961F/\u8D1F\u8D23\u4EBA\u3001\u6216\u56E2\u961F\u660E\u786E\u5931\u8D25\u4E14\u7528\u6237\u540C\u610F CEO \u63A5\u7BA1\u65F6\uFF0CCEO \u624D\u80FD\u8D8A\u8FC7\u56E2\u961F\u4EB2\u81EA\u6267\u884C\u4E13\u4E1A\u5DE5\u4F5C\u3002
45267
+
45261
45268
  ## \u8D23\u4EFB\u5F52\u5C5E\u786C\u89C4\u5219
45262
45269
  - Department Head \u4EA4\u4ED8\u7ED3\u679C\u540E\uFF0C\u5982\u679C\u7528\u6237\u53CD\u9988\u201C\u6253\u4E0D\u5F00\u201D\u201C\u6709 bug\u201D\u201C\u5E2E\u6211\u6539\u4E00\u4E0B\u201D\u201C\u518D\u51FA\u4E00\u7248\u201D\u7B49\uFF0C\u8FD9\u5C5E\u4E8E\u5BF9\u65E2\u6709\u4EA7\u51FA\u7684\u8FD4\u5DE5\u6216\u8FED\u4EE3\uFF0C\u9ED8\u8BA4\u5E94\u7EE7\u7EED\u4EA4\u7ED9\u539F\u8D23\u4EFB Department Head \u5904\u7406
45263
45270
  - \u4F18\u5148\u4F7F\u7528 mailbox_followup \u5BF9\u8BE5 Department Head \u6700\u8FD1\u4E00\u6B21\u76F8\u5173\u56DE\u4FE1\u8FFD\u52A0\u53CD\u9988\uFF0C\u907F\u514D CEO \u4EB2\u81EA\u4E0B\u573A\u91CD\u505A\u5B9E\u73B0
@@ -46593,15 +46600,16 @@ var wakeDepartmentAgent = async (mailboxId, msgIds) => {
46593
46600
  }
46594
46601
  const department = getDepartmentById(member.departmentId);
46595
46602
  const workspacePath = department?.workpath;
46596
- const agentConfig = getDepartmentAgentConfig(void 0, member.focusOn, workspacePath, department?.name);
46603
+ const agentConfig = getDepartmentAgentConfig(void 0, member.focusOn, workspacePath, department?.name, member.role, member.name);
46597
46604
  const agent = createAgent(agentConfig);
46605
+ const roleSpecificReminder = member.role === "department_head" ? `\u4F60\u662F Department Head\u3002\u8BFB\u53D6\u90AE\u4EF6\u540E\uFF0C\u5982\u679C\u8FD9\u662F\u590D\u6742\u6267\u884C\u5DE5\u4F5C\uFF08\u4F8B\u5982\u5199\u4EE3\u7801\u3001\u8BFB\u4EE3\u7801\u5B9A\u4F4D\u3001\u8DD1\u6D4B\u8BD5\u3001\u8C03\u8BD5\u3001\u90E8\u7F72\u3001\u5168\u9762\u9A8C\u8BC1\u6216\u751F\u6210\u590D\u6742\u4EA7\u7269\uFF09\uFF0C\u4E0D\u8981\u9ED8\u8BA4\u81EA\u5DF1\u4E0B\u573A\u6267\u884C\uFF1B\u5148\u7528 department_member_list \u67E5\u770B\u6210\u5458\uFF0C\u9009\u62E9\u6216\u521B\u5EFA\u5408\u9002 Executor\uFF0C\u5E76\u7528 department_communicate \u5206\u6D3E\u5177\u4F53\u4EFB\u52A1\u3002\u4F60\u8D1F\u8D23\u62C6\u89E3\u3001\u534F\u8C03\u3001\u8FFD\u95EE\u3001\u9A8C\u6536\u548C\u6C47\u603B\u3002` : `\u4F60\u662F Executor\u3002\u8BFB\u53D6\u90AE\u4EF6\u540E\u76F4\u63A5\u5904\u7406\u5206\u6D3E\u7ED9\u4F60\u7684\u5177\u4F53\u6267\u884C\u4EFB\u52A1\uFF1B\u4E0D\u8981\u5C1D\u8BD5\u67E5\u770B\u5B8C\u6574\u90E8\u95E8\u6210\u5458\u76EE\u5F55\u6216\u521B\u5EFA\u6210\u5458\u3002`;
46598
46606
  const request = {
46599
46607
  platform: "mailbox",
46600
46608
  userId: mailboxId,
46601
46609
  requestId: msgIds[0],
46602
46610
  departmentAgentId: mailboxId,
46603
46611
  workspacePath,
46604
- content: `\u4F60\u7684\u90AE\u7BB1\u4E2D\u6709 ${msgIds.length} \u5C01\u5F85\u5904\u7406\u90AE\u4EF6\u3002\u8BF7\u4F7F\u7528 list_mailbox \u67E5\u770B\u90AE\u4EF6\u5217\u8868\uFF0C\u6839\u636E\u91CD\u8981\u6027\u548C\u65F6\u6548\u6027\u9009\u62E9\u4E00\u5C01\u90AE\u4EF6\uFF0C\u518D\u7528 get_mailbox \u9886\u53D6\u5E76\u8BFB\u53D6\u8BE5\u90AE\u4EF6\u3002\u5B8C\u6210\u8FD9\u5C01\u90AE\u4EF6\u540E\u5FC5\u987B\u4F7F\u7528 reply_mailbox \u56DE\u590D\u5E76\u7ED3\u675F\u5B83\uFF1B\u5982\u679C\u67D0\u5C01\u90AE\u4EF6\u53EA\u662F\u786E\u8BA4\u6027\u56DE\u6267\u3001\u91CD\u590D\u901A\u77E5\u6216\u65E0\u9700\u4E1A\u52A1\u56DE\u590D\uFF0C\u5FC5\u987B\u4F7F\u7528 discard_mailbox \u4E22\u5F03\u5E76\u7ED3\u675F\u5B83\u3002\u7136\u540E\u7EE7\u7EED list_mailbox \u51B3\u5B9A\u4E0B\u4E00\u5C01\u3002`
46612
+ content: `\u4F60\u7684\u90AE\u7BB1\u4E2D\u6709 ${msgIds.length} \u5C01\u5F85\u5904\u7406\u90AE\u4EF6\u3002\u8BF7\u4F7F\u7528 list_mailbox \u67E5\u770B\u90AE\u4EF6\u5217\u8868\uFF0C\u6839\u636E\u91CD\u8981\u6027\u548C\u65F6\u6548\u6027\u9009\u62E9\u4E00\u5C01\u90AE\u4EF6\uFF0C\u518D\u7528 get_mailbox \u9886\u53D6\u5E76\u8BFB\u53D6\u8BE5\u90AE\u4EF6\u3002${roleSpecificReminder} \u5B8C\u6210\u8FD9\u5C01\u90AE\u4EF6\u540E\u5FC5\u987B\u4F7F\u7528 reply_mailbox \u56DE\u590D\u5E76\u7ED3\u675F\u5B83\uFF1B\u5982\u679C\u67D0\u5C01\u90AE\u4EF6\u53EA\u662F\u786E\u8BA4\u6027\u56DE\u6267\u3001\u91CD\u590D\u901A\u77E5\u6216\u65E0\u9700\u4E1A\u52A1\u56DE\u590D\uFF0C\u5FC5\u987B\u4F7F\u7528 discard_mailbox \u4E22\u5F03\u5E76\u7ED3\u675F\u5B83\u3002\u7136\u540E\u7EE7\u7EED list_mailbox \u51B3\u5B9A\u4E0B\u4E00\u5C01\u3002`
46605
46613
  };
46606
46614
  const result = await agent(request);
46607
46615
  console.log(`[mailbox] department agent ${mailboxId} \u5904\u7406\u5B8C\u6210, alreadySent=${result.alreadySent}`);
@@ -46794,13 +46802,19 @@ var createDepartmentAgentTools = () => {
46794
46802
  registerTool(registry2, departmentProposalCreate);
46795
46803
  return { registry: registry2, executor };
46796
46804
  };
46797
- var getDepartmentAgentConfig = (tools, memberFocusOn, workspacePath, departmentName) => {
46805
+ var getDepartmentAgentConfig = (tools, memberFocusOn, workspacePath, departmentName, memberRole, memberName) => {
46798
46806
  loadEnv();
46799
46807
  const defaultSystemPrompt = `
46800
46808
  You are a department member agent in an AI company collaboration system. You communicate with other agents through a mailbox system \u2014 you do NOT interact with end users directly.
46801
46809
 
46802
46810
  <Role>
46803
46811
  Your role is to process messages from other department agents, complete your assigned tasks, and respond with clear results. Focus on your department role and collaborate effectively with other agents.
46812
+ ${departmentName ? `
46813
+ Your department: ${departmentName}` : ""}
46814
+ ${memberName ? `
46815
+ Your member name: ${memberName}` : ""}
46816
+ ${memberRole ? `
46817
+ Your organization role: ${memberRole}` : ""}
46804
46818
  ${memberFocusOn ? `
46805
46819
  Your specialization: ${memberFocusOn}` : ""}
46806
46820
  </Role>
@@ -46836,6 +46850,19 @@ ${workspacePath ? `
46836
46850
  - \u56DE\u590D\u5185\u5BB9\u5E94\u6E05\u6670\u3001\u7ED3\u6784\u5316\uFF0C\u4FBF\u4E8E\u5BF9\u65B9\u89E3\u6790\u548C\u7EE7\u7EED\u5DE5\u4F5C
46837
46851
  </Mailbox Workflow>
46838
46852
 
46853
+ <Department Head Delegation Rules>
46854
+ \u5982\u679C\u4F60\u7684 organization role \u662F department_head\uFF0C\u4F60\u662F\u7BA1\u7406\u5C42\u548C\u9A8C\u6536\u8005\uFF0C\u4E0D\u662F\u9ED8\u8BA4\u6267\u884C\u5C42\u3002
46855
+
46856
+ \u786C\u89C4\u5219\uFF1A
46857
+ 1. \u5BF9\u4E8E\u5199\u4EE3\u7801\u3001\u8BFB\u4EE3\u7801\u5B9A\u4F4D\u95EE\u9898\u3001\u6539\u6587\u4EF6\u3001\u8DD1\u6D4B\u8BD5\u3001\u8C03\u8BD5\u3001\u90E8\u7F72\u3001\u6570\u636E\u5904\u7406\u3001\u5916\u90E8 API \u9A8C\u8BC1\u3001\u751F\u6210\u590D\u6742\u4EA7\u7269\u3001\u5168\u9762\u6D4B\u8BD5\u7B49\u5177\u4F53\u6267\u884C\u5DE5\u4F5C\uFF0C\u5FC5\u987B\u5148\u5224\u65AD\u662F\u5426\u53EF\u4EE5\u5206\u6D3E\u7ED9\u672C\u90E8\u95E8 Executor\u3002
46858
+ 2. \u5904\u7406\u8FD9\u7C7B\u590D\u6742\u6267\u884C\u90AE\u4EF6\u65F6\uFF0C\u7B2C\u4E00\u6B65\u5E94\u4F7F\u7528 department_member_list \u67E5\u770B\u672C\u90E8\u95E8\u6210\u5458\uFF1B\u5982\u679C\u5DF2\u6709\u5408\u9002 Executor\uFF0C\u4F7F\u7528 department_communicate \u628A\u5177\u4F53\u6267\u884C\u4EFB\u52A1\u6D3E\u7ED9 Executor\u3002
46859
+ 3. \u5982\u679C\u6CA1\u6709\u5408\u9002 Executor\uFF0C\u4F18\u5148\u4F7F\u7528 department_member_create \u521B\u5EFA\u4E00\u4E2A\u804C\u8D23\u660E\u786E\u7684 Executor\uFF0C\u518D\u4F7F\u7528 department_communicate \u5206\u6D3E\u4EFB\u52A1\u3002
46860
+ 4. Department Head \u53EF\u4EE5\u81EA\u5DF1\u505A\u4EFB\u52A1\u62C6\u89E3\u3001\u6D4B\u8BD5\u8BA1\u5212\u3001\u9A8C\u6536\u6807\u51C6\u3001\u98CE\u9669\u5224\u65AD\u3001\u8FDB\u5EA6\u8FFD\u95EE\u548C\u6700\u7EC8\u6C47\u603B\uFF1B\u4E0D\u8981\u9ED8\u8BA4\u81EA\u5DF1\u8C03\u7528 bash/read/write/edit/grep/codesearch/websearch \u53BB\u5B8C\u6210 Executor \u5E94\u8BE5\u505A\u7684\u4E13\u4E1A\u6267\u884C\u3002
46861
+ 5. Executor \u672A\u56DE\u4FE1\u6216\u8FDB\u5EA6\u6162\uFF0C\u4E0D\u662F Department Head \u81EA\u5DF1\u4E0B\u573A\u5E72\u6D3B\u7684\u7406\u7531\uFF1B\u5E94\u901A\u8FC7 mailbox_followup \u6216 department_communicate \u8FFD\u95EE/\u8865\u5145\u4E0A\u4E0B\u6587\uFF0C\u5E76\u5411\u4E0A\u6E38\u8BF4\u660E\u6B63\u5728\u7B49\u5F85\u6267\u884C\u5C42\u7ED3\u679C\u3002
46862
+ 6. \u53EA\u6709\u5F53\u90AE\u4EF6\u660E\u786E\u8981\u6C42 Department Head \u4EB2\u81EA\u6267\u884C\u3001\u5F53\u524D\u90E8\u95E8\u6CA1\u6709\u53EF\u7528 Executor \u4E14\u77ED\u671F\u65E0\u6CD5\u521B\u5EFA\u3001\u6216 Executor \u660E\u786E\u5931\u8D25\u4E14\u4E0A\u6E38\u540C\u610F Head \u63A5\u7BA1\u65F6\uFF0CDepartment Head \u624D\u80FD\u4EB2\u81EA\u4F7F\u7528\u6267\u884C\u7C7B\u5DE5\u5177\u5B8C\u6210\u4E13\u4E1A\u6267\u884C\u3002
46863
+ 7. \u6536\u5230 Executor \u56DE\u4FE1\u540E\uFF0CDepartment Head \u5E94\u505A\u9A8C\u6536\u548C\u6C47\u603B\uFF1A\u5FC5\u8981\u65F6\u53EF\u4EE5\u68C0\u67E5\u5C11\u91CF\u5173\u952E\u8BC1\u636E\uFF0C\u4F46\u4E0D\u8981\u628A Executor \u7684\u5B8C\u6574\u6267\u884C\u804C\u8D23\u91CD\u65B0\u81EA\u5DF1\u505A\u4E00\u904D\u3002
46864
+ </Department Head Delegation Rules>
46865
+
46839
46866
  <Task Execution>
46840
46867
  - Use available tools to complete the work.
46841
46868
  - For file operations, use the dedicated file tools:
@@ -50678,6 +50705,60 @@ agentRoutes.get("/goals/:gid/chat/logs", async (c) => {
50678
50705
 
50679
50706
  // src/server/routes/departments.ts
50680
50707
  var departmentRoutes = new Hono2();
50708
+ var toBeijingDateKeys = (days = 7) => {
50709
+ const now = /* @__PURE__ */ new Date();
50710
+ return Array.from({ length: days }, (_, i) => {
50711
+ const d = new Date(now.getTime() - i * 864e5);
50712
+ return d.toLocaleString("sv-SE", {
50713
+ timeZone: "Asia/Shanghai",
50714
+ year: "numeric",
50715
+ month: "2-digit",
50716
+ day: "2-digit"
50717
+ }).replace(/-/g, "");
50718
+ });
50719
+ };
50720
+ var blockToApiBlock = (block) => {
50721
+ if (block.type === "text") return { type: "text", text: block.text };
50722
+ if (block.type === "tool_use") {
50723
+ return {
50724
+ type: "tool_use",
50725
+ id: block.id,
50726
+ name: block.name,
50727
+ input: block.input
50728
+ };
50729
+ }
50730
+ if (block.type === "tool_result") {
50731
+ return {
50732
+ type: "tool_result",
50733
+ toolUseId: block.tool_use_id,
50734
+ content: typeof block.content === "string" ? block.content.slice(0, 2e3) : JSON.stringify(block.content).slice(0, 2e3)
50735
+ };
50736
+ }
50737
+ if (block.type === "thinking") {
50738
+ return {
50739
+ type: "thinking",
50740
+ thinking: block.thinking.slice(0, 2e3)
50741
+ };
50742
+ }
50743
+ if (block.type === "image") {
50744
+ return {
50745
+ type: "image"
50746
+ };
50747
+ }
50748
+ return { type: "unknown" };
50749
+ };
50750
+ var messagesToAgentLogs = (messages, startIndex = 0) => messages.map((msg, idx) => ({
50751
+ index: startIndex + idx,
50752
+ role: msg.role,
50753
+ blocks: msg.content.map(blockToApiBlock)
50754
+ }));
50755
+ var collectRecentMessages = async (storage, userId) => {
50756
+ for (const dateStr of toBeijingDateKeys()) {
50757
+ const msgs = await getMessages(storage, userId, 300, dateStr);
50758
+ if (msgs.length > 0) return msgs;
50759
+ }
50760
+ return getMessages(storage, userId, 300);
50761
+ };
50681
50762
  departmentRoutes.get("/departments", (c) => {
50682
50763
  try {
50683
50764
  return c.json(listDepartments());
@@ -50840,16 +50921,8 @@ departmentRoutes.get("/departments/:name/members/:memberName/context", async (c)
50840
50921
  loadEnv();
50841
50922
  const storageConf = { url: process.env.REDIS_URL };
50842
50923
  const storage = createRuntimeStorage(storageConf);
50843
- const now = /* @__PURE__ */ new Date();
50844
50924
  let allMessages = [];
50845
- for (let i = 0; i < 7; i++) {
50846
- const d = new Date(now.getTime() - i * 864e5);
50847
- const dateStr = d.toLocaleString("sv-SE", {
50848
- timeZone: "Asia/Shanghai",
50849
- year: "numeric",
50850
- month: "2-digit",
50851
- day: "2-digit"
50852
- }).replace(/-/g, "");
50925
+ for (const dateStr of toBeijingDateKeys()) {
50853
50926
  const msgs = await getMessages(storage, mailBoxId, 300, dateStr);
50854
50927
  if (msgs.length > 0) {
50855
50928
  allMessages = msgs;
@@ -50859,39 +50932,7 @@ departmentRoutes.get("/departments/:name/members/:memberName/context", async (c)
50859
50932
  if (allMessages.length === 0) {
50860
50933
  allMessages = await getMessages(storage, mailBoxId, 300);
50861
50934
  }
50862
- agentLogs = allMessages.map((msg, idx) => {
50863
- const blocks = msg.content.map((block) => {
50864
- if (block.type === "text") return { type: "text", text: block.text };
50865
- if (block.type === "tool_use") {
50866
- return {
50867
- type: "tool_use",
50868
- id: block.id,
50869
- name: block.name,
50870
- input: block.input
50871
- };
50872
- }
50873
- if (block.type === "tool_result") {
50874
- return {
50875
- type: "tool_result",
50876
- toolUseId: block.tool_use_id,
50877
- content: typeof block.content === "string" ? block.content.slice(0, 2e3) : JSON.stringify(block.content).slice(0, 2e3)
50878
- };
50879
- }
50880
- if (block.type === "thinking") {
50881
- return {
50882
- type: "thinking",
50883
- thinking: block.thinking.slice(0, 2e3)
50884
- };
50885
- }
50886
- if (block.type === "image") {
50887
- return {
50888
- type: "image"
50889
- };
50890
- }
50891
- return { type: "unknown" };
50892
- });
50893
- return { index: idx, role: msg.role, blocks };
50894
- });
50935
+ agentLogs = messagesToAgentLogs(allMessages);
50895
50936
  } catch {
50896
50937
  agentLogs = [];
50897
50938
  }
@@ -50902,6 +50943,73 @@ departmentRoutes.get("/departments/:name/members/:memberName/context", async (c)
50902
50943
  agentLogs
50903
50944
  });
50904
50945
  });
50946
+ departmentRoutes.get("/departments/:name/ceo-context", async (c) => {
50947
+ const name = c.req.param("name");
50948
+ const department = getDepartment(name);
50949
+ if (!department) return c.json({ error: "Department not found" }, 404);
50950
+ let messages = [];
50951
+ const sourceUserIds = /* @__PURE__ */ new Set();
50952
+ try {
50953
+ const members = listDepartmentMembers(name);
50954
+ const mailboxIds = members.map((m) => m.mailBoxId);
50955
+ if (mailboxIds.length > 0) {
50956
+ const placeholders = mailboxIds.map(() => "?").join(", ");
50957
+ const db3 = createSqliteDB();
50958
+ const rows = db3.prepare(
50959
+ `SELECT id, from_mailbox_id, to_mailbox_id, content, send_time, status, thread_id, parent_message_id, origin_user_id
50960
+ FROM mailbox
50961
+ WHERE from_mailbox_id IN (${placeholders}) OR to_mailbox_id IN (${placeholders})
50962
+ ORDER BY send_time DESC
50963
+ LIMIT 100`
50964
+ ).all(...mailboxIds, ...mailboxIds);
50965
+ messages = rows.filter((row) => row.from_mailbox_id === "manager" || row.to_mailbox_id === "manager").map((row) => ({
50966
+ id: row.id,
50967
+ fromMailboxId: row.from_mailbox_id,
50968
+ toMailboxId: row.to_mailbox_id,
50969
+ content: row.content,
50970
+ sendTime: row.send_time,
50971
+ status: row.status,
50972
+ threadId: row.thread_id || void 0,
50973
+ parentMessageId: row.parent_message_id || void 0
50974
+ }));
50975
+ for (const row of rows) {
50976
+ if (typeof row.origin_user_id === "string" && row.origin_user_id.trim()) {
50977
+ sourceUserIds.add(row.origin_user_id);
50978
+ }
50979
+ }
50980
+ }
50981
+ } catch (err) {
50982
+ return c.json({ error: err.message || "Failed to get CEO mailbox messages" }, 500);
50983
+ }
50984
+ if (department.sourceGoalId) {
50985
+ const context = getGoalConversationContext(department.sourceGoalId);
50986
+ sourceUserIds.add(context?.threadId ?? getGoalThreadId(department.sourceGoalId));
50987
+ if (context?.originUserId) sourceUserIds.add(context.originUserId);
50988
+ }
50989
+ let agentLogs = [];
50990
+ try {
50991
+ loadEnv();
50992
+ const storageConf = { url: process.env.REDIS_URL };
50993
+ const storage = createRuntimeStorage(storageConf);
50994
+ let index = 0;
50995
+ for (const userId of sourceUserIds) {
50996
+ const userMessages = await collectRecentMessages(storage, userId);
50997
+ if (userMessages.length === 0) continue;
50998
+ const logs = messagesToAgentLogs(userMessages, index);
50999
+ agentLogs.push(...logs);
51000
+ index += logs.length;
51001
+ }
51002
+ } catch {
51003
+ agentLogs = [];
51004
+ }
51005
+ return c.json({
51006
+ memberName: "CEO",
51007
+ mailBoxId: "manager",
51008
+ messages,
51009
+ agentLogs,
51010
+ sourceUserIds: [...sourceUserIds]
51011
+ });
51012
+ });
50905
51013
 
50906
51014
  // src/server/routes/cron.ts
50907
51015
  var import_crypto7 = require("crypto");
@@ -51723,7 +51831,7 @@ var systemRoutes = new Hono2();
51723
51831
  var startTime = Date.now();
51724
51832
  systemRoutes.get("/system/info", (c) => {
51725
51833
  return c.json({
51726
- version: true ? "1.8.29" : "unknown",
51834
+ version: true ? "1.8.31" : "unknown",
51727
51835
  uptime: Math.floor((Date.now() - startTime) / 1e3),
51728
51836
  env: process.env.NODE_ENV || "development",
51729
51837
  nodeVersion: process.version