@agentchatme/openclaw 0.7.81 → 0.7.82
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/LICENSE +21 -21
- package/README.md +308 -308
- package/RUNBOOK.md +134 -134
- package/SECURITY.md +104 -104
- package/dist/binding/agents-anchor.cjs.map +1 -1
- package/dist/binding/agents-anchor.js.map +1 -1
- package/dist/configured-state.cjs.map +1 -1
- package/dist/configured-state.js.map +1 -1
- package/dist/credentials/read-env.cjs.map +1 -1
- package/dist/credentials/read-env.js.map +1 -1
- package/dist/index.cjs +102 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +102 -19
- package/dist/index.js.map +1 -1
- package/dist/setup-entry.cjs +102 -19
- package/dist/setup-entry.cjs.map +1 -1
- package/dist/setup-entry.js +102 -19
- package/dist/setup-entry.js.map +1 -1
- package/icon.svg +5 -5
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/skills/agentchat/SKILL.md +331 -331
package/dist/setup-entry.js
CHANGED
|
@@ -1515,6 +1515,19 @@ var messageContentSchema = z.object({
|
|
|
1515
1515
|
data: z.record(z.string(), z.unknown()).optional(),
|
|
1516
1516
|
attachment_id: z.string().optional()
|
|
1517
1517
|
}).passthrough();
|
|
1518
|
+
var messageContextSchema = z.object({
|
|
1519
|
+
sender: z.object({
|
|
1520
|
+
handle: z.string(),
|
|
1521
|
+
display_name: z.string().nullable().optional(),
|
|
1522
|
+
kind: z.enum(["agent", "system"]).optional()
|
|
1523
|
+
}).passthrough().optional(),
|
|
1524
|
+
conversation: z.object({
|
|
1525
|
+
type: z.enum(["direct", "group"]).optional(),
|
|
1526
|
+
group_name: z.string().nullable().optional(),
|
|
1527
|
+
member_count: z.number().int().nullable().optional()
|
|
1528
|
+
}).passthrough().optional(),
|
|
1529
|
+
mentions: z.array(z.string()).optional()
|
|
1530
|
+
}).passthrough();
|
|
1518
1531
|
var messageSchema = z.object({
|
|
1519
1532
|
id: z.string(),
|
|
1520
1533
|
conversation_id: z.string(),
|
|
@@ -1524,6 +1537,7 @@ var messageSchema = z.object({
|
|
|
1524
1537
|
type: z.enum(["text", "structured", "file", "system"]),
|
|
1525
1538
|
content: messageContentSchema,
|
|
1526
1539
|
metadata: z.record(z.string(), z.unknown()).default({}),
|
|
1540
|
+
context: messageContextSchema.optional(),
|
|
1527
1541
|
// Per-recipient delivery state lives in `message_deliveries` since
|
|
1528
1542
|
// migration 011 — the `messages` row no longer carries `status`,
|
|
1529
1543
|
// `delivered_at`, or `read_at`. Fresh-send envelopes over WS omit
|
|
@@ -1645,7 +1659,12 @@ function normalizeMessageNew(frame) {
|
|
|
1645
1659
|
createdAt: msg.created_at,
|
|
1646
1660
|
deliveredAt: msg.delivered_at ?? null,
|
|
1647
1661
|
readAt: msg.read_at ?? null,
|
|
1648
|
-
receivedAt: frame.receivedAt
|
|
1662
|
+
receivedAt: frame.receivedAt,
|
|
1663
|
+
senderDisplayName: msg.context?.sender?.display_name ?? null,
|
|
1664
|
+
senderKind: msg.context?.sender?.kind === "system" ? "system" : "agent",
|
|
1665
|
+
groupName: msg.context?.conversation?.group_name ?? null,
|
|
1666
|
+
memberCount: msg.context?.conversation?.member_count ?? null,
|
|
1667
|
+
mentions: (msg.context?.mentions ?? []).map((m) => m.toLowerCase())
|
|
1649
1668
|
};
|
|
1650
1669
|
}
|
|
1651
1670
|
function normalizeMessageRead(frame) {
|
|
@@ -1852,7 +1871,7 @@ var CircuitBreaker = class {
|
|
|
1852
1871
|
};
|
|
1853
1872
|
|
|
1854
1873
|
// src/version.ts
|
|
1855
|
-
var PACKAGE_VERSION = "0.7.
|
|
1874
|
+
var PACKAGE_VERSION = "0.7.82";
|
|
1856
1875
|
|
|
1857
1876
|
// src/outbound.ts
|
|
1858
1877
|
var DEFAULT_RETRY_POLICY = {
|
|
@@ -2626,10 +2645,14 @@ function buildDecisionMessages(params) {
|
|
|
2626
2645
|
}
|
|
2627
2646
|
];
|
|
2628
2647
|
}
|
|
2629
|
-
function
|
|
2630
|
-
|
|
2631
|
-
const
|
|
2632
|
-
|
|
2648
|
+
function formatReceivedAt(ms) {
|
|
2649
|
+
if (!Number.isFinite(ms)) return "an unknown time";
|
|
2650
|
+
const iso = new Date(ms).toISOString();
|
|
2651
|
+
return `${iso.slice(0, 10)} ${iso.slice(11, 16)} UTC`;
|
|
2652
|
+
}
|
|
2653
|
+
function formatConversationContext(params) {
|
|
2654
|
+
const { handle, event, signals, priorCount } = params;
|
|
2655
|
+
const lines = [`Conversation type: ${formatConversationLabel(event)}`];
|
|
2633
2656
|
if (signals) {
|
|
2634
2657
|
lines.push(`Relationship: ${relationshipPhrase(signals)}`);
|
|
2635
2658
|
if (signals.secondsSincePrevious !== null) {
|
|
@@ -2638,13 +2661,28 @@ function buildUserContent(params) {
|
|
|
2638
2661
|
);
|
|
2639
2662
|
}
|
|
2640
2663
|
}
|
|
2641
|
-
lines.push(`Prior messages in this thread: ${
|
|
2642
|
-
if (
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2664
|
+
lines.push(`Prior messages in this thread: ${priorCount}`);
|
|
2665
|
+
if (event.conversationKind === "group" && handle && (event.mentions ?? []).includes(handle.toLowerCase())) {
|
|
2666
|
+
lines.push("You were @-mentioned in this message.");
|
|
2667
|
+
}
|
|
2668
|
+
return lines;
|
|
2669
|
+
}
|
|
2670
|
+
function formatConversationLabel(event) {
|
|
2671
|
+
if (event.conversationKind !== "group") return "direct";
|
|
2672
|
+
let label = event.groupName ? `group "${event.groupName}"` : "group";
|
|
2673
|
+
if (event.memberCount != null) {
|
|
2674
|
+
label += ` (${event.memberCount} member${event.memberCount === 1 ? "" : "s"})`;
|
|
2647
2675
|
}
|
|
2676
|
+
return label;
|
|
2677
|
+
}
|
|
2678
|
+
function buildUserContent(params) {
|
|
2679
|
+
const { handle, event, history, signals, maxHistory } = params;
|
|
2680
|
+
const lines = formatConversationContext({
|
|
2681
|
+
handle,
|
|
2682
|
+
event,
|
|
2683
|
+
signals,
|
|
2684
|
+
priorCount: history.length
|
|
2685
|
+
});
|
|
2648
2686
|
lines.push("");
|
|
2649
2687
|
const rendered = renderHistory(history, maxHistory);
|
|
2650
2688
|
if (rendered.length > 0) {
|
|
@@ -2934,8 +2972,9 @@ async function handleMessage(deps, event) {
|
|
|
2934
2972
|
peer,
|
|
2935
2973
|
runtime
|
|
2936
2974
|
});
|
|
2975
|
+
let gateContext = null;
|
|
2937
2976
|
if (gateEnabled()) {
|
|
2938
|
-
const decision = await runReplyGate({
|
|
2977
|
+
const { decision, context } = await runReplyGate({
|
|
2939
2978
|
deps,
|
|
2940
2979
|
event,
|
|
2941
2980
|
body,
|
|
@@ -2957,17 +2996,40 @@ async function handleMessage(deps, event) {
|
|
|
2957
2996
|
"reply gate decision"
|
|
2958
2997
|
);
|
|
2959
2998
|
if (!decision.reply) return;
|
|
2999
|
+
gateContext = context;
|
|
3000
|
+
}
|
|
3001
|
+
const contextHeader = [formatSenderLine(event), `Received: ${formatReceivedAt(ts)}`];
|
|
3002
|
+
if (gateContext) {
|
|
3003
|
+
contextHeader.push(...gateContext);
|
|
3004
|
+
} else {
|
|
3005
|
+
contextHeader.push(
|
|
3006
|
+
`Conversation type: ${formatConversationLabel({
|
|
3007
|
+
conversationKind: event.conversationKind,
|
|
3008
|
+
senderHandle,
|
|
3009
|
+
contentText: body,
|
|
3010
|
+
groupName: event.groupName,
|
|
3011
|
+
memberCount: event.memberCount,
|
|
3012
|
+
mentions: event.mentions
|
|
3013
|
+
})}`
|
|
3014
|
+
);
|
|
3015
|
+
const self = (selfHandle ?? "").replace(/^@/, "").toLowerCase();
|
|
3016
|
+
if (event.conversationKind === "group" && self && event.mentions.includes(self)) {
|
|
3017
|
+
contextHeader.push("You were @-mentioned in this message.");
|
|
3018
|
+
}
|
|
2960
3019
|
}
|
|
3020
|
+
const agentBody = `${contextHeader.join("\n")}
|
|
3021
|
+
|
|
3022
|
+
${body}`;
|
|
2961
3023
|
const { storePath, body: envelopeBody } = buildEnvelope({
|
|
2962
3024
|
channel: "AgentChat",
|
|
2963
3025
|
from: conversationLabel,
|
|
2964
|
-
body,
|
|
3026
|
+
body: agentBody,
|
|
2965
3027
|
timestamp: ts
|
|
2966
3028
|
});
|
|
2967
3029
|
const finalize = channelRuntime.reply.finalizeInboundContext;
|
|
2968
3030
|
const ctxPayload = finalize({
|
|
2969
3031
|
Body: envelopeBody,
|
|
2970
|
-
BodyForAgent:
|
|
3032
|
+
BodyForAgent: agentBody,
|
|
2971
3033
|
RawBody: body,
|
|
2972
3034
|
CommandBody: body,
|
|
2973
3035
|
From: `@${senderHandle}`,
|
|
@@ -3034,6 +3096,10 @@ async function handleMessage(deps, event) {
|
|
|
3034
3096
|
);
|
|
3035
3097
|
}
|
|
3036
3098
|
}
|
|
3099
|
+
function formatSenderLine(event) {
|
|
3100
|
+
const who = event.senderDisplayName ? `${event.senderDisplayName} (@${event.sender})` : `@${event.sender}`;
|
|
3101
|
+
return `From: ${event.senderKind === "system" ? `${who}, a system agent` : who}`;
|
|
3102
|
+
}
|
|
3037
3103
|
async function runReplyGate(params) {
|
|
3038
3104
|
const { deps, event, body, agentId, selfHandle, senderHandle, nowMs } = params;
|
|
3039
3105
|
const ownHandle = selfHandle ?? "";
|
|
@@ -3048,17 +3114,22 @@ async function runReplyGate(params) {
|
|
|
3048
3114
|
"reply gate: history fetch failed \u2014 deciding on the new message alone"
|
|
3049
3115
|
);
|
|
3050
3116
|
}
|
|
3117
|
+
const bareHandle = ownHandle.replace(/^@/, "");
|
|
3051
3118
|
const gateEvent = {
|
|
3052
3119
|
conversationKind: event.conversationKind,
|
|
3053
3120
|
senderHandle,
|
|
3054
|
-
contentText: body
|
|
3121
|
+
contentText: body,
|
|
3122
|
+
groupName: event.groupName,
|
|
3123
|
+
memberCount: event.memberCount,
|
|
3124
|
+
mentions: event.mentions
|
|
3055
3125
|
};
|
|
3056
|
-
|
|
3126
|
+
const history = translateHistory(rawMessages, ownHandle, event.conversationKind, event.messageId);
|
|
3127
|
+
const decision = await decideReply({
|
|
3057
3128
|
cfg: deps.gatewayCfg,
|
|
3058
3129
|
agentId,
|
|
3059
|
-
handle:
|
|
3130
|
+
handle: bareHandle,
|
|
3060
3131
|
event: gateEvent,
|
|
3061
|
-
history
|
|
3132
|
+
history,
|
|
3062
3133
|
rawMessages,
|
|
3063
3134
|
triggerMessageId: event.messageId,
|
|
3064
3135
|
ownHandle,
|
|
@@ -3067,6 +3138,18 @@ async function runReplyGate(params) {
|
|
|
3067
3138
|
timeoutMs: gateTimeoutMs(),
|
|
3068
3139
|
caller: deps.gateCaller
|
|
3069
3140
|
});
|
|
3141
|
+
const signals = computeConversationSignals(rawMessages, {
|
|
3142
|
+
ownHandle,
|
|
3143
|
+
triggerMessageId: event.messageId,
|
|
3144
|
+
nowMs
|
|
3145
|
+
});
|
|
3146
|
+
const context = formatConversationContext({
|
|
3147
|
+
handle: bareHandle,
|
|
3148
|
+
event: gateEvent,
|
|
3149
|
+
signals,
|
|
3150
|
+
priorCount: history.length
|
|
3151
|
+
});
|
|
3152
|
+
return { decision, context };
|
|
3070
3153
|
}
|
|
3071
3154
|
function translateHistory(messages, ownHandle, conversationKind, triggerMessageId) {
|
|
3072
3155
|
const own = ownHandle.replace(/^@/, "").toLowerCase();
|