@composio/core 1.0.0-beta.0 → 1.0.0-beta.1

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 (82) hide show
  1. package/dist/{CustomTool-l-j5HtEf.mjs → CustomTool-CM-roKk7.mjs} +16 -6
  2. package/dist/{CustomTool-CwpeQhz2.d.mts → CustomTool-yMQjEyMz.d.mts} +1 -1
  3. package/dist/{FileModifierErrors-B8V8_3VE.mjs → FileModifierErrors-CdGSABoq.mjs} +1 -1
  4. package/dist/{FileToolModifier.utils.neutral-D_YkHwZP.mjs → FileToolModifier.utils.neutral-DWFpnsj2.mjs} +4 -2
  5. package/dist/{SsrfErrors-DNJt57GL.mjs → SsrfErrors-DiQldIdC.mjs} +154 -19
  6. package/dist/{Telemetry-DK1uAWnD.mjs → Telemetry-JRJJYS4I.mjs} +28 -44
  7. package/dist/cancellation-BEpFk2S8.mjs +706 -0
  8. package/dist/{composio-XjF7EMEe.d.mts → composio-BVNJTVYa.d.mts} +2450 -119
  9. package/dist/{customTool.types-DpJbYY5m.d.mts → customTool.types-CY5SXFfF.d.mts} +143 -28
  10. package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +1 -1
  11. package/dist/docs/reference/sdk-reference/typescript/session.mdx +4 -3
  12. package/dist/{errors-BcEUHZbq.mjs → errors-CvZjP9CH.mjs} +42 -4
  13. package/dist/experimental/index.d.mts +2 -2
  14. package/dist/experimental/index.mjs +1 -1
  15. package/dist/{fileUtils.node-BwpUOF0s.mjs → fileUtils.node-HQsywtTj.mjs} +11 -9
  16. package/dist/index.d.mts +393 -142
  17. package/dist/index.mjs +1945 -171
  18. package/dist/models/Files.node.d.mts +2 -3
  19. package/dist/models/Files.node.mjs +2 -2
  20. package/dist/models/Files.workerd.d.mts +2 -3
  21. package/dist/platform/node.d.mts +2 -3
  22. package/dist/platform/workerd.d.mts +2 -3
  23. package/dist/{sensitiveFileUploadPaths-B0w8dqpv.mjs → sensitiveFileUploadPaths-BlLp-Yo2.mjs} +10 -7
  24. package/dist/{ssrfGuard.node-DlxO8uzr.mjs → ssrfGuard.node-BK50mYTq.mjs} +187 -24
  25. package/dist/{types-C9kJAurw.d.mts → types-CqGfjlZg.d.mts} +2 -2
  26. package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +3 -4
  27. package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +3 -4
  28. package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -4
  29. package/dist/utils/modifiers/FileToolModifier.node.mjs +6 -6
  30. package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -4
  31. package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
  32. package/dist/utils/ssrfGuard.node.d.mts +7 -7
  33. package/dist/utils/ssrfGuard.node.mjs +1 -1
  34. package/dist/utils/ssrfGuard.workerd.d.mts +3 -4
  35. package/dist/utils/ssrfGuard.workerd.mjs +2 -2
  36. package/package.json +25 -7
  37. package/src/composio.ts +86 -2
  38. package/src/errors/ConnectedAccountsErrors.ts +47 -0
  39. package/src/errors/ToolErrors.ts +1 -0
  40. package/src/errors/ValidationErrors.ts +2 -0
  41. package/src/index.ts +21 -0
  42. package/src/models/ConnectedAccounts.ts +118 -2
  43. package/src/models/CustomTool.ts +41 -6
  44. package/src/models/CustomToolkits.ts +169 -0
  45. package/src/models/Experimental.ts +27 -0
  46. package/src/models/Keyring.ts +65 -0
  47. package/src/models/Logs.ts +101 -0
  48. package/src/models/RemoteFile.ts +54 -36
  49. package/src/models/ToolRouterSession.ts +60 -4
  50. package/src/models/Toolkits.ts +180 -0
  51. package/src/models/Tools.ts +3 -1
  52. package/src/models/Triggers.ts +17 -87
  53. package/src/models/Usage.ts +119 -0
  54. package/src/models/Webhooks.ts +520 -0
  55. package/src/services/telemetry/TelemetryService.ts +27 -12
  56. package/src/telemetry/redact.ts +133 -6
  57. package/src/types/authConfigs.types.ts +2 -0
  58. package/src/types/connectedAccounts.types.ts +54 -0
  59. package/src/types/customToolkits.types.ts +102 -0
  60. package/src/types/keyring.types.ts +32 -0
  61. package/src/types/logs.types.ts +108 -0
  62. package/src/types/toolRouter.types.ts +49 -1
  63. package/src/types/toolkit.types.ts +131 -0
  64. package/src/types/usage.types.ts +81 -0
  65. package/src/types/webhooks.types.ts +143 -0
  66. package/src/utils/constants.ts +1 -5
  67. package/src/utils/fileUtils.node.ts +10 -2
  68. package/src/utils/jsonSchema.ts +509 -28
  69. package/src/utils/logger.ts +45 -13
  70. package/src/utils/pinnedDispatcher.node.ts +109 -13
  71. package/src/utils/sdk.ts +1 -1
  72. package/src/utils/ssrfGuard.node.ts +124 -21
  73. package/src/utils/ssrfGuard.workerd.ts +5 -1
  74. package/src/utils/transformers/connectedAccounts.ts +37 -2
  75. package/src/utils/transformers/customToolkits.ts +98 -0
  76. package/src/utils/transformers/keyring.ts +24 -0
  77. package/src/utils/transformers/logs.ts +85 -0
  78. package/src/utils/transformers/toolkits.ts +100 -1
  79. package/src/utils/transformers/triggers.ts +2 -2
  80. package/src/utils/transformers/usage.ts +77 -0
  81. package/src/utils/transformers/webhooks.ts +139 -0
  82. package/dist/cancellation-C-qy8rcj.mjs +0 -364
@@ -13,6 +13,33 @@
13
13
  */
14
14
 
15
15
  const REDACTED = '[REDACTED]';
16
+ const SECRET_KEY_PATTERN = String.raw`authorization|auth|api[-_]?key|apikey|x-api-key|access[-_]?token|refresh[-_]?token|client[-_]?secret|secret|password|passwd|pwd`;
17
+ const SECRET_KEY_WITH_PREFIX_PATTERN = String.raw`(?:[A-Za-z0-9]+_)*(?:${SECRET_KEY_PATTERN})`;
18
+ const QUOTED_SECRET_KEY_PREFIX = String.raw`(["'])(${SECRET_KEY_WITH_PREFIX_PATTERN})\1(\s*[:=]+\s*)`;
19
+ const BARE_SECRET_KEY_PREFIX = String.raw`(?<![A-Za-z0-9"'])(${SECRET_KEY_PATTERN})\b(\s*[:=]+\s*)`;
20
+ const ESCAPED_SECRET_KEY_PREFIX = String.raw`(?<![A-Za-z0-9])(${SECRET_KEY_PATTERN})\b((?:\\["'])?\s*[:=]+\s*)`;
21
+ const SECRET_PAIR_PREFIX = String.raw`(?<![A-Za-z0-9])(${SECRET_KEY_PATTERN})\b(["']?\s*[:=]+\s*)`;
22
+ const BARE_KEY_DOUBLE_QUOTED_VALUE = new RegExp(
23
+ String.raw`${BARE_SECRET_KEY_PREFIX}"((?:\\.|[^"\\\r\n])*)"`,
24
+ 'gi'
25
+ );
26
+ const BARE_KEY_SINGLE_QUOTED_VALUE = new RegExp(
27
+ String.raw`${BARE_SECRET_KEY_PREFIX}'((?:\\.|[^'\\\r\n])*)'`,
28
+ 'gi'
29
+ );
30
+ const BARE_KEY_ESCAPED_DOUBLE_QUOTED_VALUE = new RegExp(
31
+ String.raw`${ESCAPED_SECRET_KEY_PREFIX}\\"((?:\\.|[^"\\\r\n])*)\\"`,
32
+ 'gi'
33
+ );
34
+ const BARE_KEY_ESCAPED_SINGLE_QUOTED_VALUE = new RegExp(
35
+ String.raw`${ESCAPED_SECRET_KEY_PREFIX}\\'((?:\\.|[^'\\\r\n])*)\\'`,
36
+ 'gi'
37
+ );
38
+ const SECRET_PAIR_UNQUOTED = new RegExp(
39
+ String.raw`${SECRET_PAIR_PREFIX}(?!\\["'])([^\s"',}&]+)`,
40
+ 'gi'
41
+ );
42
+ const CONTAINS_QUOTED_FIELD = /(?:^|[,{\s])(["'])[^"'\\\r\n]+\1\s*[:=]\s*$/;
16
43
 
17
44
  const REDACTION_RULES: ReadonlyArray<readonly [RegExp, string]> = [
18
45
  // URL query strings — tokens, presigned signatures, one-time codes.
@@ -20,17 +47,113 @@ const REDACTION_RULES: ReadonlyArray<readonly [RegExp, string]> = [
20
47
  // Authorization scheme + credential: `Bearer <token>`, `Basic <token>`.
21
48
  [/\b(bearer|basic)\s+[A-Za-z0-9._~+/=-]+/gi, `$1 ${REDACTED}`],
22
49
  // Secret-ish `key: value` / `key=value` / `key: "value"` / `key: 'value'` pairs.
23
- // The separator group allows a quote directly after the key name so JSON is
24
- // covered: in `{"api_key": "secret"}` the key's own closing quote sits
25
- // between the name and the colon.
50
+ // Match quoted keys separately so key-like prose cannot treat an enclosing
51
+ // string's closing quote as the start of a secret value.
26
52
  // Leading lookbehind (not \b) so env-style names like COMPOSIO_API_KEY still
27
53
  // match: underscore is a word char, so \b can't fire between COMPOSIO_ and API.
28
54
  [
29
- /(?<![A-Za-z0-9])(authorization|api[-_]?key|apikey|x-api-key|access[-_]?token|refresh[-_]?token|client[-_]?secret|secret|password|passwd|pwd)\b(["']?\s*[:=]+\s*)(["']?)([^\s"',}&]+)\3/gi,
30
- `$1$2$3${REDACTED}$3`,
55
+ new RegExp(String.raw`${QUOTED_SECRET_KEY_PREFIX}"(?:\\.|[^"\\\r\n])*"`, 'gi'),
56
+ `$1$2$1$3"${REDACTED}"`,
57
+ ],
58
+ [
59
+ new RegExp(String.raw`${QUOTED_SECRET_KEY_PREFIX}'(?:\\.|[^'\\\r\n])*'`, 'gi'),
60
+ `$1$2$1$3'${REDACTED}'`,
31
61
  ],
32
62
  ];
33
63
 
64
+ const isWordCharacter = (character: string): boolean => /[\p{L}\p{N}_]/u.test(character);
65
+
66
+ const activeQuotesAt = (
67
+ input: string,
68
+ offsets: ReadonlySet<number>
69
+ ): ReadonlyMap<number, '"' | "'" | undefined> => {
70
+ const activeQuotes = new Map<number, '"' | "'" | undefined>();
71
+ let quote: '"' | "'" | undefined;
72
+ let escaped = false;
73
+ let lastOffset = -1;
74
+ for (const offset of offsets) lastOffset = Math.max(lastOffset, offset);
75
+
76
+ for (let position = 0; position < input.length; position += 1) {
77
+ const character = input[position];
78
+ if (offsets.has(position)) {
79
+ activeQuotes.set(position, quote);
80
+ if (position === lastOffset) break;
81
+ }
82
+ if (character === '\n' || character === '\r') {
83
+ quote = undefined;
84
+ escaped = false;
85
+ continue;
86
+ }
87
+ const previous =
88
+ position > 0 && !['\n', '\r'].includes(input[position - 1]) ? input[position - 1] : '';
89
+ const following = input[position + 1] ?? '';
90
+ if (!quote) {
91
+ if (character === '"' || (character === "'" && !isWordCharacter(previous))) {
92
+ quote = character;
93
+ }
94
+ continue;
95
+ }
96
+ if (escaped) escaped = false;
97
+ else if (character === '\\') escaped = true;
98
+ else if (character === quote) {
99
+ if (quote === "'" && isWordCharacter(previous) && isWordCharacter(following)) continue;
100
+ quote = undefined;
101
+ }
102
+ }
103
+
104
+ return activeQuotes;
105
+ };
106
+
107
+ const completesQuotedFieldAt = (input: string, index: number, quote: '"' | "'"): boolean => {
108
+ let escaped = false;
109
+ for (let position = index; position < input.length; position += 1) {
110
+ const character = input[position];
111
+ if (character === '\n' || character === '\r') return false;
112
+ if (escaped) {
113
+ escaped = false;
114
+ continue;
115
+ }
116
+ if (character === '\\') {
117
+ escaped = true;
118
+ continue;
119
+ }
120
+ if (character !== quote) continue;
121
+
122
+ let separator = position + 1;
123
+ while (separator < input.length && /\s/.test(input[separator])) separator += 1;
124
+ return input[separator] === ':' || input[separator] === '=';
125
+ }
126
+ return false;
127
+ };
128
+
129
+ const redactBareQuotedValue = (input: string, pattern: RegExp, quote: '"' | "'"): string => {
130
+ pattern.lastIndex = 0;
131
+ const matches = Array.from(input.matchAll(pattern));
132
+ if (matches.length === 0) return input;
133
+
134
+ const activeQuotes = activeQuotesAt(input, new Set(matches.map(match => match.index)));
135
+ const parts: string[] = [];
136
+ let cursor = 0;
137
+
138
+ for (const match of matches) {
139
+ const offset = match.index;
140
+ parts.push(input.slice(cursor, offset));
141
+ if (
142
+ activeQuotes.get(offset) === quote &&
143
+ (completesQuotedFieldAt(input, offset + match[0].length, quote) ||
144
+ CONTAINS_QUOTED_FIELD.test(match[3]))
145
+ ) {
146
+ parts.push(match[0]);
147
+ } else {
148
+ parts.push(`${match[1]}${match[2]}${quote}${REDACTED}${quote}`);
149
+ }
150
+ cursor = offset + match[0].length;
151
+ }
152
+
153
+ parts.push(input.slice(cursor));
154
+ return parts.join('');
155
+ };
156
+
34
157
  /**
35
158
  * Redact common secret shapes from a free-form string. Returns the input
36
159
  * unchanged when it is empty or `undefined`.
@@ -41,5 +164,9 @@ export const redactSensitiveText = (input: string | undefined): string | undefin
41
164
  for (const [pattern, replacement] of REDACTION_RULES) {
42
165
  output = output.replace(pattern, replacement);
43
166
  }
44
- return output;
167
+ output = output.replace(BARE_KEY_ESCAPED_DOUBLE_QUOTED_VALUE, `$1$2\\"${REDACTED}\\"`);
168
+ output = output.replace(BARE_KEY_ESCAPED_SINGLE_QUOTED_VALUE, `$1$2\\'${REDACTED}\\'`);
169
+ output = redactBareQuotedValue(output, BARE_KEY_DOUBLE_QUOTED_VALUE, '"');
170
+ output = redactBareQuotedValue(output, BARE_KEY_SINGLE_QUOTED_VALUE, "'");
171
+ return output.replace(SECRET_PAIR_UNQUOTED, `$1$2${REDACTED}`);
45
172
  };
@@ -20,6 +20,7 @@ export const AuthSchemeTypes = {
20
20
  SERVICE_ACCOUNT: 'SERVICE_ACCOUNT',
21
21
  SAML: 'SAML',
22
22
  DCR_OAUTH: 'DCR_OAUTH',
23
+ CIMD_OAUTH: 'CIMD_OAUTH',
23
24
  S2S_OAUTH2: 'S2S_OAUTH2',
24
25
  } as const;
25
26
  export type AuthSchemeType = (typeof AuthSchemeTypes)[keyof typeof AuthSchemeTypes];
@@ -47,6 +48,7 @@ export const AuthSchemeEnum = z.enum([
47
48
  'SERVICE_ACCOUNT',
48
49
  'SAML',
49
50
  'DCR_OAUTH',
51
+ 'CIMD_OAUTH',
50
52
  'S2S_OAUTH2',
51
53
  ]);
52
54
  export const CreateCustomAuthConfigParamsSchema = z.object({
@@ -356,6 +356,10 @@ export type CreateConnectedAccountLinkResponse = z.infer<
356
356
 
357
357
  export const ConnectedAccountRefreshOptionsSchema = z.object({
358
358
  redirectUrl: z.string().optional(),
359
+ /**
360
+ * @deprecated The Composio API no longer accepts this field. It is ignored
361
+ * and `refresh()` logs a warning when it is set.
362
+ */
359
363
  validateCredentials: z.boolean().optional(),
360
364
  });
361
365
  export type ConnectedAccountRefreshOptions = z.infer<typeof ConnectedAccountRefreshOptionsSchema>;
@@ -393,3 +397,53 @@ export const UpdateConnectedAccountAclParamsSchema = ConnectedAccountAclConfigSc
393
397
  }
394
398
  );
395
399
  export type UpdateConnectedAccountAclParams = z.infer<typeof UpdateConnectedAccountAclParamsSchema>;
400
+
401
+ /**
402
+ * Response of `composio.connectedAccounts.revoke()`.
403
+ */
404
+ export const ConnectedAccountRevokedTokenSchema = z.enum([
405
+ 'access_token',
406
+ 'refresh_token',
407
+ 'credential',
408
+ ]);
409
+ export type ConnectedAccountRevokedToken = z.infer<typeof ConnectedAccountRevokedTokenSchema>;
410
+
411
+ export const ConnectedAccountRevokeResponseSchema = z.object({
412
+ /**
413
+ * Tokens revoked at the provider on this call. An empty array means the
414
+ * connection was already revoked (no upstream dispatch).
415
+ */
416
+ revokedTokens: z.array(ConnectedAccountRevokedTokenSchema),
417
+ connectedAccount: z.object({
418
+ id: z.string(),
419
+ /** The connection status after this call (`REVOKED` on success). */
420
+ status: ConnectedAccountStatusSchema,
421
+ }),
422
+ });
423
+ export type ConnectedAccountRevokeResponse = z.infer<typeof ConnectedAccountRevokeResponseSchema>;
424
+
425
+ /**
426
+ * Params for `composio.connectedAccounts.completeAuth()`.
427
+ */
428
+ export const ConnectedAccountCompleteAuthParamsSchema = z.object({
429
+ /** The user the connection was initiated for. Must match the connection owner. */
430
+ userId: z.string().min(1),
431
+ /** The opaque, single-use session URI your OAuth callback verifier received. */
432
+ sessionUri: z.string().min(1),
433
+ });
434
+ export type ConnectedAccountCompleteAuthParams = z.infer<
435
+ typeof ConnectedAccountCompleteAuthParamsSchema
436
+ >;
437
+
438
+ /**
439
+ * Response of `composio.connectedAccounts.completeAuth()`.
440
+ */
441
+ export const ConnectedAccountCompleteAuthResponseSchema = z.object({
442
+ /** The connection that was completed; it is now `ACTIVE`. */
443
+ connectedAccountId: z.string(),
444
+ /** The toolkit the connection belongs to. */
445
+ toolkitSlug: z.string(),
446
+ });
447
+ export type ConnectedAccountCompleteAuthResponse = z.infer<
448
+ typeof ConnectedAccountCompleteAuthResponseSchema
449
+ >;
@@ -0,0 +1,102 @@
1
+ import { z } from 'zod/v3';
2
+
3
+ /**
4
+ * How end users authenticate to a custom toolkit.
5
+ * **Experimental — custom toolkits are in pilot; shape may change.**
6
+ */
7
+ export const CustomToolkitAuthSchemeSchema = z.discriminatedUnion('mode', [
8
+ z.object({ mode: z.literal('NO_AUTH') }),
9
+ z.object({
10
+ mode: z.literal('API_KEY'),
11
+ /**
12
+ * Headers sent with each request. Write `{{generic_api_key}}` where the
13
+ * end user's API key goes, for example
14
+ * `{ Authorization: 'Bearer {{generic_api_key}}' }`.
15
+ */
16
+ headers: z.record(z.string(), z.string()),
17
+ /** End-user copy for the API key input on the connect page. */
18
+ apiKeyField: z
19
+ .object({
20
+ displayName: z.string().min(1).max(100).optional(),
21
+ description: z.string().min(1).max(500).optional(),
22
+ })
23
+ .optional(),
24
+ }),
25
+ z.object({
26
+ mode: z.literal('DCR_OAUTH'),
27
+ /**
28
+ * Where to fetch the full auth scheme, usually the
29
+ * `/.well-known/oauth-authorization-server` path of your MCP URL.
30
+ */
31
+ discoveryUrl: z.string().url(),
32
+ }),
33
+ ]);
34
+ export type CustomToolkitAuthScheme = z.infer<typeof CustomToolkitAuthSchemeSchema>;
35
+
36
+ /**
37
+ * Params for `composio.experimental.customToolkits.upsert()`.
38
+ * **Experimental — custom toolkits are in pilot; shape may change.**
39
+ */
40
+ export const CustomToolkitUpsertParamsSchema = z.object({
41
+ /**
42
+ * Letters, digits, underscores or spaces, up to 30 characters. The API
43
+ * prefixes it with `CUSTOM_` and turns spaces into underscores.
44
+ */
45
+ slug: z
46
+ .string()
47
+ .min(1)
48
+ .max(30)
49
+ .regex(/^[a-zA-Z0-9_\s]+$/),
50
+ toolkitConfig: z.object({
51
+ /** Human-readable toolkit name. */
52
+ name: z.string().min(1).max(200),
53
+ /** The app URL. For an MCP app, the MCP server URL. */
54
+ appUrl: z.string().url(),
55
+ /** Square PNG or JPEG logo (256-1024px, max 3MB), base64-encoded. Defaults to the Composio logo. */
56
+ logoFile: z
57
+ .object({
58
+ content: z.string().min(1),
59
+ mimeType: z.enum(['image/png', 'image/jpeg']),
60
+ })
61
+ .optional(),
62
+ /** At least one scheme. The schemes cannot change once the toolkit exists. */
63
+ authSchemes: z.array(CustomToolkitAuthSchemeSchema).min(1),
64
+ }),
65
+ });
66
+ export type CustomToolkitUpsertParams = z.infer<typeof CustomToolkitUpsertParamsSchema>;
67
+
68
+ export const CustomToolkitUpsertResponseSchema = z.object({
69
+ /** Slug of the created or updated toolkit. */
70
+ slug: z.string(),
71
+ });
72
+ export type CustomToolkitUpsertResponse = z.infer<typeof CustomToolkitUpsertResponseSchema>;
73
+
74
+ /**
75
+ * Params for `composio.experimental.customToolkits.sync()`.
76
+ * **Experimental — custom toolkits are in pilot; shape may change.**
77
+ */
78
+ export const CustomToolkitSyncParamsSchema = z.object({
79
+ /** Connected account to use when fetching the remote tool definitions. */
80
+ connectedAccountId: z.string().optional(),
81
+ });
82
+ export type CustomToolkitSyncParams = z.infer<typeof CustomToolkitSyncParamsSchema>;
83
+
84
+ export const CustomToolkitSyncResponseSchema = z.object({
85
+ slug: z.string(),
86
+ /** Toolkit version after the sync. */
87
+ version: z.string(),
88
+ /** Number of tools synced. */
89
+ syncedCount: z.number(),
90
+ });
91
+ export type CustomToolkitSyncResponse = z.infer<typeof CustomToolkitSyncResponseSchema>;
92
+
93
+ export const CustomToolkitDeleteResponseSchema = z.object({
94
+ /** Slug of the deleted toolkit. */
95
+ slug: z.string(),
96
+ deleted: z.boolean(),
97
+ /** Background jobs revoking the credentials of the toolkit's connected accounts. */
98
+ revokeJobIds: z.array(z.string()),
99
+ authConfigsDeleted: z.number(),
100
+ connectedAccountsDeleted: z.number(),
101
+ });
102
+ export type CustomToolkitDeleteResponse = z.infer<typeof CustomToolkitDeleteResponseSchema>;
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod/v3';
2
+
3
+ /**
4
+ * A public JWK a secret can be sealed to. Fields keep their JWK names so a
5
+ * key can be handed straight to WebCrypto or a JOSE library.
6
+ */
7
+ export const KeyringTransferKeySchema = z.object({
8
+ /** Key type. Always `RSA`. */
9
+ kty: z.string(),
10
+ /** RSA modulus, base64url-encoded. */
11
+ n: z.string(),
12
+ /** RSA public exponent, base64url-encoded. */
13
+ e: z.string(),
14
+ /** Key-management algorithm for the JWE (`RSA-OAEP-256`). Pair it with `A256GCM` content encryption. */
15
+ alg: z.string(),
16
+ /** Key use. Always `enc`. */
17
+ use: z.string(),
18
+ /** Key identifier. Put it in the JWE protected header. */
19
+ kid: z.string(),
20
+ });
21
+ export type KeyringTransferKey = z.infer<typeof KeyringTransferKeySchema>;
22
+
23
+ /**
24
+ * Response of `composio.keyring.listTransferKeys()`.
25
+ */
26
+ export const KeyringTransferKeysResponseSchema = z.object({
27
+ /** The `kid` of the key to seal new secrets to. */
28
+ activeKid: z.string(),
29
+ /** Every currently accepted transfer key, newest first. */
30
+ keys: z.array(KeyringTransferKeySchema),
31
+ });
32
+ export type KeyringTransferKeysResponse = z.infer<typeof KeyringTransferKeysResponseSchema>;
@@ -0,0 +1,108 @@
1
+ import { z } from 'zod/v3';
2
+
3
+ /**
4
+ * Fields a tool-execution log search can filter on.
5
+ */
6
+ export const LogSearchFilterFieldSchema = z.enum([
7
+ 'tool_slug',
8
+ 'toolkit_slug',
9
+ 'connected_account_id',
10
+ 'auth_config_id',
11
+ 'status',
12
+ 'user_id',
13
+ 'session_id',
14
+ 'sandbox_id',
15
+ 'request_id',
16
+ 'log_id',
17
+ ]);
18
+ export type LogSearchFilterField = z.infer<typeof LogSearchFilterFieldSchema>;
19
+
20
+ export const LogSearchFilterOperatorSchema = z.enum(['==', '!=', 'contains', 'not_contains']);
21
+ export type LogSearchFilterOperator = z.infer<typeof LogSearchFilterOperatorSchema>;
22
+
23
+ export const LogSearchFilterSchema = z.object({
24
+ field: LogSearchFilterFieldSchema,
25
+ operator: LogSearchFilterOperatorSchema,
26
+ value: z.string(),
27
+ });
28
+ export type LogSearchFilter = z.infer<typeof LogSearchFilterSchema>;
29
+
30
+ export const LogSearchTimeRangeSchema = z.object({
31
+ /** Start time in epoch milliseconds (inclusive). */
32
+ from: z.number(),
33
+ /** End time in epoch milliseconds. */
34
+ to: z.number(),
35
+ });
36
+ export type LogSearchTimeRange = z.infer<typeof LogSearchTimeRangeSchema>;
37
+
38
+ /**
39
+ * Params for `composio.logs.search()`.
40
+ */
41
+ export const LogSearchParamsSchema = z.object({
42
+ limit: z.number().optional(),
43
+ cursor: z.string().nullable().optional(),
44
+ filters: z.array(LogSearchFilterSchema).optional(),
45
+ timeRange: LogSearchTimeRangeSchema.optional(),
46
+ });
47
+ export type LogSearchParams = z.infer<typeof LogSearchParamsSchema>;
48
+
49
+ export const ToolExecutionLogStatusSchema = z.enum(['success', 'failed']);
50
+ export const ToolExecutionLogLevelSchema = z.enum(['info', 'error', 'warn']);
51
+
52
+ export const ToolExecutionLogParentSchema = z
53
+ .object({
54
+ logId: z.string(),
55
+ toolSlug: z.string(),
56
+ })
57
+ .nullable();
58
+
59
+ /**
60
+ * A tool-execution log entry as returned by `composio.logs.search()`.
61
+ */
62
+ export const ToolExecutionLogSchema = z.object({
63
+ id: z.string(),
64
+ /** ISO 8601 timestamp. */
65
+ timestamp: z.string(),
66
+ /** Log event type, e.g. `tool.execution`. */
67
+ type: z.string(),
68
+ status: ToolExecutionLogStatusSchema,
69
+ level: ToolExecutionLogLevelSchema,
70
+ message: z.string().optional(),
71
+ metadata: z.record(z.string(), z.unknown()),
72
+ metrics: z.record(z.string(), z.unknown()),
73
+ parent: ToolExecutionLogParentSchema,
74
+ });
75
+ export type ToolExecutionLog = z.infer<typeof ToolExecutionLogSchema>;
76
+
77
+ export const LogSearchResponseSchema = z.object({
78
+ logs: z.array(ToolExecutionLogSchema),
79
+ nextCursor: z.string().nullable(),
80
+ });
81
+ export type LogSearchResponse = z.infer<typeof LogSearchResponseSchema>;
82
+
83
+ /**
84
+ * A single tool-execution log with its full detail, as returned by
85
+ * `composio.logs.get()`.
86
+ */
87
+ export const ToolExecutionLogDetailSchema = ToolExecutionLogSchema.extend({
88
+ timings: z
89
+ .object({
90
+ /** Epoch milliseconds. */
91
+ startTime: z.number(),
92
+ /** Epoch milliseconds. */
93
+ endTime: z.number(),
94
+ })
95
+ .optional(),
96
+ context: z.object({
97
+ sessionId: z.string().optional(),
98
+ traceId: z.string().optional(),
99
+ requestId: z.string().optional(),
100
+ }),
101
+ source: z.object({
102
+ host: z.string().optional(),
103
+ framework: z.string().optional(),
104
+ language: z.string().optional(),
105
+ }),
106
+ data: z.record(z.string(), z.unknown()),
107
+ });
108
+ export type ToolExecutionLogDetail = z.infer<typeof ToolExecutionLogDetailSchema>;
@@ -4,7 +4,10 @@ import { SessionMetaToolOptions } from './modifiers.types';
4
4
  import { ConnectionRequest } from './connectionRequest.types';
5
5
  import type { ComposioRequestOptions } from './requestOptions.types';
6
6
  import type { ToolRouterSessionFilesMount } from '../models/ToolRouterSessionFileMount';
7
- import type { SessionCreateResponse } from '@composio/client/resources/tool-router/session/session.mjs';
7
+ import type {
8
+ SessionConfigHistoryResponse,
9
+ SessionCreateResponse,
10
+ } from '@composio/client/resources/tool-router/session/session.mjs';
8
11
  import type {
9
12
  CustomTool,
10
13
  CustomToolkit,
@@ -707,6 +710,49 @@ export const ToolRouterSessionDeleteResponseSchema = z.object({
707
710
  });
708
711
  export type ToolRouterSessionDeleteResponse = z.infer<typeof ToolRouterSessionDeleteResponseSchema>;
709
712
 
713
+ /**
714
+ * Options for `session.configHistory()`.
715
+ */
716
+ export const ToolRouterSessionConfigHistoryOptionsSchema = z.object({
717
+ /** Cursor from a previous response's `nextCursor`. */
718
+ cursor: z.string().optional(),
719
+ /** Number of items per page, max allowed is 100. */
720
+ limit: z.number().optional(),
721
+ });
722
+ export type ToolRouterSessionConfigHistoryOptions = z.infer<
723
+ typeof ToolRouterSessionConfigHistoryOptionsSchema
724
+ >;
725
+
726
+ /**
727
+ * The session configuration at one version, as stored by the API. This is
728
+ * the wire shape (snake_case), typed from the generated client.
729
+ */
730
+ export type ToolRouterSessionConfigHistoryConfig = SessionConfigHistoryResponse.Item.Config;
731
+
732
+ export type ToolRouterSessionConfigHistoryItem = {
733
+ /** The config version this entry represents. */
734
+ version: number;
735
+ /** ISO timestamp — for archived rows, when the version was superseded by an update. */
736
+ createdAt: string;
737
+ /** True only for the live (current) config, present on the first page. */
738
+ isCurrent: boolean;
739
+ /** The session configuration at this version. */
740
+ config: ToolRouterSessionConfigHistoryConfig;
741
+ };
742
+
743
+ export type ToolRouterSessionConfigHistoryResponse = {
744
+ items: ToolRouterSessionConfigHistoryItem[];
745
+ nextCursor: string | null;
746
+ totalPages: number;
747
+ currentPage: number;
748
+ totalItems: number;
749
+ };
750
+
751
+ export type ToolRouterSessionConfigHistoryFn = (
752
+ options?: ToolRouterSessionConfigHistoryOptions,
753
+ requestOptions?: ComposioRequestOptions
754
+ ) => Promise<ToolRouterSessionConfigHistoryResponse>;
755
+
710
756
  export type ToolRouterSessionDeleteFn = (
711
757
  requestOptions?: ComposioRequestOptions
712
758
  ) => Promise<ToolRouterSessionDeleteResponse>;
@@ -748,6 +794,8 @@ export interface Session<
748
794
  update: ToolRouterSessionUpdateFn;
749
795
  /** Delete the session. Deleted sessions are no longer retrievable or executable. */
750
796
  delete: ToolRouterSessionDeleteFn;
797
+ /** Page through the session's configuration history (newest first). */
798
+ configHistory: ToolRouterSessionConfigHistoryFn;
751
799
  /** Proxy an API call through Composio's auth layer using the session's connected account */
752
800
  proxyExecute: ToolRouterSessionProxyExecuteFn;
753
801
  /** List custom tools registered in this session, with their final slugs and schemas */