duclaw-cli 1.9.18 → 1.9.19
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/DuclawMac.app/Contents/Info.plist +4 -0
- package/dist/DuclawMac.app/Contents/Resources/AppIcon.icns +0 -0
- package/dist/DuclawMac.app/Contents/Resources/Assets.car +0 -0
- package/dist/DuclawMac.app/Contents/assetcatalog_generated_info.plist +10 -0
- package/dist/bundle.js +137 -14
- package/dist/main.js +1 -1
- package/dist/worker-main.js +1 -1
- package/package.json +1 -1
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
<string>DuclawMac</string>
|
|
7
7
|
<key>CFBundleIdentifier</key>
|
|
8
8
|
<string>dev.duclaw.mac</string>
|
|
9
|
+
<key>CFBundleIconFile</key>
|
|
10
|
+
<string>AppIcon</string>
|
|
11
|
+
<key>CFBundleIconName</key>
|
|
12
|
+
<string>AppIcon</string>
|
|
9
13
|
<key>CFBundleName</key>
|
|
10
14
|
<string>DuclawMac</string>
|
|
11
15
|
<key>CFBundlePackageType</key>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>CFBundleIconFile</key>
|
|
6
|
+
<string>AppIcon</string>
|
|
7
|
+
<key>CFBundleIconName</key>
|
|
8
|
+
<string>AppIcon</string>
|
|
9
|
+
</dict>
|
|
10
|
+
</plist>
|
package/dist/bundle.js
CHANGED
|
@@ -39957,7 +39957,7 @@ function printHelp() {
|
|
|
39957
39957
|
`);
|
|
39958
39958
|
}
|
|
39959
39959
|
function printVersion() {
|
|
39960
|
-
console.log(`duclaw-cli v${true ? "1.9.
|
|
39960
|
+
console.log(`duclaw-cli v${true ? "1.9.19" : "unknown"}`);
|
|
39961
39961
|
}
|
|
39962
39962
|
function getDuclawTemplate() {
|
|
39963
39963
|
return {
|
|
@@ -52912,12 +52912,19 @@ var renderAgentEventReminder = (events) => {
|
|
|
52912
52912
|
`\u8BFB\u4E00\u904D\uFF0C\u7528\u4F60\u81EA\u5DF1\u7684\u8BDD\u7ED9\u8001\u677F\u6C47\u62A5\u4E00\u6B21\uFF1A\u6709\u591A\u6761\u5C31\u5408\u5E76\u6210\u4E00\u6761\u8BF4\u6E05\u695A\uFF0C\u522B\u4E00\u6761\u4E8B\u4EF6\u56DE\u4E00\u53E5\u3001\u628A\u540C\u4E00\u4EF6\u4E8B\u91CD\u590D\u53D1\u7ED9\u8001\u677F\u3002`,
|
|
52913
52913
|
`\u5982\u679C\u7ED3\u679C\u8BF4\u660E\u4E8B\u60C5\u8FD8\u6CA1\u505A\u5B8C\u6216\u5361\u4F4F\u4E86\uFF0C\u5C31\u5982\u5B9E\u8FD9\u4E48\u8BB2\uFF0C\u800C\u4E0D\u662F\u542B\u7CCA\u5730\u201C\u7A0D\u540E\u540C\u6B65\u201D\u3002`
|
|
52914
52914
|
].join("\n") : "";
|
|
52915
|
+
const hasManagerMailboxMessage = events.some((event) => event.type === "manager.mailbox_message");
|
|
52916
|
+
const managerMailboxInstruction = hasManagerMailboxMessage ? [
|
|
52917
|
+
``,
|
|
52918
|
+
`\u5176\u4E2D type=manager.mailbox_message \u7684\u4E8B\u4EF6\uFF0C\u662F\u56E2\u961F\u53D1\u7ED9 CEO \u7684\u5185\u90E8\u8FDB\u5C55\u3001\u8865\u5145\u6216\u963B\u585E\u72B6\u6001\u3002`,
|
|
52919
|
+
`\u8FD9\u7C7B\u4E8B\u4EF6\u53EA\u4EE3\u8868\u4F60\u770B\u5230\u4E86\u56E2\u961F\u6D88\u606F\uFF0C\u4E0D\u4EE3\u8868\u7CFB\u7EDF\u8981\u6C42\u4F60\u9010\u6761\u8F6C\u53D1\u3002\u8BF7\u50CF CEO \u4E00\u6837\u5224\u65AD\uFF1A\u5982\u679C\u7528\u6237\u9700\u8981\u77E5\u9053\u3001\u9700\u8981\u884C\u52A8\u3001\u6216\u6B63\u5728\u7B49\u5F85\u5173\u952E\u72B6\u6001\uFF0C\u5C31\u7528 send_message \u7B80\u660E\u8F6C\u8FBE\uFF1B\u5982\u679C\u53EA\u662F\u666E\u901A\u5185\u90E8\u8FDB\u5C55\uFF0C\u5C31\u8BB0\u4F4F\u5E76\u7EE7\u7EED\u534F\u8C03\u3002`
|
|
52920
|
+
].join("\n") : "";
|
|
52915
52921
|
return `<system-reminder>
|
|
52916
52922
|
\u672C\u8F6E\u6709 ${events.length} \u6761\u5185\u90E8\u4E8B\u4EF6\u53EF\u7528\uFF1A
|
|
52917
52923
|
${lines}
|
|
52918
52924
|
|
|
52919
52925
|
\u8FD9\u4E9B\u4E8B\u4EF6\u4E0D\u662F\u7528\u6237\u7684\u65B0\u8BF7\u6C42\uFF0C\u4E5F\u4E0D\u5E94\u8BE5\u4F5C\u4E3A\u7528\u6237\u786E\u8BA4\u3002\u82E5\u4E8B\u4EF6\u7C7B\u578B\u662F mailbox.message_received\uFF0C\u8868\u793A\u4F60\u7684 mailbox \u5728\u5F53\u524D\u5DE5\u4F5C\u671F\u95F4\u6536\u5230\u65B0\u5185\u90E8\u534F\u4F5C\u6D88\u606F\uFF1B\u8BF7\u5C3D\u5FEB\u8C03\u7528 list_mailbox \u67E5\u770B\u961F\u5217\uFF0C\u5E76\u5728\u9700\u8981\u65F6\u7528 get_mailbox(message_id) \u9886\u53D6\u5173\u8054\u6D88\u606F\u3002\u4E0D\u8981\u76F4\u63A5\u628A\u4E8B\u4EF6\u5F53\u4F5C\u5DF2\u9886\u53D6\u90AE\u4EF6\u3002\u8BF7\u53EA\u5728\u9700\u8981\u65F6\u81EA\u7136\u5730\u6C47\u603B\u7ED9\u7528\u6237\uFF1B\u5982\u9700\u7EE7\u7EED\u534F\u4F5C\uFF0C\u4F18\u5148\u4F7F\u7528\u4E8B\u4EF6\u4E2D\u5173\u8054\u7684 mailboxMessageId/thread \u7EE7\u7EED\u5904\u7406\u3002\u4E0D\u8981\u590D\u8FF0\u672C system-reminder\u3002
|
|
52920
52926
|
${ceoFollowupInstruction}
|
|
52927
|
+
${managerMailboxInstruction}
|
|
52921
52928
|
</system-reminder>`;
|
|
52922
52929
|
};
|
|
52923
52930
|
|
|
@@ -53605,8 +53612,36 @@ var queueMailboxInterruptIfRunning = (msg) => {
|
|
|
53605
53612
|
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`);
|
|
53606
53613
|
}
|
|
53607
53614
|
};
|
|
53615
|
+
var recordManagerMailboxAgentEvent = (msg) => {
|
|
53616
|
+
if (msg.toMailboxId !== "manager") return null;
|
|
53617
|
+
if (msg.workItemRole !== "followup") return null;
|
|
53618
|
+
if (!msg.originUserId || !msg.originPlatform) return null;
|
|
53619
|
+
return recordAgentEvent({
|
|
53620
|
+
userId: msg.originUserId,
|
|
53621
|
+
type: "manager.mailbox_message",
|
|
53622
|
+
source: "mailbox",
|
|
53623
|
+
sourceId: msg.id,
|
|
53624
|
+
payload: {
|
|
53625
|
+
ownerMailboxId: "manager",
|
|
53626
|
+
mailboxMessageId: msg.id,
|
|
53627
|
+
fromMailboxId: msg.fromMailboxId,
|
|
53628
|
+
toMailboxId: msg.toMailboxId,
|
|
53629
|
+
threadId: msg.threadId || msg.id,
|
|
53630
|
+
parentMessageId: msg.parentMessageId || null,
|
|
53631
|
+
workItemId: msg.workItemId || null,
|
|
53632
|
+
workItemRole: msg.workItemRole || null,
|
|
53633
|
+
originPlatform: msg.originPlatform,
|
|
53634
|
+
userVisibleRequired: false,
|
|
53635
|
+
contentPreview: msg.content.slice(0, 1200),
|
|
53636
|
+
summary: `\u56E2\u961F\u53D1\u6765\u4E00\u6761\u5185\u90E8\u8FDB\u5C55/\u8865\u5145\u6D88\u606F\uFF0C\u8BF7\u4F60\u4F5C\u4E3A CEO \u5224\u65AD\u662F\u5426\u9700\u8981\u8F6C\u8FBE\u7ED9 Boss/User\uFF1A${msg.content.slice(0, 400)}`
|
|
53637
|
+
}
|
|
53638
|
+
});
|
|
53639
|
+
};
|
|
53608
53640
|
var recordMailboxReceivedAgentEvent = (msg) => {
|
|
53609
|
-
if (msg.toMailboxId === "manager")
|
|
53641
|
+
if (msg.toMailboxId === "manager") {
|
|
53642
|
+
recordManagerMailboxAgentEvent(msg);
|
|
53643
|
+
return;
|
|
53644
|
+
}
|
|
53610
53645
|
recordAgentEvent({
|
|
53611
53646
|
userId: msg.toMailboxId,
|
|
53612
53647
|
type: "mailbox.message_received",
|
|
@@ -58479,7 +58514,7 @@ var LangSmithRun = class _LangSmithRun {
|
|
|
58479
58514
|
id;
|
|
58480
58515
|
run;
|
|
58481
58516
|
async child(input) {
|
|
58482
|
-
const child =
|
|
58517
|
+
const child = this.run.createChild({
|
|
58483
58518
|
name: input.name,
|
|
58484
58519
|
run_type: input.runType,
|
|
58485
58520
|
inputs: redactForTrace(input.inputs),
|
|
@@ -58489,10 +58524,7 @@ var LangSmithRun = class _LangSmithRun {
|
|
|
58489
58524
|
return new _LangSmithRun(child.id ?? (0, import_node_crypto17.randomUUID)(), child);
|
|
58490
58525
|
}
|
|
58491
58526
|
async end(result) {
|
|
58492
|
-
await this.run.end(
|
|
58493
|
-
outputs: redactForTrace(result.outputs),
|
|
58494
|
-
error: result.error
|
|
58495
|
-
});
|
|
58527
|
+
await this.run.end(redactForTrace(result.outputs), result.error);
|
|
58496
58528
|
await this.run.patchRun();
|
|
58497
58529
|
}
|
|
58498
58530
|
};
|
|
@@ -58507,16 +58539,18 @@ var createRuntimeTracer = () => {
|
|
|
58507
58539
|
return {
|
|
58508
58540
|
enabled: true,
|
|
58509
58541
|
async startRun(input) {
|
|
58510
|
-
const { RunTree: RunTree2 } = await Promise.resolve().then(() => (init_langsmith(), langsmith_exports));
|
|
58542
|
+
const { Client: Client3, RunTree: RunTree2 } = await Promise.resolve().then(() => (init_langsmith(), langsmith_exports));
|
|
58511
58543
|
const run = new RunTree2({
|
|
58512
58544
|
name: input.name,
|
|
58513
58545
|
run_type: input.runType,
|
|
58514
58546
|
inputs: redactForTrace(input.inputs),
|
|
58515
58547
|
extra: { metadata: redactForTrace(input.metadata) },
|
|
58516
58548
|
project_name: process.env.LANGSMITH_PROJECT || `duclaw-runtime`,
|
|
58517
|
-
|
|
58518
|
-
|
|
58519
|
-
|
|
58549
|
+
client: new Client3({
|
|
58550
|
+
apiUrl: process.env.LANGSMITH_ENDPOINT,
|
|
58551
|
+
apiKey: process.env.LANGSMITH_API_KEY,
|
|
58552
|
+
workspaceId: process.env.LANGSMITH_WORKSPACE_ID
|
|
58553
|
+
})
|
|
58520
58554
|
});
|
|
58521
58555
|
await run.postRun();
|
|
58522
58556
|
return new LangSmithRun(run.id ?? (0, import_node_crypto17.randomUUID)(), run);
|
|
@@ -60496,11 +60530,12 @@ var markMailboxStatus = (msgId, status) => {
|
|
|
60496
60530
|
const fromStatusMap = {
|
|
60497
60531
|
processing: ["pending"],
|
|
60498
60532
|
done: ["pending", "processing", "read"],
|
|
60533
|
+
read: ["pending", "processing"],
|
|
60499
60534
|
failed: ["processing"],
|
|
60500
60535
|
cancelled: ["pending", "processing"],
|
|
60501
60536
|
pending: ["processing"]
|
|
60502
60537
|
};
|
|
60503
|
-
updateMailboxMessageStatus(msgId, status, {
|
|
60538
|
+
return updateMailboxMessageStatus(msgId, status, {
|
|
60504
60539
|
fromStatus: fromStatusMap[status],
|
|
60505
60540
|
reason: "mailbox_poller"
|
|
60506
60541
|
});
|
|
@@ -60664,6 +60699,62 @@ var processCeoFollowupGroup = async (followups) => {
|
|
|
60664
60699
|
console.error(`[mailbox] CEO followup \u5904\u7406\u5931\u8D25 user=${claimed[0].originUserId}:`, err);
|
|
60665
60700
|
}
|
|
60666
60701
|
};
|
|
60702
|
+
var handleManagerMailboxEventGroup = async (items) => {
|
|
60703
|
+
const first = items[0];
|
|
60704
|
+
const originUserId = first.message.originUserId;
|
|
60705
|
+
const originPlatform = first.message.originPlatform;
|
|
60706
|
+
if (!originUserId || !originPlatform) return;
|
|
60707
|
+
const eventIds = items.map((item) => item.event.id);
|
|
60708
|
+
const mailboxMessageIds = items.map((item) => item.message.id);
|
|
60709
|
+
const metadata = {
|
|
60710
|
+
internalOnly: true,
|
|
60711
|
+
trigger: "manager.mailbox_message",
|
|
60712
|
+
agentEventIds: eventIds,
|
|
60713
|
+
mailboxMessageIds,
|
|
60714
|
+
mailboxMessageId: first.message.id,
|
|
60715
|
+
threadId: first.message.threadId || first.message.id,
|
|
60716
|
+
parentMessageId: first.message.parentMessageId || null,
|
|
60717
|
+
workItemId: first.message.workItemId || null
|
|
60718
|
+
};
|
|
60719
|
+
if (hasRunningAgent(originUserId)) {
|
|
60720
|
+
queueInterrupt(originUserId, {
|
|
60721
|
+
content: "",
|
|
60722
|
+
metadata
|
|
60723
|
+
});
|
|
60724
|
+
for (const item of items) markMailboxStatus(item.message.id, "read");
|
|
60725
|
+
console.log(`[mailbox] \u4E3B agent \u6B63\u5728\u8FD0\u884C\u4E2D\uFF0C${items.length} \u6761 manager \u5185\u90E8\u6D88\u606F\u5DF2\u4F5C\u4E3A\u4E8B\u4EF6\u5165\u961F user=${originUserId}`);
|
|
60726
|
+
return;
|
|
60727
|
+
}
|
|
60728
|
+
const request = {
|
|
60729
|
+
platform: originPlatform,
|
|
60730
|
+
userId: originUserId,
|
|
60731
|
+
requestId: first.message.id,
|
|
60732
|
+
departmentAgentId: "",
|
|
60733
|
+
content: "",
|
|
60734
|
+
metadata
|
|
60735
|
+
};
|
|
60736
|
+
const config2 = getDefaultAgentConfig();
|
|
60737
|
+
config2.channelPlugin = getCeoFollowupChannelPlugin(originPlatform);
|
|
60738
|
+
const mainAgent = createAgent(config2);
|
|
60739
|
+
const result = await mainAgent(request);
|
|
60740
|
+
for (const item of items) markMailboxStatus(item.message.id, "read");
|
|
60741
|
+
console.log(`[mailbox] \u4E3B agent \u5DF2\u5904\u7406 ${items.length} \u6761 manager \u5185\u90E8\u6D88\u606F, user=${originUserId}, alreadySent=${result.alreadySent}`);
|
|
60742
|
+
};
|
|
60743
|
+
var processManagerMailboxEventGroup = async (items) => {
|
|
60744
|
+
const claimed = [];
|
|
60745
|
+
for (const item of items) {
|
|
60746
|
+
if (markMailboxStatus(item.message.id, "processing")) {
|
|
60747
|
+
claimed.push(item);
|
|
60748
|
+
}
|
|
60749
|
+
}
|
|
60750
|
+
if (claimed.length === 0) return;
|
|
60751
|
+
try {
|
|
60752
|
+
await handleManagerMailboxEventGroup(claimed);
|
|
60753
|
+
} catch (err) {
|
|
60754
|
+
for (const item of claimed) markMailboxStatus(item.message.id, "pending");
|
|
60755
|
+
console.error(`[mailbox] CEO manager \u5185\u90E8\u6D88\u606F\u5904\u7406\u5931\u8D25 user=${claimed[0].message.originUserId}:`, err);
|
|
60756
|
+
}
|
|
60757
|
+
};
|
|
60667
60758
|
var wakeDepartmentAgent = async (mailboxId, msgIds) => {
|
|
60668
60759
|
try {
|
|
60669
60760
|
const [departmentName, memberName] = mailboxId.split("::");
|
|
@@ -60846,12 +60937,18 @@ var pollMailbox = async () => {
|
|
|
60846
60937
|
const ceoMsgs = grouped.get("manager") || [];
|
|
60847
60938
|
grouped.delete("manager");
|
|
60848
60939
|
const newFollowups = [];
|
|
60940
|
+
const managerMailboxEvents = [];
|
|
60849
60941
|
for (const msg of ceoMsgs) {
|
|
60850
60942
|
const followup = enqueueCeoFollowupFromMailbox(msg);
|
|
60851
60943
|
if (followup) {
|
|
60852
60944
|
newFollowups.push(followup);
|
|
60853
60945
|
} else {
|
|
60854
|
-
|
|
60946
|
+
const event = recordManagerMailboxAgentEvent(msg);
|
|
60947
|
+
if (event) {
|
|
60948
|
+
managerMailboxEvents.push({ message: msg, event });
|
|
60949
|
+
} else {
|
|
60950
|
+
console.warn(`[mailbox] \u6536\u5230\u53D1\u7ED9 manager \u7684\u56DE\u4FE1 ${msg.id}\uFF0C\u4F46\u7F3A\u5C11\u53EF\u8C03\u5EA6\u4E0A\u4E0B\u6587\uFF0C\u65E0\u6CD5\u521B\u5EFA CEO followup \u6216\u5185\u90E8\u4E8B\u4EF6`);
|
|
60951
|
+
}
|
|
60855
60952
|
}
|
|
60856
60953
|
}
|
|
60857
60954
|
const followups = [...pendingFollowups, ...newFollowups];
|
|
@@ -60879,6 +60976,32 @@ var pollMailbox = async () => {
|
|
|
60879
60976
|
}
|
|
60880
60977
|
})();
|
|
60881
60978
|
}
|
|
60979
|
+
const managerEventsByUser = /* @__PURE__ */ new Map();
|
|
60980
|
+
for (const item of managerMailboxEvents) {
|
|
60981
|
+
const originUserId = item.message.originUserId;
|
|
60982
|
+
if (!originUserId) continue;
|
|
60983
|
+
if (inFlightCeoReplyUsers.has(originUserId)) continue;
|
|
60984
|
+
if (followupsByUser.has(originUserId)) continue;
|
|
60985
|
+
const arr2 = managerEventsByUser.get(originUserId) || [];
|
|
60986
|
+
arr2.push(item);
|
|
60987
|
+
managerEventsByUser.set(originUserId, arr2);
|
|
60988
|
+
}
|
|
60989
|
+
for (const [originUserId, group] of managerEventsByUser) {
|
|
60990
|
+
if (inFlightCeoReplyUsers.has(originUserId)) continue;
|
|
60991
|
+
inFlightCeoReplyUsers.add(originUserId);
|
|
60992
|
+
for (const item of group) inFlightCeoReplyMessages.add(item.message.id);
|
|
60993
|
+
console.log(`[mailbox] \u6536\u5230 ${group.length} \u6761 manager \u5185\u90E8\u6D88\u606F\uFF0C\u6B63\u5728\u5524\u9192\u4E3B agent \u5224\u65AD user=${originUserId}...`);
|
|
60994
|
+
void (async () => {
|
|
60995
|
+
try {
|
|
60996
|
+
await processManagerMailboxEventGroup(group);
|
|
60997
|
+
} catch (err) {
|
|
60998
|
+
console.error(`[mailbox] \u5524\u9192\u4E3B agent \u5904\u7406 manager \u5185\u90E8\u6D88\u606F\u5931\u8D25:`, err);
|
|
60999
|
+
} finally {
|
|
61000
|
+
inFlightCeoReplyUsers.delete(originUserId);
|
|
61001
|
+
for (const item of group) inFlightCeoReplyMessages.delete(item.message.id);
|
|
61002
|
+
}
|
|
61003
|
+
})();
|
|
61004
|
+
}
|
|
60882
61005
|
for (const [mailboxId, msgs] of grouped.entries()) {
|
|
60883
61006
|
if (inFlightDepartmentMailboxes.has(mailboxId)) continue;
|
|
60884
61007
|
inFlightDepartmentMailboxes.add(mailboxId);
|
|
@@ -66073,7 +66196,7 @@ var systemRoutes = new Hono2();
|
|
|
66073
66196
|
var startTime = Date.now();
|
|
66074
66197
|
systemRoutes.get("/system/info", (c) => {
|
|
66075
66198
|
return c.json({
|
|
66076
|
-
version: true ? "1.9.
|
|
66199
|
+
version: true ? "1.9.19" : "unknown",
|
|
66077
66200
|
uptime: Math.floor((Date.now() - startTime) / 1e3),
|
|
66078
66201
|
env: process.env.NODE_ENV || "development",
|
|
66079
66202
|
nodeVersion: process.version
|