@composio/client 2.0.0-rc.17 → 2.0.0-rc.18

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 (173) hide show
  1. package/README.md +107 -33
  2. package/dist/{api-key-revocation-lc3308Ao.mjs → api-key-revocation-JkA4sOGH.mjs} +1 -1
  3. package/dist/{auth-DkGiEaxg.mjs → auth-B_K-wdMm.mjs} +1 -1
  4. package/dist/{auth-configs-DbxqGahP.mjs → auth-configs-RAgN782Z.mjs} +1 -1
  5. package/dist/{clanker-fK9cAkTz.mjs → clanker-Pgyyh95r.mjs} +1 -1
  6. package/dist/{cli-K1MskpaR.mjs → cli-Ca5bRiEN.mjs} +4 -5
  7. package/dist/{connected-accounts-Bfl7_SY_.mjs → connected-accounts-D6NTwvbi.mjs} +1 -1
  8. package/dist/{consumer-5o2zMQwr.mjs → consumer-BP4OyJS0.mjs} +6 -7
  9. package/dist/{custom-wEkSiPHn.mjs → custom-BBr7KbCv.mjs} +1 -1
  10. package/dist/{custom-8rs-sHnb.mjs → custom-DA3ABHnI.mjs} +1 -1
  11. package/dist/effect.d.mts +54 -23
  12. package/dist/effect.mjs +204 -143
  13. package/dist/{error-D9cG225M.mjs → error-Bw7_G2NZ.mjs} +1 -1
  14. package/dist/{files-BPKJXlpc.mjs → files-CeBs4ZE1.mjs} +1 -1
  15. package/dist/{files-BjPFzRnM.mjs → files-DLRmNLRD.mjs} +1 -1
  16. package/dist/{generate-DDHNgbPS.mjs → generate-16uLPwUU.mjs} +1 -1
  17. package/dist/{generated-deprecated-inputs--L5LHDO_.mjs → generated-deprecated-inputs-zx6ml908.mjs} +2 -2
  18. package/dist/{generated-operations-D1e__yar.mjs → generated-operations-DKgGT6Dg.mjs} +426 -198
  19. package/dist/index.d.mts +3 -3
  20. package/dist/index.mjs +131 -101
  21. package/dist/{keyring-Dkm6DQIp.mjs → keyring-Q8GSieAv.mjs} +1 -1
  22. package/dist/{link-BBU-J5L_.mjs → link-D4dY_eaN.mjs} +1 -1
  23. package/dist/{logs-CuuysWk1.mjs → logs-Dc63Ju74.mjs} +3 -3
  24. package/dist/{manage-B1R7I3ZM.mjs → manage-ByF6b3OD.mjs} +1 -1
  25. package/dist/{mcp-C3beSy48.mjs → mcp-Cw7-Mtkm.mjs} +3 -3
  26. package/dist/{org-B13XOuKh.mjs → org-RRUxKfRw.mjs} +6 -6
  27. package/dist/{owner-BAr5uwk3.mjs → owner-GZX-sp-h.mjs} +1 -1
  28. package/dist/{pagination-rules-uMUdPq_7.mjs → pagination-rules-CMnBwktJ.mjs} +1 -1
  29. package/dist/pagination.mjs +1 -1
  30. package/dist/{project-BbCgXD83.mjs → project-BsKmk9T7.mjs} +1 -1
  31. package/dist/{project-C30H_5b6.mjs → project-C1uq7bV_.mjs} +1 -1
  32. package/dist/{project-DF5KclHm.mjs → project-C_YZ-eLI.mjs} +4 -7
  33. package/dist/{project-CDm8tjUw.mjs → project-Cj9ULE0a.mjs} +1 -1
  34. package/dist/{realtime-6LigMh83.mjs → realtime-W-lJ0Vcs.mjs} +1 -1
  35. package/dist/resources/api-key-revocation.d.mts +1 -1
  36. package/dist/resources/api-key-revocation.mjs +1 -1
  37. package/dist/resources/auth/auth.d.mts +1 -1
  38. package/dist/resources/auth/auth.mjs +1 -1
  39. package/dist/resources/auth/index.d.mts +1 -1
  40. package/dist/resources/auth/index.mjs +2 -2
  41. package/dist/resources/auth/session.d.mts +1 -1
  42. package/dist/resources/auth/session.mjs +1 -1
  43. package/dist/resources/auth-configs.d.mts +1 -1
  44. package/dist/resources/auth-configs.mjs +1 -1
  45. package/dist/resources/auth.d.mts +1 -1
  46. package/dist/resources/auth.mjs +2 -2
  47. package/dist/resources/cli/cli.d.mts +1 -1
  48. package/dist/resources/cli/cli.mjs +1 -1
  49. package/dist/resources/cli/index.d.mts +1 -1
  50. package/dist/resources/cli/index.mjs +2 -2
  51. package/dist/resources/cli/realtime.d.mts +1 -1
  52. package/dist/resources/cli/realtime.mjs +1 -1
  53. package/dist/resources/cli.d.mts +1 -1
  54. package/dist/resources/cli.mjs +2 -2
  55. package/dist/resources/connected-accounts.d.mts +1 -1
  56. package/dist/resources/connected-accounts.mjs +1 -1
  57. package/dist/resources/custom.d.mts +1 -1
  58. package/dist/resources/custom.mjs +1 -1
  59. package/dist/resources/files.d.mts +1 -1
  60. package/dist/resources/files.mjs +1 -1
  61. package/dist/resources/index.d.mts +1 -1
  62. package/dist/resources/index.mjs +13 -13
  63. package/dist/resources/keyring.d.mts +1 -1
  64. package/dist/resources/keyring.mjs +1 -1
  65. package/dist/resources/link.d.mts +1 -1
  66. package/dist/resources/link.mjs +1 -1
  67. package/dist/resources/logs/index.d.mts +1 -1
  68. package/dist/resources/logs/index.mjs +3 -3
  69. package/dist/resources/logs/logs.d.mts +1 -1
  70. package/dist/resources/logs/logs.mjs +1 -1
  71. package/dist/resources/logs/tools.d.mts +1 -1
  72. package/dist/resources/logs/tools.mjs +1 -1
  73. package/dist/resources/logs/triggers.d.mts +1 -1
  74. package/dist/resources/logs/triggers.mjs +1 -1
  75. package/dist/resources/logs.d.mts +1 -1
  76. package/dist/resources/logs.mjs +3 -3
  77. package/dist/resources/mcp/custom.d.mts +1 -1
  78. package/dist/resources/mcp/custom.mjs +1 -1
  79. package/dist/resources/mcp/generate.d.mts +1 -1
  80. package/dist/resources/mcp/generate.mjs +1 -1
  81. package/dist/resources/mcp/index.d.mts +1 -1
  82. package/dist/resources/mcp/index.mjs +3 -3
  83. package/dist/resources/mcp/mcp.d.mts +1 -1
  84. package/dist/resources/mcp/mcp.mjs +1 -1
  85. package/dist/resources/mcp.d.mts +1 -1
  86. package/dist/resources/mcp.mjs +3 -3
  87. package/dist/resources/org/clanker.d.mts +1 -1
  88. package/dist/resources/org/clanker.mjs +1 -1
  89. package/dist/resources/org/consumer/consumer.d.mts +1 -1
  90. package/dist/resources/org/consumer/consumer.mjs +1 -1
  91. package/dist/resources/org/consumer/index.d.mts +1 -1
  92. package/dist/resources/org/consumer/index.mjs +2 -2
  93. package/dist/resources/org/consumer/project.d.mts +1 -1
  94. package/dist/resources/org/consumer/project.mjs +1 -1
  95. package/dist/resources/org/consumer.d.mts +1 -1
  96. package/dist/resources/org/consumer.mjs +2 -2
  97. package/dist/resources/org/index.d.mts +1 -1
  98. package/dist/resources/org/index.mjs +6 -6
  99. package/dist/resources/org/org.d.mts +1 -1
  100. package/dist/resources/org/org.mjs +1 -1
  101. package/dist/resources/org/owner/index.d.mts +1 -1
  102. package/dist/resources/org/owner/index.mjs +2 -2
  103. package/dist/resources/org/owner/owner.d.mts +1 -1
  104. package/dist/resources/org/owner/owner.mjs +1 -1
  105. package/dist/resources/org/owner/project.d.mts +1 -1
  106. package/dist/resources/org/owner/project.mjs +1 -1
  107. package/dist/resources/org/owner.d.mts +1 -1
  108. package/dist/resources/org/owner.mjs +2 -2
  109. package/dist/resources/org/project.d.mts +1 -1
  110. package/dist/resources/org/project.mjs +1 -1
  111. package/dist/resources/org/usage.d.mts +1 -1
  112. package/dist/resources/org/usage.mjs +1 -1
  113. package/dist/resources/org.d.mts +1 -1
  114. package/dist/resources/org.mjs +6 -6
  115. package/dist/resources/project/index.d.mts +1 -1
  116. package/dist/resources/project/index.mjs +1 -1
  117. package/dist/resources/project/project.d.mts +1 -1
  118. package/dist/resources/project/project.mjs +1 -1
  119. package/dist/resources/project/usage.d.mts +1 -1
  120. package/dist/resources/project/usage.mjs +1 -1
  121. package/dist/resources/project.d.mts +1 -1
  122. package/dist/resources/project.mjs +1 -1
  123. package/dist/resources/session-configs.d.mts +1 -1
  124. package/dist/resources/session-configs.mjs +1 -1
  125. package/dist/resources/tool-router/index.d.mts +1 -1
  126. package/dist/resources/tool-router/index.mjs +2 -2
  127. package/dist/resources/tool-router/session/files.d.mts +1 -1
  128. package/dist/resources/tool-router/session/files.mjs +1 -1
  129. package/dist/resources/tool-router/session/index.d.mts +1 -1
  130. package/dist/resources/tool-router/session/index.mjs +2 -2
  131. package/dist/resources/tool-router/session/session.d.mts +1 -1
  132. package/dist/resources/tool-router/session/session.mjs +1 -1
  133. package/dist/resources/tool-router/session.d.mts +1 -1
  134. package/dist/resources/tool-router/session.mjs +2 -2
  135. package/dist/resources/tool-router/tool-router.d.mts +1 -1
  136. package/dist/resources/tool-router/tool-router.mjs +1 -1
  137. package/dist/resources/tool-router.d.mts +1 -1
  138. package/dist/resources/tool-router.mjs +2 -2
  139. package/dist/resources/toolkits.d.mts +1 -1
  140. package/dist/resources/toolkits.mjs +1 -1
  141. package/dist/resources/tools.d.mts +1 -1
  142. package/dist/resources/tools.mjs +1 -1
  143. package/dist/resources/trigger-instances/index.d.mts +1 -1
  144. package/dist/resources/trigger-instances/index.mjs +2 -2
  145. package/dist/resources/trigger-instances/manage.d.mts +1 -1
  146. package/dist/resources/trigger-instances/manage.mjs +1 -1
  147. package/dist/resources/trigger-instances/trigger-instances.d.mts +1 -1
  148. package/dist/resources/trigger-instances/trigger-instances.mjs +1 -1
  149. package/dist/resources/trigger-instances.d.mts +1 -1
  150. package/dist/resources/trigger-instances.mjs +2 -2
  151. package/dist/resources/triggers-types.d.mts +1 -1
  152. package/dist/resources/triggers-types.mjs +1 -1
  153. package/dist/resources/webhook-endpoints.d.mts +1 -1
  154. package/dist/resources/webhook-endpoints.mjs +1 -1
  155. package/dist/resources/webhook-subscriptions.d.mts +1 -1
  156. package/dist/resources/webhook-subscriptions.mjs +1 -1
  157. package/dist/{session-Dm8WtF4I.mjs → session-BT5NJfbm.mjs} +1 -1
  158. package/dist/{session-DEfDnHZZ.mjs → session-BmXeclWC.mjs} +2 -2
  159. package/dist/{session-configs-nA6TL_i4.d.mts → session-configs-x3OA4CSe.d.mts} +179 -102
  160. package/dist/{tool-router-6l_dREjC.mjs → tool-router-DYPUf-fN.mjs} +1 -1
  161. package/dist/{toolkits-Mn_uLV98.mjs → toolkits-DZOZDm-4.mjs} +1 -1
  162. package/dist/{tools-btk0mzFP.mjs → tools-BDCRk80t.mjs} +1 -1
  163. package/dist/{tools-z-PjBsf7.mjs → tools-C0GjPEpP.mjs} +1 -1
  164. package/dist/{trigger-instances-PQaObQQy.mjs → trigger-instances-J5frdgzO.mjs} +2 -2
  165. package/dist/{triggers-y0mi0XzT.mjs → triggers-CnvE7y0L.mjs} +1 -1
  166. package/dist/{triggers-types-KoRbT0k5.mjs → triggers-types-DLVCtuwC.mjs} +1 -1
  167. package/dist/{usage-B2Z947BK.mjs → usage-DPxuivP6.mjs} +1 -1
  168. package/dist/{usage-DvjkSmpI.mjs → usage-DjQg9WIV.mjs} +1 -1
  169. package/dist/version-DEAhxVwC.d.mts +4 -0
  170. package/dist/{webhook-endpoints-kf4Jj2Mz.mjs → webhook-endpoints-BrSjXOf0.mjs} +1 -1
  171. package/dist/{webhook-subscriptions-DcYN8qo1.mjs → webhook-subscriptions-HT1acmwH.mjs} +1 -1
  172. package/package.json +2 -2
  173. package/dist/version-DUxhnnPj.d.mts +0 -4
package/dist/effect.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { h as makeAPIErrorMessage, m as errorDetails, s as ComposioError } from "./error-D9cG225M.mjs";
2
- import { A as callerPlacedCredential, C as resolveIdentity, D as matchOperation, E as inspectDeprecation, F as mergeHeaders, M as parseHTTPURL, N as resolveHTTPURL, O as SCHEME_HEADERS, P as buildHeaders, S as assertNoReservedHeaders, T as inspectDeprecatedInputs, _ as schemeForRequest, a as TOO_MANY_REDIRECTS, c as buildURL, d as path, f as printableURL, g as safeJSON, h as rewriteForRedirect, i as REDIRECT_STATUSES, j as carriesCredentials, k as assertCredentialTransport, m as retryDelayMillis, n as generatedOperation, o as buildBody, r as OPAQUE_REDIRECT, s as buildRequestHeaders, t as GENERATED_OPERATIONS, v as shouldRetryResponse, w as VERSION, y as validatePositiveInteger } from "./generated-operations-D1e__yar.mjs";
3
- import { r as classifySuccessBody, t as GENERATED_DEPRECATED_INPUTS } from "./generated-deprecated-inputs--L5LHDO_.mjs";
4
- import { i as standardNextCursor, n as assertPageItems, r as isFinalCursor, t as assertCursorAdvanced } from "./pagination-rules-uMUdPq_7.mjs";
1
+ import { h as makeAPIErrorMessage, m as errorDetails, s as ComposioError } from "./error-Bw7_G2NZ.mjs";
2
+ import { B as unusableKeyError, C as resolveIdentity, D as inspectDeprecatedInputs, E as mergeHeaders, F as chooseCredential, G as resolveHTTPURL, H as assertCredentialTransport, I as isUsableKey, K as sameOrigin, L as resolveAuth, M as assertRequiredOperationHeaders, N as authConstructors, O as inspectDeprecation, P as authFromCredentials, R as resolveScope, S as reservedHeaders, T as buildHeaders, U as carriesCredentials, V as SCHEME_HEADERS, W as parseHTTPURL, _ as shouldRetryResponse, a as TOO_MANY_REDIRECTS, c as buildURL, d as path, f as printableURL, g as safeJSON, h as rewriteForRedirect, i as REDIRECT_STATUSES, j as assertNoRemovedCredentialOptions, k as matchOperation, m as retryDelayMillis, n as generatedOperation, o as buildBody, q as schemeHeader, r as OPAQUE_REDIRECT, s as buildRequestHeaders, t as GENERATED_OPERATIONS, v as validatePositiveInteger, w as VERSION, x as assertNoReservedHeaders, z as scopeForCall } from "./generated-operations-DKgGT6Dg.mjs";
3
+ import { r as classifySuccessBody, t as GENERATED_DEPRECATED_INPUTS } from "./generated-deprecated-inputs-zx6ml908.mjs";
4
+ import { i as standardNextCursor, n as assertPageItems, r as isFinalCursor, t as assertCursorAdvanced } from "./pagination-rules-CMnBwktJ.mjs";
5
5
  import { Config, Context, Data, Effect, Exit, Layer, Match, Option, Predicate, Redacted, Result, Stream, Tracer } from "effect";
6
6
  import * as FetchHttpClient from "effect/http/FetchHttpClient";
7
7
  import * as HttpClient from "effect/http/HttpClient";
@@ -12,68 +12,6 @@ import { StatusCodeError, isHttpClientError } from "effect/http/HttpClientError"
12
12
  import * as HttpClientRequest from "effect/http/HttpClientRequest";
13
13
  import * as UrlParams from "effect/http/UrlParams";
14
14
 
15
- //#region src/effect/credentials.ts
16
- /**
17
- * How the Effect kernel holds credentials, and how it keeps them out of what
18
- * the transport records.
19
- *
20
- * Which credential a request carries, and where it may go, is decided by the
21
- * compat kernel's own functions (`../compat/credentials.ts`); nothing here
22
- * restates a rule. What is specific to this surface is the wrapping — a
23
- * credential is a `Redacted` for as long as the client holds it — and Effect's
24
- * redaction list, which knows `x-api-key` and not the other two schemes.
25
- */
26
- const reveal = (credential) => credential === null ? null : Redacted.value(credential);
27
- /** The credentials in the plain form the compat functions take. Never stored. */
28
- const revealCredentials = (held) => ({
29
- apiKey: reveal(held.apiKey),
30
- userApiKey: reveal(held.userApiKey),
31
- orgApiKey: reveal(held.orgApiKey)
32
- });
33
- const OPTION_HEADERS = {
34
- apiKey: SCHEME_HEADERS.ApiKeyAuth,
35
- userApiKey: SCHEME_HEADERS.UserApiKeyAuth,
36
- orgApiKey: SCHEME_HEADERS.OrgApiKeyAuth
37
- };
38
- const CREDENTIAL_OPTIONS = Object.keys(OPTION_HEADERS);
39
- /** Whether the platform's `Headers` takes `value` under `name`. Its refusal quotes the value, so it stays here. */
40
- const isSendable = (name, value) => {
41
- try {
42
- new globalThis.Headers().set(name, value);
43
- return true;
44
- } catch {
45
- return false;
46
- }
47
- };
48
- /**
49
- * The option naming a credential no header can carry (an interior CR, LF or
50
- * NUL, or a character outside Latin-1), or `undefined` when all of them can be
51
- * sent. The answer is the option's name and never the value.
52
- */
53
- const unsendableCredential = (held) => CREDENTIAL_OPTIONS.find((option) => {
54
- const credential = held[option];
55
- return credential !== null && !isSendable(OPTION_HEADERS[option], Redacted.value(credential));
56
- });
57
- const CREDENTIAL_HEADER_NAMES = Object.values(SCHEME_HEADERS);
58
- /** The extended list for each list seen, so a request does not rebuild it. */
59
- const extended = /* @__PURE__ */ new WeakMap();
60
- /**
61
- * Effect's redaction list with every credential header name on it, so a span
62
- * attribute or a rendering of the request made while the transport handles it
63
- * shows `<redacted>` for all three.
64
- *
65
- * The list in context is extended, not replaced: an application that added
66
- * names of its own keeps them.
67
- */
68
- const withCredentialHeaderNames = (names) => {
69
- const known = extended.get(names);
70
- if (known !== void 0) return known;
71
- const all = [...names, ...CREDENTIAL_HEADER_NAMES.filter((name) => !Headers.isRedactedName(name, names))];
72
- extended.set(names, all);
73
- return all;
74
- };
75
-
76
- //#endregion
77
15
  //#region src/effect/errors.ts
78
16
  /**
79
17
  * The failure model of the Effect surface: flat tagged errors, one per status
@@ -178,6 +116,88 @@ const isAPIError = (value) => kindOf(value) === "status";
178
116
  /** Whether a value is any error this surface produces. Structural, like {@link isAPIError}. */
179
117
  const isComposioError = (value) => kindOf(value) !== void 0;
180
118
 
119
+ //#endregion
120
+ //#region src/effect/credentials.ts
121
+ /**
122
+ * How the Effect kernel holds credentials, and how it keeps them out of what
123
+ * the transport records.
124
+ *
125
+ * Which credential a request carries, and where it may go, is decided by the
126
+ * compat kernel's own functions (`../compat/credentials.ts`); nothing here
127
+ * restates a rule. What is specific to this surface is the wrapping — a
128
+ * credential is a `Redacted` for as long as the client holds it — and Effect's
129
+ * redaction list, which knows `x-api-key` and not the other two schemes.
130
+ */
131
+ const isEffectCredential = (value) => typeof value === "string" || typeof value === "function" || Redacted.isRedacted(value);
132
+ /** The key inside a credential that is one, and `undefined` for a provider. */
133
+ const keyOf = (credential) => typeof credential === "string" ? credential : Redacted.isRedacted(credential) ? Redacted.value(credential) : void 0;
134
+ /** Refuses a key no header can carry. The error names the option and never the value. */
135
+ const checkEffectKey = (credential, option) => {
136
+ const key = keyOf(credential);
137
+ if (key !== void 0 && !isUsableKey("ApiKeyAuth", key)) throw unusableKeyError(`\`${option}\``);
138
+ };
139
+ /** Wraps every key `auth` holds, so the kernel never keeps one in the clear. */
140
+ const holdAuth = (auth) => ({
141
+ mode: auth.mode,
142
+ credentials: Object.fromEntries(Object.entries(auth.credentials).map(([scheme, credential]) => [scheme, typeof credential === "function" ? credential : Redacted.isRedacted(credential) ? credential : Redacted.make(credential)]))
143
+ });
144
+ const reveal = (key) => typeof key === "string" ? key : Redacted.value(key);
145
+ const providerFailed = () => new ConfigurationError({ message: "The `auth` credential provider failed." });
146
+ /**
147
+ * The credential one call carries, its provider asked at most once and before
148
+ * any network work; the rule is the compat kernel's `resolveCallCredential`.
149
+ * A configured credential is asked for only when the call starts on the API
150
+ * origin. A provider that fails, or returns something no header can carry,
151
+ * fails the call with a `ConfigurationError` that holds neither the
152
+ * provider's error nor the value.
153
+ */
154
+ const resolveCallCredential = (auth, baseURL, operation, supplied, requestURL) => Effect.suspend(() => {
155
+ let choice;
156
+ try {
157
+ choice = chooseCredential(auth, operation, supplied);
158
+ } catch (cause) {
159
+ return Effect.fail(configurationErrorFrom(cause));
160
+ }
161
+ if (choice === null) return Effect.succeed(null);
162
+ const name = schemeHeader(choice.scheme);
163
+ if (choice.kind === "operation") return Effect.succeed({
164
+ name,
165
+ value: choice.key
166
+ });
167
+ if (!sameOrigin(baseURL, requestURL)) return Effect.succeed(null);
168
+ const credential = choice.credential;
169
+ if (typeof credential !== "function") return Effect.succeed({
170
+ name,
171
+ value: Redacted.value(credential)
172
+ });
173
+ const scheme = choice.scheme;
174
+ return Effect.tryPromise({
175
+ try: async () => reveal(await credential()),
176
+ catch: providerFailed
177
+ }).pipe(Effect.flatMap((key) => isUsableKey(scheme, key) ? Effect.succeed({
178
+ name,
179
+ value: key
180
+ }) : Effect.fail(configurationErrorFrom(unusableKeyError("The key the `auth` credential provider returned")))));
181
+ });
182
+ const CREDENTIAL_HEADER_NAMES = Object.values(SCHEME_HEADERS);
183
+ /** The extended list for each list seen, so a request does not rebuild it. */
184
+ const extended = /* @__PURE__ */ new WeakMap();
185
+ /**
186
+ * Effect's redaction list with every credential header name on it, so a span
187
+ * attribute or a rendering of the request made while the transport handles it
188
+ * shows `<redacted>` for all three.
189
+ *
190
+ * The list in context is extended, not replaced: an application that added
191
+ * names of its own keeps them.
192
+ */
193
+ const withCredentialHeaderNames = (names) => {
194
+ const known = extended.get(names);
195
+ if (known !== void 0) return known;
196
+ const all = [...names, ...CREDENTIAL_HEADER_NAMES.filter((name) => !Headers.isRedactedName(name, names))];
197
+ extended.set(names, all);
198
+ return all;
199
+ };
200
+
181
201
  //#endregion
182
202
  //#region src/effect/decode.ts
183
203
  /**
@@ -380,10 +400,11 @@ const substitute = (template, params) => {
380
400
  const statics = template.split(PLACEHOLDER);
381
401
  return path(Object.assign(statics, { raw: statics }), ...params);
382
402
  };
383
- const hopHeaders = (prepared, hop) => buildRequestHeaders(prepared.headerConfig, { headers: prepared.callHeaders }, hop.url, hop.bodyHeaders, hop.withdrawn, prepared.scheme, prepared.callerPlaced);
384
- const prepare = (kernel, call) => {
403
+ const hopHeaders = (prepared, hop) => buildRequestHeaders(prepared.headerConfig, { headers: prepared.callHeaders }, hop.url, hop.bodyHeaders, hop.withdrawn, prepared.call);
404
+ const check = (kernel, call) => {
385
405
  const callHeaders = call.headers();
386
- assertNoReservedHeaders(callHeaders, kernel.identity, "headers");
406
+ assertNoReservedHeaders(callHeaders, kernel.reserved, "headers");
407
+ if (!call.recovered) assertRequiredOperationHeaders(call.operation, call.operationHeaders);
387
408
  const path = call.path();
388
409
  if (call.options?.timeout !== void 0) validatePositiveInteger("timeout", call.options.timeout);
389
410
  const resolvedRetries = call.options?.maxRetries ?? kernel.maxRetries;
@@ -400,8 +421,7 @@ const prepare = (kernel, call) => {
400
421
  query: call.query
401
422
  });
402
423
  const { body, bodyHeaders } = buildBody({ body: call.body });
403
- const credentials = revealCredentials(kernel);
404
- const shared = {
424
+ return {
405
425
  method: call.method,
406
426
  path,
407
427
  label: printableURL(url, call.operation),
@@ -409,36 +429,59 @@ const prepare = (kernel, call) => {
409
429
  query,
410
430
  headerConfig: {
411
431
  baseURL: kernel.baseURL,
412
- credentials,
413
432
  allowedHTTPOrigin: kernel.allowedHTTPOrigin,
414
433
  userAgent: kernel.userAgent,
415
434
  defaultHeaders: kernel.defaultHeaders,
416
435
  identity: kernel.identity
417
436
  },
418
437
  callHeaders,
419
- scheme: schemeForRequest({ credentials }, call.operation),
420
- callerPlaced: callerPlacedCredential([kernel.defaultHeaders, callHeaders]),
438
+ scope: scopeForCall(kernel.scope, call.operationHeaders),
421
439
  maxRetries,
422
440
  timeout: call.options?.timeout ?? kernel.timeout,
423
- schemas: decode ? kernel.schemas : void 0
424
- };
425
- const first = {
441
+ schemas: decode ? kernel.schemas : void 0,
426
442
  url,
427
- method: call.method.toUpperCase(),
428
443
  body,
429
- bodyHeaders,
430
- withdrawn: false,
431
- index: 0
432
- };
433
- return {
434
- ...shared,
435
- first: {
436
- ...first,
437
- headers: hopHeaders(shared, first)
438
- }
444
+ bodyHeaders
439
445
  };
440
446
  };
441
447
  /**
448
+ * A call resolved against the client: checked, its credential resolved once
449
+ * (a provider is asked here, and its key reused by every attempt and hop),
450
+ * and its first hop built. Whatever fails here is the caller's setup, never
451
+ * the network, and is not retried.
452
+ */
453
+ const prepare = (kernel, call) => Effect.flatMap(Effect.try({
454
+ try: () => check(kernel, call),
455
+ catch: configurationErrorFrom
456
+ }), (checked) => Effect.flatMap(resolveCallCredential(kernel.auth, kernel.baseURL, call.operation, call.operationHeaders, checked.url), (credential) => Effect.try({
457
+ try: () => {
458
+ const { scope, url, body, bodyHeaders, ...rest } = checked;
459
+ const shared = {
460
+ ...rest,
461
+ call: {
462
+ credential,
463
+ scope
464
+ }
465
+ };
466
+ const first = {
467
+ url,
468
+ method: call.method.toUpperCase(),
469
+ body,
470
+ bodyHeaders,
471
+ withdrawn: false,
472
+ index: 0
473
+ };
474
+ return {
475
+ ...shared,
476
+ first: {
477
+ ...first,
478
+ headers: hopHeaders(shared, first)
479
+ }
480
+ };
481
+ },
482
+ catch: configurationErrorFrom
483
+ })));
484
+ /**
442
485
  * Built from its parts rather than through `HttpClientRequest.make`: the URL
443
486
  * already carries its query, serialized by the compat rules, and must reach
444
487
  * the transport as that exact string. The body goes out as the same JSON text
@@ -721,10 +764,7 @@ const parse = (prepared, response, headers) => {
721
764
  catch: () => invalidJSON(prepared, response)
722
765
  }), (body) => validated(prepared, response, body)));
723
766
  };
724
- const dispatch = (kernel, call) => Effect.try({
725
- try: () => prepare(kernel, call),
726
- catch: configurationErrorFrom
727
- }).pipe(Effect.flatMap((prepared) => {
767
+ const dispatch = (kernel, call) => prepare(kernel, call).pipe(Effect.flatMap((prepared) => {
728
768
  const noticed = call.recovered || prepared.operation?.hasDeprecatedInputs === true ? noticeDeprecatedInputs(kernel.notices, {
729
769
  operation: prepared.operation,
730
770
  query: prepared.query,
@@ -756,6 +796,7 @@ const executeOperation = (kernel, operation, args, options) => dispatch(kernel,
756
796
  query: args.query,
757
797
  body: args.body,
758
798
  headers: () => args.headers === void 0 ? options?.headers : mergeHeaders([args.headers, options?.headers]),
799
+ operationHeaders: args.operationHeaders,
759
800
  operation,
760
801
  recovered: false,
761
802
  options
@@ -772,6 +813,7 @@ const executeRaw = (kernel, method, path, options) => dispatch(kernel, {
772
813
  query: options?.query,
773
814
  body: options?.body,
774
815
  headers: () => options?.headers,
816
+ operationHeaders: void 0,
775
817
  operation: matchOperation(method, path, GENERATED_OPERATIONS),
776
818
  recovered: true,
777
819
  options
@@ -1206,7 +1248,7 @@ const makeCli = (kernel) => ({
1206
1248
  const { "x-user-api-key": xUserApiKey, ...body } = params;
1207
1249
  return executeOperation(kernel, OP_CREATE_CODACT_FAILURE, {
1208
1250
  body,
1209
- headers: { ...xUserApiKey != null ? { "x-user-api-key": xUserApiKey } : void 0 }
1251
+ operationHeaders: { "x-user-api-key": xUserApiKey }
1210
1252
  }, options);
1211
1253
  },
1212
1254
  createSession: (body = {}, options) => executeOperation(kernel, OP_CREATE_SESSION, { body }, options),
@@ -1337,9 +1379,9 @@ const makeOwner = (kernel) => ({ project: makeProject$2(kernel) });
1337
1379
  const OP_RESOLVE = generatedOperation("org.consumer.project.resolve");
1338
1380
  const makeProject$1 = (kernel) => ({ resolve: (params, options) => {
1339
1381
  const { "x-user-api-key": xUserApiKey, "x-org-id": xOrgId } = params;
1340
- return executeOperation(kernel, OP_RESOLVE, { headers: {
1341
- ...xUserApiKey != null ? { "x-user-api-key": xUserApiKey } : void 0,
1342
- ...xOrgId != null ? { "x-org-id": xOrgId } : void 0
1382
+ return executeOperation(kernel, OP_RESOLVE, { operationHeaders: {
1383
+ "x-user-api-key": xUserApiKey,
1384
+ "x-org-id": xOrgId
1343
1385
  } }, options);
1344
1386
  } });
1345
1387
 
@@ -1352,9 +1394,9 @@ const makeConsumer = (kernel) => ({
1352
1394
  const { "x-user-api-key": xUserApiKey, "x-org-id": xOrgId, ...query } = params;
1353
1395
  return executeOperation(kernel, OP_LIST_CONNECTED_TOOLKITS, {
1354
1396
  query,
1355
- headers: {
1356
- ...xUserApiKey != null ? { "x-user-api-key": xUserApiKey } : void 0,
1357
- ...xOrgId != null ? { "x-org-id": xOrgId } : void 0
1397
+ operationHeaders: {
1398
+ "x-user-api-key": xUserApiKey,
1399
+ "x-org-id": xOrgId
1358
1400
  }
1359
1401
  }, options);
1360
1402
  }
@@ -1480,51 +1522,56 @@ const createClientResources = (kernel) => ({
1480
1522
  * {@link layerConfig}, which reads the `COMPOSIO_*` settings through Effect's
1481
1523
  * `Config` — so the `ConfigProvider` in context decides where they come from.
1482
1524
  */
1525
+ /**
1526
+ * The constructors of {@link Auth}, the same as the root entry's: `Auth.project(key)`,
1527
+ * `Auth.user(key)`, `Auth.organization(key)`, `Auth.auto({ ... })` and
1528
+ * `Auth.none()`. A key may be a string, a `Redacted<string>`, or a function
1529
+ * that returns either.
1530
+ */
1531
+ const Auth = authConstructors();
1483
1532
  var ComposioClient = class extends Context.Service()("@composio/client/effect/ComposioClient") {};
1484
1533
  const DEFAULT_BASE_URL = "https://backend.composio.dev";
1485
1534
  const DEFAULT_MAX_RETRIES = 2;
1486
1535
  const DEFAULT_TIMEOUT = 6e4;
1487
- const hold = (credential) => {
1488
- if (credential === null || credential === void 0) return null;
1489
- return Redacted.isRedacted(credential) ? credential : Redacted.make(credential);
1490
- };
1491
1536
  const resolveKernel = (options, httpClient) => {
1492
1537
  const baseURL = options.baseURL || DEFAULT_BASE_URL;
1493
1538
  if (options.decode === true && options.schemas === void 0) return Result.fail(new ConfigurationError({ message: SCHEMAS_MISSING }));
1494
- const identity = Result.try({
1539
+ const resolved = Result.try({
1495
1540
  try: () => {
1496
- const resolved = resolveIdentity(options.identity);
1497
- assertNoReservedHeaders(options.defaultHeaders, resolved, "defaultHeaders");
1498
- return resolved;
1541
+ assertNoRemovedCredentialOptions(options);
1542
+ const auth = resolveAuth(options.auth, isEffectCredential, checkEffectKey);
1543
+ const scope = resolveScope(options.scope);
1544
+ const identity = resolveIdentity(options.identity);
1545
+ const reserved = reservedHeaders(identity, {
1546
+ auth: auth.mode !== "none",
1547
+ scope: scope !== void 0
1548
+ });
1549
+ assertNoReservedHeaders(options.defaultHeaders, reserved, "defaultHeaders");
1550
+ const allowedHTTPOrigin = options.allowInsecureHTTP ? parseHTTPURL(baseURL)?.origin ?? null : null;
1551
+ assertCredentialTransport(baseURL, auth.mode !== "none", allowedHTTPOrigin);
1552
+ return {
1553
+ auth: holdAuth(auth),
1554
+ scope,
1555
+ identity,
1556
+ reserved,
1557
+ allowedHTTPOrigin
1558
+ };
1499
1559
  },
1500
1560
  catch: configurationErrorFrom
1501
1561
  });
1502
- if (Result.isFailure(identity)) return Result.fail(identity.failure);
1503
- const kernel = {
1562
+ if (Result.isFailure(resolved)) return Result.fail(resolved.failure);
1563
+ return Result.succeed({
1504
1564
  httpClient,
1505
1565
  baseURL,
1506
- apiKey: hold(options.apiKey),
1507
- userApiKey: hold(options.userApiKey),
1508
- orgApiKey: hold(options.orgApiKey),
1509
- allowedHTTPOrigin: options.allowInsecureHTTP ? parseHTTPURL(baseURL)?.origin ?? null : null,
1566
+ ...resolved.success,
1510
1567
  userAgent: `Composio/JS ${VERSION}`,
1511
1568
  defaultHeaders: options.defaultHeaders,
1512
- identity: identity.success,
1513
1569
  maxRetries: options.maxRetries ?? DEFAULT_MAX_RETRIES,
1514
1570
  timeout: options.timeout ?? DEFAULT_TIMEOUT,
1515
1571
  tracing: options.tracing ?? "off",
1516
1572
  decode: options.decode ?? false,
1517
1573
  schemas: options.schemas,
1518
1574
  notices: makeNoticeRecord(options.deprecationNotices)
1519
- };
1520
- const unsendable = unsendableCredential(kernel);
1521
- if (unsendable !== void 0) return Result.fail(new ConfigurationError({ message: `The \`${unsendable}\` option cannot be sent as a header: it contains a line break, a NUL or a character outside Latin-1.` }));
1522
- return Result.try({
1523
- try: () => {
1524
- assertCredentialTransport(baseURL, revealCredentials(kernel), kernel.allowedHTTPOrigin);
1525
- return kernel;
1526
- },
1527
- catch: configurationErrorFrom
1528
1575
  });
1529
1576
  };
1530
1577
  const fromKernel = (kernel) => ({
@@ -1559,43 +1606,57 @@ const make = (options, httpClient) => fromKernel(makeKernel(options, httpClient)
1559
1606
  * Provides the client from explicit options and the `HttpClient` in context.
1560
1607
  * Reads no environment variable.
1561
1608
  */
1562
- const layer = (options = {}) => Layer.effect(ComposioClient, Effect.flatMap(HttpClient.HttpClient, (httpClient) => Effect.map(Effect.fromResult(resolveKernel(options, httpClient)), fromKernel)));
1609
+ const layer = (options) => Layer.effect(ComposioClient, Effect.flatMap(HttpClient.HttpClient, (httpClient) => Effect.map(Effect.fromResult(resolveKernel(options, httpClient)), fromKernel)));
1563
1610
  /**
1564
1611
  * {@link layer} over a fetch-backed `HttpClient`, for an application that has
1565
1612
  * no transport of its own to supply. `fetch` is the platform's, or whatever
1566
1613
  * the `FetchHttpClient.Fetch` reference in context names.
1567
1614
  */
1568
- const layerFetch = (options = {}) => Layer.provide(layer(options), FetchHttpClient.layer);
1569
- /** A setting as the compat client reads one: trimmed, and absent when empty. */
1615
+ const layerFetch = (options) => Layer.provide(layer(options), FetchHttpClient.layer);
1616
+ /** A setting as `Composio.fromEnv` reads one: trimmed, and absent when empty. */
1570
1617
  const setting = (name) => Config.map(Config.option(Config.String(name)), (value) => Option.getOrUndefined(Option.filter(Option.map(value, (text) => text.trim()), (text) => text !== "")));
1618
+ /** A key, read as `Redacted` and kept that way: trimmed, and absent when empty. */
1619
+ const secret = (name) => Config.map(Config.option(Config.Redacted(name)), (value) => Option.getOrUndefined(Option.flatMap(value, (key) => {
1620
+ const trimmed = Redacted.value(key).trim();
1621
+ return trimmed === "" ? Option.none() : Option.some(Redacted.make(trimmed));
1622
+ })));
1571
1623
  const settings = Config.all({
1572
- apiKey: setting("COMPOSIO_API_KEY"),
1573
- userApiKey: setting("COMPOSIO_USER_API_KEY"),
1574
- orgApiKey: setting("COMPOSIO_ORG_API_KEY"),
1624
+ project: secret("COMPOSIO_API_KEY"),
1625
+ user: secret("COMPOSIO_USER_API_KEY"),
1626
+ organization: secret("COMPOSIO_ORG_API_KEY"),
1575
1627
  baseURL: setting("COMPOSIO_BASE_URL"),
1576
1628
  allowInsecureHTTP: setting("COMPOSIO_ALLOW_INSECURE_HTTP")
1577
1629
  });
1578
1630
  /**
1579
- * Provides the client from the `COMPOSIO_*` settings — `COMPOSIO_API_KEY`,
1580
- * `COMPOSIO_USER_API_KEY`, `COMPOSIO_ORG_API_KEY`, `COMPOSIO_BASE_URL` and
1581
- * `COMPOSIO_ALLOW_INSECURE_HTTP=1` — read through the `ConfigProvider` in
1582
- * context, which is the process environment unless the application says
1583
- * otherwise. An option given here wins over its setting; `null` for a
1584
- * credential means "none", whatever is configured.
1631
+ * Provides the client from the `COMPOSIO_*` settings, read through the
1632
+ * `ConfigProvider` in context, which is the process environment unless the
1633
+ * application says otherwise. `COMPOSIO_API_KEY`, `COMPOSIO_USER_API_KEY` and
1634
+ * `COMPOSIO_ORG_API_KEY` become `auth` by the rule `Composio.fromEnv` applies
1635
+ * (one set: that fixed mode; several: `Auth.auto`; none: `Auth.none()`), each
1636
+ * key `Redacted` throughout; `COMPOSIO_BASE_URL` and
1637
+ * `COMPOSIO_ALLOW_INSECURE_HTTP=1` are read too. `COMPOSIO_ORG_ID` and
1638
+ * `COMPOSIO_PROJECT_ID` are not: `scope` is an argument. An option given here
1639
+ * replaces the whole setting it names, so `{ auth: Auth.none() }` means none
1640
+ * whatever is configured.
1585
1641
  */
1586
- const layerConfig = (options = {}) => Layer.effect(ComposioClient, Effect.gen(function* () {
1642
+ const layerConfig = (overrides = {}) => Layer.effect(ComposioClient, Effect.gen(function* () {
1587
1643
  const httpClient = yield* HttpClient.HttpClient;
1588
1644
  const env = yield* Effect.mapError(settings, () => new ConfigurationError({ message: "The COMPOSIO_* configuration could not be read." }));
1645
+ const mapped = {
1646
+ auth: authFromCredentials({
1647
+ project: env.project,
1648
+ user: env.user,
1649
+ organization: env.organization
1650
+ }),
1651
+ ...env.baseURL !== void 0 ? { baseURL: env.baseURL } : {},
1652
+ ...env.allowInsecureHTTP === "1" ? { allowInsecureHTTP: true } : {}
1653
+ };
1589
1654
  const kernel = yield* Effect.fromResult(resolveKernel({
1590
- ...options,
1591
- apiKey: options.apiKey !== void 0 ? options.apiKey : env.apiKey,
1592
- userApiKey: options.userApiKey !== void 0 ? options.userApiKey : env.userApiKey,
1593
- orgApiKey: options.orgApiKey !== void 0 ? options.orgApiKey : env.orgApiKey,
1594
- baseURL: options.baseURL ?? env.baseURL,
1595
- allowInsecureHTTP: options.allowInsecureHTTP ?? env.allowInsecureHTTP === "1"
1655
+ ...mapped,
1656
+ ...overrides
1596
1657
  }, httpClient));
1597
1658
  return fromKernel(kernel);
1598
1659
  }));
1599
1660
 
1600
1661
  //#endregion
1601
- export { APIConnectionError, APIConnectionTimeoutError, APIError, AuthenticationError, BadRequestError, ComposioClient, ConfigurationError, ConflictError, DecodeError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, VERSION, isAPIError, isComposioError, layer, layerConfig, layerFetch, make };
1662
+ export { APIConnectionError, APIConnectionTimeoutError, APIError, Auth, AuthenticationError, BadRequestError, ComposioClient, ConfigurationError, ConflictError, DecodeError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, VERSION, isAPIError, isComposioError, layer, layerConfig, layerFetch, make };
@@ -51,7 +51,7 @@ var APIError = class APIError extends ComposioError {
51
51
  * `errors[]` and `suggested_fix` are reachable without casting `error`.
52
52
  *
53
53
  * Not part of the Stainless surface: a sanctioned superset, like
54
- * `ClientOptions.userApiKey`.
54
+ * `ClientOptions.identity`.
55
55
  */
56
56
  details;
57
57
  /**
@@ -1,4 +1,4 @@
1
- import { b as withOperation, d as path, n as generatedOperation } from "./generated-operations-D1e__yar.mjs";
1
+ import { d as path, n as generatedOperation, y as withOperation } from "./generated-operations-DKgGT6Dg.mjs";
2
2
 
3
3
  //#region src/compat/resources/tool-router/session/files.ts
4
4
  const OP_LIST = generatedOperation("toolRouter.session.files.list");
@@ -1,4 +1,4 @@
1
- import { b as withOperation, n as generatedOperation } from "./generated-operations-D1e__yar.mjs";
1
+ import { n as generatedOperation, y as withOperation } from "./generated-operations-DKgGT6Dg.mjs";
2
2
 
3
3
  //#region src/compat/resources/files.ts
4
4
  const OP_LIST = generatedOperation("files.list");
@@ -1,4 +1,4 @@
1
- import { b as withOperation, n as generatedOperation } from "./generated-operations-D1e__yar.mjs";
1
+ import { n as generatedOperation, y as withOperation } from "./generated-operations-DKgGT6Dg.mjs";
2
2
 
3
3
  //#region src/compat/resources/mcp/generate.ts
4
4
  const OP_URL = generatedOperation("mcp.generate.url");
@@ -1,5 +1,5 @@
1
- import { r as APIError } from "./error-D9cG225M.mjs";
2
- import { g as safeJSON, l as castToError } from "./generated-operations-D1e__yar.mjs";
1
+ import { r as APIError } from "./error-Bw7_G2NZ.mjs";
2
+ import { g as safeJSON, l as castToError } from "./generated-operations-DKgGT6Dg.mjs";
3
3
 
4
4
  //#region src/compat/api-promise.ts
5
5
  /**