@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
|
@@ -13,8 +13,8 @@ import {
|
|
|
13
13
|
__esm
|
|
14
14
|
} from "./cli-242037k3.js";
|
|
15
15
|
|
|
16
|
-
// node_modules/@ai-sdk/provider/dist/index.mjs
|
|
17
|
-
function
|
|
16
|
+
// node_modules/@ai-sdk/provider-utils/node_modules/@ai-sdk/provider/dist/index.mjs
|
|
17
|
+
function getErrorMessage2(error) {
|
|
18
18
|
if (error == null) {
|
|
19
19
|
return "unknown error";
|
|
20
20
|
}
|
|
@@ -26,24 +26,6 @@ function getErrorMessage(error) {
|
|
|
26
26
|
}
|
|
27
27
|
return JSON.stringify(error);
|
|
28
28
|
}
|
|
29
|
-
function isJSONValue(value) {
|
|
30
|
-
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
if (Array.isArray(value)) {
|
|
34
|
-
return value.every(isJSONValue);
|
|
35
|
-
}
|
|
36
|
-
if (typeof value === "object") {
|
|
37
|
-
return Object.entries(value).every(([key, val]) => typeof key === "string" && (val === undefined || isJSONValue(val)));
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
function isJSONArray(value) {
|
|
42
|
-
return Array.isArray(value) && value.every(isJSONValue);
|
|
43
|
-
}
|
|
44
|
-
function isJSONObject(value) {
|
|
45
|
-
return value != null && typeof value === "object" && Object.entries(value).every(([key, val]) => typeof key === "string" && (val === undefined || isJSONValue(val)));
|
|
46
|
-
}
|
|
47
29
|
var marker = "vercel.ai.error", symbol, _a, _b, AISDKError, name = "AI_APICallError", marker2, symbol2, _a2, _b2, APICallError, name2 = "AI_EmptyResponseBodyError", marker3, symbol3, _a3, _b3, EmptyResponseBodyError, name3 = "AI_InvalidArgumentError", marker4, symbol4, _a4, _b4, InvalidArgumentError, name4 = "AI_InvalidPromptError", marker5, symbol5, _a5, _b5, InvalidPromptError, name5 = "AI_InvalidResponseDataError", marker6, symbol6, _a6, _b6, InvalidResponseDataError, name6 = "AI_JSONParseError", marker7, symbol7, _a7, _b7, JSONParseError, name7 = "AI_LoadAPIKeyError", marker8, symbol8, _a8, _b8, LoadAPIKeyError, name8 = "AI_LoadSettingError", marker9, symbol9, _a9, _b9, LoadSettingError, name9 = "AI_NoContentGeneratedError", marker10, symbol10, _a10, _b10, NoContentGeneratedError, name10 = "AI_NoSuchModelError", marker11, symbol11, _a11, _b11, NoSuchModelError, name11 = "AI_TooManyEmbeddingValuesForCallError", marker12, symbol12, _a12, _b12, TooManyEmbeddingValuesForCallError, name12 = "AI_TypeValidationError", marker13, symbol13, _a13, _b13, TypeValidationError, name13 = "AI_UnsupportedFunctionalityError", marker14, symbol14, _a14, _b14, UnsupportedFunctionalityError;
|
|
48
30
|
var init_dist = __esm(() => {
|
|
49
31
|
symbol = Symbol.for(marker);
|
|
@@ -159,7 +141,7 @@ var init_dist = __esm(() => {
|
|
|
159
141
|
super({
|
|
160
142
|
name: name6,
|
|
161
143
|
message: `JSON parsing failed: Text: ${text}.
|
|
162
|
-
Error message: ${
|
|
144
|
+
Error message: ${getErrorMessage2(cause)}`,
|
|
163
145
|
cause
|
|
164
146
|
});
|
|
165
147
|
this[_a7] = true;
|
|
@@ -267,7 +249,7 @@ Error message: ${getErrorMessage(cause)}`,
|
|
|
267
249
|
super({
|
|
268
250
|
name: name12,
|
|
269
251
|
message: `${contextPrefix}: Value: ${JSON.stringify(value)}.
|
|
270
|
-
Error message: ${
|
|
252
|
+
Error message: ${getErrorMessage2(cause)}`,
|
|
271
253
|
cause
|
|
272
254
|
});
|
|
273
255
|
this[_a13] = true;
|
|
@@ -458,7 +440,7 @@ function isEventPrefix(chunk, i, firstCharCode) {
|
|
|
458
440
|
return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
|
|
459
441
|
}
|
|
460
442
|
var ParseError, LF = 10, CR = 13, SPACE = 32;
|
|
461
|
-
var
|
|
443
|
+
var init_dist2 = __esm(() => {
|
|
462
444
|
ParseError = class ParseError extends Error {
|
|
463
445
|
constructor(message, options) {
|
|
464
446
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
@@ -469,7 +451,7 @@ var init_dist3 = __esm(() => {
|
|
|
469
451
|
// node_modules/eventsource-parser/dist/stream.js
|
|
470
452
|
var EventSourceParserStream;
|
|
471
453
|
var init_stream = __esm(() => {
|
|
472
|
-
|
|
454
|
+
init_dist2();
|
|
473
455
|
EventSourceParserStream = class EventSourceParserStream extends TransformStream {
|
|
474
456
|
constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
|
|
475
457
|
let parser;
|
|
@@ -499,7 +481,7 @@ var init_stream = __esm(() => {
|
|
|
499
481
|
function combineHeaders(...headers) {
|
|
500
482
|
return headers.reduce((combinedHeaders, currentHeaders) => ({
|
|
501
483
|
...combinedHeaders,
|
|
502
|
-
...currentHeaders
|
|
484
|
+
...currentHeaders
|
|
503
485
|
}), {});
|
|
504
486
|
}
|
|
505
487
|
function createToolNameMapping({
|
|
@@ -533,7 +515,7 @@ function createToolNameMapping({
|
|
|
533
515
|
}
|
|
534
516
|
async function delay(delayInMs, options) {
|
|
535
517
|
if (delayInMs == null) {
|
|
536
|
-
return
|
|
518
|
+
return;
|
|
537
519
|
}
|
|
538
520
|
const signal = options == null ? undefined : options.abortSignal;
|
|
539
521
|
return new Promise((resolve2, reject) => {
|
|
@@ -565,17 +547,40 @@ function extractResponseHeaders(response) {
|
|
|
565
547
|
function convertBase64ToUint8Array(base64String) {
|
|
566
548
|
const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
567
549
|
const latin1string = atob(base64Url);
|
|
568
|
-
|
|
550
|
+
const bytes = new Uint8Array(latin1string.length);
|
|
551
|
+
for (let i = 0;i < latin1string.length; i++) {
|
|
552
|
+
bytes[i] = latin1string.charCodeAt(i);
|
|
553
|
+
}
|
|
554
|
+
return bytes;
|
|
569
555
|
}
|
|
570
556
|
function convertUint8ArrayToBase64(array) {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
557
|
+
var _a2;
|
|
558
|
+
if (typeof ((_a2 = globalThis.Buffer) == null ? undefined : _a2.from) === "function") {
|
|
559
|
+
return globalThis.Buffer.from(array.buffer, array.byteOffset, array.byteLength).toString("base64");
|
|
560
|
+
}
|
|
561
|
+
const chunks = [];
|
|
562
|
+
const chunkSize = 4096;
|
|
563
|
+
for (let i = 0;i < array.length; i += chunkSize) {
|
|
564
|
+
chunks.push(String.fromCodePoint(...array.subarray(i, i + chunkSize)));
|
|
565
|
+
}
|
|
566
|
+
return btoa(chunks.join(""));
|
|
567
|
+
}
|
|
568
|
+
function isUint8Array(value) {
|
|
569
|
+
return ArrayBuffer.isView(value) && typedArrayTag.call(value) === "Uint8Array";
|
|
570
|
+
}
|
|
571
|
+
function isArrayBuffer(value) {
|
|
572
|
+
if (typeof value !== "object" || value === null || !("byteLength" in value)) {
|
|
573
|
+
return false;
|
|
574
|
+
}
|
|
575
|
+
try {
|
|
576
|
+
arrayBufferByteLength.call(value);
|
|
577
|
+
return true;
|
|
578
|
+
} catch (e) {
|
|
579
|
+
return false;
|
|
574
580
|
}
|
|
575
|
-
return btoa(latin1string);
|
|
576
581
|
}
|
|
577
582
|
function convertToBase64(value) {
|
|
578
|
-
return value
|
|
583
|
+
return isUint8Array(value) ? convertUint8ArrayToBase64(value) : value;
|
|
579
584
|
}
|
|
580
585
|
function convertToFormData(input, options = {}) {
|
|
581
586
|
const { useArrayBrackets = true } = options;
|
|
@@ -599,57 +604,21 @@ function convertToFormData(input, options = {}) {
|
|
|
599
604
|
}
|
|
600
605
|
return formData;
|
|
601
606
|
}
|
|
602
|
-
async function
|
|
603
|
-
|
|
604
|
-
url,
|
|
605
|
-
maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE
|
|
606
|
-
}) {
|
|
607
|
-
const contentLength = response.headers.get("content-length");
|
|
608
|
-
if (contentLength != null) {
|
|
609
|
-
const length = parseInt(contentLength, 10);
|
|
610
|
-
if (!isNaN(length) && length > maxBytes) {
|
|
611
|
-
throw new DownloadError({
|
|
612
|
-
url,
|
|
613
|
-
message: `Download of ${url} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
|
|
614
|
-
});
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
const body = response.body;
|
|
618
|
-
if (body == null) {
|
|
619
|
-
return new Uint8Array(0);
|
|
620
|
-
}
|
|
621
|
-
const reader = body.getReader();
|
|
622
|
-
const chunks = [];
|
|
623
|
-
let totalBytes = 0;
|
|
607
|
+
async function cancelResponseBody(response) {
|
|
608
|
+
var _a2;
|
|
624
609
|
try {
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
}
|
|
637
|
-
chunks.push(value);
|
|
638
|
-
}
|
|
639
|
-
} finally {
|
|
640
|
-
try {
|
|
641
|
-
await reader.cancel();
|
|
642
|
-
} finally {
|
|
643
|
-
reader.releaseLock();
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
const result = new Uint8Array(totalBytes);
|
|
647
|
-
let offset = 0;
|
|
648
|
-
for (const chunk of chunks) {
|
|
649
|
-
result.set(chunk, offset);
|
|
650
|
-
offset += chunk.length;
|
|
610
|
+
await ((_a2 = response.body) == null ? undefined : _a2.cancel());
|
|
611
|
+
} catch (e) {}
|
|
612
|
+
}
|
|
613
|
+
function isBrowserRuntime(globalThisAny = globalThis) {
|
|
614
|
+
return globalThisAny.window != null;
|
|
615
|
+
}
|
|
616
|
+
function isSameOrigin(url, baseUrl) {
|
|
617
|
+
try {
|
|
618
|
+
return new URL(url).origin === new URL(baseUrl).origin;
|
|
619
|
+
} catch (e) {
|
|
620
|
+
return false;
|
|
651
621
|
}
|
|
652
|
-
return result;
|
|
653
622
|
}
|
|
654
623
|
function validateDownloadUrl(url) {
|
|
655
624
|
let parsed;
|
|
@@ -661,20 +630,23 @@ function validateDownloadUrl(url) {
|
|
|
661
630
|
message: `Invalid URL: ${url}`
|
|
662
631
|
});
|
|
663
632
|
}
|
|
633
|
+
if (parsed.protocol === "data:") {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
664
636
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
665
637
|
throw new DownloadError({
|
|
666
638
|
url,
|
|
667
|
-
message: `URL scheme must be http or
|
|
639
|
+
message: `URL scheme must be http, https, or data, got ${parsed.protocol}`
|
|
668
640
|
});
|
|
669
641
|
}
|
|
670
|
-
const hostname = parsed.hostname;
|
|
642
|
+
const hostname = parsed.hostname.toLowerCase().replace(/\.+$/, "");
|
|
671
643
|
if (!hostname) {
|
|
672
644
|
throw new DownloadError({
|
|
673
645
|
url,
|
|
674
646
|
message: `URL must have a hostname`
|
|
675
647
|
});
|
|
676
648
|
}
|
|
677
|
-
if (hostname === "localhost" || hostname.endsWith(".local") || hostname.endsWith(".localhost")) {
|
|
649
|
+
if (hostname === "localhost" || hostname.endsWith(".local") || hostname.endsWith(".localhost") || hostname.endsWith(".internal")) {
|
|
678
650
|
throw new DownloadError({
|
|
679
651
|
url,
|
|
680
652
|
message: `URL with hostname ${hostname} is not allowed`
|
|
@@ -697,7 +669,19 @@ function validateDownloadUrl(url) {
|
|
|
697
669
|
message: `URL with IP address ${hostname} is not allowed`
|
|
698
670
|
});
|
|
699
671
|
}
|
|
700
|
-
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
function validateDownloadAddress({
|
|
675
|
+
address,
|
|
676
|
+
family,
|
|
677
|
+
hostname
|
|
678
|
+
}) {
|
|
679
|
+
const isUnsafe = family === 4 ? !isIPv4(address) || isPrivateIPv4(address) : family === 6 ? isPrivateIPv6(address) : true;
|
|
680
|
+
if (isUnsafe) {
|
|
681
|
+
throw new DownloadError({
|
|
682
|
+
url: hostname,
|
|
683
|
+
message: `Hostname ${hostname} resolved to disallowed IP address ${address}`
|
|
684
|
+
});
|
|
701
685
|
}
|
|
702
686
|
}
|
|
703
687
|
function isIPv4(hostname) {
|
|
@@ -711,59 +695,306 @@ function isIPv4(hostname) {
|
|
|
711
695
|
}
|
|
712
696
|
function isPrivateIPv4(ip) {
|
|
713
697
|
const parts = ip.split(".").map(Number);
|
|
714
|
-
const [a, b] = parts;
|
|
698
|
+
const [a, b, c] = parts;
|
|
715
699
|
if (a === 0)
|
|
716
700
|
return true;
|
|
717
701
|
if (a === 10)
|
|
718
702
|
return true;
|
|
703
|
+
if (a === 100 && b >= 64 && b <= 127)
|
|
704
|
+
return true;
|
|
719
705
|
if (a === 127)
|
|
720
706
|
return true;
|
|
721
707
|
if (a === 169 && b === 254)
|
|
722
708
|
return true;
|
|
723
709
|
if (a === 172 && b >= 16 && b <= 31)
|
|
724
710
|
return true;
|
|
711
|
+
if (a === 192 && b === 0 && c === 0)
|
|
712
|
+
return true;
|
|
725
713
|
if (a === 192 && b === 168)
|
|
726
714
|
return true;
|
|
715
|
+
if (a === 198 && (b === 18 || b === 19))
|
|
716
|
+
return true;
|
|
717
|
+
if (a >= 240)
|
|
718
|
+
return true;
|
|
727
719
|
return false;
|
|
728
720
|
}
|
|
721
|
+
function parseIPv6(ip) {
|
|
722
|
+
let address = ip.toLowerCase();
|
|
723
|
+
const zoneIndex = address.indexOf("%");
|
|
724
|
+
if (zoneIndex !== -1) {
|
|
725
|
+
address = address.slice(0, zoneIndex);
|
|
726
|
+
}
|
|
727
|
+
const halves = address.split("::");
|
|
728
|
+
if (halves.length > 2)
|
|
729
|
+
return null;
|
|
730
|
+
const toGroups = (segment) => {
|
|
731
|
+
if (segment === "")
|
|
732
|
+
return [];
|
|
733
|
+
const groups = [];
|
|
734
|
+
const parts = segment.split(":");
|
|
735
|
+
for (let i = 0;i < parts.length; i++) {
|
|
736
|
+
const part = parts[i];
|
|
737
|
+
if (part.includes(".")) {
|
|
738
|
+
if (i !== parts.length - 1 || !isIPv4(part))
|
|
739
|
+
return null;
|
|
740
|
+
const [a, b, c, d] = part.split(".").map(Number);
|
|
741
|
+
groups.push(a << 8 | b, c << 8 | d);
|
|
742
|
+
continue;
|
|
743
|
+
}
|
|
744
|
+
if (!/^[0-9a-f]{1,4}$/.test(part))
|
|
745
|
+
return null;
|
|
746
|
+
groups.push(parseInt(part, 16));
|
|
747
|
+
}
|
|
748
|
+
return groups;
|
|
749
|
+
};
|
|
750
|
+
const head = toGroups(halves[0]);
|
|
751
|
+
if (head === null)
|
|
752
|
+
return null;
|
|
753
|
+
if (halves.length === 2) {
|
|
754
|
+
const tail = toGroups(halves[1]);
|
|
755
|
+
if (tail === null)
|
|
756
|
+
return null;
|
|
757
|
+
const fill = 8 - head.length - tail.length;
|
|
758
|
+
if (fill < 0)
|
|
759
|
+
return null;
|
|
760
|
+
return [...head, ...new Array(fill).fill(0), ...tail];
|
|
761
|
+
}
|
|
762
|
+
return head.length === 8 ? head : null;
|
|
763
|
+
}
|
|
729
764
|
function isPrivateIPv6(ip) {
|
|
730
|
-
const
|
|
731
|
-
if (
|
|
765
|
+
const groups = parseIPv6(ip);
|
|
766
|
+
if (groups === null)
|
|
732
767
|
return true;
|
|
733
|
-
|
|
768
|
+
const topZero = (count) => groups.slice(0, count).every((group) => group === 0);
|
|
769
|
+
if (topZero(7) && (groups[7] === 0 || groups[7] === 1))
|
|
734
770
|
return true;
|
|
735
|
-
if (
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
const hexParts = mappedPart.split(":");
|
|
741
|
-
if (hexParts.length === 2) {
|
|
742
|
-
const high = parseInt(hexParts[0], 16);
|
|
743
|
-
const low = parseInt(hexParts[1], 16);
|
|
744
|
-
if (!isNaN(high) && !isNaN(low)) {
|
|
745
|
-
const a = high >> 8 & 255;
|
|
746
|
-
const b = high & 255;
|
|
747
|
-
const c = low >> 8 & 255;
|
|
748
|
-
const d = low & 255;
|
|
749
|
-
return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
if (normalized.startsWith("fc") || normalized.startsWith("fd"))
|
|
771
|
+
if ((groups[0] & 65024) === 64512)
|
|
772
|
+
return true;
|
|
773
|
+
if ((groups[0] & 65472) === 65152)
|
|
774
|
+
return true;
|
|
775
|
+
if ((groups[0] & 65472) === 65216)
|
|
754
776
|
return true;
|
|
755
|
-
if (
|
|
777
|
+
if ((groups[0] & 65280) === 65280)
|
|
756
778
|
return true;
|
|
779
|
+
const embedsIPv4 = topZero(6) || topZero(5) && groups[5] === 65535 || topZero(4) && groups[4] === 65535 && groups[5] === 0 || groups[0] === 100 && groups[1] === 65435 && groups[2] === 0 && groups[3] === 0 && groups[4] === 0 && groups[5] === 0 || groups[0] === 100 && groups[1] === 65435 && groups[2] === 1;
|
|
780
|
+
if (embedsIPv4) {
|
|
781
|
+
const a = groups[6] >> 8 & 255;
|
|
782
|
+
const b = groups[6] & 255;
|
|
783
|
+
const c = groups[7] >> 8 & 255;
|
|
784
|
+
const d = groups[7] & 255;
|
|
785
|
+
return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
|
|
786
|
+
}
|
|
757
787
|
return false;
|
|
758
788
|
}
|
|
789
|
+
function createSafeLookup(lookup) {
|
|
790
|
+
return (hostname, options, callback) => {
|
|
791
|
+
lookup(hostname, { ...options, all: true }, (error, addresses) => {
|
|
792
|
+
if (error) {
|
|
793
|
+
callback(error);
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
try {
|
|
797
|
+
const [firstAddress] = addresses;
|
|
798
|
+
if (firstAddress == null) {
|
|
799
|
+
throw new Error(`Hostname ${hostname} did not resolve to an address`);
|
|
800
|
+
}
|
|
801
|
+
for (const { address, family } of addresses) {
|
|
802
|
+
validateDownloadAddress({ address, family, hostname });
|
|
803
|
+
}
|
|
804
|
+
if (options.all === true) {
|
|
805
|
+
callback(null, addresses);
|
|
806
|
+
} else {
|
|
807
|
+
callback(null, firstAddress.address, firstAddress.family);
|
|
808
|
+
}
|
|
809
|
+
} catch (error2) {
|
|
810
|
+
callback(error2 instanceof Error ? error2 : new Error(String(error2)));
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
function isNodeRuntime() {
|
|
816
|
+
var _a2, _b2, _c;
|
|
817
|
+
const runtimeProcess = globalThis.process;
|
|
818
|
+
return ((_a2 = runtimeProcess == null ? undefined : runtimeProcess.release) == null ? undefined : _a2.name) === "node" && ((_b2 = runtimeProcess.versions) == null ? undefined : _b2.bun) == null && ((_c = runtimeProcess.versions) == null ? undefined : _c.deno) == null && runtimeProcess.title !== "workerd" && globalThis.EdgeRuntime == null;
|
|
819
|
+
}
|
|
820
|
+
async function getDefaultDownloadFetch() {
|
|
821
|
+
if (!isNodeRuntime()) {
|
|
822
|
+
return globalThis.fetch;
|
|
823
|
+
}
|
|
824
|
+
return safeNodeFetchPromise != null ? safeNodeFetchPromise : safeNodeFetchPromise = createSafeNodeFetch();
|
|
825
|
+
}
|
|
826
|
+
async function createSafeNodeFetch() {
|
|
827
|
+
const [module, { lookup }] = await Promise.all([
|
|
828
|
+
loadNodeModule("node:module"),
|
|
829
|
+
loadNodeModule("node:dns")
|
|
830
|
+
]);
|
|
831
|
+
const nodeRequire = module.createRequire(getCurrentModulePath());
|
|
832
|
+
const { Agent, fetch } = nodeRequire("undici");
|
|
833
|
+
const dispatcher = new Agent({
|
|
834
|
+
connect: {
|
|
835
|
+
lookup: createSafeLookup(lookup)
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
return (input, init) => fetch(input, {
|
|
839
|
+
...init,
|
|
840
|
+
dispatcher
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
async function loadNodeModule(id) {
|
|
844
|
+
var _a2;
|
|
845
|
+
const processWithBuiltins = globalThis.process;
|
|
846
|
+
const builtinModule = (_a2 = processWithBuiltins == null ? undefined : processWithBuiltins.getBuiltinModule) == null ? undefined : _a2.call(processWithBuiltins, id);
|
|
847
|
+
if (builtinModule == null) {
|
|
848
|
+
throw new Error(`Node.js built-in module ${id} is unavailable`);
|
|
849
|
+
}
|
|
850
|
+
return builtinModule;
|
|
851
|
+
}
|
|
852
|
+
function getCurrentModulePath() {
|
|
853
|
+
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
854
|
+
try {
|
|
855
|
+
Error.prepareStackTrace = (_error, callSites) => callSites;
|
|
856
|
+
const error = new Error("Capture current module path");
|
|
857
|
+
Error.captureStackTrace(error, getCurrentModulePath);
|
|
858
|
+
const [caller] = error.stack;
|
|
859
|
+
const fileName = caller == null ? undefined : caller.getFileName();
|
|
860
|
+
if (fileName == null) {
|
|
861
|
+
throw new Error("Unable to determine the current module path");
|
|
862
|
+
}
|
|
863
|
+
return fileName;
|
|
864
|
+
} finally {
|
|
865
|
+
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
function sanitizeRequestHeaders(input) {
|
|
869
|
+
const headers = new Headers(input);
|
|
870
|
+
for (const name2 of BLOCKED_REQUEST_HEADERS) {
|
|
871
|
+
headers.delete(name2);
|
|
872
|
+
}
|
|
873
|
+
return headers;
|
|
874
|
+
}
|
|
875
|
+
async function getValidatedFetch(customFetch) {
|
|
876
|
+
return customFetch == null || customFetch === globalThis.fetch ? await getDefaultDownloadFetch() : customFetch;
|
|
877
|
+
}
|
|
878
|
+
async function fetchWithValidatedRedirects({
|
|
879
|
+
url,
|
|
880
|
+
headers,
|
|
881
|
+
abortSignal,
|
|
882
|
+
maxRedirects = MAX_DOWNLOAD_REDIRECTS,
|
|
883
|
+
fetch: customFetch,
|
|
884
|
+
trustedOrigin
|
|
885
|
+
}) {
|
|
886
|
+
var _a2;
|
|
887
|
+
let currentHeaders = headers === undefined ? undefined : sanitizeRequestHeaders(headers);
|
|
888
|
+
const perHopInit = (redirect) => {
|
|
889
|
+
const init = { signal: abortSignal, redirect };
|
|
890
|
+
if (currentHeaders !== undefined) {
|
|
891
|
+
init.headers = new Headers(currentHeaders);
|
|
892
|
+
}
|
|
893
|
+
return init;
|
|
894
|
+
};
|
|
895
|
+
let currentUrl = url;
|
|
896
|
+
for (let redirectCount = 0;redirectCount <= maxRedirects; redirectCount++) {
|
|
897
|
+
const isTrustedHop = trustedOrigin !== undefined && isSameOrigin(currentUrl, trustedOrigin);
|
|
898
|
+
if (!isTrustedHop) {
|
|
899
|
+
validateDownloadUrl(currentUrl);
|
|
900
|
+
}
|
|
901
|
+
const fetch = isTrustedHop && customFetch != null ? customFetch : isTrustedHop ? globalThis.fetch : await getValidatedFetch(customFetch);
|
|
902
|
+
const response = await fetch(currentUrl, perHopInit("manual"));
|
|
903
|
+
if (response.type === "opaqueredirect") {
|
|
904
|
+
if (!isBrowserRuntime()) {
|
|
905
|
+
throw new DownloadError({
|
|
906
|
+
url,
|
|
907
|
+
message: `Redirect from ${currentUrl} could not be validated and was blocked`
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
return await fetch(currentUrl, perHopInit("follow"));
|
|
911
|
+
}
|
|
912
|
+
const location = (_a2 = response.headers) == null ? undefined : _a2.get("location");
|
|
913
|
+
if (REDIRECT_STATUS_CODES.has(response.status) && location) {
|
|
914
|
+
cancelResponseBody(response);
|
|
915
|
+
const nextUrl = new URL(location, currentUrl).toString();
|
|
916
|
+
if (new URL(currentUrl).protocol === "https:" && new URL(nextUrl).protocol === "http:") {
|
|
917
|
+
throw new DownloadError({
|
|
918
|
+
url,
|
|
919
|
+
message: "Redirect from HTTPS to HTTP was blocked"
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
if (currentHeaders !== undefined && !isSameOrigin(nextUrl, currentUrl)) {
|
|
923
|
+
const userAgent = currentHeaders.get("user-agent");
|
|
924
|
+
currentHeaders = new Headers(userAgent == null ? undefined : { "user-agent": userAgent });
|
|
925
|
+
}
|
|
926
|
+
currentUrl = nextUrl;
|
|
927
|
+
continue;
|
|
928
|
+
}
|
|
929
|
+
return response;
|
|
930
|
+
}
|
|
931
|
+
throw new DownloadError({
|
|
932
|
+
url,
|
|
933
|
+
message: `Too many redirects (max ${maxRedirects})`
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
async function readResponseWithSizeLimit({
|
|
937
|
+
response,
|
|
938
|
+
url,
|
|
939
|
+
maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE
|
|
940
|
+
}) {
|
|
941
|
+
const contentLength = response.headers.get("content-length");
|
|
942
|
+
if (contentLength != null) {
|
|
943
|
+
const length = parseInt(contentLength, 10);
|
|
944
|
+
if (!isNaN(length) && length > maxBytes) {
|
|
945
|
+
await cancelResponseBody(response);
|
|
946
|
+
throw new DownloadError({
|
|
947
|
+
url,
|
|
948
|
+
message: `Download of ${url} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
const body = response.body;
|
|
953
|
+
if (body == null) {
|
|
954
|
+
return new Uint8Array(0);
|
|
955
|
+
}
|
|
956
|
+
const reader = body.getReader();
|
|
957
|
+
const chunks = [];
|
|
958
|
+
let totalBytes = 0;
|
|
959
|
+
try {
|
|
960
|
+
while (true) {
|
|
961
|
+
const { done, value } = await reader.read();
|
|
962
|
+
if (done) {
|
|
963
|
+
break;
|
|
964
|
+
}
|
|
965
|
+
totalBytes += value.length;
|
|
966
|
+
if (totalBytes > maxBytes) {
|
|
967
|
+
throw new DownloadError({
|
|
968
|
+
url,
|
|
969
|
+
message: `Download of ${url} exceeded maximum size of ${maxBytes} bytes.`
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
chunks.push(value);
|
|
973
|
+
}
|
|
974
|
+
} finally {
|
|
975
|
+
try {
|
|
976
|
+
await reader.cancel();
|
|
977
|
+
} catch (e) {} finally {
|
|
978
|
+
reader.releaseLock();
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
const result = new Uint8Array(totalBytes);
|
|
982
|
+
let offset = 0;
|
|
983
|
+
for (const chunk of chunks) {
|
|
984
|
+
result.set(chunk, offset);
|
|
985
|
+
offset += chunk.length;
|
|
986
|
+
}
|
|
987
|
+
return result;
|
|
988
|
+
}
|
|
759
989
|
async function downloadBlob(url, options) {
|
|
760
990
|
var _a2, _b2;
|
|
761
|
-
validateDownloadUrl(url);
|
|
762
991
|
try {
|
|
763
|
-
const response = await
|
|
764
|
-
|
|
992
|
+
const response = await fetchWithValidatedRedirects({
|
|
993
|
+
url,
|
|
994
|
+
abortSignal: options == null ? undefined : options.abortSignal
|
|
765
995
|
});
|
|
766
996
|
if (!response.ok) {
|
|
997
|
+
await cancelResponseBody(response);
|
|
767
998
|
throw new DownloadError({
|
|
768
999
|
url,
|
|
769
1000
|
statusCode: response.status,
|
|
@@ -784,7 +1015,7 @@ async function downloadBlob(url, options) {
|
|
|
784
1015
|
throw new DownloadError({ url, cause: error });
|
|
785
1016
|
}
|
|
786
1017
|
}
|
|
787
|
-
function
|
|
1018
|
+
function getErrorMessage(error) {
|
|
788
1019
|
if (error == null) {
|
|
789
1020
|
return "unknown error";
|
|
790
1021
|
}
|
|
@@ -796,25 +1027,28 @@ function getErrorMessage2(error) {
|
|
|
796
1027
|
}
|
|
797
1028
|
return JSON.stringify(error);
|
|
798
1029
|
}
|
|
799
|
-
function
|
|
1030
|
+
function isAbortError(error) {
|
|
800
1031
|
return (error instanceof Error || error instanceof DOMException) && (error.name === "AbortError" || error.name === "ResponseAborted" || error.name === "TimeoutError");
|
|
801
1032
|
}
|
|
802
|
-
function
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
1033
|
+
function findNetworkError(error) {
|
|
1034
|
+
const visited = /* @__PURE__ */ new Set;
|
|
1035
|
+
let current = error;
|
|
1036
|
+
while (current instanceof Error && !visited.has(current)) {
|
|
1037
|
+
visited.add(current);
|
|
1038
|
+
const errorWithCode = current;
|
|
1039
|
+
if (typeof errorWithCode.code === "string" && RETRYABLE_NETWORK_ERROR_CODES.has(errorWithCode.code)) {
|
|
1040
|
+
return errorWithCode;
|
|
1041
|
+
}
|
|
1042
|
+
current = current.cause;
|
|
809
1043
|
}
|
|
810
|
-
return
|
|
1044
|
+
return;
|
|
811
1045
|
}
|
|
812
1046
|
function handleFetchError({
|
|
813
1047
|
error,
|
|
814
1048
|
url,
|
|
815
1049
|
requestBodyValues
|
|
816
1050
|
}) {
|
|
817
|
-
if (
|
|
1051
|
+
if (isAbortError(error)) {
|
|
818
1052
|
return error;
|
|
819
1053
|
}
|
|
820
1054
|
if (error instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error.message.toLowerCase())) {
|
|
@@ -829,9 +1063,23 @@ function handleFetchError({
|
|
|
829
1063
|
});
|
|
830
1064
|
}
|
|
831
1065
|
}
|
|
832
|
-
|
|
1066
|
+
const networkError = findNetworkError(error);
|
|
1067
|
+
if (networkError != null) {
|
|
1068
|
+
if (APICallError.isInstance(error)) {
|
|
1069
|
+
return new APICallError({
|
|
1070
|
+
message: error.message,
|
|
1071
|
+
cause: error.cause,
|
|
1072
|
+
url: error.url,
|
|
1073
|
+
requestBodyValues: error.requestBodyValues,
|
|
1074
|
+
statusCode: error.statusCode,
|
|
1075
|
+
responseHeaders: error.responseHeaders,
|
|
1076
|
+
responseBody: error.responseBody,
|
|
1077
|
+
data: error.data,
|
|
1078
|
+
isRetryable: true
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
833
1081
|
return new APICallError({
|
|
834
|
-
message: `Cannot connect to API: ${error.message}`,
|
|
1082
|
+
message: `Cannot connect to API: ${error instanceof Error ? error.message : networkError.message}`,
|
|
835
1083
|
cause: error,
|
|
836
1084
|
url,
|
|
837
1085
|
requestBodyValues,
|
|
@@ -891,12 +1139,11 @@ function isUrlSupported({
|
|
|
891
1139
|
url,
|
|
892
1140
|
supportedUrls
|
|
893
1141
|
}) {
|
|
894
|
-
url = url.toLowerCase();
|
|
895
1142
|
mediaType = mediaType.toLowerCase();
|
|
896
1143
|
return Object.entries(supportedUrls).map(([key, value]) => {
|
|
897
1144
|
const mediaType2 = key.toLowerCase();
|
|
898
1145
|
return mediaType2 === "*" || mediaType2 === "*/*" ? { mediaTypePrefix: "", regexes: value } : { mediaTypePrefix: mediaType2.replace(/\*/, ""), regexes: value };
|
|
899
|
-
}).filter(({ mediaTypePrefix }) => mediaType.startsWith(mediaTypePrefix)).flatMap(({ regexes }) => regexes).some((pattern) => pattern.test(url));
|
|
1146
|
+
}).filter(({ mediaTypePrefix }) => mediaTypePrefix === "" || mediaTypePrefix.endsWith("/") ? mediaType.startsWith(mediaTypePrefix) : mediaType === mediaTypePrefix).flatMap(({ regexes }) => regexes).some((pattern) => pattern.test(url));
|
|
900
1147
|
}
|
|
901
1148
|
function loadApiKey({
|
|
902
1149
|
apiKey,
|
|
@@ -914,7 +1161,7 @@ function loadApiKey({
|
|
|
914
1161
|
}
|
|
915
1162
|
if (typeof process === "undefined") {
|
|
916
1163
|
throw new LoadAPIKeyError({
|
|
917
|
-
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables
|
|
1164
|
+
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables are not supported in this environment.`
|
|
918
1165
|
});
|
|
919
1166
|
}
|
|
920
1167
|
apiKey = process.env[environmentVariableName];
|
|
@@ -1004,7 +1251,8 @@ function secureJsonParse(text) {
|
|
|
1004
1251
|
}
|
|
1005
1252
|
function addAdditionalPropertiesToJsonSchema(jsonSchema2) {
|
|
1006
1253
|
if (jsonSchema2.type === "object" || Array.isArray(jsonSchema2.type) && jsonSchema2.type.includes("object")) {
|
|
1007
|
-
|
|
1254
|
+
const { additionalProperties } = jsonSchema2;
|
|
1255
|
+
jsonSchema2.additionalProperties = additionalProperties != null && typeof additionalProperties !== "boolean" ? visit(additionalProperties) : false;
|
|
1008
1256
|
const { properties } = jsonSchema2;
|
|
1009
1257
|
if (properties != null) {
|
|
1010
1258
|
for (const key of Object.keys(properties)) {
|
|
@@ -1773,12 +2021,21 @@ function isSchema(value) {
|
|
|
1773
2021
|
return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && "jsonSchema" in value && "validate" in value;
|
|
1774
2022
|
}
|
|
1775
2023
|
function asSchema(schema) {
|
|
1776
|
-
return schema == null ? jsonSchema2({
|
|
2024
|
+
return schema == null ? jsonSchema2({
|
|
2025
|
+
type: "object",
|
|
2026
|
+
properties: {},
|
|
2027
|
+
additionalProperties: false
|
|
2028
|
+
}) : isSchema(schema) ? schema : ("~standard" in schema) ? schema["~standard"].vendor === "zod" ? zodSchema(schema) : standardSchema(schema) : schema();
|
|
1777
2029
|
}
|
|
1778
2030
|
function standardSchema(standardSchema2) {
|
|
1779
|
-
return jsonSchema2(() =>
|
|
1780
|
-
|
|
1781
|
-
|
|
2031
|
+
return jsonSchema2(() => {
|
|
2032
|
+
if (!hasStandardJsonSchema(standardSchema2)) {
|
|
2033
|
+
throw new Error(`Standard schema vendor '${standardSchema2["~standard"].vendor}' does not support JSON Schema conversion.`);
|
|
2034
|
+
}
|
|
2035
|
+
return addAdditionalPropertiesToJsonSchema(standardSchema2["~standard"].jsonSchema.input({
|
|
2036
|
+
target: "draft-07"
|
|
2037
|
+
}));
|
|
2038
|
+
}, {
|
|
1782
2039
|
validate: async (value) => {
|
|
1783
2040
|
const result = await standardSchema2["~standard"].validate(value);
|
|
1784
2041
|
return "value" in result ? { success: true, value: result.value } : {
|
|
@@ -1791,6 +2048,9 @@ function standardSchema(standardSchema2) {
|
|
|
1791
2048
|
}
|
|
1792
2049
|
});
|
|
1793
2050
|
}
|
|
2051
|
+
function hasStandardJsonSchema(schema) {
|
|
2052
|
+
return schema["~standard"].jsonSchema != null;
|
|
2053
|
+
}
|
|
1794
2054
|
function zod3Schema(zodSchema2, options) {
|
|
1795
2055
|
var _a2;
|
|
1796
2056
|
const useReferences = (_a2 = options == null ? undefined : options.useReferences) != null ? _a2 : false;
|
|
@@ -1900,14 +2160,6 @@ async function safeParseJSON({
|
|
|
1900
2160
|
};
|
|
1901
2161
|
}
|
|
1902
2162
|
}
|
|
1903
|
-
function isParsableJson(input) {
|
|
1904
|
-
try {
|
|
1905
|
-
secureJsonParse(input);
|
|
1906
|
-
return true;
|
|
1907
|
-
} catch (e) {
|
|
1908
|
-
return false;
|
|
1909
|
-
}
|
|
1910
|
-
}
|
|
1911
2163
|
function parseJsonEventStream({
|
|
1912
2164
|
stream,
|
|
1913
2165
|
schema
|
|
@@ -2005,7 +2257,130 @@ async function resolve(value) {
|
|
|
2005
2257
|
if (typeof value === "function") {
|
|
2006
2258
|
value = value();
|
|
2007
2259
|
}
|
|
2008
|
-
return
|
|
2260
|
+
return value;
|
|
2261
|
+
}
|
|
2262
|
+
async function retryWithExponentialBackoffInternal(f, {
|
|
2263
|
+
maxRetries,
|
|
2264
|
+
delayInMs,
|
|
2265
|
+
backoffFactor,
|
|
2266
|
+
abortSignal,
|
|
2267
|
+
shouldRetry,
|
|
2268
|
+
getDelayInMs,
|
|
2269
|
+
createRetryError
|
|
2270
|
+
}, errors = []) {
|
|
2271
|
+
try {
|
|
2272
|
+
return await f();
|
|
2273
|
+
} catch (error) {
|
|
2274
|
+
if (isAbortError(error)) {
|
|
2275
|
+
throw error;
|
|
2276
|
+
}
|
|
2277
|
+
if (maxRetries === 0) {
|
|
2278
|
+
throw error;
|
|
2279
|
+
}
|
|
2280
|
+
const errorMessage = getErrorMessage(error);
|
|
2281
|
+
const newErrors = [...errors, error];
|
|
2282
|
+
const tryNumber = newErrors.length;
|
|
2283
|
+
if (tryNumber > maxRetries) {
|
|
2284
|
+
throw createRetryError({
|
|
2285
|
+
message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
|
|
2286
|
+
reason: "maxRetriesExceeded",
|
|
2287
|
+
errors: newErrors
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
if (await shouldRetry(error) && tryNumber <= maxRetries) {
|
|
2291
|
+
await delay(getDelayInMs({
|
|
2292
|
+
error,
|
|
2293
|
+
exponentialBackoffDelay: delayInMs
|
|
2294
|
+
}), { abortSignal });
|
|
2295
|
+
return retryWithExponentialBackoffInternal(f, {
|
|
2296
|
+
maxRetries,
|
|
2297
|
+
delayInMs: backoffFactor * delayInMs,
|
|
2298
|
+
backoffFactor,
|
|
2299
|
+
abortSignal,
|
|
2300
|
+
shouldRetry,
|
|
2301
|
+
getDelayInMs,
|
|
2302
|
+
createRetryError
|
|
2303
|
+
}, newErrors);
|
|
2304
|
+
}
|
|
2305
|
+
if (tryNumber === 1) {
|
|
2306
|
+
throw error;
|
|
2307
|
+
}
|
|
2308
|
+
throw createRetryError({
|
|
2309
|
+
message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
|
|
2310
|
+
reason: "errorNotRetryable",
|
|
2311
|
+
errors: newErrors
|
|
2312
|
+
});
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
function wrapResponseBodyStream({
|
|
2316
|
+
stream,
|
|
2317
|
+
url,
|
|
2318
|
+
requestBodyValues,
|
|
2319
|
+
statusCode,
|
|
2320
|
+
responseHeaders
|
|
2321
|
+
}) {
|
|
2322
|
+
const reader = stream.getReader();
|
|
2323
|
+
let readerReleased = false;
|
|
2324
|
+
const releaseReader = () => {
|
|
2325
|
+
if (!readerReleased) {
|
|
2326
|
+
reader.releaseLock();
|
|
2327
|
+
readerReleased = true;
|
|
2328
|
+
}
|
|
2329
|
+
};
|
|
2330
|
+
return new ReadableStream({
|
|
2331
|
+
async pull(controller) {
|
|
2332
|
+
try {
|
|
2333
|
+
const { done, value } = await reader.read();
|
|
2334
|
+
if (done) {
|
|
2335
|
+
releaseReader();
|
|
2336
|
+
controller.close();
|
|
2337
|
+
} else {
|
|
2338
|
+
controller.enqueue(value);
|
|
2339
|
+
}
|
|
2340
|
+
} catch (error) {
|
|
2341
|
+
releaseReader();
|
|
2342
|
+
if (isAbortError(error)) {
|
|
2343
|
+
controller.error(error);
|
|
2344
|
+
return;
|
|
2345
|
+
}
|
|
2346
|
+
controller.error(handleFetchError({
|
|
2347
|
+
error: new APICallError({
|
|
2348
|
+
message: "Failed to process successful response",
|
|
2349
|
+
cause: error,
|
|
2350
|
+
statusCode,
|
|
2351
|
+
url,
|
|
2352
|
+
responseHeaders,
|
|
2353
|
+
requestBodyValues
|
|
2354
|
+
}),
|
|
2355
|
+
url,
|
|
2356
|
+
requestBodyValues
|
|
2357
|
+
}));
|
|
2358
|
+
}
|
|
2359
|
+
},
|
|
2360
|
+
async cancel(reason) {
|
|
2361
|
+
try {
|
|
2362
|
+
await reader.cancel(reason);
|
|
2363
|
+
} finally {
|
|
2364
|
+
releaseReader();
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
});
|
|
2368
|
+
}
|
|
2369
|
+
async function readResponseBodyAsText({
|
|
2370
|
+
response,
|
|
2371
|
+
url
|
|
2372
|
+
}) {
|
|
2373
|
+
return textDecoder.decode(await readResponseWithSizeLimit({
|
|
2374
|
+
response,
|
|
2375
|
+
url
|
|
2376
|
+
}));
|
|
2377
|
+
}
|
|
2378
|
+
function startsWithStructuredValue(value) {
|
|
2379
|
+
if (typeof value !== "string") {
|
|
2380
|
+
return false;
|
|
2381
|
+
}
|
|
2382
|
+
const firstCharacter = value.trimStart()[0];
|
|
2383
|
+
return firstCharacter === "{" || firstCharacter === "[";
|
|
2009
2384
|
}
|
|
2010
2385
|
function withoutTrailingSlash(url) {
|
|
2011
2386
|
return url == null ? undefined : url.replace(/\/$/, "");
|
|
@@ -2030,7 +2405,26 @@ async function* executeTool({
|
|
|
2030
2405
|
yield { type: "final", output: await result };
|
|
2031
2406
|
}
|
|
2032
2407
|
}
|
|
2033
|
-
|
|
2408
|
+
function stringifyWithBigIntAndCycles(value) {
|
|
2409
|
+
const ancestors = [];
|
|
2410
|
+
return JSON.stringify(value, function(_key, value2) {
|
|
2411
|
+
if (typeof value2 === "bigint") {
|
|
2412
|
+
return value2.toString();
|
|
2413
|
+
}
|
|
2414
|
+
if (typeof value2 !== "object" || value2 === null) {
|
|
2415
|
+
return value2;
|
|
2416
|
+
}
|
|
2417
|
+
while (ancestors.length > 0 && ancestors.at(-1) !== this) {
|
|
2418
|
+
ancestors.pop();
|
|
2419
|
+
}
|
|
2420
|
+
if (ancestors.includes(value2)) {
|
|
2421
|
+
return "[Circular]";
|
|
2422
|
+
}
|
|
2423
|
+
ancestors.push(value2);
|
|
2424
|
+
return value2;
|
|
2425
|
+
});
|
|
2426
|
+
}
|
|
2427
|
+
var btoa, atob, typedArrayTag, arrayBufferByteLength, name14 = "AI_DownloadError", marker15, symbol15, _a15, _b15, DownloadError, safeNodeFetchPromise, BLOCKED_REQUEST_HEADERS, MAX_DOWNLOAD_REDIRECTS = 10, REDIRECT_STATUS_CODES, DEFAULT_MAX_DOWNLOAD_SIZE, EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, createIdGenerator = ({
|
|
2034
2428
|
prefix,
|
|
2035
2429
|
size = 16,
|
|
2036
2430
|
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
@@ -2054,18 +2448,30 @@ var btoa, atob, name14 = "AI_DownloadError", marker15, symbol15, _a15, _b15, Dow
|
|
|
2054
2448
|
});
|
|
2055
2449
|
}
|
|
2056
2450
|
return () => `${prefix}${separator}${generator()}`;
|
|
2057
|
-
}, generateId, FETCH_FAILED_ERROR_MESSAGES,
|
|
2451
|
+
}, generateId, FETCH_FAILED_ERROR_MESSAGES, RETRYABLE_NETWORK_ERROR_CODES, VERSION = "4.0.66", getOriginalFetch = () => globalThis.fetch, getFromApi = async ({
|
|
2058
2452
|
url,
|
|
2059
2453
|
headers = {},
|
|
2060
2454
|
successfulResponseHandler,
|
|
2061
2455
|
failedResponseHandler,
|
|
2062
2456
|
abortSignal,
|
|
2063
|
-
fetch
|
|
2457
|
+
fetch,
|
|
2458
|
+
validateUrl,
|
|
2459
|
+
credentialedOrigin,
|
|
2460
|
+
trustedOrigin
|
|
2064
2461
|
}) => {
|
|
2065
2462
|
try {
|
|
2066
|
-
const
|
|
2463
|
+
const requestFetch = fetch != null ? fetch : getOriginalFetch();
|
|
2464
|
+
const outgoingHeaders = credentialedOrigin !== undefined && !isSameOrigin(url, credentialedOrigin) ? {} : headers;
|
|
2465
|
+
const requestHeaders = withUserAgentSuffix(outgoingHeaders, `ai-sdk/provider-utils/${VERSION}`, getRuntimeEnvironmentUserAgent());
|
|
2466
|
+
const response = validateUrl ? await fetchWithValidatedRedirects({
|
|
2467
|
+
url,
|
|
2468
|
+
headers: requestHeaders,
|
|
2469
|
+
abortSignal,
|
|
2470
|
+
fetch,
|
|
2471
|
+
trustedOrigin
|
|
2472
|
+
}) : await requestFetch(url, {
|
|
2067
2473
|
method: "GET",
|
|
2068
|
-
headers:
|
|
2474
|
+
headers: requestHeaders,
|
|
2069
2475
|
signal: abortSignal
|
|
2070
2476
|
});
|
|
2071
2477
|
const responseHeaders = extractResponseHeaders(response);
|
|
@@ -2078,7 +2484,7 @@ var btoa, atob, name14 = "AI_DownloadError", marker15, symbol15, _a15, _b15, Dow
|
|
|
2078
2484
|
requestBodyValues: {}
|
|
2079
2485
|
});
|
|
2080
2486
|
} catch (error) {
|
|
2081
|
-
if (
|
|
2487
|
+
if (isAbortError(error) || APICallError.isInstance(error)) {
|
|
2082
2488
|
throw error;
|
|
2083
2489
|
}
|
|
2084
2490
|
throw new APICallError({
|
|
@@ -2100,7 +2506,7 @@ var btoa, atob, name14 = "AI_DownloadError", marker15, symbol15, _a15, _b15, Dow
|
|
|
2100
2506
|
});
|
|
2101
2507
|
} catch (error) {
|
|
2102
2508
|
if (error instanceof Error) {
|
|
2103
|
-
if (
|
|
2509
|
+
if (isAbortError(error) || APICallError.isInstance(error)) {
|
|
2104
2510
|
throw error;
|
|
2105
2511
|
}
|
|
2106
2512
|
}
|
|
@@ -2342,7 +2748,7 @@ var btoa, atob, name14 = "AI_DownloadError", marker15, symbol15, _a15, _b15, Dow
|
|
|
2342
2748
|
failedResponseHandler,
|
|
2343
2749
|
successfulResponseHandler,
|
|
2344
2750
|
abortSignal,
|
|
2345
|
-
fetch
|
|
2751
|
+
fetch
|
|
2346
2752
|
}) => postToApi({
|
|
2347
2753
|
url,
|
|
2348
2754
|
headers: {
|
|
@@ -2356,7 +2762,7 @@ var btoa, atob, name14 = "AI_DownloadError", marker15, symbol15, _a15, _b15, Dow
|
|
|
2356
2762
|
failedResponseHandler,
|
|
2357
2763
|
successfulResponseHandler,
|
|
2358
2764
|
abortSignal,
|
|
2359
|
-
fetch
|
|
2765
|
+
fetch
|
|
2360
2766
|
}), postFormDataToApi = async ({
|
|
2361
2767
|
url,
|
|
2362
2768
|
headers,
|
|
@@ -2364,7 +2770,7 @@ var btoa, atob, name14 = "AI_DownloadError", marker15, symbol15, _a15, _b15, Dow
|
|
|
2364
2770
|
failedResponseHandler,
|
|
2365
2771
|
successfulResponseHandler,
|
|
2366
2772
|
abortSignal,
|
|
2367
|
-
fetch
|
|
2773
|
+
fetch
|
|
2368
2774
|
}) => postToApi({
|
|
2369
2775
|
url,
|
|
2370
2776
|
headers,
|
|
@@ -2375,7 +2781,7 @@ var btoa, atob, name14 = "AI_DownloadError", marker15, symbol15, _a15, _b15, Dow
|
|
|
2375
2781
|
failedResponseHandler,
|
|
2376
2782
|
successfulResponseHandler,
|
|
2377
2783
|
abortSignal,
|
|
2378
|
-
fetch
|
|
2784
|
+
fetch
|
|
2379
2785
|
}), postToApi = async ({
|
|
2380
2786
|
url,
|
|
2381
2787
|
headers = {},
|
|
@@ -2383,10 +2789,10 @@ var btoa, atob, name14 = "AI_DownloadError", marker15, symbol15, _a15, _b15, Dow
|
|
|
2383
2789
|
successfulResponseHandler,
|
|
2384
2790
|
failedResponseHandler,
|
|
2385
2791
|
abortSignal,
|
|
2386
|
-
fetch
|
|
2792
|
+
fetch = getOriginalFetch2()
|
|
2387
2793
|
}) => {
|
|
2388
2794
|
try {
|
|
2389
|
-
const response = await
|
|
2795
|
+
const response = await fetch(url, {
|
|
2390
2796
|
method: "POST",
|
|
2391
2797
|
headers: withUserAgentSuffix(headers, `ai-sdk/provider-utils/${VERSION}`, getRuntimeEnvironmentUserAgent()),
|
|
2392
2798
|
body: body.content,
|
|
@@ -2402,7 +2808,7 @@ var btoa, atob, name14 = "AI_DownloadError", marker15, symbol15, _a15, _b15, Dow
|
|
|
2402
2808
|
requestBodyValues: body.values
|
|
2403
2809
|
});
|
|
2404
2810
|
} catch (error) {
|
|
2405
|
-
if (
|
|
2811
|
+
if (isAbortError(error) || APICallError.isInstance(error)) {
|
|
2406
2812
|
throw error;
|
|
2407
2813
|
}
|
|
2408
2814
|
throw new APICallError({
|
|
@@ -2424,7 +2830,7 @@ var btoa, atob, name14 = "AI_DownloadError", marker15, symbol15, _a15, _b15, Dow
|
|
|
2424
2830
|
});
|
|
2425
2831
|
} catch (error) {
|
|
2426
2832
|
if (error instanceof Error) {
|
|
2427
|
-
if (
|
|
2833
|
+
if (isAbortError(error) || APICallError.isInstance(error)) {
|
|
2428
2834
|
throw error;
|
|
2429
2835
|
}
|
|
2430
2836
|
}
|
|
@@ -2440,12 +2846,28 @@ var btoa, atob, name14 = "AI_DownloadError", marker15, symbol15, _a15, _b15, Dow
|
|
|
2440
2846
|
} catch (error) {
|
|
2441
2847
|
throw handleFetchError({ error, url, requestBodyValues: body.values });
|
|
2442
2848
|
}
|
|
2443
|
-
},
|
|
2849
|
+
}, retryWithExponentialBackoff = ({
|
|
2850
|
+
maxRetries = 2,
|
|
2851
|
+
initialDelayInMs = 2000,
|
|
2852
|
+
backoffFactor = 2,
|
|
2853
|
+
abortSignal,
|
|
2854
|
+
shouldRetry,
|
|
2855
|
+
getDelayInMs = ({ exponentialBackoffDelay }) => exponentialBackoffDelay,
|
|
2856
|
+
createRetryError = ({ message }) => new Error(message)
|
|
2857
|
+
}) => async (f) => retryWithExponentialBackoffInternal(f, {
|
|
2858
|
+
maxRetries,
|
|
2859
|
+
delayInMs: initialDelayInMs,
|
|
2860
|
+
backoffFactor,
|
|
2861
|
+
abortSignal,
|
|
2862
|
+
shouldRetry,
|
|
2863
|
+
getDelayInMs,
|
|
2864
|
+
createRetryError
|
|
2865
|
+
}), textDecoder, createJsonErrorResponseHandler = ({
|
|
2444
2866
|
errorSchema,
|
|
2445
2867
|
errorToMessage,
|
|
2446
2868
|
isRetryable
|
|
2447
2869
|
}) => async ({ response, url, requestBodyValues }) => {
|
|
2448
|
-
const responseBody = await response
|
|
2870
|
+
const responseBody = await readResponseBodyAsText({ response, url });
|
|
2449
2871
|
const responseHeaders = extractResponseHeaders(response);
|
|
2450
2872
|
if (responseBody.trim() === "") {
|
|
2451
2873
|
return {
|
|
@@ -2493,7 +2915,7 @@ var btoa, atob, name14 = "AI_DownloadError", marker15, symbol15, _a15, _b15, Dow
|
|
|
2493
2915
|
})
|
|
2494
2916
|
};
|
|
2495
2917
|
}
|
|
2496
|
-
}, createEventSourceResponseHandler = (chunkSchema) => async ({ response }) => {
|
|
2918
|
+
}, createEventSourceResponseHandler = (chunkSchema) => async ({ response, url, requestBodyValues }) => {
|
|
2497
2919
|
const responseHeaders = extractResponseHeaders(response);
|
|
2498
2920
|
if (response.body == null) {
|
|
2499
2921
|
throw new EmptyResponseBodyError({});
|
|
@@ -2501,12 +2923,18 @@ var btoa, atob, name14 = "AI_DownloadError", marker15, symbol15, _a15, _b15, Dow
|
|
|
2501
2923
|
return {
|
|
2502
2924
|
responseHeaders,
|
|
2503
2925
|
value: parseJsonEventStream({
|
|
2504
|
-
stream:
|
|
2926
|
+
stream: wrapResponseBodyStream({
|
|
2927
|
+
stream: response.body,
|
|
2928
|
+
url,
|
|
2929
|
+
requestBodyValues,
|
|
2930
|
+
statusCode: response.status,
|
|
2931
|
+
responseHeaders
|
|
2932
|
+
}),
|
|
2505
2933
|
schema: chunkSchema
|
|
2506
2934
|
})
|
|
2507
2935
|
};
|
|
2508
2936
|
}, createJsonResponseHandler = (responseSchema) => async ({ response, url, requestBodyValues }) => {
|
|
2509
|
-
const responseBody = await response
|
|
2937
|
+
const responseBody = await readResponseBodyAsText({ response, url });
|
|
2510
2938
|
const parsedResult = await safeParseJSON({
|
|
2511
2939
|
text: responseBody,
|
|
2512
2940
|
schema: responseSchema
|
|
@@ -2557,8 +2985,322 @@ var btoa, atob, name14 = "AI_DownloadError", marker15, symbol15, _a15, _b15, Dow
|
|
|
2557
2985
|
cause: error
|
|
2558
2986
|
});
|
|
2559
2987
|
}
|
|
2988
|
+
}, StreamingToolCallArgumentState = class {
|
|
2989
|
+
constructor(initialValue = "") {
|
|
2990
|
+
this.structure = { kind: "undetermined" };
|
|
2991
|
+
this.append(initialValue);
|
|
2992
|
+
}
|
|
2993
|
+
get hasCompleteStructuredValue() {
|
|
2994
|
+
return this.structure.kind === "structured" && this.structure.complete === true;
|
|
2995
|
+
}
|
|
2996
|
+
append(delta) {
|
|
2997
|
+
let nextStructure = this.structure;
|
|
2998
|
+
for (const character of delta) {
|
|
2999
|
+
if (nextStructure.kind === "undetermined") {
|
|
3000
|
+
if (/\s/.test(character)) {
|
|
3001
|
+
continue;
|
|
3002
|
+
}
|
|
3003
|
+
if (character !== "{" && character !== "[") {
|
|
3004
|
+
nextStructure = { kind: "other" };
|
|
3005
|
+
continue;
|
|
3006
|
+
}
|
|
3007
|
+
nextStructure = {
|
|
3008
|
+
kind: "structured",
|
|
3009
|
+
stack: [character],
|
|
3010
|
+
inString: false,
|
|
3011
|
+
escaped: false,
|
|
3012
|
+
complete: false
|
|
3013
|
+
};
|
|
3014
|
+
continue;
|
|
3015
|
+
}
|
|
3016
|
+
if (nextStructure.kind !== "structured" || nextStructure.complete) {
|
|
3017
|
+
continue;
|
|
3018
|
+
}
|
|
3019
|
+
if (nextStructure.inString) {
|
|
3020
|
+
if (nextStructure.escaped) {
|
|
3021
|
+
nextStructure.escaped = false;
|
|
3022
|
+
} else if (character === "\\") {
|
|
3023
|
+
nextStructure.escaped = true;
|
|
3024
|
+
} else if (character === '"') {
|
|
3025
|
+
nextStructure.inString = false;
|
|
3026
|
+
}
|
|
3027
|
+
continue;
|
|
3028
|
+
}
|
|
3029
|
+
if (character === '"') {
|
|
3030
|
+
nextStructure.inString = true;
|
|
3031
|
+
} else if (character === "{" || character === "[") {
|
|
3032
|
+
nextStructure.stack.push(character);
|
|
3033
|
+
} else if (character === "}" || character === "]") {
|
|
3034
|
+
const expectedOpening = character === "}" ? "{" : "[";
|
|
3035
|
+
if (nextStructure.stack[nextStructure.stack.length - 1] !== expectedOpening) {
|
|
3036
|
+
nextStructure = { kind: "other" };
|
|
3037
|
+
continue;
|
|
3038
|
+
}
|
|
3039
|
+
nextStructure.stack.pop();
|
|
3040
|
+
if (nextStructure.stack.length === 0) {
|
|
3041
|
+
nextStructure.complete = true;
|
|
3042
|
+
}
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
this.structure = nextStructure;
|
|
3046
|
+
}
|
|
3047
|
+
}, StreamingToolCallTracker = class {
|
|
3048
|
+
constructor(controller, options = {}) {
|
|
3049
|
+
this.toolCalls = [];
|
|
3050
|
+
this.toolCallsById = /* @__PURE__ */ new Map;
|
|
3051
|
+
this.toolCallsByIndex = /* @__PURE__ */ new Map;
|
|
3052
|
+
this.usedToolCallIds = /* @__PURE__ */ new Set;
|
|
3053
|
+
this.nextGeneratedIdSuffixes = /* @__PURE__ */ new Map;
|
|
3054
|
+
var _a2, _b2;
|
|
3055
|
+
this.controller = controller;
|
|
3056
|
+
this._generateId = (_a2 = options.generateId) != null ? _a2 : generateId;
|
|
3057
|
+
this.typeValidation = (_b2 = options.typeValidation) != null ? _b2 : "none";
|
|
3058
|
+
this.extractMetadata = options.extractMetadata;
|
|
3059
|
+
this.buildToolCallProviderMetadata = options.buildToolCallProviderMetadata;
|
|
3060
|
+
}
|
|
3061
|
+
processDelta(toolCallDelta) {
|
|
3062
|
+
var _a2, _b2;
|
|
3063
|
+
const wireName = (_a2 = toolCallDelta.function) == null ? undefined : _a2.name;
|
|
3064
|
+
const hasBlankName = typeof wireName === "string" && wireName.trim().length === 0;
|
|
3065
|
+
const wireId = this.getNonBlankString(toolCallDelta.id);
|
|
3066
|
+
const name2 = this.getNonBlankString(wireName);
|
|
3067
|
+
const { index } = toolCallDelta;
|
|
3068
|
+
const resolution = this.resolveToolCall({
|
|
3069
|
+
wireId,
|
|
3070
|
+
index,
|
|
3071
|
+
name: name2,
|
|
3072
|
+
hasExplicitCallStart: name2 != null && startsWithStructuredValue((_b2 = toolCallDelta.function) == null ? undefined : _b2.arguments)
|
|
3073
|
+
});
|
|
3074
|
+
if (resolution.kind === "ambiguous") {
|
|
3075
|
+
return;
|
|
3076
|
+
}
|
|
3077
|
+
let toolCall;
|
|
3078
|
+
if (resolution.kind === "new") {
|
|
3079
|
+
if (hasBlankName) {
|
|
3080
|
+
return;
|
|
3081
|
+
}
|
|
3082
|
+
toolCall = this.processNewToolCall(toolCallDelta, {
|
|
3083
|
+
wireId,
|
|
3084
|
+
index,
|
|
3085
|
+
name: name2
|
|
3086
|
+
});
|
|
3087
|
+
} else {
|
|
3088
|
+
toolCall = resolution.toolCall;
|
|
3089
|
+
if (wireId != null) {
|
|
3090
|
+
this.associateWireId(toolCall, wireId);
|
|
3091
|
+
}
|
|
3092
|
+
this.processExistingToolCall(toolCall, toolCallDelta);
|
|
3093
|
+
}
|
|
3094
|
+
if (index != null) {
|
|
3095
|
+
this.associateIndex(toolCall, index);
|
|
3096
|
+
}
|
|
3097
|
+
}
|
|
3098
|
+
flush() {
|
|
3099
|
+
const toolCalls = this.toolCalls.every((toolCall) => toolCall.index != null) ? [...this.toolCalls].sort((a, b) => a.index - b.index || a.sequence - b.sequence) : this.toolCalls;
|
|
3100
|
+
for (const toolCall of toolCalls) {
|
|
3101
|
+
if (!toolCall.hasFinished) {
|
|
3102
|
+
this.finishToolCall(toolCall);
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
}
|
|
3106
|
+
resolveToolCall({
|
|
3107
|
+
wireId,
|
|
3108
|
+
index,
|
|
3109
|
+
name: name2,
|
|
3110
|
+
hasExplicitCallStart
|
|
3111
|
+
}) {
|
|
3112
|
+
const indexedToolCalls = index != null ? this.toolCallsByIndex.get(index) : undefined;
|
|
3113
|
+
const matchingIndexedToolCalls = this.filterToolCallsByName(indexedToolCalls, name2);
|
|
3114
|
+
if (wireId != null) {
|
|
3115
|
+
const toolCallsWithId = this.toolCallsById.get(wireId);
|
|
3116
|
+
if (toolCallsWithId != null) {
|
|
3117
|
+
if (index != null) {
|
|
3118
|
+
const matchingToolCalls = matchingIndexedToolCalls.filter((toolCall) => toolCallsWithId.has(toolCall));
|
|
3119
|
+
const matchingToolCall = this.resolveMatchingToolCall(matchingToolCalls, hasExplicitCallStart);
|
|
3120
|
+
if (matchingToolCall.kind !== "new") {
|
|
3121
|
+
return matchingToolCall;
|
|
3122
|
+
}
|
|
3123
|
+
if (name2 != null) {
|
|
3124
|
+
return { kind: "new" };
|
|
3125
|
+
}
|
|
3126
|
+
if (indexedToolCalls != null) {
|
|
3127
|
+
return { kind: "ambiguous" };
|
|
3128
|
+
}
|
|
3129
|
+
return this.resolveMatchingToolCall([...toolCallsWithId], false);
|
|
3130
|
+
}
|
|
3131
|
+
if (name2 != null) {
|
|
3132
|
+
const matchingToolCalls = [...toolCallsWithId].filter((toolCall) => toolCall.function.name === name2);
|
|
3133
|
+
return this.resolveMatchingToolCall(matchingToolCalls, hasExplicitCallStart);
|
|
3134
|
+
}
|
|
3135
|
+
return this.resolveMatchingToolCall([...toolCallsWithId], false);
|
|
3136
|
+
}
|
|
3137
|
+
if (matchingIndexedToolCalls.length > 0) {
|
|
3138
|
+
return hasExplicitCallStart ? { kind: "new" } : this.resolveMatchingToolCall(matchingIndexedToolCalls, false);
|
|
3139
|
+
}
|
|
3140
|
+
return { kind: "new" };
|
|
3141
|
+
}
|
|
3142
|
+
if (indexedToolCalls != null) {
|
|
3143
|
+
return this.resolveMatchingToolCall(matchingIndexedToolCalls, hasExplicitCallStart);
|
|
3144
|
+
}
|
|
3145
|
+
if (name2 != null) {
|
|
3146
|
+
return { kind: "new" };
|
|
3147
|
+
}
|
|
3148
|
+
const unfinishedToolCalls = this.toolCalls.filter((toolCall) => !toolCall.hasFinished);
|
|
3149
|
+
if (unfinishedToolCalls.length === 1) {
|
|
3150
|
+
return { kind: "existing", toolCall: unfinishedToolCalls[0] };
|
|
3151
|
+
}
|
|
3152
|
+
return unfinishedToolCalls.length > 1 ? { kind: "ambiguous" } : { kind: "new" };
|
|
3153
|
+
}
|
|
3154
|
+
filterToolCallsByName(toolCalls, name2) {
|
|
3155
|
+
if (toolCalls == null) {
|
|
3156
|
+
return [];
|
|
3157
|
+
}
|
|
3158
|
+
return [...toolCalls].filter((toolCall) => name2 == null || toolCall.function.name === name2);
|
|
3159
|
+
}
|
|
3160
|
+
resolveMatchingToolCall(toolCalls, hasExplicitCallStart) {
|
|
3161
|
+
if (toolCalls.length === 0) {
|
|
3162
|
+
return { kind: "new" };
|
|
3163
|
+
}
|
|
3164
|
+
if (!hasExplicitCallStart) {
|
|
3165
|
+
return toolCalls.length === 1 ? { kind: "existing", toolCall: toolCalls[0] } : { kind: "ambiguous" };
|
|
3166
|
+
}
|
|
3167
|
+
const continuableToolCalls = toolCalls.filter((toolCall) => !toolCall.argumentState.hasCompleteStructuredValue);
|
|
3168
|
+
if (continuableToolCalls.length === 1) {
|
|
3169
|
+
return { kind: "existing", toolCall: continuableToolCalls[0] };
|
|
3170
|
+
}
|
|
3171
|
+
return continuableToolCalls.length > 1 ? { kind: "ambiguous" } : { kind: "new" };
|
|
3172
|
+
}
|
|
3173
|
+
processNewToolCall(toolCallDelta, {
|
|
3174
|
+
wireId,
|
|
3175
|
+
index,
|
|
3176
|
+
name: name2
|
|
3177
|
+
}) {
|
|
3178
|
+
var _a2, _b2, _c, _d, _e;
|
|
3179
|
+
if (this.typeValidation === "required") {
|
|
3180
|
+
if (toolCallDelta.type !== "function") {
|
|
3181
|
+
throw new InvalidResponseDataError({
|
|
3182
|
+
data: toolCallDelta,
|
|
3183
|
+
message: `Expected 'function' type.`
|
|
3184
|
+
});
|
|
3185
|
+
}
|
|
3186
|
+
} else if (this.typeValidation === "if-present") {
|
|
3187
|
+
if (toolCallDelta.type != null && toolCallDelta.type !== "function") {
|
|
3188
|
+
throw new InvalidResponseDataError({
|
|
3189
|
+
data: toolCallDelta,
|
|
3190
|
+
message: `Expected 'function' type.`
|
|
3191
|
+
});
|
|
3192
|
+
}
|
|
3193
|
+
}
|
|
3194
|
+
if (name2 == null) {
|
|
3195
|
+
throw new InvalidResponseDataError({
|
|
3196
|
+
data: toolCallDelta,
|
|
3197
|
+
message: `Expected 'function.name' to be a string.`
|
|
3198
|
+
});
|
|
3199
|
+
}
|
|
3200
|
+
const id = this.createToolCallId(wireId);
|
|
3201
|
+
this.controller.enqueue({
|
|
3202
|
+
type: "tool-input-start",
|
|
3203
|
+
id,
|
|
3204
|
+
toolName: name2
|
|
3205
|
+
});
|
|
3206
|
+
const toolCall = {
|
|
3207
|
+
id,
|
|
3208
|
+
index: index != null ? index : undefined,
|
|
3209
|
+
sequence: this.toolCalls.length,
|
|
3210
|
+
type: "function",
|
|
3211
|
+
function: {
|
|
3212
|
+
name: name2,
|
|
3213
|
+
arguments: (_b2 = (_a2 = toolCallDelta.function) == null ? undefined : _a2.arguments) != null ? _b2 : ""
|
|
3214
|
+
},
|
|
3215
|
+
argumentState: new StreamingToolCallArgumentState((_d = (_c = toolCallDelta.function) == null ? undefined : _c.arguments) != null ? _d : ""),
|
|
3216
|
+
hasFinished: false,
|
|
3217
|
+
metadata: (_e = this.extractMetadata) == null ? undefined : _e.call(this, toolCallDelta)
|
|
3218
|
+
};
|
|
3219
|
+
this.toolCalls.push(toolCall);
|
|
3220
|
+
if (wireId != null) {
|
|
3221
|
+
this.associateWireId(toolCall, wireId);
|
|
3222
|
+
}
|
|
3223
|
+
if (toolCall.function.arguments.length > 0) {
|
|
3224
|
+
this.controller.enqueue({
|
|
3225
|
+
type: "tool-input-delta",
|
|
3226
|
+
id: toolCall.id,
|
|
3227
|
+
delta: toolCall.function.arguments
|
|
3228
|
+
});
|
|
3229
|
+
}
|
|
3230
|
+
return toolCall;
|
|
3231
|
+
}
|
|
3232
|
+
associateWireId(toolCall, wireId) {
|
|
3233
|
+
let toolCallsWithId = this.toolCallsById.get(wireId);
|
|
3234
|
+
if (toolCallsWithId == null) {
|
|
3235
|
+
toolCallsWithId = /* @__PURE__ */ new Set;
|
|
3236
|
+
this.toolCallsById.set(wireId, toolCallsWithId);
|
|
3237
|
+
}
|
|
3238
|
+
toolCallsWithId.add(toolCall);
|
|
3239
|
+
}
|
|
3240
|
+
associateIndex(toolCall, index) {
|
|
3241
|
+
let toolCallsWithIndex = this.toolCallsByIndex.get(index);
|
|
3242
|
+
if (toolCallsWithIndex == null) {
|
|
3243
|
+
toolCallsWithIndex = /* @__PURE__ */ new Set;
|
|
3244
|
+
this.toolCallsByIndex.set(index, toolCallsWithIndex);
|
|
3245
|
+
}
|
|
3246
|
+
toolCallsWithIndex.add(toolCall);
|
|
3247
|
+
}
|
|
3248
|
+
createToolCallId(wireId) {
|
|
3249
|
+
var _a2, _b2;
|
|
3250
|
+
if (wireId != null && !this.usedToolCallIds.has(wireId)) {
|
|
3251
|
+
this.usedToolCallIds.add(wireId);
|
|
3252
|
+
return wireId;
|
|
3253
|
+
}
|
|
3254
|
+
const generatedId = (_a2 = this.getNonBlankString(this._generateId())) != null ? _a2 : "tool-call";
|
|
3255
|
+
if (!this.usedToolCallIds.has(generatedId)) {
|
|
3256
|
+
this.usedToolCallIds.add(generatedId);
|
|
3257
|
+
return generatedId;
|
|
3258
|
+
}
|
|
3259
|
+
const initialSuffix = (_b2 = this.nextGeneratedIdSuffixes.get(generatedId)) != null ? _b2 : 1;
|
|
3260
|
+
const maximumSuffix = initialSuffix + this.usedToolCallIds.size;
|
|
3261
|
+
for (let suffix = initialSuffix;suffix <= maximumSuffix; suffix++) {
|
|
3262
|
+
const suffixedId = `${generatedId}-${suffix}`;
|
|
3263
|
+
if (!this.usedToolCallIds.has(suffixedId)) {
|
|
3264
|
+
this.usedToolCallIds.add(suffixedId);
|
|
3265
|
+
this.nextGeneratedIdSuffixes.set(generatedId, suffix + 1);
|
|
3266
|
+
return suffixedId;
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
throw new Error("Failed to create a unique tool call ID.");
|
|
3270
|
+
}
|
|
3271
|
+
getNonBlankString(value) {
|
|
3272
|
+
return value != null && value.trim().length > 0 ? value : undefined;
|
|
3273
|
+
}
|
|
3274
|
+
processExistingToolCall(toolCall, toolCallDelta) {
|
|
3275
|
+
var _a2;
|
|
3276
|
+
if (!toolCall.hasFinished && ((_a2 = toolCallDelta.function) == null ? undefined : _a2.arguments) != null) {
|
|
3277
|
+
toolCall.argumentState.append(toolCallDelta.function.arguments);
|
|
3278
|
+
toolCall.function.arguments += toolCallDelta.function.arguments;
|
|
3279
|
+
this.controller.enqueue({
|
|
3280
|
+
type: "tool-input-delta",
|
|
3281
|
+
id: toolCall.id,
|
|
3282
|
+
delta: toolCallDelta.function.arguments
|
|
3283
|
+
});
|
|
3284
|
+
}
|
|
3285
|
+
}
|
|
3286
|
+
finishToolCall(toolCall) {
|
|
3287
|
+
var _a2;
|
|
3288
|
+
this.controller.enqueue({
|
|
3289
|
+
type: "tool-input-end",
|
|
3290
|
+
id: toolCall.id
|
|
3291
|
+
});
|
|
3292
|
+
const providerMetadata = (_a2 = this.buildToolCallProviderMetadata) == null ? undefined : _a2.call(this, toolCall.metadata);
|
|
3293
|
+
this.controller.enqueue({
|
|
3294
|
+
type: "tool-call",
|
|
3295
|
+
toolCallId: toolCall.id,
|
|
3296
|
+
toolName: toolCall.function.name,
|
|
3297
|
+
input: toolCall.function.arguments,
|
|
3298
|
+
...providerMetadata ? { providerMetadata } : {}
|
|
3299
|
+
});
|
|
3300
|
+
toolCall.hasFinished = true;
|
|
3301
|
+
}
|
|
2560
3302
|
};
|
|
2561
|
-
var
|
|
3303
|
+
var init_dist4 = __esm(() => {
|
|
2562
3304
|
init_dist();
|
|
2563
3305
|
init_dist();
|
|
2564
3306
|
init_dist();
|
|
@@ -2575,7 +3317,10 @@ var init_dist2 = __esm(() => {
|
|
|
2575
3317
|
init_dist();
|
|
2576
3318
|
init_dist();
|
|
2577
3319
|
init_dist();
|
|
3320
|
+
init_dist();
|
|
2578
3321
|
({ btoa, atob } = globalThis);
|
|
3322
|
+
typedArrayTag = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), Symbol.toStringTag).get;
|
|
3323
|
+
arrayBufferByteLength = Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "byteLength").get;
|
|
2579
3324
|
marker15 = `vercel.ai.error.${name14}`;
|
|
2580
3325
|
symbol15 = Symbol.for(marker15);
|
|
2581
3326
|
DownloadError = class extends (_b15 = AISDKError, _a15 = symbol15, _b15) {
|
|
@@ -2596,21 +3341,49 @@ var init_dist2 = __esm(() => {
|
|
|
2596
3341
|
return AISDKError.hasMarker(error, marker15);
|
|
2597
3342
|
}
|
|
2598
3343
|
};
|
|
3344
|
+
BLOCKED_REQUEST_HEADERS = [
|
|
3345
|
+
"connection",
|
|
3346
|
+
"keep-alive",
|
|
3347
|
+
"te",
|
|
3348
|
+
"trailer",
|
|
3349
|
+
"transfer-encoding",
|
|
3350
|
+
"upgrade",
|
|
3351
|
+
"host",
|
|
3352
|
+
"forwarded",
|
|
3353
|
+
"proxy-authorization",
|
|
3354
|
+
"via",
|
|
3355
|
+
"x-forwarded-for",
|
|
3356
|
+
"x-forwarded-host",
|
|
3357
|
+
"x-forwarded-proto",
|
|
3358
|
+
"x-real-ip",
|
|
3359
|
+
"metadata",
|
|
3360
|
+
"metadata-flavor",
|
|
3361
|
+
"x-aws-ec2-metadata-token",
|
|
3362
|
+
"x-metadata-token",
|
|
3363
|
+
"cookie",
|
|
3364
|
+
"set-cookie"
|
|
3365
|
+
];
|
|
3366
|
+
REDIRECT_STATUS_CODES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
2599
3367
|
DEFAULT_MAX_DOWNLOAD_SIZE = 2 * 1024 * 1024 * 1024;
|
|
3368
|
+
EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL = /* @__PURE__ */ Symbol.for("vercel.ai.embeddingModel.maxInputBytesPerCall");
|
|
2600
3369
|
generateId = createIdGenerator();
|
|
2601
3370
|
FETCH_FAILED_ERROR_MESSAGES = ["fetch failed", "failed to fetch"];
|
|
2602
|
-
|
|
3371
|
+
RETRYABLE_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
2603
3372
|
"ConnectionRefused",
|
|
2604
3373
|
"ConnectionClosed",
|
|
2605
3374
|
"FailedToOpenSocket",
|
|
2606
3375
|
"ECONNRESET",
|
|
2607
3376
|
"ECONNREFUSED",
|
|
2608
3377
|
"ETIMEDOUT",
|
|
2609
|
-
"EPIPE"
|
|
2610
|
-
|
|
3378
|
+
"EPIPE",
|
|
3379
|
+
"UND_ERR_SOCKET",
|
|
3380
|
+
"UND_ERR_HEADERS_TIMEOUT",
|
|
3381
|
+
"UND_ERR_BODY_TIMEOUT",
|
|
3382
|
+
"UND_ERR_CONNECT_TIMEOUT"
|
|
3383
|
+
]);
|
|
2611
3384
|
suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
2612
3385
|
suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
2613
|
-
ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
3386
|
+
ignoreOverride = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
2614
3387
|
defaultOptions = {
|
|
2615
3388
|
name: undefined,
|
|
2616
3389
|
$refStrategy: "root",
|
|
@@ -2636,7 +3409,7 @@ var init_dist2 = __esm(() => {
|
|
|
2636
3409
|
cuid: /^[cC][^\s-]{8,}$/,
|
|
2637
3410
|
cuid2: /^[0-9a-z]+$/,
|
|
2638
3411
|
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
2639
|
-
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'
|
|
3412
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,
|
|
2640
3413
|
emoji: () => {
|
|
2641
3414
|
if (emojiRegex === undefined) {
|
|
2642
3415
|
emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
|
@@ -2661,7 +3434,8 @@ var init_dist2 = __esm(() => {
|
|
|
2661
3434
|
ZodBoolean: "boolean",
|
|
2662
3435
|
ZodNull: "null"
|
|
2663
3436
|
};
|
|
2664
|
-
schemaSymbol = Symbol.for("vercel.ai.schema");
|
|
3437
|
+
schemaSymbol = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
|
|
3438
|
+
textDecoder = new TextDecoder;
|
|
2665
3439
|
});
|
|
2666
3440
|
|
|
2667
|
-
export {
|
|
3441
|
+
export { combineHeaders, createToolNameMapping, convertBase64ToUint8Array, convertUint8ArrayToBase64, isUint8Array, isArrayBuffer, convertToBase64, convertToFormData, cancelResponseBody, DownloadError, fetchWithValidatedRedirects, DEFAULT_MAX_DOWNLOAD_SIZE, readResponseWithSizeLimit, downloadBlob, EMBEDDING_MODEL_MAX_INPUT_BYTES_PER_CALL, createIdGenerator, generateId, getErrorMessage, getRuntimeEnvironmentUserAgent, withUserAgentSuffix, getFromApi, isNonNullable, isUrlSupported, loadApiKey, loadOptionalSetting, mediaTypeToExtension, secureJsonParse, lazySchema, jsonSchema2, asSchema, zodSchema, validateTypes, safeValidateTypes, parseJSON, safeParseJSON, parseJsonEventStream, parseProviderOptions, postJsonToApi, postFormDataToApi, createProviderToolFactory, createProviderToolFactoryWithOutputSchema, resolve, retryWithExponentialBackoff, createJsonErrorResponseHandler, createEventSourceResponseHandler, createJsonResponseHandler, createBinaryResponseHandler, StreamingToolCallTracker, withoutTrailingSlash, executeTool, stringifyWithBigIntAndCycles, init_dist4 };
|