duclaw-cli 1.8.39 → 1.8.41
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 +88 -17
- 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.41" : "unknown"}`);
|
|
30246
30246
|
}
|
|
30247
30247
|
function getDuclawTemplate() {
|
|
30248
30248
|
return {
|
|
@@ -42682,6 +42682,18 @@ var departmentCreate = {
|
|
|
42682
42682
|
|
|
42683
42683
|
// src/tools/tools/department/DepartmentCommunicate.ts
|
|
42684
42684
|
var CEO_MAILBOX_ID = `manager`;
|
|
42685
|
+
var MANAGER_ALIAS_PATTERN = /(^|::)(manager|main[-_\s]?manager|ceo)$/i;
|
|
42686
|
+
var looksLikePseudoManagerMailbox = (mailboxId) => {
|
|
42687
|
+
if (mailboxId === CEO_MAILBOX_ID) return true;
|
|
42688
|
+
if (!mailboxId.includes(`::`)) return false;
|
|
42689
|
+
return MANAGER_ALIAS_PATTERN.test(mailboxId.trim());
|
|
42690
|
+
};
|
|
42691
|
+
var buildManagerRoutingRejection = (activeContext) => [
|
|
42692
|
+
`[departmentCommunicate] \u62D2\u7EDD\u53D1\u9001\u5230\u4F2A manager mailbox\u3002`,
|
|
42693
|
+
`Main Manager/CEO \u4E0D\u662F\u90E8\u95E8\u6210\u5458\uFF0C\u4E0D\u80FD\u7528 department_communicate \u53D1\u9001\u5230 manager\u3001Department::Manager\u3001CEO::Manager \u7B49\u5730\u5740\u3002`,
|
|
42694
|
+
activeContext ? `\u5982\u679C\u8981\u5411\u4E0A\u6E38 CEO \u6C47\u62A5\uFF0C\u8BF7\u8C03\u7528 reply_mailbox(message_id="${activeContext.id}", content="...") \u6B63\u5F0F\u56DE\u590D\u539F\u90AE\u4EF6\uFF1B\u82E5\u53EA\u662F\u540C\u6B65\u9636\u6BB5\u8FDB\u5C55\uFF0C\u8BF7\u8C03\u7528 mailbox_followup(message_id="${activeContext.id}", content="...", kind="progress")\u3002` : `\u5982\u679C\u8981\u5411\u4E0A\u6E38 CEO \u6C47\u62A5\uFF0C\u8BF7\u56DE\u5230\u539F manager \u90AE\u4EF6\uFF0C\u4F7F\u7528 reply_mailbox(message_id="\u539F\u90AE\u4EF6ID", content="...") \u6216 mailbox_followup(message_id="\u539F\u90AE\u4EF6ID", content="...", kind="progress")\u3002`
|
|
42695
|
+
].join(`
|
|
42696
|
+
`);
|
|
42685
42697
|
var getActiveMailboxContext = (actorMailboxId, messageId) => {
|
|
42686
42698
|
if (!messageId) return null;
|
|
42687
42699
|
const db3 = createSqliteDB();
|
|
@@ -42708,6 +42720,7 @@ var DESCRIPTION21 = `
|
|
|
42708
42720
|
- CEO \u9ED8\u8BA4\u901A\u8FC7 department_list \u53EA\u770B\u5230\u90E8\u95E8\u548C Department Head\uFF0C\u4E0D\u4E3B\u52A8\u66B4\u9732 Executor\u3002
|
|
42709
42721
|
- Department Head \u9ED8\u8BA4\u7BA1\u7406\u672C\u90E8\u95E8\u6210\u5458\u3002
|
|
42710
42722
|
- \u5982\u679C\u667A\u80FD\u4F53\u5DF2\u7ECF\u901A\u8FC7\u6B63\u5E38\u6C9F\u901A\u77E5\u9053\u4E86\u5176\u4ED6\u6210\u5458\u7684 mailbox \u5730\u5740\uFF0C\u5DE5\u5177\u4E0D\u4F1A\u786C\u6027\u963B\u6B62\u901A\u4FE1\uFF1B\u8FD9\u7C7B\u975E\u9ED8\u8BA4\u8DEF\u5F84\u4F1A\u5199\u5165\u5BA1\u8BA1\u4FE1\u606F\u3002
|
|
42723
|
+
- Main Manager/CEO \u7684 mailbox id \u56FA\u5B9A\u662F manager\u3002Department agent \u4E0D\u5E94\u4F7F\u7528 department_communicate \u7ED9 manager \u6216 Department::Manager \u53D1\u4FE1\uFF1B\u8981\u56DE\u590D\u4E0A\u6E38\u5FC5\u987B\u4F7F\u7528\u539F\u90AE\u4EF6\u7684 reply_mailbox \u6216 mailbox_followup\u3002
|
|
42711
42724
|
|
|
42712
42725
|
\u53C2\u6570\u8BF4\u660E\uFF1A
|
|
42713
42726
|
- department_name + member_name: \u9ED8\u8BA4\u5BFB\u5740\u65B9\u5F0F\u3002
|
|
@@ -42752,18 +42765,6 @@ var departmentCommunicate = {
|
|
|
42752
42765
|
const targetMailboxId = input.target_mailbox_id;
|
|
42753
42766
|
const content = input.content;
|
|
42754
42767
|
const reason = input.reason;
|
|
42755
|
-
let toMailboxId = targetMailboxId;
|
|
42756
|
-
let targetMember = targetMailboxId ? getDepartmentMemberByMailboxId(targetMailboxId) : null;
|
|
42757
|
-
if (!toMailboxId) {
|
|
42758
|
-
if (!departmentName || !memberName) {
|
|
42759
|
-
return `[departmentCommunicate] department_name/member_name \u6216 target_mailbox_id \u81F3\u5C11\u9700\u8981\u63D0\u4F9B\u4E00\u79CD`;
|
|
42760
|
-
}
|
|
42761
|
-
targetMember = getDepartmentMemberByName(departmentName, memberName);
|
|
42762
|
-
if (!targetMember) {
|
|
42763
|
-
return `[departmentCommunicate] \u4E0D\u5B58\u5728 ${departmentName} \u90E8\u95E8\u7684\u6210\u5458: ${memberName}`;
|
|
42764
|
-
}
|
|
42765
|
-
toMailboxId = getMailBoxId(departmentName, memberName);
|
|
42766
|
-
}
|
|
42767
42768
|
let fromMailboxId;
|
|
42768
42769
|
const departmentAgentId = userRequest.departmentAgentId;
|
|
42769
42770
|
const actorMember = departmentAgentId ? getDepartmentMemberByMailboxId(
|
|
@@ -42778,6 +42779,30 @@ var departmentCommunicate = {
|
|
|
42778
42779
|
} else {
|
|
42779
42780
|
fromMailboxId = CEO_MAILBOX_ID;
|
|
42780
42781
|
}
|
|
42782
|
+
const activeContext = departmentAgentId ? getActiveMailboxContext(fromMailboxId, userRequest.requestId) : null;
|
|
42783
|
+
let toMailboxId = targetMailboxId;
|
|
42784
|
+
let targetMember = targetMailboxId ? getDepartmentMemberByMailboxId(targetMailboxId) : null;
|
|
42785
|
+
if (departmentAgentId && targetMailboxId && looksLikePseudoManagerMailbox(targetMailboxId)) {
|
|
42786
|
+
return buildManagerRoutingRejection(activeContext);
|
|
42787
|
+
}
|
|
42788
|
+
if (departmentAgentId && targetMailboxId && !targetMember) {
|
|
42789
|
+
return [
|
|
42790
|
+
`[departmentCommunicate] \u62D2\u7EDD\u53D1\u9001\u5230\u4E0D\u5B58\u5728\u7684 mailbox: ${targetMailboxId}`,
|
|
42791
|
+
`Department agent \u4F7F\u7528 target_mailbox_id \u65F6\uFF0C\u76EE\u6807\u5FC5\u987B\u662F\u5DF2\u5B58\u5728\u7684\u90E8\u95E8\u6210\u5458 mailbox\u3002`,
|
|
42792
|
+
`\u5982\u679C\u4F60\u60F3\u56DE\u590D\u4E0A\u6E38 CEO/Main Manager\uFF0C\u8BF7\u4E0D\u8981\u4F2A\u9020 manager \u5730\u5740\uFF1B\u8BF7\u4F7F\u7528\u539F\u90AE\u4EF6\u7684 reply_mailbox \u6216 mailbox_followup\u3002`
|
|
42793
|
+
].join(`
|
|
42794
|
+
`);
|
|
42795
|
+
}
|
|
42796
|
+
if (!toMailboxId) {
|
|
42797
|
+
if (!departmentName || !memberName) {
|
|
42798
|
+
return `[departmentCommunicate] department_name/member_name \u6216 target_mailbox_id \u81F3\u5C11\u9700\u8981\u63D0\u4F9B\u4E00\u79CD`;
|
|
42799
|
+
}
|
|
42800
|
+
targetMember = getDepartmentMemberByName(departmentName, memberName);
|
|
42801
|
+
if (!targetMember) {
|
|
42802
|
+
return `[departmentCommunicate] \u4E0D\u5B58\u5728 ${departmentName} \u90E8\u95E8\u7684\u6210\u5458: ${memberName}`;
|
|
42803
|
+
}
|
|
42804
|
+
toMailboxId = getMailBoxId(departmentName, memberName);
|
|
42805
|
+
}
|
|
42781
42806
|
const isCrossDepartment = Boolean(actorMember && targetMember && actorMember.departmentId !== targetMember.departmentId);
|
|
42782
42807
|
const isKnownAddressPath = Boolean(targetMailboxId);
|
|
42783
42808
|
const options = {
|
|
@@ -42794,7 +42819,6 @@ var departmentCommunicate = {
|
|
|
42794
42819
|
options.originUserId = userRequest.userId;
|
|
42795
42820
|
options.originPlatform = userRequest.platform;
|
|
42796
42821
|
} else {
|
|
42797
|
-
const activeContext = getActiveMailboxContext(fromMailboxId, userRequest.requestId);
|
|
42798
42822
|
if (activeContext) {
|
|
42799
42823
|
options.originUserId = activeContext.originUserId;
|
|
42800
42824
|
options.originPlatform = activeContext.originPlatform;
|
|
@@ -45912,6 +45936,32 @@ var createAgent = (config2 = getDefaultAgentConfig()) => {
|
|
|
45912
45936
|
for (const id of ids) injectedEventIds.add(id);
|
|
45913
45937
|
markAgentEventsInjected(ids);
|
|
45914
45938
|
};
|
|
45939
|
+
const ceoFollowupIdsFromMetadata = (metadata) => {
|
|
45940
|
+
const ids = /* @__PURE__ */ new Set();
|
|
45941
|
+
if (typeof metadata?.ceoFollowupId === "string") ids.add(metadata.ceoFollowupId);
|
|
45942
|
+
if (Array.isArray(metadata?.ceoFollowupIds)) {
|
|
45943
|
+
for (const id of metadata.ceoFollowupIds) {
|
|
45944
|
+
if (typeof id === "string") ids.add(id);
|
|
45945
|
+
}
|
|
45946
|
+
}
|
|
45947
|
+
return Array.from(ids);
|
|
45948
|
+
};
|
|
45949
|
+
const rememberCeoFollowupIds = (ids) => {
|
|
45950
|
+
if (ids.length === 0) return;
|
|
45951
|
+
const current = ceoFollowupIdsFromMetadata(request.metadata);
|
|
45952
|
+
request.metadata = {
|
|
45953
|
+
...request.metadata ?? {},
|
|
45954
|
+
ceoFollowupIds: Array.from(/* @__PURE__ */ new Set([...current, ...ids]))
|
|
45955
|
+
};
|
|
45956
|
+
};
|
|
45957
|
+
const completeUserVisibleCeoFollowups = () => {
|
|
45958
|
+
const ids = ceoFollowupIdsFromMetadata(request.metadata);
|
|
45959
|
+
if (ids.length > 0) {
|
|
45960
|
+
for (const id of ids) completeCeoFollowup(id);
|
|
45961
|
+
return;
|
|
45962
|
+
}
|
|
45963
|
+
completePendingCeoFollowupsForUser(request.userId);
|
|
45964
|
+
};
|
|
45915
45965
|
const queuePendingDurableEvents = () => {
|
|
45916
45966
|
try {
|
|
45917
45967
|
const events = listPendingAgentEvents(userId, 10).filter((event) => !injectedEventIds.has(event.id)).filter((event) => !interruptQueuedEventIds.has(event.id));
|
|
@@ -46099,6 +46149,7 @@ ${msg}</user-interrupt>`;
|
|
|
46099
46149
|
if (pendingEvents.length > 0) {
|
|
46100
46150
|
for (const event of pendingEvents) injectedEventIds.add(event.id);
|
|
46101
46151
|
markAgentEventsInjected(pendingEvents.map((event) => event.id));
|
|
46152
|
+
rememberCeoFollowupIds(pendingEvents.filter((event) => event.type === "ceo.followup_required").map((event) => event.payload.ceoFollowupId).filter((id) => typeof id === "string"));
|
|
46102
46153
|
}
|
|
46103
46154
|
if (messages.length === 0 && internalOnly && eventReminder) {
|
|
46104
46155
|
messages = [userMessage(text(eventReminder))];
|
|
@@ -46237,7 +46288,7 @@ ${memoryInjection}` : "") + dreamInjection;
|
|
|
46237
46288
|
}
|
|
46238
46289
|
hasSentMessage = true;
|
|
46239
46290
|
sentMessageContent = answer;
|
|
46240
|
-
|
|
46291
|
+
completeUserVisibleCeoFollowups();
|
|
46241
46292
|
}
|
|
46242
46293
|
}
|
|
46243
46294
|
if (useBlock.name === `send_file`) {
|
|
@@ -46307,6 +46358,18 @@ ${msg}</user-interrupt>`
|
|
|
46307
46358
|
}
|
|
46308
46359
|
continue;
|
|
46309
46360
|
}
|
|
46361
|
+
const visibleCeoFollowupIds = ceoFollowupIdsFromMetadata(request.metadata);
|
|
46362
|
+
if (!hasSentMessage && visibleCeoFollowupIds.length > 0 && config2.channelPlugin) {
|
|
46363
|
+
await config2.channelPlugin.outbound.sendText({
|
|
46364
|
+
cfg: {},
|
|
46365
|
+
to: request.userId,
|
|
46366
|
+
text: textContent,
|
|
46367
|
+
accountId: request.requestId
|
|
46368
|
+
});
|
|
46369
|
+
hasSentMessage = true;
|
|
46370
|
+
sentMessageContent = textContent;
|
|
46371
|
+
completeUserVisibleCeoFollowups();
|
|
46372
|
+
}
|
|
46310
46373
|
if (topicStorage) {
|
|
46311
46374
|
const topicSummary = hasSentMessage ? sentMessageContent : textContent;
|
|
46312
46375
|
await updateTopicSummary(topicStorage, userId, beijingTime, topicSummary, job?.title);
|
|
@@ -47056,6 +47119,7 @@ var replyMailbox = {
|
|
|
47056
47119
|
// src/cron/mailbox.ts
|
|
47057
47120
|
var db2 = createSqliteDB();
|
|
47058
47121
|
var DEFAULT_MAILBOX_PROCESSING_STALE_MS = 15 * 6e4;
|
|
47122
|
+
var PSEUDO_MANAGER_MAILBOX_PATTERN = /(^|::)(manager|main[-_\s]?manager|ceo)$/i;
|
|
47059
47123
|
var selectStmt = db2.prepare(`select
|
|
47060
47124
|
id,
|
|
47061
47125
|
to_mailbox_id as toMailboxId,
|
|
@@ -47095,6 +47159,7 @@ var getMailboxLivenessSnapshot = () => {
|
|
|
47095
47159
|
};
|
|
47096
47160
|
};
|
|
47097
47161
|
var hasUnresolvedInternalWork = (snapshot) => snapshot.pendingMailbox > 0 || snapshot.processingMailbox > 0 || snapshot.pendingCeoFollowups > 0 || snapshot.processingCeoFollowups > 0 || snapshot.failedCeoFollowups > 0;
|
|
47162
|
+
var looksLikePseudoManagerMailbox2 = (mailboxId) => mailboxId !== "manager" && mailboxId.includes("::") && PSEUDO_MANAGER_MAILBOX_PATTERN.test(mailboxId.trim());
|
|
47098
47163
|
var reportMailboxLiveness = async (snapshot) => {
|
|
47099
47164
|
if (!hasUnresolvedInternalWork(snapshot)) return;
|
|
47100
47165
|
await reportRuntimeActivity({
|
|
@@ -47180,7 +47245,8 @@ var handleCeoFollowup = async (followup) => {
|
|
|
47180
47245
|
metadata: {
|
|
47181
47246
|
internalOnly: true,
|
|
47182
47247
|
eventId: event.id,
|
|
47183
|
-
trigger: "ceo.followup_required"
|
|
47248
|
+
trigger: "ceo.followup_required",
|
|
47249
|
+
ceoFollowupId: followup.id
|
|
47184
47250
|
}
|
|
47185
47251
|
});
|
|
47186
47252
|
console.log(`[mailbox] \u4E3B agent \u6B63\u5728\u8FD0\u884C\u4E2D\uFF0C${followup.fromMailboxId} \u7684\u56DE\u4FE1\u5DF2\u5165\u961F\u7B49\u5F85\u4E2D\u65AD\u6CE8\u5165 followup=${followup.id}`);
|
|
@@ -47249,6 +47315,11 @@ var wakeDepartmentAgent = async (mailboxId, msgIds) => {
|
|
|
47249
47315
|
const member = getDepartmentMemberByName(departmentName, memberName);
|
|
47250
47316
|
if (!member) {
|
|
47251
47317
|
console.warn(`[mailbox] \u76EE\u6807\u6210\u5458\u4E0D\u5B58\u5728\uFF08\u53EF\u80FD\u5DF2\u88AB\u5220\u9664\uFF09: ${mailboxId}`);
|
|
47318
|
+
if (looksLikePseudoManagerMailbox2(mailboxId)) {
|
|
47319
|
+
for (const id of msgIds) markMailboxStatus(id, "cancelled");
|
|
47320
|
+
console.warn(`[mailbox] \u5DF2\u53D6\u6D88\u4F2A manager mailbox \u6295\u9012 ${mailboxId}\uFF0C\u4E0D\u518D\u751F\u6210 CEO \u7CFB\u7EDF\u566A\u58F0`);
|
|
47321
|
+
return;
|
|
47322
|
+
}
|
|
47252
47323
|
const notifyContent = `[\u7CFB\u7EDF\u901A\u77E5] \u90E8\u95E8\u6210\u5458 ${mailboxId} \u4E0D\u5B58\u5728\uFF08\u53EF\u80FD\u6240\u5C5E\u90E8\u95E8\u5DF2\u89E3\u6563\u6216\u6210\u5458\u5DF2\u88AB\u5220\u9664\uFF09\uFF0C\u4EE5\u4E0B\u6D88\u606F\u65E0\u6CD5\u6295\u9012\u5DF2\u88AB\u53D6\u6D88\u3002\u8BF7\u6839\u636E\u60C5\u51B5\u51B3\u5B9A\u662F\u5426\u9700\u8981\u91CD\u65B0\u7EC4\u5EFA\u90E8\u95E8\u6216\u8C03\u6574\u8BA1\u5212\u3002`;
|
|
47253
47324
|
const originStmt = db2.prepare(
|
|
47254
47325
|
`SELECT origin_user_id as originUserId, origin_platform as originPlatform
|
|
@@ -52520,7 +52591,7 @@ var systemRoutes = new Hono2();
|
|
|
52520
52591
|
var startTime = Date.now();
|
|
52521
52592
|
systemRoutes.get("/system/info", (c) => {
|
|
52522
52593
|
return c.json({
|
|
52523
|
-
version: true ? "1.8.
|
|
52594
|
+
version: true ? "1.8.41" : "unknown",
|
|
52524
52595
|
uptime: Math.floor((Date.now() - startTime) / 1e3),
|
|
52525
52596
|
env: process.env.NODE_ENV || "development",
|
|
52526
52597
|
nodeVersion: process.version
|