@desplega.ai/agent-swarm 2.14.0 → 2.14.2
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.
- package/dist/acp-adapter-q1vz4hh2.js +17 -0
- package/dist/{acp-targets-23exz4z4.js → acp-targets-d44eerh4.js} +10 -10
- package/dist/{actions-zcr25x27.js → actions-z4k4bvss.js} +28 -28
- package/dist/{agent-fs-provision-7fa9e12e.js → agent-fs-provision-aan1cgpx.js} +4 -4
- package/dist/{amp-adapter-s7ytmv6b.js → amp-adapter-wac3py0p.js} +3 -3
- package/dist/{anthropic-messages-vdd1zmha.js → anthropic-messages-njt2r5m4.js} +28 -27
- package/dist/{app-5d3sz1hy.js → app-wax6qz5e.js} +10 -10
- package/dist/{approval-notifications-7qgkzkzx.js → approval-notifications-6fvkhnma.js} +11 -11
- package/dist/{assistant-p2yvhc3j.js → assistant-e8fe08zx.js} +29 -29
- package/dist/{azure-openai-responses-jeaas6x0.js → azure-openai-responses-6ewf9rwp.js} +6 -6
- package/dist/{boot-args-schema-ry6cb0p7.js → boot-args-schema-rv97cmnt.js} +1 -1
- package/dist/{boot-reembed-c9643ms3.js → boot-reembed-bcn7frk9.js} +1 -1
- package/dist/{boot-reembed-2hkm3vz2.js → boot-reembed-xakrdy6y.js} +1 -1
- package/dist/{boot-scrub-sweep-3ycxr51t.js → boot-scrub-sweep-20t8akhf.js} +2 -2
- package/dist/{boot-seeds-2hzvvzg0.js → boot-seeds-48rr6r29.js} +4 -4
- package/dist/{boxd-9py3x0jb.js → boxd-tjpxwecx.js} +3 -3
- package/dist/{claude-adapter-dnkww93e.js → claude-adapter-0wzwntrj.js} +12 -13
- package/dist/{claude-managed-adapter-yk0cr5x6.js → claude-managed-adapter-4xcgt46w.js} +4 -4
- package/dist/{claude-managed-setup-4byxpp47.js → claude-managed-setup-91cyktw7.js} +7 -7
- package/dist/{claude-sdk-session-4wf3dbvs.js → claude-sdk-session-ngj4dce5.js} +11144 -12464
- package/dist/{cli-gcyws2bp.js → cli-021hrewp.js} +2 -2
- package/dist/{cli-wvgg7r4j.js → cli-08gfvs58.js} +2 -2
- package/dist/{cli-2zjxake1.js → cli-0kyjrbaa.js} +4 -4
- package/dist/{cli-rp1n2xpd.js → cli-0nvqg1hb.js} +1 -1
- package/dist/{cli-vxmmttmt.js → cli-0nz04gqv.js} +50 -50
- package/dist/{cli-vr4eyq6p.js → cli-0rrft7s3.js} +538 -410
- package/dist/{cli-mw1tmn3x.js → cli-1d9q7qrn.js} +7 -7
- package/dist/{cli-84xn7bgz.js → cli-1t5vhrpv.js} +1 -1
- package/dist/{cli-hzhv7yac.js → cli-1zbj28py.js} +1 -1
- package/dist/{cli-z8t4485r.js → cli-2ja7eadd.js} +2 -2
- package/dist/{cli-r04ve9xw.js → cli-2r62jy9s.js} +1 -1
- package/dist/{cli-9fwznq4p.js → cli-3ffzr65w.js} +7 -7
- package/dist/{cli-2ckwgs7q.js → cli-3kdgm393.js} +5 -5
- package/dist/{cli-jwnac23b.js → cli-3vc518cw.js} +1 -1
- package/dist/{cli-6p8p2e6r.js → cli-5188hq0a.js} +1286 -31
- package/dist/{cli-zcghfsdg.js → cli-53gt8wfv.js} +1 -1
- package/dist/{cli-930zbczq.js → cli-5njmmmer.js} +3 -3
- package/dist/{cli-dw9rtjm3.js → cli-5rw7nt99.js} +3061 -727
- package/dist/{cli-6c61yjwy.js → cli-5xx353cy.js} +7554 -1534
- package/dist/{cli-2ap1the6.js → cli-65k149j5.js} +2 -2
- package/dist/{cli-v41kn3cd.js → cli-6prwz0zn.js} +4427 -5566
- package/dist/{cli-yd7e590v.js → cli-6zpn5hmp.js} +12 -12
- package/dist/{cli-ty3gha1p.js → cli-7b9bwrfg.js} +2 -2
- package/dist/{cli-2414h5r9.js → cli-7dpdq7yh.js} +11428 -1914
- package/dist/{cli-r9d2tya0.js → cli-7qkbab03.js} +5 -5
- package/dist/{cli-7ca8hczj.js → cli-7svwhw1a.js} +1 -1
- package/dist/cli-7wwewkf4.js +37 -0
- package/dist/{cli-ejnhs815.js → cli-83hynhes.js} +17 -13
- package/dist/{cli-rs1rzwp4.js → cli-8crn0510.js} +1 -1
- package/dist/{cli-f2rwt43y.js → cli-8ee7xt75.js} +13 -13
- package/dist/{cli-9j47sgzy.js → cli-8ef94zm2.js} +2 -2
- package/dist/{cli-9fvk9mv8.js → cli-8gr1bg9t.js} +1 -1
- package/dist/{cli-b0m3bg0f.js → cli-9j1qcs0b.js} +1 -1
- package/dist/{cli-ad00h1st.js → cli-9mvfvggt.js} +7 -7
- package/dist/{cli-xh5fpmg8.js → cli-9txap41q.js} +101 -18
- package/dist/{cli-24wervhz.js → cli-aktk3qt6.js} +3 -3
- package/dist/{cli-6ajyhxh7.js → cli-an8bpy60.js} +2 -2
- package/dist/{cli-meydjstb.js → cli-azptj8xe.js} +5591 -69
- package/dist/cli-c0rt16vk.js +15 -0
- package/dist/{cli-w4bvtxet.js → cli-c6vhcknq.js} +7 -7
- package/dist/{cli-2savn6mm.js → cli-cczffwak.js} +7 -7
- package/dist/{cli-ze1ndjs4.js → cli-cgmka83w.js} +3 -3
- package/dist/{cli-kc7vd07m.js → cli-d13qgcct.js} +3699 -1733
- package/dist/{cli-k3facve0.js → cli-d5nvy1jy.js} +1 -1
- package/dist/{cli-edxfzgah.js → cli-dev6f0px.js} +4 -4
- package/dist/{cli-0e914dp9.js → cli-dzhht0vq.js} +3 -3
- package/dist/{cli-m0ea8ggd.js → cli-e13kbyq0.js} +2 -2
- package/dist/{cli-73rmgm45.js → cli-e2k0ej0d.js} +2 -2
- package/dist/cli-ek8b88kv.js +9740 -0
- package/dist/{cli-0k7ppk9k.js → cli-ertcjw6z.js} +281 -46
- package/dist/{cli-qrwjk4xy.js → cli-f3ta4e67.js} +5 -5
- package/dist/{cli-1nfabrt4.js → cli-f4xv7s0t.js} +7 -7
- package/dist/{cli-phe2vcw5.js → cli-fdam1t9b.js} +171 -104
- package/dist/{cli-gc6b94tj.js → cli-fe8he9cy.js} +2 -2
- package/dist/{cli-spfz393q.js → cli-feh37wgs.js} +598 -219
- package/dist/{cli-ebqx630g.js → cli-fjzjtqna.js} +35 -18
- package/dist/{cli-37p61fcg.js → cli-fs9t2m2k.js} +18 -20
- package/dist/{cli-7w1fs01q.js → cli-g03x26q6.js} +2 -2
- package/dist/{cli-879txsac.js → cli-gnkzh8ed.js} +4 -4
- package/dist/{cli-v4z5v3jd.js → cli-gy0r7gb8.js} +514 -337
- package/dist/{cli-s4pccby1.js → cli-h0edykd1.js} +1 -1
- package/dist/{cli-pq0kv31y.js → cli-h364asjc.js} +9 -9
- package/dist/{cli-69szn7w7.js → cli-h3xcfp4c.js} +93 -54
- package/dist/{cli-jcnc5ret.js → cli-h8k5801a.js} +73 -27
- package/dist/{cli-6yy4fepf.js → cli-h96yp7xv.js} +4 -4
- package/dist/{cli-q5n3deaf.js → cli-hab0bvrh.js} +1 -1
- package/dist/{cli-g6a696c0.js → cli-j3wqt73b.js} +4 -4
- package/dist/{cli-wym6rxgt.js → cli-jfgaz10x.js} +10 -15
- package/dist/{cli-shyhb4t5.js → cli-jrhvywah.js} +53 -52
- package/dist/{cli-qkbevqer.js → cli-jrxt5j0n.js} +3 -3
- package/dist/{cli-7b7rxz22.js → cli-jw7n9pct.js} +5 -2
- package/dist/{cli-8vbxjzk0.js → cli-k9kfck3s.js} +3 -3
- package/dist/{cli-yjb3cddd.js → cli-kkwq5b12.js} +1 -1
- package/dist/{cli-39t9d248.js → cli-kz8rar0g.js} +1 -1
- package/dist/{cli-rzbsh6bw.js → cli-n15fhd43.js} +1 -1
- package/dist/{cli-1jx0srjt.js → cli-nc842kc9.js} +1921 -80
- package/dist/{cli-9j1t3kf6.js → cli-nmj4phcg.js} +2 -2
- package/dist/{cli-t9pzz2eq.js → cli-ntmjzyte.js} +4 -1
- package/dist/{cli-adzmmcvf.js → cli-praaw1wh.js} +2 -2
- package/dist/{cli-f9g96z28.js → cli-q44p4869.js} +11 -11
- package/dist/{cli-fww016hh.js → cli-q58qt9dw.js} +1711 -7287
- package/dist/{cli-njvpngc6.js → cli-qqz5z36e.js} +3 -3
- package/dist/{cli-096aftq6.js → cli-r7rpy2xz.js} +7 -7
- package/dist/cli-rcqgr0hs.js +30 -0
- package/dist/{cli-ph95yejc.js → cli-rjc464jg.js} +2 -2
- package/dist/{cli-md4tn21h.js → cli-rw3m83j4.js} +40 -26
- package/dist/cli-rwcj6wt3.js +1291 -0
- package/dist/{cli-srq69pn1.js → cli-ryn4y478.js} +1 -1
- package/dist/{cli-jgq9xptq.js → cli-s48k2rzx.js} +4 -4
- package/dist/{cli-cbg0j1yt.js → cli-s90wcbk9.js} +3 -3
- package/dist/{cli-2ayk9gn8.js → cli-svcy72s5.js} +2 -2
- package/dist/{cli-4dyzzkfb.js → cli-swtwbg85.js} +944 -170
- package/dist/{cli-mv8ft7b0.js → cli-t1bqpzgz.js} +3 -3
- package/dist/{cli-tc165vrb.js → cli-t5jbjq61.js} +4 -3
- package/dist/{cli-enavhq6r.js → cli-tbrjvrrg.js} +1 -1
- package/dist/{cli-mz7ycqn8.js → cli-td2h8zej.js} +6 -6
- package/dist/{cli-9t7syepg.js → cli-ttatvwn6.js} +1 -1
- package/dist/{cli-ayxxkk3p.js → cli-txxcf9s1.js} +8 -8
- package/dist/{cli-q4z9s6zs.js → cli-v7az4d1g.js} +2 -2
- package/dist/cli-vqt44168.js +14 -0
- package/dist/{cli-q457ga28.js → cli-vs9h3vw2.js} +14 -14
- package/dist/{cli-snxhtehz.js → cli-w2fg8kjc.js} +7 -8
- package/dist/{cli-wd7b5hgc.js → cli-w81s97bn.js} +1 -1
- package/dist/{cli-bqfx72e6.js → cli-wkzrknpt.js} +1 -1
- package/dist/{cli-cg1q8ymp.js → cli-wqpvfq2m.js} +1 -1
- package/dist/{cli-kg63yp1r.js → cli-wz7qj1jy.js} +19 -19
- package/dist/{cli-3wsabyt0.js → cli-x5t54ytt.js} +2 -2
- package/dist/{cli-r495stwd.js → cli-xd6ntv7x.js} +2 -2
- package/dist/{cli-wvbaq052.js → cli-xphbv66z.js} +10 -3
- package/dist/{cli-a49frv85.js → cli-xxgqn93n.js} +3753 -1186
- package/dist/{cli-91amj3md.js → cli-z209g721.js} +111 -87
- package/dist/{cli-3mhdmcd4.js → cli-z5andw8k.js} +1 -1
- package/dist/{cli-7g5qj2ca.js → cli-zcb64xzv.js} +1 -1
- package/dist/{cli-0h6m6z5g.js → cli-zr2sc5tr.js} +1 -1
- package/dist/{cli-krk8y8c7.js → cli-zrm0610v.js} +1833 -518
- package/dist/cli.js +73 -73
- package/dist/{cloudflare-workers-ai-system-one-w3m0fbf8.js → cloudflare-workers-ai-system-one-kb0tq22h.js} +2 -2
- package/dist/{codex-adapter-eq61radw.js → codex-adapter-0c1ynrmt.js} +9 -9
- package/dist/{codex-hook-8nmepvz6.js → codex-hook-w5nmtrn2.js} +2 -2
- package/dist/{codex-login-vbd9707w.js → codex-login-67qarfcg.js} +1 -1
- package/dist/{codex-session-runner-rfx355h4.js → codex-session-runner-z4t9z7yy.js} +10 -10
- package/dist/{commands-d1z0sx62.js → commands-h0jxqdhk.js} +3 -3
- package/dist/{controller-9hz6d8x3.js → controller-4ygy66hv.js} +4 -4
- package/dist/{controllers-connect-tz07d2xr.js → controllers-connect-ynbvv8pv.js} +28 -28
- package/dist/core-mj9fzrcm.js +41 -0
- package/dist/{cursor-adapter-ef22ze3j.js → cursor-adapter-9e4d6658.js} +2 -2
- package/dist/{db-gd81d68c.js → db-bg0hxjq1.js} +3 -3
- package/dist/{db-vrckks6q.js → db-q12gmpns.js} +2 -2
- package/dist/{devin-adapter-kdt6a2bh.js → devin-adapter-tn1twrha.js} +1 -1
- package/dist/{devtools-qxfgbsqz.js → devtools-t8my9az6.js} +1 -1
- package/dist/{dispatcher-76as8w2t.js → dispatcher-v5dbfscq.js} +24 -24
- package/dist/{docker-51ta7jsh.js → docker-6007r2fj.js} +2 -2
- package/dist/{dsh-adapter-ypfvcdyz.js → dsh-adapter-z3fneea1.js} +2 -2
- package/dist/{e2b-05kn3kpq.js → e2b-k3kb8b52.js} +4 -4
- package/dist/{e2b-dm9r8hpy.js → e2b-p269awh6.js} +5 -5
- package/dist/{easter-egg-3d-sg21j15g.js → easter-egg-3d-y49v5z90.js} +1 -1
- package/dist/{embedding-space-zsdw37bb.js → embedding-space-mjt5ksq0.js} +5 -5
- package/dist/{embeddings-p4e3e1m6.js → embeddings-td9hgnc5.js} +1 -1
- package/dist/emscripten-module-Q67P5WYC-3sde6cre.js +2458 -0
- package/dist/{event-bus-tvf2grf4.js → event-bus-pawddp92.js} +1 -1
- package/dist/{execute-nztd0af0.js → execute-z8nc8bba.js} +1 -1
- package/dist/{external-channel-717yzn4d.js → external-channel-pjenc2ag.js} +2 -2
- package/dist/ffi-cbfmmtqk.js +85 -0
- package/dist/fx-adapter-pjeztp0n.js +20 -0
- package/dist/getMachineId-bsd-hjs2tbdp.js +36 -0
- package/dist/getMachineId-darwin-kzbvr8s3.js +40 -0
- package/dist/getMachineId-linux-embmcq2c.js +26 -0
- package/dist/getMachineId-unsupported-jvznc6d4.js +20 -0
- package/dist/getMachineId-win-qr8z0b13.js +36 -0
- package/dist/{google-generative-ai-sw77egmr.js → google-generative-ai-tf3w7557.js} +11 -16
- package/dist/{google-vertex-rrw93g8h.js → google-vertex-9pj87bd8.js} +15 -17
- package/dist/grok-adapter-davbhx8t.js +20 -0
- package/dist/handlers-rf130hnp.js +39 -0
- package/dist/heartbeat-9hmvqxk0.js +49 -0
- package/dist/hook-0b1jqs2t.js +21 -0
- package/dist/{hook-ctz0xmp3.js → hook-1n0sjv8p.js} +10 -11
- package/dist/{http-zregegrx.js → http-vykejyjx.js} +432 -170
- package/dist/{index-7dgxveck.js → index-07d66kdm.js} +3 -3
- package/dist/index-0hgjxqz8.js +10584 -0
- package/dist/{index-rz8ve510.js → index-0nt39qwy.js} +2 -2
- package/dist/{index-ym9fgxad.js → index-2xbxq71g.js} +2 -2
- package/dist/{index-42jq9yy3.js → index-3j8hffkb.js} +12327 -7450
- package/dist/index-8w09aggw.js +43 -0
- package/dist/{index-5kx15d19.js → index-b3wy4jzs.js} +1 -1
- package/dist/{index-kzdqn3dd.js → index-dt9vr7tb.js} +3143 -760
- package/dist/{index-maddg9ys.js → index-ezfas4jj.js} +5858 -15337
- package/dist/index-g2jntx15.js +38 -0
- package/dist/{index-x9qf8dg7.js → index-j6sqtb83.js} +105 -75
- package/dist/{index-m6g8q65g.js → index-na0tczq0.js} +9268 -10220
- package/dist/{index-whysn1wf.js → index-p9dkwhwe.js} +1 -1
- package/dist/{index-126v2d0t.js → index-pe2etczf.js} +6 -2918
- package/dist/{index-mtnbhe12.js → index-q60mhcpd.js} +23631 -19921
- package/dist/index-qffex5k4.js +41 -0
- package/dist/index-qrp11tp9.js +4 -0
- package/dist/{index-kdmkfjt7.js → index-ryyrg0d8.js} +3426 -2333
- package/dist/{index-t17p395x.js → index-sf06w57a.js} +13 -13
- package/dist/{index-evay0xyk.js → index-vybnwd5v.js} +1 -1
- package/dist/{index-fdym6ryb.js → index-wsf1f5pe.js} +28 -28
- package/dist/{k8s-ejkk0aw7.js → k8s-mr1r12th.js} +2 -2
- package/dist/{keepalive-zdqay870.js → keepalive-86z0tzzf.js} +4 -4
- package/dist/lead-edmwagkn.js +81 -0
- package/dist/{llama-cpp-classify-yvb8vh7w.js → llama-cpp-classify-wd7htn1x.js} +2 -2
- package/dist/{maintenance-t5ndg11m.js → maintenance-19h6tfwz.js} +1 -1
- package/dist/{mistral-conversations-w4bncwbt.js → mistral-conversations-txjmc64f.js} +7 -7
- package/dist/module-ES6BEMUI-44w9s1dx.js +1210 -0
- package/dist/{multipart-parser-xevcstye.js → multipart-parser-xqbgwrav.js} +1 -1
- package/dist/{node-0as4n1ef.js → node-q4628t0b.js} +1 -1
- package/dist/{oauth-refresh-sweep-y9zyd7t6.js → oauth-refresh-sweep-6nmyrv32.js} +3 -3
- package/dist/{object-webhooks-mkca91s0.js → object-webhooks-2kynmdf8.js} +7 -7
- package/dist/{onboard-ss995244.js → onboard-zbpm96mn.js} +7 -7
- package/dist/{openai-codex-responses-70g39cgz.js → openai-codex-responses-6ckhys6r.js} +35 -29
- package/dist/{openai-completions-cv3hp4h5.js → openai-completions-c9dsq9jh.js} +15 -15
- package/dist/{openai-decisions-fyq1p9f9.js → openai-decisions-9vzvv10c.js} +2 -2
- package/dist/{openai-responses-trsvnks6.js → openai-responses-bhfmt9sa.js} +6 -6
- package/dist/{opencode-adapter-mwpz0278.js → opencode-adapter-fyqcbdra.js} +8 -8
- package/dist/{openrouter-images-0jj12a2q.js → openrouter-images-hkk5p580.js} +3 -3
- package/dist/otel-impl-txa20w1h.js +11178 -0
- package/dist/{pending-2sxh1t6j.js → pending-4rxawq8y.js} +25 -25
- package/dist/{pi-messages-zk3g4esn.js → pi-messages-py3f96p7.js} +5 -5
- package/dist/{pi-mono-adapter-sfb7zy43.js → pi-mono-adapter-rnsed1xa.js} +24 -27
- package/dist/{pricing-refresh-h79bg4cf.js → pricing-refresh-4314hwtw.js} +2 -2
- package/dist/{rbac-roles-ckq0czp4.js → rbac-roles-fztcm8ky.js} +2 -2
- package/dist/{rbac-roles-jg2e260w.js → rbac-roles-msqt7a3k.js} +3 -3
- package/dist/{render-v2-ymbshmn0.js → render-v2-w49wtecg.js} +10 -10
- package/dist/{resume-jdhnt4jk.js → resume-gwgtp4m3.js} +13 -13
- package/dist/{runtime-y28jhhnf.js → runtime-kkebz8yq.js} +1 -1
- package/dist/{session-access-k4ta5hvp.js → session-access-kjb19m2w.js} +5 -5
- package/dist/{session-source-backfill-528j4s8j.js → session-source-backfill-805p4wqr.js} +3 -3
- package/dist/{setup-d6pj82fr.js → setup-q8y168c8.js} +3 -3
- package/dist/thread-buffer-yqbffd0t.js +40 -0
- package/dist/{token-util-pjgekqxr.js → token-util-hnzceyn9.js} +1 -1
- package/dist/{token-pgr2w4s3.js → token-xnc02n6w.js} +21 -14
- package/dist/{tree-visibility-kjxv3nxk.js → tree-visibility-qj323994.js} +2 -2
- package/dist/{typesafe-system-one-qkvkgrcz.js → typesafe-system-one-avrdb4zm.js} +2 -2
- package/dist/{user-merge-jobs-rabbncf6.js → user-merge-jobs-qfp40f2s.js} +3 -3
- package/dist/{virtual-modules-22k51txd.js → virtual-modules-nzxegw0a.js} +7 -7
- package/dist/{work-objects-xtjbar3r.js → work-objects-hs089w60.js} +26 -26
- package/dist/{worker-follow-up-fg48vk6d.js → worker-follow-up-zwgg20sr.js} +24 -24
- package/dist/worker-kg4g7rnx.js +81 -0
- package/dist/{x-vfsqypht.js → x-k29vmskt.js} +2 -2
- package/openapi.json +59 -3
- package/package.json +53 -52
- package/plugin/commands/create-pr.md +5 -2
- package/plugin/pi-skills/create-pr/SKILL.md +5 -2
- package/src/apps/sync.ts +7 -2
- package/src/be/db/model-profiles.ts +103 -12
- package/src/be/db/tasks/read.ts +5 -0
- package/src/be/db/workflow-runs.ts +12 -8
- package/src/be/db.ts +18 -5
- package/src/be/migrations/367_workflow_run_principal.sql +5 -0
- package/src/be/model-group-resolution.ts +134 -0
- package/src/be/model-tier-resolution.ts +120 -17
- package/src/be/model-validation.ts +9 -1
- package/src/be/runtime-pools/routing.ts +22 -8
- package/src/be/scripts/extract-schema.ts +7 -0
- package/src/be/swarm-config-guard.ts +20 -7
- package/src/be/task-auto-title-listener.ts +2 -2
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/extensions/post-bridge.ts +27 -28
- package/src/http/active-sessions.ts +7 -0
- package/src/http/agents.ts +7 -0
- package/src/http/api-keys.ts +7 -0
- package/src/http/approval-requests.ts +4 -0
- package/src/http/budgets.ts +2 -0
- package/src/http/codex-oauth-keep-warm.ts +6 -2
- package/src/http/config.ts +1 -0
- package/src/http/context.ts +4 -0
- package/src/http/db-query.ts +11 -2
- package/src/http/events.ts +2 -0
- package/src/http/fs.ts +1 -0
- package/src/http/integrations.ts +4 -0
- package/src/http/mcp-bridge.ts +1 -0
- package/src/http/memory.ts +3 -0
- package/src/http/metrics.ts +16 -0
- package/src/http/oauth-locks.ts +8 -0
- package/src/http/operator-actor.ts +3 -8
- package/src/http/page-proxy.ts +16 -0
- package/src/http/pages.ts +9 -0
- package/src/http/poll.ts +21 -1
- package/src/http/pricing.ts +2 -0
- package/src/http/prompt-templates.ts +34 -0
- package/src/http/repos.ts +3 -1
- package/src/http/schedules.ts +33 -3
- package/src/http/script-runs.ts +24 -0
- package/src/http/scripts.ts +1 -0
- package/src/http/session-data.ts +2 -0
- package/src/http/status.ts +1 -0
- package/src/http/tasks.ts +28 -1
- package/src/http/trackers/jira.ts +2 -0
- package/src/http/trackers/linear.ts +4 -0
- package/src/http/users.ts +18 -0
- package/src/http/webhooks.ts +12 -0
- package/src/http/workflow-events.ts +26 -6
- package/src/http/workflows.ts +40 -0
- package/src/http/x.ts +4 -0
- package/src/linear/app.ts +3 -2
- package/src/linear/client.ts +5 -1
- package/src/linear/host.ts +40 -0
- package/src/linear/oauth.ts +3 -2
- package/src/linear/sync.ts +4 -3
- package/src/otel-impl.ts +8 -5
- package/src/prompts/base-prompt.ts +10 -6
- package/src/prompts/session-templates.ts +3 -3
- package/src/providers/acp-targets.ts +1 -1
- package/src/providers/amp-adapter.ts +11 -9
- package/src/providers/cursor-adapter.ts +1 -1
- package/src/rbac/legacy-policy.ts +2 -0
- package/src/rbac/permissions.ts +5 -0
- package/src/realtime/browser.generated.txt +1 -1
- package/src/scheduler/schedule-task.ts +1 -0
- package/src/scripts-runtime/quickjs-compat.ts +44 -10
- package/src/scripts-runtime/types/swarm-extension.d.ts +2 -0
- package/src/slack/config.ts +4 -0
- package/src/slack/render-v2.ts +52 -24
- package/src/slack/responses.ts +2 -1
- package/src/slack/reviewed-deliverables.ts +251 -0
- package/src/tasks/follow-up-gate.ts +142 -38
- package/src/tasks/worker-follow-up.ts +126 -37
- package/src/tests/amp-adapter.test.ts +57 -9
- package/src/tests/base-prompt.test.ts +36 -2
- package/src/tests/check-pr-body.test.ts +408 -93
- package/src/tests/compose-dev-object-store.test.ts +13 -0
- package/src/tests/compose-example-object-store.test.ts +67 -0
- package/src/tests/db-query.test.ts +8 -4
- package/src/tests/db-retention-defaults.test.ts +28 -3
- package/src/tests/e2b-dispatch.test.ts +7 -1
- package/src/tests/entrypoint-repo-autoclone-args.test.ts +10 -0
- package/src/tests/follow-up-gate-shadow.test.ts +268 -10
- package/src/tests/linear-outbound-sync.test.ts +59 -25
- package/src/tests/operator-actor-keyless.test.ts +103 -0
- package/src/tests/otel-event-loop-and-logs.test.ts +1 -1
- package/src/tests/profile-tier-alias.test.ts +9 -3
- package/src/tests/quickjs-compat.test.ts +40 -4
- package/src/tests/rbac-route-verbs-e2e.test.ts +142 -0
- package/src/tests/runner-repo-clone-args.test.ts +15 -6
- package/src/tests/script-connections.test.ts +2 -0
- package/src/tests/slack-render-v2.test.ts +52 -8
- package/src/tests/workflow-definition-pinning.test.ts +2 -0
- package/src/tests/workflow-hitl-routing.test.ts +67 -5
- package/src/tests/workflow-replay.test.ts +13 -1
- package/src/tests/workflow-system-one-extraction.test.ts +21 -0
- package/src/tests/workflow-wait-filter.test.ts +7 -7
- package/src/tests/worktree-reaper.test.ts +15 -4
- package/src/tests/x402-client.test.ts +82 -0
- package/src/tools/memory-rate.ts +2 -2
- package/src/tools/prompt-templates/delete.ts +22 -1
- package/src/tools/prompt-templates/set.ts +15 -1
- package/src/tools/schedules/create-schedule.ts +20 -3
- package/src/tools/schedules/patch-schedule.ts +30 -4
- package/src/tools/schedules/update-schedule.ts +30 -4
- package/src/tools/send-task.ts +17 -3
- package/src/tools/slack-post.ts +7 -2
- package/src/tools/slack-reply.ts +6 -2
- package/src/tools/task-action.ts +16 -3
- package/src/tools/utils.ts +1 -1
- package/src/types.ts +10 -0
- package/src/utils/amp-models.ts +20 -4
- package/src/utils/constants.ts +5 -4
- package/src/utils/secret-scrubber.ts +6 -4
- package/src/utils/task-citations.ts +11 -0
- package/src/workflows/engine.ts +41 -8
- package/src/workflows/executors/agent-task.ts +13 -2
- package/src/workflows/executors/code-match.ts +11 -31
- package/src/workflows/executors/script.ts +13 -0
- package/src/workflows/executors/sub-workflow.ts +5 -7
- package/src/workflows/executors/swarm-script.ts +4 -5
- package/src/workflows/executors/system-one-extraction.ts +9 -6
- package/src/workflows/executors/wait.ts +1 -1
- package/src/workflows/foreach-driver.ts +5 -1
- package/src/workflows/model-validation.ts +13 -1
- package/src/workflows/predicate-sandbox.ts +171 -0
- package/src/workflows/resume.ts +21 -4
- package/src/workflows/retry-poller.ts +1 -1
- package/src/workflows/run-principal.ts +51 -0
- package/src/workflows/wait-filter.ts +14 -192
- package/src/x402/client.ts +38 -17
- package/templates/skills/code-quality/content.md +1 -1
- package/templates/skills/heartbeat-runbook/content.md +1 -0
- package/templates/skills/pages/content.md +36 -12
- package/templates/skills/slack-interaction/content.md +4 -0
- package/templates/skills/swarm-docs/content.md +47 -41
- package/templates/skills/swarm-scripts/SKILL.md +1 -1
- package/templates/skills/swarm-scripts/content.md +1 -1
- package/dist/acp-adapter-99n6z9ky.js +0 -17
- package/dist/cli-5ss6qqt9.js +0 -45
- package/dist/cli-dzzh58sy.js +0 -6996
- package/dist/cli-e8trbfx1.js +0 -15
- package/dist/cli-j9ccfveb.js +0 -1849
- package/dist/cli-mna6pmfx.js +0 -1485
- package/dist/cli-r8ddn0hf.js +0 -25583
- package/dist/core-dynsv289.js +0 -41
- package/dist/fx-adapter-9k0hptnz.js +0 -20
- package/dist/getMachineId-bsd-637a7rbk.js +0 -36
- package/dist/getMachineId-darwin-9vytrcnn.js +0 -36
- package/dist/getMachineId-linux-mkzsvyyz.js +0 -29
- package/dist/getMachineId-unsupported-4cfs2n11.js +0 -19
- package/dist/getMachineId-win-154s3qma.js +0 -38
- package/dist/grok-adapter-skdj2pce.js +0 -20
- package/dist/handlers-5btjqkz6.js +0 -39
- package/dist/heartbeat-vfb1gy84.js +0 -49
- package/dist/hook-eh52p7yd.js +0 -22
- package/dist/index-7w8p6em0.js +0 -41
- package/dist/index-t56y945n.js +0 -4
- package/dist/index-vfemrwwk.js +0 -10002
- package/dist/index-vz4semsx.js +0 -38
- package/dist/index-y3s0xp2v.js +0 -43
- package/dist/lead-6cscw8a5.js +0 -82
- package/dist/otel-impl-6n6vva3x.js +0 -28205
- package/dist/thread-buffer-9w6x5zec.js +0 -40
- package/dist/worker-g4aj93dt.js +0 -82
|
@@ -7,15 +7,14 @@ import {
|
|
|
7
7
|
require_checksum,
|
|
8
8
|
require_event_streams,
|
|
9
9
|
require_protocols,
|
|
10
|
-
require_retry,
|
|
11
10
|
require_dist_cjs,
|
|
11
|
+
require_retry,
|
|
12
12
|
require_client2,
|
|
13
13
|
require_httpAuthSchemes,
|
|
14
|
-
require_dist_cjs2,
|
|
15
14
|
require_protocols2,
|
|
16
15
|
require_sso_oidc,
|
|
17
16
|
require_dist_cjs3
|
|
18
|
-
} from "./cli-
|
|
17
|
+
} from "./cli-6prwz0zn.js";
|
|
19
18
|
import {
|
|
20
19
|
resolveHttpProxyUrlForTarget,
|
|
21
20
|
init_node_http_proxy
|
|
@@ -26,14 +25,14 @@ import {
|
|
|
26
25
|
hasExceededStrictToolLimits,
|
|
27
26
|
init_strict_tool_limits
|
|
28
27
|
} from "./cli-8mfdbdhe.js";
|
|
29
|
-
import {
|
|
30
|
-
getProviderEnvValue,
|
|
31
|
-
init_provider_env
|
|
32
|
-
} from "./cli-dc4m8cpv.js";
|
|
33
28
|
import {
|
|
34
29
|
ToolCallArgumentsStream,
|
|
35
30
|
init_streaming_json
|
|
36
31
|
} from "./cli-6pzk82fd.js";
|
|
32
|
+
import {
|
|
33
|
+
getProviderEnvValue,
|
|
34
|
+
init_provider_env
|
|
35
|
+
} from "./cli-dc4m8cpv.js";
|
|
37
36
|
import {
|
|
38
37
|
prefersJsonSchemaStrictSampling,
|
|
39
38
|
getJsonSchemaToolParameters,
|
|
@@ -47,7 +46,7 @@ import {
|
|
|
47
46
|
splitErrorToolResultImages,
|
|
48
47
|
transformMessages,
|
|
49
48
|
init_transform_messages
|
|
50
|
-
} from "./cli-
|
|
49
|
+
} from "./cli-jw7n9pct.js";
|
|
51
50
|
import {
|
|
52
51
|
sanitizeSurrogates,
|
|
53
52
|
init_sanitize_unicode
|
|
@@ -60,7 +59,7 @@ import {
|
|
|
60
59
|
init_transcript,
|
|
61
60
|
calculateCost,
|
|
62
61
|
init_models
|
|
63
|
-
} from "./cli-
|
|
62
|
+
} from "./cli-8gr1bg9t.js";
|
|
64
63
|
import {
|
|
65
64
|
AssistantMessageEventStream,
|
|
66
65
|
init_event_stream,
|
|
@@ -70,7 +69,7 @@ import {
|
|
|
70
69
|
import {
|
|
71
70
|
normalizeProviderError,
|
|
72
71
|
init_error_body
|
|
73
|
-
} from "./cli-
|
|
72
|
+
} from "./cli-53gt8wfv.js";
|
|
74
73
|
import {
|
|
75
74
|
providerHeadersToRecord,
|
|
76
75
|
init_headers
|
|
@@ -80,7 +79,7 @@ import {
|
|
|
80
79
|
init_text,
|
|
81
80
|
getClientVersion,
|
|
82
81
|
init_identity2
|
|
83
|
-
} from "./cli-
|
|
82
|
+
} from "./cli-ttatvwn6.js";
|
|
84
83
|
import {
|
|
85
84
|
require_src3
|
|
86
85
|
} from "./cli-qe909n63.js";
|
|
@@ -91,7 +90,7 @@ import {
|
|
|
91
90
|
} from "./cli-242037k3.js";
|
|
92
91
|
|
|
93
92
|
// node_modules/@aws-sdk/middleware-eventstream/dist-cjs/index.js
|
|
94
|
-
var
|
|
93
|
+
var require_dist_cjs2 = __commonJS(function(exports) {
|
|
95
94
|
var { HttpRequest } = require_protocols();
|
|
96
95
|
function resolveEventStreamConfig(input) {
|
|
97
96
|
const eventSigner = input.signer;
|
|
@@ -158,8 +157,9 @@ var require_util = __commonJS(function(exports) {
|
|
|
158
157
|
var validate = (str) => typeof str === "string" && str.indexOf("arn:") === 0 && str.split(":").length >= 6;
|
|
159
158
|
var parse = (arn) => {
|
|
160
159
|
const segments = arn.split(":");
|
|
161
|
-
if (segments.length < 6 || segments[0] !== "arn")
|
|
160
|
+
if (segments.length < 6 || segments[0] !== "arn") {
|
|
162
161
|
throw new Error("Malformed ARN");
|
|
162
|
+
}
|
|
163
163
|
const [, partition, service, region, accountId, ...resource] = segments;
|
|
164
164
|
return {
|
|
165
165
|
partition,
|
|
@@ -215,7 +215,7 @@ var require_util = __commonJS(function(exports) {
|
|
|
215
215
|
});
|
|
216
216
|
|
|
217
217
|
// node_modules/@smithy/fetch-http-handler/dist-cjs/index.js
|
|
218
|
-
var
|
|
218
|
+
var require_dist_cjs4 = __commonJS(function(exports) {
|
|
219
219
|
var { buildQueryString, HttpResponse } = require_protocols();
|
|
220
220
|
var { streamCollector } = require_serde();
|
|
221
221
|
exports.streamCollector = streamCollector;
|
|
@@ -223,15 +223,17 @@ var require_dist_cjs5 = __commonJS(function(exports) {
|
|
|
223
223
|
return new Request(url, requestOptions);
|
|
224
224
|
}
|
|
225
225
|
function requestTimeout(timeoutInMs = 0) {
|
|
226
|
-
|
|
226
|
+
let timeoutId;
|
|
227
|
+
const promise = new Promise((resolve, reject) => {
|
|
227
228
|
if (timeoutInMs) {
|
|
228
|
-
setTimeout(() => {
|
|
229
|
+
timeoutId = setTimeout(() => {
|
|
229
230
|
const timeoutError = new Error(`Request did not complete within ${timeoutInMs} ms`);
|
|
230
231
|
timeoutError.name = "TimeoutError";
|
|
231
232
|
reject(timeoutError);
|
|
232
233
|
}, timeoutInMs);
|
|
233
234
|
}
|
|
234
235
|
});
|
|
236
|
+
return { promise, cancel: () => clearTimeout(timeoutId) };
|
|
235
237
|
}
|
|
236
238
|
var keepAliveSupport = {
|
|
237
239
|
supported: undefined
|
|
@@ -309,6 +311,7 @@ var require_dist_cjs5 = __commonJS(function(exports) {
|
|
|
309
311
|
Object.assign(requestOptions, this.config.requestInit(request));
|
|
310
312
|
}
|
|
311
313
|
let removeSignalEventListener = () => {};
|
|
314
|
+
const timeout = requestTimeout(requestTimeoutInMs);
|
|
312
315
|
const fetchRequest = createRequest(url, requestOptions);
|
|
313
316
|
const raceOfPromises = [
|
|
314
317
|
fetchFn(fetchRequest).then((response) => {
|
|
@@ -337,7 +340,7 @@ var require_dist_cjs5 = __commonJS(function(exports) {
|
|
|
337
340
|
})
|
|
338
341
|
};
|
|
339
342
|
}),
|
|
340
|
-
|
|
343
|
+
timeout.promise
|
|
341
344
|
];
|
|
342
345
|
if (abortSignal) {
|
|
343
346
|
raceOfPromises.push(new Promise((resolve, reject) => {
|
|
@@ -354,7 +357,10 @@ var require_dist_cjs5 = __commonJS(function(exports) {
|
|
|
354
357
|
}
|
|
355
358
|
}));
|
|
356
359
|
}
|
|
357
|
-
return Promise.race(raceOfPromises).finally(
|
|
360
|
+
return Promise.race(raceOfPromises).finally(() => {
|
|
361
|
+
timeout.cancel();
|
|
362
|
+
removeSignalEventListener();
|
|
363
|
+
});
|
|
358
364
|
}
|
|
359
365
|
updateHttpClientConfig(key, value) {
|
|
360
366
|
this.config = undefined;
|
|
@@ -389,12 +395,12 @@ var require_dist_cjs5 = __commonJS(function(exports) {
|
|
|
389
395
|
});
|
|
390
396
|
|
|
391
397
|
// node_modules/@aws-sdk/middleware-websocket/dist-cjs/index.js
|
|
392
|
-
var
|
|
398
|
+
var require_dist_cjs5 = __commonJS(function(exports) {
|
|
393
399
|
var { formatUrl } = require_util();
|
|
394
400
|
var { iterableToReadableStream, readableStreamToIterable, EventStreamCodec } = require_event_streams();
|
|
395
401
|
var { HttpResponse, HttpRequest } = require_protocols();
|
|
396
402
|
var { fromBase64, fromHex } = require_serde();
|
|
397
|
-
var { FetchHttpHandler } =
|
|
403
|
+
var { FetchHttpHandler } = require_dist_cjs4();
|
|
398
404
|
var isWebSocketRequest = (request) => request.protocol === "ws:" || request.protocol === "wss:";
|
|
399
405
|
var DEFAULT_WS_CONNECTION_TIMEOUT_MS = 3000;
|
|
400
406
|
|
|
@@ -770,7 +776,7 @@ var require_dist_cjs6 = __commonJS(function(exports) {
|
|
|
770
776
|
});
|
|
771
777
|
|
|
772
778
|
// node_modules/@aws-sdk/eventstream-handler-node/dist-cjs/index.js
|
|
773
|
-
var
|
|
779
|
+
var require_dist_cjs6 = __commonJS(function(exports) {
|
|
774
780
|
var { EventStreamCodec } = require_event_streams();
|
|
775
781
|
var { Transform, Readable, PassThrough, pipeline } = __require("node:stream");
|
|
776
782
|
|
|
@@ -890,7 +896,7 @@ var require_dist_cjs7 = __commonJS(function(exports) {
|
|
|
890
896
|
});
|
|
891
897
|
|
|
892
898
|
// node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@aws-sdk/token-providers/dist-cjs/index.js
|
|
893
|
-
var
|
|
899
|
+
var require_dist_cjs7 = __commonJS(function(exports) {
|
|
894
900
|
var { setTokenFeature } = require_client2();
|
|
895
901
|
var { getBearerTokenEnvKey } = require_httpAuthSchemes();
|
|
896
902
|
var { TokenProviderError, getSSOTokenFilepath, parseKnownFiles, getProfileName, loadSsoSessionData, getSSOTokenFromFile, memoize, chain } = require_config();
|
|
@@ -1035,10 +1041,836 @@ var require_dist_cjs8 = __commonJS(function(exports) {
|
|
|
1035
1041
|
exports.nodeProvider = nodeProvider;
|
|
1036
1042
|
});
|
|
1037
1043
|
|
|
1044
|
+
// node_modules/@aws-sdk/client-bedrock-runtime/node_modules/@smithy/node-http-handler/dist-cjs/index.js
|
|
1045
|
+
var require_dist_cjs8 = __commonJS(function(exports) {
|
|
1046
|
+
var { hasOwn } = require_serde();
|
|
1047
|
+
var { streamCollector } = require_serde();
|
|
1048
|
+
exports.streamCollector = streamCollector;
|
|
1049
|
+
var { buildQueryString, HttpResponse } = require_protocols();
|
|
1050
|
+
var node_https = __require("node:https");
|
|
1051
|
+
var { Readable } = __require("node:stream");
|
|
1052
|
+
var http2 = __require("node:http2");
|
|
1053
|
+
function buildAbortError(abortSignal) {
|
|
1054
|
+
const reason = abortSignal && typeof abortSignal === "object" && "reason" in abortSignal ? abortSignal.reason : undefined;
|
|
1055
|
+
if (reason) {
|
|
1056
|
+
if (reason instanceof Error) {
|
|
1057
|
+
const abortError = new Error("Request aborted");
|
|
1058
|
+
abortError.name = "AbortError";
|
|
1059
|
+
abortError.cause = reason;
|
|
1060
|
+
return abortError;
|
|
1061
|
+
}
|
|
1062
|
+
const abortError = new Error(String(reason));
|
|
1063
|
+
abortError.name = "AbortError";
|
|
1064
|
+
return abortError;
|
|
1065
|
+
}
|
|
1066
|
+
const abortError = new Error("Request aborted");
|
|
1067
|
+
abortError.name = "AbortError";
|
|
1068
|
+
return abortError;
|
|
1069
|
+
}
|
|
1070
|
+
var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
|
|
1071
|
+
var getTransformedHeaders = (headers) => {
|
|
1072
|
+
const transformedHeaders = {};
|
|
1073
|
+
for (const name in headers) {
|
|
1074
|
+
if (!hasOwn(headers, name))
|
|
1075
|
+
continue;
|
|
1076
|
+
const headerValues = headers[name];
|
|
1077
|
+
transformedHeaders[name] = Array.isArray(headerValues) ? headerValues.join(",") : headerValues;
|
|
1078
|
+
}
|
|
1079
|
+
return transformedHeaders;
|
|
1080
|
+
};
|
|
1081
|
+
var timing = {
|
|
1082
|
+
setTimeout: (cb, ms) => setTimeout(cb, ms),
|
|
1083
|
+
clearTimeout: (timeoutId) => clearTimeout(timeoutId)
|
|
1084
|
+
};
|
|
1085
|
+
var DEFER_EVENT_LISTENER_TIME$2 = 1000;
|
|
1086
|
+
var setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
|
|
1087
|
+
if (!timeoutInMs) {
|
|
1088
|
+
return -1;
|
|
1089
|
+
}
|
|
1090
|
+
const registerTimeout = (offset) => {
|
|
1091
|
+
const timeoutId = timing.setTimeout(() => {
|
|
1092
|
+
request.destroy();
|
|
1093
|
+
reject(Object.assign(new Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${timeoutInMs} ms.`), {
|
|
1094
|
+
name: "TimeoutError"
|
|
1095
|
+
}));
|
|
1096
|
+
}, timeoutInMs - offset);
|
|
1097
|
+
const doWithSocket = (socket) => {
|
|
1098
|
+
if (socket?.connecting) {
|
|
1099
|
+
socket.on("connect", () => {
|
|
1100
|
+
timing.clearTimeout(timeoutId);
|
|
1101
|
+
});
|
|
1102
|
+
} else {
|
|
1103
|
+
timing.clearTimeout(timeoutId);
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1106
|
+
if (request.socket) {
|
|
1107
|
+
doWithSocket(request.socket);
|
|
1108
|
+
} else {
|
|
1109
|
+
request.on("socket", doWithSocket);
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
if (timeoutInMs < 2000) {
|
|
1113
|
+
registerTimeout(0);
|
|
1114
|
+
return 0;
|
|
1115
|
+
}
|
|
1116
|
+
return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME$2), DEFER_EVENT_LISTENER_TIME$2);
|
|
1117
|
+
};
|
|
1118
|
+
var setRequestTimeout = (req, reject, timeoutInMs = 0, throwOnRequestTimeout, logger) => {
|
|
1119
|
+
if (timeoutInMs) {
|
|
1120
|
+
return timing.setTimeout(() => {
|
|
1121
|
+
let msg = `@smithy/node-http-handler - [${throwOnRequestTimeout ? "ERROR" : "WARN"}] a request has exceeded the configured ${timeoutInMs} ms requestTimeout.`;
|
|
1122
|
+
if (throwOnRequestTimeout) {
|
|
1123
|
+
const error = Object.assign(new Error(msg), {
|
|
1124
|
+
name: "TimeoutError",
|
|
1125
|
+
code: "ETIMEDOUT"
|
|
1126
|
+
});
|
|
1127
|
+
req.destroy(error);
|
|
1128
|
+
reject(error);
|
|
1129
|
+
} else {
|
|
1130
|
+
msg += ` Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.`;
|
|
1131
|
+
logger?.warn?.(msg);
|
|
1132
|
+
}
|
|
1133
|
+
}, timeoutInMs);
|
|
1134
|
+
}
|
|
1135
|
+
return -1;
|
|
1136
|
+
};
|
|
1137
|
+
var DEFER_EVENT_LISTENER_TIME$1 = 3000;
|
|
1138
|
+
var setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME$1) => {
|
|
1139
|
+
if (keepAlive !== true) {
|
|
1140
|
+
return -1;
|
|
1141
|
+
}
|
|
1142
|
+
const registerListener = () => {
|
|
1143
|
+
if (request.socket) {
|
|
1144
|
+
request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
1145
|
+
} else {
|
|
1146
|
+
request.on("socket", (socket) => {
|
|
1147
|
+
socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
};
|
|
1151
|
+
if (deferTimeMs === 0) {
|
|
1152
|
+
registerListener();
|
|
1153
|
+
return 0;
|
|
1154
|
+
}
|
|
1155
|
+
return timing.setTimeout(registerListener, deferTimeMs);
|
|
1156
|
+
};
|
|
1157
|
+
var DEFER_EVENT_LISTENER_TIME = 3000;
|
|
1158
|
+
var setSocketTimeout = (request, reject, timeoutInMs = 0) => {
|
|
1159
|
+
const registerTimeout = (offset) => {
|
|
1160
|
+
const timeout = timeoutInMs - offset;
|
|
1161
|
+
const onTimeout = () => {
|
|
1162
|
+
request.destroy();
|
|
1163
|
+
reject(Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${timeoutInMs} ms of inactivity (configured by client requestHandler).`), { name: "TimeoutError" }));
|
|
1164
|
+
};
|
|
1165
|
+
if (request.socket) {
|
|
1166
|
+
request.socket.setTimeout(timeout, onTimeout);
|
|
1167
|
+
request.on("close", () => request.socket?.removeListener("timeout", onTimeout));
|
|
1168
|
+
} else {
|
|
1169
|
+
request.setTimeout(timeout, onTimeout);
|
|
1170
|
+
}
|
|
1171
|
+
};
|
|
1172
|
+
if (0 < timeoutInMs && timeoutInMs < 6000) {
|
|
1173
|
+
registerTimeout(0);
|
|
1174
|
+
return 0;
|
|
1175
|
+
}
|
|
1176
|
+
return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
|
|
1177
|
+
};
|
|
1178
|
+
var MIN_WAIT_TIME = 6000;
|
|
1179
|
+
async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME, externalAgent = false) {
|
|
1180
|
+
const headers = request.headers;
|
|
1181
|
+
const expect = headers ? headers.Expect || headers.expect : undefined;
|
|
1182
|
+
let timeoutId = -1;
|
|
1183
|
+
let sendBody = true;
|
|
1184
|
+
if (!externalAgent && expect === "100-continue") {
|
|
1185
|
+
sendBody = await Promise.race([
|
|
1186
|
+
new Promise((resolve) => {
|
|
1187
|
+
timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
1188
|
+
}),
|
|
1189
|
+
new Promise((resolve) => {
|
|
1190
|
+
httpRequest.on("continue", () => {
|
|
1191
|
+
timing.clearTimeout(timeoutId);
|
|
1192
|
+
resolve(true);
|
|
1193
|
+
});
|
|
1194
|
+
httpRequest.on("response", () => {
|
|
1195
|
+
timing.clearTimeout(timeoutId);
|
|
1196
|
+
resolve(false);
|
|
1197
|
+
});
|
|
1198
|
+
httpRequest.on("error", () => {
|
|
1199
|
+
timing.clearTimeout(timeoutId);
|
|
1200
|
+
resolve(false);
|
|
1201
|
+
});
|
|
1202
|
+
})
|
|
1203
|
+
]);
|
|
1204
|
+
}
|
|
1205
|
+
if (sendBody) {
|
|
1206
|
+
writeBody(httpRequest, request.body);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
function writeBody(httpRequest, body) {
|
|
1210
|
+
if (body instanceof Readable) {
|
|
1211
|
+
body.pipe(httpRequest);
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
if (body) {
|
|
1215
|
+
const isBuffer = Buffer.isBuffer(body);
|
|
1216
|
+
const isString = typeof body === "string";
|
|
1217
|
+
if (isBuffer || isString) {
|
|
1218
|
+
if (isBuffer && body.byteLength === 0) {
|
|
1219
|
+
httpRequest.end();
|
|
1220
|
+
} else {
|
|
1221
|
+
httpRequest.end(body);
|
|
1222
|
+
}
|
|
1223
|
+
return;
|
|
1224
|
+
}
|
|
1225
|
+
const uint8 = body;
|
|
1226
|
+
if (typeof uint8 === "object" && uint8.buffer && typeof uint8.byteOffset === "number" && typeof uint8.byteLength === "number") {
|
|
1227
|
+
httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
|
|
1228
|
+
return;
|
|
1229
|
+
}
|
|
1230
|
+
httpRequest.end(Buffer.from(body));
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
httpRequest.end();
|
|
1234
|
+
}
|
|
1235
|
+
var DEFAULT_REQUEST_TIMEOUT = 0;
|
|
1236
|
+
var hAgent = undefined;
|
|
1237
|
+
var hRequest = undefined;
|
|
1238
|
+
|
|
1239
|
+
class NodeHttpHandler {
|
|
1240
|
+
config;
|
|
1241
|
+
configProvider;
|
|
1242
|
+
socketWarningTimestamp = 0;
|
|
1243
|
+
externalAgent = false;
|
|
1244
|
+
metadata = { handlerProtocol: "http/1.1" };
|
|
1245
|
+
static create(instanceOrOptions) {
|
|
1246
|
+
if (typeof instanceOrOptions?.handle === "function") {
|
|
1247
|
+
return instanceOrOptions;
|
|
1248
|
+
}
|
|
1249
|
+
return new NodeHttpHandler(instanceOrOptions);
|
|
1250
|
+
}
|
|
1251
|
+
static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
|
|
1252
|
+
const { sockets, requests, maxSockets } = agent;
|
|
1253
|
+
if (typeof maxSockets !== "number" || maxSockets === Infinity) {
|
|
1254
|
+
return socketWarningTimestamp;
|
|
1255
|
+
}
|
|
1256
|
+
const interval = 15000;
|
|
1257
|
+
if (Date.now() - interval < socketWarningTimestamp) {
|
|
1258
|
+
return socketWarningTimestamp;
|
|
1259
|
+
}
|
|
1260
|
+
if (sockets && requests) {
|
|
1261
|
+
for (const origin in sockets) {
|
|
1262
|
+
if (!hasOwn(sockets, origin))
|
|
1263
|
+
continue;
|
|
1264
|
+
const socketsInUse = sockets[origin]?.length ?? 0;
|
|
1265
|
+
const requestsEnqueued = requests[origin]?.length ?? 0;
|
|
1266
|
+
if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
|
|
1267
|
+
logger?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
|
|
1268
|
+
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
|
|
1269
|
+
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
|
|
1270
|
+
return Date.now();
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
return socketWarningTimestamp;
|
|
1275
|
+
}
|
|
1276
|
+
constructor(options) {
|
|
1277
|
+
this.configProvider = new Promise((resolve, reject) => {
|
|
1278
|
+
if (typeof options === "function") {
|
|
1279
|
+
options().then((_options) => {
|
|
1280
|
+
resolve(this.resolveDefaultConfig(_options));
|
|
1281
|
+
}).catch(reject);
|
|
1282
|
+
} else {
|
|
1283
|
+
resolve(this.resolveDefaultConfig(options));
|
|
1284
|
+
}
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1287
|
+
destroy() {
|
|
1288
|
+
this.config?.httpAgent?.destroy();
|
|
1289
|
+
this.config?.httpsAgent?.destroy();
|
|
1290
|
+
}
|
|
1291
|
+
async handle(request2, { abortSignal, requestTimeout } = {}) {
|
|
1292
|
+
if (!this.config) {
|
|
1293
|
+
this.config = await this.configProvider;
|
|
1294
|
+
}
|
|
1295
|
+
const config = this.config;
|
|
1296
|
+
const logger = config.logger;
|
|
1297
|
+
const isSSL = request2.protocol === "https:";
|
|
1298
|
+
if (!isSSL && !this.config.httpAgent) {
|
|
1299
|
+
this.config.httpAgent = await this.config.httpAgentProvider();
|
|
1300
|
+
}
|
|
1301
|
+
return new Promise((_resolve, _reject) => {
|
|
1302
|
+
let writeRequestBodyPromise = undefined;
|
|
1303
|
+
let socketWarningTimeoutId = -1;
|
|
1304
|
+
let connectionTimeoutId = -1;
|
|
1305
|
+
let requestTimeoutId = -1;
|
|
1306
|
+
let socketTimeoutId = -1;
|
|
1307
|
+
let keepAliveTimeoutId = -1;
|
|
1308
|
+
const clearTimeouts = () => {
|
|
1309
|
+
timing.clearTimeout(socketWarningTimeoutId);
|
|
1310
|
+
timing.clearTimeout(connectionTimeoutId);
|
|
1311
|
+
timing.clearTimeout(requestTimeoutId);
|
|
1312
|
+
timing.clearTimeout(socketTimeoutId);
|
|
1313
|
+
timing.clearTimeout(keepAliveTimeoutId);
|
|
1314
|
+
};
|
|
1315
|
+
const resolve = async (arg) => {
|
|
1316
|
+
await writeRequestBodyPromise;
|
|
1317
|
+
clearTimeouts();
|
|
1318
|
+
_resolve(arg);
|
|
1319
|
+
};
|
|
1320
|
+
const reject = async (arg) => {
|
|
1321
|
+
await writeRequestBodyPromise;
|
|
1322
|
+
clearTimeouts();
|
|
1323
|
+
_reject(arg);
|
|
1324
|
+
};
|
|
1325
|
+
if (abortSignal?.aborted) {
|
|
1326
|
+
const abortError = buildAbortError(abortSignal);
|
|
1327
|
+
reject(abortError);
|
|
1328
|
+
return;
|
|
1329
|
+
}
|
|
1330
|
+
const headers = request2.headers;
|
|
1331
|
+
const expectContinue = headers ? (headers.Expect ?? headers.expect) === "100-continue" : false;
|
|
1332
|
+
let agent = isSSL ? config.httpsAgent : config.httpAgent;
|
|
1333
|
+
if (expectContinue && !this.externalAgent) {
|
|
1334
|
+
agent = new (isSSL ? node_https.Agent : hAgent)({
|
|
1335
|
+
keepAlive: false,
|
|
1336
|
+
maxSockets: Infinity
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
socketWarningTimeoutId = timing.setTimeout(() => {
|
|
1340
|
+
this.socketWarningTimestamp = NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp, logger);
|
|
1341
|
+
}, config.socketAcquisitionWarningTimeout ?? (config.requestTimeout ?? 2000) + (config.connectionTimeout ?? 1000));
|
|
1342
|
+
const queryString = request2.query ? buildQueryString(request2.query) : "";
|
|
1343
|
+
let auth = undefined;
|
|
1344
|
+
if (request2.username != null || request2.password != null) {
|
|
1345
|
+
const username = request2.username ?? "";
|
|
1346
|
+
const password = request2.password ?? "";
|
|
1347
|
+
auth = `${username}:${password}`;
|
|
1348
|
+
}
|
|
1349
|
+
let path = request2.path;
|
|
1350
|
+
if (queryString) {
|
|
1351
|
+
path += `?${queryString}`;
|
|
1352
|
+
}
|
|
1353
|
+
if (request2.fragment) {
|
|
1354
|
+
path += `#${request2.fragment}`;
|
|
1355
|
+
}
|
|
1356
|
+
let hostname = request2.hostname ?? "";
|
|
1357
|
+
if (hostname[0] === "[" && hostname.endsWith("]")) {
|
|
1358
|
+
hostname = request2.hostname.slice(1, -1);
|
|
1359
|
+
} else {
|
|
1360
|
+
hostname = request2.hostname;
|
|
1361
|
+
}
|
|
1362
|
+
const nodeHttpsOptions = {
|
|
1363
|
+
headers: request2.headers,
|
|
1364
|
+
host: hostname,
|
|
1365
|
+
method: request2.method,
|
|
1366
|
+
path,
|
|
1367
|
+
port: request2.port,
|
|
1368
|
+
agent,
|
|
1369
|
+
auth
|
|
1370
|
+
};
|
|
1371
|
+
const requestFunc = isSSL ? node_https.request : hRequest;
|
|
1372
|
+
const req = requestFunc(nodeHttpsOptions, (res) => {
|
|
1373
|
+
const httpResponse = new HttpResponse({
|
|
1374
|
+
statusCode: res.statusCode || -1,
|
|
1375
|
+
reason: res.statusMessage,
|
|
1376
|
+
headers: getTransformedHeaders(res.headers),
|
|
1377
|
+
body: res
|
|
1378
|
+
});
|
|
1379
|
+
resolve({ response: httpResponse });
|
|
1380
|
+
});
|
|
1381
|
+
req.on("error", (err) => {
|
|
1382
|
+
if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
|
|
1383
|
+
reject(Object.assign(err, { name: "TimeoutError" }));
|
|
1384
|
+
} else {
|
|
1385
|
+
reject(err);
|
|
1386
|
+
}
|
|
1387
|
+
});
|
|
1388
|
+
if (abortSignal) {
|
|
1389
|
+
const onAbort = () => {
|
|
1390
|
+
req.destroy();
|
|
1391
|
+
const abortError = buildAbortError(abortSignal);
|
|
1392
|
+
reject(abortError);
|
|
1393
|
+
};
|
|
1394
|
+
if (typeof abortSignal.addEventListener === "function") {
|
|
1395
|
+
const signal = abortSignal;
|
|
1396
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
1397
|
+
req.once("close", () => signal.removeEventListener("abort", onAbort));
|
|
1398
|
+
} else {
|
|
1399
|
+
abortSignal.onabort = onAbort;
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
const effectiveRequestTimeout = requestTimeout ?? config.requestTimeout;
|
|
1403
|
+
connectionTimeoutId = setConnectionTimeout(req, reject, config.connectionTimeout);
|
|
1404
|
+
requestTimeoutId = setRequestTimeout(req, reject, effectiveRequestTimeout, config.throwOnRequestTimeout, logger ?? console);
|
|
1405
|
+
socketTimeoutId = setSocketTimeout(req, reject, config.socketTimeout);
|
|
1406
|
+
const httpAgent = nodeHttpsOptions.agent;
|
|
1407
|
+
if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
|
|
1408
|
+
keepAliveTimeoutId = setSocketKeepAlive(req, {
|
|
1409
|
+
keepAlive: httpAgent.keepAlive,
|
|
1410
|
+
keepAliveMsecs: httpAgent.keepAliveMsecs
|
|
1411
|
+
});
|
|
1412
|
+
}
|
|
1413
|
+
writeRequestBodyPromise = writeRequestBody(req, request2, effectiveRequestTimeout, this.externalAgent).catch((e) => {
|
|
1414
|
+
clearTimeouts();
|
|
1415
|
+
return _reject(e);
|
|
1416
|
+
});
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
updateHttpClientConfig(key, value) {
|
|
1420
|
+
this.config = undefined;
|
|
1421
|
+
this.configProvider = this.configProvider.then((config) => {
|
|
1422
|
+
if (key === Symbol.for("logger")) {
|
|
1423
|
+
return {
|
|
1424
|
+
...config,
|
|
1425
|
+
logger: config.logger ?? value
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
return {
|
|
1429
|
+
...config,
|
|
1430
|
+
[key]: value
|
|
1431
|
+
};
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
httpHandlerConfigs() {
|
|
1435
|
+
return this.config ?? {};
|
|
1436
|
+
}
|
|
1437
|
+
resolveDefaultConfig(options) {
|
|
1438
|
+
const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent, throwOnRequestTimeout, logger } = options || {};
|
|
1439
|
+
const keepAlive = true;
|
|
1440
|
+
const maxSockets = 50;
|
|
1441
|
+
return {
|
|
1442
|
+
connectionTimeout,
|
|
1443
|
+
requestTimeout,
|
|
1444
|
+
socketTimeout,
|
|
1445
|
+
socketAcquisitionWarningTimeout,
|
|
1446
|
+
throwOnRequestTimeout,
|
|
1447
|
+
httpAgentProvider: async () => {
|
|
1448
|
+
const node_http = __require("node:http");
|
|
1449
|
+
const { Agent, request } = node_http.default ?? node_http;
|
|
1450
|
+
hRequest = request;
|
|
1451
|
+
hAgent = Agent;
|
|
1452
|
+
if (httpAgent instanceof hAgent || typeof httpAgent?.destroy === "function") {
|
|
1453
|
+
this.externalAgent = true;
|
|
1454
|
+
return httpAgent;
|
|
1455
|
+
}
|
|
1456
|
+
return new hAgent({ keepAlive, maxSockets, ...httpAgent });
|
|
1457
|
+
},
|
|
1458
|
+
httpsAgent: (() => {
|
|
1459
|
+
if (httpsAgent instanceof node_https.Agent || typeof httpsAgent?.destroy === "function") {
|
|
1460
|
+
this.externalAgent = true;
|
|
1461
|
+
return httpsAgent;
|
|
1462
|
+
}
|
|
1463
|
+
return new node_https.Agent({ keepAlive, maxSockets, ...httpsAgent });
|
|
1464
|
+
})(),
|
|
1465
|
+
logger
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
var ids = new Uint16Array(1);
|
|
1470
|
+
|
|
1471
|
+
class ClientHttp2SessionRef {
|
|
1472
|
+
id = ids[0]++;
|
|
1473
|
+
total = 0;
|
|
1474
|
+
max = 0;
|
|
1475
|
+
session;
|
|
1476
|
+
refs = 0;
|
|
1477
|
+
constructor(session) {
|
|
1478
|
+
session.unref();
|
|
1479
|
+
this.session = session;
|
|
1480
|
+
}
|
|
1481
|
+
retain() {
|
|
1482
|
+
if (this.session.destroyed) {
|
|
1483
|
+
throw new Error("@smithy/node-http-handler - cannot acquire reference to destroyed session.");
|
|
1484
|
+
}
|
|
1485
|
+
this.refs += 1;
|
|
1486
|
+
this.total += 1;
|
|
1487
|
+
this.max = Math.max(this.refs, this.max);
|
|
1488
|
+
this.session.ref();
|
|
1489
|
+
}
|
|
1490
|
+
free() {
|
|
1491
|
+
if (this.session.destroyed) {
|
|
1492
|
+
return;
|
|
1493
|
+
}
|
|
1494
|
+
this.refs -= 1;
|
|
1495
|
+
if (this.refs === 0) {
|
|
1496
|
+
this.session.unref();
|
|
1497
|
+
}
|
|
1498
|
+
if (this.refs < 0) {
|
|
1499
|
+
throw new Error("@smithy/node-http-handler - ClientHttp2Session refcount at zero, cannot decrement.");
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
deref() {
|
|
1503
|
+
return this.session;
|
|
1504
|
+
}
|
|
1505
|
+
close() {
|
|
1506
|
+
if (!this.session.closed) {
|
|
1507
|
+
this.session.close();
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
destroy() {
|
|
1511
|
+
this.refs = 0;
|
|
1512
|
+
if (!this.session.destroyed) {
|
|
1513
|
+
this.session.setTimeout(0);
|
|
1514
|
+
this.session.destroy();
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
useCount() {
|
|
1518
|
+
return this.refs;
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
class NodeHttp2ConnectionPool {
|
|
1523
|
+
sessions = [];
|
|
1524
|
+
maxConcurrency = 0;
|
|
1525
|
+
constructor(sessions) {
|
|
1526
|
+
this.sessions = (sessions ?? []).map((session) => new ClientHttp2SessionRef(session));
|
|
1527
|
+
}
|
|
1528
|
+
poll() {
|
|
1529
|
+
let cleanup = false;
|
|
1530
|
+
for (const session of this.sessions) {
|
|
1531
|
+
if (session.deref().destroyed) {
|
|
1532
|
+
cleanup = true;
|
|
1533
|
+
continue;
|
|
1534
|
+
}
|
|
1535
|
+
if (!this.maxConcurrency || session.useCount() < this.maxConcurrency) {
|
|
1536
|
+
return session;
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
if (cleanup) {
|
|
1540
|
+
for (const session of this.sessions) {
|
|
1541
|
+
if (session.deref().destroyed) {
|
|
1542
|
+
this.remove(session);
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
offerLast(ref) {
|
|
1548
|
+
this.sessions.push(ref);
|
|
1549
|
+
}
|
|
1550
|
+
remove(ref) {
|
|
1551
|
+
const ix = this.sessions.indexOf(ref);
|
|
1552
|
+
if (ix > -1) {
|
|
1553
|
+
this.sessions.splice(ix, 1);
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
[Symbol.iterator]() {
|
|
1557
|
+
return this.sessions[Symbol.iterator]();
|
|
1558
|
+
}
|
|
1559
|
+
setMaxConcurrency(maxConcurrency) {
|
|
1560
|
+
this.maxConcurrency = maxConcurrency;
|
|
1561
|
+
}
|
|
1562
|
+
destroy(ref) {
|
|
1563
|
+
this.remove(ref);
|
|
1564
|
+
ref.destroy();
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
class NodeHttp2ConnectionManager {
|
|
1569
|
+
config;
|
|
1570
|
+
connectOptions;
|
|
1571
|
+
connectionPools = new Map;
|
|
1572
|
+
constructor(config) {
|
|
1573
|
+
this.config = config;
|
|
1574
|
+
if (this.config.maxConcurrency && this.config.maxConcurrency <= 0) {
|
|
1575
|
+
throw new RangeError("maxConcurrency must be greater than zero.");
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
lease(requestContext, connectionConfiguration) {
|
|
1579
|
+
const url = this.getUrlString(requestContext);
|
|
1580
|
+
const pool = this.getPool(url);
|
|
1581
|
+
if (!this.config.disableConcurrency && !connectionConfiguration.isEventStream) {
|
|
1582
|
+
const available = pool.poll();
|
|
1583
|
+
if (available) {
|
|
1584
|
+
available.retain();
|
|
1585
|
+
return available;
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
const ref = new ClientHttp2SessionRef(this.connect(url));
|
|
1589
|
+
const session = ref.deref();
|
|
1590
|
+
if (this.config.maxConcurrency) {
|
|
1591
|
+
session.settings({ maxConcurrentStreams: this.config.maxConcurrency }, (err) => {
|
|
1592
|
+
if (err) {
|
|
1593
|
+
throw new Error("Fail to set maxConcurrentStreams to " + this.config.maxConcurrency + "when creating new session for " + requestContext.destination.toString());
|
|
1594
|
+
}
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
const graceful = () => {
|
|
1598
|
+
this.removeFromPoolAndClose(url, ref);
|
|
1599
|
+
};
|
|
1600
|
+
const ensureDestroyed = () => {
|
|
1601
|
+
this.removeFromPoolAndCheckedDestroy(url, ref);
|
|
1602
|
+
};
|
|
1603
|
+
session.on("goaway", graceful);
|
|
1604
|
+
session.on("error", ensureDestroyed);
|
|
1605
|
+
session.on("frameError", ensureDestroyed);
|
|
1606
|
+
session.on("close", ensureDestroyed);
|
|
1607
|
+
if (connectionConfiguration.requestTimeout) {
|
|
1608
|
+
session.setTimeout(connectionConfiguration.requestTimeout, ensureDestroyed);
|
|
1609
|
+
}
|
|
1610
|
+
pool.offerLast(ref);
|
|
1611
|
+
ref.retain();
|
|
1612
|
+
return ref;
|
|
1613
|
+
}
|
|
1614
|
+
release(_requestContext, ref) {
|
|
1615
|
+
ref.free();
|
|
1616
|
+
}
|
|
1617
|
+
createIsolatedSession(requestContext, connectionConfiguration) {
|
|
1618
|
+
const url = this.getUrlString(requestContext);
|
|
1619
|
+
const ref = new ClientHttp2SessionRef(this.connect(url));
|
|
1620
|
+
const session = ref.deref();
|
|
1621
|
+
session.settings({ maxConcurrentStreams: 1 });
|
|
1622
|
+
const ensureDestroyed = () => {
|
|
1623
|
+
ref.destroy();
|
|
1624
|
+
};
|
|
1625
|
+
session.on("error", ensureDestroyed);
|
|
1626
|
+
session.on("frameError", ensureDestroyed);
|
|
1627
|
+
session.on("close", ensureDestroyed);
|
|
1628
|
+
const timeout = connectionConfiguration.requestTimeout ?? 300000;
|
|
1629
|
+
session.setTimeout(timeout, ensureDestroyed);
|
|
1630
|
+
ref.retain();
|
|
1631
|
+
return ref;
|
|
1632
|
+
}
|
|
1633
|
+
destroy() {
|
|
1634
|
+
for (const [url, connectionPool] of this.connectionPools) {
|
|
1635
|
+
for (const session of [...connectionPool]) {
|
|
1636
|
+
session.destroy();
|
|
1637
|
+
}
|
|
1638
|
+
this.connectionPools.delete(url);
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
setMaxConcurrentStreams(maxConcurrentStreams) {
|
|
1642
|
+
if (maxConcurrentStreams && maxConcurrentStreams <= 0) {
|
|
1643
|
+
throw new RangeError("maxConcurrentStreams must be greater than zero.");
|
|
1644
|
+
}
|
|
1645
|
+
this.config.maxConcurrency = maxConcurrentStreams;
|
|
1646
|
+
for (const pool of this.connectionPools.values()) {
|
|
1647
|
+
pool.setMaxConcurrency(maxConcurrentStreams);
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
setDisableConcurrentStreams(disableConcurrentStreams) {
|
|
1651
|
+
this.config.disableConcurrency = disableConcurrentStreams;
|
|
1652
|
+
}
|
|
1653
|
+
setNodeHttp2ConnectOptions(nodeHttp2ConnectOptions) {
|
|
1654
|
+
this.connectOptions = nodeHttp2ConnectOptions;
|
|
1655
|
+
}
|
|
1656
|
+
debug() {
|
|
1657
|
+
const pools = {};
|
|
1658
|
+
for (const [url, pool] of this.connectionPools) {
|
|
1659
|
+
const sessions = [];
|
|
1660
|
+
for (const ref of pool) {
|
|
1661
|
+
sessions.push({
|
|
1662
|
+
id: ref.id,
|
|
1663
|
+
active: ref.useCount(),
|
|
1664
|
+
maxConcurrent: ref.max,
|
|
1665
|
+
totalRequests: ref.total
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
pools[url] = { sessions };
|
|
1669
|
+
}
|
|
1670
|
+
return pools;
|
|
1671
|
+
}
|
|
1672
|
+
removeFromPoolAndClose(authority, ref) {
|
|
1673
|
+
this.connectionPools.get(authority)?.remove(ref);
|
|
1674
|
+
ref.close();
|
|
1675
|
+
}
|
|
1676
|
+
removeFromPoolAndCheckedDestroy(authority, ref) {
|
|
1677
|
+
this.connectionPools.get(authority)?.remove(ref);
|
|
1678
|
+
ref.destroy();
|
|
1679
|
+
}
|
|
1680
|
+
getPool(url) {
|
|
1681
|
+
if (!this.connectionPools.has(url)) {
|
|
1682
|
+
const pool = new NodeHttp2ConnectionPool;
|
|
1683
|
+
if (this.config.maxConcurrency) {
|
|
1684
|
+
pool.setMaxConcurrency(this.config.maxConcurrency);
|
|
1685
|
+
}
|
|
1686
|
+
this.connectionPools.set(url, pool);
|
|
1687
|
+
}
|
|
1688
|
+
return this.connectionPools.get(url);
|
|
1689
|
+
}
|
|
1690
|
+
getUrlString(request) {
|
|
1691
|
+
return request.destination.toString();
|
|
1692
|
+
}
|
|
1693
|
+
connect(url) {
|
|
1694
|
+
return this.connectOptions === undefined ? http2.connect(url) : http2.connect(url, this.connectOptions);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
var { constants } = http2;
|
|
1698
|
+
|
|
1699
|
+
class NodeHttp2Handler {
|
|
1700
|
+
config;
|
|
1701
|
+
configProvider;
|
|
1702
|
+
metadata = { handlerProtocol: "h2" };
|
|
1703
|
+
connectionManager = new NodeHttp2ConnectionManager({});
|
|
1704
|
+
static create(instanceOrOptions) {
|
|
1705
|
+
if (typeof instanceOrOptions?.handle === "function") {
|
|
1706
|
+
return instanceOrOptions;
|
|
1707
|
+
}
|
|
1708
|
+
return new NodeHttp2Handler(instanceOrOptions);
|
|
1709
|
+
}
|
|
1710
|
+
constructor(options) {
|
|
1711
|
+
this.configProvider = new Promise((resolve, reject) => {
|
|
1712
|
+
if (typeof options === "function") {
|
|
1713
|
+
options().then((opts) => {
|
|
1714
|
+
resolve(opts || {});
|
|
1715
|
+
}).catch(reject);
|
|
1716
|
+
} else {
|
|
1717
|
+
resolve(options || {});
|
|
1718
|
+
}
|
|
1719
|
+
});
|
|
1720
|
+
}
|
|
1721
|
+
destroy() {
|
|
1722
|
+
this.connectionManager.destroy();
|
|
1723
|
+
}
|
|
1724
|
+
async handle(request, { abortSignal, requestTimeout, isEventStream } = {}) {
|
|
1725
|
+
if (!this.config) {
|
|
1726
|
+
this.config = await this.configProvider;
|
|
1727
|
+
const { disableConcurrentStreams, maxConcurrentStreams, nodeHttp2ConnectOptions } = this.config;
|
|
1728
|
+
this.connectionManager.setDisableConcurrentStreams(disableConcurrentStreams ?? false);
|
|
1729
|
+
if (maxConcurrentStreams) {
|
|
1730
|
+
this.connectionManager.setMaxConcurrentStreams(maxConcurrentStreams);
|
|
1731
|
+
}
|
|
1732
|
+
if (nodeHttp2ConnectOptions) {
|
|
1733
|
+
this.connectionManager.setNodeHttp2ConnectOptions(nodeHttp2ConnectOptions);
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
const { requestTimeout: configRequestTimeout, disableConcurrentStreams } = this.config;
|
|
1737
|
+
const useIsolatedSession = disableConcurrentStreams || isEventStream;
|
|
1738
|
+
const effectiveRequestTimeout = requestTimeout ?? configRequestTimeout;
|
|
1739
|
+
return new Promise((_resolve, _reject) => {
|
|
1740
|
+
let fulfilled = false;
|
|
1741
|
+
let writeRequestBodyPromise = undefined;
|
|
1742
|
+
const resolve = async (arg) => {
|
|
1743
|
+
await writeRequestBodyPromise;
|
|
1744
|
+
_resolve(arg);
|
|
1745
|
+
};
|
|
1746
|
+
const reject = async (arg) => {
|
|
1747
|
+
await writeRequestBodyPromise;
|
|
1748
|
+
_reject(arg);
|
|
1749
|
+
};
|
|
1750
|
+
if (abortSignal?.aborted) {
|
|
1751
|
+
fulfilled = true;
|
|
1752
|
+
const abortError = buildAbortError(abortSignal);
|
|
1753
|
+
reject(abortError);
|
|
1754
|
+
return;
|
|
1755
|
+
}
|
|
1756
|
+
const { hostname, method, port, protocol, query } = request;
|
|
1757
|
+
let auth = "";
|
|
1758
|
+
if (request.username != null || request.password != null) {
|
|
1759
|
+
const username = request.username ?? "";
|
|
1760
|
+
const password = request.password ?? "";
|
|
1761
|
+
auth = `${username}:${password}@`;
|
|
1762
|
+
}
|
|
1763
|
+
const authority = `${protocol}//${auth}${hostname}${port ? `:${port}` : ""}`;
|
|
1764
|
+
const requestContext = { destination: new URL(authority) };
|
|
1765
|
+
const connectConfig = {
|
|
1766
|
+
requestTimeout: this.config?.sessionTimeout,
|
|
1767
|
+
isEventStream
|
|
1768
|
+
};
|
|
1769
|
+
const ref = useIsolatedSession ? this.connectionManager.createIsolatedSession(requestContext, connectConfig) : this.connectionManager.lease(requestContext, connectConfig);
|
|
1770
|
+
const session = ref.deref();
|
|
1771
|
+
const rejectWithDestroy = (err) => {
|
|
1772
|
+
if (useIsolatedSession) {
|
|
1773
|
+
ref.destroy();
|
|
1774
|
+
}
|
|
1775
|
+
fulfilled = true;
|
|
1776
|
+
reject(err);
|
|
1777
|
+
};
|
|
1778
|
+
const queryString = query ? buildQueryString(query) : "";
|
|
1779
|
+
let path = request.path;
|
|
1780
|
+
if (queryString) {
|
|
1781
|
+
path += `?${queryString}`;
|
|
1782
|
+
}
|
|
1783
|
+
if (request.fragment) {
|
|
1784
|
+
path += `#${request.fragment}`;
|
|
1785
|
+
}
|
|
1786
|
+
const clientHttp2Stream = session.request({
|
|
1787
|
+
...request.headers,
|
|
1788
|
+
[constants.HTTP2_HEADER_PATH]: path,
|
|
1789
|
+
[constants.HTTP2_HEADER_METHOD]: method
|
|
1790
|
+
});
|
|
1791
|
+
if (effectiveRequestTimeout) {
|
|
1792
|
+
clientHttp2Stream.setTimeout(effectiveRequestTimeout, () => {
|
|
1793
|
+
clientHttp2Stream.close();
|
|
1794
|
+
const timeoutError = new Error(`Stream timed out because of no activity for ${effectiveRequestTimeout} ms`);
|
|
1795
|
+
timeoutError.name = "TimeoutError";
|
|
1796
|
+
rejectWithDestroy(timeoutError);
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
if (abortSignal) {
|
|
1800
|
+
const onAbort = () => {
|
|
1801
|
+
clientHttp2Stream.close();
|
|
1802
|
+
const abortError = buildAbortError(abortSignal);
|
|
1803
|
+
rejectWithDestroy(abortError);
|
|
1804
|
+
};
|
|
1805
|
+
if (typeof abortSignal.addEventListener === "function") {
|
|
1806
|
+
const signal = abortSignal;
|
|
1807
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
1808
|
+
clientHttp2Stream.once("close", () => signal.removeEventListener("abort", onAbort));
|
|
1809
|
+
} else {
|
|
1810
|
+
abortSignal.onabort = onAbort;
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
clientHttp2Stream.on("frameError", (type, code, id) => {
|
|
1814
|
+
rejectWithDestroy(new Error(`Frame type id ${type} in stream id ${id} has failed with code ${code}.`));
|
|
1815
|
+
});
|
|
1816
|
+
clientHttp2Stream.on("error", rejectWithDestroy);
|
|
1817
|
+
clientHttp2Stream.on("aborted", () => {
|
|
1818
|
+
rejectWithDestroy(new Error(`HTTP/2 stream is abnormally aborted in mid-communication with result code ${clientHttp2Stream.rstCode}.`));
|
|
1819
|
+
});
|
|
1820
|
+
clientHttp2Stream.on("response", (headers) => {
|
|
1821
|
+
const httpResponse = new HttpResponse({
|
|
1822
|
+
statusCode: headers[":status"] ?? -1,
|
|
1823
|
+
headers: getTransformedHeaders(headers),
|
|
1824
|
+
body: clientHttp2Stream
|
|
1825
|
+
});
|
|
1826
|
+
fulfilled = true;
|
|
1827
|
+
resolve({ response: httpResponse });
|
|
1828
|
+
if (useIsolatedSession) {
|
|
1829
|
+
session.close();
|
|
1830
|
+
clientHttp2Stream.on("end", () => {
|
|
1831
|
+
ref.destroy();
|
|
1832
|
+
});
|
|
1833
|
+
}
|
|
1834
|
+
});
|
|
1835
|
+
clientHttp2Stream.on("close", () => {
|
|
1836
|
+
if (useIsolatedSession) {
|
|
1837
|
+
ref.destroy();
|
|
1838
|
+
} else {
|
|
1839
|
+
this.connectionManager.release(requestContext, ref);
|
|
1840
|
+
}
|
|
1841
|
+
if (!fulfilled) {
|
|
1842
|
+
const error = new Error("Unexpected error: http2 request did not get a response");
|
|
1843
|
+
if (session.destroyed) {
|
|
1844
|
+
error.name = "TimeoutError";
|
|
1845
|
+
}
|
|
1846
|
+
rejectWithDestroy(error);
|
|
1847
|
+
}
|
|
1848
|
+
});
|
|
1849
|
+
writeRequestBodyPromise = writeRequestBody(clientHttp2Stream, request, effectiveRequestTimeout);
|
|
1850
|
+
});
|
|
1851
|
+
}
|
|
1852
|
+
updateHttpClientConfig(key, value) {
|
|
1853
|
+
this.config = undefined;
|
|
1854
|
+
this.configProvider = this.configProvider.then((config) => {
|
|
1855
|
+
return {
|
|
1856
|
+
...config,
|
|
1857
|
+
[key]: value
|
|
1858
|
+
};
|
|
1859
|
+
});
|
|
1860
|
+
}
|
|
1861
|
+
httpHandlerConfigs() {
|
|
1862
|
+
return this.config ?? {};
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
exports.DEFAULT_REQUEST_TIMEOUT = DEFAULT_REQUEST_TIMEOUT;
|
|
1866
|
+
exports.NodeHttp2Handler = NodeHttp2Handler;
|
|
1867
|
+
exports.NodeHttpHandler = NodeHttpHandler;
|
|
1868
|
+
});
|
|
1869
|
+
|
|
1038
1870
|
// node_modules/@aws-sdk/client-bedrock-runtime/dist-cjs/index.js
|
|
1039
1871
|
var { awsEndpointFunctions, emitWarningIfUnsupportedVersion: emitWarningIfUnsupportedVersion$1, createDefaultUserAgentProvider, NODE_APP_ID_CONFIG_OPTIONS, getAwsRegionExtensionConfiguration, resolveAwsRegionExtensionConfiguration, resolveUserAgentConfig, resolveHostHeaderConfig, getUserAgentPlugin, getHostHeaderPlugin, getLoggerPlugin, getRecursionDetectionPlugin } = require_client2();
|
|
1040
|
-
var { resolveEventStreamConfig, getEventStreamPlugin } =
|
|
1041
|
-
var { resolveWebSocketConfig, getWebSocketPlugin } =
|
|
1872
|
+
var { resolveEventStreamConfig, getEventStreamPlugin } = require_dist_cjs2();
|
|
1873
|
+
var { resolveWebSocketConfig, getWebSocketPlugin } = require_dist_cjs5();
|
|
1042
1874
|
var { memoizeIdentityProvider, isIdentityExpired, doesIdentityRequireRefresh, HttpBearerAuthSigner, getHttpAuthSchemeEndpointRuleSetPlugin, DefaultIdentityProviderConfig, getHttpSigningPlugin, createPaginator } = require_dist_cjs();
|
|
1043
1875
|
var { normalizeProvider, getSmithyContext, ServiceException, NoOpLogger, emitWarningIfUnsupportedVersion, loadConfigsForDefaultMode, getDefaultExtensionConfiguration, resolveDefaultRuntimeConfig, Client, makeBuilder, createAggregatedClient } = require_client();
|
|
1044
1876
|
var { Command: $Command } = require_client();
|
|
@@ -1050,10 +1882,10 @@ var { DEFAULT_RETRY_MODE, NODE_RETRY_MODE_CONFIG_OPTIONS, NODE_MAX_ATTEMPT_CONFI
|
|
|
1050
1882
|
var { TypeRegistry, getSchemaSerdePlugin } = require_schema();
|
|
1051
1883
|
var { resolveAwsSdkSigV4Config, AwsSdkSigV4Signer, NODE_AUTH_SCHEME_PREFERENCE_OPTIONS } = require_httpAuthSchemes();
|
|
1052
1884
|
var { defaultProvider } = require_dist_cjs3();
|
|
1053
|
-
var { eventStreamPayloadHandlerProvider } =
|
|
1054
|
-
var { fromEnvSigningName, nodeProvider } =
|
|
1885
|
+
var { eventStreamPayloadHandlerProvider } = require_dist_cjs6();
|
|
1886
|
+
var { fromEnvSigningName, nodeProvider } = require_dist_cjs7();
|
|
1055
1887
|
var { toUtf8, fromUtf8, toBase64, fromBase64, calculateBodyLength } = require_serde();
|
|
1056
|
-
var { streamCollector, NodeHttp2Handler } =
|
|
1888
|
+
var { streamCollector, NodeHttp2Handler } = require_dist_cjs8();
|
|
1057
1889
|
var { AwsRestJsonProtocol } = require_protocols2();
|
|
1058
1890
|
var { Sha256 } = require_checksum();
|
|
1059
1891
|
var defaultBedrockRuntimeHttpAuthSchemeParametersProvider = async (config, context, input) => {
|
|
@@ -4316,8 +5148,431 @@ var $ImageFormat = ImageFormat;
|
|
|
4316
5148
|
var $StopReason = StopReason;
|
|
4317
5149
|
var $ToolResultStatus = ToolResultStatus;
|
|
4318
5150
|
|
|
4319
|
-
// node_modules/@earendil-works/pi-ai/
|
|
4320
|
-
var
|
|
5151
|
+
// node_modules/@earendil-works/pi-ai/node_modules/@smithy/node-http-handler/dist-cjs/index.js
|
|
5152
|
+
var { hasOwn } = require_serde();
|
|
5153
|
+
var { streamCollector: streamCollector2 } = require_serde();
|
|
5154
|
+
var { buildQueryString, HttpResponse } = require_protocols();
|
|
5155
|
+
var node_https = __require("node:https");
|
|
5156
|
+
var { Readable } = __require("node:stream");
|
|
5157
|
+
var http2 = __require("node:http2");
|
|
5158
|
+
function buildAbortError(abortSignal) {
|
|
5159
|
+
const reason = abortSignal && typeof abortSignal === "object" && "reason" in abortSignal ? abortSignal.reason : undefined;
|
|
5160
|
+
if (reason) {
|
|
5161
|
+
if (reason instanceof Error) {
|
|
5162
|
+
const abortError = new Error("Request aborted");
|
|
5163
|
+
abortError.name = "AbortError";
|
|
5164
|
+
abortError.cause = reason;
|
|
5165
|
+
return abortError;
|
|
5166
|
+
}
|
|
5167
|
+
const abortError = new Error(String(reason));
|
|
5168
|
+
abortError.name = "AbortError";
|
|
5169
|
+
return abortError;
|
|
5170
|
+
}
|
|
5171
|
+
const abortError = new Error("Request aborted");
|
|
5172
|
+
abortError.name = "AbortError";
|
|
5173
|
+
return abortError;
|
|
5174
|
+
}
|
|
5175
|
+
var NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
|
|
5176
|
+
var getTransformedHeaders = (headers) => {
|
|
5177
|
+
const transformedHeaders = {};
|
|
5178
|
+
for (const name in headers) {
|
|
5179
|
+
if (!hasOwn(headers, name))
|
|
5180
|
+
continue;
|
|
5181
|
+
const headerValues = headers[name];
|
|
5182
|
+
transformedHeaders[name] = Array.isArray(headerValues) ? headerValues.join(",") : headerValues;
|
|
5183
|
+
}
|
|
5184
|
+
return transformedHeaders;
|
|
5185
|
+
};
|
|
5186
|
+
var timing = {
|
|
5187
|
+
setTimeout: (cb, ms) => setTimeout(cb, ms),
|
|
5188
|
+
clearTimeout: (timeoutId) => clearTimeout(timeoutId)
|
|
5189
|
+
};
|
|
5190
|
+
var DEFER_EVENT_LISTENER_TIME$2 = 1000;
|
|
5191
|
+
var setConnectionTimeout = (request, reject, timeoutInMs = 0) => {
|
|
5192
|
+
if (!timeoutInMs) {
|
|
5193
|
+
return -1;
|
|
5194
|
+
}
|
|
5195
|
+
const registerTimeout = (offset) => {
|
|
5196
|
+
const timeoutId = timing.setTimeout(() => {
|
|
5197
|
+
request.destroy();
|
|
5198
|
+
reject(Object.assign(new Error(`@smithy/node-http-handler - the request socket did not establish a connection with the server within the configured timeout of ${timeoutInMs} ms.`), {
|
|
5199
|
+
name: "TimeoutError"
|
|
5200
|
+
}));
|
|
5201
|
+
}, timeoutInMs - offset);
|
|
5202
|
+
const doWithSocket = (socket) => {
|
|
5203
|
+
if (socket?.connecting) {
|
|
5204
|
+
socket.on("connect", () => {
|
|
5205
|
+
timing.clearTimeout(timeoutId);
|
|
5206
|
+
});
|
|
5207
|
+
} else {
|
|
5208
|
+
timing.clearTimeout(timeoutId);
|
|
5209
|
+
}
|
|
5210
|
+
};
|
|
5211
|
+
if (request.socket) {
|
|
5212
|
+
doWithSocket(request.socket);
|
|
5213
|
+
} else {
|
|
5214
|
+
request.on("socket", doWithSocket);
|
|
5215
|
+
}
|
|
5216
|
+
};
|
|
5217
|
+
if (timeoutInMs < 2000) {
|
|
5218
|
+
registerTimeout(0);
|
|
5219
|
+
return 0;
|
|
5220
|
+
}
|
|
5221
|
+
return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME$2), DEFER_EVENT_LISTENER_TIME$2);
|
|
5222
|
+
};
|
|
5223
|
+
var setRequestTimeout = (req, reject, timeoutInMs = 0, throwOnRequestTimeout, logger) => {
|
|
5224
|
+
if (timeoutInMs) {
|
|
5225
|
+
return timing.setTimeout(() => {
|
|
5226
|
+
let msg = `@smithy/node-http-handler - [${throwOnRequestTimeout ? "ERROR" : "WARN"}] a request has exceeded the configured ${timeoutInMs} ms requestTimeout.`;
|
|
5227
|
+
if (throwOnRequestTimeout) {
|
|
5228
|
+
const error = Object.assign(new Error(msg), {
|
|
5229
|
+
name: "TimeoutError",
|
|
5230
|
+
code: "ETIMEDOUT"
|
|
5231
|
+
});
|
|
5232
|
+
req.destroy(error);
|
|
5233
|
+
reject(error);
|
|
5234
|
+
} else {
|
|
5235
|
+
msg += ` Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.`;
|
|
5236
|
+
logger?.warn?.(msg);
|
|
5237
|
+
}
|
|
5238
|
+
}, timeoutInMs);
|
|
5239
|
+
}
|
|
5240
|
+
return -1;
|
|
5241
|
+
};
|
|
5242
|
+
var DEFER_EVENT_LISTENER_TIME$1 = 3000;
|
|
5243
|
+
var setSocketKeepAlive = (request, { keepAlive, keepAliveMsecs }, deferTimeMs = DEFER_EVENT_LISTENER_TIME$1) => {
|
|
5244
|
+
if (keepAlive !== true) {
|
|
5245
|
+
return -1;
|
|
5246
|
+
}
|
|
5247
|
+
const registerListener = () => {
|
|
5248
|
+
if (request.socket) {
|
|
5249
|
+
request.socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
5250
|
+
} else {
|
|
5251
|
+
request.on("socket", (socket) => {
|
|
5252
|
+
socket.setKeepAlive(keepAlive, keepAliveMsecs || 0);
|
|
5253
|
+
});
|
|
5254
|
+
}
|
|
5255
|
+
};
|
|
5256
|
+
if (deferTimeMs === 0) {
|
|
5257
|
+
registerListener();
|
|
5258
|
+
return 0;
|
|
5259
|
+
}
|
|
5260
|
+
return timing.setTimeout(registerListener, deferTimeMs);
|
|
5261
|
+
};
|
|
5262
|
+
var DEFER_EVENT_LISTENER_TIME = 3000;
|
|
5263
|
+
var setSocketTimeout = (request, reject, timeoutInMs = 0) => {
|
|
5264
|
+
const registerTimeout = (offset) => {
|
|
5265
|
+
const timeout = timeoutInMs - offset;
|
|
5266
|
+
const onTimeout = () => {
|
|
5267
|
+
request.destroy();
|
|
5268
|
+
reject(Object.assign(new Error(`@smithy/node-http-handler - the request socket timed out after ${timeoutInMs} ms of inactivity (configured by client requestHandler).`), { name: "TimeoutError" }));
|
|
5269
|
+
};
|
|
5270
|
+
if (request.socket) {
|
|
5271
|
+
request.socket.setTimeout(timeout, onTimeout);
|
|
5272
|
+
request.on("close", () => request.socket?.removeListener("timeout", onTimeout));
|
|
5273
|
+
} else {
|
|
5274
|
+
request.setTimeout(timeout, onTimeout);
|
|
5275
|
+
}
|
|
5276
|
+
};
|
|
5277
|
+
if (0 < timeoutInMs && timeoutInMs < 6000) {
|
|
5278
|
+
registerTimeout(0);
|
|
5279
|
+
return 0;
|
|
5280
|
+
}
|
|
5281
|
+
return timing.setTimeout(registerTimeout.bind(null, timeoutInMs === 0 ? 0 : DEFER_EVENT_LISTENER_TIME), DEFER_EVENT_LISTENER_TIME);
|
|
5282
|
+
};
|
|
5283
|
+
var MIN_WAIT_TIME = 6000;
|
|
5284
|
+
async function writeRequestBody(httpRequest, request, maxContinueTimeoutMs = MIN_WAIT_TIME, externalAgent = false) {
|
|
5285
|
+
const headers = request.headers;
|
|
5286
|
+
const expect = headers ? headers.Expect || headers.expect : undefined;
|
|
5287
|
+
let timeoutId = -1;
|
|
5288
|
+
let sendBody = true;
|
|
5289
|
+
if (!externalAgent && expect === "100-continue") {
|
|
5290
|
+
sendBody = await Promise.race([
|
|
5291
|
+
new Promise((resolve) => {
|
|
5292
|
+
timeoutId = Number(timing.setTimeout(() => resolve(true), Math.max(MIN_WAIT_TIME, maxContinueTimeoutMs)));
|
|
5293
|
+
}),
|
|
5294
|
+
new Promise((resolve) => {
|
|
5295
|
+
httpRequest.on("continue", () => {
|
|
5296
|
+
timing.clearTimeout(timeoutId);
|
|
5297
|
+
resolve(true);
|
|
5298
|
+
});
|
|
5299
|
+
httpRequest.on("response", () => {
|
|
5300
|
+
timing.clearTimeout(timeoutId);
|
|
5301
|
+
resolve(false);
|
|
5302
|
+
});
|
|
5303
|
+
httpRequest.on("error", () => {
|
|
5304
|
+
timing.clearTimeout(timeoutId);
|
|
5305
|
+
resolve(false);
|
|
5306
|
+
});
|
|
5307
|
+
})
|
|
5308
|
+
]);
|
|
5309
|
+
}
|
|
5310
|
+
if (sendBody) {
|
|
5311
|
+
writeBody(httpRequest, request.body);
|
|
5312
|
+
}
|
|
5313
|
+
}
|
|
5314
|
+
function writeBody(httpRequest, body) {
|
|
5315
|
+
if (body instanceof Readable) {
|
|
5316
|
+
body.pipe(httpRequest);
|
|
5317
|
+
return;
|
|
5318
|
+
}
|
|
5319
|
+
if (body) {
|
|
5320
|
+
const isBuffer = Buffer.isBuffer(body);
|
|
5321
|
+
const isString = typeof body === "string";
|
|
5322
|
+
if (isBuffer || isString) {
|
|
5323
|
+
if (isBuffer && body.byteLength === 0) {
|
|
5324
|
+
httpRequest.end();
|
|
5325
|
+
} else {
|
|
5326
|
+
httpRequest.end(body);
|
|
5327
|
+
}
|
|
5328
|
+
return;
|
|
5329
|
+
}
|
|
5330
|
+
const uint8 = body;
|
|
5331
|
+
if (typeof uint8 === "object" && uint8.buffer && typeof uint8.byteOffset === "number" && typeof uint8.byteLength === "number") {
|
|
5332
|
+
httpRequest.end(Buffer.from(uint8.buffer, uint8.byteOffset, uint8.byteLength));
|
|
5333
|
+
return;
|
|
5334
|
+
}
|
|
5335
|
+
httpRequest.end(Buffer.from(body));
|
|
5336
|
+
return;
|
|
5337
|
+
}
|
|
5338
|
+
httpRequest.end();
|
|
5339
|
+
}
|
|
5340
|
+
var hAgent = undefined;
|
|
5341
|
+
var hRequest = undefined;
|
|
5342
|
+
|
|
5343
|
+
class NodeHttpHandler {
|
|
5344
|
+
config;
|
|
5345
|
+
configProvider;
|
|
5346
|
+
socketWarningTimestamp = 0;
|
|
5347
|
+
externalAgent = false;
|
|
5348
|
+
metadata = { handlerProtocol: "http/1.1" };
|
|
5349
|
+
static create(instanceOrOptions) {
|
|
5350
|
+
if (typeof instanceOrOptions?.handle === "function") {
|
|
5351
|
+
return instanceOrOptions;
|
|
5352
|
+
}
|
|
5353
|
+
return new NodeHttpHandler(instanceOrOptions);
|
|
5354
|
+
}
|
|
5355
|
+
static checkSocketUsage(agent, socketWarningTimestamp, logger = console) {
|
|
5356
|
+
const { sockets, requests, maxSockets } = agent;
|
|
5357
|
+
if (typeof maxSockets !== "number" || maxSockets === Infinity) {
|
|
5358
|
+
return socketWarningTimestamp;
|
|
5359
|
+
}
|
|
5360
|
+
const interval = 15000;
|
|
5361
|
+
if (Date.now() - interval < socketWarningTimestamp) {
|
|
5362
|
+
return socketWarningTimestamp;
|
|
5363
|
+
}
|
|
5364
|
+
if (sockets && requests) {
|
|
5365
|
+
for (const origin in sockets) {
|
|
5366
|
+
if (!hasOwn(sockets, origin))
|
|
5367
|
+
continue;
|
|
5368
|
+
const socketsInUse = sockets[origin]?.length ?? 0;
|
|
5369
|
+
const requestsEnqueued = requests[origin]?.length ?? 0;
|
|
5370
|
+
if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
|
|
5371
|
+
logger?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
|
|
5372
|
+
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
|
|
5373
|
+
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
|
|
5374
|
+
return Date.now();
|
|
5375
|
+
}
|
|
5376
|
+
}
|
|
5377
|
+
}
|
|
5378
|
+
return socketWarningTimestamp;
|
|
5379
|
+
}
|
|
5380
|
+
constructor(options) {
|
|
5381
|
+
this.configProvider = new Promise((resolve, reject) => {
|
|
5382
|
+
if (typeof options === "function") {
|
|
5383
|
+
options().then((_options) => {
|
|
5384
|
+
resolve(this.resolveDefaultConfig(_options));
|
|
5385
|
+
}).catch(reject);
|
|
5386
|
+
} else {
|
|
5387
|
+
resolve(this.resolveDefaultConfig(options));
|
|
5388
|
+
}
|
|
5389
|
+
});
|
|
5390
|
+
}
|
|
5391
|
+
destroy() {
|
|
5392
|
+
this.config?.httpAgent?.destroy();
|
|
5393
|
+
this.config?.httpsAgent?.destroy();
|
|
5394
|
+
}
|
|
5395
|
+
async handle(request, { abortSignal, requestTimeout } = {}) {
|
|
5396
|
+
if (!this.config) {
|
|
5397
|
+
this.config = await this.configProvider;
|
|
5398
|
+
}
|
|
5399
|
+
const config = this.config;
|
|
5400
|
+
const logger = config.logger;
|
|
5401
|
+
const isSSL = request.protocol === "https:";
|
|
5402
|
+
if (!isSSL && !this.config.httpAgent) {
|
|
5403
|
+
this.config.httpAgent = await this.config.httpAgentProvider();
|
|
5404
|
+
}
|
|
5405
|
+
return new Promise((_resolve, _reject) => {
|
|
5406
|
+
let writeRequestBodyPromise = undefined;
|
|
5407
|
+
let socketWarningTimeoutId = -1;
|
|
5408
|
+
let connectionTimeoutId = -1;
|
|
5409
|
+
let requestTimeoutId = -1;
|
|
5410
|
+
let socketTimeoutId = -1;
|
|
5411
|
+
let keepAliveTimeoutId = -1;
|
|
5412
|
+
const clearTimeouts = () => {
|
|
5413
|
+
timing.clearTimeout(socketWarningTimeoutId);
|
|
5414
|
+
timing.clearTimeout(connectionTimeoutId);
|
|
5415
|
+
timing.clearTimeout(requestTimeoutId);
|
|
5416
|
+
timing.clearTimeout(socketTimeoutId);
|
|
5417
|
+
timing.clearTimeout(keepAliveTimeoutId);
|
|
5418
|
+
};
|
|
5419
|
+
const resolve = async (arg) => {
|
|
5420
|
+
await writeRequestBodyPromise;
|
|
5421
|
+
clearTimeouts();
|
|
5422
|
+
_resolve(arg);
|
|
5423
|
+
};
|
|
5424
|
+
const reject = async (arg) => {
|
|
5425
|
+
await writeRequestBodyPromise;
|
|
5426
|
+
clearTimeouts();
|
|
5427
|
+
_reject(arg);
|
|
5428
|
+
};
|
|
5429
|
+
if (abortSignal?.aborted) {
|
|
5430
|
+
const abortError = buildAbortError(abortSignal);
|
|
5431
|
+
reject(abortError);
|
|
5432
|
+
return;
|
|
5433
|
+
}
|
|
5434
|
+
const headers = request.headers;
|
|
5435
|
+
const expectContinue = headers ? (headers.Expect ?? headers.expect) === "100-continue" : false;
|
|
5436
|
+
let agent = isSSL ? config.httpsAgent : config.httpAgent;
|
|
5437
|
+
if (expectContinue && !this.externalAgent) {
|
|
5438
|
+
agent = new (isSSL ? node_https.Agent : hAgent)({
|
|
5439
|
+
keepAlive: false,
|
|
5440
|
+
maxSockets: Infinity
|
|
5441
|
+
});
|
|
5442
|
+
}
|
|
5443
|
+
socketWarningTimeoutId = timing.setTimeout(() => {
|
|
5444
|
+
this.socketWarningTimestamp = NodeHttpHandler.checkSocketUsage(agent, this.socketWarningTimestamp, logger);
|
|
5445
|
+
}, config.socketAcquisitionWarningTimeout ?? (config.requestTimeout ?? 2000) + (config.connectionTimeout ?? 1000));
|
|
5446
|
+
const queryString = request.query ? buildQueryString(request.query) : "";
|
|
5447
|
+
let auth = undefined;
|
|
5448
|
+
if (request.username != null || request.password != null) {
|
|
5449
|
+
const username = request.username ?? "";
|
|
5450
|
+
const password = request.password ?? "";
|
|
5451
|
+
auth = `${username}:${password}`;
|
|
5452
|
+
}
|
|
5453
|
+
let path = request.path;
|
|
5454
|
+
if (queryString) {
|
|
5455
|
+
path += `?${queryString}`;
|
|
5456
|
+
}
|
|
5457
|
+
if (request.fragment) {
|
|
5458
|
+
path += `#${request.fragment}`;
|
|
5459
|
+
}
|
|
5460
|
+
let hostname = request.hostname ?? "";
|
|
5461
|
+
if (hostname[0] === "[" && hostname.endsWith("]")) {
|
|
5462
|
+
hostname = request.hostname.slice(1, -1);
|
|
5463
|
+
} else {
|
|
5464
|
+
hostname = request.hostname;
|
|
5465
|
+
}
|
|
5466
|
+
const nodeHttpsOptions = {
|
|
5467
|
+
headers: request.headers,
|
|
5468
|
+
host: hostname,
|
|
5469
|
+
method: request.method,
|
|
5470
|
+
path,
|
|
5471
|
+
port: request.port,
|
|
5472
|
+
agent,
|
|
5473
|
+
auth
|
|
5474
|
+
};
|
|
5475
|
+
const requestFunc = isSSL ? node_https.request : hRequest;
|
|
5476
|
+
const req = requestFunc(nodeHttpsOptions, (res) => {
|
|
5477
|
+
const httpResponse = new HttpResponse({
|
|
5478
|
+
statusCode: res.statusCode || -1,
|
|
5479
|
+
reason: res.statusMessage,
|
|
5480
|
+
headers: getTransformedHeaders(res.headers),
|
|
5481
|
+
body: res
|
|
5482
|
+
});
|
|
5483
|
+
resolve({ response: httpResponse });
|
|
5484
|
+
});
|
|
5485
|
+
req.on("error", (err) => {
|
|
5486
|
+
if (NODEJS_TIMEOUT_ERROR_CODES.includes(err.code)) {
|
|
5487
|
+
reject(Object.assign(err, { name: "TimeoutError" }));
|
|
5488
|
+
} else {
|
|
5489
|
+
reject(err);
|
|
5490
|
+
}
|
|
5491
|
+
});
|
|
5492
|
+
if (abortSignal) {
|
|
5493
|
+
const onAbort = () => {
|
|
5494
|
+
req.destroy();
|
|
5495
|
+
const abortError = buildAbortError(abortSignal);
|
|
5496
|
+
reject(abortError);
|
|
5497
|
+
};
|
|
5498
|
+
if (typeof abortSignal.addEventListener === "function") {
|
|
5499
|
+
const signal = abortSignal;
|
|
5500
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
5501
|
+
req.once("close", () => signal.removeEventListener("abort", onAbort));
|
|
5502
|
+
} else {
|
|
5503
|
+
abortSignal.onabort = onAbort;
|
|
5504
|
+
}
|
|
5505
|
+
}
|
|
5506
|
+
const effectiveRequestTimeout = requestTimeout ?? config.requestTimeout;
|
|
5507
|
+
connectionTimeoutId = setConnectionTimeout(req, reject, config.connectionTimeout);
|
|
5508
|
+
requestTimeoutId = setRequestTimeout(req, reject, effectiveRequestTimeout, config.throwOnRequestTimeout, logger ?? console);
|
|
5509
|
+
socketTimeoutId = setSocketTimeout(req, reject, config.socketTimeout);
|
|
5510
|
+
const httpAgent = nodeHttpsOptions.agent;
|
|
5511
|
+
if (typeof httpAgent === "object" && "keepAlive" in httpAgent) {
|
|
5512
|
+
keepAliveTimeoutId = setSocketKeepAlive(req, {
|
|
5513
|
+
keepAlive: httpAgent.keepAlive,
|
|
5514
|
+
keepAliveMsecs: httpAgent.keepAliveMsecs
|
|
5515
|
+
});
|
|
5516
|
+
}
|
|
5517
|
+
writeRequestBodyPromise = writeRequestBody(req, request, effectiveRequestTimeout, this.externalAgent).catch((e) => {
|
|
5518
|
+
clearTimeouts();
|
|
5519
|
+
return _reject(e);
|
|
5520
|
+
});
|
|
5521
|
+
});
|
|
5522
|
+
}
|
|
5523
|
+
updateHttpClientConfig(key, value) {
|
|
5524
|
+
this.config = undefined;
|
|
5525
|
+
this.configProvider = this.configProvider.then((config) => {
|
|
5526
|
+
if (key === Symbol.for("logger")) {
|
|
5527
|
+
return {
|
|
5528
|
+
...config,
|
|
5529
|
+
logger: config.logger ?? value
|
|
5530
|
+
};
|
|
5531
|
+
}
|
|
5532
|
+
return {
|
|
5533
|
+
...config,
|
|
5534
|
+
[key]: value
|
|
5535
|
+
};
|
|
5536
|
+
});
|
|
5537
|
+
}
|
|
5538
|
+
httpHandlerConfigs() {
|
|
5539
|
+
return this.config ?? {};
|
|
5540
|
+
}
|
|
5541
|
+
resolveDefaultConfig(options) {
|
|
5542
|
+
const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent, throwOnRequestTimeout, logger } = options || {};
|
|
5543
|
+
const keepAlive = true;
|
|
5544
|
+
const maxSockets = 50;
|
|
5545
|
+
return {
|
|
5546
|
+
connectionTimeout,
|
|
5547
|
+
requestTimeout,
|
|
5548
|
+
socketTimeout,
|
|
5549
|
+
socketAcquisitionWarningTimeout,
|
|
5550
|
+
throwOnRequestTimeout,
|
|
5551
|
+
httpAgentProvider: async () => {
|
|
5552
|
+
const node_http = __require("node:http");
|
|
5553
|
+
const { Agent, request } = node_http.default ?? node_http;
|
|
5554
|
+
hRequest = request;
|
|
5555
|
+
hAgent = Agent;
|
|
5556
|
+
if (httpAgent instanceof hAgent || typeof httpAgent?.destroy === "function") {
|
|
5557
|
+
this.externalAgent = true;
|
|
5558
|
+
return httpAgent;
|
|
5559
|
+
}
|
|
5560
|
+
return new hAgent({ keepAlive, maxSockets, ...httpAgent });
|
|
5561
|
+
},
|
|
5562
|
+
httpsAgent: (() => {
|
|
5563
|
+
if (httpsAgent instanceof node_https.Agent || typeof httpsAgent?.destroy === "function") {
|
|
5564
|
+
this.externalAgent = true;
|
|
5565
|
+
return httpsAgent;
|
|
5566
|
+
}
|
|
5567
|
+
return new node_https.Agent({ keepAlive, maxSockets, ...httpsAgent });
|
|
5568
|
+
})(),
|
|
5569
|
+
logger
|
|
5570
|
+
};
|
|
5571
|
+
}
|
|
5572
|
+
}
|
|
5573
|
+
var ids = new Uint16Array(1);
|
|
5574
|
+
var { constants } = http2;
|
|
5575
|
+
var $NodeHttpHandler = NodeHttpHandler;
|
|
4321
5576
|
|
|
4322
5577
|
// node_modules/http-proxy-agent/dist/index.js
|
|
4323
5578
|
var import_debug = __toESM(require_src3(), 1);
|
|
@@ -4904,12 +6159,12 @@ var stream = (model, context, options = {}) => {
|
|
|
4904
6159
|
}
|
|
4905
6160
|
const proxyUrl = resolveHttpProxyUrlForTarget(model.baseUrl, options.env);
|
|
4906
6161
|
if (proxyUrl) {
|
|
4907
|
-
config.requestHandler = new
|
|
6162
|
+
config.requestHandler = new $NodeHttpHandler({
|
|
4908
6163
|
httpAgent: new HttpProxyAgent(proxyUrl),
|
|
4909
6164
|
httpsAgent: new HttpsProxyAgent(proxyUrl)
|
|
4910
6165
|
});
|
|
4911
6166
|
} else if (getProviderEnvValue("AWS_BEDROCK_FORCE_HTTP1", options.env) === "1") {
|
|
4912
|
-
config.requestHandler = new
|
|
6167
|
+
config.requestHandler = new $NodeHttpHandler;
|
|
4913
6168
|
}
|
|
4914
6169
|
} else {
|
|
4915
6170
|
config.region = configuredRegion || (endpointRegion && useExplicitEndpoint ? endpointRegion : undefined) || "us-east-1";
|