@alfe.ai/openclaw-identity 0.1.1 → 0.1.2

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/plugin2.cjs CHANGED
@@ -132,6 +132,7 @@ function evaluateAgentChat(permissions, args) {
132
132
  const pkg = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("../package.json");
133
133
  const RESOLVE_CACHE_TTL_MS = 6e4;
134
134
  const resolveCache = /* @__PURE__ */ new Map();
135
+ let lastInboundConversationId;
135
136
  function getCachedResolve(key) {
136
137
  const entry = resolveCache.get(key);
137
138
  if (!entry) return null;
@@ -175,15 +176,19 @@ function isSelfScopedWhoIsThis(toolArgs, cacheKey) {
175
176
  return argProvider === cached.senderProvider && argPlatformId === cached.senderPlatformId;
176
177
  }
177
178
  /**
178
- * Resolve the inbound session identity from `conversationId`. Returns
179
- * `{ error }` on cache miss / missing param never falls back to LLM-
180
- * supplied identity (that's the security property see header).
179
+ * Resolve the inbound session identity. Reads from `lastInboundConversationId`
180
+ * (set by `message_received`)the LLM-supplied `params.conversationId` is
181
+ * ignored because in practice the LLM copies the visible-metadata
182
+ * `conversationId` field, which is currently the WS request envelope id
183
+ * (`req_…`), not the real session key the cache is keyed on. Falls back to
184
+ * `params.conversationId` only when no inbound message has been observed
185
+ * this process (autonomous / scheduled triggers).
181
186
  */
182
187
  function resolveSessionIdentity(params) {
183
- const conversationId = params.conversationId;
188
+ const conversationId = lastInboundConversationId ?? params.conversationId;
184
189
  if (!conversationId) return {
185
190
  ok: false,
186
- error: "missing_conversation_id: pass conversationId from the inbound message metadata. The verify tools auto-bind to the inbound sender's identity there is no manual override."
191
+ error: "no_inbound_session: identity verification can only be initiated from a user-message turn. The verify tools auto-bind to the inbound sender's session and cannot be called from autonomous / scheduled / tool-chain triggers."
187
192
  };
188
193
  const cached = getCachedResolve(conversationId);
189
194
  if (cached?.identityId == null) return {
@@ -416,9 +421,9 @@ const plugin = {
416
421
  }),
417
422
  defineTool({
418
423
  name: "request_identity_verification",
419
- description: "Send a verification phrase to the inbound user's email or mobile to prove they own that contact endpoint. Use when the inbound user has just told you their email or mobile number and you want them to confirm it. PASS conversationId from the inbound message metadata — the verification ALWAYS binds to the inbound sender's identity (the WhatsApp / SMS / Discord / Google Chat / chat-web user who just spoke). There is no way to verify a different identity via this tool — identity is server-authoritative, resolved at session-start by the chat service. If the contact you supply already lives on another existing identity (e.g. the user's Clerk web account), the merge happens automatically on confirm. To add a new contact to an already-verified canonical identity (e.g. add a new email to a Clerk account), the user must be talking from a session that already resolves to that canonical identity (post-merge, or chat-web logged in as Clerk).",
424
+ description: "Send a verification phrase to the inbound user's email or mobile to prove they own that contact endpoint. Use when the inbound user has just told you their email or mobile number and you want them to confirm it. The verification ALWAYS binds to the inbound sender's identity (the WhatsApp / SMS / Discord / Google Chat / chat-web user who just spoke) — identity is server-authoritative, auto-derived from the current inbound session. There is no way to verify a different identity via this tool. If the contact you supply already lives on another existing identity (e.g. the user's Clerk web account), the merge happens automatically on confirm. To add a new contact to an already-verified canonical identity (e.g. add a new email to a Clerk account), the user must be talking from a session that already resolves to that canonical identity (post-merge, or chat-web logged in as Clerk).",
420
425
  parameters: _sinclair_typebox.Type.Object({
421
- conversationId: _sinclair_typebox.Type.String({ description: "Conversation ID from the inbound message the daemon attaches this to every message. REQUIRED there is no manual override path." }),
426
+ conversationId: _sinclair_typebox.Type.Optional(_sinclair_typebox.Type.String({ description: "Deprecated and ignored the tool auto-binds to the current inbound session. Retained as optional for back-compat with older agent prompts." })),
422
427
  contactEmail: _sinclair_typebox.Type.Optional(_sinclair_typebox.Type.String({ description: "Email to verify (mutually exclusive with contactMobile)" })),
423
428
  contactMobile: _sinclair_typebox.Type.Optional(_sinclair_typebox.Type.String({ description: "E.164 mobile to verify (mutually exclusive with contactEmail)" })),
424
429
  preferredChannel: _sinclair_typebox.Type.Optional(_sinclair_typebox.Type.String({ description: "When neither contactEmail nor contactMobile is provided, pick which existing verified contact to deliver to: 'mobile' or 'email'" }))
@@ -448,9 +453,9 @@ const plugin = {
448
453
  }),
449
454
  defineTool({
450
455
  name: "confirm_identity_verification",
451
- description: "Confirm a verification by submitting the phrase the inbound user received. Returns `{ verified, identityId, action }` where `action` is 'merged' (the verified contact already lived on another identity, which is now the survivor — the inbound identity merged into it) or 'contact_verified' (the contact was attached to the inbound identity). PASS the same conversationId you used on request_identity_verificationidentity is auto-derived from it, no override.",
456
+ description: "Confirm a verification by submitting the phrase the inbound user received. Returns `{ verified, identityId, action }` where `action` is 'merged' (the verified contact already lived on another identity, which is now the survivor — the inbound identity merged into it) or 'contact_verified' (the contact was attached to the inbound identity). Identity is server-authoritative, auto-derived from the current inbound session — no override available.",
452
457
  parameters: _sinclair_typebox.Type.Object({
453
- conversationId: _sinclair_typebox.Type.String({ description: "Conversation ID from the inbound message same one passed to request_identity_verification. REQUIRED." }),
458
+ conversationId: _sinclair_typebox.Type.Optional(_sinclair_typebox.Type.String({ description: "Deprecated and ignored the tool auto-binds to the current inbound session. Retained as optional for back-compat with older agent prompts." })),
454
459
  verificationId: _sinclair_typebox.Type.String({ description: "Verification ID returned from request_identity_verification" }),
455
460
  phrase: _sinclair_typebox.Type.String({ description: "Three-word phrase the inbound user received via mobile or email" })
456
461
  }),
@@ -463,8 +468,8 @@ const plugin = {
463
468
  phrase: params.phrase
464
469
  });
465
470
  if (result.verified === true) {
466
- const conversationId = params.conversationId;
467
- invalidateCachedResolve(conversationId);
471
+ const conversationId = lastInboundConversationId ?? params.conversationId;
472
+ if (conversationId) invalidateCachedResolve(conversationId);
468
473
  }
469
474
  return result;
470
475
  }
@@ -478,6 +483,7 @@ const plugin = {
478
483
  const provider = ctx.channelId ?? "unknown";
479
484
  const senderId = event.metadata?.UserId ?? event.from;
480
485
  if (!senderId) return;
486
+ if (ctx.conversationId) lastInboundConversationId = ctx.conversationId;
481
487
  let agentId = ctx.agentId;
482
488
  if (!agentId) {
483
489
  const fallback = await getAgentContext(client);
package/dist/plugin2.js CHANGED
@@ -132,6 +132,7 @@ function evaluateAgentChat(permissions, args) {
132
132
  const pkg = createRequire(import.meta.url)("../package.json");
133
133
  const RESOLVE_CACHE_TTL_MS = 6e4;
134
134
  const resolveCache = /* @__PURE__ */ new Map();
135
+ let lastInboundConversationId;
135
136
  function getCachedResolve(key) {
136
137
  const entry = resolveCache.get(key);
137
138
  if (!entry) return null;
@@ -175,15 +176,19 @@ function isSelfScopedWhoIsThis(toolArgs, cacheKey) {
175
176
  return argProvider === cached.senderProvider && argPlatformId === cached.senderPlatformId;
176
177
  }
177
178
  /**
178
- * Resolve the inbound session identity from `conversationId`. Returns
179
- * `{ error }` on cache miss / missing param never falls back to LLM-
180
- * supplied identity (that's the security property see header).
179
+ * Resolve the inbound session identity. Reads from `lastInboundConversationId`
180
+ * (set by `message_received`)the LLM-supplied `params.conversationId` is
181
+ * ignored because in practice the LLM copies the visible-metadata
182
+ * `conversationId` field, which is currently the WS request envelope id
183
+ * (`req_…`), not the real session key the cache is keyed on. Falls back to
184
+ * `params.conversationId` only when no inbound message has been observed
185
+ * this process (autonomous / scheduled triggers).
181
186
  */
182
187
  function resolveSessionIdentity(params) {
183
- const conversationId = params.conversationId;
188
+ const conversationId = lastInboundConversationId ?? params.conversationId;
184
189
  if (!conversationId) return {
185
190
  ok: false,
186
- error: "missing_conversation_id: pass conversationId from the inbound message metadata. The verify tools auto-bind to the inbound sender's identity there is no manual override."
191
+ error: "no_inbound_session: identity verification can only be initiated from a user-message turn. The verify tools auto-bind to the inbound sender's session and cannot be called from autonomous / scheduled / tool-chain triggers."
187
192
  };
188
193
  const cached = getCachedResolve(conversationId);
189
194
  if (cached?.identityId == null) return {
@@ -416,9 +421,9 @@ const plugin = {
416
421
  }),
417
422
  defineTool({
418
423
  name: "request_identity_verification",
419
- description: "Send a verification phrase to the inbound user's email or mobile to prove they own that contact endpoint. Use when the inbound user has just told you their email or mobile number and you want them to confirm it. PASS conversationId from the inbound message metadata — the verification ALWAYS binds to the inbound sender's identity (the WhatsApp / SMS / Discord / Google Chat / chat-web user who just spoke). There is no way to verify a different identity via this tool — identity is server-authoritative, resolved at session-start by the chat service. If the contact you supply already lives on another existing identity (e.g. the user's Clerk web account), the merge happens automatically on confirm. To add a new contact to an already-verified canonical identity (e.g. add a new email to a Clerk account), the user must be talking from a session that already resolves to that canonical identity (post-merge, or chat-web logged in as Clerk).",
424
+ description: "Send a verification phrase to the inbound user's email or mobile to prove they own that contact endpoint. Use when the inbound user has just told you their email or mobile number and you want them to confirm it. The verification ALWAYS binds to the inbound sender's identity (the WhatsApp / SMS / Discord / Google Chat / chat-web user who just spoke) — identity is server-authoritative, auto-derived from the current inbound session. There is no way to verify a different identity via this tool. If the contact you supply already lives on another existing identity (e.g. the user's Clerk web account), the merge happens automatically on confirm. To add a new contact to an already-verified canonical identity (e.g. add a new email to a Clerk account), the user must be talking from a session that already resolves to that canonical identity (post-merge, or chat-web logged in as Clerk).",
420
425
  parameters: Type.Object({
421
- conversationId: Type.String({ description: "Conversation ID from the inbound message the daemon attaches this to every message. REQUIRED there is no manual override path." }),
426
+ conversationId: Type.Optional(Type.String({ description: "Deprecated and ignored the tool auto-binds to the current inbound session. Retained as optional for back-compat with older agent prompts." })),
422
427
  contactEmail: Type.Optional(Type.String({ description: "Email to verify (mutually exclusive with contactMobile)" })),
423
428
  contactMobile: Type.Optional(Type.String({ description: "E.164 mobile to verify (mutually exclusive with contactEmail)" })),
424
429
  preferredChannel: Type.Optional(Type.String({ description: "When neither contactEmail nor contactMobile is provided, pick which existing verified contact to deliver to: 'mobile' or 'email'" }))
@@ -448,9 +453,9 @@ const plugin = {
448
453
  }),
449
454
  defineTool({
450
455
  name: "confirm_identity_verification",
451
- description: "Confirm a verification by submitting the phrase the inbound user received. Returns `{ verified, identityId, action }` where `action` is 'merged' (the verified contact already lived on another identity, which is now the survivor — the inbound identity merged into it) or 'contact_verified' (the contact was attached to the inbound identity). PASS the same conversationId you used on request_identity_verificationidentity is auto-derived from it, no override.",
456
+ description: "Confirm a verification by submitting the phrase the inbound user received. Returns `{ verified, identityId, action }` where `action` is 'merged' (the verified contact already lived on another identity, which is now the survivor — the inbound identity merged into it) or 'contact_verified' (the contact was attached to the inbound identity). Identity is server-authoritative, auto-derived from the current inbound session — no override available.",
452
457
  parameters: Type.Object({
453
- conversationId: Type.String({ description: "Conversation ID from the inbound message same one passed to request_identity_verification. REQUIRED." }),
458
+ conversationId: Type.Optional(Type.String({ description: "Deprecated and ignored the tool auto-binds to the current inbound session. Retained as optional for back-compat with older agent prompts." })),
454
459
  verificationId: Type.String({ description: "Verification ID returned from request_identity_verification" }),
455
460
  phrase: Type.String({ description: "Three-word phrase the inbound user received via mobile or email" })
456
461
  }),
@@ -463,8 +468,8 @@ const plugin = {
463
468
  phrase: params.phrase
464
469
  });
465
470
  if (result.verified === true) {
466
- const conversationId = params.conversationId;
467
- invalidateCachedResolve(conversationId);
471
+ const conversationId = lastInboundConversationId ?? params.conversationId;
472
+ if (conversationId) invalidateCachedResolve(conversationId);
468
473
  }
469
474
  return result;
470
475
  }
@@ -478,6 +483,7 @@ const plugin = {
478
483
  const provider = ctx.channelId ?? "unknown";
479
484
  const senderId = event.metadata?.UserId ?? event.from;
480
485
  if (!senderId) return;
486
+ if (ctx.conversationId) lastInboundConversationId = ctx.conversationId;
481
487
  let agentId = ctx.agentId;
482
488
  if (!agentId) {
483
489
  const fallback = await getAgentContext(client);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfe.ai/openclaw-identity",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "OpenClaw identity plugin — identity resolution, access gating, permission enforcement",
5
5
  "type": "module",
6
6
  "main": "./dist/plugin.js",