@apifuse/provider-sdk 2.2.0-beta.3 → 2.2.0-beta.5

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 (165) hide show
  1. package/AUTHORING.md +53 -0
  2. package/CHANGELOG.md +8 -0
  3. package/bin/apifuse-check.ts +18 -58
  4. package/bin/apifuse-create.ts +1 -1
  5. package/bin/apifuse-dev.ts +27 -52
  6. package/bin/apifuse-pack-smoke.ts +22 -81
  7. package/bin/apifuse-pack-types.ts +266 -0
  8. package/bin/apifuse-perf.ts +45 -127
  9. package/bin/apifuse-record.ts +23 -61
  10. package/bin/apifuse-submit-check.ts +266 -34
  11. package/bin/apifuse.ts +1 -1
  12. package/bin/submit-check-xml.ts +1 -1
  13. package/dist/auth-turn/index.d.ts +1 -1
  14. package/dist/auth.d.ts +2 -2
  15. package/dist/auth.js +9 -18
  16. package/dist/ceremonies/index.d.ts +1 -1
  17. package/dist/ceremonies/index.js +8 -18
  18. package/dist/config/loader.d.ts +2 -2
  19. package/dist/config/loader.js +19 -42
  20. package/dist/contract-serialization.d.ts +2 -2
  21. package/dist/contract-serialization.js +3 -6
  22. package/dist/contract-types.d.ts +2 -2
  23. package/dist/contract.d.ts +3 -3
  24. package/dist/contract.js +4 -6
  25. package/dist/define.d.ts +8 -1
  26. package/dist/define.js +57 -115
  27. package/dist/dev.d.ts +1 -1
  28. package/dist/dev.js +1 -1
  29. package/dist/errors.d.ts +1 -1
  30. package/dist/errors.js +1 -3
  31. package/dist/i18n/catalog.d.ts +2 -2
  32. package/dist/i18n/catalog.js +4 -10
  33. package/dist/i18n/index.d.ts +2 -2
  34. package/dist/i18n/index.js +2 -2
  35. package/dist/i18n/keys.d.ts +2 -2
  36. package/dist/index.d.ts +43 -42
  37. package/dist/index.js +38 -37
  38. package/dist/lint.js +8 -15
  39. package/dist/provider.d.ts +11 -11
  40. package/dist/provider.js +9 -9
  41. package/dist/public-schema-field-lint.d.ts +1 -1
  42. package/dist/recipes/gov-api.js +1 -1
  43. package/dist/runtime/auth-flow.d.ts +1 -1
  44. package/dist/runtime/auth-flow.js +3 -3
  45. package/dist/runtime/browser.d.ts +1 -1
  46. package/dist/runtime/browser.js +15 -29
  47. package/dist/runtime/cache.d.ts +1 -1
  48. package/dist/runtime/cache.js +4 -8
  49. package/dist/runtime/choice.d.ts +1 -1
  50. package/dist/runtime/choice.js +12 -34
  51. package/dist/runtime/credential.d.ts +1 -1
  52. package/dist/runtime/credential.js +1 -1
  53. package/dist/runtime/env.d.ts +1 -1
  54. package/dist/runtime/executor.d.ts +1 -1
  55. package/dist/runtime/executor.js +2 -2
  56. package/dist/runtime/http.d.ts +2 -2
  57. package/dist/runtime/http.js +5 -5
  58. package/dist/runtime/insights.d.ts +1 -1
  59. package/dist/runtime/insights.js +6 -13
  60. package/dist/runtime/instrumentation.d.ts +2 -2
  61. package/dist/runtime/instrumentation.js +5 -15
  62. package/dist/runtime/keyring.js +1 -1
  63. package/dist/runtime/namespace.js +1 -1
  64. package/dist/runtime/otlp.d.ts +1 -1
  65. package/dist/runtime/perf.d.ts +1 -1
  66. package/dist/runtime/provider.d.ts +1 -1
  67. package/dist/runtime/provider.js +1 -2
  68. package/dist/runtime/proxy-errors.d.ts +1 -1
  69. package/dist/runtime/proxy-errors.js +3 -5
  70. package/dist/runtime/proxy-retry-policy.d.ts +2 -2
  71. package/dist/runtime/proxy-retry-policy.js +2 -2
  72. package/dist/runtime/proxy-telemetry.d.ts +1 -1
  73. package/dist/runtime/proxy-telemetry.js +16 -48
  74. package/dist/runtime/redis.d.ts +1 -1
  75. package/dist/runtime/redis.js +2 -4
  76. package/dist/runtime/request-options.d.ts +1 -1
  77. package/dist/runtime/state.d.ts +2 -2
  78. package/dist/runtime/state.js +3 -3
  79. package/dist/runtime/stealth.d.ts +2 -2
  80. package/dist/runtime/stealth.js +6 -6
  81. package/dist/runtime/stt.d.ts +1 -1
  82. package/dist/runtime/stt.js +11 -15
  83. package/dist/runtime/trace.d.ts +2 -2
  84. package/dist/runtime/trace.js +2 -4
  85. package/dist/runtime/waterfall.d.ts +1 -1
  86. package/dist/schema.d.ts +1 -1
  87. package/dist/schema.js +7 -15
  88. package/dist/serve.d.ts +1 -1
  89. package/dist/serve.js +1 -1
  90. package/dist/server/index.d.ts +7 -7
  91. package/dist/server/index.js +6 -6
  92. package/dist/server/self-test-redaction.d.ts +1 -1
  93. package/dist/server/self-test-redaction.js +1 -1
  94. package/dist/server/self-test.d.ts +104 -3
  95. package/dist/server/self-test.js +673 -115
  96. package/dist/server/serve.d.ts +3 -3
  97. package/dist/server/serve.js +37 -49
  98. package/dist/server/types.js +2 -7
  99. package/dist/stealth/profiles.d.ts +1 -1
  100. package/dist/stealth/profiles.js +5 -14
  101. package/dist/stream.d.ts +1 -1
  102. package/dist/testing/index.d.ts +2 -2
  103. package/dist/testing/index.js +2 -2
  104. package/dist/testing/run.d.ts +1 -1
  105. package/dist/testing/run.js +7 -14
  106. package/dist/types.d.ts +57 -0
  107. package/dist/user-input.d.ts +30 -0
  108. package/dist/user-input.js +66 -0
  109. package/package.json +6 -4
  110. package/src/auth-turn/index.ts +1 -1
  111. package/src/auth.ts +28 -86
  112. package/src/ceremonies/index.ts +24 -78
  113. package/src/config/loader.ts +58 -176
  114. package/src/contract-serialization.ts +5 -11
  115. package/src/contract-types.ts +2 -2
  116. package/src/contract.ts +12 -28
  117. package/src/define.ts +174 -495
  118. package/src/dev.ts +4 -9
  119. package/src/errors.ts +4 -11
  120. package/src/i18n/catalog.ts +10 -32
  121. package/src/i18n/index.ts +2 -2
  122. package/src/i18n/keys.ts +5 -11
  123. package/src/index.ts +44 -42
  124. package/src/lint.ts +89 -159
  125. package/src/provider.ts +12 -11
  126. package/src/public-schema-field-lint.ts +7 -33
  127. package/src/recipes/gov-api.ts +2 -5
  128. package/src/runtime/auth-flow.ts +5 -7
  129. package/src/runtime/browser.ts +64 -187
  130. package/src/runtime/cache.ts +20 -67
  131. package/src/runtime/choice.ts +55 -129
  132. package/src/runtime/credential.ts +2 -2
  133. package/src/runtime/env.ts +1 -1
  134. package/src/runtime/executor.ts +9 -19
  135. package/src/runtime/http.ts +7 -7
  136. package/src/runtime/insights.ts +15 -53
  137. package/src/runtime/instrumentation.ts +19 -58
  138. package/src/runtime/keyring.ts +7 -19
  139. package/src/runtime/namespace.ts +2 -7
  140. package/src/runtime/otlp.ts +12 -23
  141. package/src/runtime/perf.ts +1 -1
  142. package/src/runtime/provider.ts +4 -9
  143. package/src/runtime/proxy-errors.ts +17 -38
  144. package/src/runtime/proxy-retry-policy.ts +3 -3
  145. package/src/runtime/proxy-telemetry.ts +23 -72
  146. package/src/runtime/redis.ts +4 -12
  147. package/src/runtime/request-options.ts +4 -13
  148. package/src/runtime/state.ts +30 -109
  149. package/src/runtime/stealth.ts +8 -8
  150. package/src/runtime/stt.ts +38 -94
  151. package/src/runtime/trace.ts +14 -44
  152. package/src/runtime/waterfall.ts +5 -18
  153. package/src/schema.ts +23 -84
  154. package/src/serve.ts +1 -1
  155. package/src/server/index.ts +12 -7
  156. package/src/server/self-test-redaction.ts +2 -2
  157. package/src/server/self-test.ts +857 -132
  158. package/src/server/serve.ts +89 -238
  159. package/src/server/types.ts +6 -19
  160. package/src/stealth/profiles.ts +10 -26
  161. package/src/stream.ts +8 -19
  162. package/src/testing/index.ts +2 -2
  163. package/src/testing/run.ts +19 -67
  164. package/src/types.ts +58 -0
  165. package/src/user-input.ts +118 -0
package/dist/define.js CHANGED
@@ -1,27 +1,14 @@
1
1
  import ms from "ms";
2
- import { ProviderError, ValidationError } from "./errors";
3
- import { safeParseSchemaSync } from "./schema";
4
- import { HEALTH_CHECK_DEGRADED_THRESHOLD_MS_MAX, HEALTH_CHECK_DEGRADED_THRESHOLD_MS_MIN, HEALTH_CHECK_TIMEOUT_MS_MAX, HEALTH_CHECK_TIMEOUT_MS_MIN, OPERATION_TIMEOUT_MS_MAX, OPERATION_TIMEOUT_MS_MIN, STREAM_CHUNK_BYTES_MAX, STREAM_CHUNK_BYTES_MIN, STREAM_HEARTBEAT_MS_MAX, STREAM_HEARTBEAT_MS_MIN, STREAM_IDLE_TIMEOUT_MS_MAX, STREAM_IDLE_TIMEOUT_MS_MIN, STREAM_MAX_DURATION_MS_MAX, STREAM_MAX_DURATION_MS_MIN, } from "./types";
2
+ import { ProviderError, ValidationError } from "./errors.js";
3
+ import { safeParseSchemaSync } from "./schema.js";
4
+ import { HEALTH_CHECK_DEGRADED_THRESHOLD_MS_MAX, HEALTH_CHECK_DEGRADED_THRESHOLD_MS_MIN, HEALTH_CHECK_TIMEOUT_MS_MAX, HEALTH_CHECK_TIMEOUT_MS_MIN, OPERATION_TIMEOUT_MS_MAX, OPERATION_TIMEOUT_MS_MIN, STREAM_CHUNK_BYTES_MAX, STREAM_CHUNK_BYTES_MIN, STREAM_HEARTBEAT_MS_MAX, STREAM_HEARTBEAT_MS_MIN, STREAM_IDLE_TIMEOUT_MS_MAX, STREAM_IDLE_TIMEOUT_MS_MIN, STREAM_MAX_DURATION_MS_MAX, STREAM_MAX_DURATION_MS_MIN, } from "./types.js";
5
5
  const CONNECTOR_ID_REGEX = /^[a-z][a-z0-9]*(-[a-z][a-z0-9]*)*$/;
6
6
  const OPERATION_ID_REGEX = /^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$/;
7
7
  const VALID_RUNTIMES = ["standard", "shared", "browser"];
8
- const VALID_AUTH_MODES = [
9
- "none",
10
- "platform-managed",
11
- "credentials",
12
- "oauth2",
13
- ];
8
+ const VALID_AUTH_MODES = ["none", "platform-managed", "credentials", "oauth2"];
14
9
  const VALID_PROVIDER_ACCESS_VISIBILITIES = ["public", "early_access"];
15
- const VALID_PROVIDER_PROXY_MODES = [
16
- "disabled",
17
- "optional",
18
- "required",
19
- ];
20
- const VALID_PROVIDER_PROXY_PROVIDERS = [
21
- "smartproxy",
22
- "decodo",
23
- "custom",
24
- ];
10
+ const VALID_PROVIDER_PROXY_MODES = ["disabled", "optional", "required"];
11
+ const VALID_PROVIDER_PROXY_PROVIDERS = ["smartproxy", "decodo", "custom"];
25
12
  const VALID_PROVIDER_PROXY_AFFINITIES = [
26
13
  "request",
27
14
  "operation",
@@ -32,23 +19,9 @@ const VALID_PROVIDER_STT_MODES = ["optional", "required"];
32
19
  const SMARTPROXY_APP_KEY_SECRET = "APIFUSE__PROXY__SMARTPROXY_APP_KEY";
33
20
  const RESERVED_OPERATION_IDS = new Set(["auth", "health"]);
34
21
  const MCP_TOOL_NAME_REGEX = /^[A-Za-z][A-Za-z0-9_]{0,127}$/;
35
- const VALID_OPERATION_RISK_CLASSES = [
36
- "read",
37
- "write",
38
- "destructive",
39
- "external-send",
40
- ];
41
- const VALID_OPERATION_APPROVAL_POLICIES = [
42
- "never",
43
- "risk-based",
44
- "always",
45
- ];
46
- const VALID_OPERATION_TRANSPORT_KINDS = [
47
- "json",
48
- "sse",
49
- "http-stream",
50
- "websocket",
51
- ];
22
+ const VALID_OPERATION_RISK_CLASSES = ["read", "write", "destructive", "external-send"];
23
+ const VALID_OPERATION_APPROVAL_POLICIES = ["never", "risk-based", "always"];
24
+ const VALID_OPERATION_TRANSPORT_KINDS = ["json", "sse", "http-stream", "websocket"];
52
25
  const SSE_EVENT_NAME_REGEX = /^[A-Za-z][A-Za-z0-9_.-]{0,127}$/;
53
26
  const WEBSOCKET_SUBPROTOCOL_REGEX = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
54
27
  const MS_DURATION_PATTERN = /^([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*([a-zA-Z]+)?$/;
@@ -109,10 +82,7 @@ function validateProviderShape(config) {
109
82
  if (typeof config.runtime === "string")
110
83
  assertLiteralField(config.runtime, "runtime", VALID_RUNTIMES, String(config.id));
111
84
  const auth = config.auth;
112
- if (auth &&
113
- typeof auth === "object" &&
114
- "mode" in auth &&
115
- typeof auth.mode === "string")
85
+ if (auth && typeof auth === "object" && "mode" in auth && typeof auth.mode === "string")
116
86
  assertLiteralField(auth.mode, "auth.mode", VALID_AUTH_MODES, String(config.id));
117
87
  if (auth && typeof auth === "object" && "exchange" in auth) {
118
88
  throw new ProviderError(`Provider "${String(config.id)}" auth.exchange is not part of the Provider SDK auth contract`, {
@@ -173,9 +143,7 @@ function validateProviderProxy(config) {
173
143
  assertLiteralField(proxy.provider, "proxy.provider", VALID_PROVIDER_PROXY_PROVIDERS, config.id);
174
144
  }
175
145
  if (proxy.geo !== undefined) {
176
- if (!proxy.geo ||
177
- typeof proxy.geo !== "object" ||
178
- Array.isArray(proxy.geo)) {
146
+ if (!proxy.geo || typeof proxy.geo !== "object" || Array.isArray(proxy.geo)) {
179
147
  throw new ValidationError(`Provider "${config.id}" has invalid proxy.geo: must be an object.`, {
180
148
  fix: `Use proxy.geo: { country: "KR" } with ISO alpha-2 country codes.`,
181
149
  });
@@ -192,9 +160,7 @@ function validateProviderProxy(config) {
192
160
  }
193
161
  }
194
162
  if (proxy.session !== undefined) {
195
- if (!proxy.session ||
196
- typeof proxy.session !== "object" ||
197
- Array.isArray(proxy.session)) {
163
+ if (!proxy.session || typeof proxy.session !== "object" || Array.isArray(proxy.session)) {
198
164
  throw new ValidationError(`Provider "${config.id}" has invalid proxy.session: must be an object.`, {
199
165
  fix: `Use proxy.session: { affinity: "connection", lifetimeMinutes: 30 }.`,
200
166
  });
@@ -204,13 +170,11 @@ function validateProviderProxy(config) {
204
170
  assertLiteralField(proxy.session.affinity, "proxy.session.affinity", VALID_PROVIDER_PROXY_AFFINITIES, config.id);
205
171
  }
206
172
  const lifetime = proxy.session.lifetimeMinutes;
207
- if (lifetime !== undefined &&
208
- (!Number.isFinite(lifetime) || lifetime <= 0)) {
173
+ if (lifetime !== undefined && (!Number.isFinite(lifetime) || lifetime <= 0)) {
209
174
  throw new ValidationError(`Provider "${config.id}" has invalid proxy.session.lifetimeMinutes: must be a positive number of minutes.`);
210
175
  }
211
176
  const poolSize = proxy.session.poolSize;
212
- if (poolSize !== undefined &&
213
- (!Number.isInteger(poolSize) || poolSize <= 0)) {
177
+ if (poolSize !== undefined && (!Number.isInteger(poolSize) || poolSize <= 0)) {
214
178
  throw new ValidationError(`Provider "${config.id}" has invalid proxy.session.poolSize: must be a positive integer.`);
215
179
  }
216
180
  }
@@ -228,7 +192,9 @@ function validateProviderStt(config) {
228
192
  if (stt === undefined)
229
193
  return;
230
194
  if (!stt || typeof stt !== "object" || Array.isArray(stt)) {
231
- throw new ValidationError(`Provider "${config.id}" has invalid stt: must be an object.`, { fix: `Use stt: { mode: "required" } or stt: { mode: "optional" }.` });
195
+ throw new ValidationError(`Provider "${config.id}" has invalid stt: must be an object.`, {
196
+ fix: `Use stt: { mode: "required" } or stt: { mode: "optional" }.`,
197
+ });
232
198
  }
233
199
  rejectUnknownFields(stt, new Set(["mode"]), "stt");
234
200
  assertLiteralField(stt.mode, "stt.mode", VALID_PROVIDER_STT_MODES, config.id);
@@ -247,12 +213,7 @@ function validateOperationIds(providerId, operations) {
247
213
  }
248
214
  const OPERATION_CONTRACT_VERSION_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
249
215
  const OPERATION_SENSITIVE_PATH_REGEX = /^(?:[A-Za-z0-9_$-]+|\*)(?:\.(?:[A-Za-z0-9_$-]+|\*))*$/;
250
- const VALID_OPERATION_LIFECYCLES = [
251
- "stable",
252
- "beta",
253
- "deprecated",
254
- "removed",
255
- ];
216
+ const VALID_OPERATION_LIFECYCLES = ["stable", "beta", "deprecated", "removed"];
256
217
  function assertNonEmptyString(value, field, providerId, operationName) {
257
218
  if (typeof value !== "string" || value.trim().length === 0) {
258
219
  throw new ValidationError(`Provider "${providerId}" operation "${operationName}" has invalid ${field}: must be a non-empty string.`, { fix: `Set ${field} to a non-empty customer-facing value.` });
@@ -268,8 +229,7 @@ function validateToolRouterMetadata(providerId, operations) {
268
229
  fix: `Remove operations.${operationName}.toolRouter or provide MCP-safe metadata.`,
269
230
  });
270
231
  }
271
- if (toolRouter.name !== undefined &&
272
- !MCP_TOOL_NAME_REGEX.test(toolRouter.name)) {
232
+ if (toolRouter.name !== undefined && !MCP_TOOL_NAME_REGEX.test(toolRouter.name)) {
273
233
  throw new ValidationError(`Provider "${providerId}" operation "${operationName}" has invalid operations.${operationName}.toolRouter.name: expected an MCP-safe name.`, {
274
234
  fix: `Use letters, numbers, and underscores only, starting with a letter, for example "${providerId.replace(/[^A-Za-z0-9]+/g, "_")}__${operationName.replace(/[^A-Za-z0-9]+/g, "_")}".`,
275
235
  });
@@ -307,8 +267,7 @@ function validateOperationContracts(providerId, operations) {
307
267
  if (contract.lifecycle !== undefined) {
308
268
  assertLiteralField(contract.lifecycle, `operations.${operationName}.contract.lifecycle`, VALID_OPERATION_LIFECYCLES, providerId);
309
269
  }
310
- if (contract.lifecycle === "deprecated" ||
311
- contract.lifecycle === "removed") {
270
+ if (contract.lifecycle === "deprecated" || contract.lifecycle === "removed") {
312
271
  if (!contract.deprecation || typeof contract.deprecation !== "object") {
313
272
  throw new ValidationError(`Provider "${providerId}" operation "${operationName}" is ${contract.lifecycle} but lacks operations.${operationName}.contract.deprecation metadata.`, {
314
273
  fix: `Add announcedAt, removalAfter, and migrationGuide to operations.${operationName}.contract.deprecation.`,
@@ -333,8 +292,7 @@ function validateOperationAnnotations(providerId, operations) {
333
292
  throw new ValidationError(`Provider "${providerId}" has invalid ${field}: must be an integer number of milliseconds.`, {
334
293
  fix: `Set ${field} to an integer in [${OPERATION_TIMEOUT_MS_MIN}, ${OPERATION_TIMEOUT_MS_MAX}] (milliseconds).`,
335
294
  });
336
- if (timeoutMs < OPERATION_TIMEOUT_MS_MIN ||
337
- timeoutMs > OPERATION_TIMEOUT_MS_MAX)
295
+ if (timeoutMs < OPERATION_TIMEOUT_MS_MIN || timeoutMs > OPERATION_TIMEOUT_MS_MAX)
338
296
  throw new ValidationError(`Provider "${providerId}" has invalid ${field}: ${timeoutMs} is outside [${OPERATION_TIMEOUT_MS_MIN}, ${OPERATION_TIMEOUT_MS_MAX}] ms.`, {
339
297
  fix: `Set ${field} to an integer in [${OPERATION_TIMEOUT_MS_MIN}, ${OPERATION_TIMEOUT_MS_MAX}] ms (the upper bound stays below the gateway/ALB ceiling).`,
340
298
  });
@@ -478,9 +436,7 @@ function validateOperationTransports(providerId, operations) {
478
436
  assertStreamMs(maxDurationMs, `${fieldPath}.maxDurationMs`, STREAM_MAX_DURATION_MS_MIN, STREAM_MAX_DURATION_MS_MAX, "max duration");
479
437
  assertPositiveBytes(Reflect.get(transport, "maxEventBytes"), `${fieldPath}.maxEventBytes`);
480
438
  const resumable = Reflect.get(transport, "resumable");
481
- if (resumable !== undefined &&
482
- resumable !== false &&
483
- resumable !== "last-event-id") {
439
+ if (resumable !== undefined && resumable !== false && resumable !== "last-event-id") {
484
440
  throw new ValidationError(`Provider "${providerId}" operation "${operationName}" has invalid ${fieldPath}.resumable: expected false or "last-event-id".`, {
485
441
  fix: `Use ${fieldPath}.resumable: "last-event-id" for SSE Last-Event-ID resume support, or false to disable resume.`,
486
442
  });
@@ -515,8 +471,7 @@ function validateOperationTransports(providerId, operations) {
515
471
  });
516
472
  }
517
473
  for (const subprotocol of subprotocols) {
518
- if (typeof subprotocol !== "string" ||
519
- !WEBSOCKET_SUBPROTOCOL_REGEX.test(subprotocol)) {
474
+ if (typeof subprotocol !== "string" || !WEBSOCKET_SUBPROTOCOL_REGEX.test(subprotocol)) {
520
475
  throw new ValidationError(`Provider "${providerId}" operation "${operationName}" has invalid ${fieldPath}.subprotocols: each subprotocol must be an RFC token string.`, {
521
476
  fix: `Use values such as "apifuse.v1" without spaces or separators that are invalid for Sec-WebSocket-Protocol.`,
522
477
  });
@@ -624,9 +579,7 @@ function assertBoundedIntegerMs(value, fieldPath, options) {
624
579
  function validateProviderHealthMonitor(providerId, healthMonitor, field = "healthMonitor") {
625
580
  if (healthMonitor === undefined)
626
581
  return;
627
- if (!healthMonitor ||
628
- typeof healthMonitor !== "object" ||
629
- Array.isArray(healthMonitor))
582
+ if (!healthMonitor || typeof healthMonitor !== "object" || Array.isArray(healthMonitor))
630
583
  throw new ValidationError(`Provider "${providerId}" has invalid ${field}: must be an object.`, {
631
584
  fix: `Set ${field} to { requiredSecrets?: string[]; serviceAccount?: string }`,
632
585
  });
@@ -676,9 +629,7 @@ function validateProviderHealthMonitor(providerId, healthMonitor, field = "healt
676
629
  }
677
630
  const probeOverrides = healthMonitorRecord.probeOverrides;
678
631
  if (probeOverrides !== undefined) {
679
- if (!probeOverrides ||
680
- typeof probeOverrides !== "object" ||
681
- Array.isArray(probeOverrides))
632
+ if (!probeOverrides || typeof probeOverrides !== "object" || Array.isArray(probeOverrides))
682
633
  throw new ValidationError(`Provider "${providerId}" has invalid ${field}.probeOverrides: must be an object keyed by probe id.`);
683
634
  for (const [probeId, override] of Object.entries(probeOverrides)) {
684
635
  if (probeId.length === 0)
@@ -756,9 +707,7 @@ function validateHealthCheckSuite(providerId, operationName, suite) {
756
707
  fix: `Set ${fieldPath}.interval to a positive ms-style duration string.`,
757
708
  });
758
709
  if (s.schedule !== undefined) {
759
- if (!s.schedule ||
760
- typeof s.schedule !== "object" ||
761
- Array.isArray(s.schedule)) {
710
+ if (!s.schedule || typeof s.schedule !== "object" || Array.isArray(s.schedule)) {
762
711
  throw new ValidationError(`Provider "${providerId}" ${fieldPath}.schedule must be an object.`);
763
712
  }
764
713
  if (Reflect.get(s.schedule, "jitter") !== undefined) {
@@ -784,8 +733,7 @@ function validateHealthCheckSuite(providerId, operationName, suite) {
784
733
  label: "degraded threshold",
785
734
  });
786
735
  }
787
- if (s.requiresConnection !== undefined &&
788
- typeof s.requiresConnection !== "boolean")
736
+ if (s.requiresConnection !== undefined && typeof s.requiresConnection !== "boolean")
789
737
  throw new ValidationError(`Provider "${providerId}" ${fieldPath}.requiresConnection must be a boolean.`);
790
738
  if (!Array.isArray(s.cases) || s.cases.length === 0)
791
739
  throw new ValidationError(`Provider "${providerId}" ${fieldPath}.cases must be a non-empty array.`, {
@@ -804,9 +752,7 @@ function validateHealthCheckSuite(providerId, operationName, suite) {
804
752
  }
805
753
  function validateHealthCheckUnsupported(providerId, operationName, unsupported) {
806
754
  const fieldPath = `operations.${operationName}.healthCheckUnsupported`;
807
- if (!unsupported ||
808
- typeof unsupported !== "object" ||
809
- Array.isArray(unsupported))
755
+ if (!unsupported || typeof unsupported !== "object" || Array.isArray(unsupported))
810
756
  throw new ValidationError(`Provider "${providerId}" ${fieldPath} must be an object.`);
811
757
  rejectUnknownFields(unsupported, HEALTH_CHECK_UNSUPPORTED_FIELDS, fieldPath);
812
758
  const u = unsupported;
@@ -831,12 +777,7 @@ const HEALTH_JOURNEY_FIELDS = new Set([
831
777
  "steps",
832
778
  "run",
833
779
  ]);
834
- const HEALTH_JOURNEY_SCHEDULE_FIELDS = new Set([
835
- "kind",
836
- "interval",
837
- "jitter",
838
- "randomize",
839
- ]);
780
+ const HEALTH_JOURNEY_SCHEDULE_FIELDS = new Set(["kind", "interval", "jitter", "randomize"]);
840
781
  const HEALTH_JOURNEY_STEP_FIELDS = new Set([
841
782
  "id",
842
783
  "description",
@@ -854,10 +795,7 @@ const HEALTH_JOURNEY_MANUAL_TRIGGER_FIELDS = new Set([
854
795
  "minManualInterval",
855
796
  "publicRationale",
856
797
  ]);
857
- const HEALTH_JOURNEY_MANUAL_TRIGGER_DISABLED_FIELDS = new Set([
858
- "enabled",
859
- "reason",
860
- ]);
798
+ const HEALTH_JOURNEY_MANUAL_TRIGGER_DISABLED_FIELDS = new Set(["enabled", "reason"]);
861
799
  const HEALTH_JOURNEY_MANUAL_TRIGGER_ENABLED_FIELDS = new Set([
862
800
  "enabled",
863
801
  "requiresAcknowledgement",
@@ -872,9 +810,7 @@ const HEALTH_JOURNEY_MANUAL_TRIGGER_RISKS = new Set([
872
810
  ]);
873
811
  function validateHealthJourneyManualTrigger(providerId, journeyId, manualTrigger) {
874
812
  const fieldPath = `healthJourneys.${journeyId}.manualTrigger`;
875
- if (!manualTrigger ||
876
- typeof manualTrigger !== "object" ||
877
- Array.isArray(manualTrigger)) {
813
+ if (!manualTrigger || typeof manualTrigger !== "object" || Array.isArray(manualTrigger)) {
878
814
  throw new ValidationError(`Provider "${providerId}" ${fieldPath} must be an object when present.`);
879
815
  }
880
816
  rejectUnknownFields(manualTrigger, HEALTH_JOURNEY_MANUAL_TRIGGER_FIELDS, fieldPath);
@@ -897,8 +833,7 @@ function validateHealthJourneyManualTrigger(providerId, journeyId, manualTrigger
897
833
  throw new ValidationError(`Provider "${providerId}" ${fieldPath}.requiresAcknowledgement must be a boolean.`);
898
834
  }
899
835
  const risk = Reflect.get(manualTrigger, "risk");
900
- if (typeof risk !== "string" ||
901
- !HEALTH_JOURNEY_MANUAL_TRIGGER_RISKS.has(risk)) {
836
+ if (typeof risk !== "string" || !HEALTH_JOURNEY_MANUAL_TRIGGER_RISKS.has(risk)) {
902
837
  throw new ValidationError(`Provider "${providerId}" ${fieldPath}.risk must be one of read_only, writes_external_state, or sms_or_payment.`);
903
838
  }
904
839
  if (risk !== "read_only" && requiresAcknowledgement !== true) {
@@ -950,7 +885,7 @@ function isoDurationMs(value) {
950
885
  const hours = Number(/(\d+)H/.exec(value)?.[1] ?? 0);
951
886
  const minutes = Number(/(\d+)M/.exec(value)?.[1] ?? 0);
952
887
  const seconds = Number(/(\d+(?:\.\d+)?)S/.exec(value)?.[1] ?? 0);
953
- return (days * 86_400_000 + hours * 3_600_000 + minutes * 60_000 + seconds * 1_000);
888
+ return days * 86_400_000 + hours * 3_600_000 + minutes * 60_000 + seconds * 1_000;
954
889
  }
955
890
  function scheduleRandomizationMs(randomize, fieldPath) {
956
891
  const mode = Reflect.get(randomize, "mode");
@@ -974,9 +909,7 @@ function validateScheduleRandomization(randomize, fieldPath, intervalMs) {
974
909
  throw new ValidationError(`${fieldPath} must be an object.`);
975
910
  }
976
911
  const mode = Reflect.get(randomize, "mode");
977
- const allowedFields = mode === "centered"
978
- ? new Set(["mode", "maxOffset"])
979
- : new Set(["mode", "maxDelay"]);
912
+ const allowedFields = mode === "centered" ? new Set(["mode", "maxOffset"]) : new Set(["mode", "maxDelay"]);
980
913
  rejectUnknownFields(randomize, allowedFields, fieldPath);
981
914
  const offsetMs = scheduleRandomizationMs(randomize, fieldPath);
982
915
  if (offsetMs <= 0) {
@@ -1062,9 +995,7 @@ function countCapturingGroups(pattern) {
1062
995
  const next = source[i + 1];
1063
996
  if (next === "?" && source[i + 2] !== "<")
1064
997
  continue;
1065
- if (next === "?" &&
1066
- source[i + 2] === "<" &&
1067
- (source[i + 3] === "=" || source[i + 3] === "!"))
998
+ if (next === "?" && source[i + 2] === "<" && (source[i + 3] === "=" || source[i + 3] === "!"))
1068
999
  continue;
1069
1000
  count += 1;
1070
1001
  }
@@ -1142,8 +1073,7 @@ function validateSmsOtpMatcher(matcher, fieldPath) {
1142
1073
  throw new ValidationError(`${fieldPath}.code.pattern must be a RegExp or pattern source string.`);
1143
1074
  }
1144
1075
  const regex = pattern instanceof RegExp ? pattern : new RegExp(pattern);
1145
- if (countCapturingGroups(regex) !== 1 &&
1146
- Reflect.get(code, "capture") === undefined) {
1076
+ if (countCapturingGroups(regex) !== 1 && Reflect.get(code, "capture") === undefined) {
1147
1077
  throw new ValidationError(`${fieldPath}.code.pattern must contain exactly one OTP capture or declare code.capture.`);
1148
1078
  }
1149
1079
  if (Reflect.get(code, "capture") !== undefined &&
@@ -1195,8 +1125,7 @@ function validateHealthJourneySchedule(providerId, journeyId, schedule) {
1195
1125
  const interval = Reflect.get(schedule, "interval");
1196
1126
  assertIsoDuration(interval, `Provider "${providerId}" ${fieldPath}.interval`);
1197
1127
  const randomize = Reflect.get(schedule, "randomize");
1198
- if (Reflect.get(schedule, "jitter") !== undefined &&
1199
- randomize !== undefined) {
1128
+ if (Reflect.get(schedule, "jitter") !== undefined && randomize !== undefined) {
1200
1129
  throw new ValidationError(`Provider "${providerId}" ${fieldPath} cannot define both jitter and randomize.`);
1201
1130
  }
1202
1131
  if (Reflect.get(schedule, "jitter") !== undefined)
@@ -1226,8 +1155,7 @@ function validateHealthJourneys(providerId, operations, healthJourneys) {
1226
1155
  throw new ValidationError(`Provider "${providerId}" has duplicate health journey id "${journey.id}".`);
1227
1156
  journeyIds.add(journey.id);
1228
1157
  validateHealthJourneySchedule(providerId, journey.id, journey.schedule);
1229
- if (!Array.isArray(journey.coversOperations) ||
1230
- journey.coversOperations.length === 0) {
1158
+ if (!Array.isArray(journey.coversOperations) || journey.coversOperations.length === 0) {
1231
1159
  throw new ValidationError(`Provider "${providerId}" healthJourneys.${journey.id}.coversOperations must be a non-empty array.`);
1232
1160
  }
1233
1161
  for (const operationId of journey.coversOperations) {
@@ -1265,8 +1193,7 @@ function validateHealthJourneys(providerId, operations, healthJourneys) {
1265
1193
  throw new ValidationError(`Provider "${providerId}" ${stepPath}.id must be a kebab-case identifier.`);
1266
1194
  if (step.operationId !== undefined && !operations[step.operationId])
1267
1195
  throw new ValidationError(`Provider "${providerId}" ${stepPath}.operationId references unknown operation "${step.operationId}".`);
1268
- if (step.usesSmsMatcher !== undefined &&
1269
- !matcherIds.has(step.usesSmsMatcher))
1196
+ if (step.usesSmsMatcher !== undefined && !matcherIds.has(step.usesSmsMatcher))
1270
1197
  throw new ValidationError(`Provider "${providerId}" ${stepPath}.usesSmsMatcher references unknown matcher "${step.usesSmsMatcher}".`);
1271
1198
  }
1272
1199
  if (journey.manualTrigger !== undefined)
@@ -1300,9 +1227,7 @@ function validateOperationHealthChecks(providerId, operations, journeyCoveredOpe
1300
1227
  validateHealthCheckSuite(providerId, operationName, operation.healthCheck);
1301
1228
  if (hasUnsupported)
1302
1229
  validateHealthCheckUnsupported(providerId, operationName, operation.healthCheckUnsupported);
1303
- if (!hasCheck &&
1304
- !hasUnsupported &&
1305
- !journeyCoveredOperations.has(operationName))
1230
+ if (!hasCheck && !hasUnsupported && !journeyCoveredOperations.has(operationName))
1306
1231
  throw new ValidationError(`Provider "${providerId}" operation "${operationName}" declares neither healthCheck nor healthCheckUnsupported.`, {
1307
1232
  fix: `Add \`healthCheck: { interval, cases: [...] }\` or \`healthCheckUnsupported: { reason: "..." }\` to operations.${operationName}.`,
1308
1233
  });
@@ -1332,6 +1257,19 @@ function validateOperationFixtures(providerId, operations) {
1332
1257
  }
1333
1258
  }
1334
1259
  }
1260
+ /**
1261
+ * Shallow shape guard only: the `deployment` object is passed through
1262
+ * verbatim and deliberately not deep-validated by the SDK — the APIFuse
1263
+ * registry builder owns deployment validation and profile resolution.
1264
+ */
1265
+ function validateProviderDeployment(providerId, deployment) {
1266
+ if (deployment === undefined)
1267
+ return;
1268
+ if (!deployment || typeof deployment !== "object" || Array.isArray(deployment))
1269
+ throw new ProviderError(`Provider "${providerId}" deployment must be an object when present`, {
1270
+ fix: 'Pass deployment: { runtime: "shared" | "dedicated" | "browser", ... } or remove the field',
1271
+ });
1272
+ }
1335
1273
  export function defineProvider(config) {
1336
1274
  validateProviderShape(config);
1337
1275
  if (!CONNECTOR_ID_REGEX.test(config.id))
@@ -1356,6 +1294,7 @@ export function defineProvider(config) {
1356
1294
  });
1357
1295
  validateProviderHealthMonitor(config.id, config.healthProbe ?? config.healthMonitor, config.healthProbe !== undefined ? "healthProbe" : "healthMonitor");
1358
1296
  validateOperationFixtures(config.id, config.operations);
1297
+ validateProviderDeployment(config.id, config.deployment);
1359
1298
  validateProviderProxy(config);
1360
1299
  validateProviderStt(config);
1361
1300
  if (config.runtime === "browser" && !config.browser)
@@ -1368,6 +1307,9 @@ export function defineProvider(config) {
1368
1307
  id: config.id,
1369
1308
  version: config.version,
1370
1309
  runtime: config.runtime,
1310
+ // Verbatim passthrough: deployment validation and profile resolution
1311
+ // are owned by the APIFuse registry builder, not the SDK.
1312
+ deployment: config.deployment,
1371
1313
  allowedHosts: config.allowedHosts,
1372
1314
  stealth: config.stealth,
1373
1315
  proxy: config.proxy,
package/dist/dev.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ProviderDefinition } from "./types";
1
+ import type { ProviderDefinition } from "./types.js";
2
2
  export interface DevServerOptions {
3
3
  port?: number;
4
4
  sessionDbPath?: string;
package/dist/dev.js CHANGED
@@ -1,4 +1,4 @@
1
- import { serve } from "./server/serve";
1
+ import { serve } from "./server/serve.js";
2
2
  export function createDevServer(provider, options) {
3
3
  const port = options?.port ?? 3900;
4
4
  return {
package/dist/errors.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ProviderErrorCategory } from "./observability";
1
+ import type { ProviderErrorCategory } from "./observability.js";
2
2
  export type ProviderErrorOptions = {
3
3
  fix?: string;
4
4
  code?: string;
package/dist/errors.js CHANGED
@@ -28,9 +28,7 @@ function hasOwnBrand(value, brand, expected) {
28
28
  return false;
29
29
  }
30
30
  const descriptor = Object.getOwnPropertyDescriptor(value, brand);
31
- return (descriptor !== undefined &&
32
- Object.hasOwn(descriptor, "value") &&
33
- descriptor.value === expected);
31
+ return (descriptor !== undefined && Object.hasOwn(descriptor, "value") && descriptor.value === expected);
34
32
  }
35
33
  export class ProviderError extends Error {
36
34
  options;
@@ -1,5 +1,5 @@
1
- import type { AuthTurn } from "../types";
2
- import { type ProviderLocale, type ProviderLocaleCatalog, type ProviderLocaleKey, type ProviderLocaleValue } from "./keys";
1
+ import type { AuthTurn } from "../types.js";
2
+ import { type ProviderLocale, type ProviderLocaleCatalog, type ProviderLocaleKey, type ProviderLocaleValue } from "./keys.js";
3
3
  export type ProviderLocaleCatalogMap = Record<ProviderLocale, ProviderLocaleCatalog>;
4
4
  export interface LoadProviderLocaleCatalogsOptions {
5
5
  providerDir: string;
@@ -1,6 +1,6 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { getProviderLocalePath, isProviderLocaleValue, providerLocaleKey, } from "./keys";
3
+ import { getProviderLocalePath, isProviderLocaleValue, providerLocaleKey, } from "./keys.js";
4
4
  export function loadProviderLocaleCatalogs(options) {
5
5
  const catalogs = {};
6
6
  for (const locale of options.locales) {
@@ -26,9 +26,7 @@ function isStringRecord(value) {
26
26
  function localizeAuthInputSchema(expectedInput, options) {
27
27
  if (!expectedInput)
28
28
  return undefined;
29
- const schema = isRecord(expectedInput.schema)
30
- ? expectedInput.schema
31
- : expectedInput;
29
+ const schema = isRecord(expectedInput.schema) ? expectedInput.schema : expectedInput;
32
30
  const localizedSchema = localizeAuthSchemaObject(schema, options);
33
31
  if (localizedSchema === schema)
34
32
  return undefined;
@@ -40,9 +38,7 @@ function isRecord(value) {
40
38
  return !!value && typeof value === "object" && !Array.isArray(value);
41
39
  }
42
40
  function localizeAuthSchemaObject(schema, options) {
43
- const properties = isRecord(schema.properties)
44
- ? schema.properties
45
- : undefined;
41
+ const properties = isRecord(schema.properties) ? schema.properties : undefined;
46
42
  if (!properties)
47
43
  return schema;
48
44
  let changed = false;
@@ -50,9 +46,7 @@ function localizeAuthSchemaObject(schema, options) {
50
46
  if (!isRecord(property))
51
47
  return [fieldName, property];
52
48
  const nameKey = typeof property.nameKey === "string" ? property.nameKey : undefined;
53
- const descriptionKey = typeof property.descriptionKey === "string"
54
- ? property.descriptionKey
55
- : undefined;
49
+ const descriptionKey = typeof property.descriptionKey === "string" ? property.descriptionKey : undefined;
56
50
  const title = nameKey
57
51
  ? asStringValue(resolveProviderLocaleValue(options.catalogs, nameKey, options.locale, options.fallbackLocale))
58
52
  : undefined;
@@ -1,2 +1,2 @@
1
- export * from "./catalog";
2
- export * from "./keys";
1
+ export * from "./catalog.js";
2
+ export * from "./keys.js";
@@ -1,2 +1,2 @@
1
- export * from "./catalog";
2
- export * from "./keys";
1
+ export * from "./catalog.js";
2
+ export * from "./keys.js";
@@ -1,5 +1,5 @@
1
- import type { ProviderLocaleKey } from "../types";
2
- export type { ProviderLocale, ProviderLocaleKey } from "../types";
1
+ import type { ProviderLocaleKey } from "../types.js";
2
+ export type { ProviderLocale, ProviderLocaleKey } from "../types.js";
3
3
  export declare function providerLocaleKey(key: string): ProviderLocaleKey;
4
4
  export declare function isProviderLocaleKey(value: unknown): value is ProviderLocaleKey;
5
5
  export declare function assertProviderLocaleKey(value: unknown): asserts value is ProviderLocaleKey;
package/dist/index.d.ts CHANGED
@@ -1,42 +1,43 @@
1
- export * from "./auth";
2
- export * from "./ceremonies";
3
- export * from "./choice-token";
4
- export type { ApiFuseConfig, BrowserConfig, ProxyConfig, SessionConfig, } from "./config/loader";
5
- export { defineConfig, loadApiFuseConfig } from "./config/loader";
6
- export { canonicalJson, digestProviderContract, extractProviderContract, type JsonPrimitive, type JsonValue, PROVIDER_CONTRACT_SCHEMA_VERSION, type ProviderContractOperation, type ProviderContractSnapshot, } from "./contract";
7
- export { centered, delayed, defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, defineStreamOperation, every, type ProviderConfig, } from "./define";
8
- export type { DevServerOptions } from "./dev";
9
- export { createDevServer, startDevServer } from "./dev";
10
- export * from "./errors";
11
- export * from "./i18n";
12
- export { type LintDiagnostic, lintOperation, lintProvider, } from "./lint";
13
- export * from "./recipes/gov-api";
14
- export * from "./recipes/rest-api";
15
- export { createFlowContext, createScratchpad } from "./runtime/auth-flow";
16
- export type { BrowserClientOptions } from "./runtime/browser";
17
- export { BrowserClient, createBrowserClient } from "./runtime/browser";
18
- export { createBypassProviderCache, createProviderCache, type ProviderCacheOptions, resetProviderCacheForTests, } from "./runtime/cache";
19
- export { type CreateProviderChoiceContextOptions, createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice";
20
- export { type CreateCredentialContextOptions, createCredentialContext, } from "./runtime/credential";
21
- export { createEnvContext } from "./runtime/env";
22
- export { executeOperation } from "./runtime/executor";
23
- export { createHttpClient } from "./runtime/http";
24
- export type { Insight, InsightSeverity } from "./runtime/insights";
25
- export { generateInsights } from "./runtime/insights";
26
- export { type InstrumentationOptions, type InstrumentedProviderContext, wrapWithInstrumentation, } from "./runtime/instrumentation";
27
- export { type PrevalidateResult, prevalidate } from "./runtime/prevalidate";
28
- export { getProviderBaseUrl } from "./runtime/provider";
29
- export { createUnsupportedProviderRuntimeState, UnsupportedProviderStateError, } from "./runtime/state";
30
- export { createStealthClient } from "./runtime/stealth";
31
- export { APIFUSE__STT__BACKEND_ENV, APIFUSE__STT__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__STT__MODEL_ENV, createSttClientFromEnv, createUnsupportedSttClient, extractVerificationCode, resolveSttPrompt, } from "./runtime/stt";
32
- export { type CreateTraceContextOptions, createTraceContext, type Span, type TraceContext, } from "./runtime/trace";
33
- export { APIFUSE_DESCRIPTION_KEY_META_KEY, APIFUSE_REDACTION_MARKER, APIFUSE_SENSITIVE_KIND_META_KEY, APIFUSE_SENSITIVE_META_KEY, collectSensitivePaths, describeKey, field, fields, isSensitiveSchema, redactPayload, type SensitiveFieldKind, type SensitiveFieldOptions, type SensitivePath, sensitive, z, } from "./schema";
34
- export { createServerApp, type ServeOptions, serve } from "./server";
35
- export { getStealthProfile, listStealthProfiles } from "./stealth/profiles";
36
- export * from "./stream";
37
- export type { ApiFuseResponse, AuthConfig, AuthContext, AuthFlowDefinition, AuthFlowInputHandler, AuthFlowStartHandler, AuthMode, AuthTurn, Bcp47Locale, BrowserEngine, BrowserOptions, BrowserResourceBody, BrowserResourceDecision, BrowserResourceMethod, BrowserResourcePolicy, BrowserResourceRequest, BrowserResourceRoute, ConnectionMode, ContextDeclaration, CookieJar, ContextScratchpad, CredentialContext, CredentialDeclaration, E164PhoneNumber, EnvContext, FlowContext, FlowContextStore, HealthCheckAssertionContext, HealthCheckCase, HealthCheckCaseResult, HealthCheckSuite, HealthCheckUnsupported, HealthJourneyDefinition, HealthJourneyEventContext, HealthJourneyGatewayContext, HealthJourneyJournalContext, HealthJourneyManualTriggerPolicy, HealthJourneyRunContext, HealthJourneyRunResult, HealthJourneySchedule, HealthScheduleRandomization, HealthJourneySmsContext, HealthJourneyStep, HttpClient, HttpMethod, HttpResponse, HttpRetryOptions, HttpRetrySummary, HttpStreamResponse, IanaTimeZone, InferSchemaOutput, Iso3166Alpha2CountryCode, Iso4217CurrencyCode, Iso8601Duration, OperationAnnotations, OperationApprovalPolicy, OperationContractMetadata, OperationDefinition, OperationDeprecationMetadata, OperationDocMeta, OperationErrorCode, OperationHandlerResult, OperationInputExample, OperationLifecycle, OperationObservabilityConfig, OperationObservabilitySensitiveConfig, OperationRelationships, OperationRiskClass, OperationSensitivePath, OperationToolRouterMetadata, OperationTransport, OperationTransportKind, ProbeInterval, ProviderAccessConfig, ProviderAccessVisibility, ProviderCache, ProviderCacheGetOrSetOptions, ProviderCacheKeyOptions, ProviderCacheLookupMeta, ProviderCacheResponseMeta, ProviderCacheResult, ProviderChoiceBindingOptions, ProviderChoiceContext, ProviderChoiceIssueOptions, ProviderChoiceParseOptions, ProviderContext, ProviderDefinition, ProviderHealthMonitorConfig, ProviderHealthProbeConfig, ProviderLocale, ProviderLocaleKey, ProviderLocaleKeyInput, ProviderLogoProfile, ProviderLogoSource, ProviderMeta, ProviderProxyConfig, ProviderProxyMode, ProviderProxyPolicy, ProviderProxyProvider, ProviderProxySessionAffinity, ProviderPublicConnectionMode, ProviderPublicProfile, ProviderReviewed, ProviderRuntimeState, ProviderSecretDeclaration, ProviderStateDurationString, ProviderStateNamespace, ProviderStreamEvent, ProviderSttConfig, ProviderSttMode, ProviderSupportLevel, RequestOptions, Rfc3339Instant, SchemaLike, SmsOrigin, SmsOtpExtractionPattern, SmsOtpMatcherDefinition, SseMessage, StandardSchemaV1, StateCasResult, StateNamespaceOptions, StateValue, StateWriteOptions, StealthClient, StealthFetchOptions, StealthPlatform, StealthProfile, StealthRedirectHop, StealthRedirectRunOptions, StealthRedirectRunResult, StealthResponse, StealthSession, StealthSessionCookies, SttAudioInput, SttContext, SttPromptPolicy, SttSegment, SttTranscribeMode, SttTranscribeRequest, SttTranscript, SttUnsupportedOptionPolicy, SttUsage, SttVerificationCodeOptions, SttWarning, TraceConfig, TraceSpan, VerificationCodeCandidate, VerificationCodeCandidateSource, VerificationCodeExtractionResult, } from "./types";
38
- export { DEFAULT_OPERATION_TRANSPORT, HttpRetryAfterPolicy, HttpRetryDelayStrategy, HttpRetryJitter, HttpRetryPreset, HttpRetryUnsafeMethodPolicy, PROBE_INTERVALS, STREAM_CHUNK_BYTES_MAX, STREAM_CHUNK_BYTES_MIN, STREAM_HEARTBEAT_MS_MAX, STREAM_HEARTBEAT_MS_MIN, STREAM_IDLE_TIMEOUT_MS_MAX, STREAM_IDLE_TIMEOUT_MS_MIN, STREAM_MAX_DURATION_MS_MAX, STREAM_MAX_DURATION_MS_MIN, } from "./types";
39
- export * from "./utils/date";
40
- export * from "./utils/parse";
41
- export * from "./utils/text";
42
- export * from "./utils/transform";
1
+ export * from "./auth.js";
2
+ export * from "./ceremonies/index.js";
3
+ export * from "./choice-token.js";
4
+ export type { ApiFuseConfig, BrowserConfig, ProxyConfig, SessionConfig, } from "./config/loader.js";
5
+ export { defineConfig, loadApiFuseConfig } from "./config/loader.js";
6
+ export { canonicalJson, digestProviderContract, extractProviderContract, type JsonPrimitive, type JsonValue, PROVIDER_CONTRACT_SCHEMA_VERSION, type ProviderContractOperation, type ProviderContractSnapshot, } from "./contract.js";
7
+ export { centered, delayed, defineHealthJourney, defineOperation, defineProvider, defineSmsOtpMatcher, defineStreamOperation, every, type ProviderConfig, } from "./define.js";
8
+ export type { DevServerOptions } from "./dev.js";
9
+ export { createDevServer, startDevServer } from "./dev.js";
10
+ export * from "./errors.js";
11
+ export * from "./user-input.js";
12
+ export * from "./i18n/index.js";
13
+ export { type LintDiagnostic, lintOperation, lintProvider, } from "./lint.js";
14
+ export * from "./recipes/gov-api.js";
15
+ export * from "./recipes/rest-api.js";
16
+ export { createFlowContext, createScratchpad } from "./runtime/auth-flow.js";
17
+ export type { BrowserClientOptions } from "./runtime/browser.js";
18
+ export { BrowserClient, createBrowserClient } from "./runtime/browser.js";
19
+ export { createBypassProviderCache, createProviderCache, type ProviderCacheOptions, resetProviderCacheForTests, } from "./runtime/cache.js";
20
+ export { type CreateProviderChoiceContextOptions, createProviderChoiceContext, createTestProviderChoiceContext, PROVIDER_RUNTIME_CHOICE_TOKEN_MASTER_SECRET_ENV, } from "./runtime/choice.js";
21
+ export { type CreateCredentialContextOptions, createCredentialContext, } from "./runtime/credential.js";
22
+ export { createEnvContext } from "./runtime/env.js";
23
+ export { executeOperation } from "./runtime/executor.js";
24
+ export { createHttpClient } from "./runtime/http.js";
25
+ export type { Insight, InsightSeverity } from "./runtime/insights.js";
26
+ export { generateInsights } from "./runtime/insights.js";
27
+ export { type InstrumentationOptions, type InstrumentedProviderContext, wrapWithInstrumentation, } from "./runtime/instrumentation.js";
28
+ export { type PrevalidateResult, prevalidate } from "./runtime/prevalidate.js";
29
+ export { getProviderBaseUrl } from "./runtime/provider.js";
30
+ export { createUnsupportedProviderRuntimeState, UnsupportedProviderStateError, } from "./runtime/state.js";
31
+ export { createStealthClient } from "./runtime/stealth.js";
32
+ export { APIFUSE__STT__BACKEND_ENV, APIFUSE__STT__CLOUDFLARE_API_TOKEN_ENV, APIFUSE__STT__MODEL_ENV, createSttClientFromEnv, createUnsupportedSttClient, extractVerificationCode, resolveSttPrompt, } from "./runtime/stt.js";
33
+ export { type CreateTraceContextOptions, createTraceContext, type Span, type TraceContext, } from "./runtime/trace.js";
34
+ export { APIFUSE_DESCRIPTION_KEY_META_KEY, APIFUSE_REDACTION_MARKER, APIFUSE_SENSITIVE_KIND_META_KEY, APIFUSE_SENSITIVE_META_KEY, collectSensitivePaths, describeKey, field, fields, isSensitiveSchema, redactPayload, type SensitiveFieldKind, type SensitiveFieldOptions, type SensitivePath, sensitive, z, } from "./schema.js";
35
+ export { createServerApp, type ServeOptions, serve } from "./server/index.js";
36
+ export { getStealthProfile, listStealthProfiles } from "./stealth/profiles.js";
37
+ export * from "./stream.js";
38
+ export type { ApiFuseResponse, AuthConfig, AuthContext, AuthFlowDefinition, AuthFlowInputHandler, AuthFlowStartHandler, AuthMode, AuthTurn, Bcp47Locale, BrowserEngine, BrowserOptions, BrowserResourceBody, BrowserResourceDecision, BrowserResourceMethod, BrowserResourcePolicy, BrowserResourceRequest, BrowserResourceRoute, ConnectionMode, ContextDeclaration, CookieJar, ContextScratchpad, CredentialContext, CredentialDeclaration, E164PhoneNumber, EnvContext, FlowContext, FlowContextStore, HealthCheckAssertionContext, HealthCheckCase, HealthCheckCaseResult, HealthCheckSuite, HealthCheckUnsupported, HealthJourneyDefinition, HealthJourneyEventContext, HealthJourneyGatewayContext, HealthJourneyJournalContext, HealthJourneyManualTriggerPolicy, HealthJourneyRunContext, HealthJourneyRunResult, HealthJourneySchedule, HealthScheduleRandomization, HealthJourneySmsContext, HealthJourneyStep, HttpClient, HttpMethod, HttpResponse, HttpRetryOptions, HttpRetrySummary, HttpStreamResponse, IanaTimeZone, InferSchemaOutput, Iso3166Alpha2CountryCode, Iso4217CurrencyCode, Iso8601Duration, OperationAnnotations, OperationApprovalPolicy, OperationContractMetadata, OperationDefinition, OperationDeprecationMetadata, OperationDocMeta, OperationErrorCode, OperationHandlerResult, OperationInputExample, OperationLifecycle, OperationObservabilityConfig, OperationObservabilitySensitiveConfig, OperationRelationships, OperationRiskClass, OperationSensitivePath, OperationToolRouterMetadata, OperationTransport, OperationTransportKind, ProbeInterval, ProviderAccessConfig, ProviderAccessVisibility, ProviderCache, ProviderCacheGetOrSetOptions, ProviderCacheKeyOptions, ProviderCacheLookupMeta, ProviderCacheResponseMeta, ProviderCacheResult, ProviderChoiceBindingOptions, ProviderChoiceContext, ProviderChoiceIssueOptions, ProviderChoiceParseOptions, ProviderContext, ProviderDefinition, ProviderDeploymentOverrides, ProviderHealthMonitorConfig, ProviderHealthProbeConfig, ProviderLocale, ProviderLocaleKey, ProviderLocaleKeyInput, ProviderLogoProfile, ProviderLogoSource, ProviderMeta, ProviderProxyConfig, ProviderProxyMode, ProviderProxyPolicy, ProviderProxyProvider, ProviderProxySessionAffinity, ProviderPublicConnectionMode, ProviderPublicProfile, ProviderReviewed, ProviderRuntimeState, ProviderSecretDeclaration, ProviderStateDurationString, ProviderStateNamespace, ProviderStreamEvent, ProviderSttConfig, ProviderSttMode, ProviderSupportLevel, RequestOptions, Rfc3339Instant, SchemaLike, SmsOrigin, SmsOtpExtractionPattern, SmsOtpMatcherDefinition, SseMessage, StandardSchemaV1, StateCasResult, StateNamespaceOptions, StateValue, StateWriteOptions, StealthClient, StealthFetchOptions, StealthPlatform, StealthProfile, StealthRedirectHop, StealthRedirectRunOptions, StealthRedirectRunResult, StealthResponse, StealthSession, StealthSessionCookies, SttAudioInput, SttContext, SttPromptPolicy, SttSegment, SttTranscribeMode, SttTranscribeRequest, SttTranscript, SttUnsupportedOptionPolicy, SttUsage, SttVerificationCodeOptions, SttWarning, TraceConfig, TraceSpan, VerificationCodeCandidate, VerificationCodeCandidateSource, VerificationCodeExtractionResult, } from "./types.js";
39
+ export { DEFAULT_OPERATION_TRANSPORT, HttpRetryAfterPolicy, HttpRetryDelayStrategy, HttpRetryJitter, HttpRetryPreset, HttpRetryUnsafeMethodPolicy, PROBE_INTERVALS, STREAM_CHUNK_BYTES_MAX, STREAM_CHUNK_BYTES_MIN, STREAM_HEARTBEAT_MS_MAX, STREAM_HEARTBEAT_MS_MIN, STREAM_IDLE_TIMEOUT_MS_MAX, STREAM_IDLE_TIMEOUT_MS_MIN, STREAM_MAX_DURATION_MS_MAX, STREAM_MAX_DURATION_MS_MIN, } from "./types.js";
40
+ export * from "./utils/date.js";
41
+ export * from "./utils/parse.js";
42
+ export * from "./utils/text.js";
43
+ export * from "./utils/transform.js";