@composio/client 0.1.0-alpha.60 → 0.1.0-alpha.61

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.
Files changed (226) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/client.d.mts +34 -1
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +34 -1
  5. package/client.d.ts.map +1 -1
  6. package/client.js +41 -7
  7. package/client.js.map +1 -1
  8. package/client.mjs +41 -7
  9. package/client.mjs.map +1 -1
  10. package/internal/utils/query.d.mts +2 -0
  11. package/internal/utils/query.d.mts.map +1 -0
  12. package/internal/utils/query.d.ts +2 -0
  13. package/internal/utils/query.d.ts.map +1 -0
  14. package/internal/utils/query.js +10 -0
  15. package/internal/utils/query.js.map +1 -0
  16. package/internal/utils/query.mjs +6 -0
  17. package/internal/utils/query.mjs.map +1 -0
  18. package/internal/utils.d.mts +1 -0
  19. package/internal/utils.d.ts +1 -0
  20. package/internal/utils.js +1 -0
  21. package/internal/utils.js.map +1 -1
  22. package/internal/utils.mjs +1 -0
  23. package/package.json +1 -1
  24. package/resources/auth-configs.d.mts +4 -1
  25. package/resources/auth-configs.d.mts.map +1 -1
  26. package/resources/auth-configs.d.ts +4 -1
  27. package/resources/auth-configs.d.ts.map +1 -1
  28. package/resources/auth-configs.js +3 -0
  29. package/resources/auth-configs.js.map +1 -1
  30. package/resources/auth-configs.mjs +3 -0
  31. package/resources/auth-configs.mjs.map +1 -1
  32. package/resources/cli/realtime.d.mts +3 -0
  33. package/resources/cli/realtime.d.mts.map +1 -1
  34. package/resources/cli/realtime.d.ts +3 -0
  35. package/resources/cli/realtime.d.ts.map +1 -1
  36. package/resources/cli/realtime.js +3 -0
  37. package/resources/cli/realtime.js.map +1 -1
  38. package/resources/cli/realtime.mjs +3 -0
  39. package/resources/cli/realtime.mjs.map +1 -1
  40. package/resources/connected-accounts.d.mts +11 -2
  41. package/resources/connected-accounts.d.mts.map +1 -1
  42. package/resources/connected-accounts.d.ts +11 -2
  43. package/resources/connected-accounts.d.ts.map +1 -1
  44. package/resources/connected-accounts.js +3 -0
  45. package/resources/connected-accounts.js.map +1 -1
  46. package/resources/connected-accounts.mjs +3 -0
  47. package/resources/connected-accounts.mjs.map +1 -1
  48. package/resources/files.d.mts +3 -0
  49. package/resources/files.d.mts.map +1 -1
  50. package/resources/files.d.ts +3 -0
  51. package/resources/files.d.ts.map +1 -1
  52. package/resources/files.js +3 -0
  53. package/resources/files.js.map +1 -1
  54. package/resources/files.mjs +3 -0
  55. package/resources/files.mjs.map +1 -1
  56. package/resources/link.d.mts +3 -0
  57. package/resources/link.d.mts.map +1 -1
  58. package/resources/link.d.ts +3 -0
  59. package/resources/link.d.ts.map +1 -1
  60. package/resources/link.js +3 -0
  61. package/resources/link.js.map +1 -1
  62. package/resources/link.mjs +3 -0
  63. package/resources/link.mjs.map +1 -1
  64. package/resources/logs/tools.d.mts +3 -0
  65. package/resources/logs/tools.d.mts.map +1 -1
  66. package/resources/logs/tools.d.ts +3 -0
  67. package/resources/logs/tools.d.ts.map +1 -1
  68. package/resources/logs/tools.js +3 -0
  69. package/resources/logs/tools.js.map +1 -1
  70. package/resources/logs/tools.mjs +3 -0
  71. package/resources/logs/tools.mjs.map +1 -1
  72. package/resources/logs/triggers.d.mts +3 -0
  73. package/resources/logs/triggers.d.mts.map +1 -1
  74. package/resources/logs/triggers.d.ts +3 -0
  75. package/resources/logs/triggers.d.ts.map +1 -1
  76. package/resources/logs/triggers.js +3 -0
  77. package/resources/logs/triggers.js.map +1 -1
  78. package/resources/logs/triggers.mjs +3 -0
  79. package/resources/logs/triggers.mjs.map +1 -1
  80. package/resources/mcp/custom.d.mts +3 -0
  81. package/resources/mcp/custom.d.mts.map +1 -1
  82. package/resources/mcp/custom.d.ts +3 -0
  83. package/resources/mcp/custom.d.ts.map +1 -1
  84. package/resources/mcp/custom.js +3 -0
  85. package/resources/mcp/custom.js.map +1 -1
  86. package/resources/mcp/custom.mjs +3 -0
  87. package/resources/mcp/custom.mjs.map +1 -1
  88. package/resources/mcp/generate.d.mts +3 -0
  89. package/resources/mcp/generate.d.mts.map +1 -1
  90. package/resources/mcp/generate.d.ts +3 -0
  91. package/resources/mcp/generate.d.ts.map +1 -1
  92. package/resources/mcp/generate.js +3 -0
  93. package/resources/mcp/generate.js.map +1 -1
  94. package/resources/mcp/generate.mjs +3 -0
  95. package/resources/mcp/generate.mjs.map +1 -1
  96. package/resources/mcp/mcp.d.mts +3 -0
  97. package/resources/mcp/mcp.d.mts.map +1 -1
  98. package/resources/mcp/mcp.d.ts +3 -0
  99. package/resources/mcp/mcp.d.ts.map +1 -1
  100. package/resources/mcp/mcp.js +3 -0
  101. package/resources/mcp/mcp.js.map +1 -1
  102. package/resources/mcp/mcp.mjs +3 -0
  103. package/resources/mcp/mcp.mjs.map +1 -1
  104. package/resources/migration.d.mts +3 -0
  105. package/resources/migration.d.mts.map +1 -1
  106. package/resources/migration.d.ts +3 -0
  107. package/resources/migration.d.ts.map +1 -1
  108. package/resources/migration.js +3 -0
  109. package/resources/migration.js.map +1 -1
  110. package/resources/migration.mjs +3 -0
  111. package/resources/migration.mjs.map +1 -1
  112. package/resources/tool-router/index.d.mts +1 -1
  113. package/resources/tool-router/index.d.ts +1 -1
  114. package/resources/tool-router/index.js +2 -2
  115. package/resources/tool-router/index.js.map +1 -1
  116. package/resources/tool-router/index.mjs +1 -1
  117. package/resources/tool-router/session/files.d.mts +205 -0
  118. package/resources/tool-router/session/files.d.mts.map +1 -0
  119. package/resources/tool-router/session/files.d.ts +205 -0
  120. package/resources/tool-router/session/files.d.ts.map +1 -0
  121. package/resources/tool-router/session/files.js +101 -0
  122. package/resources/tool-router/session/files.js.map +1 -0
  123. package/resources/tool-router/session/files.mjs +97 -0
  124. package/resources/tool-router/session/files.mjs.map +1 -0
  125. package/resources/tool-router/session/index.d.mts +3 -0
  126. package/resources/tool-router/session/index.d.mts.map +1 -0
  127. package/resources/tool-router/session/index.d.ts +3 -0
  128. package/resources/tool-router/session/index.d.ts.map +1 -0
  129. package/resources/tool-router/session/index.js +9 -0
  130. package/resources/tool-router/session/index.js.map +1 -0
  131. package/resources/tool-router/session/index.mjs +4 -0
  132. package/resources/tool-router/session/index.mjs.map +1 -0
  133. package/resources/tool-router/session/session.d.mts +1201 -0
  134. package/resources/tool-router/session/session.d.mts.map +1 -0
  135. package/resources/tool-router/session/session.d.ts +1201 -0
  136. package/resources/tool-router/session/session.d.ts.map +1 -0
  137. package/resources/tool-router/session/session.js +153 -0
  138. package/resources/tool-router/session/session.js.map +1 -0
  139. package/resources/tool-router/session/session.mjs +148 -0
  140. package/resources/tool-router/session/session.mjs.map +1 -0
  141. package/resources/tool-router/session.d.mts +1 -1193
  142. package/resources/tool-router/session.d.mts.map +1 -1
  143. package/resources/tool-router/session.d.ts +1 -1193
  144. package/resources/tool-router/session.d.ts.map +1 -1
  145. package/resources/tool-router/session.js +2 -138
  146. package/resources/tool-router/session.js.map +1 -1
  147. package/resources/tool-router/session.mjs +1 -136
  148. package/resources/tool-router/session.mjs.map +1 -1
  149. package/resources/tool-router/tool-router.d.mts +5 -2
  150. package/resources/tool-router/tool-router.d.mts.map +1 -1
  151. package/resources/tool-router/tool-router.d.ts +5 -2
  152. package/resources/tool-router/tool-router.d.ts.map +1 -1
  153. package/resources/tool-router/tool-router.js +5 -2
  154. package/resources/tool-router/tool-router.js.map +1 -1
  155. package/resources/tool-router/tool-router.mjs +5 -2
  156. package/resources/tool-router/tool-router.mjs.map +1 -1
  157. package/resources/toolkits.d.mts +3 -0
  158. package/resources/toolkits.d.mts.map +1 -1
  159. package/resources/toolkits.d.ts +3 -0
  160. package/resources/toolkits.d.ts.map +1 -1
  161. package/resources/toolkits.js +3 -0
  162. package/resources/toolkits.js.map +1 -1
  163. package/resources/toolkits.mjs +3 -0
  164. package/resources/toolkits.mjs.map +1 -1
  165. package/resources/tools.d.mts +3 -0
  166. package/resources/tools.d.mts.map +1 -1
  167. package/resources/tools.d.ts +3 -0
  168. package/resources/tools.d.ts.map +1 -1
  169. package/resources/tools.js +3 -0
  170. package/resources/tools.js.map +1 -1
  171. package/resources/tools.mjs +3 -0
  172. package/resources/tools.mjs.map +1 -1
  173. package/resources/trigger-instances/manage.d.mts +3 -0
  174. package/resources/trigger-instances/manage.d.mts.map +1 -1
  175. package/resources/trigger-instances/manage.d.ts +3 -0
  176. package/resources/trigger-instances/manage.d.ts.map +1 -1
  177. package/resources/trigger-instances/manage.js +3 -0
  178. package/resources/trigger-instances/manage.js.map +1 -1
  179. package/resources/trigger-instances/manage.mjs +3 -0
  180. package/resources/trigger-instances/manage.mjs.map +1 -1
  181. package/resources/trigger-instances/trigger-instances.d.mts +3 -0
  182. package/resources/trigger-instances/trigger-instances.d.mts.map +1 -1
  183. package/resources/trigger-instances/trigger-instances.d.ts +3 -0
  184. package/resources/trigger-instances/trigger-instances.d.ts.map +1 -1
  185. package/resources/trigger-instances/trigger-instances.js +3 -0
  186. package/resources/trigger-instances/trigger-instances.js.map +1 -1
  187. package/resources/trigger-instances/trigger-instances.mjs +3 -0
  188. package/resources/trigger-instances/trigger-instances.mjs.map +1 -1
  189. package/resources/triggers-types.d.mts +3 -0
  190. package/resources/triggers-types.d.mts.map +1 -1
  191. package/resources/triggers-types.d.ts +3 -0
  192. package/resources/triggers-types.d.ts.map +1 -1
  193. package/resources/triggers-types.js +3 -0
  194. package/resources/triggers-types.js.map +1 -1
  195. package/resources/triggers-types.mjs +3 -0
  196. package/resources/triggers-types.mjs.map +1 -1
  197. package/src/client.ts +44 -10
  198. package/src/internal/utils/query.ts +7 -0
  199. package/src/internal/utils.ts +1 -0
  200. package/src/resources/auth-configs.ts +4 -1
  201. package/src/resources/cli/realtime.ts +3 -0
  202. package/src/resources/connected-accounts.ts +11 -2
  203. package/src/resources/files.ts +3 -0
  204. package/src/resources/link.ts +3 -0
  205. package/src/resources/logs/tools.ts +3 -0
  206. package/src/resources/logs/triggers.ts +3 -0
  207. package/src/resources/mcp/custom.ts +3 -0
  208. package/src/resources/mcp/generate.ts +3 -0
  209. package/src/resources/mcp/mcp.ts +3 -0
  210. package/src/resources/migration.ts +3 -0
  211. package/src/resources/tool-router/index.ts +1 -1
  212. package/src/resources/tool-router/session/files.ts +284 -0
  213. package/src/resources/tool-router/session/index.ts +31 -0
  214. package/src/resources/tool-router/session/session.ts +1465 -0
  215. package/src/resources/tool-router/session.ts +1 -1432
  216. package/src/resources/tool-router/tool-router.ts +5 -2
  217. package/src/resources/toolkits.ts +3 -0
  218. package/src/resources/tools.ts +3 -0
  219. package/src/resources/trigger-instances/manage.ts +3 -0
  220. package/src/resources/trigger-instances/trigger-instances.ts +3 -0
  221. package/src/resources/triggers-types.ts +3 -0
  222. package/src/version.ts +1 -1
  223. package/version.d.mts +1 -1
  224. package/version.d.ts +1 -1
  225. package/version.js +1 -1
  226. package/version.mjs +1 -1
package/src/client.ts CHANGED
@@ -11,7 +11,7 @@ import type { APIResponseProps } from './internal/parse';
11
11
  import { getPlatformHeaders } from './internal/detect-platform';
12
12
  import * as Shims from './internal/shims';
13
13
  import * as Opts from './internal/request-options';
14
- import * as qs from './internal/qs';
14
+ import { stringifyQuery } from './internal/utils/query';
15
15
  import { VERSION } from './version';
16
16
  import * as Errors from './core/error';
17
17
  import * as Uploads from './core/uploads';
@@ -336,8 +336,8 @@ export class Composio {
336
336
  return buildHeaders([{ 'x-api-key': this.apiKey }]);
337
337
  }
338
338
 
339
- protected stringifyQuery(query: Record<string, unknown>): string {
340
- return qs.stringify(query, { arrayFormat: 'comma' });
339
+ protected stringifyQuery(query: object | Record<string, unknown>): string {
340
+ return stringifyQuery(query);
341
341
  }
342
342
 
343
343
  private getUserAgent(): string {
@@ -369,12 +369,13 @@ export class Composio {
369
369
  : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
370
370
 
371
371
  const defaultQuery = this.defaultQuery();
372
- if (!isEmptyObj(defaultQuery)) {
373
- query = { ...defaultQuery, ...query };
372
+ const pathQuery = Object.fromEntries(url.searchParams);
373
+ if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
374
+ query = { ...pathQuery, ...defaultQuery, ...query };
374
375
  }
375
376
 
376
377
  if (typeof query === 'object' && query && !Array.isArray(query)) {
377
- url.search = this.stringifyQuery(query as Record<string, unknown>);
378
+ url.search = this.stringifyQuery(query);
378
379
  }
379
380
 
380
381
  return url.toString();
@@ -679,9 +680,9 @@ export class Composio {
679
680
  }
680
681
  }
681
682
 
682
- // If the API asks us to wait a certain amount of time (and it's a reasonable amount),
683
- // just do what it says, but otherwise calculate a default
684
- if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
683
+ // If the API asks us to wait a certain amount of time, just do what it
684
+ // says, but otherwise calculate a default
685
+ if (timeoutMillis === undefined) {
685
686
  const maxRetries = options.maxRetries ?? this.maxRetries;
686
687
  timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
687
688
  }
@@ -813,7 +814,7 @@ export class Composio {
813
814
  ) {
814
815
  return {
815
816
  bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
816
- body: this.stringifyQuery(body as Record<string, unknown>),
817
+ body: this.stringifyQuery(body),
817
818
  };
818
819
  } else {
819
820
  return this.#encoder({ body, headers });
@@ -839,19 +840,52 @@ export class Composio {
839
840
 
840
841
  static toFile = Uploads.toFile;
841
842
 
843
+ /**
844
+ * Authentication configuration management
845
+ */
842
846
  authConfigs: API.AuthConfigs = new API.AuthConfigs(this);
847
+ /**
848
+ * Connected account management
849
+ */
843
850
  connectedAccounts: API.ConnectedAccounts = new API.ConnectedAccounts(this);
851
+ /**
852
+ * Connected account management
853
+ */
844
854
  link: API.Link = new API.Link(this);
855
+ /**
856
+ * Toolkit and tool management
857
+ */
845
858
  toolkits: API.Toolkits = new API.Toolkits(this);
859
+ /**
860
+ * Tool execution endpoints
861
+ */
846
862
  tools: API.Tools = new API.Tools(this);
863
+ /**
864
+ * Trigger management and execution
865
+ */
847
866
  triggerInstances: API.TriggerInstances = new API.TriggerInstances(this);
867
+ /**
868
+ * Trigger management and execution
869
+ */
848
870
  triggersTypes: API.TriggersTypes = new API.TriggersTypes(this);
871
+ /**
872
+ * MCP server management
873
+ */
849
874
  mcp: API.Mcp = new API.Mcp(this);
875
+ /**
876
+ * File management
877
+ */
850
878
  files: API.Files = new API.Files(this);
879
+ /**
880
+ * Endpoints to help with migration from v1 to v3
881
+ */
851
882
  migration: API.Migration = new API.Migration(this);
852
883
  cli: API.Cli = new API.Cli(this);
853
884
  project: API.Project = new API.Project(this);
854
885
  logs: API.Logs = new API.Logs(this);
886
+ /**
887
+ * (Labs) Tool router endpoints
888
+ */
855
889
  toolRouter: API.ToolRouter = new API.ToolRouter(this);
856
890
  }
857
891
 
@@ -0,0 +1,7 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import * as qs from '../qs/stringify';
4
+
5
+ export function stringifyQuery(query: object | Record<string, unknown>) {
6
+ return qs.stringify(query, { arrayFormat: 'comma' });
7
+ }
@@ -6,3 +6,4 @@ export * from './utils/env';
6
6
  export * from './utils/log';
7
7
  export * from './utils/uuid';
8
8
  export * from './utils/sleep';
9
+ export * from './utils/query';
@@ -5,6 +5,9 @@ import { APIPromise } from '../core/api-promise';
5
5
  import { RequestOptions } from '../internal/request-options';
6
6
  import { path } from '../internal/utils/path';
7
7
 
8
+ /**
9
+ * Authentication configuration management
10
+ */
8
11
  export class AuthConfigs extends APIResource {
9
12
  /**
10
13
  * Creates a new auth config for a toolkit, allowing you to use your own OAuth
@@ -813,7 +816,7 @@ export interface AuthConfigListParams {
813
816
  limit?: number | null;
814
817
 
815
818
  /**
816
- * Search auth configs by name
819
+ * Search auth configs by name or id
817
820
  */
818
821
  search?: string;
819
822
 
@@ -4,6 +4,9 @@ import { APIResource } from '../../core/resource';
4
4
  import { APIPromise } from '../../core/api-promise';
5
5
  import { RequestOptions } from '../../internal/request-options';
6
6
 
7
+ /**
8
+ * CLI integration endpoints
9
+ */
7
10
  export class Realtime extends APIResource {
8
11
  /**
9
12
  * Authenticate CLI client access to a private-cli-{nanoId} Pusher channel
@@ -5,6 +5,9 @@ import { APIPromise } from '../core/api-promise';
5
5
  import { RequestOptions } from '../internal/request-options';
6
6
  import { path } from '../internal/utils/path';
7
7
 
8
+ /**
9
+ * Connected account management
10
+ */
8
11
  export class ConnectedAccounts extends APIResource {
9
12
  /**
10
13
  * Initiates a new connection to an external service for a user. For OAuth-based
@@ -4236,7 +4239,10 @@ export interface ConnectedAccountRetrieveResponse {
4236
4239
  status: 'INITIALIZING' | 'INITIATED' | 'ACTIVE' | 'FAILED' | 'EXPIRED' | 'INACTIVE';
4237
4240
 
4238
4241
  /**
4239
- * The reason the connection is disabled
4242
+ * The reason the connection status changed. Possible reasons: Connection
4243
+ * initiation did not complete within 10 minutes, Permanent auth error during token
4244
+ * refresh, Max auth failures reached, OAuth callback failed during token exchange,
4245
+ * Connection status updated by user, Auth config is disabled
4240
4246
  */
4241
4247
  status_reason: string | null;
4242
4248
 
@@ -8393,7 +8399,10 @@ export namespace ConnectedAccountListResponse {
8393
8399
  status: 'INITIALIZING' | 'INITIATED' | 'ACTIVE' | 'FAILED' | 'EXPIRED' | 'INACTIVE';
8394
8400
 
8395
8401
  /**
8396
- * The reason the connection is disabled
8402
+ * The reason the connection status changed. Possible reasons: Connection
8403
+ * initiation did not complete within 10 minutes, Permanent auth error during token
8404
+ * refresh, Max auth failures reached, OAuth callback failed during token exchange,
8405
+ * Connection status updated by user, Auth config is disabled
8397
8406
  */
8398
8407
  status_reason: string | null;
8399
8408
 
@@ -4,6 +4,9 @@ import { APIResource } from '../core/resource';
4
4
  import { APIPromise } from '../core/api-promise';
5
5
  import { RequestOptions } from '../internal/request-options';
6
6
 
7
+ /**
8
+ * File management
9
+ */
7
10
  export class Files extends APIResource {
8
11
  /**
9
12
  * Retrieves a list of files associated with the authenticated project. Results can
@@ -4,6 +4,9 @@ import { APIResource } from '../core/resource';
4
4
  import { APIPromise } from '../core/api-promise';
5
5
  import { RequestOptions } from '../internal/request-options';
6
6
 
7
+ /**
8
+ * Connected account management
9
+ */
7
10
  export class Link extends APIResource {
8
11
  /**
9
12
  * Creates a new authentication link session that users can use to connect their
@@ -5,6 +5,9 @@ import { APIPromise } from '../../core/api-promise';
5
5
  import { RequestOptions } from '../../internal/request-options';
6
6
  import { path } from '../../internal/utils/path';
7
7
 
8
+ /**
9
+ * Logging and monitoring
10
+ */
8
11
  export class Tools extends APIResource {
9
12
  /**
10
13
  * Get detailed execution log by ID
@@ -5,6 +5,9 @@ import { APIPromise } from '../../core/api-promise';
5
5
  import { RequestOptions } from '../../internal/request-options';
6
6
  import { path } from '../../internal/utils/path';
7
7
 
8
+ /**
9
+ * Logging and monitoring
10
+ */
8
11
  export class Triggers extends APIResource {
9
12
  /**
10
13
  * Get detailed trigger log by ID
@@ -4,6 +4,9 @@ import { APIResource } from '../../core/resource';
4
4
  import { APIPromise } from '../../core/api-promise';
5
5
  import { RequestOptions } from '../../internal/request-options';
6
6
 
7
+ /**
8
+ * MCP server management
9
+ */
7
10
  export class Custom extends APIResource {
8
11
  /**
9
12
  * Creates a new Model Control Protocol (MCP) server instance that can integrate
@@ -4,6 +4,9 @@ import { APIResource } from '../../core/resource';
4
4
  import { APIPromise } from '../../core/api-promise';
5
5
  import { RequestOptions } from '../../internal/request-options';
6
6
 
7
+ /**
8
+ * MCP server management
9
+ */
7
10
  export class Generate extends APIResource {
8
11
  /**
9
12
  * Generates a Model Control Protocol (MCP) URL for an existing server with custom
@@ -9,6 +9,9 @@ import { APIPromise } from '../../core/api-promise';
9
9
  import { RequestOptions } from '../../internal/request-options';
10
10
  import { path } from '../../internal/utils/path';
11
11
 
12
+ /**
13
+ * MCP server management
14
+ */
12
15
  export class Mcp extends APIResource {
13
16
  custom: CustomAPI.Custom = new CustomAPI.Custom(this._client);
14
17
  generate: GenerateAPI.Generate = new GenerateAPI.Generate(this._client);
@@ -4,6 +4,9 @@ import { APIResource } from '../core/resource';
4
4
  import { APIPromise } from '../core/api-promise';
5
5
  import { RequestOptions } from '../internal/request-options';
6
6
 
7
+ /**
8
+ * Endpoints to help with migration from v1 to v3
9
+ */
7
10
  export class Migration extends APIResource {
8
11
  /**
9
12
  * Convert a legacy UUID to its corresponding NanoId for migration purposes. This
@@ -17,7 +17,7 @@ export {
17
17
  type SessionSearchParams,
18
18
  type SessionToolkitsParams,
19
19
  type SessionToolsParams,
20
- } from './session';
20
+ } from './session/index';
21
21
  export {
22
22
  ToolRouter,
23
23
  type ToolRouterCreateSessionResponse,
@@ -0,0 +1,284 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../../core/resource';
4
+ import { APIPromise } from '../../../core/api-promise';
5
+ import { RequestOptions } from '../../../internal/request-options';
6
+ import { path } from '../../../internal/utils/path';
7
+
8
+ /**
9
+ * (Labs) Tool router endpoints
10
+ */
11
+ export class Files extends APIResource {
12
+ /**
13
+ * Lists files in a workbench session storage mount with cursor-based pagination.
14
+ * Use the download_url endpoint with the returned mount_relative_path to get a
15
+ * presigned download URL.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const files = await client.toolRouter.session.files.list(
20
+ * 'files',
21
+ * { session_id: 'trs_123456789' },
22
+ * );
23
+ * ```
24
+ */
25
+ list(mountID: string, params: FileListParams, options?: RequestOptions): APIPromise<FileListResponse> {
26
+ const { session_id, ...query } = params;
27
+ return this._client.get(path`/api/v3/tool_router/session/${session_id}/mounts/${mountID}/items`, {
28
+ query,
29
+ ...options,
30
+ });
31
+ }
32
+
33
+ /**
34
+ * Deletes a file from a workbench session storage mount. S3 delete is idempotent —
35
+ * deleting a non-existent file succeeds silently.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const file = await client.toolRouter.session.files.delete(
40
+ * 'files',
41
+ * {
42
+ * session_id: 'trs_123456789',
43
+ * mount_relative_path: 'report.pdf',
44
+ * },
45
+ * );
46
+ * ```
47
+ */
48
+ delete(
49
+ mountID: string,
50
+ params: FileDeleteParams,
51
+ options?: RequestOptions,
52
+ ): APIPromise<FileDeleteResponse> {
53
+ const { session_id, ...body } = params;
54
+ return this._client.post(path`/api/v3/tool_router/session/${session_id}/mounts/${mountID}/delete`, {
55
+ body,
56
+ ...options,
57
+ });
58
+ }
59
+
60
+ /**
61
+ * Generates a presigned download URL for a file in a workbench session mount.
62
+ * Accepts a relative path within the mount.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const response =
67
+ * await client.toolRouter.session.files.createDownloadURL(
68
+ * 'files',
69
+ * {
70
+ * session_id: 'trs_123456789',
71
+ * mount_relative_path: 'report.pdf',
72
+ * },
73
+ * );
74
+ * ```
75
+ */
76
+ createDownloadURL(
77
+ mountID: string,
78
+ params: FileCreateDownloadURLParams,
79
+ options?: RequestOptions,
80
+ ): APIPromise<FileCreateDownloadURLResponse> {
81
+ const { session_id, ...body } = params;
82
+ return this._client.post(path`/api/v3/tool_router/session/${session_id}/mounts/${mountID}/download_url`, {
83
+ body,
84
+ ...options,
85
+ });
86
+ }
87
+
88
+ /**
89
+ * Generates a presigned upload URL for uploading a file to a workbench session
90
+ * mount. The caller should PUT the file content directly to the returned URL.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * const response =
95
+ * await client.toolRouter.session.files.createUploadURL(
96
+ * 'files',
97
+ * {
98
+ * session_id: 'trs_123456789',
99
+ * mount_relative_path: 'report.pdf',
100
+ * },
101
+ * );
102
+ * ```
103
+ */
104
+ createUploadURL(
105
+ mountID: string,
106
+ params: FileCreateUploadURLParams,
107
+ options?: RequestOptions,
108
+ ): APIPromise<FileCreateUploadURLResponse> {
109
+ const { session_id, ...body } = params;
110
+ return this._client.post(path`/api/v3/tool_router/session/${session_id}/mounts/${mountID}/upload_url`, {
111
+ body,
112
+ ...options,
113
+ });
114
+ }
115
+ }
116
+
117
+ export interface FileListResponse {
118
+ /**
119
+ * List of files in the mount
120
+ */
121
+ items: Array<FileListResponse.Item>;
122
+
123
+ /**
124
+ * Cursor for the next page of results. If absent, there are no more pages.
125
+ */
126
+ next_cursor?: string;
127
+ }
128
+
129
+ export namespace FileListResponse {
130
+ export interface Item {
131
+ /**
132
+ * ISO 8601 timestamp of last modification
133
+ */
134
+ last_modified: string;
135
+
136
+ /**
137
+ * Relative file path within the mount (e.g. "report.pdf")
138
+ */
139
+ mount_relative_path: string;
140
+
141
+ /**
142
+ * Absolute mount path inside the sandbox (e.g. /mnt/files)
143
+ */
144
+ sandbox_mount_prefix: string;
145
+
146
+ /**
147
+ * File size in bytes
148
+ */
149
+ size: number;
150
+ }
151
+ }
152
+
153
+ export interface FileDeleteResponse {
154
+ /**
155
+ * Relative file path that was deleted
156
+ */
157
+ mount_relative_path: string;
158
+
159
+ /**
160
+ * Absolute mount path inside the sandbox (e.g. /mnt/files)
161
+ */
162
+ sandbox_mount_prefix: string;
163
+ }
164
+
165
+ export interface FileCreateDownloadURLResponse {
166
+ /**
167
+ * Presigned download URL for the file
168
+ */
169
+ download_url: string;
170
+
171
+ /**
172
+ * ISO 8601 timestamp when the download URL expires
173
+ */
174
+ expires_at: string;
175
+
176
+ /**
177
+ * Relative file path within the mount (e.g. "report.pdf")
178
+ */
179
+ mount_relative_path: string;
180
+
181
+ /**
182
+ * Absolute mount path inside the sandbox (e.g. /mnt/files)
183
+ */
184
+ sandbox_mount_prefix: string;
185
+ }
186
+
187
+ export interface FileCreateUploadURLResponse {
188
+ /**
189
+ * ISO 8601 timestamp when the upload URL expires
190
+ */
191
+ expires_at: string;
192
+
193
+ /**
194
+ * Relative file path within the mount (e.g. "report.pdf")
195
+ */
196
+ mount_relative_path: string;
197
+
198
+ /**
199
+ * Absolute mount path inside the sandbox (e.g. /mnt/files)
200
+ */
201
+ sandbox_mount_prefix: string;
202
+
203
+ /**
204
+ * Presigned upload URL — PUT the file content here
205
+ */
206
+ upload_url: string;
207
+ }
208
+
209
+ export interface FileListParams {
210
+ /**
211
+ * Path param: The unique identifier of the tool router session
212
+ */
213
+ session_id: string;
214
+
215
+ /**
216
+ * Query param: Pagination cursor from the previous response next_cursor field
217
+ */
218
+ cursor?: string;
219
+
220
+ /**
221
+ * Query param: Maximum number of files to return per page (1-500)
222
+ */
223
+ limit?: number;
224
+
225
+ /**
226
+ * Query param: Relative path prefix within the mount for filtering
227
+ */
228
+ mount_relative_prefix?: string;
229
+ }
230
+
231
+ export interface FileDeleteParams {
232
+ /**
233
+ * Path param: The unique identifier of the tool router session
234
+ */
235
+ session_id: string;
236
+
237
+ /**
238
+ * Body param: Relative file path within the mount
239
+ */
240
+ mount_relative_path: string;
241
+ }
242
+
243
+ export interface FileCreateDownloadURLParams {
244
+ /**
245
+ * Path param: The unique identifier of the tool router session
246
+ */
247
+ session_id: string;
248
+
249
+ /**
250
+ * Body param: Relative file path within the mount
251
+ */
252
+ mount_relative_path: string;
253
+ }
254
+
255
+ export interface FileCreateUploadURLParams {
256
+ /**
257
+ * Path param: The unique identifier of the tool router session
258
+ */
259
+ session_id: string;
260
+
261
+ /**
262
+ * Body param: Supports subdirectories (e.g. "data/output.csv",
263
+ * "images/charts/chart.png")
264
+ */
265
+ mount_relative_path: string;
266
+
267
+ /**
268
+ * Body param: MIME type of the file being uploaded
269
+ */
270
+ mimetype?: string;
271
+ }
272
+
273
+ export declare namespace Files {
274
+ export {
275
+ type FileListResponse as FileListResponse,
276
+ type FileDeleteResponse as FileDeleteResponse,
277
+ type FileCreateDownloadURLResponse as FileCreateDownloadURLResponse,
278
+ type FileCreateUploadURLResponse as FileCreateUploadURLResponse,
279
+ type FileListParams as FileListParams,
280
+ type FileDeleteParams as FileDeleteParams,
281
+ type FileCreateDownloadURLParams as FileCreateDownloadURLParams,
282
+ type FileCreateUploadURLParams as FileCreateUploadURLParams,
283
+ };
284
+ }
@@ -0,0 +1,31 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export {
4
+ Files,
5
+ type FileListResponse,
6
+ type FileDeleteResponse,
7
+ type FileCreateDownloadURLResponse,
8
+ type FileCreateUploadURLResponse,
9
+ type FileListParams,
10
+ type FileDeleteParams,
11
+ type FileCreateDownloadURLParams,
12
+ type FileCreateUploadURLParams,
13
+ } from './files';
14
+ export {
15
+ Session,
16
+ type SessionCreateResponse,
17
+ type SessionRetrieveResponse,
18
+ type SessionExecuteResponse,
19
+ type SessionExecuteMetaResponse,
20
+ type SessionLinkResponse,
21
+ type SessionSearchResponse,
22
+ type SessionToolkitsResponse,
23
+ type SessionToolsResponse,
24
+ type SessionCreateParams,
25
+ type SessionExecuteParams,
26
+ type SessionExecuteMetaParams,
27
+ type SessionLinkParams,
28
+ type SessionSearchParams,
29
+ type SessionToolkitsParams,
30
+ type SessionToolsParams,
31
+ } from './session';