@desplega.ai/agent-swarm 1.152.2 → 1.154.0

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 (284) hide show
  1. package/README.md +2 -2
  2. package/dist/{acp-adapter-pfeje2v5.js → acp-adapter-eb2aj8xy.js} +4 -4
  3. package/dist/{actions-0sttc7f5.js → actions-kpnwp1kz.js} +31 -27
  4. package/dist/{anthropic-messages-2y8nktar.js → anthropic-messages-9vqsbznt.js} +112 -84
  5. package/dist/{app-p8teva95.js → app-zk1apkf6.js} +10 -7
  6. package/dist/{assistant-r45jnsrt.js → assistant-kwq4y50q.js} +32 -28
  7. package/dist/{azure-openai-responses-f38x2avq.js → azure-openai-responses-04qwdwfq.js} +27 -13
  8. package/dist/{boot-reembed-je26h5y7.js → boot-reembed-22hd3jjn.js} +9 -7
  9. package/dist/{boot-reembed-1qmybsd4.js → boot-reembed-qe168424.js} +10 -8
  10. package/dist/{boot-scrub-logs-gte3h1mm.js → boot-scrub-logs-pkdpsrjd.js} +7 -5
  11. package/dist/{claude-adapter-csc1mzka.js → claude-adapter-3fx90nww.js} +18 -16
  12. package/dist/{claude-managed-adapter-dsmkcrjy.js → claude-managed-adapter-ea2aga6w.js} +3 -3
  13. package/dist/{claude-sdk-session-fcd6f078.js → claude-sdk-session-z7fahf1k.js} +18 -16
  14. package/dist/{cli-r2fpe7cx.js → cli-00w2c66p.js} +61 -55
  15. package/dist/{cli-wbyk465z.js → cli-09y3tjxz.js} +1 -1
  16. package/dist/{cli-ht5rs63n.js → cli-0e31nm4n.js} +16 -7
  17. package/dist/cli-0x5qzvkg.js +4279 -0
  18. package/dist/{cli-d3p82erb.js → cli-18amys3y.js} +9 -9
  19. package/dist/{cli-4ahpr4sw.js → cli-1jpjafw4.js} +5 -5
  20. package/dist/{cli-jbmc0r7r.js → cli-243tzws8.js} +1 -1
  21. package/dist/{cli-ch38q5z4.js → cli-24k806sc.js} +6789 -2542
  22. package/dist/cli-3bkz2p7j.js +2828 -0
  23. package/dist/cli-3er6gcsn.js +1849 -0
  24. package/dist/cli-4k7jazkq.js +3339 -0
  25. package/dist/{cli-c4eeb5q2.js → cli-5b6b62tz.js} +1 -1
  26. package/dist/{cli-qd65dvr6.js → cli-5vs0nh43.js} +65 -44
  27. package/dist/{cli-z3wkng35.js → cli-6r3cgpk2.js} +224 -156
  28. package/dist/{cli-pgj4a5fb.js → cli-71cj99hx.js} +4 -3
  29. package/dist/cli-8sea27q4.js +14075 -0
  30. package/dist/{cli-jvy9qgjs.js → cli-913yakhv.js} +22 -7
  31. package/dist/{cli-pf9q3696.js → cli-927erqqt.js} +5 -2
  32. package/dist/cli-95jnpnqg.js +230 -0
  33. package/dist/{cli-wpv5rgg2.js → cli-abp3g4ax.js} +15 -2
  34. package/dist/{cli-ckz5t2hb.js → cli-acy6bfhr.js} +10 -7
  35. package/dist/{cli-4yc5d8fk.js → cli-avkd6mqv.js} +50 -0
  36. package/dist/{cli-8wrympd7.js → cli-bzr0ftht.js} +26 -7
  37. package/dist/{cli-qn042eh7.js → cli-c1v10xb2.js} +194 -1913
  38. package/dist/cli-cgj4hc12.js +18902 -0
  39. package/dist/{cli-2nnd56zt.js → cli-e0pg4zeh.js} +3 -2
  40. package/dist/{cli-r84ctdxn.js → cli-e31ehqwy.js} +2 -2
  41. package/dist/{cli-gphgnvpf.js → cli-e3229na9.js} +3 -3
  42. package/dist/{cli-gpqcs935.js → cli-e3cyf59d.js} +2 -2
  43. package/dist/{cli-s25avqg9.js → cli-e781c6f9.js} +1 -0
  44. package/dist/{cli-s2qjdd6z.js → cli-eetrvv91.js} +1 -1
  45. package/dist/{cli-j4nv2wqy.js → cli-fdzg6jhf.js} +10 -4
  46. package/dist/{cli-fm4ytsdk.js → cli-g2h29qar.js} +2 -2
  47. package/dist/{cli-zvgj5zg8.js → cli-ge67p080.js} +302 -3497
  48. package/dist/cli-h38x0qhg.js +6912 -0
  49. package/dist/{cli-9xvdm3bx.js → cli-h60qfasa.js} +742 -278
  50. package/dist/{cli-jew3jda5.js → cli-hws0vn86.js} +2 -2
  51. package/dist/{cli-j8dggbcr.js → cli-k0g1sjzm.js} +23 -31
  52. package/dist/{cli-xw7vak96.js → cli-kp3qs53m.js} +5 -5
  53. package/dist/{cli-rgvp6r2x.js → cli-mcnhgnn1.js} +193 -4
  54. package/dist/{cli-zvkq5csn.js → cli-myaxtgh8.js} +7 -6
  55. package/dist/{cli-56h18ng2.js → cli-n62atwh9.js} +1 -1
  56. package/dist/cli-n7h1kqpf.js +29 -0
  57. package/dist/{cli-fmy65jdn.js → cli-pf1v8xhb.js} +7 -5
  58. package/dist/{cli-xy1cchaf.js → cli-q85qhckh.js} +238 -11
  59. package/dist/{cli-3bpzj8me.js → cli-r1d3dzt6.js} +2 -2
  60. package/dist/{pi-mono-adapter-jcqt71cg.js → cli-rxkqvngf.js} +67343 -101083
  61. package/dist/{cli-kj76p1ez.js → cli-scwq51gn.js} +13 -7
  62. package/dist/{cli-b9dd0h3k.js → cli-stwsmd6k.js} +3 -2
  63. package/dist/{cli-c2mk1kgf.js → cli-v4en75c5.js} +8 -1
  64. package/dist/{cli-z61ykvam.js → cli-wg04s9kr.js} +4 -3
  65. package/dist/cli-yn0a417a.js +4069 -0
  66. package/dist/{cli-zfzznn7c.js → cli-ytxs7mn1.js} +26 -2
  67. package/dist/{cli-4j8k1m4w.js → cli-zt1227k1.js} +1162 -192
  68. package/dist/cli.js +28 -35
  69. package/dist/{codex-adapter-fxmpsabw.js → codex-adapter-ttdm995v.js} +12 -11
  70. package/dist/{codex-hook-8jexc34x.js → codex-hook-8gx7bcz0.js} +3 -3
  71. package/dist/{codex-session-runner-rr1e47ea.js → codex-session-runner-3v8nh4c8.js} +12 -11
  72. package/dist/{commands-0f5rxz51.js → commands-1cxwbhhq.js} +7 -5
  73. package/dist/{db-r3jxf3wy.js → db-y9zwsr79.js} +25 -5
  74. package/dist/{dispatcher-06vph6q4.js → dispatcher-9m9zss36.js} +30 -26
  75. package/dist/dsh-adapter-gsb2qqf9.js +19 -0
  76. package/dist/{e2b-413b8t4v.js → e2b-93x1k0j5.js} +6 -7
  77. package/dist/{google-generative-ai-ndjmj5fa.js → google-generative-ai-gwwrnzqn.js} +33 -73
  78. package/dist/{google-vertex-fr665tqs.js → google-vertex-5wfawpwz.js} +38 -68
  79. package/dist/{handlers-0hgtc910.js → handlers-36fm1bwn.js} +33 -29
  80. package/dist/{hook-9kvrv1er.js → hook-pntw4r8h.js} +12 -10
  81. package/dist/{hook-fbfhkat3.js → hook-vwq8y26p.js} +13 -11
  82. package/dist/{http-xbyx8k5j.js → http-20jesakk.js} +357 -261
  83. package/dist/{index-jsw3aynb.js → index-6artrehg.js} +30 -26
  84. package/dist/{cli-pdz9qde4.js → index-9ch1n761.js} +10 -11
  85. package/dist/{index-rnyahfn5.js → index-9n5z2492.js} +30 -26
  86. package/dist/{index-66xz5e9j.js → index-h5gs261z.js} +521 -9
  87. package/dist/{index-tfsdxyv6.js → index-j5wrf1yw.js} +40 -25
  88. package/dist/{index-2sp0384z.js → index-kkeftv5h.js} +738 -21
  89. package/dist/{index-sgk50mbg.js → index-m2xqpz5r.js} +31 -27
  90. package/dist/{index-gpfn1741.js → index-m9ks8a7t.js} +9 -7
  91. package/dist/index-w097eg0x.js +5 -0
  92. package/dist/jiti-loader-b4837mtm.js +34 -0
  93. package/dist/jiti-static-loader-q2g5ds0y.js +31267 -0
  94. package/dist/{keepalive-s3xpr7sw.js → keepalive-pwxvxd2c.js} +9 -7
  95. package/dist/{lead-rq4n5r16.js → lead-m789wqa3.js} +46 -41
  96. package/dist/{maintenance-f0atj1ab.js → maintenance-bvg6w7e2.js} +10 -8
  97. package/dist/{mistral-conversations-qhr84ph3.js → mistral-conversations-zx0kn554.js} +24 -18
  98. package/dist/{node-x1g4v0pq.js → node-5qtycf6a.js} +16 -11
  99. package/dist/{oauth-refresh-sweep-q0t3bxre.js → oauth-refresh-sweep-6v4bd737.js} +8 -6
  100. package/dist/{onboard-br5j1kch.js → onboard-snckpcj1.js} +115 -35
  101. package/dist/{openai-codex-responses-wy6a43wd.js → openai-codex-responses-4vjqzvjp.js} +33 -27
  102. package/dist/{openai-completions-32rdwmze.js → openai-completions-pxsmym7g.js} +52 -64
  103. package/dist/{openai-responses-6xwf7bzg.js → openai-responses-tmn0rqp0.js} +23 -24
  104. package/dist/{opencode-adapter-28axqa09.js → opencode-adapter-qbmv4tpy.js} +6 -6
  105. package/dist/{otel-impl-vdqge2nt.js → otel-impl-e0ytens5.js} +4 -4
  106. package/dist/{pi-messages-b1mbr6gp.js → pi-messages-txpjj39q.js} +3 -3
  107. package/dist/pi-mono-adapter-c4ggemhz.js +1316 -0
  108. package/dist/{pricing-refresh-hb3691fd.js → pricing-refresh-52g2ywrw.js} +9 -7
  109. package/dist/{rbac-roles-t78xt39b.js → rbac-roles-5455kfdn.js} +8 -6
  110. package/dist/{rbac-roles-jh280k9g.js → rbac-roles-hbf0xa52.js} +9 -7
  111. package/dist/{render-v2-7p8r2ymg.js → render-v2-npm8xdzh.js} +16 -9
  112. package/dist/{seed-pricing-hf889enh.js → seed-pricing-650wbr1n.js} +8 -6
  113. package/dist/{setup-w6mb03jv.js → setup-k1mew5rf.js} +4 -5
  114. package/dist/virtual-modules-2q5b2pk4.js +54 -0
  115. package/dist/{work-objects-nt8gy1kj.js → work-objects-2ea3kvwg.js} +33 -29
  116. package/dist/{worker-dwy617t0.js → worker-ec6hvc4m.js} +46 -41
  117. package/openapi.json +109 -16
  118. package/package.json +7 -6
  119. package/plugin/opencode-plugins/lib/memory-raters.ts +7 -0
  120. package/src/be/automation-preflight.ts +6 -4
  121. package/src/be/db/agents.ts +75 -2
  122. package/src/be/db/tasks/read.ts +2 -0
  123. package/src/be/db/tasks/write.ts +7 -1
  124. package/src/be/db.ts +140 -18
  125. package/src/be/extensions/db.ts +35 -4
  126. package/src/be/memory/raters/llm.ts +2 -6
  127. package/src/be/memory/raters/noop.ts +2 -3
  128. package/src/be/memory/raters/registry.ts +4 -10
  129. package/src/be/migrations/157_defer_provenance_and_marker.sql +27 -0
  130. package/src/be/models-catalog.ts +2 -0
  131. package/src/be/modelsdev-cache.json +213 -0
  132. package/src/be/rbac-audit.ts +2 -0
  133. package/src/be/seed/agent-fs-provision.ts +23 -0
  134. package/src/be/seed-pricing.ts +3 -1
  135. package/src/be/swarm-config-guard.ts +1 -0
  136. package/src/commands/onboard/compose-generator.ts +16 -1
  137. package/src/commands/onboard/env-generator.ts +14 -1
  138. package/src/commands/onboard/manifest.ts +1 -0
  139. package/src/commands/onboard/steps/integration-slack.tsx +56 -16
  140. package/src/commands/onboard/steps/review.tsx +5 -0
  141. package/src/commands/onboard/types.ts +6 -0
  142. package/src/commands/onboard.tsx +5 -1
  143. package/src/commands/provider-credentials.ts +14 -2
  144. package/src/commands/runner.ts +18 -2
  145. package/src/extensions/identity.ts +15 -7
  146. package/src/extensions/lifecycle.ts +15 -21
  147. package/src/hooks/codex-hook.ts +7 -1
  148. package/src/http/agents.ts +12 -4
  149. package/src/http/config.ts +1 -1
  150. package/src/http/core.ts +5 -3
  151. package/src/http/extensions.ts +108 -34
  152. package/src/http/poll.ts +7 -0
  153. package/src/http/schedules.ts +10 -0
  154. package/src/http/script-runs.ts +35 -26
  155. package/src/http/status.ts +24 -11
  156. package/src/http/tasks.ts +6 -1
  157. package/src/prompts/base-prompt.ts +15 -7
  158. package/src/prompts/memories.ts +5 -7
  159. package/src/prompts/session-templates.ts +3 -2
  160. package/src/prompts/steering-delivery.ts +2 -0
  161. package/src/providers/claude-managed-models.ts +8 -0
  162. package/src/providers/codex-adapter.ts +3 -6
  163. package/src/providers/codex-models.ts +15 -1
  164. package/src/providers/dsh-adapter.ts +248 -0
  165. package/src/providers/index.ts +5 -1
  166. package/src/providers/modelsdev-reasoning.json +50 -0
  167. package/src/providers/pi-mono-extension.ts +2 -5
  168. package/src/rbac/legacy-policy.ts +15 -1
  169. package/src/rbac/types.ts +2 -0
  170. package/src/server.ts +7 -1
  171. package/src/slack/ack.ts +43 -8
  172. package/src/slack/app.ts +32 -10
  173. package/src/slack/config.ts +29 -0
  174. package/src/slack/handlers.ts +7 -1
  175. package/src/slack/render-v2.ts +186 -17
  176. package/src/slack/responses.ts +1 -3
  177. package/src/slack/task-output.ts +66 -8
  178. package/src/slack/thread-buffer.ts +27 -3
  179. package/src/telemetry.ts +2 -3
  180. package/src/tests/agent-fs-provision-seeder.test.ts +56 -2
  181. package/src/tests/agents-harness-provider.test.ts +19 -0
  182. package/src/tests/agents-list-model-display.test.ts +60 -1
  183. package/src/tests/base-prompt.test.ts +25 -0
  184. package/src/tests/claude-managed-adapter.test.ts +6 -0
  185. package/src/tests/codex-gpt6-release.test.ts +97 -0
  186. package/src/tests/codex-steering-hook.test.ts +2 -2
  187. package/src/tests/config-api-only-keys.test.ts +9 -0
  188. package/src/tests/context-window.test.ts +1 -0
  189. package/src/tests/db-task-read-contract.test.ts +9 -0
  190. package/src/tests/db-task-write-contract.test.ts +9 -0
  191. package/src/tests/defer-task.test.ts +115 -16
  192. package/src/tests/dsh-adapter.test.ts +276 -0
  193. package/src/tests/e2e-nightly-report.test.ts +3 -3
  194. package/src/tests/e2e-redact.test.ts +2 -0
  195. package/src/tests/env-flag.test.ts +6 -0
  196. package/src/tests/extension-agent-visibility.test.ts +474 -0
  197. package/src/tests/extensions-db.test.ts +41 -0
  198. package/src/tests/extensions-http.test.ts +148 -4
  199. package/src/tests/extensions-lifecycle.test.ts +21 -1
  200. package/src/tests/extensions-mcp-tools.test.ts +9 -5
  201. package/src/tests/fetch-resolved-env.test.ts +43 -0
  202. package/src/tests/internal-ai/complete-structured.test.ts +32 -9
  203. package/src/tests/internal-ai/credentials.test.ts +4 -4
  204. package/src/tests/internal-ai/models.test.ts +20 -0
  205. package/src/tests/memory-rate-tool.test.ts +7 -10
  206. package/src/tests/memory-rater-defaults.test.ts +23 -0
  207. package/src/tests/memory-rater-e2e.test.ts +2 -3
  208. package/src/tests/migration-046-budgets.test.ts +2 -0
  209. package/src/tests/model-control.test.ts +2 -2
  210. package/src/tests/onboard-compose.test.ts +14 -0
  211. package/src/tests/onboard-env.test.ts +17 -0
  212. package/src/tests/onboard-manifest.test.ts +12 -0
  213. package/src/tests/opus-5-5-registry.test.ts +48 -0
  214. package/src/tests/pricing-refresh.test.ts +1 -1
  215. package/src/tests/pricing-routes.test.ts +15 -3
  216. package/src/tests/provider-registration.test.ts +5 -2
  217. package/src/tests/rbac-admission-e2e.test.ts +54 -0
  218. package/src/tests/rbac-e2e-helpers.ts +2 -0
  219. package/src/tests/rbac-engine.test.ts +32 -0
  220. package/src/tests/rbac-wire-e2e.test.ts +33 -0
  221. package/src/tests/reasoning-effort.test.ts +8 -0
  222. package/src/tests/reload-config.test.ts +33 -0
  223. package/src/tests/script-connections.test.ts +3 -0
  224. package/src/tests/session-costs-model-key-normalize.test.ts +1 -0
  225. package/src/tests/slack-config.test.ts +136 -0
  226. package/src/tests/slack-mode-lifecycle.test.ts +69 -0
  227. package/src/tests/slack-render-v2.test.ts +446 -16
  228. package/src/tests/slack-steering.test.ts +69 -1
  229. package/src/tests/slack-task-output.test.ts +33 -12
  230. package/src/tests/status.test.ts +22 -2
  231. package/src/tests/steering-core.test.ts +35 -0
  232. package/src/tests/steering-delivery.test.ts +39 -0
  233. package/src/tests/steering-transport.test.ts +2 -2
  234. package/src/tests/task-tool-preload-mcp.test.ts +3 -1
  235. package/src/tests/telemetry-init.test.ts +18 -0
  236. package/src/tests/workflow-live-recovery.test.ts +126 -0
  237. package/src/tests/workflow-llm.test.ts +3 -3
  238. package/src/tools/defer-task.ts +64 -26
  239. package/src/tools/extension-common.ts +4 -0
  240. package/src/tools/extension-install.ts +1 -1
  241. package/src/tools/extension-list.ts +4 -3
  242. package/src/tools/join-swarm.ts +1 -1
  243. package/src/tools/schedules/create-schedule.ts +11 -1
  244. package/src/tools/schedules/patch-schedule.ts +5 -0
  245. package/src/tools/schedules/update-schedule.ts +5 -0
  246. package/src/tools/send-task.ts +6 -0
  247. package/src/tools/utils.ts +1 -1
  248. package/src/types.ts +30 -8
  249. package/src/utils/context-window.ts +1 -0
  250. package/src/utils/credentials.ts +8 -0
  251. package/src/utils/internal-ai/complete-structured.ts +8 -0
  252. package/src/utils/internal-ai/models.ts +5 -5
  253. package/src/utils/memory-raters.ts +3 -0
  254. package/src/workflows/engine.ts +28 -0
  255. package/src/workflows/recovery.ts +7 -4
  256. package/templates/schedules/daily-status-report/content.md +25 -12
  257. package/templates/schedules/daily-workflow-health-audit/content.md +1 -1
  258. package/templates/skills/swarm-extensions/content.md +9 -5
  259. package/dist/cli-4wppfkcm.js +0 -16384
  260. package/dist/cli-55qrx3q8.js +0 -6041
  261. package/dist/cli-cg4vnyh4.js +0 -305
  262. package/dist/cli-jyetr64j.js +0 -52
  263. package/dist/cli-pp9ax9pa.js +0 -520
  264. package/dist/cli-qa66qaf0.js +0 -6076
  265. package/dist/cli-qghpvca2.js +0 -590
  266. package/dist/cli-rembwgt8.js +0 -861
  267. package/dist/cli-tcvj7j2r.js +0 -1971
  268. package/dist/cli-vfcth11k.js +0 -36
  269. package/dist/cli-w1d1bgkk.js +0 -1422
  270. package/dist/cli-y6x0gqtg.js +0 -5977
  271. package/dist/es5-tj3tn4jj.js +0 -844
  272. package/dist/index-1kq5hw2p.js +0 -467
  273. package/dist/index-1p8wdstt.js +0 -7
  274. package/dist/index-8fdjzb2f.js +0 -100
  275. package/dist/index-bxmwzbgw.js +0 -365
  276. package/dist/index-nzerxd5z.js +0 -7
  277. package/dist/index-pyymnzat.js +0 -1168
  278. package/dist/index-qv6atbab.js +0 -619
  279. package/dist/index-rja32qa7.js +0 -801
  280. package/dist/index-tzg5srfp.js +0 -211
  281. package/dist/index-vhncw983.js +0 -90
  282. package/dist/index-xk036zsk.js +0 -859
  283. package/dist/index-zyazbzcb.js +0 -6
  284. package/dist/{claude-managed-setup-48dwg9bv.js → claude-managed-setup-f5pmsyrp.js} +3 -3
@@ -1,1971 +0,0 @@
1
- import {
2
- require_client,
3
- require_config,
4
- require_dist_cjs,
5
- require_endpoints,
6
- require_protocols,
7
- require_serde
8
- } from "./cli-qa66qaf0.js";
9
- import {
10
- __commonJS,
11
- __require,
12
- __toESM
13
- } from "./cli-bc05qbss.js";
14
-
15
- // node_modules/@smithy/core/dist-cjs/submodules/retry/index.js
16
- var require_retry = __commonJS(function(exports) {
17
- var node_stream = __require("node:stream");
18
- var client = require_client();
19
- var protocols = require_protocols();
20
- var serde = require_serde();
21
- var isStreamingPayload = (request) => request?.body instanceof node_stream.Readable || typeof ReadableStream !== "undefined" && request?.body instanceof ReadableStream;
22
- var CLOCK_SKEW_ERROR_CODES = [
23
- "AuthFailure",
24
- "InvalidSignatureException",
25
- "RequestExpired",
26
- "RequestInTheFuture",
27
- "RequestTimeTooSkewed",
28
- "SignatureDoesNotMatch"
29
- ];
30
- var THROTTLING_ERROR_CODES = [
31
- "BandwidthLimitExceeded",
32
- "EC2ThrottledException",
33
- "LimitExceededException",
34
- "PriorRequestNotComplete",
35
- "ProvisionedThroughputExceededException",
36
- "RequestLimitExceeded",
37
- "RequestThrottled",
38
- "RequestThrottledException",
39
- "SlowDown",
40
- "ThrottledException",
41
- "Throttling",
42
- "ThrottlingException",
43
- "TooManyRequestsException",
44
- "TransactionInProgressException"
45
- ];
46
- var TRANSIENT_ERROR_CODES = ["TimeoutError", "RequestTimeout", "RequestTimeoutException"];
47
- var TRANSIENT_ERROR_STATUS_CODES = [500, 502, 503, 504];
48
- var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "ECONNREFUSED", "EPIPE", "ETIMEDOUT"];
49
- var NODEJS_NETWORK_ERROR_CODES = ["EHOSTUNREACH", "ENETUNREACH", "ENOTFOUND"];
50
- var isRetryableByTrait = (error) => error?.$retryable !== undefined;
51
- var isClockSkewError = (error) => CLOCK_SKEW_ERROR_CODES.includes(error.name);
52
- var isClockSkewCorrectedError = (error) => error.$metadata?.clockSkewCorrected;
53
- var isBrowserNetworkError = (error) => {
54
- const errorMessages = new Set([
55
- "Failed to fetch",
56
- "NetworkError when attempting to fetch resource",
57
- "The Internet connection appears to be offline",
58
- "Load failed",
59
- "Network request failed"
60
- ]);
61
- const isValid = error && error instanceof TypeError;
62
- if (!isValid) {
63
- return false;
64
- }
65
- return errorMessages.has(error.message);
66
- };
67
- var isThrottlingError = (error) => error.$metadata?.httpStatusCode === 429 || THROTTLING_ERROR_CODES.includes(error.name) || error.$retryable?.throttling == true;
68
- var isTransientError = (error, depth = 0) => isRetryableByTrait(error) || isClockSkewCorrectedError(error) || error.name === "InvalidSignatureException" && error.message?.includes("Signature expired") || TRANSIENT_ERROR_CODES.includes(error.name) || NODEJS_TIMEOUT_ERROR_CODES.includes(error?.code || "") || NODEJS_NETWORK_ERROR_CODES.includes(error?.code || "") || TRANSIENT_ERROR_STATUS_CODES.includes(error.$metadata?.httpStatusCode || 0) || isBrowserNetworkError(error) || isNodeJsHttp2TransientError(error) || error.cause !== undefined && depth <= 10 && isTransientError(error.cause, depth + 1);
69
- var isServerError = (error) => {
70
- if (error.$metadata?.httpStatusCode !== undefined) {
71
- const statusCode = error.$metadata.httpStatusCode;
72
- if (500 <= statusCode && statusCode <= 599 && !isTransientError(error)) {
73
- return true;
74
- }
75
- return false;
76
- }
77
- return false;
78
- };
79
- function isNodeJsHttp2TransientError(error) {
80
- return error.code === "ERR_HTTP2_STREAM_ERROR" && error.message.includes("NGHTTP2_REFUSED_STREAM");
81
- }
82
- var DEFAULT_RETRY_DELAY_BASE = 100;
83
- var MAXIMUM_RETRY_DELAY = 20 * 1000;
84
- var THROTTLING_RETRY_DELAY_BASE = 500;
85
- var INITIAL_RETRY_TOKENS = 500;
86
- var RETRY_COST = 5;
87
- var TIMEOUT_RETRY_COST = 10;
88
- var NO_RETRY_INCREMENT = 1;
89
- var INVOCATION_ID_HEADER = "amz-sdk-invocation-id";
90
- var REQUEST_HEADER = "amz-sdk-request";
91
- function parseRetryAfterHeader(response, logger) {
92
- if (!protocols.HttpResponse.isInstance(response)) {
93
- return;
94
- }
95
- for (const header of Object.keys(response.headers)) {
96
- const h = header.toLowerCase();
97
- if (h === "retry-after") {
98
- const retryAfter = response.headers[header];
99
- let retryAfterSeconds = NaN;
100
- if (retryAfter.endsWith("GMT")) {
101
- try {
102
- const date = serde.parseRfc7231DateTime(retryAfter);
103
- retryAfterSeconds = (date.getTime() - Date.now()) / 1000;
104
- } catch (e) {
105
- logger?.trace?.("Failed to parse retry-after header");
106
- logger?.trace?.(e);
107
- }
108
- } else if (retryAfter.match(/ GMT, ((\d+)|(\d+\.\d+))$/)) {
109
- retryAfterSeconds = Number(retryAfter.match(/ GMT, ([\d.]+)$/)?.[1]);
110
- } else if (retryAfter.match(/^((\d+)|(\d+\.\d+))$/)) {
111
- retryAfterSeconds = Number(retryAfter);
112
- } else if (Date.parse(retryAfter) >= Date.now()) {
113
- retryAfterSeconds = (Date.parse(retryAfter) - Date.now()) / 1000;
114
- }
115
- if (isNaN(retryAfterSeconds)) {
116
- return;
117
- }
118
- return new Date(Date.now() + retryAfterSeconds * 1000);
119
- } else if (h === "x-amz-retry-after") {
120
- const v = response.headers[header];
121
- const backoffMilliseconds = Number(v);
122
- if (isNaN(backoffMilliseconds)) {
123
- logger?.trace?.(`Failed to parse x-amz-retry-after=${v}`);
124
- return;
125
- }
126
- return new Date(Date.now() + backoffMilliseconds);
127
- }
128
- }
129
- }
130
- function getRetryAfterHint(response, logger) {
131
- return parseRetryAfterHeader(response, logger);
132
- }
133
- var asSdkError = (error) => {
134
- if (error instanceof Error)
135
- return error;
136
- if (error instanceof Object)
137
- return Object.assign(new Error, error);
138
- if (typeof error === "string")
139
- return new Error(error);
140
- return new Error(`AWS SDK error wrapper for ${error}`);
141
- };
142
- function bindRetryMiddleware(isStreamingPayload2) {
143
- return (options) => (next, context) => async (args) => {
144
- let retryStrategy = await options.retryStrategy();
145
- const maxAttempts = await options.maxAttempts();
146
- if (isRetryStrategyV2(retryStrategy)) {
147
- retryStrategy = retryStrategy;
148
- let retryToken = await retryStrategy.acquireInitialRetryToken((context["partition_id"] ?? "") + (context.__retryLongPoll ? ":longpoll" : ""));
149
- let lastError = new Error;
150
- let attempts = 0;
151
- let totalRetryDelay = 0;
152
- const { request } = args;
153
- const isRequest = protocols.HttpRequest.isInstance(request);
154
- if (isRequest) {
155
- request.headers[INVOCATION_ID_HEADER] = serde.v4();
156
- }
157
- while (true) {
158
- try {
159
- if (isRequest) {
160
- request.headers[REQUEST_HEADER] = `attempt=${attempts + 1}; max=${maxAttempts}`;
161
- }
162
- const { response, output } = await next(args);
163
- retryStrategy.recordSuccess(retryToken);
164
- output.$metadata.attempts = attempts + 1;
165
- output.$metadata.totalRetryDelay = totalRetryDelay;
166
- return { response, output };
167
- } catch (e) {
168
- const retryErrorInfo = getRetryErrorInfo(e, options.logger);
169
- lastError = asSdkError(e);
170
- if (isRequest && isStreamingPayload2(request)) {
171
- (context.logger instanceof client.NoOpLogger ? console : context.logger)?.warn("An error was encountered in a non-retryable streaming request.");
172
- throw lastError;
173
- }
174
- try {
175
- retryToken = await retryStrategy.refreshRetryTokenForRetry(retryToken, retryErrorInfo);
176
- } catch (refreshError) {
177
- if (typeof refreshError.$backoff === "number") {
178
- await cooldown(refreshError.$backoff);
179
- }
180
- if (!lastError.$metadata) {
181
- lastError.$metadata = {};
182
- }
183
- lastError.$metadata.attempts = attempts + 1;
184
- lastError.$metadata.totalRetryDelay = totalRetryDelay;
185
- throw lastError;
186
- }
187
- attempts = retryToken.getRetryCount();
188
- const delay = retryToken.getRetryDelay();
189
- totalRetryDelay += delay;
190
- await cooldown(delay);
191
- }
192
- }
193
- } else {
194
- retryStrategy = retryStrategy;
195
- if (retryStrategy?.mode) {
196
- context.userAgent = [...context.userAgent || [], ["cfg/retry-mode", retryStrategy.mode]];
197
- }
198
- return retryStrategy.retry(next, args);
199
- }
200
- };
201
- }
202
- var cooldown = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
203
- var isRetryStrategyV2 = (retryStrategy) => typeof retryStrategy.acquireInitialRetryToken !== "undefined" && typeof retryStrategy.refreshRetryTokenForRetry !== "undefined" && typeof retryStrategy.recordSuccess !== "undefined";
204
- var getRetryErrorInfo = (error, logger) => {
205
- const errorInfo = {
206
- error,
207
- errorType: getRetryErrorType(error)
208
- };
209
- const retryAfterHint = parseRetryAfterHeader(error.$response, logger);
210
- if (retryAfterHint) {
211
- errorInfo.retryAfterHint = retryAfterHint;
212
- }
213
- return errorInfo;
214
- };
215
- var getRetryErrorType = (error) => {
216
- if (isThrottlingError(error))
217
- return "THROTTLING";
218
- if (isTransientError(error))
219
- return "TRANSIENT";
220
- if (isServerError(error))
221
- return "SERVER_ERROR";
222
- return "CLIENT_ERROR";
223
- };
224
- var retryMiddlewareOptions = {
225
- name: "retryMiddleware",
226
- tags: ["RETRY"],
227
- step: "finalizeRequest",
228
- priority: "high",
229
- override: true
230
- };
231
- function bindGetRetryPlugin(isStreamingPayload2) {
232
- const retryMiddleware2 = bindRetryMiddleware(isStreamingPayload2);
233
- return (options) => ({
234
- applyToStack: (clientStack) => {
235
- clientStack.add(retryMiddleware2(options), retryMiddlewareOptions);
236
- }
237
- });
238
- }
239
-
240
- class DefaultRateLimiter {
241
- static setTimeoutFn = setTimeout;
242
- beta;
243
- minCapacity;
244
- minFillRate;
245
- scaleConstant;
246
- smooth;
247
- enabled = false;
248
- availableTokens = 0;
249
- lastMaxRate = 0;
250
- measuredTxRate = 0;
251
- requestCount = 0;
252
- fillRate;
253
- lastThrottleTime;
254
- lastTimestamp = 0;
255
- lastTxRateBucket;
256
- maxCapacity;
257
- timeWindow = 0;
258
- constructor(options) {
259
- this.beta = options?.beta ?? 0.7;
260
- this.minCapacity = options?.minCapacity ?? 1;
261
- this.minFillRate = options?.minFillRate ?? 0.5;
262
- this.scaleConstant = options?.scaleConstant ?? 0.4;
263
- this.smooth = options?.smooth ?? 0.8;
264
- this.lastThrottleTime = this.getCurrentTimeInSeconds();
265
- this.lastTxRateBucket = Math.floor(this.getCurrentTimeInSeconds());
266
- this.fillRate = this.minFillRate;
267
- this.maxCapacity = this.minCapacity;
268
- }
269
- async getSendToken() {
270
- return this.acquireTokenBucket(1);
271
- }
272
- updateClientSendingRate(response) {
273
- let calculatedRate;
274
- this.updateMeasuredRate();
275
- const retryErrorInfo = response;
276
- const isThrottling = retryErrorInfo?.errorType === "THROTTLING" || isThrottlingError(retryErrorInfo?.error ?? response);
277
- if (isThrottling) {
278
- const rateToUse = !this.enabled ? this.measuredTxRate : Math.min(this.measuredTxRate, this.fillRate);
279
- this.lastMaxRate = rateToUse;
280
- this.calculateTimeWindow();
281
- this.lastThrottleTime = this.getCurrentTimeInSeconds();
282
- calculatedRate = this.cubicThrottle(rateToUse);
283
- this.enableTokenBucket();
284
- } else {
285
- this.calculateTimeWindow();
286
- calculatedRate = this.cubicSuccess(this.getCurrentTimeInSeconds());
287
- }
288
- const newRate = Math.min(calculatedRate, 2 * this.measuredTxRate);
289
- this.updateTokenBucketRate(newRate);
290
- }
291
- getCurrentTimeInSeconds() {
292
- return Date.now() / 1000;
293
- }
294
- async acquireTokenBucket(amount) {
295
- if (!this.enabled) {
296
- return;
297
- }
298
- this.refillTokenBucket();
299
- while (amount > this.availableTokens) {
300
- const delay = (amount - this.availableTokens) / this.fillRate * 1000;
301
- await new Promise((resolve) => DefaultRateLimiter.setTimeoutFn(resolve, delay));
302
- this.refillTokenBucket();
303
- }
304
- this.availableTokens = this.availableTokens - amount;
305
- }
306
- refillTokenBucket() {
307
- const timestamp = this.getCurrentTimeInSeconds();
308
- if (!this.lastTimestamp) {
309
- this.lastTimestamp = timestamp;
310
- return;
311
- }
312
- const fillAmount = (timestamp - this.lastTimestamp) * this.fillRate;
313
- this.availableTokens = Math.min(this.maxCapacity, this.availableTokens + fillAmount);
314
- this.lastTimestamp = timestamp;
315
- }
316
- calculateTimeWindow() {
317
- this.timeWindow = this.getPrecise(Math.pow(this.lastMaxRate * (1 - this.beta) / this.scaleConstant, 1 / 3));
318
- }
319
- cubicThrottle(rateToUse) {
320
- return this.getPrecise(rateToUse * this.beta);
321
- }
322
- cubicSuccess(timestamp) {
323
- return this.getPrecise(this.scaleConstant * Math.pow(timestamp - this.lastThrottleTime - this.timeWindow, 3) + this.lastMaxRate);
324
- }
325
- enableTokenBucket() {
326
- this.enabled = true;
327
- }
328
- updateTokenBucketRate(newRate) {
329
- this.refillTokenBucket();
330
- this.fillRate = Math.max(newRate, this.minFillRate);
331
- this.maxCapacity = Math.max(newRate, this.minCapacity);
332
- this.availableTokens = Math.min(this.availableTokens, this.maxCapacity);
333
- }
334
- updateMeasuredRate() {
335
- const t = this.getCurrentTimeInSeconds();
336
- const timeBucket = Math.floor(t * 2) / 2;
337
- this.requestCount++;
338
- if (timeBucket > this.lastTxRateBucket) {
339
- const currentRate = this.requestCount / (timeBucket - this.lastTxRateBucket);
340
- this.measuredTxRate = this.getPrecise(currentRate * this.smooth + this.measuredTxRate * (1 - this.smooth));
341
- this.requestCount = 0;
342
- this.lastTxRateBucket = timeBucket;
343
- }
344
- }
345
- getPrecise(num) {
346
- return parseFloat(num.toFixed(8));
347
- }
348
- }
349
-
350
- class Retry {
351
- static v2026 = typeof process !== "undefined" && process.env?.SMITHY_NEW_RETRIES_2026 === "true";
352
- static delay() {
353
- return Retry.v2026 ? 50 : 100;
354
- }
355
- static throttlingDelay() {
356
- return Retry.v2026 ? 1000 : 500;
357
- }
358
- static cost() {
359
- return Retry.v2026 ? 14 : 5;
360
- }
361
- static throttlingCost() {
362
- return Retry.v2026 ? 5 : 10;
363
- }
364
- static modifiedCostType() {
365
- return Retry.v2026 ? "THROTTLING" : "TRANSIENT";
366
- }
367
- }
368
-
369
- class DefaultRetryBackoffStrategy {
370
- x = Retry.delay();
371
- computeNextBackoffDelay(i) {
372
- const b = Math.random();
373
- const r = 2;
374
- const t_i = b * Math.min(this.x * r ** i, MAXIMUM_RETRY_DELAY);
375
- return Math.floor(t_i);
376
- }
377
- setDelayBase(delay) {
378
- this.x = delay;
379
- }
380
- }
381
-
382
- class DefaultRetryToken {
383
- delay;
384
- count;
385
- cost;
386
- longPoll;
387
- constructor(delay, count, cost, longPoll) {
388
- this.delay = delay;
389
- this.count = count;
390
- this.cost = cost;
391
- this.longPoll = longPoll;
392
- }
393
- getRetryCount() {
394
- return this.count;
395
- }
396
- getRetryDelay() {
397
- return Math.min(MAXIMUM_RETRY_DELAY, this.delay);
398
- }
399
- getRetryCost() {
400
- return this.cost;
401
- }
402
- isLongPoll() {
403
- return this.longPoll;
404
- }
405
- }
406
- exports.RETRY_MODES = undefined;
407
- (function(RETRY_MODES) {
408
- RETRY_MODES["STANDARD"] = "standard";
409
- RETRY_MODES["ADAPTIVE"] = "adaptive";
410
- })(exports.RETRY_MODES || (exports.RETRY_MODES = {}));
411
- var DEFAULT_MAX_ATTEMPTS = 3;
412
- var DEFAULT_RETRY_MODE = exports.RETRY_MODES.STANDARD;
413
- var refusal = {
414
- incompatible: 1,
415
- attempts: 2,
416
- capacity: 3
417
- };
418
- var StandardRetryStrategy$1 = class StandardRetryStrategy2 {
419
- mode = exports.RETRY_MODES.STANDARD;
420
- capacity = INITIAL_RETRY_TOKENS;
421
- retryBackoffStrategy;
422
- maxAttemptsProvider;
423
- baseDelay;
424
- constructor(arg1) {
425
- if (typeof arg1 === "number") {
426
- this.maxAttemptsProvider = async () => arg1;
427
- } else if (typeof arg1 === "function") {
428
- this.maxAttemptsProvider = arg1;
429
- } else if (arg1 && typeof arg1 === "object") {
430
- this.maxAttemptsProvider = async () => arg1.maxAttempts;
431
- this.baseDelay = arg1.baseDelay;
432
- this.retryBackoffStrategy = arg1.backoff;
433
- }
434
- this.maxAttemptsProvider ??= async () => DEFAULT_MAX_ATTEMPTS;
435
- this.baseDelay ??= Retry.delay();
436
- this.retryBackoffStrategy ??= new DefaultRetryBackoffStrategy;
437
- }
438
- async acquireInitialRetryToken(retryTokenScope) {
439
- return new DefaultRetryToken(Retry.delay(), 0, undefined, Retry.v2026 && retryTokenScope.includes(":longpoll"));
440
- }
441
- async refreshRetryTokenForRetry(token, errorInfo) {
442
- const maxAttempts = await this.getMaxAttempts();
443
- const retryCode = this.retryCode(token, errorInfo, maxAttempts);
444
- const shouldRetry = retryCode === 0;
445
- const isLongPoll = token.isLongPoll?.();
446
- if (shouldRetry || isLongPoll) {
447
- const errorType = errorInfo.errorType;
448
- this.retryBackoffStrategy.setDelayBase(errorType === "THROTTLING" ? Retry.throttlingDelay() : this.baseDelay);
449
- const delayFromErrorType = this.retryBackoffStrategy.computeNextBackoffDelay(token.getRetryCount());
450
- let retryDelay = delayFromErrorType;
451
- if (errorInfo.retryAfterHint instanceof Date) {
452
- retryDelay = Math.max(delayFromErrorType, Math.min(errorInfo.retryAfterHint.getTime() - Date.now(), delayFromErrorType + 5000));
453
- }
454
- if (!shouldRetry) {
455
- throw Object.assign(new Error("No retry token available"), {
456
- $backoff: Retry.v2026 && retryCode === refusal.capacity && isLongPoll ? retryDelay : 0
457
- });
458
- } else {
459
- const capacityCost = this.getCapacityCost(errorType);
460
- this.capacity -= capacityCost;
461
- return new DefaultRetryToken(retryDelay, token.getRetryCount() + 1, capacityCost, token.isLongPoll?.() ?? false);
462
- }
463
- }
464
- throw new Error("No retry token available");
465
- }
466
- recordSuccess(token) {
467
- this.capacity = Math.min(INITIAL_RETRY_TOKENS, this.capacity + (token.getRetryCost() ?? NO_RETRY_INCREMENT));
468
- }
469
- getCapacity() {
470
- return this.capacity;
471
- }
472
- async maxAttempts() {
473
- return this.maxAttemptsProvider();
474
- }
475
- async getMaxAttempts() {
476
- try {
477
- return await this.maxAttemptsProvider();
478
- } catch (error) {
479
- console.warn(`Max attempts provider could not resolve. Using default of ${DEFAULT_MAX_ATTEMPTS}`);
480
- return DEFAULT_MAX_ATTEMPTS;
481
- }
482
- }
483
- retryCode(tokenToRenew, errorInfo, maxAttempts) {
484
- const attempts = tokenToRenew.getRetryCount() + 1;
485
- const retryableStatus = this.isRetryableError(errorInfo.errorType) ? 0 : refusal.incompatible;
486
- const attemptStatus = attempts < maxAttempts ? 0 : refusal.attempts;
487
- const capacityStatus = this.capacity >= this.getCapacityCost(errorInfo.errorType) ? 0 : refusal.capacity;
488
- return retryableStatus || attemptStatus || capacityStatus;
489
- }
490
- getCapacityCost(errorType) {
491
- return errorType === Retry.modifiedCostType() ? Retry.throttlingCost() : Retry.cost();
492
- }
493
- isRetryableError(errorType) {
494
- return errorType === "THROTTLING" || errorType === "TRANSIENT";
495
- }
496
- };
497
- var AdaptiveRetryStrategy$1 = class AdaptiveRetryStrategy2 {
498
- mode = exports.RETRY_MODES.ADAPTIVE;
499
- rateLimiter;
500
- standardRetryStrategy;
501
- constructor(maxAttemptsProvider, options) {
502
- const { rateLimiter } = options ?? {};
503
- this.rateLimiter = rateLimiter ?? new DefaultRateLimiter;
504
- this.standardRetryStrategy = options ? new StandardRetryStrategy$1({
505
- maxAttempts: typeof maxAttemptsProvider === "number" ? maxAttemptsProvider : 3,
506
- ...options
507
- }) : new StandardRetryStrategy$1(maxAttemptsProvider);
508
- }
509
- async acquireInitialRetryToken(retryTokenScope) {
510
- const token = await this.standardRetryStrategy.acquireInitialRetryToken(retryTokenScope);
511
- await this.rateLimiter.getSendToken();
512
- return token;
513
- }
514
- async refreshRetryTokenForRetry(tokenToRenew, errorInfo) {
515
- this.rateLimiter.updateClientSendingRate(errorInfo);
516
- const token = await this.standardRetryStrategy.refreshRetryTokenForRetry(tokenToRenew, errorInfo);
517
- await this.rateLimiter.getSendToken();
518
- return token;
519
- }
520
- recordSuccess(token) {
521
- this.rateLimiter.updateClientSendingRate({});
522
- this.standardRetryStrategy.recordSuccess(token);
523
- }
524
- async maxAttemptsProvider() {
525
- return this.standardRetryStrategy.maxAttempts();
526
- }
527
- };
528
-
529
- class ConfiguredRetryStrategy extends StandardRetryStrategy$1 {
530
- computeNextBackoffDelay;
531
- constructor(maxAttempts, computeNextBackoffDelay = Retry.delay()) {
532
- super(typeof maxAttempts === "function" ? maxAttempts : async () => maxAttempts);
533
- if (typeof computeNextBackoffDelay === "number") {
534
- this.computeNextBackoffDelay = () => computeNextBackoffDelay;
535
- } else {
536
- this.computeNextBackoffDelay = computeNextBackoffDelay;
537
- }
538
- }
539
- async refreshRetryTokenForRetry(tokenToRenew, errorInfo) {
540
- const token = await super.refreshRetryTokenForRetry(tokenToRenew, errorInfo);
541
- token.getRetryDelay = () => this.computeNextBackoffDelay(token.getRetryCount());
542
- return token;
543
- }
544
- }
545
- var getDefaultRetryQuota = (initialRetryTokens, options) => {
546
- const MAX_CAPACITY = initialRetryTokens;
547
- const noRetryIncrement = NO_RETRY_INCREMENT;
548
- const retryCost = RETRY_COST;
549
- const timeoutRetryCost = TIMEOUT_RETRY_COST;
550
- let availableCapacity = initialRetryTokens;
551
- const getCapacityAmount = (error) => error.name === "TimeoutError" ? timeoutRetryCost : retryCost;
552
- const hasRetryTokens = (error) => getCapacityAmount(error) <= availableCapacity;
553
- const retrieveRetryTokens = (error) => {
554
- if (!hasRetryTokens(error)) {
555
- throw new Error("No retry token available");
556
- }
557
- const capacityAmount = getCapacityAmount(error);
558
- availableCapacity -= capacityAmount;
559
- return capacityAmount;
560
- };
561
- const releaseRetryTokens = (capacityReleaseAmount) => {
562
- availableCapacity += capacityReleaseAmount ?? noRetryIncrement;
563
- availableCapacity = Math.min(availableCapacity, MAX_CAPACITY);
564
- };
565
- return Object.freeze({
566
- hasRetryTokens,
567
- retrieveRetryTokens,
568
- releaseRetryTokens
569
- });
570
- };
571
- var defaultDelayDecider = (delayBase, attempts) => Math.floor(Math.min(MAXIMUM_RETRY_DELAY, Math.random() * 2 ** attempts * delayBase));
572
- var defaultRetryDecider = (error) => {
573
- if (!error) {
574
- return false;
575
- }
576
- return isRetryableByTrait(error) || isClockSkewError(error) || isThrottlingError(error) || isTransientError(error);
577
- };
578
-
579
- class StandardRetryStrategy {
580
- maxAttemptsProvider;
581
- retryDecider;
582
- delayDecider;
583
- retryQuota;
584
- mode = exports.RETRY_MODES.STANDARD;
585
- constructor(maxAttemptsProvider, options) {
586
- this.maxAttemptsProvider = maxAttemptsProvider;
587
- this.retryDecider = options?.retryDecider ?? defaultRetryDecider;
588
- this.delayDecider = options?.delayDecider ?? defaultDelayDecider;
589
- this.retryQuota = options?.retryQuota ?? getDefaultRetryQuota(INITIAL_RETRY_TOKENS);
590
- }
591
- shouldRetry(error, attempts, maxAttempts) {
592
- return attempts < maxAttempts && this.retryDecider(error) && this.retryQuota.hasRetryTokens(error);
593
- }
594
- async getMaxAttempts() {
595
- let maxAttempts;
596
- try {
597
- maxAttempts = await this.maxAttemptsProvider();
598
- } catch (error) {
599
- maxAttempts = DEFAULT_MAX_ATTEMPTS;
600
- }
601
- return maxAttempts;
602
- }
603
- async retry(next, args, options) {
604
- let retryTokenAmount;
605
- let attempts = 0;
606
- let totalDelay = 0;
607
- const maxAttempts = await this.getMaxAttempts();
608
- const { request } = args;
609
- if (protocols.HttpRequest.isInstance(request)) {
610
- request.headers[INVOCATION_ID_HEADER] = serde.v4();
611
- }
612
- while (true) {
613
- try {
614
- if (protocols.HttpRequest.isInstance(request)) {
615
- request.headers[REQUEST_HEADER] = `attempt=${attempts + 1}; max=${maxAttempts}`;
616
- }
617
- if (options?.beforeRequest) {
618
- await options.beforeRequest();
619
- }
620
- const { response, output } = await next(args);
621
- if (options?.afterRequest) {
622
- options.afterRequest(response);
623
- }
624
- this.retryQuota.releaseRetryTokens(retryTokenAmount);
625
- output.$metadata.attempts = attempts + 1;
626
- output.$metadata.totalRetryDelay = totalDelay;
627
- return { response, output };
628
- } catch (e) {
629
- const err = asSdkError(e);
630
- attempts++;
631
- if (this.shouldRetry(err, attempts, maxAttempts)) {
632
- retryTokenAmount = this.retryQuota.retrieveRetryTokens(err);
633
- const delayFromDecider = this.delayDecider(isThrottlingError(err) ? THROTTLING_RETRY_DELAY_BASE : DEFAULT_RETRY_DELAY_BASE, attempts);
634
- const delayFromResponse = getDelayFromRetryAfterHeader(err.$response);
635
- const delay = Math.max(delayFromResponse || 0, delayFromDecider);
636
- totalDelay += delay;
637
- await new Promise((resolve) => setTimeout(resolve, delay));
638
- continue;
639
- }
640
- if (!err.$metadata) {
641
- err.$metadata = {};
642
- }
643
- err.$metadata.attempts = attempts;
644
- err.$metadata.totalRetryDelay = totalDelay;
645
- throw err;
646
- }
647
- }
648
- }
649
- }
650
- var getDelayFromRetryAfterHeader = (response) => {
651
- if (!protocols.HttpResponse.isInstance(response))
652
- return;
653
- const retryAfterHeaderName = Object.keys(response.headers).find((key) => key.toLowerCase() === "retry-after");
654
- if (!retryAfterHeaderName)
655
- return;
656
- const retryAfter = response.headers[retryAfterHeaderName];
657
- const retryAfterSeconds = Number(retryAfter);
658
- if (!Number.isNaN(retryAfterSeconds))
659
- return retryAfterSeconds * 1000;
660
- const retryAfterDate = new Date(retryAfter);
661
- return retryAfterDate.getTime() - Date.now();
662
- };
663
-
664
- class AdaptiveRetryStrategy extends StandardRetryStrategy {
665
- rateLimiter;
666
- constructor(maxAttemptsProvider, options) {
667
- const { rateLimiter, ...superOptions } = options ?? {};
668
- super(maxAttemptsProvider, superOptions);
669
- this.rateLimiter = rateLimiter ?? new DefaultRateLimiter;
670
- this.mode = exports.RETRY_MODES.ADAPTIVE;
671
- }
672
- async retry(next, args) {
673
- return super.retry(next, args, {
674
- beforeRequest: async () => {
675
- return this.rateLimiter.getSendToken();
676
- },
677
- afterRequest: (response) => {
678
- this.rateLimiter.updateClientSendingRate(response);
679
- }
680
- });
681
- }
682
- }
683
- var ENV_MAX_ATTEMPTS = "AWS_MAX_ATTEMPTS";
684
- var CONFIG_MAX_ATTEMPTS = "max_attempts";
685
- var NODE_MAX_ATTEMPT_CONFIG_OPTIONS = {
686
- environmentVariableSelector: (env) => {
687
- const value = env[ENV_MAX_ATTEMPTS];
688
- if (!value)
689
- return;
690
- const maxAttempt = parseInt(value);
691
- if (Number.isNaN(maxAttempt)) {
692
- throw new Error(`Environment variable ${ENV_MAX_ATTEMPTS} mast be a number, got "${value}"`);
693
- }
694
- return maxAttempt;
695
- },
696
- configFileSelector: (profile) => {
697
- const value = profile[CONFIG_MAX_ATTEMPTS];
698
- if (!value)
699
- return;
700
- const maxAttempt = parseInt(value);
701
- if (Number.isNaN(maxAttempt)) {
702
- throw new Error(`Shared config file entry ${CONFIG_MAX_ATTEMPTS} mast be a number, got "${value}"`);
703
- }
704
- return maxAttempt;
705
- },
706
- default: DEFAULT_MAX_ATTEMPTS
707
- };
708
- var resolveRetryConfig = (input) => {
709
- const { retryStrategy, retryMode } = input;
710
- const maxAttempts = client.normalizeProvider(input.maxAttempts ?? DEFAULT_MAX_ATTEMPTS);
711
- let controller = retryStrategy ? Promise.resolve(retryStrategy) : undefined;
712
- const getDefault = async () => await client.normalizeProvider(retryMode)() === exports.RETRY_MODES.ADAPTIVE ? new AdaptiveRetryStrategy$1(maxAttempts) : new StandardRetryStrategy$1(maxAttempts);
713
- return Object.assign(input, {
714
- maxAttempts,
715
- retryStrategy: () => controller ??= getDefault()
716
- });
717
- };
718
- var ENV_RETRY_MODE = "AWS_RETRY_MODE";
719
- var CONFIG_RETRY_MODE = "retry_mode";
720
- var NODE_RETRY_MODE_CONFIG_OPTIONS = {
721
- environmentVariableSelector: (env) => env[ENV_RETRY_MODE],
722
- configFileSelector: (profile) => profile[CONFIG_RETRY_MODE],
723
- default: DEFAULT_RETRY_MODE
724
- };
725
- var omitRetryHeadersMiddleware = () => (next) => async (args) => {
726
- const { request } = args;
727
- if (protocols.HttpRequest.isInstance(request)) {
728
- delete request.headers[INVOCATION_ID_HEADER];
729
- delete request.headers[REQUEST_HEADER];
730
- }
731
- return next(args);
732
- };
733
- var omitRetryHeadersMiddlewareOptions = {
734
- name: "omitRetryHeadersMiddleware",
735
- tags: ["RETRY", "HEADERS", "OMIT_RETRY_HEADERS"],
736
- relation: "before",
737
- toMiddleware: "awsAuthMiddleware",
738
- override: true
739
- };
740
- var getOmitRetryHeadersPlugin = (options) => ({
741
- applyToStack: (clientStack) => {
742
- clientStack.addRelativeTo(omitRetryHeadersMiddleware(), omitRetryHeadersMiddlewareOptions);
743
- }
744
- });
745
- var retryMiddleware = bindRetryMiddleware(isStreamingPayload);
746
- var getRetryPlugin = bindGetRetryPlugin(isStreamingPayload);
747
- exports.AdaptiveRetryStrategy = AdaptiveRetryStrategy$1;
748
- exports.CONFIG_MAX_ATTEMPTS = CONFIG_MAX_ATTEMPTS;
749
- exports.CONFIG_RETRY_MODE = CONFIG_RETRY_MODE;
750
- exports.ConfiguredRetryStrategy = ConfiguredRetryStrategy;
751
- exports.DEFAULT_MAX_ATTEMPTS = DEFAULT_MAX_ATTEMPTS;
752
- exports.DEFAULT_RETRY_DELAY_BASE = DEFAULT_RETRY_DELAY_BASE;
753
- exports.DEFAULT_RETRY_MODE = DEFAULT_RETRY_MODE;
754
- exports.DefaultRateLimiter = DefaultRateLimiter;
755
- exports.DeprecatedAdaptiveRetryStrategy = AdaptiveRetryStrategy;
756
- exports.DeprecatedStandardRetryStrategy = StandardRetryStrategy;
757
- exports.ENV_MAX_ATTEMPTS = ENV_MAX_ATTEMPTS;
758
- exports.ENV_RETRY_MODE = ENV_RETRY_MODE;
759
- exports.INITIAL_RETRY_TOKENS = INITIAL_RETRY_TOKENS;
760
- exports.INVOCATION_ID_HEADER = INVOCATION_ID_HEADER;
761
- exports.MAXIMUM_RETRY_DELAY = MAXIMUM_RETRY_DELAY;
762
- exports.NODE_MAX_ATTEMPT_CONFIG_OPTIONS = NODE_MAX_ATTEMPT_CONFIG_OPTIONS;
763
- exports.NODE_RETRY_MODE_CONFIG_OPTIONS = NODE_RETRY_MODE_CONFIG_OPTIONS;
764
- exports.NO_RETRY_INCREMENT = NO_RETRY_INCREMENT;
765
- exports.REQUEST_HEADER = REQUEST_HEADER;
766
- exports.RETRY_COST = RETRY_COST;
767
- exports.Retry = Retry;
768
- exports.StandardRetryStrategy = StandardRetryStrategy$1;
769
- exports.THROTTLING_RETRY_DELAY_BASE = THROTTLING_RETRY_DELAY_BASE;
770
- exports.TIMEOUT_RETRY_COST = TIMEOUT_RETRY_COST;
771
- exports.defaultDelayDecider = defaultDelayDecider;
772
- exports.defaultRetryDecider = defaultRetryDecider;
773
- exports.getOmitRetryHeadersPlugin = getOmitRetryHeadersPlugin;
774
- exports.getRetryAfterHint = getRetryAfterHint;
775
- exports.getRetryPlugin = getRetryPlugin;
776
- exports.isBrowserNetworkError = isBrowserNetworkError;
777
- exports.isClockSkewCorrectedError = isClockSkewCorrectedError;
778
- exports.isClockSkewError = isClockSkewError;
779
- exports.isNodeJsHttp2TransientError = isNodeJsHttp2TransientError;
780
- exports.isRetryableByTrait = isRetryableByTrait;
781
- exports.isServerError = isServerError;
782
- exports.isThrottlingError = isThrottlingError;
783
- exports.isTransientError = isTransientError;
784
- exports.omitRetryHeadersMiddleware = omitRetryHeadersMiddleware;
785
- exports.omitRetryHeadersMiddlewareOptions = omitRetryHeadersMiddlewareOptions;
786
- exports.resolveRetryConfig = resolveRetryConfig;
787
- exports.retryMiddleware = retryMiddleware;
788
- exports.retryMiddlewareOptions = retryMiddlewareOptions;
789
- });
790
-
791
- // node_modules/@smithy/core/dist-cjs/index.js
792
- var require_dist_cjs2 = __commonJS(function(exports) {
793
- var types = require_dist_cjs();
794
- var protocols = require_protocols();
795
- var client = require_client();
796
- var getSmithyContext = (context) => context[types.SMITHY_CONTEXT_KEY] || (context[types.SMITHY_CONTEXT_KEY] = {});
797
- var resolveAuthOptions = (candidateAuthOptions, authSchemePreference) => {
798
- if (!authSchemePreference || authSchemePreference.length === 0) {
799
- return candidateAuthOptions;
800
- }
801
- const preferredAuthOptions = [];
802
- for (const preferredSchemeName of authSchemePreference) {
803
- for (const candidateAuthOption of candidateAuthOptions) {
804
- const candidateAuthSchemeName = candidateAuthOption.schemeId.split("#")[1];
805
- if (candidateAuthSchemeName === preferredSchemeName) {
806
- preferredAuthOptions.push(candidateAuthOption);
807
- }
808
- }
809
- }
810
- for (const candidateAuthOption of candidateAuthOptions) {
811
- if (!preferredAuthOptions.find(({ schemeId }) => schemeId === candidateAuthOption.schemeId)) {
812
- preferredAuthOptions.push(candidateAuthOption);
813
- }
814
- }
815
- return preferredAuthOptions;
816
- };
817
- function convertHttpAuthSchemesToMap(httpAuthSchemes) {
818
- const map = new Map;
819
- for (const scheme of httpAuthSchemes) {
820
- map.set(scheme.schemeId, scheme);
821
- }
822
- return map;
823
- }
824
- var httpAuthSchemeMiddleware = (config, mwOptions) => (next, context) => async (args) => {
825
- const options = config.httpAuthSchemeProvider(await mwOptions.httpAuthSchemeParametersProvider(config, context, args.input));
826
- const authSchemePreference = config.authSchemePreference ? await config.authSchemePreference() : [];
827
- const resolvedOptions = resolveAuthOptions(options, authSchemePreference);
828
- const authSchemes = convertHttpAuthSchemesToMap(config.httpAuthSchemes);
829
- const smithyContext = client.getSmithyContext(context);
830
- const failureReasons = [];
831
- for (const option of resolvedOptions) {
832
- const scheme = authSchemes.get(option.schemeId);
833
- if (!scheme) {
834
- failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` was not enabled for this service.`);
835
- continue;
836
- }
837
- const identityProvider = scheme.identityProvider(await mwOptions.identityProviderConfigProvider(config));
838
- if (!identityProvider) {
839
- failureReasons.push(`HttpAuthScheme \`${option.schemeId}\` did not have an IdentityProvider configured.`);
840
- continue;
841
- }
842
- const { identityProperties = {}, signingProperties = {} } = option.propertiesExtractor?.(config, context) || {};
843
- option.identityProperties = Object.assign(option.identityProperties || {}, identityProperties);
844
- option.signingProperties = Object.assign(option.signingProperties || {}, signingProperties);
845
- smithyContext.selectedHttpAuthScheme = {
846
- httpAuthOption: option,
847
- identity: await identityProvider(option.identityProperties),
848
- signer: scheme.signer
849
- };
850
- break;
851
- }
852
- if (!smithyContext.selectedHttpAuthScheme) {
853
- throw new Error(failureReasons.join(`
854
- `));
855
- }
856
- return next(args);
857
- };
858
- var httpAuthSchemeEndpointRuleSetMiddlewareOptions = {
859
- step: "serialize",
860
- tags: ["HTTP_AUTH_SCHEME"],
861
- name: "httpAuthSchemeMiddleware",
862
- override: true,
863
- relation: "before",
864
- toMiddleware: "endpointV2Middleware"
865
- };
866
- var getHttpAuthSchemeEndpointRuleSetPlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider }) => ({
867
- applyToStack: (clientStack) => {
868
- clientStack.addRelativeTo(httpAuthSchemeMiddleware(config, {
869
- httpAuthSchemeParametersProvider,
870
- identityProviderConfigProvider
871
- }), httpAuthSchemeEndpointRuleSetMiddlewareOptions);
872
- }
873
- });
874
- var httpAuthSchemeMiddlewareOptions = {
875
- step: "serialize",
876
- tags: ["HTTP_AUTH_SCHEME"],
877
- name: "httpAuthSchemeMiddleware",
878
- override: true,
879
- relation: "before",
880
- toMiddleware: "serializerMiddleware"
881
- };
882
- var getHttpAuthSchemePlugin = (config, { httpAuthSchemeParametersProvider, identityProviderConfigProvider }) => ({
883
- applyToStack: (clientStack) => {
884
- clientStack.addRelativeTo(httpAuthSchemeMiddleware(config, {
885
- httpAuthSchemeParametersProvider,
886
- identityProviderConfigProvider
887
- }), httpAuthSchemeMiddlewareOptions);
888
- }
889
- });
890
- var defaultErrorHandler = (signingProperties) => (error) => {
891
- throw error;
892
- };
893
- var defaultSuccessHandler = (httpResponse, signingProperties) => {};
894
- var httpSigningMiddleware = (config) => (next, context) => async (args) => {
895
- if (!protocols.HttpRequest.isInstance(args.request)) {
896
- return next(args);
897
- }
898
- const smithyContext = client.getSmithyContext(context);
899
- const scheme = smithyContext.selectedHttpAuthScheme;
900
- if (!scheme) {
901
- throw new Error(`No HttpAuthScheme was selected: unable to sign request`);
902
- }
903
- const { httpAuthOption: { signingProperties = {} }, identity, signer } = scheme;
904
- const output = await next({
905
- ...args,
906
- request: await signer.sign(args.request, identity, signingProperties)
907
- }).catch((signer.errorHandler || defaultErrorHandler)(signingProperties));
908
- (signer.successHandler || defaultSuccessHandler)(output.response, signingProperties);
909
- return output;
910
- };
911
- var httpSigningMiddlewareOptions = {
912
- step: "finalizeRequest",
913
- tags: ["HTTP_SIGNING"],
914
- name: "httpSigningMiddleware",
915
- aliases: ["apiKeyMiddleware", "tokenMiddleware", "awsAuthMiddleware"],
916
- override: true,
917
- relation: "after",
918
- toMiddleware: "retryMiddleware"
919
- };
920
- var getHttpSigningPlugin = (config) => ({
921
- applyToStack: (clientStack) => {
922
- clientStack.addRelativeTo(httpSigningMiddleware(), httpSigningMiddlewareOptions);
923
- }
924
- });
925
- var normalizeProvider = (input) => {
926
- if (typeof input === "function")
927
- return input;
928
- const promisified = Promise.resolve(input);
929
- return () => promisified;
930
- };
931
- var makePagedClientRequest = async (CommandCtor, client2, input, withCommand = (_) => _, ...args) => {
932
- let command = new CommandCtor(input);
933
- command = withCommand(command) ?? command;
934
- return await client2.send(command, ...args);
935
- };
936
- function createPaginator(ClientCtor, CommandCtor, inputTokenName, outputTokenName, pageSizeTokenName) {
937
- return async function* paginateOperation(config, input, ...additionalArguments) {
938
- const _input = input;
939
- let token = config.startingToken ?? _input[inputTokenName];
940
- let hasNext = true;
941
- let page;
942
- while (hasNext) {
943
- _input[inputTokenName] = token;
944
- if (pageSizeTokenName) {
945
- _input[pageSizeTokenName] = _input[pageSizeTokenName] ?? config.pageSize;
946
- }
947
- if (config.client instanceof ClientCtor) {
948
- page = await makePagedClientRequest(CommandCtor, config.client, input, config.withCommand, ...additionalArguments);
949
- } else {
950
- throw new Error(`Invalid client, expected instance of ${ClientCtor.name}`);
951
- }
952
- yield page;
953
- const prevToken = token;
954
- token = get(page, outputTokenName);
955
- hasNext = !!(token && (!config.stopOnSameToken || token !== prevToken));
956
- }
957
- return;
958
- };
959
- }
960
- var get = (fromObject, path) => {
961
- let cursor = fromObject;
962
- const pathComponents = path.split(".");
963
- for (const step of pathComponents) {
964
- if (!cursor || typeof cursor !== "object") {
965
- return;
966
- }
967
- cursor = cursor[step];
968
- }
969
- return cursor;
970
- };
971
- function setFeature(context, feature, value) {
972
- if (!context.__smithy_context) {
973
- context.__smithy_context = {
974
- features: {}
975
- };
976
- } else if (!context.__smithy_context.features) {
977
- context.__smithy_context.features = {};
978
- }
979
- context.__smithy_context.features[feature] = value;
980
- }
981
-
982
- class DefaultIdentityProviderConfig {
983
- authSchemes = new Map;
984
- constructor(config) {
985
- for (const key in config) {
986
- const value = config[key];
987
- if (value !== undefined) {
988
- this.authSchemes.set(key, value);
989
- }
990
- }
991
- }
992
- getIdentityProvider(schemeId) {
993
- return this.authSchemes.get(schemeId);
994
- }
995
- }
996
-
997
- class HttpApiKeyAuthSigner {
998
- async sign(httpRequest, identity, signingProperties) {
999
- if (!signingProperties) {
1000
- throw new Error("request could not be signed with `apiKey` since the `name` and `in` signer properties are missing");
1001
- }
1002
- if (!signingProperties.name) {
1003
- throw new Error("request could not be signed with `apiKey` since the `name` signer property is missing");
1004
- }
1005
- if (!signingProperties.in) {
1006
- throw new Error("request could not be signed with `apiKey` since the `in` signer property is missing");
1007
- }
1008
- if (!identity.apiKey) {
1009
- throw new Error("request could not be signed with `apiKey` since the `apiKey` is not defined");
1010
- }
1011
- const clonedRequest = protocols.HttpRequest.clone(httpRequest);
1012
- if (signingProperties.in === types.HttpApiKeyAuthLocation.QUERY) {
1013
- clonedRequest.query[signingProperties.name] = identity.apiKey;
1014
- } else if (signingProperties.in === types.HttpApiKeyAuthLocation.HEADER) {
1015
- clonedRequest.headers[signingProperties.name] = signingProperties.scheme ? `${signingProperties.scheme} ${identity.apiKey}` : identity.apiKey;
1016
- } else {
1017
- throw new Error("request can only be signed with `apiKey` locations `query` or `header`, " + "but found: `" + signingProperties.in + "`");
1018
- }
1019
- return clonedRequest;
1020
- }
1021
- }
1022
-
1023
- class HttpBearerAuthSigner {
1024
- async sign(httpRequest, identity, signingProperties) {
1025
- const clonedRequest = protocols.HttpRequest.clone(httpRequest);
1026
- if (!identity.token) {
1027
- throw new Error("request could not be signed with `token` since the `token` is not defined");
1028
- }
1029
- clonedRequest.headers["Authorization"] = `Bearer ${identity.token}`;
1030
- return clonedRequest;
1031
- }
1032
- }
1033
-
1034
- class NoAuthSigner {
1035
- async sign(httpRequest, identity, signingProperties) {
1036
- return httpRequest;
1037
- }
1038
- }
1039
- var createIsIdentityExpiredFunction = (expirationMs) => function isIdentityExpired2(identity) {
1040
- return doesIdentityRequireRefresh(identity) && identity.expiration.getTime() - Date.now() < expirationMs;
1041
- };
1042
- var EXPIRATION_MS = 300000;
1043
- var isIdentityExpired = createIsIdentityExpiredFunction(EXPIRATION_MS);
1044
- var doesIdentityRequireRefresh = (identity) => identity.expiration !== undefined;
1045
- var memoizeIdentityProvider = (provider, isExpired, requiresRefresh) => {
1046
- if (provider === undefined) {
1047
- return;
1048
- }
1049
- const normalizedProvider = typeof provider !== "function" ? async () => Promise.resolve(provider) : provider;
1050
- let resolved;
1051
- let pending;
1052
- let hasResult;
1053
- let isConstant = false;
1054
- const coalesceProvider = async (options) => {
1055
- if (!pending) {
1056
- pending = normalizedProvider(options);
1057
- }
1058
- try {
1059
- resolved = await pending;
1060
- hasResult = true;
1061
- isConstant = false;
1062
- } finally {
1063
- pending = undefined;
1064
- }
1065
- return resolved;
1066
- };
1067
- if (isExpired === undefined) {
1068
- return async (options) => {
1069
- if (!hasResult || options?.forceRefresh) {
1070
- resolved = await coalesceProvider(options);
1071
- }
1072
- return resolved;
1073
- };
1074
- }
1075
- return async (options) => {
1076
- if (!hasResult || options?.forceRefresh) {
1077
- resolved = await coalesceProvider(options);
1078
- }
1079
- if (isConstant) {
1080
- return resolved;
1081
- }
1082
- if (!requiresRefresh(resolved)) {
1083
- isConstant = true;
1084
- return resolved;
1085
- }
1086
- if (isExpired(resolved)) {
1087
- await coalesceProvider(options);
1088
- return resolved;
1089
- }
1090
- return resolved;
1091
- };
1092
- };
1093
- exports.requestBuilder = protocols.requestBuilder;
1094
- exports.DefaultIdentityProviderConfig = DefaultIdentityProviderConfig;
1095
- exports.EXPIRATION_MS = EXPIRATION_MS;
1096
- exports.HttpApiKeyAuthSigner = HttpApiKeyAuthSigner;
1097
- exports.HttpBearerAuthSigner = HttpBearerAuthSigner;
1098
- exports.NoAuthSigner = NoAuthSigner;
1099
- exports.createIsIdentityExpiredFunction = createIsIdentityExpiredFunction;
1100
- exports.createPaginator = createPaginator;
1101
- exports.doesIdentityRequireRefresh = doesIdentityRequireRefresh;
1102
- exports.getHttpAuthSchemeEndpointRuleSetPlugin = getHttpAuthSchemeEndpointRuleSetPlugin;
1103
- exports.getHttpAuthSchemePlugin = getHttpAuthSchemePlugin;
1104
- exports.getHttpSigningPlugin = getHttpSigningPlugin;
1105
- exports.getSmithyContext = getSmithyContext;
1106
- exports.httpAuthSchemeEndpointRuleSetMiddlewareOptions = httpAuthSchemeEndpointRuleSetMiddlewareOptions;
1107
- exports.httpAuthSchemeMiddleware = httpAuthSchemeMiddleware;
1108
- exports.httpAuthSchemeMiddlewareOptions = httpAuthSchemeMiddlewareOptions;
1109
- exports.httpSigningMiddleware = httpSigningMiddleware;
1110
- exports.httpSigningMiddlewareOptions = httpSigningMiddlewareOptions;
1111
- exports.isIdentityExpired = isIdentityExpired;
1112
- exports.memoizeIdentityProvider = memoizeIdentityProvider;
1113
- exports.normalizeProvider = normalizeProvider;
1114
- exports.setFeature = setFeature;
1115
- });
1116
-
1117
- // node_modules/@aws/lambda-invoke-store/dist-cjs/invoke-store.js
1118
- var require_invoke_store = __commonJS(function(exports) {
1119
- var PROTECTED_KEYS = {
1120
- REQUEST_ID: Symbol.for("_AWS_LAMBDA_REQUEST_ID"),
1121
- X_RAY_TRACE_ID: Symbol.for("_AWS_LAMBDA_X_RAY_TRACE_ID"),
1122
- TENANT_ID: Symbol.for("_AWS_LAMBDA_TENANT_ID")
1123
- };
1124
- var NO_GLOBAL_AWS_LAMBDA = ["true", "1"].includes(process.env?.AWS_LAMBDA_NODEJS_NO_GLOBAL_AWSLAMBDA ?? "");
1125
- if (!NO_GLOBAL_AWS_LAMBDA) {
1126
- globalThis.awslambda = globalThis.awslambda || {};
1127
- }
1128
-
1129
- class InvokeStoreBase {
1130
- static PROTECTED_KEYS = PROTECTED_KEYS;
1131
- isProtectedKey(key) {
1132
- return Object.values(PROTECTED_KEYS).includes(key);
1133
- }
1134
- getRequestId() {
1135
- return this.get(PROTECTED_KEYS.REQUEST_ID) ?? "-";
1136
- }
1137
- getXRayTraceId() {
1138
- return this.get(PROTECTED_KEYS.X_RAY_TRACE_ID);
1139
- }
1140
- getTenantId() {
1141
- return this.get(PROTECTED_KEYS.TENANT_ID);
1142
- }
1143
- }
1144
-
1145
- class InvokeStoreSingle extends InvokeStoreBase {
1146
- currentContext;
1147
- getContext() {
1148
- return this.currentContext;
1149
- }
1150
- hasContext() {
1151
- return this.currentContext !== undefined;
1152
- }
1153
- get(key) {
1154
- return this.currentContext?.[key];
1155
- }
1156
- set(key, value) {
1157
- if (this.isProtectedKey(key)) {
1158
- throw new Error(`Cannot modify protected Lambda context field: ${String(key)}`);
1159
- }
1160
- this.currentContext = this.currentContext || {};
1161
- this.currentContext[key] = value;
1162
- }
1163
- run(context, fn) {
1164
- this.currentContext = context;
1165
- return fn();
1166
- }
1167
- }
1168
-
1169
- class InvokeStoreMulti extends InvokeStoreBase {
1170
- als;
1171
- static async create() {
1172
- const instance = new InvokeStoreMulti;
1173
- const asyncHooks = await import("node:async_hooks");
1174
- instance.als = new asyncHooks.AsyncLocalStorage;
1175
- return instance;
1176
- }
1177
- getContext() {
1178
- return this.als.getStore();
1179
- }
1180
- hasContext() {
1181
- return this.als.getStore() !== undefined;
1182
- }
1183
- get(key) {
1184
- return this.als.getStore()?.[key];
1185
- }
1186
- set(key, value) {
1187
- if (this.isProtectedKey(key)) {
1188
- throw new Error(`Cannot modify protected Lambda context field: ${String(key)}`);
1189
- }
1190
- const store = this.als.getStore();
1191
- if (!store) {
1192
- throw new Error("No context available");
1193
- }
1194
- store[key] = value;
1195
- }
1196
- run(context, fn) {
1197
- return this.als.run(context, fn);
1198
- }
1199
- }
1200
- exports.InvokeStore = undefined;
1201
- (function(InvokeStore) {
1202
- let instance = null;
1203
- async function getInstanceAsync() {
1204
- if (!instance) {
1205
- instance = (async () => {
1206
- const isMulti = "AWS_LAMBDA_MAX_CONCURRENCY" in process.env;
1207
- const newInstance = isMulti ? await InvokeStoreMulti.create() : new InvokeStoreSingle;
1208
- if (!NO_GLOBAL_AWS_LAMBDA && globalThis.awslambda?.InvokeStore) {
1209
- return globalThis.awslambda.InvokeStore;
1210
- } else if (!NO_GLOBAL_AWS_LAMBDA && globalThis.awslambda) {
1211
- globalThis.awslambda.InvokeStore = newInstance;
1212
- return newInstance;
1213
- } else {
1214
- return newInstance;
1215
- }
1216
- })();
1217
- }
1218
- return instance;
1219
- }
1220
- InvokeStore.getInstanceAsync = getInstanceAsync;
1221
- InvokeStore._testing = process.env.AWS_LAMBDA_BENCHMARK_MODE === "1" ? {
1222
- reset: () => {
1223
- instance = null;
1224
- if (globalThis.awslambda?.InvokeStore) {
1225
- delete globalThis.awslambda.InvokeStore;
1226
- }
1227
- globalThis.awslambda = { InvokeStore: undefined };
1228
- }
1229
- } : undefined;
1230
- })(exports.InvokeStore || (exports.InvokeStore = {}));
1231
- exports.InvokeStoreBase = InvokeStoreBase;
1232
- });
1233
-
1234
- // node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.js
1235
- var require_client2 = __commonJS(function(exports) {
1236
- var __dirname = "/home/runner/work/agent-swarm/agent-swarm/node_modules/@aws-sdk/core/dist-cjs/submodules/client";
1237
- var retry = require_retry();
1238
- var protocols = require_protocols();
1239
- var lambdaInvokeStore = require_invoke_store();
1240
- var core = require_dist_cjs2();
1241
- var node_os = __require("node:os");
1242
- var node_process = __require("node:process");
1243
- var config = require_config();
1244
- var promises = __require("node:fs/promises");
1245
- var node_path = __require("node:path");
1246
- var endpoints = require_endpoints();
1247
- var state = {
1248
- warningEmitted: false
1249
- };
1250
- var emitWarningIfUnsupportedVersion = (version) => {
1251
- if (version && !state.warningEmitted) {
1252
- if (process.env.AWS_SDK_JS_NODE_VERSION_SUPPORT_WARNING_DISABLED === "true") {
1253
- state.warningEmitted = true;
1254
- return;
1255
- }
1256
- const userMajorVersion = parseInt(version.substring(1, version.indexOf(".")));
1257
- const vv = 22;
1258
- if (userMajorVersion < vv) {
1259
- state.warningEmitted = true;
1260
- process.emitWarning(`NodeVersionSupportWarning: The AWS SDK for JavaScript (v3)
1261
- versions published after the first week of January 2027
1262
- will require node >=${vv}. You are running node ${version}.
1263
-
1264
- To continue receiving updates to AWS services, bug fixes,
1265
- and security updates please upgrade to node >=${vv}.
1266
-
1267
- More information can be found at: https://a.co/c895JFp`);
1268
- }
1269
- }
1270
- };
1271
- var longPollMiddleware = () => (next, context) => async (args) => {
1272
- context.__retryLongPoll = true;
1273
- return next(args);
1274
- };
1275
- var longPollMiddlewareOptions = {
1276
- name: "longPollMiddleware",
1277
- tags: ["RETRY"],
1278
- step: "initialize",
1279
- override: true
1280
- };
1281
- var getLongPollPlugin = (options) => ({
1282
- applyToStack: (clientStack) => {
1283
- clientStack.add(longPollMiddleware(), longPollMiddlewareOptions);
1284
- }
1285
- });
1286
- function setCredentialFeature(credentials, feature, value) {
1287
- if (!credentials.$source) {
1288
- credentials.$source = {};
1289
- }
1290
- credentials.$source[feature] = value;
1291
- return credentials;
1292
- }
1293
- retry.Retry.v2026 ||= typeof process === "object" && process.env?.AWS_NEW_RETRIES_2026 === "true";
1294
- function setFeature(context, feature, value) {
1295
- if (!context.__aws_sdk_context) {
1296
- context.__aws_sdk_context = {
1297
- features: {}
1298
- };
1299
- } else if (!context.__aws_sdk_context.features) {
1300
- context.__aws_sdk_context.features = {};
1301
- }
1302
- context.__aws_sdk_context.features[feature] = value;
1303
- }
1304
- function setTokenFeature(token, feature, value) {
1305
- if (!token.$source) {
1306
- token.$source = {};
1307
- }
1308
- token.$source[feature] = value;
1309
- return token;
1310
- }
1311
- function resolveHostHeaderConfig(input) {
1312
- return input;
1313
- }
1314
- var hostHeaderMiddleware = (options) => (next) => async (args) => {
1315
- if (!protocols.HttpRequest.isInstance(args.request))
1316
- return next(args);
1317
- const { request } = args;
1318
- const { handlerProtocol = "" } = options.requestHandler.metadata || {};
1319
- if (handlerProtocol.indexOf("h2") >= 0 && !request.headers[":authority"]) {
1320
- delete request.headers["host"];
1321
- request.headers[":authority"] = request.hostname + (request.port ? ":" + request.port : "");
1322
- } else if (!request.headers["host"]) {
1323
- let host = request.hostname;
1324
- if (request.port != null)
1325
- host += `:${request.port}`;
1326
- request.headers["host"] = host;
1327
- }
1328
- return next(args);
1329
- };
1330
- var hostHeaderMiddlewareOptions = {
1331
- name: "hostHeaderMiddleware",
1332
- step: "build",
1333
- priority: "low",
1334
- tags: ["HOST"],
1335
- override: true
1336
- };
1337
- var getHostHeaderPlugin = (options) => ({
1338
- applyToStack: (clientStack) => {
1339
- clientStack.add(hostHeaderMiddleware(options), hostHeaderMiddlewareOptions);
1340
- }
1341
- });
1342
- var loggerMiddleware = () => (next, context) => async (args) => {
1343
- try {
1344
- const response = await next(args);
1345
- const { clientName, commandName, logger, dynamoDbDocumentClientOptions = {} } = context;
1346
- const { overrideInputFilterSensitiveLog, overrideOutputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
1347
- const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
1348
- const outputFilterSensitiveLog = overrideOutputFilterSensitiveLog ?? context.outputFilterSensitiveLog;
1349
- const { $metadata, ...outputWithoutMetadata } = response.output;
1350
- logger?.info?.({
1351
- clientName,
1352
- commandName,
1353
- input: inputFilterSensitiveLog(args.input),
1354
- output: outputFilterSensitiveLog(outputWithoutMetadata),
1355
- metadata: $metadata
1356
- });
1357
- return response;
1358
- } catch (error) {
1359
- const { clientName, commandName, logger, dynamoDbDocumentClientOptions = {} } = context;
1360
- const { overrideInputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
1361
- const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
1362
- logger?.error?.({
1363
- clientName,
1364
- commandName,
1365
- input: inputFilterSensitiveLog(args.input),
1366
- error,
1367
- metadata: error.$metadata
1368
- });
1369
- throw error;
1370
- }
1371
- };
1372
- var loggerMiddlewareOptions = {
1373
- name: "loggerMiddleware",
1374
- tags: ["LOGGER"],
1375
- step: "initialize",
1376
- override: true
1377
- };
1378
- var getLoggerPlugin = (options) => ({
1379
- applyToStack: (clientStack) => {
1380
- clientStack.add(loggerMiddleware(), loggerMiddlewareOptions);
1381
- }
1382
- });
1383
- var recursionDetectionMiddlewareOptions = {
1384
- step: "build",
1385
- tags: ["RECURSION_DETECTION"],
1386
- name: "recursionDetectionMiddleware",
1387
- override: true,
1388
- priority: "low"
1389
- };
1390
- var TRACE_ID_HEADER_NAME = "X-Amzn-Trace-Id";
1391
- var ENV_LAMBDA_FUNCTION_NAME = "AWS_LAMBDA_FUNCTION_NAME";
1392
- var ENV_TRACE_ID = "_X_AMZN_TRACE_ID";
1393
- var recursionDetectionMiddleware = () => (next) => async (args) => {
1394
- const { request } = args;
1395
- if (!protocols.HttpRequest.isInstance(request)) {
1396
- return next(args);
1397
- }
1398
- const traceIdHeader = Object.keys(request.headers ?? {}).find((h) => h.toLowerCase() === TRACE_ID_HEADER_NAME.toLowerCase()) ?? TRACE_ID_HEADER_NAME;
1399
- if (request.headers.hasOwnProperty(traceIdHeader)) {
1400
- return next(args);
1401
- }
1402
- const functionName = process.env[ENV_LAMBDA_FUNCTION_NAME];
1403
- const traceIdFromEnv = process.env[ENV_TRACE_ID];
1404
- const invokeStore = await lambdaInvokeStore.InvokeStore.getInstanceAsync();
1405
- const traceIdFromInvokeStore = invokeStore?.getXRayTraceId();
1406
- const traceId = traceIdFromInvokeStore ?? traceIdFromEnv;
1407
- const nonEmptyString = (str) => typeof str === "string" && str.length > 0;
1408
- if (nonEmptyString(functionName) && nonEmptyString(traceId)) {
1409
- request.headers[TRACE_ID_HEADER_NAME] = traceId;
1410
- }
1411
- return next({
1412
- ...args,
1413
- request
1414
- });
1415
- };
1416
- var getRecursionDetectionPlugin = (options) => ({
1417
- applyToStack: (clientStack) => {
1418
- clientStack.add(recursionDetectionMiddleware(), recursionDetectionMiddlewareOptions);
1419
- }
1420
- });
1421
- var DEFAULT_UA_APP_ID = undefined;
1422
- function isValidUserAgentAppId(appId) {
1423
- if (appId === undefined) {
1424
- return true;
1425
- }
1426
- return typeof appId === "string" && appId.length <= 50;
1427
- }
1428
- function resolveUserAgentConfig(input) {
1429
- const normalizedAppIdProvider = core.normalizeProvider(input.userAgentAppId ?? DEFAULT_UA_APP_ID);
1430
- const { customUserAgent } = input;
1431
- return Object.assign(input, {
1432
- customUserAgent: typeof customUserAgent === "string" ? [[customUserAgent]] : customUserAgent,
1433
- userAgentAppId: async () => {
1434
- const appId = await normalizedAppIdProvider();
1435
- if (!isValidUserAgentAppId(appId)) {
1436
- const logger = input.logger?.constructor?.name === "NoOpLogger" || !input.logger ? console : input.logger;
1437
- if (typeof appId !== "string") {
1438
- logger?.warn("userAgentAppId must be a string or undefined.");
1439
- } else if (appId.length > 50) {
1440
- logger?.warn("The provided userAgentAppId exceeds the maximum length of 50 characters.");
1441
- }
1442
- }
1443
- return appId;
1444
- }
1445
- });
1446
- }
1447
- var partitionsInfo = { partitions: [{ id: "aws", outputs: { dnsSuffix: "amazonaws.com", dualStackDnsSuffix: "api.aws", implicitGlobalRegion: "us-east-1", name: "aws", supportsDualStack: true, supportsFIPS: true }, regionRegex: "^(us|eu|ap|sa|ca|me|af|il|mx)\\-\\w+\\-\\d+$", regions: { "af-south-1": { description: "Africa (Cape Town)" }, "ap-east-1": { description: "Asia Pacific (Hong Kong)" }, "ap-east-2": { description: "Asia Pacific (Taipei)" }, "ap-northeast-1": { description: "Asia Pacific (Tokyo)" }, "ap-northeast-2": { description: "Asia Pacific (Seoul)" }, "ap-northeast-3": { description: "Asia Pacific (Osaka)" }, "ap-south-1": { description: "Asia Pacific (Mumbai)" }, "ap-south-2": { description: "Asia Pacific (Hyderabad)" }, "ap-southeast-1": { description: "Asia Pacific (Singapore)" }, "ap-southeast-2": { description: "Asia Pacific (Sydney)" }, "ap-southeast-3": { description: "Asia Pacific (Jakarta)" }, "ap-southeast-4": { description: "Asia Pacific (Melbourne)" }, "ap-southeast-5": { description: "Asia Pacific (Malaysia)" }, "ap-southeast-6": { description: "Asia Pacific (New Zealand)" }, "ap-southeast-7": { description: "Asia Pacific (Thailand)" }, "aws-global": { description: "aws global region" }, "ca-central-1": { description: "Canada (Central)" }, "ca-west-1": { description: "Canada West (Calgary)" }, "eu-central-1": { description: "Europe (Frankfurt)" }, "eu-central-2": { description: "Europe (Zurich)" }, "eu-north-1": { description: "Europe (Stockholm)" }, "eu-south-1": { description: "Europe (Milan)" }, "eu-south-2": { description: "Europe (Spain)" }, "eu-west-1": { description: "Europe (Ireland)" }, "eu-west-2": { description: "Europe (London)" }, "eu-west-3": { description: "Europe (Paris)" }, "il-central-1": { description: "Israel (Tel Aviv)" }, "me-central-1": { description: "Middle East (UAE)" }, "me-south-1": { description: "Middle East (Bahrain)" }, "mx-central-1": { description: "Mexico (Central)" }, "sa-east-1": { description: "South America (Sao Paulo)" }, "us-east-1": { description: "US East (N. Virginia)" }, "us-east-2": { description: "US East (Ohio)" }, "us-west-1": { description: "US West (N. California)" }, "us-west-2": { description: "US West (Oregon)" } } }, { id: "aws-cn", outputs: { dnsSuffix: "amazonaws.com.cn", dualStackDnsSuffix: "api.amazonwebservices.com.cn", implicitGlobalRegion: "cn-northwest-1", name: "aws-cn", supportsDualStack: true, supportsFIPS: true }, regionRegex: "^cn\\-\\w+\\-\\d+$", regions: { "aws-cn-global": { description: "aws-cn global region" }, "cn-north-1": { description: "China (Beijing)" }, "cn-northwest-1": { description: "China (Ningxia)" } } }, { id: "aws-eusc", outputs: { dnsSuffix: "amazonaws.eu", dualStackDnsSuffix: "api.amazonwebservices.eu", implicitGlobalRegion: "eusc-de-east-1", name: "aws-eusc", supportsDualStack: true, supportsFIPS: true }, regionRegex: "^eusc\\-(de)\\-\\w+\\-\\d+$", regions: { "eusc-de-east-1": { description: "AWS European Sovereign Cloud (Germany)" } } }, { id: "aws-iso", outputs: { dnsSuffix: "c2s.ic.gov", dualStackDnsSuffix: "api.aws.ic.gov", implicitGlobalRegion: "us-iso-east-1", name: "aws-iso", supportsDualStack: true, supportsFIPS: true }, regionRegex: "^us\\-iso\\-\\w+\\-\\d+$", regions: { "aws-iso-global": { description: "aws-iso global region" }, "us-iso-east-1": { description: "US ISO East" }, "us-iso-west-1": { description: "US ISO WEST" } } }, { id: "aws-iso-b", outputs: { dnsSuffix: "sc2s.sgov.gov", dualStackDnsSuffix: "api.aws.scloud", implicitGlobalRegion: "us-isob-east-1", name: "aws-iso-b", supportsDualStack: true, supportsFIPS: true }, regionRegex: "^us\\-isob\\-\\w+\\-\\d+$", regions: { "aws-iso-b-global": { description: "aws-iso-b global region" }, "us-isob-east-1": { description: "US ISOB East (Ohio)" }, "us-isob-west-1": { description: "US ISOB West" } } }, { id: "aws-iso-e", outputs: { dnsSuffix: "cloud.adc-e.uk", dualStackDnsSuffix: "api.cloud-aws.adc-e.uk", implicitGlobalRegion: "eu-isoe-west-1", name: "aws-iso-e", supportsDualStack: true, supportsFIPS: true }, regionRegex: "^eu\\-isoe\\-\\w+\\-\\d+$", regions: { "aws-iso-e-global": { description: "aws-iso-e global region" }, "eu-isoe-west-1": { description: "EU ISOE West" } } }, { id: "aws-iso-f", outputs: { dnsSuffix: "csp.hci.ic.gov", dualStackDnsSuffix: "api.aws.hci.ic.gov", implicitGlobalRegion: "us-isof-south-1", name: "aws-iso-f", supportsDualStack: true, supportsFIPS: true }, regionRegex: "^us\\-isof\\-\\w+\\-\\d+$", regions: { "aws-iso-f-global": { description: "aws-iso-f global region" }, "us-isof-east-1": { description: "US ISOF EAST" }, "us-isof-south-1": { description: "US ISOF SOUTH" } } }, { id: "aws-us-gov", outputs: { dnsSuffix: "amazonaws.com", dualStackDnsSuffix: "api.aws", implicitGlobalRegion: "us-gov-west-1", name: "aws-us-gov", supportsDualStack: true, supportsFIPS: true }, regionRegex: "^us\\-gov\\-\\w+\\-\\d+$", regions: { "aws-us-gov-global": { description: "aws-us-gov global region" }, "us-gov-east-1": { description: "AWS GovCloud (US-East)" }, "us-gov-west-1": { description: "AWS GovCloud (US-West)" } } }], version: "1.1" };
1448
- var selectedPartitionsInfo = partitionsInfo;
1449
- var selectedUserAgentPrefix = "";
1450
- var partition = (value) => {
1451
- const { partitions } = selectedPartitionsInfo;
1452
- for (const partition2 of partitions) {
1453
- const { regions, outputs } = partition2;
1454
- for (const [region, regionData] of Object.entries(regions)) {
1455
- if (region === value) {
1456
- return {
1457
- ...outputs,
1458
- ...regionData
1459
- };
1460
- }
1461
- }
1462
- }
1463
- for (const partition2 of partitions) {
1464
- const { regionRegex, outputs } = partition2;
1465
- if (new RegExp(regionRegex).test(value)) {
1466
- return {
1467
- ...outputs
1468
- };
1469
- }
1470
- }
1471
- const DEFAULT_PARTITION = partitions.find((partition2) => partition2.id === "aws");
1472
- if (!DEFAULT_PARTITION) {
1473
- throw new Error("Provided region was not found in the partition array or regex," + " and default partition with id 'aws' doesn't exist.");
1474
- }
1475
- return {
1476
- ...DEFAULT_PARTITION.outputs
1477
- };
1478
- };
1479
- var setPartitionInfo = (partitionsInfo2, userAgentPrefix = "") => {
1480
- selectedPartitionsInfo = partitionsInfo2;
1481
- selectedUserAgentPrefix = userAgentPrefix;
1482
- };
1483
- var useDefaultPartitionInfo = () => {
1484
- setPartitionInfo(partitionsInfo, "");
1485
- };
1486
- var getUserAgentPrefix = () => selectedUserAgentPrefix;
1487
- var ACCOUNT_ID_ENDPOINT_REGEX = /\d{12}\.ddb/;
1488
- async function checkFeatures(context, config2, args) {
1489
- const request = args.request;
1490
- if (request?.headers?.["smithy-protocol"] === "rpc-v2-cbor") {
1491
- setFeature(context, "PROTOCOL_RPC_V2_CBOR", "M");
1492
- }
1493
- if (typeof config2.retryStrategy === "function") {
1494
- const retryStrategy = await config2.retryStrategy();
1495
- if (typeof retryStrategy.mode === "string") {
1496
- switch (retryStrategy.mode) {
1497
- case retry.RETRY_MODES.ADAPTIVE:
1498
- setFeature(context, "RETRY_MODE_ADAPTIVE", "F");
1499
- break;
1500
- case retry.RETRY_MODES.STANDARD:
1501
- setFeature(context, "RETRY_MODE_STANDARD", "E");
1502
- break;
1503
- }
1504
- }
1505
- }
1506
- if (typeof config2.accountIdEndpointMode === "function") {
1507
- const endpointV2 = context.endpointV2;
1508
- if (String(endpointV2?.url?.hostname).match(ACCOUNT_ID_ENDPOINT_REGEX)) {
1509
- setFeature(context, "ACCOUNT_ID_ENDPOINT", "O");
1510
- }
1511
- switch (await config2.accountIdEndpointMode?.()) {
1512
- case "disabled":
1513
- setFeature(context, "ACCOUNT_ID_MODE_DISABLED", "Q");
1514
- break;
1515
- case "preferred":
1516
- setFeature(context, "ACCOUNT_ID_MODE_PREFERRED", "P");
1517
- break;
1518
- case "required":
1519
- setFeature(context, "ACCOUNT_ID_MODE_REQUIRED", "R");
1520
- break;
1521
- }
1522
- }
1523
- const identity = context.__smithy_context?.selectedHttpAuthScheme?.identity;
1524
- if (identity?.$source) {
1525
- const credentials = identity;
1526
- if (credentials.accountId) {
1527
- setFeature(context, "RESOLVED_ACCOUNT_ID", "T");
1528
- }
1529
- for (const [key, value] of Object.entries(credentials.$source ?? {})) {
1530
- setFeature(context, key, value);
1531
- }
1532
- }
1533
- }
1534
- var USER_AGENT = "user-agent";
1535
- var X_AMZ_USER_AGENT = "x-amz-user-agent";
1536
- var SPACE = " ";
1537
- var UA_NAME_SEPARATOR = "/";
1538
- var UA_NAME_ESCAPE_REGEX = /[^!$%&'*+\-.^_`|~\w]/g;
1539
- var UA_VALUE_ESCAPE_REGEX = /[^!$%&'*+\-.^_`|~\w#]/g;
1540
- var UA_ESCAPE_CHAR = "-";
1541
- var BYTE_LIMIT = 1024;
1542
- function encodeFeatures(features) {
1543
- let buffer = "";
1544
- for (const key in features) {
1545
- const val = features[key];
1546
- if (buffer.length + val.length + 1 <= BYTE_LIMIT) {
1547
- if (buffer.length) {
1548
- buffer += "," + val;
1549
- } else {
1550
- buffer += val;
1551
- }
1552
- continue;
1553
- }
1554
- break;
1555
- }
1556
- return buffer;
1557
- }
1558
- var userAgentMiddleware = (options) => (next, context) => async (args) => {
1559
- const { request } = args;
1560
- if (!protocols.HttpRequest.isInstance(request)) {
1561
- return next(args);
1562
- }
1563
- const { headers } = request;
1564
- const userAgent = context?.userAgent?.map(escapeUserAgent) || [];
1565
- const defaultUserAgent2 = (await options.defaultUserAgentProvider()).map(escapeUserAgent);
1566
- await checkFeatures(context, options, args);
1567
- const awsContext = context;
1568
- defaultUserAgent2.push(`m/${encodeFeatures(Object.assign({}, context.__smithy_context?.features, awsContext.__aws_sdk_context?.features))}`);
1569
- const customUserAgent = options?.customUserAgent?.map(escapeUserAgent) || [];
1570
- const appId = await options.userAgentAppId();
1571
- if (appId) {
1572
- defaultUserAgent2.push(escapeUserAgent([`app`, `${appId}`]));
1573
- }
1574
- const prefix = getUserAgentPrefix();
1575
- const sdkUserAgentValue = (prefix ? [prefix] : []).concat([...defaultUserAgent2, ...userAgent, ...customUserAgent]).join(SPACE);
1576
- const normalUAValue = [
1577
- ...defaultUserAgent2.filter((section) => section.startsWith("aws-sdk-")),
1578
- ...customUserAgent
1579
- ].join(SPACE);
1580
- if (options.runtime !== "browser") {
1581
- if (normalUAValue) {
1582
- headers[X_AMZ_USER_AGENT] = headers[X_AMZ_USER_AGENT] ? `${headers[USER_AGENT]} ${normalUAValue}` : normalUAValue;
1583
- }
1584
- headers[USER_AGENT] = sdkUserAgentValue;
1585
- } else {
1586
- headers[X_AMZ_USER_AGENT] = sdkUserAgentValue;
1587
- }
1588
- return next({
1589
- ...args,
1590
- request
1591
- });
1592
- };
1593
- var escapeUserAgent = (userAgentPair) => {
1594
- const name = userAgentPair[0].split(UA_NAME_SEPARATOR).map((part) => part.replace(UA_NAME_ESCAPE_REGEX, UA_ESCAPE_CHAR)).join(UA_NAME_SEPARATOR);
1595
- const version = userAgentPair[1]?.replace(UA_VALUE_ESCAPE_REGEX, UA_ESCAPE_CHAR);
1596
- const prefixSeparatorIndex = name.indexOf(UA_NAME_SEPARATOR);
1597
- const prefix = name.substring(0, prefixSeparatorIndex);
1598
- let uaName = name.substring(prefixSeparatorIndex + 1);
1599
- if (prefix === "api") {
1600
- uaName = uaName.toLowerCase();
1601
- }
1602
- return [prefix, uaName, version].filter((item) => item && item.length > 0).reduce((acc, item, index) => {
1603
- switch (index) {
1604
- case 0:
1605
- return item;
1606
- case 1:
1607
- return `${acc}/${item}`;
1608
- default:
1609
- return `${acc}#${item}`;
1610
- }
1611
- }, "");
1612
- };
1613
- var getUserAgentMiddlewareOptions = {
1614
- name: "getUserAgentMiddleware",
1615
- step: "build",
1616
- priority: "low",
1617
- tags: ["SET_USER_AGENT", "USER_AGENT"],
1618
- override: true
1619
- };
1620
- var getUserAgentPlugin = (config2) => ({
1621
- applyToStack: (clientStack) => {
1622
- clientStack.add(userAgentMiddleware(config2), getUserAgentMiddlewareOptions);
1623
- }
1624
- });
1625
- var getRuntimeUserAgentPair = () => {
1626
- const runtimesToCheck = ["deno", "bun", "llrt"];
1627
- for (const runtime of runtimesToCheck) {
1628
- if (node_process.versions[runtime]) {
1629
- return [`md/${runtime}`, node_process.versions[runtime]];
1630
- }
1631
- }
1632
- return ["md/nodejs", node_process.versions.node];
1633
- };
1634
- var getNodeModulesParentDirs = (dirname) => {
1635
- const cwd = process.cwd();
1636
- if (!dirname) {
1637
- return [cwd];
1638
- }
1639
- const normalizedPath = node_path.normalize(dirname);
1640
- const parts = normalizedPath.split(node_path.sep);
1641
- const nodeModulesIndex = parts.indexOf("node_modules");
1642
- const parentDir = nodeModulesIndex !== -1 ? parts.slice(0, nodeModulesIndex).join(node_path.sep) : normalizedPath;
1643
- if (cwd === parentDir) {
1644
- return [cwd];
1645
- }
1646
- return [parentDir, cwd];
1647
- };
1648
- var SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/;
1649
- var getSanitizedTypeScriptVersion = (version = "") => {
1650
- const match = version.match(SEMVER_REGEX);
1651
- if (!match) {
1652
- return;
1653
- }
1654
- const [major, minor, patch, prerelease] = [match[1], match[2], match[3], match[4]];
1655
- return prerelease ? `${major}.${minor}.${patch}-${prerelease}` : `${major}.${minor}.${patch}`;
1656
- };
1657
- var ALLOWED_PREFIXES = ["^", "~", ">=", "<=", ">", "<"];
1658
- var ALLOWED_DIST_TAGS = ["latest", "beta", "dev", "rc", "insiders", "next"];
1659
- var getSanitizedDevTypeScriptVersion = (version = "") => {
1660
- if (ALLOWED_DIST_TAGS.includes(version)) {
1661
- return version;
1662
- }
1663
- const prefix = ALLOWED_PREFIXES.find((p) => version.startsWith(p)) ?? "";
1664
- const sanitizedTypeScriptVersion = getSanitizedTypeScriptVersion(version.slice(prefix.length));
1665
- if (!sanitizedTypeScriptVersion) {
1666
- return;
1667
- }
1668
- return `${prefix}${sanitizedTypeScriptVersion}`;
1669
- };
1670
- var tscVersion;
1671
- var TS_PACKAGE_JSON = node_path.join("node_modules", "typescript", "package.json");
1672
- var getTypeScriptUserAgentPair = async () => {
1673
- if (tscVersion === null) {
1674
- return;
1675
- } else if (typeof tscVersion === "string") {
1676
- return ["md/tsc", tscVersion];
1677
- }
1678
- let isTypeScriptDetectionDisabled = false;
1679
- try {
1680
- isTypeScriptDetectionDisabled = config.booleanSelector(process.env, "AWS_SDK_JS_TYPESCRIPT_DETECTION_DISABLED", config.SelectorType.ENV) || false;
1681
- } catch {}
1682
- if (isTypeScriptDetectionDisabled) {
1683
- tscVersion = null;
1684
- return;
1685
- }
1686
- const dirname = typeof __dirname !== "undefined" ? __dirname : undefined;
1687
- const nodeModulesParentDirs = getNodeModulesParentDirs(dirname);
1688
- let versionFromApp;
1689
- for (const nodeModulesParentDir of nodeModulesParentDirs) {
1690
- try {
1691
- const appPackageJsonPath = node_path.join(nodeModulesParentDir, "package.json");
1692
- const packageJson = await promises.readFile(appPackageJsonPath, "utf-8");
1693
- const { dependencies, devDependencies } = JSON.parse(packageJson);
1694
- const version = devDependencies?.typescript ?? dependencies?.typescript;
1695
- if (typeof version !== "string") {
1696
- continue;
1697
- }
1698
- versionFromApp = version;
1699
- break;
1700
- } catch {}
1701
- }
1702
- if (!versionFromApp) {
1703
- tscVersion = null;
1704
- return;
1705
- }
1706
- let versionFromNodeModules;
1707
- for (const nodeModulesParentDir of nodeModulesParentDirs) {
1708
- try {
1709
- const tsPackageJsonPath = node_path.join(nodeModulesParentDir, TS_PACKAGE_JSON);
1710
- const packageJson = await promises.readFile(tsPackageJsonPath, "utf-8");
1711
- const { version } = JSON.parse(packageJson);
1712
- const sanitizedVersion2 = getSanitizedTypeScriptVersion(version);
1713
- if (typeof sanitizedVersion2 !== "string") {
1714
- continue;
1715
- }
1716
- versionFromNodeModules = sanitizedVersion2;
1717
- break;
1718
- } catch {}
1719
- }
1720
- if (versionFromNodeModules) {
1721
- tscVersion = versionFromNodeModules;
1722
- return ["md/tsc", tscVersion];
1723
- }
1724
- const sanitizedVersion = getSanitizedDevTypeScriptVersion(versionFromApp);
1725
- if (typeof sanitizedVersion !== "string") {
1726
- tscVersion = null;
1727
- return;
1728
- }
1729
- tscVersion = `dev_${sanitizedVersion}`;
1730
- return ["md/tsc", tscVersion];
1731
- };
1732
- var crtAvailability = {
1733
- isCrtAvailable: false
1734
- };
1735
- var isCrtAvailable = () => {
1736
- if (crtAvailability.isCrtAvailable) {
1737
- return ["md/crt-avail"];
1738
- }
1739
- return null;
1740
- };
1741
- var createDefaultUserAgentProvider = ({ serviceId, clientVersion }) => {
1742
- const runtimeUserAgentPair = getRuntimeUserAgentPair();
1743
- return async (config2) => {
1744
- const sections = [
1745
- ["aws-sdk-js", clientVersion],
1746
- ["ua", "2.1"],
1747
- [`os/${node_os.platform()}`, node_os.release()],
1748
- ["lang/js"],
1749
- runtimeUserAgentPair
1750
- ];
1751
- const typescriptUserAgentPair = await getTypeScriptUserAgentPair();
1752
- if (typescriptUserAgentPair) {
1753
- sections.push(typescriptUserAgentPair);
1754
- }
1755
- const crtAvailable = isCrtAvailable();
1756
- if (crtAvailable) {
1757
- sections.push(crtAvailable);
1758
- }
1759
- if (serviceId) {
1760
- sections.push([`api/${serviceId}`, clientVersion]);
1761
- }
1762
- if (node_process.env.AWS_EXECUTION_ENV) {
1763
- sections.push([`exec-env/${node_process.env.AWS_EXECUTION_ENV}`]);
1764
- }
1765
- const appId = await config2?.userAgentAppId?.();
1766
- const resolvedUserAgent = appId ? [...sections, [`app/${appId}`]] : [...sections];
1767
- return resolvedUserAgent;
1768
- };
1769
- };
1770
- var defaultUserAgent = createDefaultUserAgentProvider;
1771
- var UA_APP_ID_ENV_NAME = "AWS_SDK_UA_APP_ID";
1772
- var UA_APP_ID_INI_NAME = "sdk_ua_app_id";
1773
- var UA_APP_ID_INI_NAME_DEPRECATED = "sdk-ua-app-id";
1774
- var NODE_APP_ID_CONFIG_OPTIONS = {
1775
- environmentVariableSelector: (env) => env[UA_APP_ID_ENV_NAME],
1776
- configFileSelector: (profile) => profile[UA_APP_ID_INI_NAME] ?? profile[UA_APP_ID_INI_NAME_DEPRECATED],
1777
- default: DEFAULT_UA_APP_ID
1778
- };
1779
- var createUserAgentStringParsingProvider = ({ serviceId, clientVersion }) => async (config2) => {
1780
- const module2 = await import("./es5-tj3tn4jj.js").then((m)=>__toESM(m.default));
1781
- const parse = module2.parse ?? module2.default.parse ?? (() => "");
1782
- const parsedUA = typeof window !== "undefined" && window?.navigator?.userAgent ? parse(window.navigator.userAgent) : undefined;
1783
- const sections = [
1784
- ["aws-sdk-js", clientVersion],
1785
- ["ua", "2.1"],
1786
- [`os/${parsedUA?.os?.name || "other"}`, parsedUA?.os?.version],
1787
- ["lang/js"],
1788
- ["md/browser", `${parsedUA?.browser?.name ?? "unknown"}_${parsedUA?.browser?.version ?? "unknown"}`]
1789
- ];
1790
- if (serviceId) {
1791
- sections.push([`api/${serviceId}`, clientVersion]);
1792
- }
1793
- const appId = await config2?.userAgentAppId?.();
1794
- if (appId) {
1795
- sections.push([`app/${appId}`]);
1796
- }
1797
- return sections;
1798
- };
1799
- var fallback = {
1800
- os(ua) {
1801
- if (/iPhone|iPad|iPod/.test(ua))
1802
- return "iOS";
1803
- if (/Macintosh|Mac OS X/.test(ua))
1804
- return "macOS";
1805
- if (/Windows NT/.test(ua))
1806
- return "Windows";
1807
- if (/Android/.test(ua))
1808
- return "Android";
1809
- if (/Linux/.test(ua))
1810
- return "Linux";
1811
- return;
1812
- },
1813
- browser(ua) {
1814
- if (/EdgiOS|EdgA|Edg\//.test(ua))
1815
- return "Microsoft Edge";
1816
- if (/Firefox\//.test(ua))
1817
- return "Firefox";
1818
- if (/Chrome\//.test(ua))
1819
- return "Chrome";
1820
- if (/Safari\//.test(ua))
1821
- return "Safari";
1822
- return;
1823
- }
1824
- };
1825
- var isVirtualHostableS3Bucket = (value, allowSubDomains = false) => {
1826
- if (allowSubDomains) {
1827
- for (const label of value.split(".")) {
1828
- if (!isVirtualHostableS3Bucket(label)) {
1829
- return false;
1830
- }
1831
- }
1832
- return true;
1833
- }
1834
- if (!endpoints.isValidHostLabel(value)) {
1835
- return false;
1836
- }
1837
- if (value.length < 3 || value.length > 63) {
1838
- return false;
1839
- }
1840
- if (value !== value.toLowerCase()) {
1841
- return false;
1842
- }
1843
- if (endpoints.isIpAddress(value)) {
1844
- return false;
1845
- }
1846
- return true;
1847
- };
1848
- var ARN_DELIMITER = ":";
1849
- var RESOURCE_DELIMITER = "/";
1850
- var parseArn = (value) => {
1851
- const segments = value.split(ARN_DELIMITER);
1852
- if (segments.length < 6)
1853
- return null;
1854
- const [arn, partition2, service, region, accountId, ...resourcePath] = segments;
1855
- if (arn !== "arn" || partition2 === "" || service === "" || resourcePath.join(ARN_DELIMITER) === "")
1856
- return null;
1857
- const resourceId = resourcePath.map((resource) => resource.split(RESOURCE_DELIMITER)).flat();
1858
- return {
1859
- partition: partition2,
1860
- service,
1861
- region,
1862
- accountId,
1863
- resourceId
1864
- };
1865
- };
1866
- var awsEndpointFunctions = {
1867
- isVirtualHostableS3Bucket,
1868
- parseArn,
1869
- partition
1870
- };
1871
- endpoints.customEndpointFunctions.aws = awsEndpointFunctions;
1872
- var resolveDefaultAwsRegionalEndpointsConfig = (input) => {
1873
- if (typeof input.endpointProvider !== "function") {
1874
- throw new Error("@aws-sdk/util-endpoint - endpointProvider and endpoint missing in config for this client.");
1875
- }
1876
- const { endpoint } = input;
1877
- if (endpoint === undefined) {
1878
- input.endpoint = async () => {
1879
- return toEndpointV1(input.endpointProvider({
1880
- Region: typeof input.region === "function" ? await input.region() : input.region,
1881
- UseDualStack: typeof input.useDualstackEndpoint === "function" ? await input.useDualstackEndpoint() : input.useDualstackEndpoint,
1882
- UseFIPS: typeof input.useFipsEndpoint === "function" ? await input.useFipsEndpoint() : input.useFipsEndpoint,
1883
- Endpoint: undefined
1884
- }, { logger: input.logger }));
1885
- };
1886
- }
1887
- return input;
1888
- };
1889
- var toEndpointV1 = (endpoint) => protocols.parseUrl(endpoint.url);
1890
- function stsRegionDefaultResolver(loaderConfig = {}) {
1891
- return config.loadConfig({
1892
- ...config.NODE_REGION_CONFIG_OPTIONS,
1893
- async default() {
1894
- if (!warning.silence) {
1895
- console.warn("@aws-sdk - WARN - default STS region of us-east-1 used. See @aws-sdk/credential-providers README and set a region explicitly.");
1896
- }
1897
- return "us-east-1";
1898
- }
1899
- }, { ...config.NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig });
1900
- }
1901
- var warning = {
1902
- silence: false
1903
- };
1904
- var getAwsRegionExtensionConfiguration = (runtimeConfig) => {
1905
- return {
1906
- setRegion(region) {
1907
- runtimeConfig.region = region;
1908
- },
1909
- region() {
1910
- return runtimeConfig.region;
1911
- }
1912
- };
1913
- };
1914
- var resolveAwsRegionExtensionConfiguration = (awsRegionExtensionConfiguration) => {
1915
- return {
1916
- region: awsRegionExtensionConfiguration.region()
1917
- };
1918
- };
1919
- exports.NODE_REGION_CONFIG_FILE_OPTIONS = config.NODE_REGION_CONFIG_FILE_OPTIONS;
1920
- exports.NODE_REGION_CONFIG_OPTIONS = config.NODE_REGION_CONFIG_OPTIONS;
1921
- exports.REGION_ENV_NAME = config.REGION_ENV_NAME;
1922
- exports.REGION_INI_NAME = config.REGION_INI_NAME;
1923
- exports.resolveRegionConfig = config.resolveRegionConfig;
1924
- exports.EndpointError = endpoints.EndpointError;
1925
- exports.isIpAddress = endpoints.isIpAddress;
1926
- exports.resolveEndpoint = endpoints.resolveEndpoint;
1927
- exports.DEFAULT_UA_APP_ID = DEFAULT_UA_APP_ID;
1928
- exports.NODE_APP_ID_CONFIG_OPTIONS = NODE_APP_ID_CONFIG_OPTIONS;
1929
- exports.UA_APP_ID_ENV_NAME = UA_APP_ID_ENV_NAME;
1930
- exports.UA_APP_ID_INI_NAME = UA_APP_ID_INI_NAME;
1931
- exports.awsEndpointFunctions = awsEndpointFunctions;
1932
- exports.createDefaultUserAgentProvider = createDefaultUserAgentProvider;
1933
- exports.createUserAgentStringParsingProvider = createUserAgentStringParsingProvider;
1934
- exports.crtAvailability = crtAvailability;
1935
- exports.defaultUserAgent = defaultUserAgent;
1936
- exports.emitWarningIfUnsupportedVersion = emitWarningIfUnsupportedVersion;
1937
- exports.fallback = fallback;
1938
- exports.getAwsRegionExtensionConfiguration = getAwsRegionExtensionConfiguration;
1939
- exports.getHostHeaderPlugin = getHostHeaderPlugin;
1940
- exports.getLoggerPlugin = getLoggerPlugin;
1941
- exports.getLongPollPlugin = getLongPollPlugin;
1942
- exports.getRecursionDetectionPlugin = getRecursionDetectionPlugin;
1943
- exports.getUserAgentMiddlewareOptions = getUserAgentMiddlewareOptions;
1944
- exports.getUserAgentPlugin = getUserAgentPlugin;
1945
- exports.getUserAgentPrefix = getUserAgentPrefix;
1946
- exports.hostHeaderMiddleware = hostHeaderMiddleware;
1947
- exports.hostHeaderMiddlewareOptions = hostHeaderMiddlewareOptions;
1948
- exports.isVirtualHostableS3Bucket = isVirtualHostableS3Bucket;
1949
- exports.loggerMiddleware = loggerMiddleware;
1950
- exports.loggerMiddlewareOptions = loggerMiddlewareOptions;
1951
- exports.parseArn = parseArn;
1952
- exports.partition = partition;
1953
- exports.recursionDetectionMiddleware = recursionDetectionMiddleware;
1954
- exports.recursionDetectionMiddlewareOptions = recursionDetectionMiddlewareOptions;
1955
- exports.resolveAwsRegionExtensionConfiguration = resolveAwsRegionExtensionConfiguration;
1956
- exports.resolveDefaultAwsRegionalEndpointsConfig = resolveDefaultAwsRegionalEndpointsConfig;
1957
- exports.resolveHostHeaderConfig = resolveHostHeaderConfig;
1958
- exports.resolveUserAgentConfig = resolveUserAgentConfig;
1959
- exports.setCredentialFeature = setCredentialFeature;
1960
- exports.setFeature = setFeature;
1961
- exports.setPartitionInfo = setPartitionInfo;
1962
- exports.setTokenFeature = setTokenFeature;
1963
- exports.state = state;
1964
- exports.stsRegionDefaultResolver = stsRegionDefaultResolver;
1965
- exports.stsRegionWarning = warning;
1966
- exports.toEndpointV1 = toEndpointV1;
1967
- exports.useDefaultPartitionInfo = useDefaultPartitionInfo;
1968
- exports.userAgentMiddleware = userAgentMiddleware;
1969
- });
1970
-
1971
- export { require_retry, require_dist_cjs2 as require_dist_cjs, require_client2 as require_client };