@composio/core 0.24.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-CnJxXr07.mjs → CustomTool-BYHB7sPs.mjs} +1 -1
- package/dist/{CustomTool-CNJysHMK.d.mts → CustomTool-DfP4ldQl.d.mts} +1 -1
- package/dist/{cancellation-BQibgpRG.mjs → cancellation-ZoRh6EJQ.mjs} +55 -3
- package/dist/{composio-BFTtZj82.d.mts → composio-BMDH-1Qj.d.mts} +35 -15
- package/dist/{customTool.types-D57QrTns.d.mts → customTool.types-BoOELgJF.d.mts} +346 -23
- package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +10 -10
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +2 -2
- package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +22 -22
- package/dist/docs/reference/sdk-reference/typescript/custom-toolkits.mdx +8 -8
- package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +2 -2
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +1 -1
- package/dist/docs/reference/sdk-reference/typescript/keyring.mdx +2 -2
- package/dist/docs/reference/sdk-reference/typescript/logs.mdx +5 -5
- package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +15 -15
- package/dist/docs/reference/sdk-reference/typescript/meta.json +1 -1
- package/dist/docs/reference/sdk-reference/typescript/session-configs.mdx +5 -5
- package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +10 -10
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +56 -21
- package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +6 -6
- package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +22 -22
- package/dist/docs/reference/sdk-reference/typescript/tools.mdx +18 -18
- package/dist/docs/reference/sdk-reference/typescript/triggers.mdx +25 -25
- package/dist/docs/reference/sdk-reference/typescript/usage.mdx +6 -6
- package/dist/docs/reference/sdk-reference/typescript/webhook-endpoints.mdx +14 -14
- package/dist/docs/reference/sdk-reference/typescript/webhook-subscriptions.mdx +13 -13
- package/dist/{errors-BN15NcCW.mjs → errors-Cly0vXFh.mjs} +5 -5
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/index.d.mts +19 -11
- package/dist/index.mjs +693 -196
- package/dist/{types-q8TwAngA.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 +2 -2
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/package.json +5 -5
- package/src/composio.ts +81 -67
- package/src/errors/ToolRouterErrors.ts +5 -5
- package/src/lib/toolRouterMcp.ts +2 -0
- package/src/lib/toolRouterParams.ts +28 -16
- package/src/models/ConnectedAccounts.ts +7 -16
- package/src/models/ToolRouter.ts +8 -1
- package/src/models/ToolRouterSession.ts +17 -0
- package/src/models/Tools.ts +1 -4
- package/src/models/Triggers.ts +14 -7
- package/src/services/internal/InternalService.ts +3 -4
- package/src/services/pusher/Pusher.ts +170 -92
- package/src/types/connectedAccountAuthStates.types.ts +2 -1
- package/src/types/pusher.types.ts +2 -0
- package/src/types/requestOptions.types.ts +1 -10
- package/src/types/toolRouter.types.ts +104 -18
- package/src/utils/jsonSchema.ts +76 -4
- package/src/utils/sdk.ts +172 -11
- package/src/utils/session.ts +25 -47
- package/src/utils/toolkitDeprecation.ts +271 -0
- package/src/utils/transformers/connectedAccounts.ts +9 -20
- package/src/utils/transformers/mcp.ts +3 -10
- package/src/utils/userCallback.ts +41 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as CreateCustomToolkitParams, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams, t as AnyZodSchema } from "./customTool.types-
|
|
1
|
+
import { a as CreateCustomToolkitParams, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams, t as AnyZodSchema } from "./customTool.types-BoOELgJF.mjs";
|
|
2
2
|
import { SessionCreateResponse } from "@composio/client/resources/tool-router/session/session.mjs";
|
|
3
3
|
//#region src/models/CustomTool.d.ts
|
|
4
4
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as logger } from "./SsrfErrors-DiQldIdC.mjs";
|
|
2
|
-
import { S as JsonSchemaToZodError, _ as ComposioRequestCancelledError, b as isRequestAbortError, x as JsonSchemaRefResolutionError } from "./errors-
|
|
2
|
+
import { S as JsonSchemaToZodError, _ as ComposioRequestCancelledError, b as isRequestAbortError, x as JsonSchemaRefResolutionError } from "./errors-Cly0vXFh.mjs";
|
|
3
3
|
import { o as isPlainObject } from "./FileToolModifier.utils.neutral-DWFpnsj2.mjs";
|
|
4
4
|
import { jsonSchemaToZod } from "@composio/json-schema-to-zod";
|
|
5
5
|
|
|
@@ -354,6 +354,24 @@ function jsonSchemaToZodSchema(jsonSchema, { strict } = { strict: false }) {
|
|
|
354
354
|
const MAX_STRICT_CHANGES = 50;
|
|
355
355
|
/** Annotation-only keywords OpenAI structured outputs rejects; safe to strip. */
|
|
356
356
|
const STRICT_STRIP_KEYWORDS = /* @__PURE__ */ new Set(["examples", "default"]);
|
|
357
|
+
/**
|
|
358
|
+
* The `format` values OpenAI structured outputs accepts on a string schema,
|
|
359
|
+
* matched case-sensitively; any other value there is rejected with a 400.
|
|
360
|
+
* Formats on number and integer schemas are not checked.
|
|
361
|
+
*/
|
|
362
|
+
const STRICT_STRING_FORMATS = /* @__PURE__ */ new Set([
|
|
363
|
+
"date-time",
|
|
364
|
+
"time",
|
|
365
|
+
"date",
|
|
366
|
+
"duration",
|
|
367
|
+
"email",
|
|
368
|
+
"hostname",
|
|
369
|
+
"ipv4",
|
|
370
|
+
"ipv6",
|
|
371
|
+
"uuid"
|
|
372
|
+
]);
|
|
373
|
+
/** Whether a `type` value admits strings; an absent `type` admits every type. */
|
|
374
|
+
const admitsString = (type) => type === void 0 || type === "string" || Array.isArray(type) && type.includes("string");
|
|
357
375
|
/** Keywords OpenAI structured outputs reject and that have no lossless rewrite. */
|
|
358
376
|
const STRICT_UNSUPPORTED_KEYWORDS = [
|
|
359
377
|
"allOf",
|
|
@@ -454,6 +472,11 @@ function resolveLocalRefs(node, root) {
|
|
|
454
472
|
* the one it was given: the rewrite types every node that declares
|
|
455
473
|
* `properties` as an object, so such a node stops accepting null.
|
|
456
474
|
*
|
|
475
|
+
* `followRefs: false` makes every `$ref` reject null without resolving it.
|
|
476
|
+
* Folding `nullable` needs that, because a `$ref` can lead back to the node
|
|
477
|
+
* being folded, whose source still accepts null. It costs at most a
|
|
478
|
+
* redundant null branch.
|
|
479
|
+
*
|
|
457
480
|
* One check serves a whole document, and an answer is computed once per node.
|
|
458
481
|
* A reference cycle never yields a null by itself, so a node met again while
|
|
459
482
|
* it is being evaluated counts as rejecting. An answer that leans on that is
|
|
@@ -466,7 +489,7 @@ function resolveLocalRefs(node, root) {
|
|
|
466
489
|
* went through stay marked as unproven, so a later check that reaches one of
|
|
467
490
|
* them neither repeats the work nor trusts the answer.
|
|
468
491
|
*/
|
|
469
|
-
function createNullCheck(root, strictOutput = false) {
|
|
492
|
+
function createNullCheck(root, strictOutput = false, followRefs = true) {
|
|
470
493
|
const NOTHING = 65;
|
|
471
494
|
const A_BOUND = -1;
|
|
472
495
|
const answers = /* @__PURE__ */ new Map();
|
|
@@ -531,12 +554,14 @@ function createNullCheck(root, strictOutput = false) {
|
|
|
531
554
|
return answer;
|
|
532
555
|
};
|
|
533
556
|
const keywordsAccept = (node) => {
|
|
557
|
+
if (node.nullable === true) return true;
|
|
534
558
|
if (typeof node.type === "string" && node.type !== "null") return false;
|
|
535
559
|
if (Array.isArray(node.type) && !node.type.includes("null")) return false;
|
|
536
560
|
if (strictOutput && !("type" in node) && isPlainObject(node.properties)) return false;
|
|
537
561
|
if (Array.isArray(node.enum) && !node.enum.includes(null)) return false;
|
|
538
562
|
if ("const" in node && node.const !== null) return false;
|
|
539
563
|
if ("$ref" in node) {
|
|
564
|
+
if (!followRefs) return false;
|
|
540
565
|
const resolution = typeof node.$ref === "string" ? tryResolvePointer(root, node.$ref) : void 0;
|
|
541
566
|
if (resolution === void 0 || resolution.kind === "unresolved") return false;
|
|
542
567
|
if (!accepts(resolution.value)) return false;
|
|
@@ -569,7 +594,9 @@ function createNullCheck(root, strictOutput = false) {
|
|
|
569
594
|
* sends for such a property means "omitted"; the strict providers drop it
|
|
570
595
|
* before executing the tool (see {@link omitNullToolArguments});
|
|
571
596
|
* - `type` arrays are kept as-is (the API accepts them); `oneOf` becomes
|
|
572
|
-
* `anyOf`; `default` and `
|
|
597
|
+
* `anyOf`; `default`, `examples`, and a string `format` the API does
|
|
598
|
+
* not accept are stripped; OpenAPI `nullable` is stripped too, and a
|
|
599
|
+
* node that set it to `true` is widened to accept `null`;
|
|
573
600
|
* - local `$ref`s into `$defs`/`definitions` are kept (the API supports
|
|
574
601
|
* them, including recursion) and the definitions themselves are
|
|
575
602
|
* normalized; an optional `$ref` property is widened with an `anyOf`
|
|
@@ -597,6 +624,7 @@ function toStrictJsonSchema(schema) {
|
|
|
597
624
|
};
|
|
598
625
|
const root = isPlainObject(schema) ? schema : {};
|
|
599
626
|
const acceptsNullInOutput = createNullCheck(root, true);
|
|
627
|
+
const acceptsNullWithoutRefs = createNullCheck(root, true, false);
|
|
600
628
|
function walkChildren(node, mode, depth, path) {
|
|
601
629
|
const clone = {};
|
|
602
630
|
for (const [key, child] of Object.entries(node)) {
|
|
@@ -626,6 +654,7 @@ function toStrictJsonSchema(schema) {
|
|
|
626
654
|
if (!isPlainObject(value) || mode === "value") return value;
|
|
627
655
|
const node = {};
|
|
628
656
|
for (const [key, child] of Object.entries(value)) {
|
|
657
|
+
if (key === "nullable") continue;
|
|
629
658
|
if (STRICT_STRIP_KEYWORDS.has(key)) {
|
|
630
659
|
recordChange({
|
|
631
660
|
path,
|
|
@@ -634,6 +663,14 @@ function toStrictJsonSchema(schema) {
|
|
|
634
663
|
});
|
|
635
664
|
continue;
|
|
636
665
|
}
|
|
666
|
+
if (key === "format" && typeof child === "string" && !STRICT_STRING_FORMATS.has(child) && admitsString(value.type)) {
|
|
667
|
+
recordChange({
|
|
668
|
+
path,
|
|
669
|
+
reason: "unsupported-keyword-stripped",
|
|
670
|
+
detail: `format "${child}" removed`
|
|
671
|
+
});
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
637
674
|
setOwn(node, key, child);
|
|
638
675
|
}
|
|
639
676
|
if (Array.isArray(node.oneOf) && node.anyOf === void 0) {
|
|
@@ -670,6 +707,21 @@ function toStrictJsonSchema(schema) {
|
|
|
670
707
|
keyword: "properties",
|
|
671
708
|
detail: "properties is not an object"
|
|
672
709
|
});
|
|
710
|
+
const normalized = normalizeNode(node, mode, depth, path);
|
|
711
|
+
if (!("nullable" in value)) return normalized;
|
|
712
|
+
const widened = value.nullable === true ? widenToNullable(normalized, acceptsNullWithoutRefs) : normalized;
|
|
713
|
+
recordChange(widened === normalized ? {
|
|
714
|
+
path,
|
|
715
|
+
reason: "unsupported-keyword-stripped",
|
|
716
|
+
detail: "keyword \"nullable\" removed"
|
|
717
|
+
} : {
|
|
718
|
+
path,
|
|
719
|
+
reason: "nullable-converted",
|
|
720
|
+
detail: "nullable became a null type"
|
|
721
|
+
});
|
|
722
|
+
return widened;
|
|
723
|
+
}
|
|
724
|
+
function normalizeNode(node, mode, depth, path) {
|
|
673
725
|
const out = walkChildren(node, mode, depth, path);
|
|
674
726
|
if (typeof node.$ref === "string") {
|
|
675
727
|
if ((node.$ref === "#" || node.$ref.startsWith("#/") ? tryResolvePointer(root, node.$ref) : {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Aa as
|
|
1
|
+
import { $n as CreateConnectedAccountOptions, Aa as ToolExecuteParams, Cn as ConnectedAccountCompleteAuthResponse, D as Session, Da as Tool, Ea as SchemaModifierOptions, Fa as ToolListParams, In as ConnectedAccountRetrieveResponse, Ja as ToolkitVersionParam, M as SessionWithoutMcp, Ma as ToolExecuteResponse, Oa as ToolExecuteMetaParams, Pa as ToolList, Pn as ConnectedAccountRefreshOptions, Rn as ConnectedAccountRevokeResponse, Va as ToolRetrievalOptions, Yn as CreateConnectedAccountLinkOptions, ai as McpServerGetResponse, cr as UpdateConnectedAccountParams, dr as BaseComposioProvider, f as CustomToolkit, fa as ProviderOptions, fn as ComposioRequestOptions, fr as BaseNonAgenticProvider, jn as ConnectedAccountListResponse, kn as ConnectedAccountListParams, mi as ExecuteToolFnOptions, o as CustomTool, or as UpdateConnectedAccountAclParams, pa as SessionExecuteMetaModifiers, pn as ConnectionRequest, rt as ToolRouterSessionDeleteResponse, ua as ExecuteToolModifiers, ui as McpUrlResponse, vi as ToolCallSession, xn as ConnectedAccountCompleteAuthParams, z as ToolRouterCreateSessionConfig, za as ToolProxyParams } from "./customTool.types-BoOELgJF.mjs";
|
|
2
2
|
import ComposioClient, { Composio } from "@composio/client";
|
|
3
3
|
import z, { z as z$1 } from "zod/v3";
|
|
4
4
|
import { Files } from "#files";
|
|
@@ -4223,16 +4223,16 @@ declare const VerifyWebhookParamsSchema: z$1.ZodObject<{
|
|
|
4223
4223
|
tolerance: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNumber>>;
|
|
4224
4224
|
}, "strip", z$1.ZodTypeAny, {
|
|
4225
4225
|
id: string;
|
|
4226
|
-
secret: string;
|
|
4227
4226
|
payload: string;
|
|
4228
4227
|
timestamp: string;
|
|
4228
|
+
secret: string;
|
|
4229
4229
|
signature: string;
|
|
4230
4230
|
tolerance: number;
|
|
4231
4231
|
}, {
|
|
4232
4232
|
id: string;
|
|
4233
|
-
secret: string;
|
|
4234
4233
|
payload: string;
|
|
4235
4234
|
timestamp: string;
|
|
4235
|
+
secret: string;
|
|
4236
4236
|
signature: string;
|
|
4237
4237
|
tolerance?: number | undefined;
|
|
4238
4238
|
}>;
|
|
@@ -4398,7 +4398,8 @@ declare class Triggers<TProvider extends BaseComposioProvider<unknown, unknown,
|
|
|
4398
4398
|
/**
|
|
4399
4399
|
* Subscribe to all the triggers
|
|
4400
4400
|
*
|
|
4401
|
-
* @param fn - The function to call when a trigger is received
|
|
4401
|
+
* @param fn - The function to call when a trigger is received. It may be `async`. Errors
|
|
4402
|
+
* thrown from — or promises rejected by — the function are contained and logged.
|
|
4402
4403
|
* @param filters - The filters to apply to the triggers
|
|
4403
4404
|
* @param onSubscriptionError - Optional callback invoked with the raw Pusher payload when
|
|
4404
4405
|
* the underlying subscription fails (for example on auth or permission rejection). The
|
|
@@ -4429,6 +4430,10 @@ declare class Triggers<TProvider extends BaseComposioProvider<unknown, unknown,
|
|
|
4429
4430
|
/**
|
|
4430
4431
|
* Unsubscribe from all the triggers
|
|
4431
4432
|
*
|
|
4433
|
+
* Ends every subscription made with {@link subscribe} on this instance, including one that is
|
|
4434
|
+
* still connecting, and closes the realtime connection so that a script can exit. A later
|
|
4435
|
+
* `subscribe()` opens a new connection.
|
|
4436
|
+
*
|
|
4432
4437
|
* @returns {Promise<void>}
|
|
4433
4438
|
*
|
|
4434
4439
|
* @example
|
|
@@ -8350,7 +8355,8 @@ declare class ToolRouter<TToolCollection, TTool, TProvider extends BaseComposioP
|
|
|
8350
8355
|
/**
|
|
8351
8356
|
* Derives the MCP config for a session from the auth context the session
|
|
8352
8357
|
* request was made with: the project key when one is configured, otherwise
|
|
8353
|
-
* the resolved user API key,
|
|
8358
|
+
* the resolved user API key, otherwise the organization API key, plus the
|
|
8359
|
+
* org/project scope when configured.
|
|
8354
8360
|
* Headers are only attached when the MCP URL shares the client's API
|
|
8355
8361
|
* origin. Any other destination throws when the caller passed `mcp: true`
|
|
8356
8362
|
* and otherwise yields empty headers plus a warning; see
|
|
@@ -8468,8 +8474,10 @@ type ComposioConfig<TProvider extends BaseComposioProvider<unknown, unknown, unk
|
|
|
8468
8474
|
* project key; the SDK throws instead of sending it.
|
|
8469
8475
|
* - `null`: disables project-key authentication entirely, including both fallbacks. The SDK
|
|
8470
8476
|
* then requires another credential (`userApiKey`, `orgApiKey`, or an `x-user-api-key`
|
|
8471
|
-
* entry in `defaultHeaders`) and sends no `x-api-key`; an `x-api-key` entry in
|
|
8472
|
-
* `defaultHeaders` is rejected, also on `createSession()` clones.
|
|
8477
|
+
* or `x-org-api-key` entry in `defaultHeaders`) and sends no `x-api-key`; an `x-api-key` entry in
|
|
8478
|
+
* `defaultHeaders` is rejected, also on `createSession()` clones. The user API key
|
|
8479
|
+
* then authenticates every request; the organization API key does when it is the
|
|
8480
|
+
* only credential held.
|
|
8473
8481
|
*
|
|
8474
8482
|
* @example 'ak_1234567890'
|
|
8475
8483
|
*/
|
|
@@ -8490,7 +8498,8 @@ type ComposioConfig<TProvider extends BaseComposioProvider<unknown, unknown, unk
|
|
|
8490
8498
|
* Sent as `x-org-api-key` only on operations whose security scheme accepts
|
|
8491
8499
|
* it, never alongside the project key. Falls back to
|
|
8492
8500
|
* `process.env['COMPOSIO_ORG_API_KEY']`; `null` disables that fallback.
|
|
8493
|
-
* Combine with `apiKey: null`
|
|
8501
|
+
* Combine with `apiKey: null` (and no user API key) to authenticate every
|
|
8502
|
+
* request with the organization key alone.
|
|
8494
8503
|
* @example 'oak_1234567890'
|
|
8495
8504
|
*/
|
|
8496
8505
|
orgApiKey?: string | null;
|
|
@@ -8587,11 +8596,22 @@ type ComposioConfig<TProvider extends BaseComposioProvider<unknown, unknown, unk
|
|
|
8587
8596
|
/**
|
|
8588
8597
|
* Default headers attached to every request made through this instance.
|
|
8589
8598
|
*
|
|
8590
|
-
*
|
|
8591
|
-
*
|
|
8592
|
-
*
|
|
8593
|
-
*
|
|
8594
|
-
*
|
|
8599
|
+
* Credential and scope headers are not forwarded as headers: the SDK folds
|
|
8600
|
+
* them into its own options, which `getConfig()` then reports.
|
|
8601
|
+
* A non-empty `x-user-api-key` (or `x-org-api-key`) entry becomes the
|
|
8602
|
+
* credential every request carries, in place of the configured keys; together
|
|
8603
|
+
* with `apiKey: null` it authenticates with that key instead of a project key.
|
|
8604
|
+
* An `x-api-key` entry replaces the project key, and is rejected when `apiKey`
|
|
8605
|
+
* is `null`. At most one of the three may be set. `x-org-id` / `x-project-id`
|
|
8606
|
+
* entries supply `orgId` / `projectId`.
|
|
8607
|
+
*
|
|
8608
|
+
* The SDK reports itself through the API client's identity headers
|
|
8609
|
+
* (`x-client-provenance`, `x-client-version`, `x-client-library`,
|
|
8610
|
+
* `x-client-library-version`, `x-client-language`, `x-client-runtime`,
|
|
8611
|
+
* `x-sdk-version`, `x-source`, `x-framework`, `x-runtime` and
|
|
8612
|
+
* `x-runtime-version`); an entry naming one of them is rejected with a
|
|
8613
|
+
* `ComposioError` from `@composio/client`. Every other header is passed
|
|
8614
|
+
* through untouched.
|
|
8595
8615
|
* @example
|
|
8596
8616
|
* ```typescript
|
|
8597
8617
|
* const composio = new Composio({
|
|
@@ -8869,8 +8889,8 @@ declare class Composio$1<TProvider extends BaseComposioProvider<unknown, unknown
|
|
|
8869
8889
|
* instance directly with the headers you need: `new Composio({ ...existingConfig, defaultHeaders })`.
|
|
8870
8890
|
* For one-off overrides, pass per-call `requestOptions` where supported.
|
|
8871
8891
|
*
|
|
8872
|
-
* @param {
|
|
8873
|
-
*
|
|
8892
|
+
* @param {object} [options] - Options for the new instance.
|
|
8893
|
+
* @param {ComposioRequestHeaders} [options.headers] - Headers sent with every API call the new instance makes.
|
|
8874
8894
|
* @returns {Composio<TProvider>} A new Composio instance with the custom request options applied.
|
|
8875
8895
|
*
|
|
8876
8896
|
* @example
|