duclaw-cli 1.8.28 → 1.8.29
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 +80 -36
- package/dist/main.js +1 -1
- package/dist/worker-main.js +1 -1
- package/package.json +1 -1
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.
|
|
30245
|
+
console.log(`duclaw-cli v${true ? "1.8.29" : "unknown"}`);
|
|
30246
30246
|
}
|
|
30247
30247
|
function getDuclawTemplate() {
|
|
30248
30248
|
return {
|
|
@@ -41559,6 +41559,39 @@ var create_agent_events_table = () => {
|
|
|
41559
41559
|
`);
|
|
41560
41560
|
};
|
|
41561
41561
|
|
|
41562
|
+
// src/agent/interruptRegistry.ts
|
|
41563
|
+
var registry = /* @__PURE__ */ new Map();
|
|
41564
|
+
var markRunning = (userId) => {
|
|
41565
|
+
const current = registry.get(userId);
|
|
41566
|
+
if (current) {
|
|
41567
|
+
current.startedAt = Date.now();
|
|
41568
|
+
return;
|
|
41569
|
+
}
|
|
41570
|
+
registry.set(userId, { messages: [], startedAt: Date.now() });
|
|
41571
|
+
};
|
|
41572
|
+
var markDone = (userId) => {
|
|
41573
|
+
registry.delete(userId);
|
|
41574
|
+
};
|
|
41575
|
+
var hasRunningAgent = (userId) => {
|
|
41576
|
+
return registry.has(userId);
|
|
41577
|
+
};
|
|
41578
|
+
var queueInterrupt = (userId, message) => {
|
|
41579
|
+
const entry = registry.get(userId);
|
|
41580
|
+
if (!entry) return false;
|
|
41581
|
+
const interruptMessage = typeof message === "string" ? { content: message } : message;
|
|
41582
|
+
entry.messages.push(interruptMessage);
|
|
41583
|
+
console.log(`[interrupt] \u7528\u6237 ${userId} \u65B0\u6D88\u606F\u5DF2\u5165\u961F\uFF0C\u5F53\u524D\u961F\u5217\u957F\u5EA6: ${entry.messages.length}`);
|
|
41584
|
+
return true;
|
|
41585
|
+
};
|
|
41586
|
+
var drainInterrupts = (userId) => {
|
|
41587
|
+
const entry = registry.get(userId);
|
|
41588
|
+
if (!entry || entry.messages.length === 0) return [];
|
|
41589
|
+
const messages = [...entry.messages];
|
|
41590
|
+
entry.messages.length = 0;
|
|
41591
|
+
console.log(`[interrupt] \u7528\u6237 ${userId} drain ${messages.length} \u6761\u4E2D\u65AD\u6D88\u606F`);
|
|
41592
|
+
return messages;
|
|
41593
|
+
};
|
|
41594
|
+
|
|
41562
41595
|
// src/department/mailbox/events.ts
|
|
41563
41596
|
var import_node_crypto2 = require("node:crypto");
|
|
41564
41597
|
var parseDetail = (detailJson) => {
|
|
@@ -41911,6 +41944,41 @@ var cancelMailboxMessages = (mailboxId) => {
|
|
|
41911
41944
|
}
|
|
41912
41945
|
return messages.length;
|
|
41913
41946
|
};
|
|
41947
|
+
var buildMailboxInterruptContent = (msg) => {
|
|
41948
|
+
const from = msg.fromMailboxId;
|
|
41949
|
+
return [
|
|
41950
|
+
`<system_reminder>`,
|
|
41951
|
+
`\u4F60\u7684 mailbox \u6536\u5230\u4E00\u5C01\u65B0\u7684\u5185\u90E8\u534F\u4F5C\u6D88\u606F\u3002`,
|
|
41952
|
+
``,
|
|
41953
|
+
`message_id: ${msg.id}`,
|
|
41954
|
+
`from: ${from}`,
|
|
41955
|
+
`thread: ${msg.threadId || msg.id}`,
|
|
41956
|
+
``,
|
|
41957
|
+
`\u8FD9\u662F\u4E00\u6761\u4E2D\u65AD\u63D0\u9192\uFF0C\u4E0D\u4EE3\u8868\u90AE\u4EF6\u5DF2\u88AB\u9886\u53D6\u3002\u8BF7\u5C3D\u5FEB\u91CD\u65B0\u8BC4\u4F30\u5F53\u524D\u5DE5\u4F5C\u4F18\u5148\u7EA7\uFF1A`,
|
|
41958
|
+
`1. \u8C03\u7528 list_mailbox \u67E5\u770B\u5F85\u5904\u7406\u961F\u5217\u3002`,
|
|
41959
|
+
`2. \u5982\u8BE5\u6D88\u606F\u66F4\u7D27\u6025\uFF0C\u8C03\u7528 get_mailbox(message_id="${msg.id}") \u9886\u53D6\u5E76\u8BFB\u53D6\u3002`,
|
|
41960
|
+
`3. \u5982\u679C\u4F60\u6B63\u5728\u8FD0\u884C\u957F\u4EFB\u52A1\uFF0C\u5E94\u5148\u8BB0\u5F55\u5F53\u524D\u8FDB\u5C55\uFF0C\u5FC5\u8981\u65F6\u7528 mailbox_followup \u540C\u6B65\u72B6\u6001\uFF0C\u518D\u5904\u7406\u8FD9\u5C01\u65B0\u6D88\u606F\u3002`,
|
|
41961
|
+
`4. \u5F62\u6210\u6B63\u5F0F\u7B54\u590D\u540E\u5FC5\u987B\u7528 reply_mailbox \u56DE\u590D\u5BF9\u5E94 message_id\u3002`,
|
|
41962
|
+
`</system_reminder>`
|
|
41963
|
+
].join("\n");
|
|
41964
|
+
};
|
|
41965
|
+
var queueMailboxInterruptIfRunning = (msg) => {
|
|
41966
|
+
if (msg.toMailboxId === "manager") return;
|
|
41967
|
+
if (!hasRunningAgent(msg.toMailboxId)) return;
|
|
41968
|
+
const queued = queueInterrupt(msg.toMailboxId, {
|
|
41969
|
+
content: buildMailboxInterruptContent(msg),
|
|
41970
|
+
metadata: {
|
|
41971
|
+
trigger: "mailbox.message_received",
|
|
41972
|
+
mailboxMessageId: msg.id,
|
|
41973
|
+
fromMailboxId: msg.fromMailboxId,
|
|
41974
|
+
toMailboxId: msg.toMailboxId,
|
|
41975
|
+
threadId: msg.threadId || msg.id
|
|
41976
|
+
}
|
|
41977
|
+
});
|
|
41978
|
+
if (queued) {
|
|
41979
|
+
console.log(`[mailbox] \u76EE\u6807 agent ${msg.toMailboxId} \u6B63\u5728\u8FD0\u884C\uFF0C\u5DF2\u5C06\u65B0\u90AE\u4EF6 ${msg.id} \u4F5C\u4E3A\u4E2D\u65AD\u63D0\u9192\u5165\u961F`);
|
|
41980
|
+
}
|
|
41981
|
+
};
|
|
41914
41982
|
var sendMessage2 = (fromMailboxId, toMailboxId, content, options) => {
|
|
41915
41983
|
const db3 = createSqliteDB();
|
|
41916
41984
|
const stmt = db3.prepare(`insert into mailbox (
|
|
@@ -41963,6 +42031,7 @@ var sendMessage2 = (fromMailboxId, toMailboxId, content, options) => {
|
|
|
41963
42031
|
},
|
|
41964
42032
|
createdAt: mailboxMsg.sendTime
|
|
41965
42033
|
});
|
|
42034
|
+
queueMailboxInterruptIfRunning(mailboxMsg);
|
|
41966
42035
|
return mailboxMsg;
|
|
41967
42036
|
};
|
|
41968
42037
|
var updateMailboxMessageStatus = (messageId, nextStatus, options) => {
|
|
@@ -42478,7 +42547,15 @@ var checkDepartmentReplies = {
|
|
|
42478
42547
|
msgs = stmt.all();
|
|
42479
42548
|
}
|
|
42480
42549
|
if (msgs.length === 0) {
|
|
42481
|
-
return
|
|
42550
|
+
return [
|
|
42551
|
+
`[checkDepartmentReplies] \u6682\u65E0\u90E8\u95E8\u56DE\u4FE1\u3002\u6210\u5458\u53EF\u80FD\u4ECD\u5728\u5904\u7406\u4EFB\u52A1\u4E2D\uFF0C\u8BF7\u7A0D\u540E\u518D\u67E5\u3002`,
|
|
42552
|
+
``,
|
|
42553
|
+
`\u6CBB\u7406\u63D0\u793A\uFF1A`,
|
|
42554
|
+
`- \u8FD9\u4E0D\u662F\u8BA9 CEO \u4EB2\u81EA read/bash/\u6D4B\u8BD5/\u6539\u4EE3\u7801\u7684\u4FE1\u53F7\u3002`,
|
|
42555
|
+
`- \u5982\u679C\u7528\u6237\u6B63\u5728\u7B49\u5F85\uFF0C\u8BF7\u5148\u7528 send_message \u7B80\u77ED\u8BF4\u660E\u201C\u8D1F\u8D23\u4EBA\u8FD8\u5728\u5904\u7406\uFF0C\u6211\u7A0D\u540E\u540C\u6B65\u7ED3\u679C\u201D\u3002`,
|
|
42556
|
+
`- \u5982\u679C\u5DF2\u7ECF\u7B49\u5F85\u8F83\u4E45\uFF0C\u4F7F\u7528 mailbox_followup \u6216 department_communicate \u50AC\u95EE\u5BF9\u5E94 Department Head \u7684\u771F\u5B9E\u8FDB\u5C55\u3001\u963B\u585E\u9879\u548C\u9884\u8BA1\u5B8C\u6210\u65F6\u95F4\u3002`,
|
|
42557
|
+
`- \u4E4B\u540E\u518D\u8C03\u7528 check_department_replies \u67E5\u770B\u56DE\u4FE1\u3002`
|
|
42558
|
+
].join("\n");
|
|
42482
42559
|
}
|
|
42483
42560
|
const updateStmt = db3.prepare(`UPDATE mailbox SET status = 'read' WHERE id = ?`);
|
|
42484
42561
|
for (const msg of msgs) {
|
|
@@ -43689,39 +43766,6 @@ var recallChatHistory = (messageStorage, topicStorage, recallIndexStorage) => ({
|
|
|
43689
43766
|
}
|
|
43690
43767
|
});
|
|
43691
43768
|
|
|
43692
|
-
// src/agent/interruptRegistry.ts
|
|
43693
|
-
var registry = /* @__PURE__ */ new Map();
|
|
43694
|
-
var markRunning = (userId) => {
|
|
43695
|
-
const current = registry.get(userId);
|
|
43696
|
-
if (current) {
|
|
43697
|
-
current.startedAt = Date.now();
|
|
43698
|
-
return;
|
|
43699
|
-
}
|
|
43700
|
-
registry.set(userId, { messages: [], startedAt: Date.now() });
|
|
43701
|
-
};
|
|
43702
|
-
var markDone = (userId) => {
|
|
43703
|
-
registry.delete(userId);
|
|
43704
|
-
};
|
|
43705
|
-
var hasRunningAgent = (userId) => {
|
|
43706
|
-
return registry.has(userId);
|
|
43707
|
-
};
|
|
43708
|
-
var queueInterrupt = (userId, message) => {
|
|
43709
|
-
const entry = registry.get(userId);
|
|
43710
|
-
if (!entry) return false;
|
|
43711
|
-
const interruptMessage = typeof message === "string" ? { content: message } : message;
|
|
43712
|
-
entry.messages.push(interruptMessage);
|
|
43713
|
-
console.log(`[interrupt] \u7528\u6237 ${userId} \u65B0\u6D88\u606F\u5DF2\u5165\u961F\uFF0C\u5F53\u524D\u961F\u5217\u957F\u5EA6: ${entry.messages.length}`);
|
|
43714
|
-
return true;
|
|
43715
|
-
};
|
|
43716
|
-
var drainInterrupts = (userId) => {
|
|
43717
|
-
const entry = registry.get(userId);
|
|
43718
|
-
if (!entry || entry.messages.length === 0) return [];
|
|
43719
|
-
const messages = [...entry.messages];
|
|
43720
|
-
entry.messages.length = 0;
|
|
43721
|
-
console.log(`[interrupt] \u7528\u6237 ${userId} drain ${messages.length} \u6761\u4E2D\u65AD\u6D88\u606F`);
|
|
43722
|
-
return messages;
|
|
43723
|
-
};
|
|
43724
|
-
|
|
43725
43769
|
// src/dream/dreamPrompt.ts
|
|
43726
43770
|
var DREAM_MAX_MESSAGE_CHARS = 1e4;
|
|
43727
43771
|
var DREAM_MAX_TEXT_BLOCK_CHARS = 400;
|
|
@@ -51679,7 +51723,7 @@ var systemRoutes = new Hono2();
|
|
|
51679
51723
|
var startTime = Date.now();
|
|
51680
51724
|
systemRoutes.get("/system/info", (c) => {
|
|
51681
51725
|
return c.json({
|
|
51682
|
-
version: true ? "1.8.
|
|
51726
|
+
version: true ? "1.8.29" : "unknown",
|
|
51683
51727
|
uptime: Math.floor((Date.now() - startTime) / 1e3),
|
|
51684
51728
|
env: process.env.NODE_ENV || "development",
|
|
51685
51729
|
nodeVersion: process.version
|