@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
|
@@ -8,10 +8,8 @@
|
|
|
8
8
|
* This will be shipped with the SDK and users don't need to install it separately.
|
|
9
9
|
*/
|
|
10
10
|
import { OpenAI } from 'openai';
|
|
11
|
-
import { Stream } from 'openai/streaming';
|
|
12
11
|
import { BaseNonAgenticProvider } from './BaseProvider';
|
|
13
12
|
import { Tool } from '../types/tool.types';
|
|
14
|
-
import logger from '../utils/logger';
|
|
15
13
|
import { ExecuteToolModifiers } from '../types/modifiers.types';
|
|
16
14
|
import {
|
|
17
15
|
ExecuteToolFnOptions,
|
|
@@ -296,285 +294,4 @@ export class OpenAIProvider extends BaseNonAgenticProvider<
|
|
|
296
294
|
}
|
|
297
295
|
return outputs;
|
|
298
296
|
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Handles all the tool calls from the OpenAI Assistant API.
|
|
302
|
-
*
|
|
303
|
-
* This method processes tool calls from an OpenAI Assistant run,
|
|
304
|
-
* executes each tool call, and returns the tool outputs for submission.
|
|
305
|
-
*
|
|
306
|
-
* @deprecated Assistant API is deprecated, please use responses or chat completions instead. This method will be removed in the next major version.
|
|
307
|
-
*
|
|
308
|
-
* @param {string} userId - The user ID for authentication and tracking
|
|
309
|
-
* @param {OpenAI.Beta.Threads.Run} run - The Assistant run object containing tool calls
|
|
310
|
-
* @param {ExecuteToolFnOptions} [options] - Optional execution options
|
|
311
|
-
* @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
|
|
312
|
-
* @returns {Promise<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput[]>} Array of tool outputs for submission
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
* @example
|
|
316
|
-
* ```typescript
|
|
317
|
-
* // Handle tool calls from an OpenAI Assistant run
|
|
318
|
-
* const run = {
|
|
319
|
-
* id: 'run_abc123',
|
|
320
|
-
* required_action: {
|
|
321
|
-
* submit_tool_outputs: {
|
|
322
|
-
* tool_calls: [
|
|
323
|
-
* {
|
|
324
|
-
* id: 'call_xyz789',
|
|
325
|
-
* type: 'function',
|
|
326
|
-
* function: {
|
|
327
|
-
* name: 'SEARCH_TOOL',
|
|
328
|
-
* arguments: '{"query":"composio documentation"}'
|
|
329
|
-
* }
|
|
330
|
-
* }
|
|
331
|
-
* ]
|
|
332
|
-
* }
|
|
333
|
-
* }
|
|
334
|
-
* };
|
|
335
|
-
*
|
|
336
|
-
* const toolOutputs = await provider.handleAssistantMessage(
|
|
337
|
-
* 'user123',
|
|
338
|
-
* run,
|
|
339
|
-
* { connectedAccountId: 'conn_xyz456' }
|
|
340
|
-
* );
|
|
341
|
-
*
|
|
342
|
-
* // Submit tool outputs back to OpenAI
|
|
343
|
-
* await openai.beta.threads.runs.submitToolOutputs(
|
|
344
|
-
* thread.id,
|
|
345
|
-
* run.id,
|
|
346
|
-
* { tool_outputs: toolOutputs }
|
|
347
|
-
* );
|
|
348
|
-
* ```
|
|
349
|
-
*/
|
|
350
|
-
async handleAssistantMessage(
|
|
351
|
-
userId: string,
|
|
352
|
-
run: OpenAI.Beta.Threads.Run,
|
|
353
|
-
options?: ExecuteToolFnOptions,
|
|
354
|
-
modifiers?: ExecuteToolModifiers
|
|
355
|
-
) {
|
|
356
|
-
const tool_calls = run.required_action?.submit_tool_outputs?.tool_calls || [];
|
|
357
|
-
const tool_outputs: Array<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput> =
|
|
358
|
-
await Promise.all(
|
|
359
|
-
tool_calls.map(async tool_call => {
|
|
360
|
-
logger.debug(`Executing tool call: ${tool_call.id}`);
|
|
361
|
-
|
|
362
|
-
// Execute each tool call and get the response
|
|
363
|
-
const tool_response = await this.executeToolCall(
|
|
364
|
-
userId,
|
|
365
|
-
tool_call as OpenAI.ChatCompletionMessageFunctionToolCall,
|
|
366
|
-
options,
|
|
367
|
-
modifiers
|
|
368
|
-
);
|
|
369
|
-
|
|
370
|
-
logger.debug(`Tool call ${tool_call.id} executed with response: ${tool_response}`);
|
|
371
|
-
|
|
372
|
-
return {
|
|
373
|
-
tool_call_id: tool_call.id,
|
|
374
|
-
output: JSON.stringify(tool_response),
|
|
375
|
-
};
|
|
376
|
-
})
|
|
377
|
-
);
|
|
378
|
-
return tool_outputs;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* Waits for the assistant stream and handles the tool calls.
|
|
383
|
-
*
|
|
384
|
-
* This method processes an OpenAI Assistant stream, handles any tool calls
|
|
385
|
-
* that require action, and yields each event from the stream. It's designed
|
|
386
|
-
* for streaming Assistant responses while handling tool calls in real-time.
|
|
387
|
-
*
|
|
388
|
-
* @deprecated Assistant API is deprecated, please use responses or chat completions instead. It will be removed in the next major version.
|
|
389
|
-
*
|
|
390
|
-
* @param {string} userId - The user ID for authentication and tracking
|
|
391
|
-
* @param {OpenAI} client - The OpenAI client instance
|
|
392
|
-
* @param {Stream<OpenAI.Beta.Assistants.AssistantStreamEvent>} runStream - The Assistant run stream
|
|
393
|
-
* @param {OpenAI.Beta.Threads.Thread} thread - The thread object
|
|
394
|
-
* @param {ExecuteToolFnOptions} [options] - Optional execution options
|
|
395
|
-
* @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
|
|
396
|
-
* @returns {AsyncGenerator<OpenAI.Beta.Assistants.AssistantStreamEvent, void, unknown>} Generator yielding stream events
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
* @example
|
|
401
|
-
* ```typescript
|
|
402
|
-
* // Process an OpenAI Assistant stream with tool calls
|
|
403
|
-
* const thread = await openai.beta.threads.create();
|
|
404
|
-
* const runStream = openai.beta.threads.runs.stream(thread.id, {
|
|
405
|
-
* assistant_id: 'asst_abc123',
|
|
406
|
-
* tools: provider.wrapTools(composioTools)
|
|
407
|
-
* });
|
|
408
|
-
*
|
|
409
|
-
* // Process the stream and handle tool calls
|
|
410
|
-
* const streamProcessor = provider.waitAndHandleAssistantStreamToolCalls(
|
|
411
|
-
* 'user123',
|
|
412
|
-
* openai,
|
|
413
|
-
* runStream,
|
|
414
|
-
* thread,
|
|
415
|
-
* { connectedAccountId: 'conn_xyz456' }
|
|
416
|
-
* );
|
|
417
|
-
*
|
|
418
|
-
* // Consume the stream events
|
|
419
|
-
* for await (const event of streamProcessor) {
|
|
420
|
-
* if (event.event === 'thread.message.delta') {
|
|
421
|
-
* console.log(event.data.delta.content);
|
|
422
|
-
* }
|
|
423
|
-
* }
|
|
424
|
-
* ```
|
|
425
|
-
*/
|
|
426
|
-
async *waitAndHandleAssistantStreamToolCalls(
|
|
427
|
-
userId: string,
|
|
428
|
-
client: OpenAI,
|
|
429
|
-
runStream: Stream<OpenAI.Beta.Assistants.AssistantStreamEvent>,
|
|
430
|
-
thread: OpenAI.Beta.Threads.Thread,
|
|
431
|
-
options?: ExecuteToolFnOptions,
|
|
432
|
-
modifiers?: ExecuteToolModifiers
|
|
433
|
-
) {
|
|
434
|
-
// @TODO: Log the run stream
|
|
435
|
-
let runId = null;
|
|
436
|
-
|
|
437
|
-
// Start processing the runStream events
|
|
438
|
-
for await (const event of runStream) {
|
|
439
|
-
yield event; // Yield each event from the stream as it arrives
|
|
440
|
-
|
|
441
|
-
if (event.event === 'thread.run.created') {
|
|
442
|
-
const { id } = event.data;
|
|
443
|
-
runId = id;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
if (!runId) {
|
|
447
|
-
continue;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
// Handle the 'requires_action' event
|
|
451
|
-
if (event.event === 'thread.run.requires_action') {
|
|
452
|
-
const toolOutputs = await this.handleAssistantMessage(
|
|
453
|
-
userId,
|
|
454
|
-
event.data,
|
|
455
|
-
options,
|
|
456
|
-
modifiers
|
|
457
|
-
);
|
|
458
|
-
|
|
459
|
-
// Submit the tool outputs
|
|
460
|
-
await client.beta.threads.runs.submitToolOutputs(runId, {
|
|
461
|
-
thread_id: thread.id,
|
|
462
|
-
tool_outputs: toolOutputs,
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
// Break if the run status becomes inactive
|
|
467
|
-
if (
|
|
468
|
-
[
|
|
469
|
-
'thread.run.completed',
|
|
470
|
-
'thread.run.failed',
|
|
471
|
-
'thread.run.cancelled',
|
|
472
|
-
'thread.run.expired',
|
|
473
|
-
].includes(event.event)
|
|
474
|
-
) {
|
|
475
|
-
break;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
if (!runId) {
|
|
480
|
-
throw new Error('No run ID found');
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
// Handle any final actions after the stream ends
|
|
484
|
-
let finalRun = await client.beta.threads.runs.retrieve(runId, {
|
|
485
|
-
thread_id: thread.id,
|
|
486
|
-
});
|
|
487
|
-
|
|
488
|
-
while (['queued', 'in_progress', 'requires_action'].includes(finalRun.status)) {
|
|
489
|
-
if (finalRun.status === 'requires_action') {
|
|
490
|
-
const toolOutputs = await this.handleAssistantMessage(userId, finalRun, options, modifiers);
|
|
491
|
-
|
|
492
|
-
// Submit tool outputs
|
|
493
|
-
finalRun = await client.beta.threads.runs.submitToolOutputs(runId, {
|
|
494
|
-
thread_id: thread.id,
|
|
495
|
-
tool_outputs: toolOutputs,
|
|
496
|
-
});
|
|
497
|
-
} else {
|
|
498
|
-
// Update the run status
|
|
499
|
-
finalRun = await client.beta.threads.runs.retrieve(runId, {
|
|
500
|
-
thread_id: thread.id,
|
|
501
|
-
});
|
|
502
|
-
await new Promise(resolve => setTimeout(resolve, 500)); // Wait before rechecking
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
* Waits for the assistant tool calls and handles them.
|
|
509
|
-
*
|
|
510
|
-
* This method polls an OpenAI Assistant run until it completes or requires action,
|
|
511
|
-
* handles any tool calls, and returns the final run object. It's designed for
|
|
512
|
-
* non-streaming Assistant interactions.
|
|
513
|
-
*
|
|
514
|
-
* @deprecated Assistant API is deprecated, please use responses or chat completions instead. It will be removed in the next major version.
|
|
515
|
-
*
|
|
516
|
-
* @param {string} userId - The user ID for authentication and tracking
|
|
517
|
-
* @param {OpenAI} client - The OpenAI client instance
|
|
518
|
-
* @param {OpenAI.Beta.Threads.Run} run - The initial run object
|
|
519
|
-
* @param {OpenAI.Beta.Threads.Thread} thread - The thread object
|
|
520
|
-
* @param {ExecuteToolFnOptions} [options] - Optional execution options
|
|
521
|
-
* @param {ExecuteToolModifiers} [modifiers] - Optional execution modifiers
|
|
522
|
-
* @returns {Promise<OpenAI.Beta.Threads.Run>} The final run object after completion
|
|
523
|
-
*
|
|
524
|
-
* @example
|
|
525
|
-
* ```typescript
|
|
526
|
-
* // Process an OpenAI Assistant run with tool calls
|
|
527
|
-
* const thread = await openai.beta.threads.create();
|
|
528
|
-
* await openai.beta.threads.messages.create(thread.id, {
|
|
529
|
-
* role: 'user',
|
|
530
|
-
* content: 'Find information about Composio'
|
|
531
|
-
* });
|
|
532
|
-
*
|
|
533
|
-
* let run = await openai.beta.threads.runs.create(thread.id, {
|
|
534
|
-
* assistant_id: 'asst_abc123',
|
|
535
|
-
* tools: provider.wrapTools(composioTools)
|
|
536
|
-
* });
|
|
537
|
-
*
|
|
538
|
-
* // Wait for the run to complete, handling any tool calls
|
|
539
|
-
* run = await provider.waitAndHandleAssistantToolCalls(
|
|
540
|
-
* 'user123',
|
|
541
|
-
* openai,
|
|
542
|
-
* run,
|
|
543
|
-
* thread,
|
|
544
|
-
* { connectedAccountId: 'conn_xyz456' }
|
|
545
|
-
* );
|
|
546
|
-
*
|
|
547
|
-
* // Get the final messages after run completion
|
|
548
|
-
* const messages = await openai.beta.threads.messages.list(thread.id);
|
|
549
|
-
* console.log(messages.data[0].content);
|
|
550
|
-
* ```
|
|
551
|
-
*/
|
|
552
|
-
async waitAndHandleAssistantToolCalls(
|
|
553
|
-
userId: string,
|
|
554
|
-
client: OpenAI,
|
|
555
|
-
run: OpenAI.Beta.Threads.Run,
|
|
556
|
-
thread: OpenAI.Beta.Threads.Thread,
|
|
557
|
-
options?: ExecuteToolFnOptions,
|
|
558
|
-
modifiers?: ExecuteToolModifiers
|
|
559
|
-
) {
|
|
560
|
-
while (['queued', 'in_progress', 'requires_action'].includes(run.status)) {
|
|
561
|
-
// logger.debug(`Current run status: ${run.status}`);
|
|
562
|
-
const tool_outputs = await this.handleAssistantMessage(userId, run, options, modifiers);
|
|
563
|
-
if (run.status === 'requires_action') {
|
|
564
|
-
// logger.debug(
|
|
565
|
-
// `Submitting tool outputs for run ID: ${run.id} in thread ID: ${thread.id}`
|
|
566
|
-
// );
|
|
567
|
-
run = await client.beta.threads.runs.submitToolOutputs(run.id, {
|
|
568
|
-
thread_id: thread.id,
|
|
569
|
-
tool_outputs: tool_outputs,
|
|
570
|
-
});
|
|
571
|
-
} else {
|
|
572
|
-
run = await client.beta.threads.runs.retrieve(run.id, {
|
|
573
|
-
thread_id: thread.id,
|
|
574
|
-
});
|
|
575
|
-
await new Promise(resolve => setTimeout(resolve, 500));
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
return run;
|
|
579
|
-
}
|
|
580
297
|
}
|
|
@@ -94,8 +94,10 @@ export class TelemetryTransport {
|
|
|
94
94
|
*/
|
|
95
95
|
instrument<T extends object>(instance: T, fileName?: string) {
|
|
96
96
|
const proto = Object.getPrototypeOf(instance);
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
// Objects returned by factory functions carry their methods as own properties.
|
|
98
|
+
const methodSource = proto === Object.prototype || proto === null ? instance : proto;
|
|
99
|
+
const methodNames = Object.getOwnPropertyNames(methodSource).filter(key => {
|
|
100
|
+
const descriptor = Object.getOwnPropertyDescriptor(methodSource, key);
|
|
99
101
|
return (
|
|
100
102
|
key !== 'constructor' &&
|
|
101
103
|
descriptor &&
|
package/src/types/logs.types.ts
CHANGED
|
@@ -56,6 +56,14 @@ export const ToolExecutionLogParentSchema = z
|
|
|
56
56
|
})
|
|
57
57
|
.nullable();
|
|
58
58
|
|
|
59
|
+
/** Tool log metadata, including the optional exact USD Instant charge. */
|
|
60
|
+
export const ToolExecutionLogMetadataSchema = z
|
|
61
|
+
.object({
|
|
62
|
+
instant_charge: z.string().optional(),
|
|
63
|
+
})
|
|
64
|
+
.catchall(z.unknown());
|
|
65
|
+
export type ToolExecutionLogMetadata = z.infer<typeof ToolExecutionLogMetadataSchema>;
|
|
66
|
+
|
|
59
67
|
/**
|
|
60
68
|
* A tool-execution log entry as returned by `composio.logs.search()`.
|
|
61
69
|
*/
|
|
@@ -68,7 +76,7 @@ export const ToolExecutionLogSchema = z.object({
|
|
|
68
76
|
status: ToolExecutionLogStatusSchema,
|
|
69
77
|
level: ToolExecutionLogLevelSchema,
|
|
70
78
|
message: z.string().optional(),
|
|
71
|
-
metadata:
|
|
79
|
+
metadata: ToolExecutionLogMetadataSchema,
|
|
72
80
|
metrics: z.record(z.string(), z.unknown()),
|
|
73
81
|
parent: ToolExecutionLogParentSchema,
|
|
74
82
|
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from 'zod/v3';
|
|
2
|
+
import { ToolRouterTagsParamSchema } from './toolRouter.types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Params for `composio.sessionConfigs.list()`. The backend owns the defaults:
|
|
6
|
+
* active configs only, 20 per page, at most 100.
|
|
7
|
+
*/
|
|
8
|
+
export const SessionConfigListParamsSchema = z.object({
|
|
9
|
+
/** Case-insensitive substring match against the config name. */
|
|
10
|
+
search: z.string().optional(),
|
|
11
|
+
/** `true` returns only archived configs. Omitted returns active configs. */
|
|
12
|
+
archived: z.boolean().optional(),
|
|
13
|
+
/** Page size. The backend defaults to 20 and caps it at 100. */
|
|
14
|
+
limit: z.number().optional(),
|
|
15
|
+
/** `nextCursor` from a previous page. */
|
|
16
|
+
cursor: z.string().optional(),
|
|
17
|
+
});
|
|
18
|
+
export type SessionConfigListParams = z.infer<typeof SessionConfigListParamsSchema>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A saved Session config as listed by `composio.sessionConfigs.list()`.
|
|
22
|
+
*/
|
|
23
|
+
export const SessionConfigSummarySchema = z.object({
|
|
24
|
+
/** Stable `sc_…` identifier. */
|
|
25
|
+
id: z.string(),
|
|
26
|
+
/** Project-unique display name. */
|
|
27
|
+
name: z.string(),
|
|
28
|
+
archived: z.boolean(),
|
|
29
|
+
/** ISO 8601 timestamp. */
|
|
30
|
+
createdAt: z.string(),
|
|
31
|
+
/** ISO 8601 timestamp. */
|
|
32
|
+
updatedAt: z.string(),
|
|
33
|
+
});
|
|
34
|
+
export type SessionConfigSummary = z.infer<typeof SessionConfigSummarySchema>;
|
|
35
|
+
|
|
36
|
+
export const SessionConfigListResponseSchema = z.object({
|
|
37
|
+
items: z.array(SessionConfigSummarySchema),
|
|
38
|
+
/** Cursor for the next page, or `null` on the last page. */
|
|
39
|
+
nextCursor: z.string().nullable(),
|
|
40
|
+
});
|
|
41
|
+
export type SessionConfigListResponse = z.infer<typeof SessionConfigListResponseSchema>;
|
|
42
|
+
|
|
43
|
+
const SessionConfigTagPolicySchema = z.object({
|
|
44
|
+
enable: z.array(ToolRouterTagsParamSchema.element).optional(),
|
|
45
|
+
disable: z.array(ToolRouterTagsParamSchema.element).optional(),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The access policy stored in a saved Session config, in the backend's
|
|
50
|
+
* `enable`/`disable` shape. Toolkit slug keys and tag names are kept exactly
|
|
51
|
+
* as the backend sends them.
|
|
52
|
+
*/
|
|
53
|
+
export const SessionConfigPolicySchema = z.object({
|
|
54
|
+
toolkits: z
|
|
55
|
+
.union([z.object({ enable: z.array(z.string()) }), z.object({ disable: z.array(z.string()) })])
|
|
56
|
+
.optional(),
|
|
57
|
+
/** Per-toolkit tool policy, keyed by toolkit slug. */
|
|
58
|
+
tools: z
|
|
59
|
+
.record(
|
|
60
|
+
z.string(),
|
|
61
|
+
z.union([
|
|
62
|
+
z.object({ enable: z.array(z.string()) }),
|
|
63
|
+
z.object({ disable: z.array(z.string()) }),
|
|
64
|
+
z.object({ tags: SessionConfigTagPolicySchema }),
|
|
65
|
+
])
|
|
66
|
+
)
|
|
67
|
+
.optional(),
|
|
68
|
+
/** Global tag policy. */
|
|
69
|
+
tags: SessionConfigTagPolicySchema.optional(),
|
|
70
|
+
});
|
|
71
|
+
export type SessionConfigPolicy = z.infer<typeof SessionConfigPolicySchema>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A saved Session config with its description and access policy, as returned
|
|
75
|
+
* by `composio.sessionConfigs.get()`.
|
|
76
|
+
*/
|
|
77
|
+
export const SessionConfigSchema = SessionConfigSummarySchema.extend({
|
|
78
|
+
description: z.string().nullable(),
|
|
79
|
+
config: SessionConfigPolicySchema,
|
|
80
|
+
});
|
|
81
|
+
export type SessionConfig = z.infer<typeof SessionConfigSchema>;
|
package/src/types/tool.types.ts
CHANGED
|
@@ -347,7 +347,7 @@ export type CustomAuthParams = z.infer<typeof CustomAuthParamsSchema>;
|
|
|
347
347
|
* Parameters for tool execution.
|
|
348
348
|
*
|
|
349
349
|
* @property {boolean} [allowTracing] - Enable tracing for this tool execution
|
|
350
|
-
* @property {string} [connectedAccountId] -
|
|
350
|
+
* @property {string} [connectedAccountId] - Connected account ID, or `instant_account` to explicitly use the Composio Instant account
|
|
351
351
|
* @property {CustomAuthParams} [customAuthParams] - Custom authentication parameters
|
|
352
352
|
* @property {CustomConnectionData} [customConnectionData] - Custom connection data (takes priority over customAuthParams)
|
|
353
353
|
* @property {Record<string, unknown>} [arguments] - The arguments to pass to the tool
|
|
@@ -407,6 +407,8 @@ export const ToolExecuteResponseSchema = z.object({
|
|
|
407
407
|
successful: z.boolean(),
|
|
408
408
|
logId: z.string().optional(),
|
|
409
409
|
sessionInfo: z.unknown().optional(),
|
|
410
|
+
/** Actual Instant usage charge when the Session opts into returning it. */
|
|
411
|
+
instantCharge: z.unknown().optional(),
|
|
410
412
|
});
|
|
411
413
|
export type ToolExecuteResponse = z.infer<typeof ToolExecuteResponseSchema>;
|
|
412
414
|
|