@clawos-dev/clawd 0.2.191-beta.381.2ccc9ac → 0.2.191-beta.382.4a6606c
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/cli.cjs +40 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -53806,10 +53806,20 @@ function buildInboxHandlers(deps) {
|
|
|
53806
53806
|
const d = deps.sendDmDeps;
|
|
53807
53807
|
if (!d) throw new ClawdError(ERROR_CODES.INTERNAL, "inbox:sendDm not wired");
|
|
53808
53808
|
if (!sessionId) {
|
|
53809
|
+
d?.logger?.warn("inbox.sendDm.rejected", { reason: "missing-session-id" });
|
|
53809
53810
|
throw new ClawdError(ERROR_CODES.VALIDATION_ERROR, "inbox:sendDm requires sessionId");
|
|
53810
53811
|
}
|
|
53811
53812
|
const scope = d.getSessionScope(sessionId);
|
|
53813
|
+
d.logger?.info("inbox.sendDm.received", {
|
|
53814
|
+
sessionId,
|
|
53815
|
+
scopeKind: scope?.kind ?? "null",
|
|
53816
|
+
mode: scope && scope.kind === "persona" ? scope.mode : void 0,
|
|
53817
|
+
personaId: scope && scope.kind === "persona" ? scope.personaId : void 0,
|
|
53818
|
+
hasPeerDeviceId: Boolean(args.peerDeviceId),
|
|
53819
|
+
textLen: args.text.length
|
|
53820
|
+
});
|
|
53812
53821
|
if (!scope || scope.kind !== "persona") {
|
|
53822
|
+
d.logger?.warn("inbox.sendDm.rejected", { sessionId, reason: "not-persona-session", scopeKind: scope?.kind ?? "null" });
|
|
53813
53823
|
throw new ClawdError(ERROR_CODES.UNAUTHORIZED, "inbox:sendDm requires a persona session");
|
|
53814
53824
|
}
|
|
53815
53825
|
const origin = { kind: "persona", personaId: scope.personaId };
|
|
@@ -53817,6 +53827,12 @@ function buildInboxHandlers(deps) {
|
|
|
53817
53827
|
const createdAt = d.now();
|
|
53818
53828
|
if (scope.mode === "guest") {
|
|
53819
53829
|
if (args.peerDeviceId && args.peerDeviceId !== d.ownerPrincipalId) {
|
|
53830
|
+
d.logger?.warn("inbox.sendDm.rejected", {
|
|
53831
|
+
sessionId,
|
|
53832
|
+
reason: "guest-non-owner-target",
|
|
53833
|
+
personaId: scope.personaId,
|
|
53834
|
+
target: args.peerDeviceId
|
|
53835
|
+
});
|
|
53820
53836
|
throw new ClawdError(ERROR_CODES.UNAUTHORIZED, "guest-driven persona may only DM the owner");
|
|
53821
53837
|
}
|
|
53822
53838
|
const message2 = manager.postMessage({
|
|
@@ -53827,13 +53843,21 @@ function buildInboxHandlers(deps) {
|
|
|
53827
53843
|
createdAt,
|
|
53828
53844
|
origin
|
|
53829
53845
|
});
|
|
53846
|
+
d.logger?.info("inbox.sendDm.delivered", { sessionId, mode: "guest", personaId: scope.personaId, peerDeviceId: scope.capId, id });
|
|
53830
53847
|
return { response: { type: "inbox:sendDm:ok", message: message2 } };
|
|
53831
53848
|
}
|
|
53832
53849
|
if (!args.peerDeviceId) {
|
|
53850
|
+
d.logger?.warn("inbox.sendDm.rejected", { sessionId, reason: "owner-missing-peer", personaId: scope.personaId });
|
|
53833
53851
|
throw new ClawdError(ERROR_CODES.VALIDATION_ERROR, "owner-driven sendDm requires peerDeviceId");
|
|
53834
53852
|
}
|
|
53835
53853
|
const contact = d.getContact(args.peerDeviceId);
|
|
53836
53854
|
if (!contact) {
|
|
53855
|
+
d.logger?.warn("inbox.sendDm.rejected", {
|
|
53856
|
+
sessionId,
|
|
53857
|
+
reason: "unknown-contact",
|
|
53858
|
+
personaId: scope.personaId,
|
|
53859
|
+
peerDeviceId: args.peerDeviceId
|
|
53860
|
+
});
|
|
53837
53861
|
throw new ClawdError(ERROR_CODES.VALIDATION_ERROR, `unknown contact: ${args.peerDeviceId}`);
|
|
53838
53862
|
}
|
|
53839
53863
|
const fwd = await d.forwardInboxPostToPeer({
|
|
@@ -53844,6 +53868,13 @@ function buildInboxHandlers(deps) {
|
|
|
53844
53868
|
origin
|
|
53845
53869
|
});
|
|
53846
53870
|
if (!fwd.ok) {
|
|
53871
|
+
d.logger?.warn("inbox.sendDm.forward-failed", {
|
|
53872
|
+
sessionId,
|
|
53873
|
+
personaId: scope.personaId,
|
|
53874
|
+
peerDeviceId: args.peerDeviceId,
|
|
53875
|
+
id,
|
|
53876
|
+
error: fwd.error ?? "unknown"
|
|
53877
|
+
});
|
|
53847
53878
|
throw new ClawdError(ERROR_CODES.INTERNAL, `deliver to peer failed: ${fwd.error ?? "unknown"}`);
|
|
53848
53879
|
}
|
|
53849
53880
|
const message = manager.postMessage({
|
|
@@ -53854,6 +53885,13 @@ function buildInboxHandlers(deps) {
|
|
|
53854
53885
|
createdAt,
|
|
53855
53886
|
origin
|
|
53856
53887
|
});
|
|
53888
|
+
d.logger?.info("inbox.sendDm.delivered", {
|
|
53889
|
+
sessionId,
|
|
53890
|
+
mode: "owner",
|
|
53891
|
+
personaId: scope.personaId,
|
|
53892
|
+
peerDeviceId: args.peerDeviceId,
|
|
53893
|
+
id
|
|
53894
|
+
});
|
|
53857
53895
|
return { response: { type: "inbox:sendDm:ok", message } };
|
|
53858
53896
|
};
|
|
53859
53897
|
return {
|
|
@@ -56364,7 +56402,8 @@ function buildMethodHandlers(deps) {
|
|
|
56364
56402
|
},
|
|
56365
56403
|
genId: () => (0, import_node_crypto17.randomUUID)(),
|
|
56366
56404
|
now: () => Date.now(),
|
|
56367
|
-
forwardInboxPostToPeer
|
|
56405
|
+
forwardInboxPostToPeer,
|
|
56406
|
+
logger: deps.logger
|
|
56368
56407
|
}
|
|
56369
56408
|
}),
|
|
56370
56409
|
...buildContactHandlers({
|
package/package.json
CHANGED