@composio/core 0.25.0 → 0.26.0
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-DZY1yLHN.d.mts → CustomTool-DfP4ldQl.d.mts} +1 -1
- package/dist/{cancellation-D-tMPk48.mjs → cancellation-ZoRh6EJQ.mjs} +54 -2
- package/dist/{composio-B8AENilE.d.mts → composio-BMDH-1Qj.d.mts} +19 -11
- package/dist/{customTool.types-Bi6-keZC.d.mts → customTool.types-BoOELgJF.d.mts} +20 -20
- package/dist/experimental/index.d.mts +2 -2
- package/dist/index.d.mts +11 -6
- package/dist/index.mjs +400 -61
- package/dist/{types-BGDMkEUl.d.mts → types-DHNV_T_z.d.mts} +2 -2
- package/dist/utils/config-defaults/ConfigDefaults.node.d.mts +1 -1
- package/dist/utils/config-defaults/ConfigDefaults.workerd.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.d.mts +1 -1
- package/dist/utils/modifiers/FileToolModifier.node.mjs +1 -1
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/package.json +3 -3
- package/src/composio.ts +68 -57
- package/src/lib/toolRouterMcp.ts +2 -0
- package/src/models/ConnectedAccounts.ts +7 -16
- package/src/models/ToolRouter.ts +3 -1
- package/src/models/Tools.ts +1 -4
- package/src/models/Triggers.ts +6 -1
- package/src/services/internal/InternalService.ts +3 -4
- package/src/services/pusher/Pusher.ts +11 -4
- package/src/types/connectedAccountAuthStates.types.ts +2 -1
- package/src/types/requestOptions.types.ts +1 -10
- package/src/types/toolRouter.types.ts +1 -1
- package/src/utils/jsonSchema.ts +76 -4
- package/src/utils/sdk.ts +172 -11
- package/src/utils/toolkitDeprecation.ts +271 -0
- package/src/utils/transformers/connectedAccounts.ts +9 -20
- package/src/utils/transformers/mcp.ts +3 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Aa as ToolExecuteParams, Da as Tool, Ma as ToolExecuteResponse } from "../../customTool.types-
|
|
1
|
+
import { Aa as ToolExecuteParams, Da as Tool, Ma as ToolExecuteResponse } from "../../customTool.types-BoOELgJF.mjs";
|
|
2
2
|
import ComposioClient from "@composio/client";
|
|
3
3
|
//#region src/utils/modifiers/FileToolModifier.node.d.ts
|
|
4
4
|
export declare class FileToolModifier {
|
|
@@ -2,7 +2,7 @@ import { i as logger } from "../../SsrfErrors-DiQldIdC.mjs";
|
|
|
2
2
|
import { _ as ComposioRequestCancelledError } from "../../errors-Cly0vXFh.mjs";
|
|
3
3
|
import { a as ComposioSensitiveFilePathBlockedError, i as ComposioFileUploadPathNotAllowedError, n as ComposioFileUploadAbortedError, r as ComposioFileUploadError, t as ComposioFileNotFoundError } from "../../FileModifierErrors-CdGSABoq.mjs";
|
|
4
4
|
import { a as isEmptyFileValue, c as transformProperties, i as getSchemaVariants, l as walkFileUploadableLeaves, o as isPlainObject, r as findSchemaVariantWithFileProperty, t as DELETE_VALUE } from "../../FileToolModifier.utils.neutral-DWFpnsj2.mjs";
|
|
5
|
-
import { r as dereferenceJsonSchema, t as withCancellation } from "../../cancellation-
|
|
5
|
+
import { r as dereferenceJsonSchema, t as withCancellation } from "../../cancellation-ZoRh6EJQ.mjs";
|
|
6
6
|
import { n as getFileDataAfterUploadingToS3, r as isHttpUrl, t as downloadFileFromS3 } from "../../fileUtils.node-DNLhLg0W.mjs";
|
|
7
7
|
|
|
8
8
|
//#region src/utils/modifiers/FileToolModifier.node.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Aa as ToolExecuteParams, Da as Tool, Ma as ToolExecuteResponse } from "../../customTool.types-
|
|
1
|
+
import { Aa as ToolExecuteParams, Da as Tool, Ma as ToolExecuteResponse } from "../../customTool.types-BoOELgJF.mjs";
|
|
2
2
|
import ComposioClient from "@composio/client";
|
|
3
3
|
//#region src/utils/modifiers/FileToolModifier.workerd.d.ts
|
|
4
4
|
export declare class FileToolModifier {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=22.22.3"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.26.0",
|
|
8
8
|
"description": "",
|
|
9
9
|
"main": "dist/index.mjs",
|
|
10
10
|
"publishConfig": {
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"zod": ">=3.25.76 <5"
|
|
129
129
|
},
|
|
130
130
|
"dependencies": {
|
|
131
|
-
"@composio/client": "2.0.0-rc.
|
|
131
|
+
"@composio/client": "2.0.0-rc.19",
|
|
132
132
|
"@types/json-schema": "^7.0.15",
|
|
133
133
|
"is-fs-case-sensitive": "^2.0.0",
|
|
134
134
|
"openai": "^7.32.0",
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
"semver": "^7.8.5",
|
|
138
138
|
"undici": "^7.30.0",
|
|
139
139
|
"zod-to-json-schema": "^3.25.2",
|
|
140
|
-
"@composio/json-schema-to-zod": "0.
|
|
140
|
+
"@composio/json-schema-to-zod": "0.4.0"
|
|
141
141
|
},
|
|
142
142
|
"gitHead": "4fae6e54d5c150fba955cc5fa314281da5a1e064",
|
|
143
143
|
"repository": {
|
package/src/composio.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { getEnvVariable } from './utils/env';
|
|
1
2
|
import type { BaseComposioProvider } from './provider/BaseProvider';
|
|
2
|
-
import ComposioClient from '@composio/client';
|
|
3
|
-
import type {
|
|
3
|
+
import ComposioClient, { createFetchTransport } from '@composio/client';
|
|
4
|
+
import type { LogLevel as ClientLogLevel } from '@composio/client';
|
|
4
5
|
import { Tools } from './models/Tools';
|
|
5
6
|
import { Toolkits } from './models/Toolkits';
|
|
6
7
|
import { Triggers } from './models/Triggers';
|
|
@@ -14,13 +15,13 @@ import { SessionConfigs } from './models/SessionConfigs';
|
|
|
14
15
|
import { Keyring } from './models/Keyring';
|
|
15
16
|
import { telemetry } from './telemetry/Telemetry';
|
|
16
17
|
import {
|
|
17
|
-
getScopeHeaders,
|
|
18
18
|
getSDKConfig,
|
|
19
19
|
getToolkitVersionsFromEnv,
|
|
20
|
-
|
|
20
|
+
resolveSDKCredentials,
|
|
21
21
|
resolveSDKScope,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
toClientAuth,
|
|
23
|
+
toClientScope,
|
|
24
|
+
withoutSDKOwnedHeaders,
|
|
24
25
|
} from './utils/sdk';
|
|
25
26
|
import logger from './utils/logger';
|
|
26
27
|
import type { ComposioLogger, LogLevel } from './utils/logger';
|
|
@@ -37,6 +38,7 @@ import { ToolRouter } from './models/ToolRouter';
|
|
|
37
38
|
import { Sessions } from './models/Sessions';
|
|
38
39
|
import { CONFIG_DEFAULTS } from './utils/config-defaults';
|
|
39
40
|
import { expandHomeAndResolve, expandHomeAndResolveMany } from './utils/fileDirs';
|
|
41
|
+
import { createToolkitDeprecationFetch } from './utils/toolkitDeprecation';
|
|
40
42
|
export type ComposioConfig<
|
|
41
43
|
TProvider extends BaseComposioProvider<unknown, unknown, unknown> = OpenAIProvider,
|
|
42
44
|
> = {
|
|
@@ -49,8 +51,10 @@ export type ComposioConfig<
|
|
|
49
51
|
* project key; the SDK throws instead of sending it.
|
|
50
52
|
* - `null`: disables project-key authentication entirely, including both fallbacks. The SDK
|
|
51
53
|
* then requires another credential (`userApiKey`, `orgApiKey`, or an `x-user-api-key`
|
|
52
|
-
* entry in `defaultHeaders`) and sends no `x-api-key`; an `x-api-key` entry in
|
|
53
|
-
* `defaultHeaders` is rejected, also on `createSession()` clones.
|
|
54
|
+
* or `x-org-api-key` entry in `defaultHeaders`) and sends no `x-api-key`; an `x-api-key` entry in
|
|
55
|
+
* `defaultHeaders` is rejected, also on `createSession()` clones. The user API key
|
|
56
|
+
* then authenticates every request; the organization API key does when it is the
|
|
57
|
+
* only credential held.
|
|
54
58
|
*
|
|
55
59
|
* @example 'ak_1234567890'
|
|
56
60
|
*/
|
|
@@ -71,7 +75,8 @@ export type ComposioConfig<
|
|
|
71
75
|
* Sent as `x-org-api-key` only on operations whose security scheme accepts
|
|
72
76
|
* it, never alongside the project key. Falls back to
|
|
73
77
|
* `process.env['COMPOSIO_ORG_API_KEY']`; `null` disables that fallback.
|
|
74
|
-
* Combine with `apiKey: null`
|
|
78
|
+
* Combine with `apiKey: null` (and no user API key) to authenticate every
|
|
79
|
+
* request with the organization key alone.
|
|
75
80
|
* @example 'oak_1234567890'
|
|
76
81
|
*/
|
|
77
82
|
orgApiKey?: string | null;
|
|
@@ -168,10 +173,14 @@ export type ComposioConfig<
|
|
|
168
173
|
/**
|
|
169
174
|
* Default headers attached to every request made through this instance.
|
|
170
175
|
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
176
|
+
* Credential and scope headers are not forwarded as headers: the SDK folds
|
|
177
|
+
* them into its own options, which `getConfig()` then reports.
|
|
178
|
+
* A non-empty `x-user-api-key` (or `x-org-api-key`) entry becomes the
|
|
179
|
+
* credential every request carries, in place of the configured keys; together
|
|
180
|
+
* with `apiKey: null` it authenticates with that key instead of a project key.
|
|
181
|
+
* An `x-api-key` entry replaces the project key, and is rejected when `apiKey`
|
|
182
|
+
* is `null`. At most one of the three may be set. `x-org-id` / `x-project-id`
|
|
183
|
+
* entries supply `orgId` / `projectId`.
|
|
175
184
|
*
|
|
176
185
|
* The SDK reports itself through the API client's identity headers
|
|
177
186
|
* (`x-client-provenance`, `x-client-version`, `x-client-library`,
|
|
@@ -291,11 +300,11 @@ const toClientLogLevel = (level: LogLevel): ClientLogLevel => {
|
|
|
291
300
|
* at call time so a later `logger.configure()` is honoured. The client's
|
|
292
301
|
* `info` records (per-request lifecycle) are forwarded as SDK `debug`.
|
|
293
302
|
*/
|
|
294
|
-
const
|
|
295
|
-
error: (...args) => logger.error(...args),
|
|
296
|
-
warn: (...args) => logger.warn(...args),
|
|
297
|
-
info: (...args) => logger.debug(...args),
|
|
298
|
-
debug: (...args) => logger.debug(...args),
|
|
303
|
+
const clientLogForwarder: Pick<Console, 'debug' | 'info' | 'warn' | 'error'> = {
|
|
304
|
+
error: (...args: unknown[]) => logger.error(...args),
|
|
305
|
+
warn: (...args: unknown[]) => logger.warn(...args),
|
|
306
|
+
info: (...args: unknown[]) => logger.debug(...args),
|
|
307
|
+
debug: (...args: unknown[]) => logger.debug(...args),
|
|
299
308
|
};
|
|
300
309
|
|
|
301
310
|
/**
|
|
@@ -472,16 +481,20 @@ export class Composio<
|
|
|
472
481
|
}
|
|
473
482
|
);
|
|
474
483
|
|
|
475
|
-
// The
|
|
476
|
-
//
|
|
477
|
-
// the
|
|
478
|
-
//
|
|
479
|
-
//
|
|
480
|
-
const
|
|
481
|
-
|
|
482
|
-
userApiKey
|
|
483
|
-
|
|
484
|
-
|
|
484
|
+
// The SDK owns the credential: it resolves the keys (with their
|
|
485
|
+
// environment fallbacks) and folds a credential default header into them,
|
|
486
|
+
// so the API client receives one `auth` and never a credential header.
|
|
487
|
+
// The resolved keys are stored on the config, so clones, the MCP export
|
|
488
|
+
// and trigger subscriptions read the same values.
|
|
489
|
+
const credentials = resolveSDKCredentials({
|
|
490
|
+
apiKey: apiKeyParsed,
|
|
491
|
+
userApiKey: config?.userApiKey,
|
|
492
|
+
orgApiKey: config?.orgApiKey,
|
|
493
|
+
defaultHeaders: config?.defaultHeaders,
|
|
494
|
+
});
|
|
495
|
+
// Credential and scope entries travel as `auth` and `scope`; the client
|
|
496
|
+
// refuses them in `defaultHeaders`.
|
|
497
|
+
const defaultHeaders = withoutSDKOwnedHeaders(config?.defaultHeaders);
|
|
485
498
|
|
|
486
499
|
if (config?.logger !== undefined || config?.logLevel !== undefined) {
|
|
487
500
|
logger.configure({ level: config.logLevel, sink: config.logger });
|
|
@@ -503,8 +516,10 @@ export class Composio<
|
|
|
503
516
|
this.config = {
|
|
504
517
|
...config,
|
|
505
518
|
baseURL: baseURLParsed,
|
|
506
|
-
apiKey:
|
|
507
|
-
|
|
519
|
+
apiKey: credentials.apiKey,
|
|
520
|
+
userApiKey: credentials.userApiKey,
|
|
521
|
+
orgApiKey: credentials.orgApiKey,
|
|
522
|
+
defaultHeaders,
|
|
508
523
|
toolkitVersions: getToolkitVersionsFromEnv(config?.toolkitVersions),
|
|
509
524
|
allowTracking: config?.allowTracking ?? CONFIG_DEFAULTS.allowTracking,
|
|
510
525
|
dangerouslyAllowAutoUploadDownloadFiles:
|
|
@@ -519,32 +534,33 @@ export class Composio<
|
|
|
519
534
|
projectId: scope.projectId,
|
|
520
535
|
};
|
|
521
536
|
|
|
522
|
-
// The resolved scope is the single source of the x-org-id / x-project-id
|
|
523
|
-
// headers: it travels via `this.config` to clones and to the MCP export.
|
|
524
|
-
const defaultHeaders = { ...this.config.defaultHeaders, ...getScopeHeaders(scope) };
|
|
525
|
-
|
|
526
537
|
/**
|
|
527
538
|
* Initialize the Composio SDK client.
|
|
528
539
|
* The client is used to make API calls to the Composio API. It sends the
|
|
529
|
-
*
|
|
540
|
+
* credential from `auth`, the resolved org/project scope from `scope`, and
|
|
541
|
+
* the SDK's identity headers from `identity`, and refuses all three in
|
|
542
|
+
* `defaultHeaders`.
|
|
530
543
|
*/
|
|
531
544
|
this.client = new ComposioClient({
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
orgApiKey: config?.orgApiKey,
|
|
545
|
+
auth: toClientAuth(credentials),
|
|
546
|
+
scope: toClientScope(scope),
|
|
535
547
|
baseURL: baseURLParsed,
|
|
536
|
-
|
|
548
|
+
// The client stopped reading the process environment in rc.18; this
|
|
549
|
+
// opt-in for a plain-HTTP development origin is the one setting of its
|
|
550
|
+
// own that core forwards.
|
|
551
|
+
...(getEnvVariable('COMPOSIO_ALLOW_INSECURE_HTTP') === '1'
|
|
552
|
+
? { allowInsecureHTTP: true }
|
|
553
|
+
: {}),
|
|
554
|
+
defaultHeaders,
|
|
537
555
|
identity: getClientIdentity(this.provider),
|
|
538
|
-
logger:
|
|
556
|
+
logger: clientLogForwarder,
|
|
539
557
|
logLevel: toClientLogLevel(logger.getLevel()),
|
|
558
|
+
// Warns once per deprecated toolkit version reported through the
|
|
559
|
+
// `Composio-Deprecated-Toolkits` response header. `createSession()`
|
|
560
|
+
// clones go through this same constructor and inherit it.
|
|
561
|
+
transport: createFetchTransport({ fetch: createToolkitDeprecationFetch() }),
|
|
540
562
|
});
|
|
541
563
|
|
|
542
|
-
// Store the resolved values, as with `apiKey`, so `getConfig()` and the
|
|
543
|
-
// `createSession()` clone carry whatever the client resolved from env
|
|
544
|
-
// rather than re-reading the environment later.
|
|
545
|
-
this.config.userApiKey = this.client.userApiKey;
|
|
546
|
-
this.config.orgApiKey = this.client.orgApiKey;
|
|
547
|
-
|
|
548
564
|
this.tools = new Tools(this.client, this.config);
|
|
549
565
|
this.mcp = new MCP(this.client);
|
|
550
566
|
this.toolkits = new Toolkits(this.client);
|
|
@@ -579,7 +595,7 @@ export class Composio<
|
|
|
579
595
|
*/
|
|
580
596
|
if (this.config.allowTracking) {
|
|
581
597
|
telemetry.setup({
|
|
582
|
-
apiKey:
|
|
598
|
+
apiKey: credentials.apiKey ?? '',
|
|
583
599
|
baseUrl: baseURLParsed ?? '',
|
|
584
600
|
isAgentic: this.provider?._isAgentic || false,
|
|
585
601
|
version: version,
|
|
@@ -669,18 +685,13 @@ export class Composio<
|
|
|
669
685
|
* ```
|
|
670
686
|
*/
|
|
671
687
|
createSession(options?: { headers?: ComposioRequestHeaders }): Composio<TProvider> {
|
|
672
|
-
// The clone inherits the resolved credentials
|
|
673
|
-
//
|
|
674
|
-
//
|
|
675
|
-
|
|
676
|
-
? undefined
|
|
677
|
-
: getUserApiKeyHeader(this.config.defaultHeaders);
|
|
678
|
-
const sessionHeaders = userApiKeyHeader
|
|
679
|
-
? { [userApiKeyHeader.name]: userApiKeyHeader.value, ...options?.headers }
|
|
680
|
-
: options?.headers;
|
|
688
|
+
// The clone inherits the resolved credentials and scope through
|
|
689
|
+
// `this.config`, where a credential or scope default header has already
|
|
690
|
+
// been folded in; `headers` replaces the default headers, and a
|
|
691
|
+
// credential or scope header in it is folded in the same way.
|
|
681
692
|
return new Composio({
|
|
682
693
|
...this.config,
|
|
683
|
-
defaultHeaders:
|
|
694
|
+
defaultHeaders: options?.headers,
|
|
684
695
|
});
|
|
685
696
|
}
|
|
686
697
|
|
package/src/lib/toolRouterMcp.ts
CHANGED
|
@@ -71,6 +71,8 @@ export type MCPServerConfigInput = {
|
|
|
71
71
|
apiKey: string | null | undefined;
|
|
72
72
|
/** The user API key the client resolved (`userApiKey` option or `COMPOSIO_USER_API_KEY`). */
|
|
73
73
|
userApiKey: string | null | undefined;
|
|
74
|
+
/** The organization API key the client resolved (`orgApiKey` option or `COMPOSIO_ORG_API_KEY`). */
|
|
75
|
+
orgApiKey?: string | null;
|
|
74
76
|
/** The default headers configured on the SDK instance; only `x-user-api-key` is consulted. */
|
|
75
77
|
defaultHeaders: ComposioRequestHeaders | undefined;
|
|
76
78
|
/** Organization nano ID the instance is scoped to, if any. */
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @module ConnectedAccounts
|
|
7
7
|
*/
|
|
8
8
|
import ComposioClient, { BadRequestError, ConflictError } from '@composio/client';
|
|
9
|
+
import type { APIPromise } from '@composio/client';
|
|
9
10
|
import {
|
|
10
11
|
ConnectedAccountCreateResponse,
|
|
11
12
|
ConnectedAccountDeleteResponse,
|
|
@@ -126,11 +127,7 @@ export class ConnectedAccounts {
|
|
|
126
127
|
cursor: parsedQuery.data.cursor?.toString(),
|
|
127
128
|
limit: parsedQuery.data.limit,
|
|
128
129
|
order_by: parsedQuery.data.orderBy,
|
|
129
|
-
|
|
130
|
-
// lag behind the live API enum. Apollo accepts the union value at
|
|
131
|
-
// runtime (`z.nativeEnum(ConnectionStatusEnum)` on the query param);
|
|
132
|
-
// remove the cast once `@composio/client` is regenerated.
|
|
133
|
-
statuses: parsedQuery.data.statuses as ConnectedAccountListParamsRaw['statuses'],
|
|
130
|
+
statuses: parsedQuery.data.statuses,
|
|
134
131
|
toolkit_slugs: parsedQuery.data.toolkitSlugs,
|
|
135
132
|
user_ids: parsedQuery.data.userIds,
|
|
136
133
|
...(parsedQuery.data.accountType !== undefined && {
|
|
@@ -271,18 +268,12 @@ export class ConnectedAccounts {
|
|
|
271
268
|
// caller needs to migrate. Custom auth configs and non-OAuth schemes
|
|
272
269
|
// never see the header, eliminating the false-positive warning that
|
|
273
270
|
// an `auth_scheme`-only check produced for `link()`-unaffected callers.
|
|
274
|
-
const apiCall =
|
|
275
|
-
|
|
271
|
+
const apiCall: APIPromise<ConnectedAccountCreateResponse> =
|
|
272
|
+
this.client.connectedAccounts.create(createParams, requestOptions);
|
|
273
|
+
// Checked at runtime: test mocks may return a plain Promise.
|
|
274
|
+
if (typeof apiCall.withResponse === 'function') {
|
|
276
275
|
const resolved = await withCancellation(
|
|
277
|
-
() =>
|
|
278
|
-
(
|
|
279
|
-
apiCall as unknown as {
|
|
280
|
-
withResponse: () => Promise<{
|
|
281
|
-
data: ConnectedAccountCreateResponse;
|
|
282
|
-
response: Response;
|
|
283
|
-
}>;
|
|
284
|
-
}
|
|
285
|
-
).withResponse(),
|
|
276
|
+
() => apiCall.withResponse(),
|
|
286
277
|
requestOptions?.signal
|
|
287
278
|
);
|
|
288
279
|
response = resolved.data;
|
package/src/models/ToolRouter.ts
CHANGED
|
@@ -139,7 +139,8 @@ export class ToolRouter<
|
|
|
139
139
|
/**
|
|
140
140
|
* Derives the MCP config for a session from the auth context the session
|
|
141
141
|
* request was made with: the project key when one is configured, otherwise
|
|
142
|
-
* the resolved user API key,
|
|
142
|
+
* the resolved user API key, otherwise the organization API key, plus the
|
|
143
|
+
* org/project scope when configured.
|
|
143
144
|
* Headers are only attached when the MCP URL shares the client's API
|
|
144
145
|
* origin. Any other destination throws when the caller passed `mcp: true`
|
|
145
146
|
* and otherwise yields empty headers plus a warning; see
|
|
@@ -155,6 +156,7 @@ export class ToolRouter<
|
|
|
155
156
|
apiBaseURL: this.client.baseURL,
|
|
156
157
|
apiKey: this.config?.apiKey,
|
|
157
158
|
userApiKey: this.config?.userApiKey,
|
|
159
|
+
orgApiKey: this.config?.orgApiKey,
|
|
158
160
|
defaultHeaders: this.config?.defaultHeaders,
|
|
159
161
|
orgId: this.config?.orgId,
|
|
160
162
|
projectId: this.config?.projectId,
|
package/src/models/Tools.ts
CHANGED
|
@@ -992,8 +992,7 @@ export class Tools<
|
|
|
992
992
|
* @deprecated The `customConnectionData` execute param is deprecated and will be
|
|
993
993
|
* removed in a future release. Use `customAuthParams` instead.
|
|
994
994
|
*/
|
|
995
|
-
custom_connection_data:
|
|
996
|
-
body.customConnectionData as ComposioToolExecuteParams['custom_connection_data'],
|
|
995
|
+
custom_connection_data: body.customConnectionData,
|
|
997
996
|
arguments: body.arguments,
|
|
998
997
|
user_id: body.userId,
|
|
999
998
|
version: toolkitVersion,
|
|
@@ -1390,8 +1389,6 @@ export class Tools<
|
|
|
1390
1389
|
* @deprecated The `customConnectionData` proxy param is deprecated and will be
|
|
1391
1390
|
* removed in a future release. Use `customAuthParams` instead.
|
|
1392
1391
|
*/
|
|
1393
|
-
// oxlint-disable-next-line typescript/ban-ts-comment -- generated client versions disagree about this deprecated field
|
|
1394
|
-
// @ts-ignore
|
|
1395
1392
|
custom_connection_data: toolProxyParams.data.customConnectionData,
|
|
1396
1393
|
} as ComposioToolProxyParams;
|
|
1397
1394
|
return withCancellation(
|
package/src/models/Triggers.ts
CHANGED
|
@@ -158,7 +158,12 @@ export class Triggers<TProvider extends BaseComposioProvider<unknown, unknown, u
|
|
|
158
158
|
|
|
159
159
|
constructor(client: ComposioClient, config?: ComposioConfig<TProvider>) {
|
|
160
160
|
this.client = client;
|
|
161
|
-
this.pusherService = new PusherService(client, {
|
|
161
|
+
this.pusherService = new PusherService(client, {
|
|
162
|
+
apiKey: config?.apiKey,
|
|
163
|
+
userApiKey: config?.userApiKey,
|
|
164
|
+
orgApiKey: config?.orgApiKey,
|
|
165
|
+
defaultHeaders: config?.defaultHeaders,
|
|
166
|
+
});
|
|
162
167
|
this.toolkitVersions = config?.toolkitVersions ?? CONFIG_DEFAULTS.toolkitVersions;
|
|
163
168
|
telemetry.instrument(this, 'Triggers');
|
|
164
169
|
}
|
|
@@ -24,10 +24,9 @@ export class InternalService {
|
|
|
24
24
|
* @returns {SDKRealtimeCredentialsResponse} The SDK realtime credentials
|
|
25
25
|
*/
|
|
26
26
|
async getSDKRealtimeCredentials(): Promise<SDKRealtimeCredentialsResponse> {
|
|
27
|
-
const response = await this.client.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
27
|
+
const response = await this.client.get<ComposioSDKRealtimeCredentialsResponse>(
|
|
28
|
+
SDK_REALTIME_CREDENTIALS_ENDPOINT
|
|
29
|
+
);
|
|
31
30
|
|
|
32
31
|
const parsedResponse = SDKRealtimeCredentialsResponseSchema.safeParse({
|
|
33
32
|
pusherKey: response.pusher_key,
|
|
@@ -14,6 +14,12 @@ import { resolveCredentialHeaders } from '../../utils/sdk';
|
|
|
14
14
|
import type { ComposioRequestHeaders } from '../../types/composio.types';
|
|
15
15
|
|
|
16
16
|
export type PusherServiceOptions = {
|
|
17
|
+
/** The project API key the owning SDK instance resolved, or `null` when disabled. */
|
|
18
|
+
apiKey?: string | null;
|
|
19
|
+
/** The user API key the owning SDK instance resolved, or `null`. */
|
|
20
|
+
userApiKey?: string | null;
|
|
21
|
+
/** The organization API key the owning SDK instance resolved, or `null`. */
|
|
22
|
+
orgApiKey?: string | null;
|
|
17
23
|
/** Default headers of the owning SDK instance; only `x-user-api-key` is consulted. */
|
|
18
24
|
defaultHeaders?: ComposioRequestHeaders;
|
|
19
25
|
};
|
|
@@ -57,11 +63,12 @@ export class PusherService {
|
|
|
57
63
|
constructor(client: ComposioClient, options: PusherServiceOptions = {}) {
|
|
58
64
|
this.composioClient = client;
|
|
59
65
|
this.pusherBaseURL = client.baseURL;
|
|
60
|
-
// Channel authorization mirrors the
|
|
61
|
-
// environment is never consulted here.
|
|
66
|
+
// Channel authorization mirrors the SDK instance's effective auth, from the
|
|
67
|
+
// keys the SDK resolved; the environment is never consulted here.
|
|
62
68
|
this.authHeaders = resolveCredentialHeaders({
|
|
63
|
-
apiKey:
|
|
64
|
-
userApiKey:
|
|
69
|
+
apiKey: options.apiKey,
|
|
70
|
+
userApiKey: options.userApiKey,
|
|
71
|
+
orgApiKey: options.orgApiKey,
|
|
65
72
|
defaultHeaders: options.defaultHeaders,
|
|
66
73
|
});
|
|
67
74
|
telemetry.instrument(this, 'PusherService');
|
|
@@ -222,7 +222,8 @@ const S2SOauth2ConnectionDataSchema = z.discriminatedUnion('status', [
|
|
|
222
222
|
}).catchall(z.unknown()),
|
|
223
223
|
]);
|
|
224
224
|
const CustomS2SOauth2ConnectionDataSchema = BaseSchemeRaw.extend({
|
|
225
|
-
|
|
225
|
+
// Required by the API: custom connection data supplies the token itself.
|
|
226
|
+
access_token: z.string(),
|
|
226
227
|
id_token: z.string().optional(),
|
|
227
228
|
token_type: z.string().optional(),
|
|
228
229
|
refresh_token: z.string().nullish().optional(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { RequestOptions as ClientRequestOptions } from '@composio/client';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Per-request transport options for cancelling an SDK call.
|
|
@@ -38,15 +38,6 @@ export type ComposioRequestOptions = {
|
|
|
38
38
|
signal?: AbortSignal;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
/**
|
|
42
|
-
* The `@composio/client` per-request transport options, reached via a public
|
|
43
|
-
* method whose only parameter is that type (`tools.retrieveEnum`). The
|
|
44
|
-
* `internal/*` subpath that declares `RequestOptions` is not in the package's
|
|
45
|
-
* `exports`, so we derive it structurally instead of deep-importing it.
|
|
46
|
-
* @internal
|
|
47
|
-
*/
|
|
48
|
-
type ClientRequestOptions = NonNullable<Parameters<ComposioClient['tools']['retrieveEnum']>[0]>;
|
|
49
|
-
|
|
50
41
|
/**
|
|
51
42
|
* Compile-time guards: {@link ComposioRequestOptions} is forwarded verbatim to
|
|
52
43
|
* every `@composio/client` call, so it MUST stay a structural subset of the
|
|
@@ -525,7 +525,7 @@ export const ToolRouterCreateSessionConfigSchema = z
|
|
|
525
525
|
* @param {SessionPreset} [sessionPreset] - Shortcut that exposes every tool allowed by the session filters directly in session.tools() and the MCP tool list. Disables search, multi-execute, manage-connections, and sandbox by default; explicit overrides for supported fields still win. Without this preset, ToolRouter uses the default configuration with meta tools enabled.
|
|
526
526
|
* @param {ToolRouterToolkitsParamSchema | ToolRouterToolkitsDisabledConfigSchema | ToolRouterToolkitsEnabledConfigSchema} toolkits - The toolkits to use in the tool router session
|
|
527
527
|
* @param {Record<string, ToolRouterToolsParam | ToolRouterConfigTools>} tools - The tools to configure per toolkit (key is toolkit slug)
|
|
528
|
-
* @param {Array<'readOnlyHint' | '
|
|
528
|
+
* @param {Array<'readOnlyHint' | 'createHint' | 'updateHint' | 'destructiveHint'>} tags - Global tags to filter tools by the type of action they take
|
|
529
529
|
* @param {Record<string, string>} authConfigs - The auth configs to use in the tool router session
|
|
530
530
|
* @param {Record<string, string | string[]>} connectedAccounts - The connected accounts to use in the tool router session. A single string is coerced to a single-element array before being sent to the backend.
|
|
531
531
|
* @param {ToolRouterInstant} [instant] - Experimental Instant usage policy. The project must allow Instant usage.
|
package/src/utils/jsonSchema.ts
CHANGED
|
@@ -515,11 +515,17 @@ export function jsonSchemaToZodSchema<T extends z.ZodTypeAny>(
|
|
|
515
515
|
* added to it and widened to accept `null`, the emulation of optional
|
|
516
516
|
* fields that OpenAI structured outputs document.
|
|
517
517
|
* - `unsupported-keyword-stripped` — an annotation keyword the API rejects
|
|
518
|
-
* (`default`, `examples`
|
|
518
|
+
* (`default`, `examples`, or a string `format` outside the accepted list)
|
|
519
|
+
* was removed.
|
|
519
520
|
* - `one-of-converted` — `oneOf` (unsupported) became `anyOf`.
|
|
521
|
+
* - `nullable-converted` — OpenAPI `nullable: true`, which Anthropic rejects
|
|
522
|
+
* on an object, became a `null` member of `type` or a null branch.
|
|
520
523
|
*/
|
|
521
524
|
export type StrictSchemaChangeReason =
|
|
522
|
-
'optional-property-nullable'
|
|
525
|
+
| 'optional-property-nullable'
|
|
526
|
+
| 'unsupported-keyword-stripped'
|
|
527
|
+
| 'one-of-converted'
|
|
528
|
+
| 'nullable-converted';
|
|
523
529
|
|
|
524
530
|
/** A single lossless rewrite applied by {@link toStrictJsonSchema}. */
|
|
525
531
|
export interface StrictSchemaChange {
|
|
@@ -567,6 +573,27 @@ const MAX_STRICT_CHANGES = 50;
|
|
|
567
573
|
/** Annotation-only keywords OpenAI structured outputs rejects; safe to strip. */
|
|
568
574
|
const STRICT_STRIP_KEYWORDS = new Set(['examples', 'default']);
|
|
569
575
|
|
|
576
|
+
/**
|
|
577
|
+
* The `format` values OpenAI structured outputs accepts on a string schema,
|
|
578
|
+
* matched case-sensitively; any other value there is rejected with a 400.
|
|
579
|
+
* Formats on number and integer schemas are not checked.
|
|
580
|
+
*/
|
|
581
|
+
const STRICT_STRING_FORMATS = new Set([
|
|
582
|
+
'date-time',
|
|
583
|
+
'time',
|
|
584
|
+
'date',
|
|
585
|
+
'duration',
|
|
586
|
+
'email',
|
|
587
|
+
'hostname',
|
|
588
|
+
'ipv4',
|
|
589
|
+
'ipv6',
|
|
590
|
+
'uuid',
|
|
591
|
+
]);
|
|
592
|
+
|
|
593
|
+
/** Whether a `type` value admits strings; an absent `type` admits every type. */
|
|
594
|
+
const admitsString = (type: unknown): boolean =>
|
|
595
|
+
type === undefined || type === 'string' || (Array.isArray(type) && type.includes('string'));
|
|
596
|
+
|
|
570
597
|
/** Keywords OpenAI structured outputs reject and that have no lossless rewrite. */
|
|
571
598
|
const STRICT_UNSUPPORTED_KEYWORDS = [
|
|
572
599
|
'allOf',
|
|
@@ -676,6 +703,11 @@ function resolveLocalRefs(node: unknown, root: Record<string, unknown>): unknown
|
|
|
676
703
|
* the one it was given: the rewrite types every node that declares
|
|
677
704
|
* `properties` as an object, so such a node stops accepting null.
|
|
678
705
|
*
|
|
706
|
+
* `followRefs: false` makes every `$ref` reject null without resolving it.
|
|
707
|
+
* Folding `nullable` needs that, because a `$ref` can lead back to the node
|
|
708
|
+
* being folded, whose source still accepts null. It costs at most a
|
|
709
|
+
* redundant null branch.
|
|
710
|
+
*
|
|
679
711
|
* One check serves a whole document, and an answer is computed once per node.
|
|
680
712
|
* A reference cycle never yields a null by itself, so a node met again while
|
|
681
713
|
* it is being evaluated counts as rejecting. An answer that leans on that is
|
|
@@ -690,7 +722,8 @@ function resolveLocalRefs(node: unknown, root: Record<string, unknown>): unknown
|
|
|
690
722
|
*/
|
|
691
723
|
function createNullCheck(
|
|
692
724
|
root: Record<string, unknown>,
|
|
693
|
-
strictOutput = false
|
|
725
|
+
strictOutput = false,
|
|
726
|
+
followRefs = true
|
|
694
727
|
): (schema: unknown) => boolean {
|
|
695
728
|
// Markers for what an answer leans on, besides the depth of a node on the path.
|
|
696
729
|
const NOTHING = MAX_NULL_CHECK_DEPTH + 1;
|
|
@@ -769,12 +802,16 @@ function createNullCheck(
|
|
|
769
802
|
};
|
|
770
803
|
|
|
771
804
|
const keywordsAccept = (node: Record<string, unknown>): boolean => {
|
|
805
|
+
// OpenAPI `nullable: true` admits null whatever the other keywords say,
|
|
806
|
+
// as the Zod conversion reads it.
|
|
807
|
+
if (node.nullable === true) return true;
|
|
772
808
|
if (typeof node.type === 'string' && node.type !== 'null') return false;
|
|
773
809
|
if (Array.isArray(node.type) && !node.type.includes('null')) return false;
|
|
774
810
|
if (strictOutput && !('type' in node) && isPlainObject(node.properties)) return false;
|
|
775
811
|
if (Array.isArray(node.enum) && !node.enum.includes(null)) return false;
|
|
776
812
|
if ('const' in node && node.const !== null) return false;
|
|
777
813
|
if ('$ref' in node) {
|
|
814
|
+
if (!followRefs) return false;
|
|
778
815
|
const resolution =
|
|
779
816
|
typeof node.$ref === 'string' ? tryResolvePointer(root, node.$ref) : undefined;
|
|
780
817
|
if (resolution === undefined || resolution.kind === 'unresolved') return false;
|
|
@@ -811,7 +848,9 @@ function createNullCheck(
|
|
|
811
848
|
* sends for such a property means "omitted"; the strict providers drop it
|
|
812
849
|
* before executing the tool (see {@link omitNullToolArguments});
|
|
813
850
|
* - `type` arrays are kept as-is (the API accepts them); `oneOf` becomes
|
|
814
|
-
* `anyOf`; `default` and `
|
|
851
|
+
* `anyOf`; `default`, `examples`, and a string `format` the API does
|
|
852
|
+
* not accept are stripped; OpenAPI `nullable` is stripped too, and a
|
|
853
|
+
* node that set it to `true` is widened to accept `null`;
|
|
815
854
|
* - local `$ref`s into `$defs`/`definitions` are kept (the API supports
|
|
816
855
|
* them, including recursion) and the definitions themselves are
|
|
817
856
|
* normalized; an optional `$ref` property is widened with an `anyOf`
|
|
@@ -841,6 +880,7 @@ export function toStrictJsonSchema(schema: unknown): StrictJsonSchemaResult {
|
|
|
841
880
|
|
|
842
881
|
const root: Record<string, unknown> = isPlainObject(schema) ? schema : {};
|
|
843
882
|
const acceptsNullInOutput = createNullCheck(root, true);
|
|
883
|
+
const acceptsNullWithoutRefs = createNullCheck(root, true, false);
|
|
844
884
|
|
|
845
885
|
function walkChildren(
|
|
846
886
|
node: Record<string, unknown>,
|
|
@@ -892,6 +932,7 @@ export function toStrictJsonSchema(schema: unknown): StrictJsonSchemaResult {
|
|
|
892
932
|
|
|
893
933
|
const node: Record<string, unknown> = {};
|
|
894
934
|
for (const [key, child] of Object.entries(value)) {
|
|
935
|
+
if (key === 'nullable') continue;
|
|
895
936
|
if (STRICT_STRIP_KEYWORDS.has(key)) {
|
|
896
937
|
recordChange({
|
|
897
938
|
path,
|
|
@@ -900,6 +941,19 @@ export function toStrictJsonSchema(schema: unknown): StrictJsonSchemaResult {
|
|
|
900
941
|
});
|
|
901
942
|
continue;
|
|
902
943
|
}
|
|
944
|
+
if (
|
|
945
|
+
key === 'format' &&
|
|
946
|
+
typeof child === 'string' &&
|
|
947
|
+
!STRICT_STRING_FORMATS.has(child) &&
|
|
948
|
+
admitsString(value.type)
|
|
949
|
+
) {
|
|
950
|
+
recordChange({
|
|
951
|
+
path,
|
|
952
|
+
reason: 'unsupported-keyword-stripped',
|
|
953
|
+
detail: `format "${child}" removed`,
|
|
954
|
+
});
|
|
955
|
+
continue;
|
|
956
|
+
}
|
|
903
957
|
setOwn(node, key, child);
|
|
904
958
|
}
|
|
905
959
|
if (Array.isArray(node.oneOf) && node.anyOf === undefined) {
|
|
@@ -932,6 +986,24 @@ export function toStrictJsonSchema(schema: unknown): StrictJsonSchemaResult {
|
|
|
932
986
|
unsupported.push({ path, keyword: 'properties', detail: 'properties is not an object' });
|
|
933
987
|
}
|
|
934
988
|
|
|
989
|
+
const normalized = normalizeNode(node, mode, depth, path);
|
|
990
|
+
if (!('nullable' in value)) return normalized;
|
|
991
|
+
const widened =
|
|
992
|
+
value.nullable === true ? widenToNullable(normalized, acceptsNullWithoutRefs) : normalized;
|
|
993
|
+
recordChange(
|
|
994
|
+
widened === normalized
|
|
995
|
+
? { path, reason: 'unsupported-keyword-stripped', detail: 'keyword "nullable" removed' }
|
|
996
|
+
: { path, reason: 'nullable-converted', detail: 'nullable became a null type' }
|
|
997
|
+
);
|
|
998
|
+
return widened;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
function normalizeNode(
|
|
1002
|
+
node: Record<string, unknown>,
|
|
1003
|
+
mode: StrictWalkMode,
|
|
1004
|
+
depth: number,
|
|
1005
|
+
path: string
|
|
1006
|
+
): Record<string, unknown> {
|
|
935
1007
|
const out = walkChildren(node, mode, depth, path);
|
|
936
1008
|
|
|
937
1009
|
if (typeof node.$ref === 'string') {
|