@openrouter/sdk 1.5.58 → 1.5.60

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 (219) hide show
  1. package/README.md +13 -11
  2. package/esm/funcs/apiKeysList.d.ts +4 -1
  3. package/esm/funcs/apiKeysList.js +32 -6
  4. package/esm/funcs/guardrailPoliciesChangeApiKeyPolicyAssignment.d.ts +19 -0
  5. package/esm/funcs/guardrailPoliciesChangeApiKeyPolicyAssignment.js +104 -0
  6. package/esm/funcs/guardrailPoliciesChangeMemberPolicyAssignment.d.ts +19 -0
  7. package/esm/funcs/guardrailPoliciesChangeMemberPolicyAssignment.js +104 -0
  8. package/esm/funcs/guardrailPoliciesCreateAccountPolicy.d.ts +19 -0
  9. package/esm/funcs/guardrailPoliciesCreateAccountPolicy.js +100 -0
  10. package/esm/funcs/guardrailPoliciesCreateBudgetPolicy.d.ts +19 -0
  11. package/esm/funcs/guardrailPoliciesCreateBudgetPolicy.js +100 -0
  12. package/esm/funcs/guardrailPoliciesCreateModelAvailabilityPolicy.d.ts +19 -0
  13. package/esm/funcs/guardrailPoliciesCreateModelAvailabilityPolicy.js +98 -0
  14. package/esm/funcs/guardrailPoliciesCreateModerationPolicy.d.ts +19 -0
  15. package/esm/funcs/guardrailPoliciesCreateModerationPolicy.js +98 -0
  16. package/esm/funcs/guardrailPoliciesDeleteAccountPolicy.d.ts +19 -0
  17. package/esm/funcs/guardrailPoliciesDeleteAccountPolicy.js +103 -0
  18. package/esm/funcs/guardrailPoliciesDeleteBudgetPolicy.d.ts +19 -0
  19. package/esm/funcs/guardrailPoliciesDeleteBudgetPolicy.js +107 -0
  20. package/esm/funcs/guardrailPoliciesDeleteModelAvailabilityPolicy.d.ts +19 -0
  21. package/esm/funcs/guardrailPoliciesDeleteModelAvailabilityPolicy.js +107 -0
  22. package/esm/funcs/guardrailPoliciesDeleteModerationPolicy.d.ts +19 -0
  23. package/esm/funcs/guardrailPoliciesDeleteModerationPolicy.js +107 -0
  24. package/esm/funcs/guardrailPoliciesGetApiKeyPolicyAssignment.d.ts +19 -0
  25. package/esm/funcs/guardrailPoliciesGetApiKeyPolicyAssignment.js +108 -0
  26. package/esm/funcs/guardrailPoliciesGetBudgetPolicy.d.ts +19 -0
  27. package/esm/funcs/guardrailPoliciesGetBudgetPolicy.js +107 -0
  28. package/esm/funcs/guardrailPoliciesGetMemberPolicyAssignment.d.ts +19 -0
  29. package/esm/funcs/guardrailPoliciesGetMemberPolicyAssignment.js +108 -0
  30. package/esm/funcs/guardrailPoliciesGetModelAvailabilityPolicy.d.ts +19 -0
  31. package/esm/funcs/guardrailPoliciesGetModelAvailabilityPolicy.js +107 -0
  32. package/esm/funcs/guardrailPoliciesGetModerationPolicy.d.ts +19 -0
  33. package/esm/funcs/guardrailPoliciesGetModerationPolicy.js +107 -0
  34. package/esm/funcs/guardrailPoliciesListAccountPolicies.d.ts +21 -0
  35. package/esm/funcs/guardrailPoliciesListAccountPolicies.js +133 -0
  36. package/esm/funcs/guardrailPoliciesListBudgetPolicies.d.ts +21 -0
  37. package/esm/funcs/guardrailPoliciesListBudgetPolicies.js +134 -0
  38. package/esm/funcs/guardrailPoliciesListModelAvailabilityPolicies.d.ts +21 -0
  39. package/esm/funcs/guardrailPoliciesListModelAvailabilityPolicies.js +132 -0
  40. package/esm/funcs/guardrailPoliciesListModerationPolicies.d.ts +21 -0
  41. package/esm/funcs/guardrailPoliciesListModerationPolicies.js +134 -0
  42. package/esm/funcs/guardrailPoliciesUpdateAccountPolicy.d.ts +19 -0
  43. package/esm/funcs/guardrailPoliciesUpdateAccountPolicy.js +106 -0
  44. package/esm/funcs/guardrailPoliciesUpdateBudgetPolicy.d.ts +19 -0
  45. package/esm/funcs/guardrailPoliciesUpdateBudgetPolicy.js +106 -0
  46. package/esm/funcs/guardrailPoliciesUpdateModelAvailabilityPolicy.d.ts +19 -0
  47. package/esm/funcs/guardrailPoliciesUpdateModelAvailabilityPolicy.js +104 -0
  48. package/esm/funcs/guardrailPoliciesUpdateModerationPolicy.d.ts +19 -0
  49. package/esm/funcs/guardrailPoliciesUpdateModerationPolicy.js +104 -0
  50. package/esm/hooks/registration.d.ts +1 -1
  51. package/esm/hooks/registration.js +8 -1
  52. package/esm/hooks/signal-hooks.d.ts +42 -0
  53. package/esm/hooks/signal-hooks.js +236 -0
  54. package/esm/lib/config.d.ts +2 -2
  55. package/esm/lib/config.js +2 -2
  56. package/esm/models/accountguardrailpolicy.d.ts +12 -0
  57. package/esm/models/accountguardrailpolicy.js +19 -0
  58. package/esm/models/accountguardrailpolicyrequest.d.ts +11 -0
  59. package/esm/models/accountguardrailpolicyrequest.js +18 -0
  60. package/esm/models/accountguardrailpolicyresponse.d.ts +11 -0
  61. package/esm/models/accountguardrailpolicyresponse.js +15 -0
  62. package/esm/models/armorautomode.d.ts +17 -0
  63. package/esm/models/armorautomode.js +51 -2
  64. package/esm/models/armorcontext.d.ts +5 -0
  65. package/esm/models/armorcontext.js +14 -1
  66. package/esm/models/armorenvironmententry.d.ts +5 -0
  67. package/esm/models/armorenvironmententry.js +9 -0
  68. package/esm/models/armorplugin.d.ts +4 -4
  69. package/esm/models/armorplugin.js +3 -4
  70. package/esm/models/armorrule.d.ts +5 -0
  71. package/esm/models/armorrule.js +11 -0
  72. package/esm/models/budgetaccountguardrailpolicy.d.ts +34 -0
  73. package/esm/models/budgetaccountguardrailpolicy.js +39 -0
  74. package/esm/models/budgetaccountguardrailpolicyrequest.d.ts +68 -0
  75. package/esm/models/budgetaccountguardrailpolicyrequest.js +46 -0
  76. package/esm/models/budgetguardrailpolicy.d.ts +27 -0
  77. package/esm/models/budgetguardrailpolicy.js +28 -0
  78. package/esm/models/budgetguardrailpolicydetail.d.ts +74 -0
  79. package/esm/models/budgetguardrailpolicydetail.js +58 -0
  80. package/esm/models/budgetguardrailpolicydetailresponse.d.ts +11 -0
  81. package/esm/models/budgetguardrailpolicydetailresponse.js +15 -0
  82. package/esm/models/budgetguardrailpolicyresponse.d.ts +11 -0
  83. package/esm/models/budgetguardrailpolicyresponse.js +15 -0
  84. package/esm/models/budgetguardrailpolicysummary.d.ts +43 -0
  85. package/esm/models/budgetguardrailpolicysummary.js +42 -0
  86. package/esm/models/changeguardrailpolicyassignmentrequest.d.ts +49 -0
  87. package/esm/models/changeguardrailpolicyassignmentrequest.js +38 -0
  88. package/esm/models/changeguardrailpolicyassignmentresponse.d.ts +13 -0
  89. package/esm/models/changeguardrailpolicyassignmentresponse.js +14 -0
  90. package/esm/models/chatrequest.d.ts +5 -0
  91. package/esm/models/chatrequest.js +5 -0
  92. package/esm/models/createbudgetguardrailpolicyrequest.d.ts +57 -0
  93. package/esm/models/createbudgetguardrailpolicyrequest.js +38 -0
  94. package/esm/models/createmodelavailabilityguardrailpolicyrequest.d.ts +57 -0
  95. package/esm/models/createmodelavailabilityguardrailpolicyrequest.js +39 -0
  96. package/esm/models/createmoderationguardrailpolicyrequest.d.ts +57 -0
  97. package/esm/models/createmoderationguardrailpolicyrequest.js +38 -0
  98. package/esm/models/deleteguardrailpolicyresponse.d.ts +13 -0
  99. package/esm/models/deleteguardrailpolicyresponse.js +14 -0
  100. package/esm/models/guardrailbudgetpolicyauthoringconfig.d.ts +25 -0
  101. package/esm/models/guardrailbudgetpolicyauthoringconfig.js +30 -0
  102. package/esm/models/guardrailbudgetpolicyconfig.d.ts +22 -0
  103. package/esm/models/guardrailbudgetpolicyconfig.js +24 -0
  104. package/esm/models/guardrailmodelavailabilitypolicyauthoringconfig.d.ts +52 -0
  105. package/esm/models/guardrailmodelavailabilitypolicyauthoringconfig.js +58 -0
  106. package/esm/models/guardrailmodelavailabilitypolicyconfig.d.ts +30 -0
  107. package/esm/models/guardrailmodelavailabilitypolicyconfig.js +59 -0
  108. package/esm/models/guardrailmoderationpolicyconfig.d.ts +240 -0
  109. package/esm/models/guardrailmoderationpolicyconfig.js +289 -0
  110. package/esm/models/guardrailpolicyassignmentresponse.d.ts +11 -0
  111. package/esm/models/guardrailpolicyassignmentresponse.js +15 -0
  112. package/esm/models/guardrailpolicyassignmentstate.d.ts +30 -0
  113. package/esm/models/guardrailpolicyassignmentstate.js +38 -0
  114. package/esm/models/index.d.ts +44 -0
  115. package/esm/models/index.js +44 -0
  116. package/esm/models/listaccountguardrailpoliciesresponse.d.ts +15 -0
  117. package/esm/models/listaccountguardrailpoliciesresponse.js +21 -0
  118. package/esm/models/listbudgetguardrailpoliciesresponse.d.ts +15 -0
  119. package/esm/models/listbudgetguardrailpoliciesresponse.js +21 -0
  120. package/esm/models/listmodelavailabilityguardrailpoliciesresponse.d.ts +15 -0
  121. package/esm/models/listmodelavailabilityguardrailpoliciesresponse.js +21 -0
  122. package/esm/models/listmoderationguardrailpoliciesresponse.d.ts +15 -0
  123. package/esm/models/listmoderationguardrailpoliciesresponse.js +21 -0
  124. package/esm/models/modelavailabilityaccountguardrailpolicy.d.ts +34 -0
  125. package/esm/models/modelavailabilityaccountguardrailpolicy.js +39 -0
  126. package/esm/models/modelavailabilityaccountguardrailpolicyrequest.d.ts +68 -0
  127. package/esm/models/modelavailabilityaccountguardrailpolicyrequest.js +47 -0
  128. package/esm/models/modelavailabilityguardrailpolicy.d.ts +27 -0
  129. package/esm/models/modelavailabilityguardrailpolicy.js +28 -0
  130. package/esm/models/modelavailabilityguardrailpolicydetail.d.ts +74 -0
  131. package/esm/models/modelavailabilityguardrailpolicydetail.js +57 -0
  132. package/esm/models/modelavailabilityguardrailpolicydetailresponse.d.ts +11 -0
  133. package/esm/models/modelavailabilityguardrailpolicydetailresponse.js +15 -0
  134. package/esm/models/modelavailabilityguardrailpolicyresponse.d.ts +11 -0
  135. package/esm/models/modelavailabilityguardrailpolicyresponse.js +15 -0
  136. package/esm/models/modelavailabilityguardrailpolicysummary.d.ts +43 -0
  137. package/esm/models/modelavailabilityguardrailpolicysummary.js +42 -0
  138. package/esm/models/moderationaccountguardrailpolicy.d.ts +34 -0
  139. package/esm/models/moderationaccountguardrailpolicy.js +39 -0
  140. package/esm/models/moderationaccountguardrailpolicyrequest.d.ts +68 -0
  141. package/esm/models/moderationaccountguardrailpolicyrequest.js +47 -0
  142. package/esm/models/moderationguardrailpolicy.d.ts +27 -0
  143. package/esm/models/moderationguardrailpolicy.js +28 -0
  144. package/esm/models/moderationguardrailpolicydetail.d.ts +78 -0
  145. package/esm/models/moderationguardrailpolicydetail.js +60 -0
  146. package/esm/models/moderationguardrailpolicydetailresponse.d.ts +11 -0
  147. package/esm/models/moderationguardrailpolicydetailresponse.js +15 -0
  148. package/esm/models/moderationguardrailpolicyresponse.d.ts +11 -0
  149. package/esm/models/moderationguardrailpolicyresponse.js +15 -0
  150. package/esm/models/moderationguardrailpolicysummary.d.ts +43 -0
  151. package/esm/models/moderationguardrailpolicysummary.js +42 -0
  152. package/esm/models/operations/changeapikeypolicyassignment.d.ts +61 -0
  153. package/esm/models/operations/changeapikeypolicyassignment.js +24 -0
  154. package/esm/models/operations/changememberpolicyassignment.d.ts +61 -0
  155. package/esm/models/operations/changememberpolicyassignment.js +25 -0
  156. package/esm/models/operations/createaccountpolicy.d.ts +56 -0
  157. package/esm/models/operations/createaccountpolicy.js +23 -0
  158. package/esm/models/operations/createbudgetpolicy.d.ts +56 -0
  159. package/esm/models/operations/createbudgetpolicy.js +23 -0
  160. package/esm/models/operations/createmodelavailabilitypolicy.d.ts +56 -0
  161. package/esm/models/operations/createmodelavailabilitypolicy.js +23 -0
  162. package/esm/models/operations/createmoderationpolicy.d.ts +56 -0
  163. package/esm/models/operations/createmoderationpolicy.js +23 -0
  164. package/esm/models/operations/deleteaccountpolicy.d.ts +58 -0
  165. package/esm/models/operations/deleteaccountpolicy.js +21 -0
  166. package/esm/models/operations/deletebudgetpolicy.d.ts +63 -0
  167. package/esm/models/operations/deletebudgetpolicy.js +23 -0
  168. package/esm/models/operations/deletemodelavailabilitypolicy.d.ts +63 -0
  169. package/esm/models/operations/deletemodelavailabilitypolicy.js +23 -0
  170. package/esm/models/operations/deletemoderationpolicy.d.ts +63 -0
  171. package/esm/models/operations/deletemoderationpolicy.js +23 -0
  172. package/esm/models/operations/getapikeypolicyassignment.d.ts +84 -0
  173. package/esm/models/operations/getapikeypolicyassignment.js +37 -0
  174. package/esm/models/operations/getbudgetpolicy.d.ts +63 -0
  175. package/esm/models/operations/getbudgetpolicy.js +23 -0
  176. package/esm/models/operations/getmemberpolicyassignment.d.ts +84 -0
  177. package/esm/models/operations/getmemberpolicyassignment.js +38 -0
  178. package/esm/models/operations/getmodelavailabilitypolicy.d.ts +63 -0
  179. package/esm/models/operations/getmodelavailabilitypolicy.js +23 -0
  180. package/esm/models/operations/getmoderationpolicy.d.ts +63 -0
  181. package/esm/models/operations/getmoderationpolicy.js +23 -0
  182. package/esm/models/operations/index.d.ts +23 -0
  183. package/esm/models/operations/index.js +23 -0
  184. package/esm/models/operations/list.d.ts +7 -1
  185. package/esm/models/operations/list.js +12 -1
  186. package/esm/models/operations/listaccountpolicies.d.ts +72 -0
  187. package/esm/models/operations/listaccountpolicies.js +35 -0
  188. package/esm/models/operations/listbudgetpolicies.d.ts +77 -0
  189. package/esm/models/operations/listbudgetpolicies.js +37 -0
  190. package/esm/models/operations/listmodelavailabilitypolicies.d.ts +77 -0
  191. package/esm/models/operations/listmodelavailabilitypolicies.js +37 -0
  192. package/esm/models/operations/listmoderationpolicies.d.ts +77 -0
  193. package/esm/models/operations/listmoderationpolicies.js +37 -0
  194. package/esm/models/operations/updateaccountpolicy.d.ts +61 -0
  195. package/esm/models/operations/updateaccountpolicy.js +24 -0
  196. package/esm/models/operations/updatebudgetpolicy.d.ts +61 -0
  197. package/esm/models/operations/updatebudgetpolicy.js +24 -0
  198. package/esm/models/operations/updatemodelavailabilitypolicy.d.ts +61 -0
  199. package/esm/models/operations/updatemodelavailabilitypolicy.js +24 -0
  200. package/esm/models/operations/updatemoderationpolicy.d.ts +61 -0
  201. package/esm/models/operations/updatemoderationpolicy.js +24 -0
  202. package/esm/models/outputmemoryservertoolitem.d.ts +5 -5
  203. package/esm/models/outputmemoryservertoolitem.js +5 -5
  204. package/esm/models/updatebudgetguardrailpolicyrequest.d.ts +48 -0
  205. package/esm/models/updatebudgetguardrailpolicyrequest.js +31 -0
  206. package/esm/models/updatemodelavailabilityguardrailpolicyrequest.d.ts +48 -0
  207. package/esm/models/updatemodelavailabilityguardrailpolicyrequest.js +31 -0
  208. package/esm/models/updatemoderationguardrailpolicyrequest.d.ts +48 -0
  209. package/esm/models/updatemoderationguardrailpolicyrequest.js +31 -0
  210. package/esm/sdk/apikeys.d.ts +4 -1
  211. package/esm/sdk/apikeys.js +2 -1
  212. package/esm/sdk/guardrailpolicies.d.ts +176 -0
  213. package/esm/sdk/guardrailpolicies.js +240 -0
  214. package/esm/sdk/sdk.d.ts +3 -0
  215. package/esm/sdk/sdk.js +4 -0
  216. package/jsr.json +1 -1
  217. package/package.json +9 -9
  218. package/scripts/check-types.js +113 -40
  219. package/vitest.config.ts +7 -0
@@ -1,11 +1,18 @@
1
+ import { SignalTimeoutHook } from './signal-hooks.js';
1
2
  /*
2
3
  * This file is only ever generated once on the first generation and then is free to be modified.
3
4
  * Any hooks you wish to add should be registered in the initHooks function. Feel free to define them
4
5
  * in this file or in separate files in the hooks folder.
5
6
  */
6
- export function initHooks(_hooks) {
7
+ export function initHooks(hooks) {
7
8
  // Add hooks by calling hooks.register{ClientInit/BeforeCreateRequest/BeforeRequest/AfterSuccess/AfterError}Hook
8
9
  // with an instance of a hook that implements that specific Hook interface
9
10
  // Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance
11
+ // Compose timeoutMs with caller signals (#1123) and keep aborts working
12
+ // after GC in Node (#1315).
13
+ const signalTimeoutHook = new SignalTimeoutHook();
14
+ hooks.registerSDKInitHook(signalTimeoutHook);
15
+ hooks.registerBeforeCreateRequestHook(signalTimeoutHook);
16
+ hooks.registerBeforeRequestHook(signalTimeoutHook);
10
17
  }
11
18
  //# sourceMappingURL=registration.js.map
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Hooks that fix two gaps in the generated request pipeline without editing
3
+ * generated files:
4
+ *
5
+ * 1. Timeouts and signals compose (#1123). The generated `_createRequest`
6
+ * skips `timeoutMs` whenever the caller passes `signal`. This hook restores
7
+ * the timeout on the hook context so `_do` combines it with the signal and
8
+ * the request aborts on whichever fires first. The timeout covers the whole
9
+ * attempt, including reading a streamed response body, the same as for
10
+ * calls made without a signal.
11
+ *
12
+ * 2. Aborts survive garbage collection in Node (#1315). The generated
13
+ * `HTTPClient` calls `fetch(request)` with only a `Request`. In undici, a
14
+ * `Request`'s signal follows its source signal through a weak reference, so
15
+ * after a GC an abort can stop reaching the network
16
+ * (https://github.com/nodejs/undici/issues/4068). Passing the caller's
17
+ * signal again in the `fetch` init avoids this. The hook links each
18
+ * outgoing `Request` to a signal built directly from the caller's signal
19
+ * and the per-attempt timeout, and a wrapped fetcher passes it as `init`.
20
+ * This part only runs on Node: other runtimes don't have the bug, and Bun
21
+ * mishandles a `Request` combined with an `init` argument.
22
+ */
23
+ import type { SDKOptions } from "../lib/config.js";
24
+ import type { RequestInput } from "../lib/http.js";
25
+ import type { BeforeCreateRequestContext, BeforeCreateRequestHook, BeforeRequestContext, BeforeRequestHook, SDKInitHook } from "./types.js";
26
+ /** True on Node.js, false on Bun, Deno, browsers and other runtimes. */
27
+ export declare function isNodeRuntime(): boolean;
28
+ export type SignalTimeoutHookOptions = {
29
+ /**
30
+ * Whether to apply the abort-after-GC fix (#1315). Defaults to true on
31
+ * Node.js only.
32
+ */
33
+ fixAbortAfterGC?: boolean;
34
+ };
35
+ export declare class SignalTimeoutHook implements SDKInitHook, BeforeCreateRequestHook, BeforeRequestHook {
36
+ #private;
37
+ constructor(options?: SignalTimeoutHookOptions);
38
+ sdkInit(opts: SDKOptions): SDKOptions;
39
+ beforeCreateRequest(hookCtx: BeforeCreateRequestContext, input: RequestInput): RequestInput;
40
+ beforeRequest(hookCtx: BeforeRequestContext, request: Request): Request;
41
+ }
42
+ //# sourceMappingURL=signal-hooks.d.ts.map
@@ -0,0 +1,236 @@
1
+ /**
2
+ * Hooks that fix two gaps in the generated request pipeline without editing
3
+ * generated files:
4
+ *
5
+ * 1. Timeouts and signals compose (#1123). The generated `_createRequest`
6
+ * skips `timeoutMs` whenever the caller passes `signal`. This hook restores
7
+ * the timeout on the hook context so `_do` combines it with the signal and
8
+ * the request aborts on whichever fires first. The timeout covers the whole
9
+ * attempt, including reading a streamed response body, the same as for
10
+ * calls made without a signal.
11
+ *
12
+ * 2. Aborts survive garbage collection in Node (#1315). The generated
13
+ * `HTTPClient` calls `fetch(request)` with only a `Request`. In undici, a
14
+ * `Request`'s signal follows its source signal through a weak reference, so
15
+ * after a GC an abort can stop reaching the network
16
+ * (https://github.com/nodejs/undici/issues/4068). Passing the caller's
17
+ * signal again in the `fetch` init avoids this. The hook links each
18
+ * outgoing `Request` to a signal built directly from the caller's signal
19
+ * and the per-attempt timeout, and a wrapped fetcher passes it as `init`.
20
+ * This part only runs on Node: other runtimes don't have the bug, and Bun
21
+ * mishandles a `Request` combined with an `init` argument.
22
+ */
23
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
24
+ if (kind === "m") throw new TypeError("Private method is not writable");
25
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
26
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
27
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
28
+ };
29
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
30
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
31
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
32
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
33
+ };
34
+ var _SignalTimeoutHook_fixAbortAfterGC;
35
+ import { combineSignals } from "../lib/primitives.js";
36
+ /** The caller's own signal for each in-flight operation. */
37
+ const callerSignals = new WeakMap();
38
+ /** The signal to pass in the `fetch` init for each outgoing request. */
39
+ const fetchSignals = new WeakMap();
40
+ /** HTTP clients whose fetcher and hooks have already been wrapped. */
41
+ const wrappedClients = new WeakSet();
42
+ /** Wrapped version of each user `HTTPClient` beforeRequest hook. */
43
+ const wrappedHooks = new WeakMap();
44
+ /** The user hook each wrapped hook came from. */
45
+ const originalHooks = new WeakMap();
46
+ function isObject(value) {
47
+ return typeof value === "object" && value !== null;
48
+ }
49
+ function hasFetcher(value) {
50
+ return (isObject(value)
51
+ && "fetcher" in value
52
+ && typeof value.fetcher === "function");
53
+ }
54
+ function hasRequestHooks(value) {
55
+ return (isObject(value)
56
+ && "requestHooks" in value
57
+ && Array.isArray(value.requestHooks));
58
+ }
59
+ function isHTTPBeforeRequestHook(value) {
60
+ return typeof value === "function";
61
+ }
62
+ /** True on Node.js, false on Bun, Deno, browsers and other runtimes. */
63
+ export function isNodeRuntime() {
64
+ const proc = Reflect.get(globalThis, "process");
65
+ if (!isObject(proc) || !("versions" in proc) || !isObject(proc.versions)) {
66
+ return false;
67
+ }
68
+ const versions = proc.versions;
69
+ return ("node" in versions
70
+ && typeof versions.node === "string"
71
+ && !("bun" in versions)
72
+ && !("deno" in versions));
73
+ }
74
+ function perRequestTimeoutMs(options) {
75
+ if (isObject(options)
76
+ && "timeoutMs" in options
77
+ && typeof options.timeoutMs === "number") {
78
+ return options.timeoutMs;
79
+ }
80
+ return undefined;
81
+ }
82
+ function resolveTimeoutMs(hookCtx, options) {
83
+ // Mirrors the generated `options?.timeoutMs || client._options.timeoutMs`
84
+ // in each `src/funcs/*` operation. `_createRequest` spreads the per-call
85
+ // RequestOptions into the fetch options, so a per-request `timeoutMs` is
86
+ // visible here. A unit test fails if a regen adds per-operation timeout
87
+ // defaults that this lookup would miss.
88
+ const timeoutMs = perRequestTimeoutMs(options) || hookCtx.options.timeoutMs;
89
+ return timeoutMs != null && timeoutMs > 0 ? timeoutMs : undefined;
90
+ }
91
+ /**
92
+ * Wraps a user `HTTPClient` beforeRequest hook so that a replacement
93
+ * `Request` it returns keeps the fetch signal linked to the original.
94
+ */
95
+ function wrapUserHook(fn) {
96
+ const existing = wrappedHooks.get(fn);
97
+ if (existing) {
98
+ return existing;
99
+ }
100
+ const wrapped = async (req) => {
101
+ const next = await fn(req);
102
+ if (next instanceof Request && next !== req) {
103
+ const signal = fetchSignals.get(req);
104
+ if (signal) {
105
+ // Keep any signal the user's hook set on the new request too.
106
+ fetchSignals.set(next, combineSignals(signal, next.signal) ?? signal);
107
+ }
108
+ }
109
+ return next;
110
+ };
111
+ wrappedHooks.set(fn, wrapped);
112
+ originalHooks.set(wrapped, fn);
113
+ return wrapped;
114
+ }
115
+ /** The user's own hook for a wrapped hook, or the hook itself. */
116
+ function unwrapUserHook(hook) {
117
+ return isHTTPBeforeRequestHook(hook) ? originalHooks.get(hook) ?? hook : hook;
118
+ }
119
+ /**
120
+ * Wraps beforeRequest hooks already on the client, and patches `addHook`,
121
+ * `removeHook` and `clone` so hooks added or removed later are handled the
122
+ * same way.
123
+ */
124
+ function wrapClientHooks(client) {
125
+ if (hasRequestHooks(client)) {
126
+ client.requestHooks = client.requestHooks.map((hook) => isHTTPBeforeRequestHook(hook) ? wrapUserHook(hook) : hook);
127
+ }
128
+ const addHook = Reflect.get(client, "addHook");
129
+ const removeHook = Reflect.get(client, "removeHook");
130
+ const clone = Reflect.get(client, "clone");
131
+ if (typeof addHook !== "function"
132
+ || typeof removeHook !== "function"
133
+ || typeof clone !== "function") {
134
+ return;
135
+ }
136
+ // A clone gets the generated, unpatched `removeHook`, so it must hold the
137
+ // user's own hooks: otherwise removing one by its original function finds
138
+ // nothing and the wrapped hook keeps running. The clone is wrapped again
139
+ // only if it is passed to an SDK.
140
+ Reflect.set(client, "clone", () => {
141
+ const child = Reflect.apply(clone, client, []);
142
+ if (hasRequestHooks(child)) {
143
+ child.requestHooks = child.requestHooks.map(unwrapUserHook);
144
+ }
145
+ return child;
146
+ });
147
+ Reflect.set(client, "addHook", (...args) => {
148
+ const [kind, fn] = args;
149
+ if (kind === "beforeRequest" && isHTTPBeforeRequestHook(fn)) {
150
+ Reflect.apply(addHook, client, [kind, wrapUserHook(fn)]);
151
+ return client;
152
+ }
153
+ Reflect.apply(addHook, client, args);
154
+ return client;
155
+ });
156
+ Reflect.set(client, "removeHook", (...args) => {
157
+ const [kind, fn] = args;
158
+ if (kind === "beforeRequest" && isHTTPBeforeRequestHook(fn)) {
159
+ Reflect.apply(removeHook, client, [kind, wrappedHooks.get(fn) ?? fn]);
160
+ return client;
161
+ }
162
+ Reflect.apply(removeHook, client, args);
163
+ return client;
164
+ });
165
+ }
166
+ export class SignalTimeoutHook {
167
+ constructor(options = {}) {
168
+ _SignalTimeoutHook_fixAbortAfterGC.set(this, void 0);
169
+ __classPrivateFieldSet(this, _SignalTimeoutHook_fixAbortAfterGC, options.fixAbortAfterGC ?? isNodeRuntime(), "f");
170
+ }
171
+ sdkInit(opts) {
172
+ if (!__classPrivateFieldGet(this, _SignalTimeoutHook_fixAbortAfterGC, "f")) {
173
+ return opts;
174
+ }
175
+ const client = opts.httpClient;
176
+ // `fetcher` and `requestHooks` are private fields of the generated
177
+ // HTTPClient. If a future regen renames them, skip the wrap rather than
178
+ // break requests; the unit tests flag that case.
179
+ if (hasFetcher(client) && !wrappedClients.has(client)) {
180
+ const inner = client.fetcher;
181
+ client.fetcher = (input, init) => {
182
+ const signal = input instanceof Request
183
+ ? fetchSignals.get(input)
184
+ : undefined;
185
+ if (signal && init?.signal == null) {
186
+ return inner(input, { ...init, signal });
187
+ }
188
+ return inner(input, init);
189
+ };
190
+ wrapClientHooks(client);
191
+ wrappedClients.add(client);
192
+ }
193
+ return opts;
194
+ }
195
+ beforeCreateRequest(hookCtx, input) {
196
+ const signal = input.options?.signal;
197
+ if (signal) {
198
+ if (__classPrivateFieldGet(this, _SignalTimeoutHook_fixAbortAfterGC, "f")) {
199
+ callerSignals.set(hookCtx, signal);
200
+ }
201
+ if (hookCtx.timeoutMs == null || hookCtx.timeoutMs <= 0) {
202
+ const timeoutMs = resolveTimeoutMs(hookCtx, input.options);
203
+ if (timeoutMs != null) {
204
+ hookCtx.timeoutMs = timeoutMs;
205
+ }
206
+ }
207
+ }
208
+ return input;
209
+ }
210
+ beforeRequest(hookCtx, request) {
211
+ if (!__classPrivateFieldGet(this, _SignalTimeoutHook_fixAbortAfterGC, "f")) {
212
+ return request;
213
+ }
214
+ // Runs once per attempt, so each retry gets a fresh timeout.
215
+ //
216
+ // `_do` has already started an `AbortSignal.timeout` of the same length
217
+ // for this attempt, but it only reaches us through `request.signal`, which
218
+ // is the weakly linked signal that #1315 is about. So we start a second
219
+ // timer and build the fetch signal from strong references only. The fetch
220
+ // uses this one; the `_do` timer is redundant but harmless.
221
+ const timeoutSignal = hookCtx.timeoutMs != null && hookCtx.timeoutMs > 0
222
+ ? AbortSignal.timeout(hookCtx.timeoutMs)
223
+ : undefined;
224
+ const strongSignal = combineSignals(callerSignals.get(hookCtx), timeoutSignal);
225
+ if (!strongSignal) {
226
+ return request;
227
+ }
228
+ // `request.signal` is included so that a signal a later create-request
229
+ // hook put on the request still cancels the fetch, instead of the caller's
230
+ // signal captured above overriding it.
231
+ fetchSignals.set(request, combineSignals(strongSignal, request.signal) ?? strongSignal);
232
+ return request;
233
+ }
234
+ }
235
+ _SignalTimeoutHook_fixAbortAfterGC = new WeakMap();
236
+ //# sourceMappingURL=signal-hooks.js.map
@@ -50,8 +50,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
50
50
  export declare const SDK_METADATA: {
51
51
  readonly language: "typescript";
52
52
  readonly openapiDocVersion: "1.0.0";
53
- readonly sdkVersion: "1.5.58";
53
+ readonly sdkVersion: "1.5.60";
54
54
  readonly genVersion: "2.950.13";
55
- readonly userAgent: "speakeasy-sdk/typescript 1.5.58 2.950.13 1.0.0 @openrouter/sdk";
55
+ readonly userAgent: "speakeasy-sdk/typescript 1.5.60 2.950.13 1.0.0 @openrouter/sdk";
56
56
  };
57
57
  //# sourceMappingURL=config.d.ts.map
package/esm/lib/config.js CHANGED
@@ -29,8 +29,8 @@ export function serverURLFromOptions(options) {
29
29
  export const SDK_METADATA = {
30
30
  language: "typescript",
31
31
  openapiDocVersion: "1.0.0",
32
- sdkVersion: "1.5.58",
32
+ sdkVersion: "1.5.60",
33
33
  genVersion: "2.950.13",
34
- userAgent: "speakeasy-sdk/typescript 1.5.58 2.950.13 1.0.0 @openrouter/sdk",
34
+ userAgent: "speakeasy-sdk/typescript 1.5.60 2.950.13 1.0.0 @openrouter/sdk",
35
35
  };
36
36
  //# sourceMappingURL=config.js.map
@@ -0,0 +1,12 @@
1
+ import * as z from "zod/v4";
2
+ import * as discriminatedUnionTypes from "../types/discriminatedUnion.js";
3
+ import { Result as SafeParseResult } from "../types/fp.js";
4
+ import { BudgetAccountGuardrailPolicy } from "./budgetaccountguardrailpolicy.js";
5
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
6
+ import { ModelAvailabilityAccountGuardrailPolicy } from "./modelavailabilityaccountguardrailpolicy.js";
7
+ import { ModerationAccountGuardrailPolicy } from "./moderationaccountguardrailpolicy.js";
8
+ export type AccountGuardrailPolicy = BudgetAccountGuardrailPolicy | ModelAvailabilityAccountGuardrailPolicy | ModerationAccountGuardrailPolicy | discriminatedUnionTypes.Unknown<"policyType">;
9
+ /** @internal */
10
+ export declare const AccountGuardrailPolicy$inboundSchema: z.ZodType<AccountGuardrailPolicy, unknown>;
11
+ export declare function accountGuardrailPolicyFromJSON(jsonString: string): SafeParseResult<AccountGuardrailPolicy, SDKValidationError>;
12
+ //# sourceMappingURL=accountguardrailpolicy.d.ts.map
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: fee967ed8916
4
+ */
5
+ import { safeParse } from "../lib/schemas.js";
6
+ import { discriminatedUnion } from "../types/discriminatedUnion.js";
7
+ import { BudgetAccountGuardrailPolicy$inboundSchema, } from "./budgetaccountguardrailpolicy.js";
8
+ import { ModelAvailabilityAccountGuardrailPolicy$inboundSchema, } from "./modelavailabilityaccountguardrailpolicy.js";
9
+ import { ModerationAccountGuardrailPolicy$inboundSchema, } from "./moderationaccountguardrailpolicy.js";
10
+ /** @internal */
11
+ export const AccountGuardrailPolicy$inboundSchema = discriminatedUnion("policy_type", {
12
+ budget: BudgetAccountGuardrailPolicy$inboundSchema,
13
+ model_availability: ModelAvailabilityAccountGuardrailPolicy$inboundSchema,
14
+ moderation: ModerationAccountGuardrailPolicy$inboundSchema,
15
+ }, { outputPropertyName: "policyType" });
16
+ export function accountGuardrailPolicyFromJSON(jsonString) {
17
+ return safeParse(jsonString, (x) => AccountGuardrailPolicy$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AccountGuardrailPolicy' from JSON`);
18
+ }
19
+ //# sourceMappingURL=accountguardrailpolicy.js.map
@@ -0,0 +1,11 @@
1
+ import * as z from "zod/v4";
2
+ import { BudgetAccountGuardrailPolicyRequest, BudgetAccountGuardrailPolicyRequest$Outbound } from "./budgetaccountguardrailpolicyrequest.js";
3
+ import { ModelAvailabilityAccountGuardrailPolicyRequest, ModelAvailabilityAccountGuardrailPolicyRequest$Outbound } from "./modelavailabilityaccountguardrailpolicyrequest.js";
4
+ import { ModerationAccountGuardrailPolicyRequest, ModerationAccountGuardrailPolicyRequest$Outbound } from "./moderationaccountguardrailpolicyrequest.js";
5
+ export type AccountGuardrailPolicyRequest = BudgetAccountGuardrailPolicyRequest | ModelAvailabilityAccountGuardrailPolicyRequest | ModerationAccountGuardrailPolicyRequest;
6
+ /** @internal */
7
+ export type AccountGuardrailPolicyRequest$Outbound = BudgetAccountGuardrailPolicyRequest$Outbound | ModelAvailabilityAccountGuardrailPolicyRequest$Outbound | ModerationAccountGuardrailPolicyRequest$Outbound;
8
+ /** @internal */
9
+ export declare const AccountGuardrailPolicyRequest$outboundSchema: z.ZodType<AccountGuardrailPolicyRequest$Outbound, AccountGuardrailPolicyRequest>;
10
+ export declare function accountGuardrailPolicyRequestToJSON(accountGuardrailPolicyRequest: AccountGuardrailPolicyRequest): string;
11
+ //# sourceMappingURL=accountguardrailpolicyrequest.d.ts.map
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 7fea38c4196a
4
+ */
5
+ import * as z from "zod/v4";
6
+ import { BudgetAccountGuardrailPolicyRequest$outboundSchema, } from "./budgetaccountguardrailpolicyrequest.js";
7
+ import { ModelAvailabilityAccountGuardrailPolicyRequest$outboundSchema, } from "./modelavailabilityaccountguardrailpolicyrequest.js";
8
+ import { ModerationAccountGuardrailPolicyRequest$outboundSchema, } from "./moderationaccountguardrailpolicyrequest.js";
9
+ /** @internal */
10
+ export const AccountGuardrailPolicyRequest$outboundSchema = z.union([
11
+ BudgetAccountGuardrailPolicyRequest$outboundSchema,
12
+ ModelAvailabilityAccountGuardrailPolicyRequest$outboundSchema,
13
+ ModerationAccountGuardrailPolicyRequest$outboundSchema,
14
+ ]);
15
+ export function accountGuardrailPolicyRequestToJSON(accountGuardrailPolicyRequest) {
16
+ return JSON.stringify(AccountGuardrailPolicyRequest$outboundSchema.parse(accountGuardrailPolicyRequest));
17
+ }
18
+ //# sourceMappingURL=accountguardrailpolicyrequest.js.map
@@ -0,0 +1,11 @@
1
+ import * as z from "zod/v4";
2
+ import { Result as SafeParseResult } from "../types/fp.js";
3
+ import { AccountGuardrailPolicy } from "./accountguardrailpolicy.js";
4
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
5
+ export type AccountGuardrailPolicyResponse = {
6
+ data: AccountGuardrailPolicy;
7
+ };
8
+ /** @internal */
9
+ export declare const AccountGuardrailPolicyResponse$inboundSchema: z.ZodType<AccountGuardrailPolicyResponse, unknown>;
10
+ export declare function accountGuardrailPolicyResponseFromJSON(jsonString: string): SafeParseResult<AccountGuardrailPolicyResponse, SDKValidationError>;
11
+ //# sourceMappingURL=accountguardrailpolicyresponse.d.ts.map
@@ -0,0 +1,15 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 9530188bd1ff
4
+ */
5
+ import * as z from "zod/v4";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import { AccountGuardrailPolicy$inboundSchema, } from "./accountguardrailpolicy.js";
8
+ /** @internal */
9
+ export const AccountGuardrailPolicyResponse$inboundSchema = z.object({
10
+ data: AccountGuardrailPolicy$inboundSchema,
11
+ });
12
+ export function accountGuardrailPolicyResponseFromJSON(jsonString) {
13
+ return safeParse(jsonString, (x) => AccountGuardrailPolicyResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AccountGuardrailPolicyResponse' from JSON`);
14
+ }
15
+ //# sourceMappingURL=accountguardrailpolicyresponse.js.map
@@ -1,6 +1,8 @@
1
1
  import * as z from "zod/v4";
2
+ import { Result as SafeParseResult } from "../types/fp.js";
2
3
  import { ArmorEnvironmentEntry, ArmorEnvironmentEntry$Outbound } from "./armorenvironmententry.js";
3
4
  import { ArmorRule, ArmorRule$Outbound } from "./armorrule.js";
5
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
4
6
  export type Allow = ArmorRule | string;
5
7
  export type Environment = ArmorEnvironmentEntry | string;
6
8
  export type HardDeny = ArmorRule | string;
@@ -12,25 +14,39 @@ export type ArmorAutoMode = {
12
14
  softDeny?: Array<ArmorRule | string> | undefined;
13
15
  };
14
16
  /** @internal */
17
+ export declare const Allow$inboundSchema: z.ZodType<Allow, unknown>;
18
+ /** @internal */
15
19
  export type Allow$Outbound = ArmorRule$Outbound | string;
16
20
  /** @internal */
17
21
  export declare const Allow$outboundSchema: z.ZodType<Allow$Outbound, Allow>;
18
22
  export declare function allowToJSON(allow: Allow): string;
23
+ export declare function allowFromJSON(jsonString: string): SafeParseResult<Allow, SDKValidationError>;
24
+ /** @internal */
25
+ export declare const Environment$inboundSchema: z.ZodType<Environment, unknown>;
19
26
  /** @internal */
20
27
  export type Environment$Outbound = ArmorEnvironmentEntry$Outbound | string;
21
28
  /** @internal */
22
29
  export declare const Environment$outboundSchema: z.ZodType<Environment$Outbound, Environment>;
23
30
  export declare function environmentToJSON(environment: Environment): string;
31
+ export declare function environmentFromJSON(jsonString: string): SafeParseResult<Environment, SDKValidationError>;
32
+ /** @internal */
33
+ export declare const HardDeny$inboundSchema: z.ZodType<HardDeny, unknown>;
24
34
  /** @internal */
25
35
  export type HardDeny$Outbound = ArmorRule$Outbound | string;
26
36
  /** @internal */
27
37
  export declare const HardDeny$outboundSchema: z.ZodType<HardDeny$Outbound, HardDeny>;
28
38
  export declare function hardDenyToJSON(hardDeny: HardDeny): string;
39
+ export declare function hardDenyFromJSON(jsonString: string): SafeParseResult<HardDeny, SDKValidationError>;
40
+ /** @internal */
41
+ export declare const SoftDeny$inboundSchema: z.ZodType<SoftDeny, unknown>;
29
42
  /** @internal */
30
43
  export type SoftDeny$Outbound = ArmorRule$Outbound | string;
31
44
  /** @internal */
32
45
  export declare const SoftDeny$outboundSchema: z.ZodType<SoftDeny$Outbound, SoftDeny>;
33
46
  export declare function softDenyToJSON(softDeny: SoftDeny): string;
47
+ export declare function softDenyFromJSON(jsonString: string): SafeParseResult<SoftDeny, SDKValidationError>;
48
+ /** @internal */
49
+ export declare const ArmorAutoMode$inboundSchema: z.ZodType<ArmorAutoMode, unknown>;
34
50
  /** @internal */
35
51
  export type ArmorAutoMode$Outbound = {
36
52
  allow?: Array<ArmorRule$Outbound | string> | undefined;
@@ -41,4 +57,5 @@ export type ArmorAutoMode$Outbound = {
41
57
  /** @internal */
42
58
  export declare const ArmorAutoMode$outboundSchema: z.ZodType<ArmorAutoMode$Outbound, ArmorAutoMode>;
43
59
  export declare function armorAutoModeToJSON(armorAutoMode: ArmorAutoMode): string;
60
+ export declare function armorAutoModeFromJSON(jsonString: string): SafeParseResult<ArmorAutoMode, SDKValidationError>;
44
61
  //# sourceMappingURL=armorautomode.d.ts.map
@@ -4,8 +4,14 @@
4
4
  */
5
5
  import * as z from "zod/v4";
6
6
  import { remap as remap$ } from "../lib/primitives.js";
7
- import { ArmorEnvironmentEntry$outboundSchema, } from "./armorenvironmententry.js";
8
- import { ArmorRule$outboundSchema, } from "./armorrule.js";
7
+ import { safeParse } from "../lib/schemas.js";
8
+ import { ArmorEnvironmentEntry$inboundSchema, ArmorEnvironmentEntry$outboundSchema, } from "./armorenvironmententry.js";
9
+ import { ArmorRule$inboundSchema, ArmorRule$outboundSchema, } from "./armorrule.js";
10
+ /** @internal */
11
+ export const Allow$inboundSchema = z.union([
12
+ ArmorRule$inboundSchema,
13
+ z.string(),
14
+ ]);
9
15
  /** @internal */
10
16
  export const Allow$outboundSchema = z.union([
11
17
  ArmorRule$outboundSchema,
@@ -14,23 +20,63 @@ export const Allow$outboundSchema = z.union([
14
20
  export function allowToJSON(allow) {
15
21
  return JSON.stringify(Allow$outboundSchema.parse(allow));
16
22
  }
23
+ export function allowFromJSON(jsonString) {
24
+ return safeParse(jsonString, (x) => Allow$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Allow' from JSON`);
25
+ }
26
+ /** @internal */
27
+ export const Environment$inboundSchema = z
28
+ .union([ArmorEnvironmentEntry$inboundSchema, z.string()]);
17
29
  /** @internal */
18
30
  export const Environment$outboundSchema = z.union([ArmorEnvironmentEntry$outboundSchema, z.string()]);
19
31
  export function environmentToJSON(environment) {
20
32
  return JSON.stringify(Environment$outboundSchema.parse(environment));
21
33
  }
34
+ export function environmentFromJSON(jsonString) {
35
+ return safeParse(jsonString, (x) => Environment$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Environment' from JSON`);
36
+ }
37
+ /** @internal */
38
+ export const HardDeny$inboundSchema = z.union([
39
+ ArmorRule$inboundSchema,
40
+ z.string(),
41
+ ]);
22
42
  /** @internal */
23
43
  export const HardDeny$outboundSchema = z
24
44
  .union([ArmorRule$outboundSchema, z.string()]);
25
45
  export function hardDenyToJSON(hardDeny) {
26
46
  return JSON.stringify(HardDeny$outboundSchema.parse(hardDeny));
27
47
  }
48
+ export function hardDenyFromJSON(jsonString) {
49
+ return safeParse(jsonString, (x) => HardDeny$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'HardDeny' from JSON`);
50
+ }
51
+ /** @internal */
52
+ export const SoftDeny$inboundSchema = z.union([
53
+ ArmorRule$inboundSchema,
54
+ z.string(),
55
+ ]);
28
56
  /** @internal */
29
57
  export const SoftDeny$outboundSchema = z
30
58
  .union([ArmorRule$outboundSchema, z.string()]);
31
59
  export function softDenyToJSON(softDeny) {
32
60
  return JSON.stringify(SoftDeny$outboundSchema.parse(softDeny));
33
61
  }
62
+ export function softDenyFromJSON(jsonString) {
63
+ return safeParse(jsonString, (x) => SoftDeny$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SoftDeny' from JSON`);
64
+ }
65
+ /** @internal */
66
+ export const ArmorAutoMode$inboundSchema = z
67
+ .object({
68
+ allow: z.array(z.union([ArmorRule$inboundSchema, z.string()])).optional(),
69
+ environment: z.array(z.union([ArmorEnvironmentEntry$inboundSchema, z.string()])).optional(),
70
+ hard_deny: z.array(z.union([ArmorRule$inboundSchema, z.string()]))
71
+ .optional(),
72
+ soft_deny: z.array(z.union([ArmorRule$inboundSchema, z.string()]))
73
+ .optional(),
74
+ }).transform((v) => {
75
+ return remap$(v, {
76
+ "hard_deny": "hardDeny",
77
+ "soft_deny": "softDeny",
78
+ });
79
+ });
34
80
  /** @internal */
35
81
  export const ArmorAutoMode$outboundSchema = z.object({
36
82
  allow: z.array(z.union([ArmorRule$outboundSchema, z.string()])).optional(),
@@ -46,4 +92,7 @@ export const ArmorAutoMode$outboundSchema = z.object({
46
92
  export function armorAutoModeToJSON(armorAutoMode) {
47
93
  return JSON.stringify(ArmorAutoMode$outboundSchema.parse(armorAutoMode));
48
94
  }
95
+ export function armorAutoModeFromJSON(jsonString) {
96
+ return safeParse(jsonString, (x) => ArmorAutoMode$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ArmorAutoMode' from JSON`);
97
+ }
49
98
  //# sourceMappingURL=armorautomode.js.map
@@ -1,5 +1,7 @@
1
1
  import * as z from "zod/v4";
2
+ import { Result as SafeParseResult } from "../types/fp.js";
2
3
  import { ArmorAutoMode, ArmorAutoMode$Outbound } from "./armorautomode.js";
4
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
3
5
  /**
4
6
  * The Armor context: Claude Code's `classifier_context` (v1), with `auto_mode.{hard_deny,soft_deny,allow}` rules as strings or `{ id, instructions, threshold? }` objects and `auto_mode.environment` entries as `"Name: value"` strings or `{ name, value }` objects. `threshold` applies when Armor evaluates; when the provider evaluates natively (Anthropic dangerous-tool-use beta) rules are judged at the provider's own boundary.
5
7
  */
@@ -11,6 +13,8 @@ export type ArmorContext = {
11
13
  } | undefined;
12
14
  };
13
15
  /** @internal */
16
+ export declare const ArmorContext$inboundSchema: z.ZodType<ArmorContext, unknown>;
17
+ /** @internal */
14
18
  export type ArmorContext$Outbound = {
15
19
  auto_mode?: ArmorAutoMode$Outbound | undefined;
16
20
  v: number;
@@ -19,4 +23,5 @@ export type ArmorContext$Outbound = {
19
23
  /** @internal */
20
24
  export declare const ArmorContext$outboundSchema: z.ZodType<ArmorContext$Outbound, ArmorContext>;
21
25
  export declare function armorContextToJSON(armorContext: ArmorContext): string;
26
+ export declare function armorContextFromJSON(jsonString: string): SafeParseResult<ArmorContext, SDKValidationError>;
22
27
  //# sourceMappingURL=armorcontext.d.ts.map
@@ -4,7 +4,17 @@
4
4
  */
5
5
  import * as z from "zod/v4";
6
6
  import { remap as remap$ } from "../lib/primitives.js";
7
- import { ArmorAutoMode$outboundSchema, } from "./armorautomode.js";
7
+ import { collectExtraKeys as collectExtraKeys$, safeParse, } from "../lib/schemas.js";
8
+ import { ArmorAutoMode$inboundSchema, ArmorAutoMode$outboundSchema, } from "./armorautomode.js";
9
+ /** @internal */
10
+ export const ArmorContext$inboundSchema = collectExtraKeys$(z.object({
11
+ auto_mode: ArmorAutoMode$inboundSchema.optional(),
12
+ v: z.number(),
13
+ }).catchall(z.any()), "additionalProperties", true).transform((v) => {
14
+ return remap$(v, {
15
+ "auto_mode": "autoMode",
16
+ });
17
+ });
8
18
  /** @internal */
9
19
  export const ArmorContext$outboundSchema = z.object({
10
20
  autoMode: ArmorAutoMode$outboundSchema.optional(),
@@ -22,4 +32,7 @@ export const ArmorContext$outboundSchema = z.object({
22
32
  export function armorContextToJSON(armorContext) {
23
33
  return JSON.stringify(ArmorContext$outboundSchema.parse(armorContext));
24
34
  }
35
+ export function armorContextFromJSON(jsonString) {
36
+ return safeParse(jsonString, (x) => ArmorContext$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ArmorContext' from JSON`);
37
+ }
25
38
  //# sourceMappingURL=armorcontext.js.map
@@ -1,9 +1,13 @@
1
1
  import * as z from "zod/v4";
2
+ import { Result as SafeParseResult } from "../types/fp.js";
3
+ import { SDKValidationError } from "./errors/sdkvalidationerror.js";
2
4
  export type ArmorEnvironmentEntry = {
3
5
  name: string;
4
6
  value: string;
5
7
  };
6
8
  /** @internal */
9
+ export declare const ArmorEnvironmentEntry$inboundSchema: z.ZodType<ArmorEnvironmentEntry, unknown>;
10
+ /** @internal */
7
11
  export type ArmorEnvironmentEntry$Outbound = {
8
12
  name: string;
9
13
  value: string;
@@ -11,4 +15,5 @@ export type ArmorEnvironmentEntry$Outbound = {
11
15
  /** @internal */
12
16
  export declare const ArmorEnvironmentEntry$outboundSchema: z.ZodType<ArmorEnvironmentEntry$Outbound, ArmorEnvironmentEntry>;
13
17
  export declare function armorEnvironmentEntryToJSON(armorEnvironmentEntry: ArmorEnvironmentEntry): string;
18
+ export declare function armorEnvironmentEntryFromJSON(jsonString: string): SafeParseResult<ArmorEnvironmentEntry, SDKValidationError>;
14
19
  //# sourceMappingURL=armorenvironmententry.d.ts.map
@@ -3,6 +3,12 @@
3
3
  * @generated-id: e4e542230452
4
4
  */
5
5
  import * as z from "zod/v4";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ /** @internal */
8
+ export const ArmorEnvironmentEntry$inboundSchema = z.object({
9
+ name: z.string(),
10
+ value: z.string(),
11
+ });
6
12
  /** @internal */
7
13
  export const ArmorEnvironmentEntry$outboundSchema = z.object({
8
14
  name: z.string(),
@@ -11,4 +17,7 @@ export const ArmorEnvironmentEntry$outboundSchema = z.object({
11
17
  export function armorEnvironmentEntryToJSON(armorEnvironmentEntry) {
12
18
  return JSON.stringify(ArmorEnvironmentEntry$outboundSchema.parse(armorEnvironmentEntry));
13
19
  }
20
+ export function armorEnvironmentEntryFromJSON(jsonString) {
21
+ return safeParse(jsonString, (x) => ArmorEnvironmentEntry$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ArmorEnvironmentEntry' from JSON`);
22
+ }
14
23
  //# sourceMappingURL=armorenvironmententry.js.map