duclaw-cli 1.8.29 → 1.8.30

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.30" : "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
@@ -50678,6 +50685,60 @@ agentRoutes.get("/goals/:gid/chat/logs", async (c) => {
50678
50685
 
50679
50686
  // src/server/routes/departments.ts
50680
50687
  var departmentRoutes = new Hono2();
50688
+ var toBeijingDateKeys = (days = 7) => {
50689
+ const now = /* @__PURE__ */ new Date();
50690
+ return Array.from({ length: days }, (_, i) => {
50691
+ const d = new Date(now.getTime() - i * 864e5);
50692
+ return d.toLocaleString("sv-SE", {
50693
+ timeZone: "Asia/Shanghai",
50694
+ year: "numeric",
50695
+ month: "2-digit",
50696
+ day: "2-digit"
50697
+ }).replace(/-/g, "");
50698
+ });
50699
+ };
50700
+ var blockToApiBlock = (block) => {
50701
+ if (block.type === "text") return { type: "text", text: block.text };
50702
+ if (block.type === "tool_use") {
50703
+ return {
50704
+ type: "tool_use",
50705
+ id: block.id,
50706
+ name: block.name,
50707
+ input: block.input
50708
+ };
50709
+ }
50710
+ if (block.type === "tool_result") {
50711
+ return {
50712
+ type: "tool_result",
50713
+ toolUseId: block.tool_use_id,
50714
+ content: typeof block.content === "string" ? block.content.slice(0, 2e3) : JSON.stringify(block.content).slice(0, 2e3)
50715
+ };
50716
+ }
50717
+ if (block.type === "thinking") {
50718
+ return {
50719
+ type: "thinking",
50720
+ thinking: block.thinking.slice(0, 2e3)
50721
+ };
50722
+ }
50723
+ if (block.type === "image") {
50724
+ return {
50725
+ type: "image"
50726
+ };
50727
+ }
50728
+ return { type: "unknown" };
50729
+ };
50730
+ var messagesToAgentLogs = (messages, startIndex = 0) => messages.map((msg, idx) => ({
50731
+ index: startIndex + idx,
50732
+ role: msg.role,
50733
+ blocks: msg.content.map(blockToApiBlock)
50734
+ }));
50735
+ var collectRecentMessages = async (storage, userId) => {
50736
+ for (const dateStr of toBeijingDateKeys()) {
50737
+ const msgs = await getMessages(storage, userId, 300, dateStr);
50738
+ if (msgs.length > 0) return msgs;
50739
+ }
50740
+ return getMessages(storage, userId, 300);
50741
+ };
50681
50742
  departmentRoutes.get("/departments", (c) => {
50682
50743
  try {
50683
50744
  return c.json(listDepartments());
@@ -50840,16 +50901,8 @@ departmentRoutes.get("/departments/:name/members/:memberName/context", async (c)
50840
50901
  loadEnv();
50841
50902
  const storageConf = { url: process.env.REDIS_URL };
50842
50903
  const storage = createRuntimeStorage(storageConf);
50843
- const now = /* @__PURE__ */ new Date();
50844
50904
  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, "");
50905
+ for (const dateStr of toBeijingDateKeys()) {
50853
50906
  const msgs = await getMessages(storage, mailBoxId, 300, dateStr);
50854
50907
  if (msgs.length > 0) {
50855
50908
  allMessages = msgs;
@@ -50859,39 +50912,7 @@ departmentRoutes.get("/departments/:name/members/:memberName/context", async (c)
50859
50912
  if (allMessages.length === 0) {
50860
50913
  allMessages = await getMessages(storage, mailBoxId, 300);
50861
50914
  }
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
- });
50915
+ agentLogs = messagesToAgentLogs(allMessages);
50895
50916
  } catch {
50896
50917
  agentLogs = [];
50897
50918
  }
@@ -50902,6 +50923,73 @@ departmentRoutes.get("/departments/:name/members/:memberName/context", async (c)
50902
50923
  agentLogs
50903
50924
  });
50904
50925
  });
50926
+ departmentRoutes.get("/departments/:name/ceo-context", async (c) => {
50927
+ const name = c.req.param("name");
50928
+ const department = getDepartment(name);
50929
+ if (!department) return c.json({ error: "Department not found" }, 404);
50930
+ let messages = [];
50931
+ const sourceUserIds = /* @__PURE__ */ new Set();
50932
+ try {
50933
+ const members = listDepartmentMembers(name);
50934
+ const mailboxIds = members.map((m) => m.mailBoxId);
50935
+ if (mailboxIds.length > 0) {
50936
+ const placeholders = mailboxIds.map(() => "?").join(", ");
50937
+ const db3 = createSqliteDB();
50938
+ const rows = db3.prepare(
50939
+ `SELECT id, from_mailbox_id, to_mailbox_id, content, send_time, status, thread_id, parent_message_id, origin_user_id
50940
+ FROM mailbox
50941
+ WHERE from_mailbox_id IN (${placeholders}) OR to_mailbox_id IN (${placeholders})
50942
+ ORDER BY send_time DESC
50943
+ LIMIT 100`
50944
+ ).all(...mailboxIds, ...mailboxIds);
50945
+ messages = rows.filter((row) => row.from_mailbox_id === "manager" || row.to_mailbox_id === "manager").map((row) => ({
50946
+ id: row.id,
50947
+ fromMailboxId: row.from_mailbox_id,
50948
+ toMailboxId: row.to_mailbox_id,
50949
+ content: row.content,
50950
+ sendTime: row.send_time,
50951
+ status: row.status,
50952
+ threadId: row.thread_id || void 0,
50953
+ parentMessageId: row.parent_message_id || void 0
50954
+ }));
50955
+ for (const row of rows) {
50956
+ if (typeof row.origin_user_id === "string" && row.origin_user_id.trim()) {
50957
+ sourceUserIds.add(row.origin_user_id);
50958
+ }
50959
+ }
50960
+ }
50961
+ } catch (err) {
50962
+ return c.json({ error: err.message || "Failed to get CEO mailbox messages" }, 500);
50963
+ }
50964
+ if (department.sourceGoalId) {
50965
+ const context = getGoalConversationContext(department.sourceGoalId);
50966
+ sourceUserIds.add(context?.threadId ?? getGoalThreadId(department.sourceGoalId));
50967
+ if (context?.originUserId) sourceUserIds.add(context.originUserId);
50968
+ }
50969
+ let agentLogs = [];
50970
+ try {
50971
+ loadEnv();
50972
+ const storageConf = { url: process.env.REDIS_URL };
50973
+ const storage = createRuntimeStorage(storageConf);
50974
+ let index = 0;
50975
+ for (const userId of sourceUserIds) {
50976
+ const userMessages = await collectRecentMessages(storage, userId);
50977
+ if (userMessages.length === 0) continue;
50978
+ const logs = messagesToAgentLogs(userMessages, index);
50979
+ agentLogs.push(...logs);
50980
+ index += logs.length;
50981
+ }
50982
+ } catch {
50983
+ agentLogs = [];
50984
+ }
50985
+ return c.json({
50986
+ memberName: "CEO",
50987
+ mailBoxId: "manager",
50988
+ messages,
50989
+ agentLogs,
50990
+ sourceUserIds: [...sourceUserIds]
50991
+ });
50992
+ });
50905
50993
 
50906
50994
  // src/server/routes/cron.ts
50907
50995
  var import_crypto7 = require("crypto");
@@ -51723,7 +51811,7 @@ var systemRoutes = new Hono2();
51723
51811
  var startTime = Date.now();
51724
51812
  systemRoutes.get("/system/info", (c) => {
51725
51813
  return c.json({
51726
- version: true ? "1.8.29" : "unknown",
51814
+ version: true ? "1.8.30" : "unknown",
51727
51815
  uptime: Math.floor((Date.now() - startTime) / 1e3),
51728
51816
  env: process.env.NODE_ENV || "development",
51729
51817
  nodeVersion: process.version