@composio/client 2.0.0-rc.16 → 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 +146 -32
  2. package/dist/{api-key-revocation-CvGpd3Rw.mjs → api-key-revocation-JkA4sOGH.mjs} +1 -1
  3. package/dist/{auth-C0IYTv5D.mjs → auth-B_K-wdMm.mjs} +1 -1
  4. package/dist/{auth-configs-COmbnKYx.mjs → auth-configs-RAgN782Z.mjs} +1 -1
  5. package/dist/{clanker-hE4FKPjg.mjs → clanker-Pgyyh95r.mjs} +1 -1
  6. package/dist/{cli-CuFaxvp4.mjs → cli-Ca5bRiEN.mjs} +4 -5
  7. package/dist/{connected-accounts-BmbcAhdS.mjs → connected-accounts-D6NTwvbi.mjs} +1 -1
  8. package/dist/{consumer-BaJgJBXQ.mjs → consumer-BP4OyJS0.mjs} +6 -7
  9. package/dist/{custom-DIJbIQGR.mjs → custom-BBr7KbCv.mjs} +1 -1
  10. package/dist/{custom-DbEv7dUC.mjs → custom-DA3ABHnI.mjs} +1 -1
  11. package/dist/effect.d.mts +70 -26
  12. package/dist/effect.mjs +216 -141
  13. package/dist/{error-D9cG225M.mjs → error-Bw7_G2NZ.mjs} +1 -1
  14. package/dist/{files-Cw6ulQZy.mjs → files-CeBs4ZE1.mjs} +1 -1
  15. package/dist/{files-RPz_Fvnz.mjs → files-DLRmNLRD.mjs} +1 -1
  16. package/dist/{generate-DZXuXtYM.mjs → generate-16uLPwUU.mjs} +1 -1
  17. package/dist/{generated-deprecated-inputs-B6o8D8ub.mjs → generated-deprecated-inputs-zx6ml908.mjs} +2 -2
  18. package/dist/{generated-operations-DrhN6W_k.mjs → generated-operations-DKgGT6Dg.mjs} +572 -211
  19. package/dist/index.d.mts +3 -3
  20. package/dist/index.mjs +134 -100
  21. package/dist/{keyring-CmnkWH5K.mjs → keyring-Q8GSieAv.mjs} +1 -1
  22. package/dist/{link-C0KzTJBI.mjs → link-D4dY_eaN.mjs} +1 -1
  23. package/dist/{logs-Bj5MAt8z.mjs → logs-Dc63Ju74.mjs} +3 -3
  24. package/dist/{manage-DDFmGWNH.mjs → manage-ByF6b3OD.mjs} +1 -1
  25. package/dist/{mcp-DXmBAF09.mjs → mcp-Cw7-Mtkm.mjs} +3 -3
  26. package/dist/{org-D4J-n07N.mjs → org-RRUxKfRw.mjs} +6 -6
  27. package/dist/{owner-CfjgcAcM.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-Dw9JLelr.mjs → project-BsKmk9T7.mjs} +1 -1
  31. package/dist/{project-CnOrdnOM.mjs → project-C1uq7bV_.mjs} +1 -1
  32. package/dist/{project-7LL6W_tc.mjs → project-C_YZ-eLI.mjs} +4 -7
  33. package/dist/{project-CLrBv6tJ.mjs → project-Cj9ULE0a.mjs} +1 -1
  34. package/dist/{realtime-DQ_gT0q7.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-CtO_BX-m.mjs → session-BT5NJfbm.mjs} +1 -1
  158. package/dist/{session-Bmbv2Y2h.mjs → session-BmXeclWC.mjs} +2 -2
  159. package/dist/{session-configs-C_A0gUf5.d.mts → session-configs-x3OA4CSe.d.mts} +205 -97
  160. package/dist/{tool-router-BICZScC1.mjs → tool-router-DYPUf-fN.mjs} +1 -1
  161. package/dist/{toolkits-Cj8oNvQi.mjs → toolkits-DZOZDm-4.mjs} +1 -1
  162. package/dist/{tools-C-2Nsm32.mjs → tools-BDCRk80t.mjs} +1 -1
  163. package/dist/{tools-BiyVpJSA.mjs → tools-C0GjPEpP.mjs} +1 -1
  164. package/dist/{trigger-instances-0GIUz_qu.mjs → trigger-instances-J5frdgzO.mjs} +2 -2
  165. package/dist/{triggers-DWnL3gjv.mjs → triggers-CnvE7y0L.mjs} +1 -1
  166. package/dist/{triggers-types-BkigxzlE.mjs → triggers-types-DLVCtuwC.mjs} +1 -1
  167. package/dist/{usage-RRYqkjLH.mjs → usage-DPxuivP6.mjs} +1 -1
  168. package/dist/{usage-D9XlIZBX.mjs → usage-DjQg9WIV.mjs} +1 -1
  169. package/dist/version-DEAhxVwC.d.mts +4 -0
  170. package/dist/{webhook-endpoints-x3UiV7uH.mjs → webhook-endpoints-BrSjXOf0.mjs} +1 -1
  171. package/dist/{webhook-subscriptions-_7MTwe1s.mjs → webhook-subscriptions-HT1acmwH.mjs} +1 -1
  172. package/package.json +2 -2
  173. package/dist/version-BkHUhokz.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 parseHTTPURL, C as inspectDeprecatedInputs, D as assertCredentialTransport, E as SCHEME_HEADERS, M as buildHeaders, N as mergeHeaders, O as callerPlacedCredential, S as VERSION, T as matchOperation, _ 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 resolveHTTPURL, k as carriesCredentials, 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 inspectDeprecation, y as validatePositiveInteger } from "./generated-operations-DrhN6W_k.mjs";
3
- import { r as classifySuccessBody, t as GENERATED_DEPRECATED_INPUTS } from "./generated-deprecated-inputs-B6o8D8ub.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,9 +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();
406
+ assertNoReservedHeaders(callHeaders, kernel.reserved, "headers");
407
+ if (!call.recovered) assertRequiredOperationHeaders(call.operation, call.operationHeaders);
386
408
  const path = call.path();
387
409
  if (call.options?.timeout !== void 0) validatePositiveInteger("timeout", call.options.timeout);
388
410
  const resolvedRetries = call.options?.maxRetries ?? kernel.maxRetries;
@@ -399,8 +421,7 @@ const prepare = (kernel, call) => {
399
421
  query: call.query
400
422
  });
401
423
  const { body, bodyHeaders } = buildBody({ body: call.body });
402
- const credentials = revealCredentials(kernel);
403
- const shared = {
424
+ return {
404
425
  method: call.method,
405
426
  path,
406
427
  label: printableURL(url, call.operation),
@@ -408,35 +429,59 @@ const prepare = (kernel, call) => {
408
429
  query,
409
430
  headerConfig: {
410
431
  baseURL: kernel.baseURL,
411
- credentials,
412
432
  allowedHTTPOrigin: kernel.allowedHTTPOrigin,
413
433
  userAgent: kernel.userAgent,
414
- defaultHeaders: kernel.defaultHeaders
434
+ defaultHeaders: kernel.defaultHeaders,
435
+ identity: kernel.identity
415
436
  },
416
437
  callHeaders,
417
- scheme: schemeForRequest({ credentials }, call.operation),
418
- callerPlaced: callerPlacedCredential([kernel.defaultHeaders, callHeaders]),
438
+ scope: scopeForCall(kernel.scope, call.operationHeaders),
419
439
  maxRetries,
420
440
  timeout: call.options?.timeout ?? kernel.timeout,
421
- schemas: decode ? kernel.schemas : void 0
422
- };
423
- const first = {
441
+ schemas: decode ? kernel.schemas : void 0,
424
442
  url,
425
- method: call.method.toUpperCase(),
426
443
  body,
427
- bodyHeaders,
428
- withdrawn: false,
429
- index: 0
430
- };
431
- return {
432
- ...shared,
433
- first: {
434
- ...first,
435
- headers: hopHeaders(shared, first)
436
- }
444
+ bodyHeaders
437
445
  };
438
446
  };
439
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
+ /**
440
485
  * Built from its parts rather than through `HttpClientRequest.make`: the URL
441
486
  * already carries its query, serialized by the compat rules, and must reach
442
487
  * the transport as that exact string. The body goes out as the same JSON text
@@ -719,10 +764,7 @@ const parse = (prepared, response, headers) => {
719
764
  catch: () => invalidJSON(prepared, response)
720
765
  }), (body) => validated(prepared, response, body)));
721
766
  };
722
- const dispatch = (kernel, call) => Effect.try({
723
- try: () => prepare(kernel, call),
724
- catch: configurationErrorFrom
725
- }).pipe(Effect.flatMap((prepared) => {
767
+ const dispatch = (kernel, call) => prepare(kernel, call).pipe(Effect.flatMap((prepared) => {
726
768
  const noticed = call.recovered || prepared.operation?.hasDeprecatedInputs === true ? noticeDeprecatedInputs(kernel.notices, {
727
769
  operation: prepared.operation,
728
770
  query: prepared.query,
@@ -754,6 +796,7 @@ const executeOperation = (kernel, operation, args, options) => dispatch(kernel,
754
796
  query: args.query,
755
797
  body: args.body,
756
798
  headers: () => args.headers === void 0 ? options?.headers : mergeHeaders([args.headers, options?.headers]),
799
+ operationHeaders: args.operationHeaders,
757
800
  operation,
758
801
  recovered: false,
759
802
  options
@@ -770,6 +813,7 @@ const executeRaw = (kernel, method, path, options) => dispatch(kernel, {
770
813
  query: options?.query,
771
814
  body: options?.body,
772
815
  headers: () => options?.headers,
816
+ operationHeaders: void 0,
773
817
  operation: matchOperation(method, path, GENERATED_OPERATIONS),
774
818
  recovered: true,
775
819
  options
@@ -1204,7 +1248,7 @@ const makeCli = (kernel) => ({
1204
1248
  const { "x-user-api-key": xUserApiKey, ...body } = params;
1205
1249
  return executeOperation(kernel, OP_CREATE_CODACT_FAILURE, {
1206
1250
  body,
1207
- headers: { ...xUserApiKey != null ? { "x-user-api-key": xUserApiKey } : void 0 }
1251
+ operationHeaders: { "x-user-api-key": xUserApiKey }
1208
1252
  }, options);
1209
1253
  },
1210
1254
  createSession: (body = {}, options) => executeOperation(kernel, OP_CREATE_SESSION, { body }, options),
@@ -1335,9 +1379,9 @@ const makeOwner = (kernel) => ({ project: makeProject$2(kernel) });
1335
1379
  const OP_RESOLVE = generatedOperation("org.consumer.project.resolve");
1336
1380
  const makeProject$1 = (kernel) => ({ resolve: (params, options) => {
1337
1381
  const { "x-user-api-key": xUserApiKey, "x-org-id": xOrgId } = params;
1338
- return executeOperation(kernel, OP_RESOLVE, { headers: {
1339
- ...xUserApiKey != null ? { "x-user-api-key": xUserApiKey } : void 0,
1340
- ...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
1341
1385
  } }, options);
1342
1386
  } });
1343
1387
 
@@ -1350,9 +1394,9 @@ const makeConsumer = (kernel) => ({
1350
1394
  const { "x-user-api-key": xUserApiKey, "x-org-id": xOrgId, ...query } = params;
1351
1395
  return executeOperation(kernel, OP_LIST_CONNECTED_TOOLKITS, {
1352
1396
  query,
1353
- headers: {
1354
- ...xUserApiKey != null ? { "x-user-api-key": xUserApiKey } : void 0,
1355
- ...xOrgId != null ? { "x-org-id": xOrgId } : void 0
1397
+ operationHeaders: {
1398
+ "x-user-api-key": xUserApiKey,
1399
+ "x-org-id": xOrgId
1356
1400
  }
1357
1401
  }, options);
1358
1402
  }
@@ -1478,24 +1522,48 @@ const createClientResources = (kernel) => ({
1478
1522
  * {@link layerConfig}, which reads the `COMPOSIO_*` settings through Effect's
1479
1523
  * `Config` — so the `ConfigProvider` in context decides where they come from.
1480
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();
1481
1532
  var ComposioClient = class extends Context.Service()("@composio/client/effect/ComposioClient") {};
1482
1533
  const DEFAULT_BASE_URL = "https://backend.composio.dev";
1483
1534
  const DEFAULT_MAX_RETRIES = 2;
1484
1535
  const DEFAULT_TIMEOUT = 6e4;
1485
- const hold = (credential) => {
1486
- if (credential === null || credential === void 0) return null;
1487
- return Redacted.isRedacted(credential) ? credential : Redacted.make(credential);
1488
- };
1489
1536
  const resolveKernel = (options, httpClient) => {
1490
1537
  const baseURL = options.baseURL || DEFAULT_BASE_URL;
1491
1538
  if (options.decode === true && options.schemas === void 0) return Result.fail(new ConfigurationError({ message: SCHEMAS_MISSING }));
1492
- const kernel = {
1539
+ const resolved = Result.try({
1540
+ try: () => {
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
+ };
1559
+ },
1560
+ catch: configurationErrorFrom
1561
+ });
1562
+ if (Result.isFailure(resolved)) return Result.fail(resolved.failure);
1563
+ return Result.succeed({
1493
1564
  httpClient,
1494
1565
  baseURL,
1495
- apiKey: hold(options.apiKey),
1496
- userApiKey: hold(options.userApiKey),
1497
- orgApiKey: hold(options.orgApiKey),
1498
- allowedHTTPOrigin: options.allowInsecureHTTP ? parseHTTPURL(baseURL)?.origin ?? null : null,
1566
+ ...resolved.success,
1499
1567
  userAgent: `Composio/JS ${VERSION}`,
1500
1568
  defaultHeaders: options.defaultHeaders,
1501
1569
  maxRetries: options.maxRetries ?? DEFAULT_MAX_RETRIES,
@@ -1504,15 +1572,6 @@ const resolveKernel = (options, httpClient) => {
1504
1572
  decode: options.decode ?? false,
1505
1573
  schemas: options.schemas,
1506
1574
  notices: makeNoticeRecord(options.deprecationNotices)
1507
- };
1508
- const unsendable = unsendableCredential(kernel);
1509
- 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.` }));
1510
- return Result.try({
1511
- try: () => {
1512
- assertCredentialTransport(baseURL, revealCredentials(kernel), kernel.allowedHTTPOrigin);
1513
- return kernel;
1514
- },
1515
- catch: configurationErrorFrom
1516
1575
  });
1517
1576
  };
1518
1577
  const fromKernel = (kernel) => ({
@@ -1528,8 +1587,9 @@ const fromKernel = (kernel) => ({
1528
1587
  * are built over it, and it is not part of the entry's exports.
1529
1588
  *
1530
1589
  * @throws {ConfigurationError} when a credentialed origin is not HTTPS, a
1531
- * credential cannot be sent as a header, or the client is to decode and was
1532
- * given no schemas.
1590
+ * credential cannot be sent as a header, `identity` is invalid or
1591
+ * `defaultHeaders` names an identity header, or the client is to decode and
1592
+ * was given no schemas.
1533
1593
  */
1534
1594
  const makeKernel = (options, httpClient) => Result.getOrThrow(resolveKernel(options, httpClient));
1535
1595
  /**
@@ -1537,51 +1597,66 @@ const makeKernel = (options, httpClient) => Result.getOrThrow(resolveKernel(opti
1537
1597
  * Reads no environment variable.
1538
1598
  *
1539
1599
  * @throws {ConfigurationError} when a credentialed origin is not HTTPS, a
1540
- * credential cannot be sent as a header, or the client is to decode and was
1541
- * given no schemas.
1600
+ * credential cannot be sent as a header, `identity` is invalid or
1601
+ * `defaultHeaders` names an identity header, or the client is to decode and
1602
+ * was given no schemas.
1542
1603
  */
1543
1604
  const make = (options, httpClient) => fromKernel(makeKernel(options, httpClient));
1544
1605
  /**
1545
1606
  * Provides the client from explicit options and the `HttpClient` in context.
1546
1607
  * Reads no environment variable.
1547
1608
  */
1548
- 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)));
1549
1610
  /**
1550
1611
  * {@link layer} over a fetch-backed `HttpClient`, for an application that has
1551
1612
  * no transport of its own to supply. `fetch` is the platform's, or whatever
1552
1613
  * the `FetchHttpClient.Fetch` reference in context names.
1553
1614
  */
1554
- const layerFetch = (options = {}) => Layer.provide(layer(options), FetchHttpClient.layer);
1555
- /** 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. */
1556
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
+ })));
1557
1623
  const settings = Config.all({
1558
- apiKey: setting("COMPOSIO_API_KEY"),
1559
- userApiKey: setting("COMPOSIO_USER_API_KEY"),
1560
- 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"),
1561
1627
  baseURL: setting("COMPOSIO_BASE_URL"),
1562
1628
  allowInsecureHTTP: setting("COMPOSIO_ALLOW_INSECURE_HTTP")
1563
1629
  });
1564
1630
  /**
1565
- * Provides the client from the `COMPOSIO_*` settings — `COMPOSIO_API_KEY`,
1566
- * `COMPOSIO_USER_API_KEY`, `COMPOSIO_ORG_API_KEY`, `COMPOSIO_BASE_URL` and
1567
- * `COMPOSIO_ALLOW_INSECURE_HTTP=1` — read through the `ConfigProvider` in
1568
- * context, which is the process environment unless the application says
1569
- * otherwise. An option given here wins over its setting; `null` for a
1570
- * 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.
1571
1641
  */
1572
- const layerConfig = (options = {}) => Layer.effect(ComposioClient, Effect.gen(function* () {
1642
+ const layerConfig = (overrides = {}) => Layer.effect(ComposioClient, Effect.gen(function* () {
1573
1643
  const httpClient = yield* HttpClient.HttpClient;
1574
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
+ };
1575
1654
  const kernel = yield* Effect.fromResult(resolveKernel({
1576
- ...options,
1577
- apiKey: options.apiKey !== void 0 ? options.apiKey : env.apiKey,
1578
- userApiKey: options.userApiKey !== void 0 ? options.userApiKey : env.userApiKey,
1579
- orgApiKey: options.orgApiKey !== void 0 ? options.orgApiKey : env.orgApiKey,
1580
- baseURL: options.baseURL ?? env.baseURL,
1581
- allowInsecureHTTP: options.allowInsecureHTTP ?? env.allowInsecureHTTP === "1"
1655
+ ...mapped,
1656
+ ...overrides
1582
1657
  }, httpClient));
1583
1658
  return fromKernel(kernel);
1584
1659
  }));
1585
1660
 
1586
1661
  //#endregion
1587
- 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-DrhN6W_k.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-DrhN6W_k.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-DrhN6W_k.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-DrhN6W_k.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
  /**