@customclaw/composio 0.0.8 → 0.0.9

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.
Files changed (2) hide show
  1. package/dist/client.js +29 -7
  2. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -290,7 +290,7 @@ export class ComposioClient {
290
290
  * Execute a single tool using COMPOSIO_MULTI_EXECUTE_TOOL
291
291
  */
292
292
  async executeTool(toolSlug, args, userId, connectedAccountId) {
293
- const uid = this.getUserId(userId);
293
+ const requestedUid = this.getUserId(userId);
294
294
  const normalizedToolSlug = normalizeToolSlug(toolSlug);
295
295
  const toolRestrictionError = this.getToolSlugRestrictionError(normalizedToolSlug);
296
296
  if (toolRestrictionError) {
@@ -305,13 +305,15 @@ export class ComposioClient {
305
305
  }
306
306
  const accountResolution = await this.resolveConnectedAccountForExecution({
307
307
  toolkit,
308
- userId: uid,
308
+ userId: requestedUid,
309
309
  connectedAccountId,
310
+ userIdWasExplicit: typeof userId === "string" && userId.trim().length > 0,
310
311
  });
311
312
  if ("error" in accountResolution) {
312
313
  return { success: false, error: accountResolution.error };
313
314
  }
314
- const session = await this.getSession(uid, accountResolution.connectedAccountId
315
+ const effectiveUid = accountResolution.userId || requestedUid;
316
+ const session = await this.getSession(effectiveUid, accountResolution.connectedAccountId
315
317
  ? { [toolkit]: accountResolution.connectedAccountId }
316
318
  : undefined);
317
319
  try {
@@ -321,7 +323,7 @@ export class ComposioClient {
321
323
  });
322
324
  if (!response.successful) {
323
325
  const recovered = await this.tryExecutionRecovery({
324
- uid,
326
+ uid: effectiveUid,
325
327
  toolSlug: normalizedToolSlug,
326
328
  args,
327
329
  connectedAccountId: accountResolution.connectedAccountId,
@@ -341,7 +343,7 @@ export class ComposioClient {
341
343
  const toolResponse = result.response;
342
344
  if (!toolResponse.successful) {
343
345
  const recovered = await this.tryExecutionRecovery({
344
- uid,
346
+ uid: effectiveUid,
345
347
  toolSlug: normalizedToolSlug,
346
348
  args,
347
349
  connectedAccountId: accountResolution.connectedAccountId,
@@ -483,9 +485,23 @@ export class ComposioClient {
483
485
  const explicitId = params.connectedAccountId?.trim();
484
486
  if (explicitId) {
485
487
  try {
486
- const account = await this.client.connectedAccounts.get(explicitId);
488
+ let rawAccount;
489
+ const retrieve = this.client?.client?.connectedAccounts?.retrieve;
490
+ if (typeof retrieve === "function") {
491
+ try {
492
+ rawAccount = await retrieve.call(this.client.client.connectedAccounts, explicitId);
493
+ }
494
+ catch {
495
+ // Best-effort: fall through to SDK get() which may omit user_id.
496
+ }
497
+ }
498
+ if (!rawAccount) {
499
+ rawAccount = await this.client.connectedAccounts.get(explicitId);
500
+ }
501
+ const account = rawAccount;
487
502
  const accountToolkit = normalizeToolkitSlug(String(account?.toolkit?.slug || ""));
488
503
  const accountStatus = String(account?.status || "").toUpperCase();
504
+ const accountUserId = String(account?.user_id || account?.userId || "").trim();
489
505
  if (accountToolkit && accountToolkit !== toolkit) {
490
506
  return {
491
507
  error: `Connected account '${explicitId}' belongs to toolkit '${accountToolkit}', but tool '${toolkit}' was requested.`,
@@ -496,7 +512,13 @@ export class ComposioClient {
496
512
  error: `Connected account '${explicitId}' is '${accountStatus}', not ACTIVE.`,
497
513
  };
498
514
  }
499
- return { connectedAccountId: explicitId };
515
+ if (params.userIdWasExplicit && accountUserId && accountUserId !== userId) {
516
+ return {
517
+ error: `Connected account '${explicitId}' belongs to user_id '${accountUserId}', ` +
518
+ `but '${userId}' was requested. Use matching user_id or omit user_id when providing connected_account_id.`,
519
+ };
520
+ }
521
+ return { connectedAccountId: explicitId, userId: accountUserId || undefined };
500
522
  }
501
523
  catch (err) {
502
524
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@customclaw/composio",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "type": "module",
5
5
  "description": "Composio Tool Router plugin for OpenClaw — access 1000+ third-party integrations",
6
6
  "main": "dist/index.js",