@composio/core 0.18.1 → 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.
- package/dist/{CustomTool-Bz0f52QR.mjs → CustomTool-CM-roKk7.mjs} +1 -1
- package/dist/{CustomTool-VRfWzMix.d.mts → CustomTool-yMQjEyMz.d.mts} +1 -1
- package/dist/{FileModifierErrors-CwB-Inm9.mjs → FileModifierErrors-CdGSABoq.mjs} +1 -1
- package/dist/{FileToolModifier.utils.neutral-D_YkHwZP.mjs → FileToolModifier.utils.neutral-DWFpnsj2.mjs} +4 -2
- package/dist/{SsrfErrors-xhdVE4yw.mjs → SsrfErrors-DiQldIdC.mjs} +32 -17
- package/dist/{Telemetry-Dw9W5RSp.mjs → Telemetry-JRJJYS4I.mjs} +2 -2
- package/dist/{cancellation-P5YUlcfz.mjs → cancellation-BEpFk2S8.mjs} +7 -5
- package/dist/{composio-Cb3d1jFe.d.mts → composio-BVNJTVYa.d.mts} +2449 -118
- package/dist/{customTool.types-B6ej_8XZ.d.mts → customTool.types-CY5SXFfF.d.mts} +118 -5
- package/dist/{errors-Ue9wMrPK.mjs → errors-CvZjP9CH.mjs} +39 -4
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/{fileUtils.node-KE5Fa-af.mjs → fileUtils.node-HQsywtTj.mjs} +8 -6
- package/dist/index.d.mts +292 -140
- package/dist/index.mjs +1914 -160
- package/dist/models/Files.node.d.mts +2 -3
- package/dist/models/Files.node.mjs +2 -2
- package/dist/models/Files.workerd.d.mts +2 -3
- package/dist/platform/node.d.mts +2 -3
- package/dist/platform/workerd.d.mts +2 -3
- package/dist/{sensitiveFileUploadPaths-QN7w4n8v.mjs → sensitiveFileUploadPaths-BlLp-Yo2.mjs} +10 -7
- package/dist/{ssrfGuard.node-BLX6b-Rf.mjs → ssrfGuard.node-BK50mYTq.mjs} +94 -8
- package/dist/{types-CGdgK442.d.mts → types-CqGfjlZg.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +3 -4
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +3 -4
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +3 -4
- package/dist/utils/modifiers/FileToolModifier.node.mjs +6 -6
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +3 -4
- package/dist/utils/modifiers/FileToolModifier.workerd.mjs +1 -1
- package/dist/utils/ssrfGuard.node.d.mts +7 -7
- package/dist/utils/ssrfGuard.node.mjs +1 -1
- package/dist/utils/ssrfGuard.workerd.d.mts +3 -4
- package/dist/utils/ssrfGuard.workerd.mjs +1 -1
- package/package.json +7 -7
- package/src/composio.ts +86 -2
- package/src/errors/ConnectedAccountsErrors.ts +47 -0
- package/src/index.ts +15 -0
- package/src/models/ConnectedAccounts.ts +118 -2
- package/src/models/CustomToolkits.ts +169 -0
- package/src/models/Experimental.ts +27 -0
- package/src/models/Keyring.ts +65 -0
- package/src/models/Logs.ts +101 -0
- package/src/models/ToolRouterSession.ts +51 -0
- package/src/models/Toolkits.ts +180 -0
- package/src/models/Tools.ts +3 -1
- package/src/models/Triggers.ts +2 -87
- package/src/models/Usage.ts +119 -0
- package/src/models/Webhooks.ts +520 -0
- package/src/types/authConfigs.types.ts +2 -0
- package/src/types/connectedAccounts.types.ts +54 -0
- package/src/types/customToolkits.types.ts +102 -0
- package/src/types/keyring.types.ts +32 -0
- package/src/types/logs.types.ts +108 -0
- package/src/types/toolRouter.types.ts +49 -1
- package/src/types/toolkit.types.ts +131 -0
- package/src/types/usage.types.ts +81 -0
- package/src/types/webhooks.types.ts +143 -0
- package/src/utils/constants.ts +1 -5
- package/src/utils/jsonSchema.ts +4 -1
- package/src/utils/logger.ts +39 -7
- package/src/utils/ssrfGuard.node.ts +98 -7
- package/src/utils/transformers/connectedAccounts.ts +37 -2
- package/src/utils/transformers/customToolkits.ts +98 -0
- package/src/utils/transformers/keyring.ts +24 -0
- package/src/utils/transformers/logs.ts +85 -0
- package/src/utils/transformers/toolkits.ts +100 -1
- package/src/utils/transformers/triggers.ts +2 -2
- package/src/utils/transformers/usage.ts +77 -0
- package/src/utils/transformers/webhooks.ts +139 -0
|
@@ -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 {
|
|
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 */
|
|
@@ -18,6 +18,14 @@ export type ToolkitMangedByEnum = z.infer<typeof ToolkitMangedByEnumSchema>;
|
|
|
18
18
|
export type ToolkitSortByEnum = z.infer<typeof ToolkitSortByEnumSchema>;
|
|
19
19
|
export type ToolkitListParams = z.infer<typeof ToolkitsListParamsSchema>;
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Toolkit getMany params — the slugs to fetch plus the same filters `list`
|
|
23
|
+
* accepts.
|
|
24
|
+
*/
|
|
25
|
+
export const ToolkitGetManySlugsSchema = z.array(z.string().min(1)).min(1);
|
|
26
|
+
export const ToolkitsGetManyParamsSchema = ToolkitsListParamsSchema;
|
|
27
|
+
export type ToolkitGetManyParams = z.infer<typeof ToolkitsGetManyParamsSchema>;
|
|
28
|
+
|
|
21
29
|
/**
|
|
22
30
|
* Toolkits response
|
|
23
31
|
*/
|
|
@@ -121,6 +129,129 @@ export type ToolkitRetrieveCategoriesResponse = z.infer<
|
|
|
121
129
|
typeof ToolkitRetrieveCategoriesResponseSchema
|
|
122
130
|
>;
|
|
123
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Toolkit changelog response
|
|
134
|
+
*/
|
|
135
|
+
export const ToolkitVersionChangelogSchema = z.object({
|
|
136
|
+
version: z.string(),
|
|
137
|
+
changelog: z.string(),
|
|
138
|
+
});
|
|
139
|
+
export const ToolkitChangelogItemSchema = z.object({
|
|
140
|
+
slug: z.string(),
|
|
141
|
+
name: z.string(),
|
|
142
|
+
displayName: z.string(),
|
|
143
|
+
/** Most recent versions first; the API returns up to the last 10 per toolkit. */
|
|
144
|
+
versions: z.array(ToolkitVersionChangelogSchema),
|
|
145
|
+
});
|
|
146
|
+
export const ToolkitChangelogResponseSchema = z.object({
|
|
147
|
+
items: z.array(ToolkitChangelogItemSchema),
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
export type ToolkitVersionChangelog = z.infer<typeof ToolkitVersionChangelogSchema>;
|
|
151
|
+
export type ToolkitChangelogItem = z.infer<typeof ToolkitChangelogItemSchema>;
|
|
152
|
+
export type ToolkitChangelogResponse = z.infer<typeof ToolkitChangelogResponseSchema>;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Params for `composio.toolkits.recommendScopes()`.
|
|
156
|
+
* **Experimental — shape may change in future releases.**
|
|
157
|
+
*/
|
|
158
|
+
export const ToolkitRecommendScopesParamsSchema = z.object({
|
|
159
|
+
/** Tool slugs to cover. Pass `[]` to cover every tool in the toolkit. */
|
|
160
|
+
tools: z.array(z.string()),
|
|
161
|
+
/** Auth scheme the connection will use. The API defaults to `OAUTH2`. */
|
|
162
|
+
authScheme: AuthSchemeEnum.optional(),
|
|
163
|
+
/** Toolkit version to compute from. The API defaults to the latest published version. */
|
|
164
|
+
toolkitVersion: z.string().min(1).optional(),
|
|
165
|
+
/**
|
|
166
|
+
* Context the scopes will be granted in, as dimension → selected value,
|
|
167
|
+
* for example `{ account_type: 'Google Workspace' }`. Discover the
|
|
168
|
+
* dimensions with `composio.toolkits.listGrantContexts()`.
|
|
169
|
+
*/
|
|
170
|
+
grantContext: z.record(z.string(), z.string()).optional(),
|
|
171
|
+
/** Scopes the recommendation must include, whether or not the tools need them. */
|
|
172
|
+
include: z.array(z.string()).optional(),
|
|
173
|
+
/** Scopes the recommendation must not include; the API picks documented alternatives or fails. */
|
|
174
|
+
exclude: z.array(z.string()).optional(),
|
|
175
|
+
/** Scopes your OAuth app can request. The recommendation never goes outside this list. */
|
|
176
|
+
availableScopes: z.array(z.string()).optional(),
|
|
177
|
+
});
|
|
178
|
+
export type ToolkitRecommendScopesParams = z.infer<typeof ToolkitRecommendScopesParamsSchema>;
|
|
179
|
+
|
|
180
|
+
export const ToolkitConditionalScopeSchema = z.object({
|
|
181
|
+
/** The scope needed only when the `when` guard matches. */
|
|
182
|
+
scope: z.string(),
|
|
183
|
+
/** Input field name → qualifying values. Any value matches within a field; all fields must match. */
|
|
184
|
+
when: z.record(z.string(), z.array(z.string())),
|
|
185
|
+
/** Tool slugs that need this scope under the guard. */
|
|
186
|
+
for: z.array(z.string()),
|
|
187
|
+
});
|
|
188
|
+
export type ToolkitConditionalScope = z.infer<typeof ToolkitConditionalScopeSchema>;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Response of `composio.toolkits.recommendScopes()`.
|
|
192
|
+
* **Experimental — shape may change in future releases.**
|
|
193
|
+
*/
|
|
194
|
+
export const ToolkitRecommendScopesResponseSchema = z.object({
|
|
195
|
+
/** Auth scheme the recommendation was computed under. */
|
|
196
|
+
authScheme: z.string(),
|
|
197
|
+
/** Concrete toolkit version the answer was computed from; pass it back as `toolkitVersion` to pin. */
|
|
198
|
+
toolkitVersion: z.string(),
|
|
199
|
+
/** The effective grant context: the toolkit default overlaid with your overrides. */
|
|
200
|
+
grantContext: z.record(z.string(), z.string()),
|
|
201
|
+
scopes: z.object({
|
|
202
|
+
/** Narrowest documented option per requirement. */
|
|
203
|
+
leastPrivilege: z.array(z.string()),
|
|
204
|
+
/** Smallest scope set covering all requirements. */
|
|
205
|
+
fewest: z.array(z.string()),
|
|
206
|
+
/**
|
|
207
|
+
* Scopes needed only for particular call-time inputs. Both lists above
|
|
208
|
+
* already include them, so a caller that knows its inputs may drop the rest.
|
|
209
|
+
*/
|
|
210
|
+
conditional: z.array(ToolkitConditionalScopeSchema),
|
|
211
|
+
}),
|
|
212
|
+
});
|
|
213
|
+
export type ToolkitRecommendScopesResponse = z.infer<typeof ToolkitRecommendScopesResponseSchema>;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Params for `composio.toolkits.listGrantContexts()`.
|
|
217
|
+
* **Experimental — shape may change in future releases.**
|
|
218
|
+
*/
|
|
219
|
+
export const ToolkitListGrantContextsParamsSchema = z.object({
|
|
220
|
+
/** Auth scheme the connection will use. The API defaults to `OAUTH2`. */
|
|
221
|
+
authScheme: AuthSchemeEnum.optional(),
|
|
222
|
+
/** Toolkit version to read the scope catalog from. The API defaults to the latest published version. */
|
|
223
|
+
toolkitVersion: z.string().min(1).optional(),
|
|
224
|
+
});
|
|
225
|
+
export type ToolkitListGrantContextsParams = z.infer<typeof ToolkitListGrantContextsParamsSchema>;
|
|
226
|
+
|
|
227
|
+
export const ToolkitGrantContextDimensionSchema = z.object({
|
|
228
|
+
/** Dimension name to use as a `grantContext` key. */
|
|
229
|
+
dimension: z.string(),
|
|
230
|
+
/** What the dimension means and when to pass it. */
|
|
231
|
+
description: z.string(),
|
|
232
|
+
/** Values the dimension can take. */
|
|
233
|
+
values: z.array(z.string()),
|
|
234
|
+
});
|
|
235
|
+
export type ToolkitGrantContextDimension = z.infer<typeof ToolkitGrantContextDimensionSchema>;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Response of `composio.toolkits.listGrantContexts()`.
|
|
239
|
+
* **Experimental — shape may change in future releases.**
|
|
240
|
+
*/
|
|
241
|
+
export const ToolkitListGrantContextsResponseSchema = z.object({
|
|
242
|
+
/** Auth scheme whose scope catalog the dimensions were read from. */
|
|
243
|
+
authScheme: z.string(),
|
|
244
|
+
/** Concrete toolkit version the answer was computed from. */
|
|
245
|
+
toolkitVersion: z.string(),
|
|
246
|
+
/** Dimensions the toolkit accepts in `grantContext`; empty when no scope depends on one. */
|
|
247
|
+
grantContextDimensions: z.array(ToolkitGrantContextDimensionSchema),
|
|
248
|
+
/** The grant context assumed when you pass none. */
|
|
249
|
+
defaultGrantContext: z.record(z.string(), z.string()),
|
|
250
|
+
});
|
|
251
|
+
export type ToolkitListGrantContextsResponse = z.infer<
|
|
252
|
+
typeof ToolkitListGrantContextsResponseSchema
|
|
253
|
+
>;
|
|
254
|
+
|
|
124
255
|
export const ToolkitAuthFieldsResponseSchema = z.array(
|
|
125
256
|
ToolkitAuthFieldSchema.extend({
|
|
126
257
|
required: z.boolean().optional(),
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from 'zod/v3';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Filters shared by the usage summary and breakdown queries.
|
|
5
|
+
* **Experimental — shape may change in future releases.**
|
|
6
|
+
*/
|
|
7
|
+
export const UsageFiltersSchema = z.object({
|
|
8
|
+
/** Only count events for these external end-user IDs (OR logic). */
|
|
9
|
+
userId: z.array(z.string()).nullable().optional(),
|
|
10
|
+
/** Only count events for these session IDs (OR logic). */
|
|
11
|
+
sessionId: z.array(z.string()).nullable().optional(),
|
|
12
|
+
});
|
|
13
|
+
export type UsageFilters = z.infer<typeof UsageFiltersSchema>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Params for `composio.experimental.usage.summary()`.
|
|
17
|
+
* **Experimental — shape may change in future releases.**
|
|
18
|
+
*/
|
|
19
|
+
export const UsageSummaryParamsSchema = z.object({
|
|
20
|
+
/** Inclusive range start (Unix epoch milliseconds). Defaults to 30 days before `to`. */
|
|
21
|
+
from: z.number().optional(),
|
|
22
|
+
/** Exclusive range end (Unix epoch milliseconds). Defaults to now. */
|
|
23
|
+
to: z.number().optional(),
|
|
24
|
+
/** Restrict to these metering entity types. Omit for all types. */
|
|
25
|
+
entityTypes: z.array(z.string()).optional(),
|
|
26
|
+
filters: UsageFiltersSchema.optional(),
|
|
27
|
+
});
|
|
28
|
+
export type UsageSummaryParams = z.infer<typeof UsageSummaryParamsSchema>;
|
|
29
|
+
|
|
30
|
+
export const UsageOrderBySchema = z.enum(['key', 'total_quantity', 'event_count']);
|
|
31
|
+
export const UsageOrderDirectionSchema = z.enum(['asc', 'desc']);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Params for `composio.experimental.usage.breakdown()`.
|
|
35
|
+
* **Experimental — shape may change in future releases.**
|
|
36
|
+
*/
|
|
37
|
+
export const UsageBreakdownParamsSchema = z.object({
|
|
38
|
+
/** Inclusive range start (Unix epoch milliseconds). Defaults to 30 days before `to`. */
|
|
39
|
+
from: z.number().optional(),
|
|
40
|
+
/** Exclusive range end (Unix epoch milliseconds). Defaults to now. */
|
|
41
|
+
to: z.number().optional(),
|
|
42
|
+
/** Dimension to group by. Defaults to `tool_slug` for tool_calls and `user_id` for sessions. */
|
|
43
|
+
groupBy: z.string().optional(),
|
|
44
|
+
/** Field to order groups by. Defaults to `total_quantity`. */
|
|
45
|
+
orderBy: UsageOrderBySchema.optional(),
|
|
46
|
+
/** Sort direction. Defaults to `desc`. */
|
|
47
|
+
orderDirection: UsageOrderDirectionSchema.optional(),
|
|
48
|
+
/** Maximum number of groups to return. Defaults to 100, max 1000. */
|
|
49
|
+
limit: z.number().optional(),
|
|
50
|
+
filters: UsageFiltersSchema.optional(),
|
|
51
|
+
});
|
|
52
|
+
export type UsageBreakdownParams = z.infer<typeof UsageBreakdownParamsSchema>;
|
|
53
|
+
|
|
54
|
+
export const UsageEntitySummarySchema = z.object({
|
|
55
|
+
unit: z.string(),
|
|
56
|
+
totalQuantity: z.string(),
|
|
57
|
+
eventCount: z.number(),
|
|
58
|
+
});
|
|
59
|
+
export type UsageEntitySummary = z.infer<typeof UsageEntitySummarySchema>;
|
|
60
|
+
|
|
61
|
+
export const UsageSummaryResponseSchema = z.object({
|
|
62
|
+
/** Aggregates keyed by metering entity type (e.g. `tool_calls`, `sessions`). */
|
|
63
|
+
entities: z.record(z.string(), UsageEntitySummarySchema),
|
|
64
|
+
});
|
|
65
|
+
export type UsageSummaryResponse = z.infer<typeof UsageSummaryResponseSchema>;
|
|
66
|
+
|
|
67
|
+
export const UsageBreakdownGroupSchema = z.object({
|
|
68
|
+
key: z.string(),
|
|
69
|
+
totalQuantity: z.string(),
|
|
70
|
+
eventCount: z.number(),
|
|
71
|
+
});
|
|
72
|
+
export type UsageBreakdownGroup = z.infer<typeof UsageBreakdownGroupSchema>;
|
|
73
|
+
|
|
74
|
+
export const UsageBreakdownResponseSchema = z.object({
|
|
75
|
+
entityType: z.string(),
|
|
76
|
+
unit: z.string(),
|
|
77
|
+
totalQuantity: z.string(),
|
|
78
|
+
eventCount: z.number(),
|
|
79
|
+
groups: z.array(UsageBreakdownGroupSchema),
|
|
80
|
+
});
|
|
81
|
+
export type UsageBreakdownResponse = z.infer<typeof UsageBreakdownResponseSchema>;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { z } from 'zod/v3';
|
|
2
|
+
import { SetWebhookSubscriptionParamsSchema } from './triggers.types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Webhook payload versions accepted by the webhook subscription endpoints.
|
|
6
|
+
*/
|
|
7
|
+
export const WebhookVersionSchema = z.enum(['V1', 'V2', 'V3']);
|
|
8
|
+
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Webhook subscriptions
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A project webhook subscription in the SDK's camelCase shape. The signing
|
|
15
|
+
* `secret` is returned by the API on every subscription read/write.
|
|
16
|
+
*/
|
|
17
|
+
export const WebhookSubscriptionSchema = z.object({
|
|
18
|
+
id: z.string(),
|
|
19
|
+
webhookUrl: z.string(),
|
|
20
|
+
version: WebhookVersionSchema,
|
|
21
|
+
enabledEvents: z.array(z.string()),
|
|
22
|
+
secret: z.string().optional(),
|
|
23
|
+
createdAt: z.string().optional(),
|
|
24
|
+
updatedAt: z.string().optional(),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const WebhookSubscriptionListParamsSchema = z.object({
|
|
28
|
+
/** Number of items per page, max allowed is 50. */
|
|
29
|
+
limit: z.number().optional(),
|
|
30
|
+
/** Cursor for pagination, taken from a previous response's `nextCursor`. */
|
|
31
|
+
cursor: z.string().optional(),
|
|
32
|
+
});
|
|
33
|
+
export type WebhookSubscriptionListParams = z.infer<typeof WebhookSubscriptionListParamsSchema>;
|
|
34
|
+
|
|
35
|
+
export const WebhookSubscriptionListResponseSchema = z.object({
|
|
36
|
+
items: z.array(WebhookSubscriptionSchema),
|
|
37
|
+
nextCursor: z.string().nullable(),
|
|
38
|
+
totalPages: z.number(),
|
|
39
|
+
currentPage: z.number(),
|
|
40
|
+
totalItems: z.number(),
|
|
41
|
+
});
|
|
42
|
+
export type WebhookSubscriptionListResponse = z.infer<typeof WebhookSubscriptionListResponseSchema>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Params for `composio.webhooks.subscriptions.set()`. Identical to the
|
|
46
|
+
* params accepted by `composio.triggers.setWebhookSubscription()`.
|
|
47
|
+
*/
|
|
48
|
+
export const WebhookSubscriptionSetParamsSchema = SetWebhookSubscriptionParamsSchema;
|
|
49
|
+
export type WebhookSubscriptionSetParams = z.infer<typeof WebhookSubscriptionSetParamsSchema>;
|
|
50
|
+
|
|
51
|
+
export const WebhookSubscriptionUpdateParamsSchema = z.object({
|
|
52
|
+
/** HTTPS URL to receive webhook events. */
|
|
53
|
+
webhookUrl: z.string().min(1).optional(),
|
|
54
|
+
/** Event types to subscribe to. */
|
|
55
|
+
enabledEvents: z.array(z.string()).min(1).optional(),
|
|
56
|
+
/** Webhook payload version. */
|
|
57
|
+
version: WebhookVersionSchema.optional(),
|
|
58
|
+
});
|
|
59
|
+
export type WebhookSubscriptionUpdateParams = z.infer<typeof WebhookSubscriptionUpdateParamsSchema>;
|
|
60
|
+
|
|
61
|
+
export const WebhookSubscriptionDeleteResponseSchema = z.object({
|
|
62
|
+
success: z.boolean(),
|
|
63
|
+
});
|
|
64
|
+
export type WebhookSubscriptionDeleteResponse = z.infer<
|
|
65
|
+
typeof WebhookSubscriptionDeleteResponseSchema
|
|
66
|
+
>;
|
|
67
|
+
|
|
68
|
+
export const WebhookSubscriptionRotateSecretResponseSchema = z.object({
|
|
69
|
+
id: z.string(),
|
|
70
|
+
/** The new signing secret. Store it — the previous secret stops validating. */
|
|
71
|
+
secret: z.string(),
|
|
72
|
+
});
|
|
73
|
+
export type WebhookSubscriptionRotateSecretResponse = z.infer<
|
|
74
|
+
typeof WebhookSubscriptionRotateSecretResponseSchema
|
|
75
|
+
>;
|
|
76
|
+
|
|
77
|
+
export const WebhookSubscriptionEventTypeSchema = z.object({
|
|
78
|
+
eventType: z.string(),
|
|
79
|
+
description: z.string(),
|
|
80
|
+
supportedVersions: z.array(WebhookVersionSchema),
|
|
81
|
+
});
|
|
82
|
+
export type WebhookSubscriptionEventType = z.infer<typeof WebhookSubscriptionEventTypeSchema>;
|
|
83
|
+
|
|
84
|
+
export const WebhookSubscriptionEventTypesResponseSchema = z.object({
|
|
85
|
+
items: z.array(WebhookSubscriptionEventTypeSchema),
|
|
86
|
+
});
|
|
87
|
+
export type WebhookSubscriptionEventTypesResponse = z.infer<
|
|
88
|
+
typeof WebhookSubscriptionEventTypesResponseSchema
|
|
89
|
+
>;
|
|
90
|
+
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
// Webhook endpoints (per toolkit + OAuth app inbound ingress URLs)
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
94
|
+
|
|
95
|
+
export const WebhookEndpointListParamsSchema = z.object({
|
|
96
|
+
/** Only return endpoints for this toolkit slug. */
|
|
97
|
+
toolkitSlug: z.string().optional(),
|
|
98
|
+
});
|
|
99
|
+
export type WebhookEndpointListParams = z.infer<typeof WebhookEndpointListParamsSchema>;
|
|
100
|
+
|
|
101
|
+
export const WebhookEndpointListItemSchema = z.object({
|
|
102
|
+
id: z.string(),
|
|
103
|
+
toolkitSlug: z.string(),
|
|
104
|
+
clientId: z.string().nullable(),
|
|
105
|
+
});
|
|
106
|
+
export type WebhookEndpointListItem = z.infer<typeof WebhookEndpointListItemSchema>;
|
|
107
|
+
|
|
108
|
+
export const WebhookEndpointListResponseSchema = z.object({
|
|
109
|
+
items: z.array(WebhookEndpointListItemSchema),
|
|
110
|
+
});
|
|
111
|
+
export type WebhookEndpointListResponse = z.infer<typeof WebhookEndpointListResponseSchema>;
|
|
112
|
+
|
|
113
|
+
export const WebhookEndpointSchema = z.object({
|
|
114
|
+
id: z.string(),
|
|
115
|
+
toolkitSlug: z.string(),
|
|
116
|
+
clientId: z.string().nullable(),
|
|
117
|
+
/** The inbound URL to register with the third-party provider. */
|
|
118
|
+
webhookUrl: z.string(),
|
|
119
|
+
/** Configured setup fields with secret values masked. */
|
|
120
|
+
data: z.record(z.string(), z.string()).nullable(),
|
|
121
|
+
createdAt: z.string(),
|
|
122
|
+
});
|
|
123
|
+
export type WebhookEndpoint = z.infer<typeof WebhookEndpointSchema>;
|
|
124
|
+
|
|
125
|
+
export const WebhookEndpointCreateParamsSchema = z.object({
|
|
126
|
+
/** Toolkit identifier (e.g. `slack`, `discord`). */
|
|
127
|
+
toolkitSlug: z.string().min(1),
|
|
128
|
+
/** OAuth app client ID — identifies which app this endpoint is for. */
|
|
129
|
+
clientId: z.string().min(1),
|
|
130
|
+
});
|
|
131
|
+
export type WebhookEndpointCreateParams = z.infer<typeof WebhookEndpointCreateParamsSchema>;
|
|
132
|
+
|
|
133
|
+
export const WebhookEndpointReplaceParamsSchema = z.object({
|
|
134
|
+
/** Key-value pairs for ALL required setup fields of the toolkit. */
|
|
135
|
+
data: z.record(z.string(), z.string()),
|
|
136
|
+
});
|
|
137
|
+
export type WebhookEndpointReplaceParams = z.infer<typeof WebhookEndpointReplaceParamsSchema>;
|
|
138
|
+
|
|
139
|
+
export const WebhookEndpointUpdateParamsSchema = z.object({
|
|
140
|
+
/** Key-value pairs to merge into the setup fields. Omitted fields are preserved. */
|
|
141
|
+
data: z.record(z.string(), z.string()),
|
|
142
|
+
});
|
|
143
|
+
export type WebhookEndpointUpdateParams = z.infer<typeof WebhookEndpointUpdateParamsSchema>;
|
package/src/utils/constants.ts
CHANGED
|
@@ -11,11 +11,7 @@ export const TELEMETRY_URL = 'https://app.composio.dev';
|
|
|
11
11
|
export const CLIENT_PUSHER_KEY = getEnvVariable('CLIENT_PUSHER_KEY') || 'ff9f18c208855d77a152';
|
|
12
12
|
|
|
13
13
|
export const COMPOSIO_LOG_LEVEL = getEnvVariable('COMPOSIO_LOG_LEVEL') as
|
|
14
|
-
| 'debug'
|
|
15
|
-
| 'info'
|
|
16
|
-
| 'warn'
|
|
17
|
-
| 'error'
|
|
18
|
-
| undefined;
|
|
14
|
+
'silent' | 'debug' | 'info' | 'warn' | 'error' | undefined;
|
|
19
15
|
|
|
20
16
|
export const IS_DEVELOPMENT_OR_CI = getEnvVariable('DEVELOPMENT') || getEnvVariable('CI') || false;
|
|
21
17
|
|
package/src/utils/jsonSchema.ts
CHANGED
|
@@ -495,7 +495,10 @@ export function jsonSchemaToZodSchema<T extends z.ZodTypeAny>(
|
|
|
495
495
|
const zodSchema = jsonSchemaToZod(schema) as T;
|
|
496
496
|
return zodSchema;
|
|
497
497
|
} catch (error) {
|
|
498
|
-
|
|
498
|
+
// The cause names the offending property path; surface it in the message
|
|
499
|
+
// so a single malformed property is identifiable without unwrapping.
|
|
500
|
+
const detail = error instanceof Error ? `: ${error.message}` : '';
|
|
501
|
+
throw new JsonSchemaToZodError(`Failed to convert JSON Schema to Zod Schema${detail}`, {
|
|
499
502
|
cause: error,
|
|
500
503
|
});
|
|
501
504
|
}
|