@composio/core 0.19.0 → 0.20.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-CB5vm1Jc.d.mts → CustomTool-B3m-188G.d.mts} +1 -1
- package/dist/{CustomTool-BMlZfJVz.mjs → CustomTool-fYEFjSLM.mjs} +1 -1
- package/dist/{FileModifierErrors-BqFmpRsm.mjs → FileModifierErrors-CdGSABoq.mjs} +1 -1
- package/dist/{SsrfErrors-C91YhASE.mjs → SsrfErrors-DiQldIdC.mjs} +18 -7
- package/dist/{Telemetry-HlftxMx6.mjs → Telemetry-JRJJYS4I.mjs} +2 -2
- package/dist/{cancellation-CXpfmiVo.mjs → cancellation-Dwa9lGHA.mjs} +2 -2
- package/dist/{composio-DLGaeN70.d.mts → composio-B36OXii1.d.mts} +2691 -119
- package/dist/{customTool.types-BAmEh3MB.d.mts → customTool.types-C436M_D0.d.mts} +431 -98
- package/dist/docs/reference/sdk-reference/typescript/auth-configs.mdx +10 -10
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +5 -2
- package/dist/docs/reference/sdk-reference/typescript/connected-accounts.mdx +101 -18
- package/dist/docs/reference/sdk-reference/typescript/custom-toolkits.mdx +123 -0
- package/dist/docs/reference/sdk-reference/typescript/experimental.mdx +9 -2
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +7 -0
- package/dist/docs/reference/sdk-reference/typescript/keyring.mdx +56 -0
- package/dist/docs/reference/sdk-reference/typescript/logs.mdx +78 -0
- package/dist/docs/reference/sdk-reference/typescript/mcp.mdx +15 -15
- package/dist/docs/reference/sdk-reference/typescript/meta.json +8 -1
- package/dist/docs/reference/sdk-reference/typescript/session-files.mdx +10 -10
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +77 -27
- package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +24 -10
- package/dist/docs/reference/sdk-reference/typescript/toolkits.mdx +149 -12
- 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 +78 -0
- package/dist/docs/reference/sdk-reference/typescript/webhook-endpoints.mdx +162 -0
- package/dist/docs/reference/sdk-reference/typescript/webhook-subscriptions.mdx +218 -0
- package/dist/docs/reference/sdk-reference/typescript/webhooks.mdx +20 -0
- package/dist/{errors-BuEKehbI.mjs → errors-D_A4b2c2.mjs} +123 -4
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/{fileUtils.node-L7XD8UPr.mjs → fileUtils.node-DNLhLg0W.mjs} +4 -4
- package/dist/index.d.mts +264 -51
- package/dist/index.mjs +2338 -168
- package/dist/models/Files.node.mjs +2 -2
- package/dist/{sensitiveFileUploadPaths-B6pBt9lO.mjs → sensitiveFileUploadPaths-BlLp-Yo2.mjs} +1 -1
- package/dist/{ssrfGuard.node-B9xQB4za.mjs → ssrfGuard.node-BZ270bcu.mjs} +1 -1
- package/dist/{types-CxLPO0Xq.d.mts → types-Br3GBya5.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 +5 -5
- package/dist/utils/modifiers/FileToolModifier.workerd.d.mts +1 -1
- package/dist/utils/ssrfGuard.node.mjs +1 -1
- package/dist/utils/ssrfGuard.workerd.mjs +1 -1
- package/package.json +2 -2
- package/src/composio.ts +207 -10
- package/src/errors/ConnectedAccountsErrors.ts +47 -0
- package/src/errors/SDKErrors.ts +52 -0
- package/src/errors/ToolRouterErrors.ts +57 -0
- package/src/errors/index.ts +3 -0
- package/src/index.ts +11 -0
- package/src/lib/toolRouterMcp.ts +132 -0
- package/src/lib/toolRouterParams.ts +116 -29
- 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/ToolRouter.ts +42 -14
- package/src/models/ToolRouterSession.ts +120 -9
- package/src/models/Toolkits.ts +180 -0
- package/src/models/Tools.ts +3 -1
- package/src/models/Triggers.ts +3 -88
- package/src/models/Usage.ts +119 -0
- package/src/models/Webhooks.ts +520 -0
- package/src/services/pusher/Pusher.ts +17 -6
- 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 +205 -11
- package/src/types/toolkit.types.ts +144 -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/logger.ts +39 -7
- package/src/utils/sdk.ts +385 -22
- 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 +106 -3
- package/src/utils/transformers/triggers.ts +2 -2
- package/src/utils/transformers/usage.ts +77 -0
- package/src/utils/transformers/webhooks.ts +139 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as ComposioError$1 } from "./SsrfErrors-
|
|
2
|
-
import "./FileModifierErrors-
|
|
1
|
+
import { r as ComposioError$1 } from "./SsrfErrors-DiQldIdC.mjs";
|
|
2
|
+
import "./FileModifierErrors-CdGSABoq.mjs";
|
|
3
3
|
import { APIError, APIUserAbortError } from "@composio/client";
|
|
4
4
|
import { ZodError } from "zod/v3";
|
|
5
5
|
|
|
@@ -29,7 +29,9 @@ const ConnectedAccountErrorCodes = {
|
|
|
29
29
|
LEGACY_CONNECTED_ACCOUNTS_ENDPOINT_RETIRED: "LEGACY_CONNECTED_ACCOUNTS_ENDPOINT_RETIRED",
|
|
30
30
|
SHARED_ACCESS_DENIED: "SHARED_ACCESS_DENIED",
|
|
31
31
|
ACL_ONLY_FOR_SHARED: "ACL_ONLY_FOR_SHARED",
|
|
32
|
-
SHARED_CONNECTION_NOT_ACCESSIBLE: "SHARED_CONNECTION_NOT_ACCESSIBLE"
|
|
32
|
+
SHARED_CONNECTION_NOT_ACCESSIBLE: "SHARED_CONNECTION_NOT_ACCESSIBLE",
|
|
33
|
+
REVOCATION_NOT_SUPPORTED: "CONNECTED_ACCOUNT_REVOCATION_NOT_SUPPORTED",
|
|
34
|
+
NOT_REVOKABLE: "CONNECTED_ACCOUNT_NOT_REVOKABLE"
|
|
33
35
|
};
|
|
34
36
|
var ComposioConnectedAccountNotFoundError = class extends ComposioError$1 {
|
|
35
37
|
constructor(message = "Connected account not found", options = {}) {
|
|
@@ -137,6 +139,39 @@ var ComposioLegacyConnectedAccountsEndpointRetiredError = class extends Composio
|
|
|
137
139
|
this.name = "ComposioLegacyConnectedAccountsEndpointRetiredError";
|
|
138
140
|
}
|
|
139
141
|
};
|
|
142
|
+
/**
|
|
143
|
+
* Thrown by `composio.connectedAccounts.revoke()` when the toolkit behind the
|
|
144
|
+
* connection does not support programmatic revocation at the provider (API
|
|
145
|
+
* 400).
|
|
146
|
+
*/
|
|
147
|
+
var ComposioConnectedAccountRevocationNotSupportedError = class extends ComposioError$1 {
|
|
148
|
+
constructor(message = "This toolkit does not support programmatic revocation of connected accounts", options = {}) {
|
|
149
|
+
super(message, {
|
|
150
|
+
...options,
|
|
151
|
+
code: ConnectedAccountErrorCodes.REVOCATION_NOT_SUPPORTED,
|
|
152
|
+
statusCode: 400,
|
|
153
|
+
possibleFixes: options.possibleFixes || ["Revoke the grant from the provider's own settings page, then disable or delete the connected account with composio.connectedAccounts.disable() / delete()."]
|
|
154
|
+
});
|
|
155
|
+
this.name = "ComposioConnectedAccountRevocationNotSupportedError";
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Thrown by `composio.connectedAccounts.revoke()` when the connection is not
|
|
160
|
+
* in a state that can be revoked (API 409), for example it never completed
|
|
161
|
+
* authentication. Revoking an already revoked connection is not an error: it
|
|
162
|
+
* returns an empty `revokedTokens` list.
|
|
163
|
+
*/
|
|
164
|
+
var ComposioConnectedAccountNotRevokableError = class extends ComposioError$1 {
|
|
165
|
+
constructor(message = "The connected account is not in a revokable state", options = {}) {
|
|
166
|
+
super(message, {
|
|
167
|
+
...options,
|
|
168
|
+
code: ConnectedAccountErrorCodes.NOT_REVOKABLE,
|
|
169
|
+
statusCode: 409,
|
|
170
|
+
possibleFixes: options.possibleFixes || ["Check the connection status with composio.connectedAccounts.get(); only ACTIVE connections can be revoked."]
|
|
171
|
+
});
|
|
172
|
+
this.name = "ComposioConnectedAccountNotRevokableError";
|
|
173
|
+
}
|
|
174
|
+
};
|
|
140
175
|
|
|
141
176
|
//#endregion
|
|
142
177
|
//#region src/errors/ConnectionRequestErrors.ts
|
|
@@ -455,6 +490,8 @@ var JsonSchemaRefResolutionError = class extends ComposioError$1 {
|
|
|
455
490
|
//#region src/errors/SDKErrors.ts
|
|
456
491
|
const SDKErrorCodes = {
|
|
457
492
|
NO_API_KEY_PROVIDED: "NO_API_KEY_PROVIDED",
|
|
493
|
+
API_KEY_KIND_MISMATCH: "API_KEY_KIND_MISMATCH",
|
|
494
|
+
SCOPE_CONFIG_INVALID: "SCOPE_CONFIG_INVALID",
|
|
458
495
|
REQUEST_CANCELLED: "REQUEST_CANCELLED"
|
|
459
496
|
};
|
|
460
497
|
var ComposioNoAPIKeyError = class extends ComposioError$1 {
|
|
@@ -475,6 +512,43 @@ var ComposioNoAPIKeyError = class extends ComposioError$1 {
|
|
|
475
512
|
}
|
|
476
513
|
};
|
|
477
514
|
/**
|
|
515
|
+
* Thrown when the organization/project scope of an SDK instance is
|
|
516
|
+
* inconsistent: only one of `orgId` / `projectId` was supplied, or a scope
|
|
517
|
+
* option disagrees with the same header placed in `defaultHeaders`.
|
|
518
|
+
*/
|
|
519
|
+
var ComposioScopeConfigError = class extends ComposioError$1 {
|
|
520
|
+
constructor(message = "Invalid organization/project scope configuration", options = {}) {
|
|
521
|
+
super(message, {
|
|
522
|
+
...options,
|
|
523
|
+
code: SDKErrorCodes.SCOPE_CONFIG_INVALID,
|
|
524
|
+
possibleFixes: options.possibleFixes || ["Pass both `orgId` and `projectId` (the organization and consumer project nano IDs), or neither", "Supply the scope through the options or through the `x-org-id` / `x-project-id` default headers, not both with different values"]
|
|
525
|
+
});
|
|
526
|
+
this.name = "ComposioScopeConfigError";
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
/**
|
|
530
|
+
* Thrown when the only API key the SDK could find is a Composio user key
|
|
531
|
+
* (`uak_...`, as stored by `composio login`) rather than a project key.
|
|
532
|
+
* User keys authenticate a person, not a project, so the SDK refuses to send
|
|
533
|
+
* one as `x-api-key`. The error never includes the key value.
|
|
534
|
+
*/
|
|
535
|
+
var ComposioAPIKeyKindError = class extends ComposioError$1 {
|
|
536
|
+
constructor(message = "The stored Composio API key is a user API key, not a project API key", options = {}) {
|
|
537
|
+
super(message, {
|
|
538
|
+
...options,
|
|
539
|
+
code: SDKErrorCodes.API_KEY_KIND_MISMATCH,
|
|
540
|
+
cause: options.cause || "The user config file holds a user API key written by the Composio CLI; it cannot authenticate SDK requests as a project",
|
|
541
|
+
possibleFixes: options.possibleFixes || [
|
|
542
|
+
"Pass a project API key via `apiKey` or the COMPOSIO_API_KEY environment variable",
|
|
543
|
+
"Create a project API key in the Composio dashboard at https://platform.composio.dev",
|
|
544
|
+
"To authenticate with the user API key instead, pass `apiKey: null` together with `userApiKey`"
|
|
545
|
+
],
|
|
546
|
+
statusCode: 401
|
|
547
|
+
});
|
|
548
|
+
this.name = "ComposioAPIKeyKindError";
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
/**
|
|
478
552
|
* Thrown when an SDK call is cancelled via the caller-supplied `AbortSignal`.
|
|
479
553
|
*
|
|
480
554
|
* @example
|
|
@@ -638,4 +712,49 @@ var RemoteFileDownloadError = class extends ComposioError$1 {
|
|
|
638
712
|
};
|
|
639
713
|
|
|
640
714
|
//#endregion
|
|
641
|
-
|
|
715
|
+
//#region src/errors/ToolRouterErrors.ts
|
|
716
|
+
const ToolRouterErrorCodes = {
|
|
717
|
+
MCP_DESTINATION_REJECTED: "MCP_DESTINATION_REJECTED",
|
|
718
|
+
SESSION_CONFIG_CONFLICT: "SESSION_CONFIG_CONFLICT"
|
|
719
|
+
};
|
|
720
|
+
/**
|
|
721
|
+
* Thrown when a session's hosted MCP endpoint is not a destination the SDK
|
|
722
|
+
* will hand the session credential to. The SDK only attaches its credential
|
|
723
|
+
* and scope headers when the MCP URL shares the origin of the API base URL
|
|
724
|
+
* the session was created against. The error is raised only when the caller
|
|
725
|
+
* asked for the endpoint with `mcp: true`; otherwise the session is returned
|
|
726
|
+
* with empty `mcp.headers` and a warning is logged instead. The error names
|
|
727
|
+
* both origins and never includes a credential value.
|
|
728
|
+
*/
|
|
729
|
+
var ComposioMCPDestinationError = class extends ComposioError$1 {
|
|
730
|
+
constructor(message = "The session MCP endpoint is not a trusted destination for the session credential", options = {}) {
|
|
731
|
+
super(message, {
|
|
732
|
+
...options,
|
|
733
|
+
code: ToolRouterErrorCodes.MCP_DESTINATION_REJECTED,
|
|
734
|
+
possibleFixes: options.possibleFixes ?? ["Point `baseURL` at the API origin that serves the session MCP endpoint; a custom base URL yields a matching MCP origin"]
|
|
735
|
+
});
|
|
736
|
+
this.name = "ComposioMCPDestinationError";
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
/**
|
|
740
|
+
* Thrown when a session update is rejected with HTTP 409 because the session
|
|
741
|
+
* configuration changed since it was last read: the `expected_config_version`
|
|
742
|
+
* precondition (the session's last observed `configVersion` by default) is
|
|
743
|
+
* stale. The local session object is left as it was before the call.
|
|
744
|
+
* Re-fetch the session with `sessions.use(sessionId)` and retry the update
|
|
745
|
+
* against the fresh `configVersion`.
|
|
746
|
+
*/
|
|
747
|
+
var ComposioSessionConfigConflictError = class extends ComposioError$1 {
|
|
748
|
+
constructor(message = "The session configuration changed since it was last read; re-fetch the session and retry the update", options = {}) {
|
|
749
|
+
super(message, {
|
|
750
|
+
...options,
|
|
751
|
+
code: ToolRouterErrorCodes.SESSION_CONFIG_CONFLICT,
|
|
752
|
+
statusCode: 409,
|
|
753
|
+
possibleFixes: options.possibleFixes ?? ["Re-fetch the session with `composio.sessions.use(sessionId)` to observe the current configVersion, then retry the update", "Pass `expectedConfigVersion: false` to apply the update regardless of concurrent changes (last writer wins)"]
|
|
754
|
+
});
|
|
755
|
+
this.name = "ComposioSessionConfigConflictError";
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
//#endregion
|
|
760
|
+
export { ComposioInvalidToolArgumentsError as A, ConnectionRequestTimeoutError as B, ValidationErrorCodes as C, ComposioGlobalExecuteToolFnNotSetError as D, ToolkitErrorCodes as E, ComposioToolVersionRequiredError as F, ComposioFailedToCreateConnectedAccountLink as G, ComposioConnectedAccountNotFoundError as H, ToolErrorCodes as I, ComposioSharedAccessDeniedError as J, ComposioLegacyConnectedAccountsEndpointRetiredError as K, handleToolExecutionError as L, ComposioToolExecutionError as M, ComposioToolFetchError as N, ComposioInvalidExecuteFunctionError as O, ComposioToolNotFoundError as P, ComposioAuthConfigNotFoundError as Q, ConnectionRequestErrorCodes as R, ValidationError as S, ComposioToolkitNotFoundError as T, ComposioConnectedAccountNotRevokableError as U, ComposioAclOnlyForSharedError as V, ComposioConnectedAccountRevocationNotSupportedError as W, ConnectedAccountErrorCodes as X, ComposioSharedConnectionNotAccessibleError as Y, AuthConfigErrorCodes as Z, ComposioScopeConfigError as _, RemoteFileErrorCodes as a, JsonSchemaRefResolutionError as b, ComposioFailedToSubscribeToPusherChannelError as c, ComposioWebhookPayloadError as d, ComposioWebhookSignatureVerificationError as f, ComposioRequestCancelledError as g, ComposioNoAPIKeyError as h, RemoteFileDownloadError as i, ComposioProviderNotDefinedError as j, ComposioInvalidModifierError as k, ComposioFailedToUnsubscribeFromPusherChannelError as l, ComposioAPIKeyKindError as m, ComposioSessionConfigConflictError as n, ComposioFailedToCreatePusherClientError as o, TriggerErrorCodes as p, ComposioMultipleConnectedAccountsError as q, ToolRouterErrorCodes as r, ComposioFailedToGetSDKRealtimeCredentialsError as s, ComposioMCPDestinationError as t, ComposioTriggerTypeNotFoundError as u, SDKErrorCodes as v, ComposioToolkitFetchError as w, JsonSchemaToZodError as x, isRequestAbortError as y, ConnectionRequestFailedError as z };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { S as SessionContext, a as CreateCustomToolkitParams, c as CustomToolExecuteFn, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams } from "../customTool.types-
|
|
2
|
-
import { n as createCustomToolkit, t as createCustomTool } from "../CustomTool-
|
|
1
|
+
import { S as SessionContext, a as CreateCustomToolkitParams, c as CustomToolExecuteFn, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams } from "../customTool.types-C436M_D0.mjs";
|
|
2
|
+
import { n as createCustomToolkit, t as createCustomTool } from "../CustomTool-B3m-188G.mjs";
|
|
3
3
|
export { type CreateCustomToolParams, type CreateCustomToolkitParams, type CustomTool, type CustomToolExecuteFn, type CustomToolkit, type SessionContext, createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as createCustomToolkit, i as createCustomTool } from "../CustomTool-
|
|
1
|
+
import { a as createCustomToolkit, i as createCustomTool } from "../CustomTool-fYEFjSLM.mjs";
|
|
2
2
|
|
|
3
3
|
export { createCustomTool as experimental_createTool, createCustomToolkit as experimental_createToolkit };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as ComposioFileUploadPathNotAllowedError, t as ComposioFileNotFoundError } from "./FileModifierErrors-
|
|
3
|
-
import { a as readResponseBodyWithLimit, c as uint8ArrayToBase64, l as getRandomShortId, n as assertSafeFileUploadPath, s as base64ToUint8Array } from "./sensitiveFileUploadPaths-
|
|
4
|
-
import { r as ssrfSafeFetch } from "./ssrfGuard.node-
|
|
1
|
+
import { i as logger, o as COMPOSIO_DIR, u as TEMP_FILES_DIRECTORY_NAME } from "./SsrfErrors-DiQldIdC.mjs";
|
|
2
|
+
import { i as ComposioFileUploadPathNotAllowedError, t as ComposioFileNotFoundError } from "./FileModifierErrors-CdGSABoq.mjs";
|
|
3
|
+
import { a as readResponseBodyWithLimit, c as uint8ArrayToBase64, l as getRandomShortId, n as assertSafeFileUploadPath, s as base64ToUint8Array } from "./sensitiveFileUploadPaths-BlLp-Yo2.mjs";
|
|
4
|
+
import { r as ssrfSafeFetch } from "./ssrfGuard.node-BZ270bcu.mjs";
|
|
5
5
|
import { platform } from "#platform";
|
|
6
6
|
import fs from "node:fs";
|
|
7
7
|
import * as path from "node:path";
|