@composio/core 0.20.0 → 0.22.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-fYEFjSLM.mjs → CustomTool-B-_VjWpy.mjs} +1 -1
- package/dist/{CustomTool-B3m-188G.d.mts → CustomTool-CKBCElpT.d.mts} +1 -1
- package/dist/{Telemetry-JRJJYS4I.mjs → Telemetry-41JkqpZ7.mjs} +3 -2
- package/dist/{cancellation-Dwa9lGHA.mjs → cancellation-DV8CIi52.mjs} +1 -1
- package/dist/{composio-B36OXii1.d.mts → composio-C-418N1P.d.mts} +542 -168
- package/dist/{customTool.types-C436M_D0.d.mts → customTool.types-CK408sI-.d.mts} +522 -66
- package/dist/docs/reference/sdk-reference/typescript/composio.mdx +2 -1
- package/dist/docs/reference/sdk-reference/typescript/index.mdx +1 -0
- package/dist/docs/reference/sdk-reference/typescript/meta.json +1 -0
- package/dist/docs/reference/sdk-reference/typescript/session-configs.mdx +83 -0
- package/dist/docs/reference/sdk-reference/typescript/session.mdx +29 -20
- package/dist/docs/reference/sdk-reference/typescript/sessions.mdx +10 -4
- package/dist/{errors-D_A4b2c2.mjs → errors-Dyiu3ifQ.mjs} +10 -6
- package/dist/experimental/index.d.mts +2 -2
- package/dist/experimental/index.mjs +1 -1
- package/dist/index.d.mts +40 -28
- package/dist/index.mjs +6815 -6571
- package/dist/models/Files.node.mjs +1 -1
- package/dist/{types-Br3GBya5.d.mts → types-RpMRVn4D.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 -3
- package/src/composio.ts +8 -0
- package/src/errors/ToolRouterErrors.ts +10 -6
- package/src/index.ts +2 -0
- package/src/lib/sessionConfigConflict.ts +43 -0
- package/src/lib/toolRouterParams.ts +43 -10
- package/src/lib/toolRouterSourceSessionConfig.ts +12 -0
- package/src/models/AuthConfigs.ts +0 -9
- package/src/models/ConnectionRequest.ts +21 -18
- package/src/models/Logs.ts +2 -2
- package/src/models/RemoteFile.ts +25 -8
- package/src/models/SessionConfigs.ts +117 -0
- package/src/models/ToolRouter.ts +23 -5
- package/src/models/ToolRouterSession.ts +49 -24
- package/src/models/Tools.ts +7 -5
- package/src/models/Usage.ts +2 -1
- package/src/provider/OpenAIProvider.ts +0 -283
- package/src/telemetry/Telemetry.ts +4 -2
- package/src/types/logs.types.ts +9 -1
- package/src/types/sessionConfigs.types.ts +81 -0
- package/src/types/tool.types.ts +3 -1
- package/src/types/toolRouter.types.ts +177 -13
- package/src/types/usage.types.ts +2 -0
- package/src/utils/safePath.ts +172 -0
- package/src/utils/transformers/logs.ts +3 -2
- package/src/utils/transformers/sessionConfigs.ts +54 -0
- package/src/utils/transformers/toolRouterResponseTransform.ts +24 -0
- package/src/utils/transformers/usage.ts +4 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The `composio.sessionConfigs` namespace: read the saved
|
|
3
|
+
* Session configs of the project.
|
|
4
|
+
*
|
|
5
|
+
* @module SessionConfigs
|
|
6
|
+
*/
|
|
7
|
+
import ComposioClient from '@composio/client';
|
|
8
|
+
import {
|
|
9
|
+
SessionConfig,
|
|
10
|
+
SessionConfigListParams,
|
|
11
|
+
SessionConfigListParamsSchema,
|
|
12
|
+
SessionConfigListResponse,
|
|
13
|
+
} from '../types/sessionConfigs.types';
|
|
14
|
+
import { ComposioRequestOptions } from '../types/requestOptions.types';
|
|
15
|
+
import { ValidationError } from '../errors/ValidationErrors';
|
|
16
|
+
import { telemetry } from '../telemetry/Telemetry';
|
|
17
|
+
import { withCancellation } from '../utils/cancellation';
|
|
18
|
+
import {
|
|
19
|
+
transformSessionConfig,
|
|
20
|
+
transformSessionConfigListResponse,
|
|
21
|
+
} from '../utils/transformers/sessionConfigs';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* `composio.sessionConfigs` — saved, reusable Session configs.
|
|
25
|
+
*
|
|
26
|
+
* A Session config is a named access policy (`sc_…`) built in the Composio
|
|
27
|
+
* Dashboard under Sessions → Configs. Pass its id as
|
|
28
|
+
* `experimental.sessionConfigId` to `composio.sessions.create()` or
|
|
29
|
+
* `session.update()` to apply it.
|
|
30
|
+
*
|
|
31
|
+
* These endpoints require Session configs to be enabled for the project;
|
|
32
|
+
* otherwise the backend returns 403.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const { items } = await composio.sessionConfigs.list({ search: 'support' });
|
|
37
|
+
* const sessionConfig = await composio.sessionConfigs.get(items[0].id);
|
|
38
|
+
* const session = await composio.sessions.create('user_123', {
|
|
39
|
+
* experimental: { sessionConfigId: sessionConfig.id },
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export class SessionConfigs {
|
|
44
|
+
private client: ComposioClient;
|
|
45
|
+
|
|
46
|
+
constructor(client: ComposioClient) {
|
|
47
|
+
this.client = client;
|
|
48
|
+
telemetry.instrument(this, 'SessionConfigs');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* List the project's saved Session configs with cursor pagination.
|
|
53
|
+
*
|
|
54
|
+
* Omitting `archived` returns active configs; `archived: true` returns only
|
|
55
|
+
* archived ones. The backend defaults `limit` to 20 and caps it at 100.
|
|
56
|
+
*
|
|
57
|
+
* Requires Session configs to be enabled for the project.
|
|
58
|
+
*
|
|
59
|
+
* @param {SessionConfigListParams} [params] - `search`, `archived`, `limit` and `cursor`
|
|
60
|
+
* @returns {Promise<SessionConfigListResponse>} Config summaries and the next cursor
|
|
61
|
+
* @throws {ValidationError} If the params fail validation
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* let cursor: string | undefined;
|
|
66
|
+
* do {
|
|
67
|
+
* const page = await composio.sessionConfigs.list({ cursor });
|
|
68
|
+
* for (const item of page.items) console.log(item.id, item.name);
|
|
69
|
+
* cursor = page.nextCursor ?? undefined;
|
|
70
|
+
* } while (cursor);
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
async list(
|
|
74
|
+
params?: SessionConfigListParams,
|
|
75
|
+
requestOptions?: ComposioRequestOptions
|
|
76
|
+
): Promise<SessionConfigListResponse> {
|
|
77
|
+
const parsedParams = SessionConfigListParamsSchema.safeParse(params ?? {});
|
|
78
|
+
if (!parsedParams.success) {
|
|
79
|
+
throw new ValidationError('Failed to parse session config list params', {
|
|
80
|
+
cause: parsedParams.error,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const result = await withCancellation(
|
|
84
|
+
() => this.client.sessionConfigs.list(parsedParams.data, requestOptions),
|
|
85
|
+
requestOptions?.signal
|
|
86
|
+
);
|
|
87
|
+
return transformSessionConfigListResponse(result);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Retrieve one saved Session config with its description and access
|
|
92
|
+
* policy. A missing or cross-project id surfaces as the backend's 404.
|
|
93
|
+
*
|
|
94
|
+
* Requires Session configs to be enabled for the project.
|
|
95
|
+
*
|
|
96
|
+
* @param {string} id - The `sc_…` id of the Session config
|
|
97
|
+
* @returns {Promise<SessionConfig>} The config and its policy
|
|
98
|
+
* @throws {ValidationError} If `id` is empty
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const sessionConfig = await composio.sessionConfigs.get('sc_abc123');
|
|
103
|
+
* console.log(sessionConfig.config.toolkits);
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
async get(id: string, requestOptions?: ComposioRequestOptions): Promise<SessionConfig> {
|
|
107
|
+
// An empty id would request the collection path and return a list page.
|
|
108
|
+
if (id.trim() === '') {
|
|
109
|
+
throw new ValidationError('Session config id must be a non-empty string');
|
|
110
|
+
}
|
|
111
|
+
const result = await withCancellation(
|
|
112
|
+
() => this.client.sessionConfigs.retrieve(id, requestOptions),
|
|
113
|
+
requestOptions?.signal
|
|
114
|
+
);
|
|
115
|
+
return transformSessionConfig(result);
|
|
116
|
+
}
|
|
117
|
+
}
|
package/src/models/ToolRouter.ts
CHANGED
|
@@ -44,16 +44,21 @@ import type {
|
|
|
44
44
|
InlineCustomToolsWirePayload,
|
|
45
45
|
} from '../types/customTool.types';
|
|
46
46
|
import {
|
|
47
|
+
type SessionCreateBody,
|
|
47
48
|
transformToolRouterTagsParams,
|
|
48
49
|
transformToolRouterToolsParams,
|
|
49
50
|
transformToolRouterManageConnectionsParams,
|
|
50
51
|
transformToolRouterSandboxParams,
|
|
51
52
|
transformToolRouterToolkitsParams,
|
|
52
53
|
transformToolRouterMultiAccountParams,
|
|
54
|
+
transformToolRouterInstantParams,
|
|
53
55
|
resolveToolRouterSandboxConfig,
|
|
54
56
|
} from '../lib/toolRouterParams';
|
|
55
57
|
import { PRELOAD_TOOLS_ALL } from '../lib/toolRouterConstants';
|
|
56
58
|
import { buildMCPServerConfig } from '../lib/toolRouterMcp';
|
|
59
|
+
import { parseSessionConfigInput } from '../lib/sessionConfigConflict';
|
|
60
|
+
import { getSourceSessionConfig } from '../lib/toolRouterSourceSessionConfig';
|
|
61
|
+
import { transformSessionConfig } from '../utils/transformers/toolRouterResponseTransform';
|
|
57
62
|
import { ToolRouterSession } from './ToolRouterSession';
|
|
58
63
|
import { ComposioRequestOptions } from '../types/requestOptions.types';
|
|
59
64
|
import { withCancellation } from '../utils/cancellation';
|
|
@@ -72,7 +77,7 @@ function getSessionMetadata(
|
|
|
72
77
|
session: SessionCreateResponse | SessionRetrieveResponse | SessionAttachResponse
|
|
73
78
|
) {
|
|
74
79
|
const metadata: ToolRouterSessionMetadata = {
|
|
75
|
-
config: session.config,
|
|
80
|
+
config: transformSessionConfig(session.config),
|
|
76
81
|
preload: session.config.preload,
|
|
77
82
|
workbench: session.config.workbench,
|
|
78
83
|
configVersion: session.config_version,
|
|
@@ -189,6 +194,12 @@ export class ToolRouter<
|
|
|
189
194
|
* customToolkits: [myToolkit],
|
|
190
195
|
* },
|
|
191
196
|
* });
|
|
197
|
+
*
|
|
198
|
+
* // Start from a saved Session config instead of inline access fields
|
|
199
|
+
* const configured = await composio.sessions.create('user_123', {
|
|
200
|
+
* authConfigs: { github: 'ac_123' },
|
|
201
|
+
* experimental: { sessionConfigId: 'sc_123' },
|
|
202
|
+
* });
|
|
192
203
|
* ```
|
|
193
204
|
*/
|
|
194
205
|
// Overloads: passing `{ mcp: true }` surfaces `session.mcp` in the returned
|
|
@@ -209,7 +220,7 @@ export class ToolRouter<
|
|
|
209
220
|
config?: ToolRouterCreateSessionConfig,
|
|
210
221
|
requestOptions?: ComposioRequestOptions
|
|
211
222
|
): Promise<Session<TToolCollection, TTool, TProvider>> {
|
|
212
|
-
const routerConfig = ToolRouterCreateSessionConfigSchema
|
|
223
|
+
const routerConfig = parseSessionConfigInput(ToolRouterCreateSessionConfigSchema, config ?? {});
|
|
213
224
|
const isDirectToolsPreset = routerConfig.sessionPreset === SessionPreset.DIRECT_TOOLS;
|
|
214
225
|
|
|
215
226
|
// Extract custom tools/toolkits from experimental config
|
|
@@ -226,6 +237,10 @@ export class ToolRouter<
|
|
|
226
237
|
// Build the typed experimental payload for the backend
|
|
227
238
|
const experimentalPayload: SessionCreateParams['experimental'] = {};
|
|
228
239
|
|
|
240
|
+
if (routerConfig.experimental?.sessionConfigId !== undefined) {
|
|
241
|
+
experimentalPayload.session_config_id = routerConfig.experimental.sessionConfigId;
|
|
242
|
+
}
|
|
243
|
+
|
|
229
244
|
if (routerConfig.experimental?.assistivePrompt?.userTimezone) {
|
|
230
245
|
experimentalPayload.assistive_prompt_config = {
|
|
231
246
|
user_timezone: routerConfig.experimental.assistivePrompt.userTimezone,
|
|
@@ -254,11 +269,14 @@ export class ToolRouter<
|
|
|
254
269
|
])
|
|
255
270
|
);
|
|
256
271
|
|
|
257
|
-
const payload:
|
|
272
|
+
const payload: SessionCreateBody = {
|
|
258
273
|
user_id: userId,
|
|
259
274
|
auth_configs: routerConfig.authConfigs,
|
|
260
275
|
connected_accounts: connectedAccountsPayload,
|
|
261
276
|
toolkits: transformToolRouterToolkitsParams(routerConfig.toolkits),
|
|
277
|
+
...(routerConfig.instant !== undefined && {
|
|
278
|
+
instant: transformToolRouterInstantParams(routerConfig.instant),
|
|
279
|
+
}),
|
|
262
280
|
tools: transformToolRouterToolsParams(routerConfig.tools),
|
|
263
281
|
tags: transformToolRouterTagsParams(routerConfig.tags),
|
|
264
282
|
manage_connections: transformToolRouterManageConnectionsParams(
|
|
@@ -302,7 +320,7 @@ export class ToolRouter<
|
|
|
302
320
|
this.config,
|
|
303
321
|
session.session_id,
|
|
304
322
|
this.createMCPServerConfig(session.mcp, routerConfig.mcp === true),
|
|
305
|
-
{ assistivePrompt },
|
|
323
|
+
{ assistivePrompt, sourceSessionConfig: getSourceSessionConfig(session) },
|
|
306
324
|
customToolsMap,
|
|
307
325
|
userId,
|
|
308
326
|
metadata
|
|
@@ -413,7 +431,7 @@ export class ToolRouter<
|
|
|
413
431
|
this.config,
|
|
414
432
|
session.session_id,
|
|
415
433
|
this.createMCPServerConfig(session.mcp, options?.mcp === true),
|
|
416
|
-
|
|
434
|
+
{ sourceSessionConfig: getSourceSessionConfig(session) },
|
|
417
435
|
customToolsMap,
|
|
418
436
|
userId,
|
|
419
437
|
metadata
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
import {
|
|
36
36
|
transformSearchResponse,
|
|
37
37
|
transformExecuteResponse,
|
|
38
|
+
transformSessionConfig,
|
|
38
39
|
} from '../utils/transformers/toolRouterResponseTransform';
|
|
39
40
|
import { SessionMetaToolOptions } from '../types/modifiers.types';
|
|
40
41
|
import { ConnectionRequest } from '../types/connectionRequest.types';
|
|
@@ -86,6 +87,8 @@ import {
|
|
|
86
87
|
import { transformProxyParams } from './proxyParamsTransform';
|
|
87
88
|
import { inlineCustomToolsExperimental } from './inlineCustomToolsPayload';
|
|
88
89
|
import { transformToolRouterUpdateParams } from '../lib/toolRouterParams';
|
|
90
|
+
import { parseSessionConfigInput } from '../lib/sessionConfigConflict';
|
|
91
|
+
import { getSourceSessionConfig } from '../lib/toolRouterSourceSessionConfig';
|
|
89
92
|
import { deleteToolRouterSession } from '../lib/toolRouterSessionDelete';
|
|
90
93
|
|
|
91
94
|
const COMPOSIO_MULTI_EXECUTE_TOOL = 'COMPOSIO_MULTI_EXECUTE_TOOL';
|
|
@@ -129,9 +132,9 @@ export class ToolRouterSession<
|
|
|
129
132
|
public readonly mcp: ToolRouterMCPServerConfig;
|
|
130
133
|
public readonly experimental: SessionExperimental;
|
|
131
134
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* `
|
|
135
|
+
* The session's current configuration (policy snapshot and runtime
|
|
136
|
+
* settings). Refreshed in place by `update()`. For saved, reusable Session
|
|
137
|
+
* configs, see `composio.sessionConfigs`.
|
|
135
138
|
*/
|
|
136
139
|
public config: ToolRouterSessionConfig;
|
|
137
140
|
public preload: ToolRouterSessionPreloadConfig;
|
|
@@ -139,8 +142,8 @@ export class ToolRouterSession<
|
|
|
139
142
|
public sandbox?: ToolRouterSessionWorkbenchConfig;
|
|
140
143
|
/**
|
|
141
144
|
* Version of the server-side configuration this object last observed.
|
|
142
|
-
* Refreshed in place by `update()
|
|
143
|
-
*
|
|
145
|
+
* Refreshed in place by `update()`. Pass it as `expectedConfigVersion` to
|
|
146
|
+
* make an update conditional.
|
|
144
147
|
*/
|
|
145
148
|
public configVersion?: number;
|
|
146
149
|
public warnings: ToolRouterSessionWarning[];
|
|
@@ -155,7 +158,7 @@ export class ToolRouterSession<
|
|
|
155
158
|
private readonly sdkConfig: ComposioConfig<TProvider> | undefined,
|
|
156
159
|
sessionId: string,
|
|
157
160
|
mcp: ToolRouterMCPServerConfig,
|
|
158
|
-
experimentalOverrides?: Pick<SessionExperimental, 'assistivePrompt'>,
|
|
161
|
+
experimentalOverrides?: Pick<SessionExperimental, 'assistivePrompt' | 'sourceSessionConfig'>,
|
|
159
162
|
private readonly customToolsMap?: CustomToolsMap,
|
|
160
163
|
private readonly userId?: string,
|
|
161
164
|
metadata?: ToolRouterSessionMetadata
|
|
@@ -165,7 +168,7 @@ export class ToolRouterSession<
|
|
|
165
168
|
execute: {},
|
|
166
169
|
search: {},
|
|
167
170
|
preload: { tools: [] },
|
|
168
|
-
|
|
171
|
+
instant: false,
|
|
169
172
|
};
|
|
170
173
|
if (customToolsMap && !userId) {
|
|
171
174
|
throw new Error('userId is required when custom tools are bound to a session.');
|
|
@@ -175,6 +178,7 @@ export class ToolRouterSession<
|
|
|
175
178
|
this.experimental = {
|
|
176
179
|
assistivePrompt: experimentalOverrides?.assistivePrompt,
|
|
177
180
|
files: new ToolRouterSessionFilesMount(client, sessionId),
|
|
181
|
+
sourceSessionConfig: experimentalOverrides?.sourceSessionConfig,
|
|
178
182
|
};
|
|
179
183
|
this.config = config;
|
|
180
184
|
this.preload = metadata?.preload ?? config.preload;
|
|
@@ -778,30 +782,37 @@ export class ToolRouterSession<
|
|
|
778
782
|
* map entirely. `manageConnections.callbackUrl: null` removes only the
|
|
779
783
|
* stored callback URL.
|
|
780
784
|
*
|
|
781
|
-
*
|
|
782
|
-
* `
|
|
785
|
+
* By default the request carries no precondition: the last writer wins.
|
|
786
|
+
* Pass `expectedConfigVersion` (for example `session.configVersion`) to make
|
|
787
|
+
* the update conditional: the API then applies it only when the stored
|
|
788
|
+
* version still matches, and a concurrent change surfaces as
|
|
783
789
|
* {@link ComposioSessionConfigConflictError} (HTTP 409) instead of being
|
|
784
|
-
* overwritten.
|
|
785
|
-
*
|
|
786
|
-
*
|
|
787
|
-
* exactly once. On conflict this object is left
|
|
788
|
-
* session with `sessions.use(sessionId)` and retry
|
|
789
|
-
* `configVersion`.
|
|
790
|
+
* overwritten. The API must support the `expected_config_version` field;
|
|
791
|
+
* otherwise it rejects the request with a 400. `expectedConfigVersion: false`
|
|
792
|
+
* is the same as omitting it. The PATCH is never retried by the transport,
|
|
793
|
+
* so a 409 is reported exactly once. On conflict this object is left
|
|
794
|
+
* unchanged: re-fetch the session with `sessions.use(sessionId)` and retry
|
|
795
|
+
* against the fresh `configVersion`.
|
|
790
796
|
*
|
|
791
|
-
* `
|
|
792
|
-
*
|
|
793
|
-
* `
|
|
797
|
+
* `experimental.sessionConfigId` applies a saved Session config: it
|
|
798
|
+
* replaces the session's toolkit, tool and tag access and cannot be combined
|
|
799
|
+
* with `toolkits`, `tools` or `tags` (a `ValidationError` is thrown before
|
|
800
|
+
* any request). A 409 while applying it means the session or the config
|
|
801
|
+
* changed; re-fetch the session and retry. Backend 400, 403 and 404 errors,
|
|
802
|
+
* for example for an archived or missing config, surface unchanged.
|
|
803
|
+
*
|
|
804
|
+
* `config`, `configVersion`, `preload`, `sandbox`, `warnings` and
|
|
805
|
+
* `experimental.sourceSessionConfig` are refreshed in place only after a
|
|
806
|
+
* successful response, and the updated `config` is returned.
|
|
794
807
|
*/
|
|
795
808
|
async update(
|
|
796
809
|
config: ToolRouterUpdateSessionConfig,
|
|
797
810
|
requestOptions?: ComposioRequestOptions
|
|
798
811
|
): Promise<ToolRouterSessionConfig> {
|
|
799
|
-
const parsed = ToolRouterUpdateSessionConfigSchema
|
|
812
|
+
const parsed = parseSessionConfigInput(ToolRouterUpdateSessionConfigSchema, config);
|
|
800
813
|
const body = transformToolRouterUpdateParams(parsed);
|
|
801
814
|
const expectedConfigVersion =
|
|
802
|
-
parsed.expectedConfigVersion === false
|
|
803
|
-
? undefined
|
|
804
|
-
: (parsed.expectedConfigVersion ?? this.configVersion);
|
|
815
|
+
parsed.expectedConfigVersion === false ? undefined : parsed.expectedConfigVersion;
|
|
805
816
|
if (expectedConfigVersion !== undefined) {
|
|
806
817
|
body.expected_config_version = expectedConfigVersion;
|
|
807
818
|
}
|
|
@@ -821,6 +832,16 @@ export class ToolRouterSession<
|
|
|
821
832
|
);
|
|
822
833
|
} catch (error) {
|
|
823
834
|
if (error instanceof ConflictError) {
|
|
835
|
+
const sessionConfigId = parsed.experimental?.sessionConfigId;
|
|
836
|
+
if (sessionConfigId !== undefined) {
|
|
837
|
+
throw new ComposioSessionConfigConflictError(
|
|
838
|
+
`Session ${this.sessionId} or Session config ${sessionConfigId} changed while the config was being applied; re-fetch the session and retry the update`,
|
|
839
|
+
{
|
|
840
|
+
cause: error,
|
|
841
|
+
meta: { sessionId: this.sessionId, sessionConfigId, expectedConfigVersion },
|
|
842
|
+
}
|
|
843
|
+
);
|
|
844
|
+
}
|
|
824
845
|
throw new ComposioSessionConfigConflictError(
|
|
825
846
|
expectedConfigVersion === undefined
|
|
826
847
|
? `Session ${this.sessionId} configuration changed while this update was in flight; re-fetch the session and retry the update`
|
|
@@ -835,10 +856,11 @@ export class ToolRouterSession<
|
|
|
835
856
|
}
|
|
836
857
|
|
|
837
858
|
this.configVersion = response.config_version;
|
|
838
|
-
this.config = response.config;
|
|
859
|
+
this.config = transformSessionConfig(response.config);
|
|
839
860
|
this.preload = response.config.preload;
|
|
840
861
|
this.sandbox = response.config.workbench;
|
|
841
862
|
this.warnings = response.warnings ?? [];
|
|
863
|
+
this.experimental.sourceSessionConfig = getSourceSessionConfig(response);
|
|
842
864
|
return this.config;
|
|
843
865
|
}
|
|
844
866
|
|
|
@@ -891,7 +913,7 @@ export class ToolRouterSession<
|
|
|
891
913
|
version: item.version,
|
|
892
914
|
createdAt: item.created_at,
|
|
893
915
|
isCurrent: item.is_current,
|
|
894
|
-
config: item.config,
|
|
916
|
+
config: transformSessionConfig(item.config),
|
|
895
917
|
})),
|
|
896
918
|
nextCursor: response.next_cursor ?? null,
|
|
897
919
|
totalPages: response.total_pages,
|
|
@@ -1097,6 +1119,9 @@ export class ToolRouterSession<
|
|
|
1097
1119
|
: `${failedCount} out of ${allResults.length} tools failed`
|
|
1098
1120
|
: null,
|
|
1099
1121
|
successful: !hasAnyError,
|
|
1122
|
+
...(remoteResult?.instantCharge !== undefined && {
|
|
1123
|
+
instantCharge: remoteResult.instantCharge,
|
|
1124
|
+
}),
|
|
1100
1125
|
};
|
|
1101
1126
|
}
|
|
1102
1127
|
}
|
package/src/models/Tools.ts
CHANGED
|
@@ -62,6 +62,7 @@ import {
|
|
|
62
62
|
import { dereferenceJsonSchema } from '../utils/jsonSchema';
|
|
63
63
|
import { ComposioRequestOptions } from '../types/requestOptions.types';
|
|
64
64
|
import { withCancellation } from '../utils/cancellation';
|
|
65
|
+
import { transformExecuteResponse } from '../utils/transformers/toolRouterResponseTransform';
|
|
65
66
|
import { ComposioRequestCancelledError } from '../errors/SDKErrors';
|
|
66
67
|
|
|
67
68
|
const TOOL_ROUTER_SESSION_TOOLS_PAGE_LIMIT = 500;
|
|
@@ -1257,12 +1258,13 @@ export class Tools<
|
|
|
1257
1258
|
requestOptions?.signal
|
|
1258
1259
|
);
|
|
1259
1260
|
|
|
1260
|
-
|
|
1261
|
+
const { data, error, logId, instantCharge } = transformExecuteResponse(response);
|
|
1261
1262
|
let result: ToolExecuteResponse = {
|
|
1262
|
-
data
|
|
1263
|
-
error
|
|
1264
|
-
successful: !
|
|
1265
|
-
logId
|
|
1263
|
+
data,
|
|
1264
|
+
error,
|
|
1265
|
+
successful: !error,
|
|
1266
|
+
logId,
|
|
1267
|
+
...(instantCharge !== undefined && { instantCharge }),
|
|
1266
1268
|
};
|
|
1267
1269
|
|
|
1268
1270
|
// Apply afterExecute modifier if provided
|
package/src/models/Usage.ts
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
* ```typescript
|
|
33
33
|
* const summary = await composio.experimental.usage.summary();
|
|
34
34
|
* console.log(summary.entities.tool_calls?.totalQuantity);
|
|
35
|
+
* console.log(summary.instantCharge); // exact USD string
|
|
35
36
|
*
|
|
36
37
|
* const byTool = await composio.experimental.usage.breakdown('tool_calls', {
|
|
37
38
|
* groupBy: 'tool_slug',
|
|
@@ -52,7 +53,7 @@ export class Usage {
|
|
|
52
53
|
* **Experimental — shape may change in future releases.**
|
|
53
54
|
*
|
|
54
55
|
* @param {UsageSummaryParams} [params] - Optional range, `entityTypes` and filters
|
|
55
|
-
* @returns {Promise<UsageSummaryResponse>} Totals keyed by entity type
|
|
56
|
+
* @returns {Promise<UsageSummaryResponse>} Totals keyed by entity type and the exact USD Instant charge
|
|
56
57
|
* @throws {ValidationError} If the params fail validation
|
|
57
58
|
*
|
|
58
59
|
* @example
|