@composio/core 0.24.0 → 0.25.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-DZY1yLHN.d.mts} +1 -1
- package/dist/{cancellation-BQibgpRG.mjs → cancellation-D-tMPk48.mjs} +1 -1
- package/dist/{composio-BFTtZj82.d.mts → composio-B8AENilE.d.mts} +22 -10
- package/dist/{customTool.types-D57QrTns.d.mts → customTool.types-Bi6-keZC.d.mts} +326 -3
- 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 +11 -8
- package/dist/index.mjs +301 -143
- package/dist/{types-q8TwAngA.d.mts → types-BGDMkEUl.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 +4 -4
- package/src/composio.ts +19 -16
- package/src/errors/ToolRouterErrors.ts +5 -5
- package/src/lib/toolRouterParams.ts +28 -16
- package/src/models/ToolRouter.ts +5 -0
- package/src/models/ToolRouterSession.ts +17 -0
- package/src/models/Triggers.ts +8 -6
- package/src/services/pusher/Pusher.ts +159 -88
- package/src/types/pusher.types.ts +2 -0
- package/src/types/toolRouter.types.ts +103 -17
- package/src/utils/session.ts +25 -47
- package/src/utils/userCallback.ts +41 -0
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { c as DEFAULT_TOOL_ROUTER_SESSION_FILES_MOUNT_ID, d as USER_DATA_FILE_NAME, f as constants_exports, i as logger, l as IS_DEVELOPMENT_OR_CI, m as getEnvsWithPrefix, n as SsrfErrorCodes, o as COMPOSIO_DIR, p as getEnvVariable, r as ComposioError, s as DEFAULT_BASE_URL, t as ComposioBlockedInternalUrlError, u as TEMP_FILES_DIRECTORY_NAME } from "./SsrfErrors-DiQldIdC.mjs";
|
|
2
|
-
import { $ as ComposioAuthConfigNotFoundError, A as ComposioInvalidModifierError, B as ConnectionRequestFailedError, C as ValidationError, D as ToolkitErrorCodes, E as ComposioToolkitNotFoundError, F as ComposioToolNotFoundError, G as ComposioConnectedAccountRevocationNotSupportedError, H as ComposioAclOnlyForSharedError, I as ComposioToolVersionRequiredError, J as ComposioMultipleConnectedAccountsError, K as ComposioFailedToCreateConnectedAccountLink, L as ToolErrorCodes, M as ComposioProviderNotDefinedError, N as ComposioToolExecutionError, O as ComposioGlobalExecuteToolFnNotSetError, P as ComposioToolFetchError, Q as AuthConfigErrorCodes, R as handleToolExecutionError, S as JsonSchemaToZodError, T as ComposioToolkitFetchError, U as ComposioConnectedAccountNotFoundError, V as ConnectionRequestTimeoutError, W as ComposioConnectedAccountNotRevokableError, X as ComposioSharedConnectionNotAccessibleError, Y as ComposioSharedAccessDeniedError, Z as ConnectedAccountErrorCodes, _ as ComposioRequestCancelledError, a as RemoteFileDownloadError, b as isRequestAbortError, c as ComposioFailedToGetSDKRealtimeCredentialsError, d as ComposioTriggerTypeNotFoundError, f as ComposioWebhookPayloadError, g as ComposioNoAPIKeyError, h as ComposioAPIKeyKindError, i as ToolRouterErrorCodes, j as ComposioInvalidToolArgumentsError, k as ComposioInvalidExecuteFunctionError, l as ComposioFailedToSubscribeToPusherChannelError, m as TriggerErrorCodes, n as ComposioSessionConfigConflictError, o as RemoteFileErrorCodes, p as ComposioWebhookSignatureVerificationError, q as ComposioLegacyConnectedAccountsEndpointRetiredError, r as ComposioToolInputRequiredError, s as ComposioFailedToCreatePusherClientError, t as ComposioMCPDestinationError, u as ComposioFailedToUnsubscribeFromPusherChannelError, v as ComposioScopeConfigError, w as ValidationErrorCodes, x as JsonSchemaRefResolutionError, y as SDKErrorCodes, z as ConnectionRequestErrorCodes } from "./errors-
|
|
2
|
+
import { $ as ComposioAuthConfigNotFoundError, A as ComposioInvalidModifierError, B as ConnectionRequestFailedError, C as ValidationError, D as ToolkitErrorCodes, E as ComposioToolkitNotFoundError, F as ComposioToolNotFoundError, G as ComposioConnectedAccountRevocationNotSupportedError, H as ComposioAclOnlyForSharedError, I as ComposioToolVersionRequiredError, J as ComposioMultipleConnectedAccountsError, K as ComposioFailedToCreateConnectedAccountLink, L as ToolErrorCodes, M as ComposioProviderNotDefinedError, N as ComposioToolExecutionError, O as ComposioGlobalExecuteToolFnNotSetError, P as ComposioToolFetchError, Q as AuthConfigErrorCodes, R as handleToolExecutionError, S as JsonSchemaToZodError, T as ComposioToolkitFetchError, U as ComposioConnectedAccountNotFoundError, V as ConnectionRequestTimeoutError, W as ComposioConnectedAccountNotRevokableError, X as ComposioSharedConnectionNotAccessibleError, Y as ComposioSharedAccessDeniedError, Z as ConnectedAccountErrorCodes, _ as ComposioRequestCancelledError, a as RemoteFileDownloadError, b as isRequestAbortError, c as ComposioFailedToGetSDKRealtimeCredentialsError, d as ComposioTriggerTypeNotFoundError, f as ComposioWebhookPayloadError, g as ComposioNoAPIKeyError, h as ComposioAPIKeyKindError, i as ToolRouterErrorCodes, j as ComposioInvalidToolArgumentsError, k as ComposioInvalidExecuteFunctionError, l as ComposioFailedToSubscribeToPusherChannelError, m as TriggerErrorCodes, n as ComposioSessionConfigConflictError, o as RemoteFileErrorCodes, p as ComposioWebhookSignatureVerificationError, q as ComposioLegacyConnectedAccountsEndpointRetiredError, r as ComposioToolInputRequiredError, s as ComposioFailedToCreatePusherClientError, t as ComposioMCPDestinationError, u as ComposioFailedToUnsubscribeFromPusherChannelError, v as ComposioScopeConfigError, w as ValidationErrorCodes, x as JsonSchemaRefResolutionError, y as SDKErrorCodes, z as ConnectionRequestErrorCodes } from "./errors-Cly0vXFh.mjs";
|
|
3
3
|
import { a as ComposioSensitiveFilePathBlockedError, i as ComposioFileUploadPathNotAllowedError, n as ComposioFileUploadAbortedError, o as FileModifierErrorCodes, r as ComposioFileUploadError, t as ComposioFileNotFoundError } from "./FileModifierErrors-CdGSABoq.mjs";
|
|
4
4
|
import { n as dropEmptyFileUploads, o as isPlainObject, s as schemaHasFileUploadable } from "./FileToolModifier.utils.neutral-DWFpnsj2.mjs";
|
|
5
|
-
import { a as jsonSchemaToZodSchema, c as toStrictJsonSchema, i as ensureObjectTypeOnProperties, n as deduplicateJsonSchemaRequiredArrays, o as omitNullToolArguments, r as dereferenceJsonSchema, s as removeNonRequiredProperties, t as withCancellation } from "./cancellation-
|
|
5
|
+
import { a as jsonSchemaToZodSchema, c as toStrictJsonSchema, i as ensureObjectTypeOnProperties, n as deduplicateJsonSchemaRequiredArrays, o as omitNullToolArguments, r as dereferenceJsonSchema, s as removeNonRequiredProperties, t as withCancellation } from "./cancellation-D-tMPk48.mjs";
|
|
6
6
|
import { t as telemetry } from "./Telemetry-41JkqpZ7.mjs";
|
|
7
7
|
import { a as readResponseBodyWithLimit, i as MAX_URL_UPLOAD_SIZE_BYTES, l as getRandomShortId, n as assertSafeFileUploadPath, o as arrayBufferToBase64, r as isBlockedSensitiveFileUploadPath, t as BUILTIN_FILE_UPLOAD_PATH_DENY_SEGMENTS } from "./sensitiveFileUploadPaths-BlLp-Yo2.mjs";
|
|
8
|
-
import { a as createCustomToolkit, c as getPreloadedCustomToolSlugs, d as CreateCustomToolBaseSchema, f as CreateCustomToolkitBaseSchema, i as createCustomTool, l as serializeCustomToolkits, n as buildCustomToolsMap, o as findCustomToolMapEntryByFinalSlug, p as CustomToolSlugSchema, r as buildCustomToolsMapFromResponse, s as findCustomToolMapEntryByToolkitAndOriginalSlug, t as assertNoCustomToolSlugsInPreload, u as serializeCustomTools } from "./CustomTool-
|
|
9
|
-
import ComposioClient, { APIError, BadRequestError, ConflictError
|
|
8
|
+
import { a as createCustomToolkit, c as getPreloadedCustomToolSlugs, d as CreateCustomToolBaseSchema, f as CreateCustomToolkitBaseSchema, i as createCustomTool, l as serializeCustomToolkits, n as buildCustomToolsMap, o as findCustomToolMapEntryByFinalSlug, p as CustomToolSlugSchema, r as buildCustomToolsMapFromResponse, s as findCustomToolMapEntryByToolkitAndOriginalSlug, t as assertNoCustomToolSlugsInPreload, u as serializeCustomTools } from "./CustomTool-BYHB7sPs.mjs";
|
|
9
|
+
import ComposioClient, { APIError, BadRequestError, ConflictError } from "@composio/client";
|
|
10
10
|
import { FileToolModifier } from "#file_tool_modifier";
|
|
11
11
|
import z, { z as z$1 } from "zod/v3";
|
|
12
12
|
import { CONFIG_DEFAULTS } from "#config_defaults";
|
|
13
13
|
import { platform } from "#platform";
|
|
14
14
|
import semver from "semver";
|
|
15
15
|
import { Files } from "#files";
|
|
16
|
-
import
|
|
17
|
-
import { z as z$2 } from "zod";
|
|
16
|
+
import manifest from "#client_identity" with { type: "json" };
|
|
18
17
|
import { ssrfSafeFetch, ssrfSafeFetchWhereSupported } from "#ssrf_guard";
|
|
18
|
+
import { z as z$2 } from "zod";
|
|
19
19
|
|
|
20
20
|
//#region src/types/authConfigs.types.ts
|
|
21
21
|
const AuthConfigTypes = {
|
|
@@ -5518,6 +5518,47 @@ var InternalService = class {
|
|
|
5518
5518
|
}
|
|
5519
5519
|
};
|
|
5520
5520
|
|
|
5521
|
+
//#endregion
|
|
5522
|
+
//#region src/utils/userCallback.ts
|
|
5523
|
+
/**
|
|
5524
|
+
* Describes a thrown or rejected value for a log line without ever throwing.
|
|
5525
|
+
*
|
|
5526
|
+
* The logger serializes object arguments with `JSON.stringify`, which turns an `Error` into `{}`
|
|
5527
|
+
* and throws on a circular value, so callers log this string instead of the raw value.
|
|
5528
|
+
* `JSON.stringify` and `String()` can both throw (a circular value, an object without a
|
|
5529
|
+
* prototype), so each is tried in turn.
|
|
5530
|
+
*/
|
|
5531
|
+
function describeThrown(value) {
|
|
5532
|
+
try {
|
|
5533
|
+
if (value instanceof Error) return value.message;
|
|
5534
|
+
if (typeof value === "object" && value !== null) return JSON.stringify(value) ?? String(value);
|
|
5535
|
+
return String(value);
|
|
5536
|
+
} catch {
|
|
5537
|
+
try {
|
|
5538
|
+
return String(value);
|
|
5539
|
+
} catch {
|
|
5540
|
+
return "[unprintable value]";
|
|
5541
|
+
}
|
|
5542
|
+
}
|
|
5543
|
+
}
|
|
5544
|
+
/**
|
|
5545
|
+
* Calls a user-supplied event callback so that neither a synchronous throw nor a rejected promise
|
|
5546
|
+
* escapes into the event emitter that invoked it. Failures are logged after `label`.
|
|
5547
|
+
*
|
|
5548
|
+
* pusher-js does not catch listener exceptions, and nothing awaits the promise an `async`
|
|
5549
|
+
* listener returns, so an escaped failure would end a Node process.
|
|
5550
|
+
*/
|
|
5551
|
+
function invokeUserCallback(label, callback) {
|
|
5552
|
+
const logFailure = (error) => {
|
|
5553
|
+
logger.error(label, describeThrown(error));
|
|
5554
|
+
};
|
|
5555
|
+
try {
|
|
5556
|
+
Promise.resolve(callback()).catch(logFailure);
|
|
5557
|
+
} catch (error) {
|
|
5558
|
+
logFailure(error);
|
|
5559
|
+
}
|
|
5560
|
+
}
|
|
5561
|
+
|
|
5521
5562
|
//#endregion
|
|
5522
5563
|
//#region src/utils/sdk.ts
|
|
5523
5564
|
/**
|
|
@@ -5804,15 +5845,21 @@ function getToolkitVersionsFromEnv(defaultVersions) {
|
|
|
5804
5845
|
|
|
5805
5846
|
//#endregion
|
|
5806
5847
|
//#region src/services/pusher/Pusher.ts
|
|
5848
|
+
/**
|
|
5849
|
+
* Owns the realtime connection that delivers trigger events.
|
|
5850
|
+
*
|
|
5851
|
+
* Each subscription period gets its own pusher-js client, which `unsubscribe()` disconnects.
|
|
5852
|
+
* Reusing one client across periods is unsafe: pusher-js keeps a channel, its bound handlers and
|
|
5853
|
+
* its cancellation flag through `disconnect()` and resubscribes every kept channel on the next
|
|
5854
|
+
* `connect()`, and a channel-auth reply requested on the old socket can arrive after a reconnect
|
|
5855
|
+
* and be sent on the new one.
|
|
5856
|
+
*/
|
|
5807
5857
|
var PusherService = class {
|
|
5808
|
-
clientId;
|
|
5809
|
-
pusherKey;
|
|
5810
|
-
pusherCluster;
|
|
5811
|
-
pusherChannel;
|
|
5812
5858
|
pusherBaseURL;
|
|
5813
5859
|
authHeaders;
|
|
5814
|
-
pusherClient;
|
|
5815
5860
|
composioClient;
|
|
5861
|
+
attempt;
|
|
5862
|
+
connection;
|
|
5816
5863
|
constructor(client, options = {}) {
|
|
5817
5864
|
this.composioClient = client;
|
|
5818
5865
|
this.pusherBaseURL = client.baseURL;
|
|
@@ -5824,40 +5871,70 @@ var PusherService = class {
|
|
|
5824
5871
|
telemetry.instrument(this, "PusherService");
|
|
5825
5872
|
}
|
|
5826
5873
|
/**
|
|
5827
|
-
*
|
|
5828
|
-
*
|
|
5829
|
-
* This method is called when the Pusher client is first used.
|
|
5830
|
-
* It will fetch the SDK realtime credentials from the Apollo API and create a Pusher client.
|
|
5874
|
+
* Returns the connection attempt of the current subscription period, starting one if needed.
|
|
5875
|
+
* A failed attempt is forgotten, so the next `subscribe()` retries.
|
|
5831
5876
|
*/
|
|
5832
|
-
|
|
5833
|
-
if (
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
this.
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
throw new ComposioFailedToCreatePusherClientError("Failed to create Pusher client", { cause: error });
|
|
5858
|
-
}
|
|
5877
|
+
connect() {
|
|
5878
|
+
if (this.attempt) return this.attempt;
|
|
5879
|
+
const controller = new AbortController();
|
|
5880
|
+
const ready = this.openConnection(controller.signal);
|
|
5881
|
+
const attempt = {
|
|
5882
|
+
controller,
|
|
5883
|
+
ready
|
|
5884
|
+
};
|
|
5885
|
+
this.attempt = attempt;
|
|
5886
|
+
ready.catch(() => {
|
|
5887
|
+
if (this.attempt === attempt) this.attempt = void 0;
|
|
5888
|
+
});
|
|
5889
|
+
return attempt;
|
|
5890
|
+
}
|
|
5891
|
+
/**
|
|
5892
|
+
* Fetches the SDK realtime credentials from the Apollo API, creates a Pusher client and
|
|
5893
|
+
* subscribes it to the triggers channel.
|
|
5894
|
+
*/
|
|
5895
|
+
async openConnection(signal) {
|
|
5896
|
+
const internalService = new InternalService(this.composioClient);
|
|
5897
|
+
let sdkRealtimeCredentials;
|
|
5898
|
+
try {
|
|
5899
|
+
sdkRealtimeCredentials = await internalService.getSDKRealtimeCredentials();
|
|
5900
|
+
} catch (error) {
|
|
5901
|
+
throw new ComposioFailedToGetSDKRealtimeCredentialsError("Failed to get SDK realtime credentials", { cause: error });
|
|
5859
5902
|
}
|
|
5860
|
-
|
|
5903
|
+
const { projectId, pusherKey, pusherCluster } = sdkRealtimeCredentials;
|
|
5904
|
+
const channelName = `private-${projectId}_triggers`;
|
|
5905
|
+
let Pusher;
|
|
5906
|
+
try {
|
|
5907
|
+
({default: Pusher} = await import("pusher-js"));
|
|
5908
|
+
} catch (error) {
|
|
5909
|
+
throw new ComposioFailedToCreatePusherClientError("Failed to create Pusher client", { cause: error });
|
|
5910
|
+
}
|
|
5911
|
+
if (signal.aborted) throw new Error("Connection attempt cancelled by unsubscribe()");
|
|
5912
|
+
logger.debug(`[PusherService] Creating Pusher client for client ID: ${projectId} in cluster ${pusherCluster}`);
|
|
5913
|
+
let client;
|
|
5914
|
+
try {
|
|
5915
|
+
client = new Pusher(pusherKey, {
|
|
5916
|
+
cluster: pusherCluster,
|
|
5917
|
+
channelAuthorization: {
|
|
5918
|
+
endpoint: `${this.pusherBaseURL}/api/v3/internal/sdk/realtime/auth`,
|
|
5919
|
+
headers: { ...this.authHeaders },
|
|
5920
|
+
transport: "ajax"
|
|
5921
|
+
}
|
|
5922
|
+
});
|
|
5923
|
+
} catch (error) {
|
|
5924
|
+
throw new ComposioFailedToCreatePusherClientError("Failed to create Pusher client", { cause: error });
|
|
5925
|
+
}
|
|
5926
|
+
logger.debug(`[PusherService] Subscribing to channel: ${channelName}`);
|
|
5927
|
+
try {
|
|
5928
|
+
this.connection = {
|
|
5929
|
+
client,
|
|
5930
|
+
channel: client.subscribe(channelName),
|
|
5931
|
+
channelName
|
|
5932
|
+
};
|
|
5933
|
+
} catch (error) {
|
|
5934
|
+
client.disconnect();
|
|
5935
|
+
throw error;
|
|
5936
|
+
}
|
|
5937
|
+
return this.connection;
|
|
5861
5938
|
}
|
|
5862
5939
|
/**
|
|
5863
5940
|
* Binds a chunked event to a Pusher client
|
|
@@ -5905,42 +5982,42 @@ var PusherService = class {
|
|
|
5905
5982
|
/**
|
|
5906
5983
|
* Subscribes to pusher to receive events from the server
|
|
5907
5984
|
*
|
|
5908
|
-
*
|
|
5909
|
-
*
|
|
5985
|
+
* The first call of a subscription period creates the Pusher client; concurrent calls share
|
|
5986
|
+
* it. A call still waiting for the client when `unsubscribe()` runs resolves without
|
|
5987
|
+
* subscribing.
|
|
5910
5988
|
*
|
|
5911
|
-
* @param channelName - The name of the Pusher channel to subscribe to
|
|
5912
|
-
* @param event - The event to subscribe to
|
|
5913
5989
|
* @param fn - The function to call when the event is received
|
|
5914
5990
|
* @param onSubscriptionError - Optional callback invoked with the raw payload when the
|
|
5915
5991
|
* Pusher subscription fails (for example on auth or permission rejection). Errors thrown
|
|
5916
5992
|
* from — or promises rejected by — this callback are contained and logged, never rethrown.
|
|
5917
5993
|
*/
|
|
5918
5994
|
async subscribe(fn, onSubscriptionError) {
|
|
5995
|
+
const attempt = this.connect();
|
|
5996
|
+
let connection;
|
|
5919
5997
|
try {
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
}
|
|
5998
|
+
connection = await attempt.ready;
|
|
5999
|
+
} catch (error) {
|
|
6000
|
+
if (attempt.controller.signal.aborted) {
|
|
6001
|
+
logger.debug("[PusherService] Subscribe cancelled by unsubscribe() before it connected");
|
|
6002
|
+
return;
|
|
6003
|
+
}
|
|
6004
|
+
throw new ComposioFailedToSubscribeToPusherChannelError("Failed to subscribe to Pusher channel", { cause: error });
|
|
6005
|
+
}
|
|
6006
|
+
if (attempt.controller.signal.aborted) {
|
|
6007
|
+
logger.debug("[PusherService] Subscribe cancelled by unsubscribe() before it connected");
|
|
6008
|
+
return;
|
|
6009
|
+
}
|
|
6010
|
+
try {
|
|
6011
|
+
const { channel } = connection;
|
|
5926
6012
|
channel.bind("pusher:subscription_error", (data) => {
|
|
5927
6013
|
logger.error("Trigger subscription error:", data);
|
|
5928
|
-
|
|
5929
|
-
Promise.resolve(onSubscriptionError?.(data)).catch(logCallbackFailure);
|
|
5930
|
-
} catch (callbackError) {
|
|
5931
|
-
logCallbackFailure(callbackError);
|
|
5932
|
-
}
|
|
6014
|
+
invokeUserCallback("❌ Error in subscription error callback:", () => onSubscriptionError?.(data));
|
|
5933
6015
|
});
|
|
5934
6016
|
channel.bind("pusher:subscription_succeeded", () => {
|
|
5935
6017
|
logger.info(`✅ Subscribed to triggers. You should start receiving events now.`);
|
|
5936
6018
|
});
|
|
5937
6019
|
const safeCallback = (data) => {
|
|
5938
|
-
|
|
5939
|
-
fn(data);
|
|
5940
|
-
} catch (error) {
|
|
5941
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
5942
|
-
logger.error("❌ Error in trigger callback:", errorMessage);
|
|
5943
|
-
}
|
|
6020
|
+
invokeUserCallback("❌ Error in trigger callback:", () => fn(data));
|
|
5944
6021
|
};
|
|
5945
6022
|
this.bindWithChunking(channel, "trigger_to_client", safeCallback);
|
|
5946
6023
|
} catch (error) {
|
|
@@ -5948,21 +6025,31 @@ var PusherService = class {
|
|
|
5948
6025
|
}
|
|
5949
6026
|
}
|
|
5950
6027
|
/**
|
|
5951
|
-
* Unsubscribes from
|
|
5952
|
-
*
|
|
5953
|
-
* This method is used to unsubscribe from a Pusher channel.
|
|
5954
|
-
* It will create a Pusher client if it doesn't exist.
|
|
6028
|
+
* Unsubscribes from the triggers channel and closes the connection
|
|
5955
6029
|
*
|
|
5956
|
-
*
|
|
6030
|
+
* This ends the subscription period: setup still in flight is cancelled, the handlers bound by
|
|
6031
|
+
* every `subscribe()` call are removed, and the Pusher client is disconnected. Without a prior
|
|
6032
|
+
* `subscribe()` this does nothing; it never creates a client or fetches credentials.
|
|
5957
6033
|
*/
|
|
5958
6034
|
async unsubscribe() {
|
|
6035
|
+
const { attempt, connection } = this;
|
|
6036
|
+
this.attempt = void 0;
|
|
6037
|
+
this.connection = void 0;
|
|
6038
|
+
attempt?.controller.abort();
|
|
6039
|
+
if (!connection) {
|
|
6040
|
+
logger.debug("[PusherService] No open connection to unsubscribe from");
|
|
6041
|
+
return;
|
|
6042
|
+
}
|
|
6043
|
+
logger.debug(`[PusherService] Unsubscribing from channel: ${connection.channelName}`);
|
|
5959
6044
|
try {
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
logger.info(`✅ Unsubscribed from triggers.`);
|
|
6045
|
+
connection.channel.unbind_all();
|
|
6046
|
+
connection.client.unsubscribe(connection.channelName);
|
|
5963
6047
|
} catch (error) {
|
|
5964
6048
|
throw new ComposioFailedToSubscribeToPusherChannelError("Failed to unsubscribe from Pusher channel", { cause: error });
|
|
6049
|
+
} finally {
|
|
6050
|
+
connection.client.disconnect();
|
|
5965
6051
|
}
|
|
6052
|
+
logger.info(`✅ Unsubscribed from triggers.`);
|
|
5966
6053
|
}
|
|
5967
6054
|
};
|
|
5968
6055
|
|
|
@@ -6343,7 +6430,8 @@ var Triggers = class {
|
|
|
6343
6430
|
/**
|
|
6344
6431
|
* Subscribe to all the triggers
|
|
6345
6432
|
*
|
|
6346
|
-
* @param fn - The function to call when a trigger is received
|
|
6433
|
+
* @param fn - The function to call when a trigger is received. It may be `async`. Errors
|
|
6434
|
+
* thrown from — or promises rejected by — the function are contained and logged.
|
|
6347
6435
|
* @param filters - The filters to apply to the triggers
|
|
6348
6436
|
* @param onSubscriptionError - Optional callback invoked with the raw Pusher payload when
|
|
6349
6437
|
* the underlying subscription fails (for example on auth or permission rejection). The
|
|
@@ -6366,11 +6454,7 @@ var Triggers = class {
|
|
|
6366
6454
|
await this.pusherService.subscribe((_data) => {
|
|
6367
6455
|
logger.debug("Received raw trigger data", JSON.stringify(_data, null, 2));
|
|
6368
6456
|
const parsedData = this.parsePusherPayload(_data);
|
|
6369
|
-
if (this.shouldSendTriggerAfterFilters(parsedFilters.data, parsedData))
|
|
6370
|
-
fn(parsedData);
|
|
6371
|
-
} catch (error) {
|
|
6372
|
-
logger.error("❌ Error in trigger callback:", error);
|
|
6373
|
-
}
|
|
6457
|
+
if (this.shouldSendTriggerAfterFilters(parsedFilters.data, parsedData)) invokeUserCallback("❌ Error in trigger callback:", () => fn(parsedData));
|
|
6374
6458
|
else logger.debug("Trigger does not match filters", JSON.stringify(parsedFilters.data, null, 2));
|
|
6375
6459
|
}, onSubscriptionError);
|
|
6376
6460
|
}
|
|
@@ -6457,6 +6541,10 @@ var Triggers = class {
|
|
|
6457
6541
|
/**
|
|
6458
6542
|
* Unsubscribe from all the triggers
|
|
6459
6543
|
*
|
|
6544
|
+
* Ends every subscription made with {@link subscribe} on this instance, including one that is
|
|
6545
|
+
* still connecting, and closes the realtime connection so that a script can exit. A later
|
|
6546
|
+
* `subscribe()` opens a new connection.
|
|
6547
|
+
*
|
|
6460
6548
|
* @returns {Promise<void>}
|
|
6461
6549
|
*
|
|
6462
6550
|
* @example
|
|
@@ -7590,6 +7678,26 @@ const ToolRouterConfigManageConnectionsSchema = z.object({
|
|
|
7590
7678
|
const ToolRouterToolkitsParamSchema = z.array(z.string()).describe("List of toolkits to enable in the tool router session");
|
|
7591
7679
|
const ToolRouterToolkitsDisabledConfigSchema = z.object({ disable: ToolRouterToolkitsParamSchema.describe("List of toolkits to disable in the tool router session") }).strict();
|
|
7592
7680
|
const ToolRouterToolkitsEnabledConfigSchema = z.object({ enable: ToolRouterToolkitsParamSchema.describe("List of toolkits to enable in the tool router session") }).strict();
|
|
7681
|
+
/**
|
|
7682
|
+
* Toolkits whose tools need the user's approval before they run. A call that
|
|
7683
|
+
* needs approval doesn't run: `session.execute()` throws
|
|
7684
|
+
* `ComposioToolInputRequiredError` with the question to show the user.
|
|
7685
|
+
* @experimental
|
|
7686
|
+
*/
|
|
7687
|
+
const ToolRouterToolkitsRequireApprovalSchema = ToolRouterToolkitsParamSchema.describe("Experimental. Toolkits whose tools need the user approval before they run");
|
|
7688
|
+
/** Session toolkit policy: a list to enable, an enable/disable object, or only an approval list. */
|
|
7689
|
+
const ToolRouterSessionToolkitsSchema = z.union([
|
|
7690
|
+
ToolRouterToolkitsParamSchema,
|
|
7691
|
+
ToolRouterToolkitsDisabledConfigSchema.extend({ requireApproval: ToolRouterToolkitsRequireApprovalSchema.optional() }).strict(),
|
|
7692
|
+
ToolRouterToolkitsEnabledConfigSchema.extend({ requireApproval: ToolRouterToolkitsRequireApprovalSchema.optional() }).strict(),
|
|
7693
|
+
z.object({ requireApproval: ToolRouterToolkitsRequireApprovalSchema }).strict()
|
|
7694
|
+
]);
|
|
7695
|
+
/**
|
|
7696
|
+
* What happens to a call that needs the user's approval when the session's MCP
|
|
7697
|
+
* client can't ask the user.
|
|
7698
|
+
* @experimental
|
|
7699
|
+
*/
|
|
7700
|
+
const ToolRouterNoElicitationSupportFallbackSchema = z.enum(["deny", "allow"]).describe("Experimental. What happens to a call that needs approval when the MCP client cannot ask the user");
|
|
7593
7701
|
/** Experimental Instant usage policy for a Session. */
|
|
7594
7702
|
const ToolRouterInstantSchema = z.union([z.literal(false), z.object({
|
|
7595
7703
|
toolkits: z.union([ToolRouterToolkitsEnabledConfigSchema, ToolRouterToolkitsDisabledConfigSchema]).optional(),
|
|
@@ -7621,7 +7729,12 @@ const ToolRouterTagsParamSchema = z.array(z.enum([
|
|
|
7621
7729
|
])).describe("The tags to filter the tools by");
|
|
7622
7730
|
const ToolRouterTagsEnableDisableSchema = z.object({
|
|
7623
7731
|
enable: ToolRouterTagsParamSchema.optional().describe("The tags to enable in the tool router session"),
|
|
7624
|
-
disable: ToolRouterTagsParamSchema.optional().describe("The tags to disable in the tool router session")
|
|
7732
|
+
disable: ToolRouterTagsParamSchema.optional().describe("The tags to disable in the tool router session"),
|
|
7733
|
+
/**
|
|
7734
|
+
* Tools with any of these tags need the user's approval before they run.
|
|
7735
|
+
* @experimental
|
|
7736
|
+
*/
|
|
7737
|
+
requireApproval: ToolRouterTagsParamSchema.optional().describe("Experimental. Tools with any of these tags need the user approval before they run")
|
|
7625
7738
|
}).strict();
|
|
7626
7739
|
const ToolRouterConfigTagsSchema = z.union([ToolRouterTagsParamSchema, ToolRouterTagsEnableDisableSchema]).describe("The tags to use in the tool router session");
|
|
7627
7740
|
/**
|
|
@@ -7647,14 +7760,29 @@ const ToolRouterConfigTagsSchema = z.union([ToolRouterTagsParamSchema, ToolRoute
|
|
|
7647
7760
|
* ```
|
|
7648
7761
|
*/
|
|
7649
7762
|
const ToolRouterToolsParamSchema = z.array(z.string()).describe("The tools to use in the tool router session");
|
|
7763
|
+
/**
|
|
7764
|
+
* Tools of the toolkit that need the user's approval before they run.
|
|
7765
|
+
* @experimental
|
|
7766
|
+
*/
|
|
7767
|
+
const ToolRouterToolsRequireApprovalSchema = ToolRouterToolsParamSchema.describe("Experimental. Tools of this toolkit that need the user approval before they run");
|
|
7650
7768
|
const ToolRouterConfigToolsSchema = z.union([
|
|
7651
7769
|
ToolRouterToolsParamSchema,
|
|
7652
|
-
z.object({
|
|
7653
|
-
|
|
7654
|
-
|
|
7770
|
+
z.object({
|
|
7771
|
+
enable: ToolRouterToolsParamSchema.describe("The tools to enable in the tool router session"),
|
|
7772
|
+
requireApproval: ToolRouterToolsRequireApprovalSchema.optional()
|
|
7773
|
+
}).strict(),
|
|
7774
|
+
z.object({
|
|
7775
|
+
disable: ToolRouterToolsParamSchema.describe("The tools to disable in the tool router session"),
|
|
7776
|
+
requireApproval: ToolRouterToolsRequireApprovalSchema.optional()
|
|
7777
|
+
}).strict(),
|
|
7778
|
+
z.object({
|
|
7779
|
+
tags: ToolRouterConfigTagsSchema.describe("The tags to filter the tools by, this will override the global tags"),
|
|
7780
|
+
requireApproval: ToolRouterToolsRequireApprovalSchema.optional()
|
|
7781
|
+
}).strict(),
|
|
7782
|
+
z.object({ requireApproval: ToolRouterToolsRequireApprovalSchema }).strict()
|
|
7655
7783
|
]).superRefine((val, ctx) => {
|
|
7656
7784
|
if (typeof val === "object" && !Array.isArray(val)) {
|
|
7657
|
-
const keys = Object.keys(val);
|
|
7785
|
+
const keys = Object.keys(val).filter((key) => key !== "requireApproval");
|
|
7658
7786
|
if (keys.length > 1) ctx.addIssue({
|
|
7659
7787
|
code: z.ZodIssueCode.custom,
|
|
7660
7788
|
message: `Only one of 'enable', 'disable', or 'tags' can be specified, but found: ${keys.join(", ")}`,
|
|
@@ -7679,11 +7807,7 @@ const ToolRouterCreateSessionConfigBaseSchema = z.object({
|
|
|
7679
7807
|
mcp: z.boolean().optional().describe("When true, the returned session surfaces its hosted MCP endpoint (`session.mcp.url` / `session.mcp.headers`) in the type, and an MCP URL that is not on the API base URL origin throws `ComposioMCPDestinationError` instead of leaving `session.mcp.headers` empty with a warning. The endpoint exists on every session at runtime regardless of this flag, but is only typed when `mcp: true` is passed. Default native tools (`session.tools()`) are unaffected. See https://docs.composio.dev/docs/sessions-via-mcp"),
|
|
7680
7808
|
tools: z.record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema])).optional().describe("The tools to use in the tool router session"),
|
|
7681
7809
|
tags: ToolRouterConfigTagsSchema.optional().describe("Global tags to filter the tools by"),
|
|
7682
|
-
toolkits:
|
|
7683
|
-
ToolRouterToolkitsParamSchema,
|
|
7684
|
-
ToolRouterToolkitsDisabledConfigSchema,
|
|
7685
|
-
ToolRouterToolkitsEnabledConfigSchema
|
|
7686
|
-
]).optional().describe("The toolkits to use in the tool router session"),
|
|
7810
|
+
toolkits: ToolRouterSessionToolkitsSchema.optional().describe("The toolkits to use in the tool router session"),
|
|
7687
7811
|
instant: ToolRouterInstantSchema.optional().describe("Experimental Instant usage policy. Omission permits eligible tools when the project allows Instant usage; false disables it for this Session."),
|
|
7688
7812
|
authConfigs: z.record(z.string(), z.string()).describe("The auth configs to use in the tool router session. The key is the toolkit slug, the value is the auth config id.").default({}),
|
|
7689
7813
|
connectedAccounts: z.record(z.string(), z.union([z.string(), z.array(z.string())])).describe("The connected accounts to use in the tool router session. The key is the toolkit slug, the value is a connected account id or an array of ids. Only one account per toolkit is allowed when multi-account mode is disabled.").default({}),
|
|
@@ -7701,7 +7825,14 @@ const ToolRouterCreateSessionConfigBaseSchema = z.object({
|
|
|
7701
7825
|
assistivePrompt: z.object({ userTimezone: z.string().optional().describe("IANA timezone identifier (e.g., \"America/New_York\", \"Europe/London\") for timezone-aware assistive prompts") }).optional().describe("Configuration for assistive prompt generation"),
|
|
7702
7826
|
customTools: z.array(z.custom()).optional().describe("Custom tools to include in this session. Created via createCustomTool() from @composio/core/experimental."),
|
|
7703
7827
|
customToolkits: z.array(z.custom()).optional().describe("Custom toolkits to include in this session. Created via createCustomToolkit() from @composio/core/experimental."),
|
|
7704
|
-
sessionConfigId: z.string().min(1).optional().describe("ID of a saved Session config (`sc_…`) to apply when the session is created. Cannot be combined with toolkits, tools, tags, customTools or customToolkits.")
|
|
7828
|
+
sessionConfigId: z.string().min(1).optional().describe("ID of a saved Session config (`sc_…`) to apply when the session is created. Cannot be combined with toolkits, tools, tags, customTools or customToolkits."),
|
|
7829
|
+
/**
|
|
7830
|
+
* What happens to a call that needs the user's approval when the
|
|
7831
|
+
* session's MCP client can't ask the user: `deny` (the default) or
|
|
7832
|
+
* `allow`.
|
|
7833
|
+
* @experimental
|
|
7834
|
+
*/
|
|
7835
|
+
noElicitationSupportFallback: ToolRouterNoElicitationSupportFallbackSchema.optional()
|
|
7705
7836
|
}).optional().describe("Experimental features configuration - not stable, may be modified or removed")
|
|
7706
7837
|
}).partial().superRefine((config, ctx) => {
|
|
7707
7838
|
if (config.experimental?.sessionConfigId !== void 0) addSessionConfigConflictIssue(ctx, [
|
|
@@ -7908,6 +8039,12 @@ const ToolRouterUpdateExperimentalSchema = z.object({
|
|
|
7908
8039
|
linkUrlOverwrite: z.string().nullable().optional().describe("Base URL override for connection link redirects. `null` removes the stored override"),
|
|
7909
8040
|
fastMode: z.boolean().nullable().optional().describe("Fast search mode. `null` removes the stored override"),
|
|
7910
8041
|
submitFeedback: z.object({ enable: z.boolean() }).strict().nullable().optional().describe("Exposes the COMPOSIO_SUBMIT_FEEDBACK helper tool. `null` removes the stored block"),
|
|
8042
|
+
/**
|
|
8043
|
+
* What happens to a call that needs the user's approval when the session's
|
|
8044
|
+
* MCP client can't ask the user: `deny` or `allow`.
|
|
8045
|
+
* @experimental
|
|
8046
|
+
*/
|
|
8047
|
+
noElicitationSupportFallback: ToolRouterNoElicitationSupportFallbackSchema.optional(),
|
|
7911
8048
|
sessionConfigId: z.string().min(1).optional().describe("Apply the latest active saved Session config (`sc_…`) from this project to this session. Replaces the session's toolkit, tool and tag access and cannot be combined with toolkits, tools or tags")
|
|
7912
8049
|
}).strict();
|
|
7913
8050
|
/**
|
|
@@ -7918,11 +8055,7 @@ const ToolRouterUpdateExperimentalSchema = z.object({
|
|
|
7918
8055
|
*/
|
|
7919
8056
|
const ToolRouterUpdateSessionConfigSchema = z.object({
|
|
7920
8057
|
instant: ToolRouterInstantSchema.optional().describe("Experimental Instant usage policy. False disables it. Any supplied object, even one that only sets returnInstantCharge, re-enables it. Omitted subfields keep their stored values."),
|
|
7921
|
-
toolkits:
|
|
7922
|
-
ToolRouterToolkitsParamSchema,
|
|
7923
|
-
ToolRouterToolkitsDisabledConfigSchema,
|
|
7924
|
-
ToolRouterToolkitsEnabledConfigSchema
|
|
7925
|
-
]).nullable().optional().describe("Toolkit policy. An empty allowlist (`[]` or `{ enable: [] }`) is sent as-is and denies every app toolkit; `null` removes the stored policy and restores the unrestricted default"),
|
|
8058
|
+
toolkits: ToolRouterSessionToolkitsSchema.nullable().optional().describe("Toolkit policy. An empty allowlist (`[]` or `{ enable: [] }`) is sent as-is and denies every app toolkit; `null` removes the stored policy and restores the unrestricted default"),
|
|
7926
8059
|
tools: z.record(z.string(), z.union([ToolRouterToolsParamSchema, ToolRouterConfigToolsSchema])).nullable().optional().describe("Replaces the entire stored tools map; `null` removes the override"),
|
|
7927
8060
|
tags: ToolRouterConfigTagsSchema.nullable().optional().describe("Replaces the global tag policy; `null` removes the override"),
|
|
7928
8061
|
authConfigs: z.record(z.string(), z.string()).nullable().optional().describe("Replaces the entire stored auth config map; `null` removes the override"),
|
|
@@ -8550,7 +8683,7 @@ var OpenAIProvider = class extends BaseNonAgenticProvider {
|
|
|
8550
8683
|
|
|
8551
8684
|
//#endregion
|
|
8552
8685
|
//#region package.json
|
|
8553
|
-
var version = "0.
|
|
8686
|
+
var version = "0.25.0";
|
|
8554
8687
|
|
|
8555
8688
|
//#endregion
|
|
8556
8689
|
//#region src/utils/session.ts
|
|
@@ -8575,44 +8708,35 @@ function detectRuntime() {
|
|
|
8575
8708
|
return "UNKNOWN";
|
|
8576
8709
|
}
|
|
8577
8710
|
const RUNTIME_ENV = detectRuntime();
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
const
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8711
|
+
/**
|
|
8712
|
+
* An identity value is sent as a header, so the client accepts only non-empty
|
|
8713
|
+
* printable ASCII with no leading or trailing whitespace.
|
|
8714
|
+
*/
|
|
8715
|
+
const HEADER_SAFE = /^[\x21-\x7e](?:[\x20-\x7e]*[\x21-\x7e])?$/;
|
|
8716
|
+
/**
|
|
8717
|
+
* The identity the API client reports for this SDK: its product headers
|
|
8718
|
+
* (`x-client-provenance`, `x-client-version`, `x-sdk-version`) and the legacy
|
|
8719
|
+
* `x-source`, `x-framework` and `x-runtime` labels. The client adds the
|
|
8720
|
+
* library headers and detects the runtime and its version itself.
|
|
8721
|
+
*
|
|
8722
|
+
* A custom provider whose name cannot be sent as a header value is reported
|
|
8723
|
+
* as `unknown` rather than making the SDK fail to construct.
|
|
8724
|
+
*/
|
|
8725
|
+
function getClientIdentity(provider) {
|
|
8726
|
+
const framework = provider?.name;
|
|
8592
8727
|
return {
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
"
|
|
8596
|
-
|
|
8597
|
-
|
|
8598
|
-
"x-client-provenance": identity.name,
|
|
8599
|
-
"x-client-version": identity.version,
|
|
8600
|
-
"x-client-language": "typescript",
|
|
8601
|
-
"x-client-library": "@composio/client",
|
|
8602
|
-
"x-client-library-version": VERSION,
|
|
8603
|
-
...RUNTIME_VERSION ? { "x-runtime-version": RUNTIME_VERSION } : {}
|
|
8728
|
+
product: manifest.name,
|
|
8729
|
+
version: manifest.version,
|
|
8730
|
+
source: "TYPESCRIPT_SDK",
|
|
8731
|
+
framework: framework && HEADER_SAFE.test(framework) ? framework : "unknown",
|
|
8732
|
+
runtime: RUNTIME_ENV
|
|
8604
8733
|
};
|
|
8605
8734
|
}
|
|
8606
|
-
const getDefaultHeaders = (headers, provider) => {
|
|
8607
|
-
const sessionHeaders = getSessionHeaders(provider);
|
|
8608
|
-
return {
|
|
8609
|
-
...headers || {},
|
|
8610
|
-
...sessionHeaders
|
|
8611
|
-
};
|
|
8612
|
-
};
|
|
8613
8735
|
|
|
8614
8736
|
//#endregion
|
|
8615
8737
|
//#region src/lib/toolRouterParams.ts
|
|
8738
|
+
/** `require_approval` when the caller set an approval list, nothing otherwise. */
|
|
8739
|
+
const requireApprovalParam = (requireApproval) => requireApproval !== void 0 ? { require_approval: requireApproval } : {};
|
|
8616
8740
|
const transformToolRouterToolsParams = (params) => {
|
|
8617
8741
|
if (!params) return;
|
|
8618
8742
|
if (typeof params === "object") return Object.keys(params).reduce((acc, key) => {
|
|
@@ -8622,12 +8746,21 @@ const transformToolRouterToolsParams = (params) => {
|
|
|
8622
8746
|
if (parsedResult.success) {
|
|
8623
8747
|
const data = parsedResult.data;
|
|
8624
8748
|
if (Array.isArray(data)) acc[key] = { enable: data };
|
|
8625
|
-
else if ("enable" in data) acc[key] = {
|
|
8626
|
-
|
|
8749
|
+
else if ("enable" in data) acc[key] = {
|
|
8750
|
+
enable: data.enable,
|
|
8751
|
+
...requireApprovalParam(data.requireApproval)
|
|
8752
|
+
};
|
|
8753
|
+
else if ("disable" in data) acc[key] = {
|
|
8754
|
+
disable: data.disable,
|
|
8755
|
+
...requireApprovalParam(data.requireApproval)
|
|
8756
|
+
};
|
|
8627
8757
|
else if ("tags" in data) {
|
|
8628
8758
|
const tags = transformToolRouterTagsParams(data.tags);
|
|
8629
|
-
if (tags) acc[key] = {
|
|
8630
|
-
|
|
8759
|
+
if (tags) acc[key] = {
|
|
8760
|
+
tags,
|
|
8761
|
+
...requireApprovalParam(data.requireApproval)
|
|
8762
|
+
};
|
|
8763
|
+
} else acc[key] = { require_approval: data.requireApproval };
|
|
8631
8764
|
} else throw new ValidationError(parsedResult.error.message);
|
|
8632
8765
|
} else acc[key] = { enable: params[key] };
|
|
8633
8766
|
return acc;
|
|
@@ -8638,7 +8771,8 @@ const transformToolRouterTagsParams = (params) => {
|
|
|
8638
8771
|
if (Array.isArray(params)) return { enable: params };
|
|
8639
8772
|
else if (typeof params === "object") return {
|
|
8640
8773
|
enable: params.enable,
|
|
8641
|
-
disable: params.disable
|
|
8774
|
+
disable: params.disable,
|
|
8775
|
+
...requireApprovalParam(params.requireApproval)
|
|
8642
8776
|
};
|
|
8643
8777
|
};
|
|
8644
8778
|
const transformToolRouterManageConnectionsParams = (params) => {
|
|
@@ -8696,6 +8830,7 @@ const transformToolRouterUpdateExperimentalParams = (config) => {
|
|
|
8696
8830
|
if (config.fastMode !== void 0) result.fast_mode = config.fastMode;
|
|
8697
8831
|
if (config.submitFeedback !== void 0) result.submit_feedback = config.submitFeedback;
|
|
8698
8832
|
if (config.sessionConfigId !== void 0) result.session_config_id = config.sessionConfigId;
|
|
8833
|
+
if (config.noElicitationSupportFallback !== void 0) result.no_elicitation_support_fallback = config.noElicitationSupportFallback;
|
|
8699
8834
|
return result;
|
|
8700
8835
|
};
|
|
8701
8836
|
/**
|
|
@@ -8723,7 +8858,15 @@ const transformToolRouterMultiAccountParams = (params) => {
|
|
|
8723
8858
|
const transformToolRouterToolkitsParams = (params) => {
|
|
8724
8859
|
if (!params) return;
|
|
8725
8860
|
if (Array.isArray(params)) return { enable: params };
|
|
8726
|
-
return
|
|
8861
|
+
if ("enable" in params) return {
|
|
8862
|
+
enable: params.enable,
|
|
8863
|
+
...requireApprovalParam(params.requireApproval)
|
|
8864
|
+
};
|
|
8865
|
+
if ("disable" in params) return {
|
|
8866
|
+
disable: params.disable,
|
|
8867
|
+
...requireApprovalParam(params.requireApproval)
|
|
8868
|
+
};
|
|
8869
|
+
return { require_approval: params.requireApproval };
|
|
8727
8870
|
};
|
|
8728
8871
|
/**
|
|
8729
8872
|
* Request body of `session.update()`. Every key present in `config` is sent,
|
|
@@ -9781,6 +9924,13 @@ async function deleteToolRouterSession(client, sessionId, requestOptions) {
|
|
|
9781
9924
|
//#endregion
|
|
9782
9925
|
//#region src/models/ToolRouterSession.ts
|
|
9783
9926
|
const COMPOSIO_MULTI_EXECUTE_TOOL = "COMPOSIO_MULTI_EXECUTE_TOOL";
|
|
9927
|
+
/** The request fields that carry the user's answers to an earlier `input_required` call. */
|
|
9928
|
+
function inputResponseParams(options) {
|
|
9929
|
+
return {
|
|
9930
|
+
...options?.inputResponses !== void 0 && { input_responses: options.inputResponses },
|
|
9931
|
+
...options?.requestState !== void 0 && { request_state: options.requestState }
|
|
9932
|
+
};
|
|
9933
|
+
}
|
|
9784
9934
|
const DIRECT_CUSTOM_TOOL_DESCRIPTION_PREFIX = "[Direct tool - call directly, no search needed beforehand.]";
|
|
9785
9935
|
/**
|
|
9786
9936
|
* Options accepted by {@link ToolRouterSession.authorize}.
|
|
@@ -10168,6 +10318,8 @@ var ToolRouterSession = class {
|
|
|
10168
10318
|
* @param arguments_ - Optional tool arguments
|
|
10169
10319
|
* @param options - Optional execution options
|
|
10170
10320
|
* @param options.account - Account identifier for direct app tool execution. Accepted on every project: in multi-account sessions it picks the account; on single-account projects it must match one of the session's active connections for the toolkit. Helper/meta tools either ignore this top-level field or define their own account-selection fields.
|
|
10321
|
+
* @param options.inputResponses - Experimental. The user's answers to an earlier `ComposioToolInputRequiredError`, keyed by the IDs in its `inputRequests`. Repeat the same call with them.
|
|
10322
|
+
* @param options.requestState - Experimental. The `requestState` of that error, sent back unchanged.
|
|
10171
10323
|
* @returns The tool execution result
|
|
10172
10324
|
* @throws {ComposioToolInputRequiredError} If the tool needs input from the user (for example an approval) before it can run
|
|
10173
10325
|
*/
|
|
@@ -10186,7 +10338,8 @@ var ToolRouterSession = class {
|
|
|
10186
10338
|
assertUnambiguousCustomToolSlug(this.customToolsMap, toolSlug);
|
|
10187
10339
|
const executeParams = {
|
|
10188
10340
|
tool_slug: toolSlug,
|
|
10189
|
-
arguments: arguments_ ?? {}
|
|
10341
|
+
arguments: arguments_ ?? {},
|
|
10342
|
+
...inputResponseParams(options)
|
|
10190
10343
|
};
|
|
10191
10344
|
if (options?.account) executeParams.account = options.account;
|
|
10192
10345
|
const experimental = inlineCustomToolsExperimental(this.inlineCustomToolsPayload);
|
|
@@ -10205,6 +10358,7 @@ var ToolRouterSession = class {
|
|
|
10205
10358
|
*
|
|
10206
10359
|
* @param slug - The meta tool slug to execute
|
|
10207
10360
|
* @param arguments_ - Optional meta tool arguments
|
|
10361
|
+
* @param options - Experimental. The user's answers to an earlier `ComposioToolInputRequiredError` (`inputResponses`) and its `requestState`, as in `session.execute()`
|
|
10208
10362
|
* @returns The tool execution result, in the same shape as `session.execute()`
|
|
10209
10363
|
* @throws {ComposioToolInputRequiredError} If the tool needs input from the user (for example an approval) before it can run
|
|
10210
10364
|
*
|
|
@@ -10215,10 +10369,11 @@ var ToolRouterSession = class {
|
|
|
10215
10369
|
* });
|
|
10216
10370
|
* ```
|
|
10217
10371
|
*/
|
|
10218
|
-
async executeMeta(slug, arguments_, requestOptions) {
|
|
10372
|
+
async executeMeta(slug, arguments_, options, requestOptions) {
|
|
10219
10373
|
const executeMetaParams = {
|
|
10220
10374
|
slug,
|
|
10221
|
-
arguments: arguments_ ?? {}
|
|
10375
|
+
arguments: arguments_ ?? {},
|
|
10376
|
+
...inputResponseParams(options)
|
|
10222
10377
|
};
|
|
10223
10378
|
const experimental = inlineCustomToolsExperimental(this.inlineCustomToolsPayload);
|
|
10224
10379
|
if (experimental) executeMetaParams.experimental = experimental;
|
|
@@ -10565,6 +10720,7 @@ var ToolRouter = class {
|
|
|
10565
10720
|
});
|
|
10566
10721
|
const experimentalPayload = {};
|
|
10567
10722
|
if (routerConfig.experimental?.sessionConfigId !== void 0) experimentalPayload.session_config_id = routerConfig.experimental.sessionConfigId;
|
|
10723
|
+
if (routerConfig.experimental?.noElicitationSupportFallback !== void 0) experimentalPayload.no_elicitation_support_fallback = routerConfig.experimental.noElicitationSupportFallback;
|
|
10568
10724
|
if (routerConfig.experimental?.assistivePrompt?.userTimezone) experimentalPayload.assistive_prompt_config = { user_timezone: routerConfig.experimental.assistivePrompt.userTimezone };
|
|
10569
10725
|
if (inlineCustomToolsPayload?.custom_tools) experimentalPayload.custom_tools = inlineCustomToolsPayload.custom_tools;
|
|
10570
10726
|
if (inlineCustomToolsPayload?.custom_toolkits) experimentalPayload.custom_toolkits = inlineCustomToolsPayload.custom_toolkits;
|
|
@@ -10884,13 +11040,14 @@ var Composio = class Composio {
|
|
|
10884
11040
|
orgId: scope.orgId,
|
|
10885
11041
|
projectId: scope.projectId
|
|
10886
11042
|
};
|
|
10887
|
-
const defaultHeaders =
|
|
11043
|
+
const defaultHeaders = {
|
|
10888
11044
|
...this.config.defaultHeaders,
|
|
10889
11045
|
...getScopeHeaders(scope)
|
|
10890
|
-
}
|
|
11046
|
+
};
|
|
10891
11047
|
/**
|
|
10892
11048
|
* Initialize the Composio SDK client.
|
|
10893
|
-
* The client is used to make API calls to the Composio API.
|
|
11049
|
+
* The client is used to make API calls to the Composio API. It sends the
|
|
11050
|
+
* SDK's identity headers from `identity`, and refuses them in `defaultHeaders`.
|
|
10894
11051
|
*/
|
|
10895
11052
|
this.client = new ComposioClient({
|
|
10896
11053
|
apiKey: apiKeyParsed,
|
|
@@ -10898,6 +11055,7 @@ var Composio = class Composio {
|
|
|
10898
11055
|
orgApiKey: config?.orgApiKey,
|
|
10899
11056
|
baseURL: baseURLParsed,
|
|
10900
11057
|
defaultHeaders,
|
|
11058
|
+
identity: getClientIdentity(this.provider),
|
|
10901
11059
|
logger: clientLoggerAdapter,
|
|
10902
11060
|
logLevel: toClientLogLevel(logger.getLevel())
|
|
10903
11061
|
});
|
|
@@ -10981,8 +11139,8 @@ var Composio = class Composio {
|
|
|
10981
11139
|
* instance directly with the headers you need: `new Composio({ ...existingConfig, defaultHeaders })`.
|
|
10982
11140
|
* For one-off overrides, pass per-call `requestOptions` where supported.
|
|
10983
11141
|
*
|
|
10984
|
-
* @param {
|
|
10985
|
-
*
|
|
11142
|
+
* @param {object} [options] - Options for the new instance.
|
|
11143
|
+
* @param {ComposioRequestHeaders} [options.headers] - Headers sent with every API call the new instance makes.
|
|
10986
11144
|
* @returns {Composio<TProvider>} A new Composio instance with the custom request options applied.
|
|
10987
11145
|
*
|
|
10988
11146
|
* @example
|
|
@@ -11007,10 +11165,10 @@ var Composio = class Composio {
|
|
|
11007
11165
|
*/
|
|
11008
11166
|
createSession(options) {
|
|
11009
11167
|
const userApiKeyHeader = getUserApiKeyHeader(options?.headers) ? void 0 : getUserApiKeyHeader(this.config.defaultHeaders);
|
|
11010
|
-
const sessionHeaders =
|
|
11168
|
+
const sessionHeaders = userApiKeyHeader ? {
|
|
11011
11169
|
[userApiKeyHeader.name]: userApiKeyHeader.value,
|
|
11012
11170
|
...options?.headers
|
|
11013
|
-
} : options?.headers
|
|
11171
|
+
} : options?.headers;
|
|
11014
11172
|
return new Composio({
|
|
11015
11173
|
...this.config,
|
|
11016
11174
|
defaultHeaders: sessionHeaders
|