@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.
Files changed (411) hide show
  1. package/dist/acp-adapter-q1vz4hh2.js +17 -0
  2. package/dist/{acp-targets-23exz4z4.js → acp-targets-d44eerh4.js} +10 -10
  3. package/dist/{actions-zcr25x27.js → actions-z4k4bvss.js} +28 -28
  4. package/dist/{agent-fs-provision-7fa9e12e.js → agent-fs-provision-aan1cgpx.js} +4 -4
  5. package/dist/{amp-adapter-s7ytmv6b.js → amp-adapter-wac3py0p.js} +3 -3
  6. package/dist/{anthropic-messages-vdd1zmha.js → anthropic-messages-njt2r5m4.js} +28 -27
  7. package/dist/{app-5d3sz1hy.js → app-wax6qz5e.js} +10 -10
  8. package/dist/{approval-notifications-7qgkzkzx.js → approval-notifications-6fvkhnma.js} +11 -11
  9. package/dist/{assistant-p2yvhc3j.js → assistant-e8fe08zx.js} +29 -29
  10. package/dist/{azure-openai-responses-jeaas6x0.js → azure-openai-responses-6ewf9rwp.js} +6 -6
  11. package/dist/{boot-args-schema-ry6cb0p7.js → boot-args-schema-rv97cmnt.js} +1 -1
  12. package/dist/{boot-reembed-c9643ms3.js → boot-reembed-bcn7frk9.js} +1 -1
  13. package/dist/{boot-reembed-2hkm3vz2.js → boot-reembed-xakrdy6y.js} +1 -1
  14. package/dist/{boot-scrub-sweep-3ycxr51t.js → boot-scrub-sweep-20t8akhf.js} +2 -2
  15. package/dist/{boot-seeds-2hzvvzg0.js → boot-seeds-48rr6r29.js} +4 -4
  16. package/dist/{boxd-9py3x0jb.js → boxd-tjpxwecx.js} +3 -3
  17. package/dist/{claude-adapter-dnkww93e.js → claude-adapter-0wzwntrj.js} +12 -13
  18. package/dist/{claude-managed-adapter-yk0cr5x6.js → claude-managed-adapter-4xcgt46w.js} +4 -4
  19. package/dist/{claude-managed-setup-4byxpp47.js → claude-managed-setup-91cyktw7.js} +7 -7
  20. package/dist/{claude-sdk-session-4wf3dbvs.js → claude-sdk-session-ngj4dce5.js} +11144 -12464
  21. package/dist/{cli-gcyws2bp.js → cli-021hrewp.js} +2 -2
  22. package/dist/{cli-wvgg7r4j.js → cli-08gfvs58.js} +2 -2
  23. package/dist/{cli-2zjxake1.js → cli-0kyjrbaa.js} +4 -4
  24. package/dist/{cli-rp1n2xpd.js → cli-0nvqg1hb.js} +1 -1
  25. package/dist/{cli-vxmmttmt.js → cli-0nz04gqv.js} +50 -50
  26. package/dist/{cli-vr4eyq6p.js → cli-0rrft7s3.js} +538 -410
  27. package/dist/{cli-mw1tmn3x.js → cli-1d9q7qrn.js} +7 -7
  28. package/dist/{cli-84xn7bgz.js → cli-1t5vhrpv.js} +1 -1
  29. package/dist/{cli-hzhv7yac.js → cli-1zbj28py.js} +1 -1
  30. package/dist/{cli-z8t4485r.js → cli-2ja7eadd.js} +2 -2
  31. package/dist/{cli-r04ve9xw.js → cli-2r62jy9s.js} +1 -1
  32. package/dist/{cli-9fwznq4p.js → cli-3ffzr65w.js} +7 -7
  33. package/dist/{cli-2ckwgs7q.js → cli-3kdgm393.js} +5 -5
  34. package/dist/{cli-jwnac23b.js → cli-3vc518cw.js} +1 -1
  35. package/dist/{cli-6p8p2e6r.js → cli-5188hq0a.js} +1286 -31
  36. package/dist/{cli-zcghfsdg.js → cli-53gt8wfv.js} +1 -1
  37. package/dist/{cli-930zbczq.js → cli-5njmmmer.js} +3 -3
  38. package/dist/{cli-dw9rtjm3.js → cli-5rw7nt99.js} +3061 -727
  39. package/dist/{cli-6c61yjwy.js → cli-5xx353cy.js} +7554 -1534
  40. package/dist/{cli-2ap1the6.js → cli-65k149j5.js} +2 -2
  41. package/dist/{cli-v41kn3cd.js → cli-6prwz0zn.js} +4427 -5566
  42. package/dist/{cli-yd7e590v.js → cli-6zpn5hmp.js} +12 -12
  43. package/dist/{cli-ty3gha1p.js → cli-7b9bwrfg.js} +2 -2
  44. package/dist/{cli-2414h5r9.js → cli-7dpdq7yh.js} +11428 -1914
  45. package/dist/{cli-r9d2tya0.js → cli-7qkbab03.js} +5 -5
  46. package/dist/{cli-7ca8hczj.js → cli-7svwhw1a.js} +1 -1
  47. package/dist/cli-7wwewkf4.js +37 -0
  48. package/dist/{cli-ejnhs815.js → cli-83hynhes.js} +17 -13
  49. package/dist/{cli-rs1rzwp4.js → cli-8crn0510.js} +1 -1
  50. package/dist/{cli-f2rwt43y.js → cli-8ee7xt75.js} +13 -13
  51. package/dist/{cli-9j47sgzy.js → cli-8ef94zm2.js} +2 -2
  52. package/dist/{cli-9fvk9mv8.js → cli-8gr1bg9t.js} +1 -1
  53. package/dist/{cli-b0m3bg0f.js → cli-9j1qcs0b.js} +1 -1
  54. package/dist/{cli-ad00h1st.js → cli-9mvfvggt.js} +7 -7
  55. package/dist/{cli-xh5fpmg8.js → cli-9txap41q.js} +101 -18
  56. package/dist/{cli-24wervhz.js → cli-aktk3qt6.js} +3 -3
  57. package/dist/{cli-6ajyhxh7.js → cli-an8bpy60.js} +2 -2
  58. package/dist/{cli-meydjstb.js → cli-azptj8xe.js} +5591 -69
  59. package/dist/cli-c0rt16vk.js +15 -0
  60. package/dist/{cli-w4bvtxet.js → cli-c6vhcknq.js} +7 -7
  61. package/dist/{cli-2savn6mm.js → cli-cczffwak.js} +7 -7
  62. package/dist/{cli-ze1ndjs4.js → cli-cgmka83w.js} +3 -3
  63. package/dist/{cli-kc7vd07m.js → cli-d13qgcct.js} +3699 -1733
  64. package/dist/{cli-k3facve0.js → cli-d5nvy1jy.js} +1 -1
  65. package/dist/{cli-edxfzgah.js → cli-dev6f0px.js} +4 -4
  66. package/dist/{cli-0e914dp9.js → cli-dzhht0vq.js} +3 -3
  67. package/dist/{cli-m0ea8ggd.js → cli-e13kbyq0.js} +2 -2
  68. package/dist/{cli-73rmgm45.js → cli-e2k0ej0d.js} +2 -2
  69. package/dist/cli-ek8b88kv.js +9740 -0
  70. package/dist/{cli-0k7ppk9k.js → cli-ertcjw6z.js} +281 -46
  71. package/dist/{cli-qrwjk4xy.js → cli-f3ta4e67.js} +5 -5
  72. package/dist/{cli-1nfabrt4.js → cli-f4xv7s0t.js} +7 -7
  73. package/dist/{cli-phe2vcw5.js → cli-fdam1t9b.js} +171 -104
  74. package/dist/{cli-gc6b94tj.js → cli-fe8he9cy.js} +2 -2
  75. package/dist/{cli-spfz393q.js → cli-feh37wgs.js} +598 -219
  76. package/dist/{cli-ebqx630g.js → cli-fjzjtqna.js} +35 -18
  77. package/dist/{cli-37p61fcg.js → cli-fs9t2m2k.js} +18 -20
  78. package/dist/{cli-7w1fs01q.js → cli-g03x26q6.js} +2 -2
  79. package/dist/{cli-879txsac.js → cli-gnkzh8ed.js} +4 -4
  80. package/dist/{cli-v4z5v3jd.js → cli-gy0r7gb8.js} +514 -337
  81. package/dist/{cli-s4pccby1.js → cli-h0edykd1.js} +1 -1
  82. package/dist/{cli-pq0kv31y.js → cli-h364asjc.js} +9 -9
  83. package/dist/{cli-69szn7w7.js → cli-h3xcfp4c.js} +93 -54
  84. package/dist/{cli-jcnc5ret.js → cli-h8k5801a.js} +73 -27
  85. package/dist/{cli-6yy4fepf.js → cli-h96yp7xv.js} +4 -4
  86. package/dist/{cli-q5n3deaf.js → cli-hab0bvrh.js} +1 -1
  87. package/dist/{cli-g6a696c0.js → cli-j3wqt73b.js} +4 -4
  88. package/dist/{cli-wym6rxgt.js → cli-jfgaz10x.js} +10 -15
  89. package/dist/{cli-shyhb4t5.js → cli-jrhvywah.js} +53 -52
  90. package/dist/{cli-qkbevqer.js → cli-jrxt5j0n.js} +3 -3
  91. package/dist/{cli-7b7rxz22.js → cli-jw7n9pct.js} +5 -2
  92. package/dist/{cli-8vbxjzk0.js → cli-k9kfck3s.js} +3 -3
  93. package/dist/{cli-yjb3cddd.js → cli-kkwq5b12.js} +1 -1
  94. package/dist/{cli-39t9d248.js → cli-kz8rar0g.js} +1 -1
  95. package/dist/{cli-rzbsh6bw.js → cli-n15fhd43.js} +1 -1
  96. package/dist/{cli-1jx0srjt.js → cli-nc842kc9.js} +1921 -80
  97. package/dist/{cli-9j1t3kf6.js → cli-nmj4phcg.js} +2 -2
  98. package/dist/{cli-t9pzz2eq.js → cli-ntmjzyte.js} +4 -1
  99. package/dist/{cli-adzmmcvf.js → cli-praaw1wh.js} +2 -2
  100. package/dist/{cli-f9g96z28.js → cli-q44p4869.js} +11 -11
  101. package/dist/{cli-fww016hh.js → cli-q58qt9dw.js} +1711 -7287
  102. package/dist/{cli-njvpngc6.js → cli-qqz5z36e.js} +3 -3
  103. package/dist/{cli-096aftq6.js → cli-r7rpy2xz.js} +7 -7
  104. package/dist/cli-rcqgr0hs.js +30 -0
  105. package/dist/{cli-ph95yejc.js → cli-rjc464jg.js} +2 -2
  106. package/dist/{cli-md4tn21h.js → cli-rw3m83j4.js} +40 -26
  107. package/dist/cli-rwcj6wt3.js +1291 -0
  108. package/dist/{cli-srq69pn1.js → cli-ryn4y478.js} +1 -1
  109. package/dist/{cli-jgq9xptq.js → cli-s48k2rzx.js} +4 -4
  110. package/dist/{cli-cbg0j1yt.js → cli-s90wcbk9.js} +3 -3
  111. package/dist/{cli-2ayk9gn8.js → cli-svcy72s5.js} +2 -2
  112. package/dist/{cli-4dyzzkfb.js → cli-swtwbg85.js} +944 -170
  113. package/dist/{cli-mv8ft7b0.js → cli-t1bqpzgz.js} +3 -3
  114. package/dist/{cli-tc165vrb.js → cli-t5jbjq61.js} +4 -3
  115. package/dist/{cli-enavhq6r.js → cli-tbrjvrrg.js} +1 -1
  116. package/dist/{cli-mz7ycqn8.js → cli-td2h8zej.js} +6 -6
  117. package/dist/{cli-9t7syepg.js → cli-ttatvwn6.js} +1 -1
  118. package/dist/{cli-ayxxkk3p.js → cli-txxcf9s1.js} +8 -8
  119. package/dist/{cli-q4z9s6zs.js → cli-v7az4d1g.js} +2 -2
  120. package/dist/cli-vqt44168.js +14 -0
  121. package/dist/{cli-q457ga28.js → cli-vs9h3vw2.js} +14 -14
  122. package/dist/{cli-snxhtehz.js → cli-w2fg8kjc.js} +7 -8
  123. package/dist/{cli-wd7b5hgc.js → cli-w81s97bn.js} +1 -1
  124. package/dist/{cli-bqfx72e6.js → cli-wkzrknpt.js} +1 -1
  125. package/dist/{cli-cg1q8ymp.js → cli-wqpvfq2m.js} +1 -1
  126. package/dist/{cli-kg63yp1r.js → cli-wz7qj1jy.js} +19 -19
  127. package/dist/{cli-3wsabyt0.js → cli-x5t54ytt.js} +2 -2
  128. package/dist/{cli-r495stwd.js → cli-xd6ntv7x.js} +2 -2
  129. package/dist/{cli-wvbaq052.js → cli-xphbv66z.js} +10 -3
  130. package/dist/{cli-a49frv85.js → cli-xxgqn93n.js} +3753 -1186
  131. package/dist/{cli-91amj3md.js → cli-z209g721.js} +111 -87
  132. package/dist/{cli-3mhdmcd4.js → cli-z5andw8k.js} +1 -1
  133. package/dist/{cli-7g5qj2ca.js → cli-zcb64xzv.js} +1 -1
  134. package/dist/{cli-0h6m6z5g.js → cli-zr2sc5tr.js} +1 -1
  135. package/dist/{cli-krk8y8c7.js → cli-zrm0610v.js} +1833 -518
  136. package/dist/cli.js +73 -73
  137. package/dist/{cloudflare-workers-ai-system-one-w3m0fbf8.js → cloudflare-workers-ai-system-one-kb0tq22h.js} +2 -2
  138. package/dist/{codex-adapter-eq61radw.js → codex-adapter-0c1ynrmt.js} +9 -9
  139. package/dist/{codex-hook-8nmepvz6.js → codex-hook-w5nmtrn2.js} +2 -2
  140. package/dist/{codex-login-vbd9707w.js → codex-login-67qarfcg.js} +1 -1
  141. package/dist/{codex-session-runner-rfx355h4.js → codex-session-runner-z4t9z7yy.js} +10 -10
  142. package/dist/{commands-d1z0sx62.js → commands-h0jxqdhk.js} +3 -3
  143. package/dist/{controller-9hz6d8x3.js → controller-4ygy66hv.js} +4 -4
  144. package/dist/{controllers-connect-tz07d2xr.js → controllers-connect-ynbvv8pv.js} +28 -28
  145. package/dist/core-mj9fzrcm.js +41 -0
  146. package/dist/{cursor-adapter-ef22ze3j.js → cursor-adapter-9e4d6658.js} +2 -2
  147. package/dist/{db-gd81d68c.js → db-bg0hxjq1.js} +3 -3
  148. package/dist/{db-vrckks6q.js → db-q12gmpns.js} +2 -2
  149. package/dist/{devin-adapter-kdt6a2bh.js → devin-adapter-tn1twrha.js} +1 -1
  150. package/dist/{devtools-qxfgbsqz.js → devtools-t8my9az6.js} +1 -1
  151. package/dist/{dispatcher-76as8w2t.js → dispatcher-v5dbfscq.js} +24 -24
  152. package/dist/{docker-51ta7jsh.js → docker-6007r2fj.js} +2 -2
  153. package/dist/{dsh-adapter-ypfvcdyz.js → dsh-adapter-z3fneea1.js} +2 -2
  154. package/dist/{e2b-05kn3kpq.js → e2b-k3kb8b52.js} +4 -4
  155. package/dist/{e2b-dm9r8hpy.js → e2b-p269awh6.js} +5 -5
  156. package/dist/{easter-egg-3d-sg21j15g.js → easter-egg-3d-y49v5z90.js} +1 -1
  157. package/dist/{embedding-space-zsdw37bb.js → embedding-space-mjt5ksq0.js} +5 -5
  158. package/dist/{embeddings-p4e3e1m6.js → embeddings-td9hgnc5.js} +1 -1
  159. package/dist/emscripten-module-Q67P5WYC-3sde6cre.js +2458 -0
  160. package/dist/{event-bus-tvf2grf4.js → event-bus-pawddp92.js} +1 -1
  161. package/dist/{execute-nztd0af0.js → execute-z8nc8bba.js} +1 -1
  162. package/dist/{external-channel-717yzn4d.js → external-channel-pjenc2ag.js} +2 -2
  163. package/dist/ffi-cbfmmtqk.js +85 -0
  164. package/dist/fx-adapter-pjeztp0n.js +20 -0
  165. package/dist/getMachineId-bsd-hjs2tbdp.js +36 -0
  166. package/dist/getMachineId-darwin-kzbvr8s3.js +40 -0
  167. package/dist/getMachineId-linux-embmcq2c.js +26 -0
  168. package/dist/getMachineId-unsupported-jvznc6d4.js +20 -0
  169. package/dist/getMachineId-win-qr8z0b13.js +36 -0
  170. package/dist/{google-generative-ai-sw77egmr.js → google-generative-ai-tf3w7557.js} +11 -16
  171. package/dist/{google-vertex-rrw93g8h.js → google-vertex-9pj87bd8.js} +15 -17
  172. package/dist/grok-adapter-davbhx8t.js +20 -0
  173. package/dist/handlers-rf130hnp.js +39 -0
  174. package/dist/heartbeat-9hmvqxk0.js +49 -0
  175. package/dist/hook-0b1jqs2t.js +21 -0
  176. package/dist/{hook-ctz0xmp3.js → hook-1n0sjv8p.js} +10 -11
  177. package/dist/{http-zregegrx.js → http-vykejyjx.js} +432 -170
  178. package/dist/{index-7dgxveck.js → index-07d66kdm.js} +3 -3
  179. package/dist/index-0hgjxqz8.js +10584 -0
  180. package/dist/{index-rz8ve510.js → index-0nt39qwy.js} +2 -2
  181. package/dist/{index-ym9fgxad.js → index-2xbxq71g.js} +2 -2
  182. package/dist/{index-42jq9yy3.js → index-3j8hffkb.js} +12327 -7450
  183. package/dist/index-8w09aggw.js +43 -0
  184. package/dist/{index-5kx15d19.js → index-b3wy4jzs.js} +1 -1
  185. package/dist/{index-kzdqn3dd.js → index-dt9vr7tb.js} +3143 -760
  186. package/dist/{index-maddg9ys.js → index-ezfas4jj.js} +5858 -15337
  187. package/dist/index-g2jntx15.js +38 -0
  188. package/dist/{index-x9qf8dg7.js → index-j6sqtb83.js} +105 -75
  189. package/dist/{index-m6g8q65g.js → index-na0tczq0.js} +9268 -10220
  190. package/dist/{index-whysn1wf.js → index-p9dkwhwe.js} +1 -1
  191. package/dist/{index-126v2d0t.js → index-pe2etczf.js} +6 -2918
  192. package/dist/{index-mtnbhe12.js → index-q60mhcpd.js} +23631 -19921
  193. package/dist/index-qffex5k4.js +41 -0
  194. package/dist/index-qrp11tp9.js +4 -0
  195. package/dist/{index-kdmkfjt7.js → index-ryyrg0d8.js} +3426 -2333
  196. package/dist/{index-t17p395x.js → index-sf06w57a.js} +13 -13
  197. package/dist/{index-evay0xyk.js → index-vybnwd5v.js} +1 -1
  198. package/dist/{index-fdym6ryb.js → index-wsf1f5pe.js} +28 -28
  199. package/dist/{k8s-ejkk0aw7.js → k8s-mr1r12th.js} +2 -2
  200. package/dist/{keepalive-zdqay870.js → keepalive-86z0tzzf.js} +4 -4
  201. package/dist/lead-edmwagkn.js +81 -0
  202. package/dist/{llama-cpp-classify-yvb8vh7w.js → llama-cpp-classify-wd7htn1x.js} +2 -2
  203. package/dist/{maintenance-t5ndg11m.js → maintenance-19h6tfwz.js} +1 -1
  204. package/dist/{mistral-conversations-w4bncwbt.js → mistral-conversations-txjmc64f.js} +7 -7
  205. package/dist/module-ES6BEMUI-44w9s1dx.js +1210 -0
  206. package/dist/{multipart-parser-xevcstye.js → multipart-parser-xqbgwrav.js} +1 -1
  207. package/dist/{node-0as4n1ef.js → node-q4628t0b.js} +1 -1
  208. package/dist/{oauth-refresh-sweep-y9zyd7t6.js → oauth-refresh-sweep-6nmyrv32.js} +3 -3
  209. package/dist/{object-webhooks-mkca91s0.js → object-webhooks-2kynmdf8.js} +7 -7
  210. package/dist/{onboard-ss995244.js → onboard-zbpm96mn.js} +7 -7
  211. package/dist/{openai-codex-responses-70g39cgz.js → openai-codex-responses-6ckhys6r.js} +35 -29
  212. package/dist/{openai-completions-cv3hp4h5.js → openai-completions-c9dsq9jh.js} +15 -15
  213. package/dist/{openai-decisions-fyq1p9f9.js → openai-decisions-9vzvv10c.js} +2 -2
  214. package/dist/{openai-responses-trsvnks6.js → openai-responses-bhfmt9sa.js} +6 -6
  215. package/dist/{opencode-adapter-mwpz0278.js → opencode-adapter-fyqcbdra.js} +8 -8
  216. package/dist/{openrouter-images-0jj12a2q.js → openrouter-images-hkk5p580.js} +3 -3
  217. package/dist/otel-impl-txa20w1h.js +11178 -0
  218. package/dist/{pending-2sxh1t6j.js → pending-4rxawq8y.js} +25 -25
  219. package/dist/{pi-messages-zk3g4esn.js → pi-messages-py3f96p7.js} +5 -5
  220. package/dist/{pi-mono-adapter-sfb7zy43.js → pi-mono-adapter-rnsed1xa.js} +24 -27
  221. package/dist/{pricing-refresh-h79bg4cf.js → pricing-refresh-4314hwtw.js} +2 -2
  222. package/dist/{rbac-roles-ckq0czp4.js → rbac-roles-fztcm8ky.js} +2 -2
  223. package/dist/{rbac-roles-jg2e260w.js → rbac-roles-msqt7a3k.js} +3 -3
  224. package/dist/{render-v2-ymbshmn0.js → render-v2-w49wtecg.js} +10 -10
  225. package/dist/{resume-jdhnt4jk.js → resume-gwgtp4m3.js} +13 -13
  226. package/dist/{runtime-y28jhhnf.js → runtime-kkebz8yq.js} +1 -1
  227. package/dist/{session-access-k4ta5hvp.js → session-access-kjb19m2w.js} +5 -5
  228. package/dist/{session-source-backfill-528j4s8j.js → session-source-backfill-805p4wqr.js} +3 -3
  229. package/dist/{setup-d6pj82fr.js → setup-q8y168c8.js} +3 -3
  230. package/dist/thread-buffer-yqbffd0t.js +40 -0
  231. package/dist/{token-util-pjgekqxr.js → token-util-hnzceyn9.js} +1 -1
  232. package/dist/{token-pgr2w4s3.js → token-xnc02n6w.js} +21 -14
  233. package/dist/{tree-visibility-kjxv3nxk.js → tree-visibility-qj323994.js} +2 -2
  234. package/dist/{typesafe-system-one-qkvkgrcz.js → typesafe-system-one-avrdb4zm.js} +2 -2
  235. package/dist/{user-merge-jobs-rabbncf6.js → user-merge-jobs-qfp40f2s.js} +3 -3
  236. package/dist/{virtual-modules-22k51txd.js → virtual-modules-nzxegw0a.js} +7 -7
  237. package/dist/{work-objects-xtjbar3r.js → work-objects-hs089w60.js} +26 -26
  238. package/dist/{worker-follow-up-fg48vk6d.js → worker-follow-up-zwgg20sr.js} +24 -24
  239. package/dist/worker-kg4g7rnx.js +81 -0
  240. package/dist/{x-vfsqypht.js → x-k29vmskt.js} +2 -2
  241. package/openapi.json +59 -3
  242. package/package.json +53 -52
  243. package/plugin/commands/create-pr.md +5 -2
  244. package/plugin/pi-skills/create-pr/SKILL.md +5 -2
  245. package/src/apps/sync.ts +7 -2
  246. package/src/be/db/model-profiles.ts +103 -12
  247. package/src/be/db/tasks/read.ts +5 -0
  248. package/src/be/db/workflow-runs.ts +12 -8
  249. package/src/be/db.ts +18 -5
  250. package/src/be/migrations/367_workflow_run_principal.sql +5 -0
  251. package/src/be/model-group-resolution.ts +134 -0
  252. package/src/be/model-tier-resolution.ts +120 -17
  253. package/src/be/model-validation.ts +9 -1
  254. package/src/be/runtime-pools/routing.ts +22 -8
  255. package/src/be/scripts/extract-schema.ts +7 -0
  256. package/src/be/swarm-config-guard.ts +20 -7
  257. package/src/be/task-auto-title-listener.ts +2 -2
  258. package/src/commands/onboard/agent-fs-version.ts +1 -1
  259. package/src/extensions/contract-types.generated.ts +1 -1
  260. package/src/extensions/post-bridge.ts +27 -28
  261. package/src/http/active-sessions.ts +7 -0
  262. package/src/http/agents.ts +7 -0
  263. package/src/http/api-keys.ts +7 -0
  264. package/src/http/approval-requests.ts +4 -0
  265. package/src/http/budgets.ts +2 -0
  266. package/src/http/codex-oauth-keep-warm.ts +6 -2
  267. package/src/http/config.ts +1 -0
  268. package/src/http/context.ts +4 -0
  269. package/src/http/db-query.ts +11 -2
  270. package/src/http/events.ts +2 -0
  271. package/src/http/fs.ts +1 -0
  272. package/src/http/integrations.ts +4 -0
  273. package/src/http/mcp-bridge.ts +1 -0
  274. package/src/http/memory.ts +3 -0
  275. package/src/http/metrics.ts +16 -0
  276. package/src/http/oauth-locks.ts +8 -0
  277. package/src/http/operator-actor.ts +3 -8
  278. package/src/http/page-proxy.ts +16 -0
  279. package/src/http/pages.ts +9 -0
  280. package/src/http/poll.ts +21 -1
  281. package/src/http/pricing.ts +2 -0
  282. package/src/http/prompt-templates.ts +34 -0
  283. package/src/http/repos.ts +3 -1
  284. package/src/http/schedules.ts +33 -3
  285. package/src/http/script-runs.ts +24 -0
  286. package/src/http/scripts.ts +1 -0
  287. package/src/http/session-data.ts +2 -0
  288. package/src/http/status.ts +1 -0
  289. package/src/http/tasks.ts +28 -1
  290. package/src/http/trackers/jira.ts +2 -0
  291. package/src/http/trackers/linear.ts +4 -0
  292. package/src/http/users.ts +18 -0
  293. package/src/http/webhooks.ts +12 -0
  294. package/src/http/workflow-events.ts +26 -6
  295. package/src/http/workflows.ts +40 -0
  296. package/src/http/x.ts +4 -0
  297. package/src/linear/app.ts +3 -2
  298. package/src/linear/client.ts +5 -1
  299. package/src/linear/host.ts +40 -0
  300. package/src/linear/oauth.ts +3 -2
  301. package/src/linear/sync.ts +4 -3
  302. package/src/otel-impl.ts +8 -5
  303. package/src/prompts/base-prompt.ts +10 -6
  304. package/src/prompts/session-templates.ts +3 -3
  305. package/src/providers/acp-targets.ts +1 -1
  306. package/src/providers/amp-adapter.ts +11 -9
  307. package/src/providers/cursor-adapter.ts +1 -1
  308. package/src/rbac/legacy-policy.ts +2 -0
  309. package/src/rbac/permissions.ts +5 -0
  310. package/src/realtime/browser.generated.txt +1 -1
  311. package/src/scheduler/schedule-task.ts +1 -0
  312. package/src/scripts-runtime/quickjs-compat.ts +44 -10
  313. package/src/scripts-runtime/types/swarm-extension.d.ts +2 -0
  314. package/src/slack/config.ts +4 -0
  315. package/src/slack/render-v2.ts +52 -24
  316. package/src/slack/responses.ts +2 -1
  317. package/src/slack/reviewed-deliverables.ts +251 -0
  318. package/src/tasks/follow-up-gate.ts +142 -38
  319. package/src/tasks/worker-follow-up.ts +126 -37
  320. package/src/tests/amp-adapter.test.ts +57 -9
  321. package/src/tests/base-prompt.test.ts +36 -2
  322. package/src/tests/check-pr-body.test.ts +408 -93
  323. package/src/tests/compose-dev-object-store.test.ts +13 -0
  324. package/src/tests/compose-example-object-store.test.ts +67 -0
  325. package/src/tests/db-query.test.ts +8 -4
  326. package/src/tests/db-retention-defaults.test.ts +28 -3
  327. package/src/tests/e2b-dispatch.test.ts +7 -1
  328. package/src/tests/entrypoint-repo-autoclone-args.test.ts +10 -0
  329. package/src/tests/follow-up-gate-shadow.test.ts +268 -10
  330. package/src/tests/linear-outbound-sync.test.ts +59 -25
  331. package/src/tests/operator-actor-keyless.test.ts +103 -0
  332. package/src/tests/otel-event-loop-and-logs.test.ts +1 -1
  333. package/src/tests/profile-tier-alias.test.ts +9 -3
  334. package/src/tests/quickjs-compat.test.ts +40 -4
  335. package/src/tests/rbac-route-verbs-e2e.test.ts +142 -0
  336. package/src/tests/runner-repo-clone-args.test.ts +15 -6
  337. package/src/tests/script-connections.test.ts +2 -0
  338. package/src/tests/slack-render-v2.test.ts +52 -8
  339. package/src/tests/workflow-definition-pinning.test.ts +2 -0
  340. package/src/tests/workflow-hitl-routing.test.ts +67 -5
  341. package/src/tests/workflow-replay.test.ts +13 -1
  342. package/src/tests/workflow-system-one-extraction.test.ts +21 -0
  343. package/src/tests/workflow-wait-filter.test.ts +7 -7
  344. package/src/tests/worktree-reaper.test.ts +15 -4
  345. package/src/tests/x402-client.test.ts +82 -0
  346. package/src/tools/memory-rate.ts +2 -2
  347. package/src/tools/prompt-templates/delete.ts +22 -1
  348. package/src/tools/prompt-templates/set.ts +15 -1
  349. package/src/tools/schedules/create-schedule.ts +20 -3
  350. package/src/tools/schedules/patch-schedule.ts +30 -4
  351. package/src/tools/schedules/update-schedule.ts +30 -4
  352. package/src/tools/send-task.ts +17 -3
  353. package/src/tools/slack-post.ts +7 -2
  354. package/src/tools/slack-reply.ts +6 -2
  355. package/src/tools/task-action.ts +16 -3
  356. package/src/tools/utils.ts +1 -1
  357. package/src/types.ts +10 -0
  358. package/src/utils/amp-models.ts +20 -4
  359. package/src/utils/constants.ts +5 -4
  360. package/src/utils/secret-scrubber.ts +6 -4
  361. package/src/utils/task-citations.ts +11 -0
  362. package/src/workflows/engine.ts +41 -8
  363. package/src/workflows/executors/agent-task.ts +13 -2
  364. package/src/workflows/executors/code-match.ts +11 -31
  365. package/src/workflows/executors/script.ts +13 -0
  366. package/src/workflows/executors/sub-workflow.ts +5 -7
  367. package/src/workflows/executors/swarm-script.ts +4 -5
  368. package/src/workflows/executors/system-one-extraction.ts +9 -6
  369. package/src/workflows/executors/wait.ts +1 -1
  370. package/src/workflows/foreach-driver.ts +5 -1
  371. package/src/workflows/model-validation.ts +13 -1
  372. package/src/workflows/predicate-sandbox.ts +171 -0
  373. package/src/workflows/resume.ts +21 -4
  374. package/src/workflows/retry-poller.ts +1 -1
  375. package/src/workflows/run-principal.ts +51 -0
  376. package/src/workflows/wait-filter.ts +14 -192
  377. package/src/x402/client.ts +38 -17
  378. package/templates/skills/code-quality/content.md +1 -1
  379. package/templates/skills/heartbeat-runbook/content.md +1 -0
  380. package/templates/skills/pages/content.md +36 -12
  381. package/templates/skills/slack-interaction/content.md +4 -0
  382. package/templates/skills/swarm-docs/content.md +47 -41
  383. package/templates/skills/swarm-scripts/SKILL.md +1 -1
  384. package/templates/skills/swarm-scripts/content.md +1 -1
  385. package/dist/acp-adapter-99n6z9ky.js +0 -17
  386. package/dist/cli-5ss6qqt9.js +0 -45
  387. package/dist/cli-dzzh58sy.js +0 -6996
  388. package/dist/cli-e8trbfx1.js +0 -15
  389. package/dist/cli-j9ccfveb.js +0 -1849
  390. package/dist/cli-mna6pmfx.js +0 -1485
  391. package/dist/cli-r8ddn0hf.js +0 -25583
  392. package/dist/core-dynsv289.js +0 -41
  393. package/dist/fx-adapter-9k0hptnz.js +0 -20
  394. package/dist/getMachineId-bsd-637a7rbk.js +0 -36
  395. package/dist/getMachineId-darwin-9vytrcnn.js +0 -36
  396. package/dist/getMachineId-linux-mkzsvyyz.js +0 -29
  397. package/dist/getMachineId-unsupported-4cfs2n11.js +0 -19
  398. package/dist/getMachineId-win-154s3qma.js +0 -38
  399. package/dist/grok-adapter-skdj2pce.js +0 -20
  400. package/dist/handlers-5btjqkz6.js +0 -39
  401. package/dist/heartbeat-vfb1gy84.js +0 -49
  402. package/dist/hook-eh52p7yd.js +0 -22
  403. package/dist/index-7w8p6em0.js +0 -41
  404. package/dist/index-t56y945n.js +0 -4
  405. package/dist/index-vfemrwwk.js +0 -10002
  406. package/dist/index-vz4semsx.js +0 -38
  407. package/dist/index-y3s0xp2v.js +0 -43
  408. package/dist/lead-6cscw8a5.js +0 -82
  409. package/dist/otel-impl-6n6vva3x.js +0 -28205
  410. package/dist/thread-buffer-9w6x5zec.js +0 -40
  411. package/dist/worker-g4aj93dt.js +0 -82
@@ -50,7 +50,7 @@ var require_constants = __commonJS(function(exports) {
50
50
  var require_package = __commonJS(function(exports, module) {
51
51
  module.exports = {
52
52
  name: "@grpc/grpc-js",
53
- version: "1.14.3",
53
+ version: "1.14.7",
54
54
  description: "gRPC Library for Node - pure JS implementation",
55
55
  homepage: "https://grpc.io/",
56
56
  repository: "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
@@ -220,6 +220,9 @@ var require_logging = __commonJS(function(exports) {
220
220
  var enabledTracers = new Set;
221
221
  var disabledTracers = new Set;
222
222
  for (const tracerName of tracersString.split(",")) {
223
+ if (tracerName.length === 0) {
224
+ continue;
225
+ }
223
226
  if (tracerName.startsWith("-")) {
224
227
  disabledTracers.add(tracerName.substring(1));
225
228
  } else {
@@ -227,12 +230,16 @@ var require_logging = __commonJS(function(exports) {
227
230
  }
228
231
  }
229
232
  var allEnabled = enabledTracers.has("all");
233
+ var anyTracerEnabled = allEnabled || enabledTracers.size > 0;
230
234
  function trace(severity, tracer, text) {
231
235
  if (isTracerEnabled(tracer)) {
232
236
  (0, exports.log)(severity, new Date().toISOString() + " | v" + clientVersion + " " + process_1.pid + " | " + tracer + " | " + text);
233
237
  }
234
238
  }
235
239
  function isTracerEnabled(tracer) {
240
+ if (!anyTracerEnabled) {
241
+ return false;
242
+ }
236
243
  return !disabledTracers.has(tracer) && (allEnabled || enabledTracers.has(tracer));
237
244
  }
238
245
  });
@@ -305,7 +312,6 @@ var require_metadata = __commonJS(function(exports) {
305
312
  class Metadata {
306
313
  constructor(options = {}) {
307
314
  this.internalRepr = new Map;
308
- this.opaqueData = new Map;
309
315
  this.options = options;
310
316
  }
311
317
  set(key, value) {
@@ -374,7 +380,11 @@ var require_metadata = __commonJS(function(exports) {
374
380
  if (key.startsWith(":")) {
375
381
  continue;
376
382
  }
377
- result[key] = values.map(bufToString);
383
+ if (values.length === 1) {
384
+ result[key] = bufToString(values[0]);
385
+ } else {
386
+ result[key] = values.map(bufToString);
387
+ }
378
388
  }
379
389
  return result;
380
390
  }
@@ -386,10 +396,14 @@ var require_metadata = __commonJS(function(exports) {
386
396
  return result;
387
397
  }
388
398
  setOpaque(key, value) {
399
+ if (!this.opaqueData) {
400
+ this.opaqueData = new Map;
401
+ }
389
402
  this.opaqueData.set(key, value);
390
403
  }
391
404
  getOpaque(key) {
392
- return this.opaqueData.get(key);
405
+ var _a;
406
+ return (_a = this.opaqueData) === null || _a === undefined ? undefined : _a.get(key);
393
407
  }
394
408
  static fromHttp2Headers(headers) {
395
409
  const result = new Metadata;
@@ -440,6 +454,7 @@ var require_metadata = __commonJS(function(exports) {
440
454
  var require_call_credentials = __commonJS(function(exports) {
441
455
  Object.defineProperty(exports, "__esModule", { value: true });
442
456
  exports.CallCredentials = undefined;
457
+ exports.isEmptyCallCredentials = isEmptyCallCredentials;
443
458
  var metadata_1 = require_metadata();
444
459
  function isCurrentOauth2Client(client) {
445
460
  return "getRequestHeaders" in client && typeof client.getRequestHeaders === "function";
@@ -500,6 +515,9 @@ var require_call_credentials = __commonJS(function(exports) {
500
515
  return base;
501
516
  }
502
517
  compose(other) {
518
+ if (other instanceof EmptyCallCredentials) {
519
+ return this;
520
+ }
503
521
  return new ComposedCallCredentials(this.creds.concat([other]));
504
522
  }
505
523
  _equals(other) {
@@ -531,6 +549,9 @@ var require_call_credentials = __commonJS(function(exports) {
531
549
  });
532
550
  }
533
551
  compose(other) {
552
+ if (other instanceof EmptyCallCredentials) {
553
+ return this;
554
+ }
534
555
  return new ComposedCallCredentials([this, other]);
535
556
  }
536
557
  _equals(other) {
@@ -556,6 +577,9 @@ var require_call_credentials = __commonJS(function(exports) {
556
577
  return other instanceof EmptyCallCredentials;
557
578
  }
558
579
  }
580
+ function isEmptyCallCredentials(callCredentials) {
581
+ return callCredentials instanceof EmptyCallCredentials;
582
+ }
559
583
  });
560
584
 
561
585
  // node_modules/@grpc/grpc-js/build/src/tls-helpers.js
@@ -585,6 +609,8 @@ var require_uri_parser = __commonJS(function(exports) {
585
609
  exports.splitHostPort = splitHostPort;
586
610
  exports.combineHostPort = combineHostPort;
587
611
  exports.uriToString = uriToString;
612
+ exports.extractServiceName = extractServiceName;
613
+ exports.computeServiceUrl = computeServiceUrl;
588
614
  var URI_REGEX = /^(?:([A-Za-z0-9+.-]+):)?(?:\/\/([^/]*)\/)?(.+)$/;
589
615
  function parseUri(uriString) {
590
616
  const parsedUri = URI_REGEX.exec(uriString);
@@ -667,6 +693,23 @@ var require_uri_parser = __commonJS(function(exports) {
667
693
  result += uri.path;
668
694
  return result;
669
695
  }
696
+ function extractServiceName(methodName) {
697
+ const firstSlashIndex = methodName.indexOf("/");
698
+ if (firstSlashIndex === -1) {
699
+ return "";
700
+ }
701
+ const secondSlashIndex = methodName.indexOf("/", firstSlashIndex + 1);
702
+ if (secondSlashIndex === -1) {
703
+ return methodName.substring(firstSlashIndex + 1);
704
+ }
705
+ return methodName.substring(firstSlashIndex + 1, secondSlashIndex);
706
+ }
707
+ function computeServiceUrl(host, methodName) {
708
+ var _a, _b;
709
+ const serviceName = extractServiceName(methodName);
710
+ const hostname = (_b = (_a = splitHostPort(host)) === null || _a === undefined ? undefined : _a.host) !== null && _b !== undefined ? _b : "localhost";
711
+ return `https://${hostname}/${serviceName}`;
712
+ }
670
713
  });
671
714
 
672
715
  // node_modules/@grpc/grpc-js/build/src/resolver.js
@@ -782,6 +825,7 @@ var require_channel_credentials = __commonJS(function(exports) {
782
825
  return other instanceof InsecureChannelCredentialsImpl;
783
826
  }
784
827
  _createSecureConnector(channelTarget, options, callCredentials) {
828
+ const credentials = callCredentials !== null && callCredentials !== undefined ? callCredentials : call_credentials_1.CallCredentials.createEmpty();
785
829
  return {
786
830
  connect(socket) {
787
831
  return Promise.resolve({
@@ -793,7 +837,7 @@ var require_channel_credentials = __commonJS(function(exports) {
793
837
  return Promise.resolve();
794
838
  },
795
839
  getCallCredentials: () => {
796
- return callCredentials !== null && callCredentials !== undefined ? callCredentials : call_credentials_1.CallCredentials.createEmpty();
840
+ return credentials;
797
841
  },
798
842
  destroy() {}
799
843
  };
@@ -1629,7 +1673,9 @@ var require_backoff_timeout = __commonJS(function(exports) {
1629
1673
  this.maxDelay = options.maxDelay;
1630
1674
  }
1631
1675
  }
1632
- this.trace("constructed initialDelay=" + this.initialDelay + " multiplier=" + this.multiplier + " jitter=" + this.jitter + " maxDelay=" + this.maxDelay);
1676
+ if (this.traceEnabled) {
1677
+ this.trace("constructed initialDelay=" + this.initialDelay + " multiplier=" + this.multiplier + " jitter=" + this.jitter + " maxDelay=" + this.maxDelay);
1678
+ }
1633
1679
  this.nextDelay = this.initialDelay;
1634
1680
  this.timerId = setTimeout(() => {}, 0);
1635
1681
  clearTimeout(this.timerId);
@@ -1637,12 +1683,19 @@ var require_backoff_timeout = __commonJS(function(exports) {
1637
1683
  static getNextId() {
1638
1684
  return this.nextId++;
1639
1685
  }
1686
+ get traceEnabled() {
1687
+ return logging.isTracerEnabled(TRACER_NAME);
1688
+ }
1640
1689
  trace(text) {
1641
- logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "{" + this.id + "} " + text);
1690
+ if (this.traceEnabled) {
1691
+ logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "{" + this.id + "} " + text);
1692
+ }
1642
1693
  }
1643
1694
  runTimer(delay) {
1644
1695
  var _a, _b;
1645
- this.trace("runTimer(delay=" + delay + ")");
1696
+ if (this.traceEnabled) {
1697
+ this.trace("runTimer(delay=" + delay + ")");
1698
+ }
1646
1699
  this.endTime = this.startTime;
1647
1700
  this.endTime.setMilliseconds(this.endTime.getMilliseconds() + delay);
1648
1701
  clearTimeout(this.timerId);
@@ -1670,7 +1723,9 @@ var require_backoff_timeout = __commonJS(function(exports) {
1670
1723
  this.running = false;
1671
1724
  }
1672
1725
  reset() {
1673
- this.trace("reset() running=" + this.running);
1726
+ if (this.traceEnabled) {
1727
+ this.trace("reset() running=" + this.running);
1728
+ }
1674
1729
  this.nextDelay = this.initialDelay;
1675
1730
  if (this.running) {
1676
1731
  const now = new Date;
@@ -1831,6 +1886,7 @@ var require_load_balancer_child_handler = __commonJS(function(exports) {
1831
1886
  var require_resolving_load_balancer = __commonJS(function(exports) {
1832
1887
  Object.defineProperty(exports, "__esModule", { value: true });
1833
1888
  exports.ResolvingLoadBalancer = undefined;
1889
+ exports.getDefaultConfigSelector = getDefaultConfigSelector;
1834
1890
  var load_balancer_1 = require_load_balancer();
1835
1891
  var service_config_1 = require_service_config();
1836
1892
  var connectivity_state_1 = require_connectivity_state();
@@ -1881,34 +1937,41 @@ var require_resolving_load_balancer = __commonJS(function(exports) {
1881
1937
  }
1882
1938
  return null;
1883
1939
  }
1940
+ var MAX_CACHED_METHOD_CONFIGS = 100;
1884
1941
  function getDefaultConfigSelector(serviceConfig) {
1942
+ const methodConfigCache = new Map;
1885
1943
  return {
1886
- invoke(methodName, metadata) {
1944
+ invoke(methodName, metadata, channelId) {
1887
1945
  var _a, _b;
1888
- const splitName = methodName.split("/").filter((x) => x.length > 0);
1889
- const service = (_a = splitName[0]) !== null && _a !== undefined ? _a : "";
1890
- const method = (_b = splitName[1]) !== null && _b !== undefined ? _b : "";
1891
- if (serviceConfig && serviceConfig.methodConfig) {
1892
- for (const matchLevel of NAME_MATCH_LEVEL_ORDER) {
1893
- const matchingConfig = findMatchingConfig(service, method, serviceConfig.methodConfig, matchLevel);
1894
- if (matchingConfig) {
1895
- return {
1896
- methodConfig: matchingConfig,
1897
- pickInformation: {},
1898
- status: constants_1.Status.OK,
1899
- dynamicFilterFactories: []
1900
- };
1946
+ let matchingConfig = methodConfigCache.get(methodName);
1947
+ if (matchingConfig === undefined) {
1948
+ const splitName = methodName.split("/").filter((x) => x.length > 0);
1949
+ const service = (_a = splitName[0]) !== null && _a !== undefined ? _a : "";
1950
+ const method = (_b = splitName[1]) !== null && _b !== undefined ? _b : "";
1951
+ matchingConfig = { name: [] };
1952
+ if (serviceConfig && serviceConfig.methodConfig) {
1953
+ for (const matchLevel of NAME_MATCH_LEVEL_ORDER) {
1954
+ const foundConfig = findMatchingConfig(service, method, serviceConfig.methodConfig, matchLevel);
1955
+ if (foundConfig) {
1956
+ matchingConfig = foundConfig;
1957
+ break;
1958
+ }
1901
1959
  }
1902
1960
  }
1961
+ if (methodConfigCache.size < MAX_CACHED_METHOD_CONFIGS) {
1962
+ methodConfigCache.set(methodName, matchingConfig);
1963
+ }
1903
1964
  }
1904
1965
  return {
1905
- methodConfig: { name: [] },
1966
+ methodConfig: matchingConfig,
1906
1967
  pickInformation: {},
1907
1968
  status: constants_1.Status.OK,
1908
1969
  dynamicFilterFactories: []
1909
1970
  };
1910
1971
  },
1911
- unref() {}
1972
+ unref() {
1973
+ methodConfigCache.clear();
1974
+ }
1912
1975
  };
1913
1976
  }
1914
1977
 
@@ -13027,6 +13090,7 @@ var require_channelz = __commonJS(function(exports) {
13027
13090
  Object.defineProperty(exports, "__esModule", { value: true });
13028
13091
  exports.registerChannelzSocket = exports.registerChannelzServer = exports.registerChannelzSubchannel = exports.registerChannelzChannel = exports.ChannelzCallTrackerStub = exports.ChannelzCallTracker = exports.ChannelzChildrenTrackerStub = exports.ChannelzChildrenTracker = exports.ChannelzTrace = exports.ChannelzTraceStub = undefined;
13029
13092
  exports.unregisterChannelzRef = unregisterChannelzRef;
13093
+ exports.dateToProtoTimestamp = dateToProtoTimestamp;
13030
13094
  exports.getChannelzHandlers = getChannelzHandlers;
13031
13095
  exports.getChannelzServiceDefinition = getChannelzServiceDefinition;
13032
13096
  exports.setup = setup;
@@ -13176,7 +13240,7 @@ var require_channelz = __commonJS(function(exports) {
13176
13240
  }
13177
13241
  addCallStarted() {
13178
13242
  this.callsStarted += 1;
13179
- this.lastCallStartedTimestamp = new Date;
13243
+ this.lastCallStartedTimestamp = Date.now();
13180
13244
  }
13181
13245
  addCallSucceeded() {
13182
13246
  this.callsSucceeded += 1;
@@ -13292,12 +13356,12 @@ var require_channelz = __commonJS(function(exports) {
13292
13356
  }
13293
13357
  }
13294
13358
  function dateToProtoTimestamp(date) {
13295
- if (!date) {
13359
+ if (date === null || date === undefined) {
13296
13360
  return null;
13297
13361
  }
13298
- const millisSinceEpoch = date.getTime();
13362
+ const millisSinceEpoch = typeof date === "number" ? date : date.getTime();
13299
13363
  return {
13300
- seconds: millisSinceEpoch / 1000 | 0,
13364
+ seconds: Math.floor(millisSinceEpoch / 1000),
13301
13365
  nanos: millisSinceEpoch % 1000 * 1e6
13302
13366
  };
13303
13367
  }
@@ -13668,6 +13732,12 @@ var require_compression_filter = __commonJS(function(exports) {
13668
13732
  let totalLength = 0;
13669
13733
  const messageParts = [];
13670
13734
  const decompresser = zlib.createInflate();
13735
+ decompresser.on("error", (error) => {
13736
+ reject({
13737
+ code: constants_1.Status.INTERNAL,
13738
+ details: "Failed to decompress deflate-encoded message"
13739
+ });
13740
+ });
13671
13741
  decompresser.on("data", (chunk) => {
13672
13742
  messageParts.push(chunk);
13673
13743
  totalLength += chunk.byteLength;
@@ -13709,6 +13779,12 @@ var require_compression_filter = __commonJS(function(exports) {
13709
13779
  let totalLength = 0;
13710
13780
  const messageParts = [];
13711
13781
  const decompresser = zlib.createGunzip();
13782
+ decompresser.on("error", (error) => {
13783
+ reject({
13784
+ code: constants_1.Status.INTERNAL,
13785
+ details: "Failed to decompress gzip-encoded message"
13786
+ });
13787
+ });
13712
13788
  decompresser.on("data", (chunk) => {
13713
13789
  messageParts.push(chunk);
13714
13790
  totalLength += chunk.byteLength;
@@ -13900,7 +13976,7 @@ var require_deadline = __commonJS(function(exports) {
13900
13976
  ["H", 60 * 60 * 1000]
13901
13977
  ];
13902
13978
  function getDeadlineTimeoutString(deadline) {
13903
- const now = new Date().getTime();
13979
+ const now = Date.now();
13904
13980
  if (deadline instanceof Date) {
13905
13981
  deadline = deadline.getTime();
13906
13982
  }
@@ -13916,7 +13992,7 @@ var require_deadline = __commonJS(function(exports) {
13916
13992
  var MAX_TIMEOUT_TIME = 2147483647;
13917
13993
  function getRelativeTimeout(deadline) {
13918
13994
  const deadlineMs = deadline instanceof Date ? deadline.getTime() : deadline;
13919
- const now = new Date().getTime();
13995
+ const now = Date.now();
13920
13996
  const timeout = deadlineMs - now;
13921
13997
  if (timeout < 0) {
13922
13998
  return 0;
@@ -13939,7 +14015,9 @@ var require_deadline = __commonJS(function(exports) {
13939
14015
  }
13940
14016
  }
13941
14017
  function formatDateDifference(startDate, endDate) {
13942
- return ((endDate.getTime() - startDate.getTime()) / 1000).toFixed(3) + "s";
14018
+ const startMs = typeof startDate === "number" ? startDate : startDate.getTime();
14019
+ const endMs = typeof endDate === "number" ? endDate : endDate.getTime();
14020
+ return ((endMs - startMs) / 1000).toFixed(3) + "s";
13943
14021
  }
13944
14022
  });
13945
14023
 
@@ -14031,7 +14109,6 @@ var require_single_subchannel_channel = __commonJS(function(exports) {
14031
14109
 
14032
14110
  class SubchannelCallWrapper {
14033
14111
  constructor(subchannel, method, filterStackFactory, options, callNumber) {
14034
- var _a, _b;
14035
14112
  this.subchannel = subchannel;
14036
14113
  this.method = method;
14037
14114
  this.options = options;
@@ -14043,13 +14120,7 @@ var require_single_subchannel_channel = __commonJS(function(exports) {
14043
14120
  this.pendingStatus = null;
14044
14121
  this.readFilterPending = false;
14045
14122
  this.writeFilterPending = false;
14046
- const splitPath = this.method.split("/");
14047
- let serviceName = "";
14048
- if (splitPath.length >= 2) {
14049
- serviceName = splitPath[1];
14050
- }
14051
- const hostname = (_b = (_a = (0, uri_parser_1.splitHostPort)(this.options.host)) === null || _a === undefined ? undefined : _a.host) !== null && _b !== undefined ? _b : "localhost";
14052
- this.serviceUrl = `https://${hostname}/${serviceName}`;
14123
+ this.serviceUrl = (0, uri_parser_1.computeServiceUrl)(this.options.host, this.method);
14053
14124
  const timeout = (0, deadline_1.getRelativeTimeout)(options.deadline);
14054
14125
  if (timeout !== Infinity) {
14055
14126
  if (timeout <= 0) {
@@ -14127,7 +14198,7 @@ var require_single_subchannel_channel = __commonJS(function(exports) {
14127
14198
  }
14128
14199
  }
14129
14200
  };
14130
- this.childCall = this.subchannel.createCall(credsMetadata, this.options.host, this.method, childListener);
14201
+ this.childCall = this.subchannel.createCall(credsMetadata, this.options.host, this.method, childListener, this.callNumber);
14131
14202
  if (this.readPending) {
14132
14203
  this.childCall.startRead();
14133
14204
  }
@@ -14286,7 +14357,9 @@ var require_subchannel = __commonJS(function(exports) {
14286
14357
  }
14287
14358
  this.channelzRef = (0, channelz_1.registerChannelzSubchannel)(this.subchannelAddressString, () => this.getChannelzInfo(), this.channelzEnabled);
14288
14359
  this.channelzTrace.addTrace("CT_INFO", "Subchannel created");
14289
- this.trace("Subchannel constructed with options " + JSON.stringify(options, undefined, 2));
14360
+ if (this.traceEnabled) {
14361
+ this.trace("Subchannel constructed with options " + JSON.stringify(options, undefined, 2));
14362
+ }
14290
14363
  this.secureConnector = credentials._createSecureConnector(channelTarget, options);
14291
14364
  }
14292
14365
  getChannelzInfo() {
@@ -14298,11 +14371,21 @@ var require_subchannel = __commonJS(function(exports) {
14298
14371
  target: this.subchannelAddressString
14299
14372
  };
14300
14373
  }
14374
+ get traceEnabled() {
14375
+ return logging.isTracerEnabled(TRACER_NAME);
14376
+ }
14377
+ get refTraceEnabled() {
14378
+ return logging.isTracerEnabled("subchannel_refcount");
14379
+ }
14301
14380
  trace(text) {
14302
- logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text);
14381
+ if (this.traceEnabled) {
14382
+ logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text);
14383
+ }
14303
14384
  }
14304
14385
  refTrace(text) {
14305
- logging.trace(constants_1.LogVerbosity.DEBUG, "subchannel_refcount", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text);
14386
+ if (this.refTraceEnabled) {
14387
+ logging.trace(constants_1.LogVerbosity.DEBUG, "subchannel_refcount", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text);
14388
+ }
14306
14389
  }
14307
14390
  handleBackoffTimer() {
14308
14391
  if (this.continueConnecting) {
@@ -14349,10 +14432,12 @@ var require_subchannel = __commonJS(function(exports) {
14349
14432
  if (oldStates.indexOf(this.connectivityState) === -1) {
14350
14433
  return false;
14351
14434
  }
14352
- if (errorMessage) {
14353
- this.trace(connectivity_state_1.ConnectivityState[this.connectivityState] + " -> " + connectivity_state_1.ConnectivityState[newState] + ' with error "' + errorMessage + '"');
14354
- } else {
14355
- this.trace(connectivity_state_1.ConnectivityState[this.connectivityState] + " -> " + connectivity_state_1.ConnectivityState[newState]);
14435
+ if (this.traceEnabled) {
14436
+ if (errorMessage) {
14437
+ this.trace(connectivity_state_1.ConnectivityState[this.connectivityState] + " -> " + connectivity_state_1.ConnectivityState[newState] + ' with error "' + errorMessage + '"');
14438
+ } else {
14439
+ this.trace(connectivity_state_1.ConnectivityState[this.connectivityState] + " -> " + connectivity_state_1.ConnectivityState[newState]);
14440
+ }
14356
14441
  }
14357
14442
  if (this.channelzEnabled) {
14358
14443
  this.channelzTrace.addTrace("CT_INFO", "Connectivity state change to " + connectivity_state_1.ConnectivityState[newState]);
@@ -14396,11 +14481,15 @@ var require_subchannel = __commonJS(function(exports) {
14396
14481
  return true;
14397
14482
  }
14398
14483
  ref() {
14399
- this.refTrace("refcount " + this.refcount + " -> " + (this.refcount + 1));
14484
+ if (this.refTraceEnabled) {
14485
+ this.refTrace("refcount " + this.refcount + " -> " + (this.refcount + 1));
14486
+ }
14400
14487
  this.refcount += 1;
14401
14488
  }
14402
14489
  unref() {
14403
- this.refTrace("refcount " + this.refcount + " -> " + (this.refcount - 1));
14490
+ if (this.refTraceEnabled) {
14491
+ this.refTrace("refcount " + this.refcount + " -> " + (this.refcount - 1));
14492
+ }
14404
14493
  this.refcount -= 1;
14405
14494
  if (this.refcount === 0) {
14406
14495
  this.channelzTrace.addTrace("CT_INFO", "Shutting down");
@@ -14418,7 +14507,7 @@ var require_subchannel = __commonJS(function(exports) {
14418
14507
  }
14419
14508
  return false;
14420
14509
  }
14421
- createCall(metadata, host, method, listener) {
14510
+ createCall(metadata, host, method, listener, callId) {
14422
14511
  if (!this.transport) {
14423
14512
  throw new Error("Cannot create call, subchannel not READY");
14424
14513
  }
@@ -14438,7 +14527,7 @@ var require_subchannel = __commonJS(function(exports) {
14438
14527
  } else {
14439
14528
  statsTracker = {};
14440
14529
  }
14441
- return this.transport.createCall(metadata, host, method, listener, statsTracker);
14530
+ return this.transport.createCall(metadata, host, method, listener, statsTracker, callId);
14442
14531
  }
14443
14532
  startConnecting() {
14444
14533
  process.nextTick(() => {
@@ -14517,9 +14606,11 @@ var require_subchannel = __commonJS(function(exports) {
14517
14606
  // node_modules/@grpc/grpc-js/build/src/environment.js
14518
14607
  var require_environment = __commonJS(function(exports) {
14519
14608
  var _a;
14609
+ var _b;
14520
14610
  Object.defineProperty(exports, "__esModule", { value: true });
14521
- exports.GRPC_NODE_USE_ALTERNATIVE_RESOLVER = undefined;
14611
+ exports.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS = exports.GRPC_NODE_USE_ALTERNATIVE_RESOLVER = undefined;
14522
14612
  exports.GRPC_NODE_USE_ALTERNATIVE_RESOLVER = ((_a = process.env.GRPC_NODE_USE_ALTERNATIVE_RESOLVER) !== null && _a !== undefined ? _a : "false") === "true";
14613
+ exports.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS = ((_b = process.env.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) !== null && _b !== undefined ? _b : "false") === "true";
14523
14614
  });
14524
14615
 
14525
14616
  // node_modules/@grpc/grpc-js/build/src/resolver-dns.js
@@ -15158,13 +15249,15 @@ var require_subchannel_call = __commonJS(function(exports) {
15158
15249
  const maxReceiveMessageLength = (_a = transport.getOptions()["grpc.max_receive_message_length"]) !== null && _a !== undefined ? _a : constants_1.DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH;
15159
15250
  this.decoder = new stream_decoder_1.StreamDecoder(maxReceiveMessageLength);
15160
15251
  http2Stream.on("response", (headers, flags) => {
15161
- let headersString = "";
15162
- for (const header of Object.keys(headers)) {
15163
- headersString += "\t\t" + header + ": " + headers[header] + `
15252
+ if (this.traceEnabled) {
15253
+ let headersString = "";
15254
+ for (const header of Object.keys(headers)) {
15255
+ headersString += "\t\t" + header + ": " + headers[header] + `
15164
15256
  `;
15165
- }
15166
- this.trace(`Received server headers:
15257
+ }
15258
+ this.trace(`Received server headers:
15167
15259
  ` + headersString);
15260
+ }
15168
15261
  this.httpStatusCode = headers[":status"];
15169
15262
  if (flags & http2.constants.NGHTTP2_FLAG_END_STREAM) {
15170
15263
  this.handleTrailers(headers);
@@ -15190,7 +15283,9 @@ var require_subchannel_call = __commonJS(function(exports) {
15190
15283
  if (this.statusOutput) {
15191
15284
  return;
15192
15285
  }
15193
- this.trace("receive HTTP/2 data frame of length " + data.length);
15286
+ if (this.traceEnabled) {
15287
+ this.trace("receive HTTP/2 data frame of length " + data.length);
15288
+ }
15194
15289
  let messages;
15195
15290
  try {
15196
15291
  messages = this.decoder.write(data);
@@ -15204,7 +15299,9 @@ var require_subchannel_call = __commonJS(function(exports) {
15204
15299
  return;
15205
15300
  }
15206
15301
  for (const message of messages) {
15207
- this.trace("parsed message of length " + message.length);
15302
+ if (this.traceEnabled) {
15303
+ this.trace("parsed message of length " + message.length);
15304
+ }
15208
15305
  this.callEventTracker.addMessageReceived();
15209
15306
  this.tryPush(message);
15210
15307
  }
@@ -15217,7 +15314,9 @@ var require_subchannel_call = __commonJS(function(exports) {
15217
15314
  this.serverEndedCall = true;
15218
15315
  process.nextTick(() => {
15219
15316
  var _a;
15220
- this.trace("HTTP/2 stream closed with code " + http2Stream.rstCode);
15317
+ if (this.traceEnabled) {
15318
+ this.trace("HTTP/2 stream closed with code " + http2Stream.rstCode);
15319
+ }
15221
15320
  if (((_a = this.finalStatus) === null || _a === undefined ? undefined : _a.code) === constants_1.Status.OK) {
15222
15321
  return;
15223
15322
  }
@@ -15285,7 +15384,9 @@ var require_subchannel_call = __commonJS(function(exports) {
15285
15384
  });
15286
15385
  http2Stream.on("error", (err) => {
15287
15386
  if (err.code !== "ERR_HTTP2_STREAM_ERROR") {
15288
- this.trace("Node error event: message=" + err.message + " code=" + err.code + " errno=" + getSystemErrorName(err.errno) + " syscall=" + err.syscall);
15387
+ if (this.traceEnabled) {
15388
+ this.trace("Node error event: message=" + err.message + " code=" + err.code + " errno=" + getSystemErrorName(err.errno) + " syscall=" + err.syscall);
15389
+ }
15289
15390
  this.internalError = err;
15290
15391
  }
15291
15392
  this.callEventTracker.onStreamEnd(false);
@@ -15307,7 +15408,9 @@ var require_subchannel_call = __commonJS(function(exports) {
15307
15408
  outputStatus() {
15308
15409
  if (!this.statusOutput) {
15309
15410
  this.statusOutput = true;
15310
- this.trace("ended with status: code=" + this.finalStatus.code + ' details="' + this.finalStatus.details + '"');
15411
+ if (this.traceEnabled) {
15412
+ this.trace("ended with status: code=" + this.finalStatus.code + ' details="' + this.finalStatus.details + '"');
15413
+ }
15311
15414
  this.callEventTracker.onCallEnd(this.finalStatus);
15312
15415
  process.nextTick(() => {
15313
15416
  this.listener.onReceiveStatus(this.finalStatus);
@@ -15315,8 +15418,13 @@ var require_subchannel_call = __commonJS(function(exports) {
15315
15418
  this.http2Stream.resume();
15316
15419
  }
15317
15420
  }
15421
+ get traceEnabled() {
15422
+ return logging.isTracerEnabled(TRACER_NAME);
15423
+ }
15318
15424
  trace(text) {
15319
- logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callId + "] " + text);
15425
+ if (this.traceEnabled) {
15426
+ logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callId + "] " + text);
15427
+ }
15320
15428
  }
15321
15429
  endCall(status) {
15322
15430
  if (this.finalStatus === null || this.finalStatus.code === constants_1.Status.OK) {
@@ -15333,7 +15441,9 @@ var require_subchannel_call = __commonJS(function(exports) {
15333
15441
  }
15334
15442
  }
15335
15443
  push(message) {
15336
- this.trace("pushing to reader message of length " + (message instanceof Buffer ? message.length : null));
15444
+ if (this.traceEnabled) {
15445
+ this.trace("pushing to reader message of length " + (message instanceof Buffer ? message.length : null));
15446
+ }
15337
15447
  this.canPush = false;
15338
15448
  this.isPushPending = true;
15339
15449
  process.nextTick(() => {
@@ -15350,41 +15460,51 @@ var require_subchannel_call = __commonJS(function(exports) {
15350
15460
  this.http2Stream.pause();
15351
15461
  this.push(messageBytes);
15352
15462
  } else {
15353
- this.trace("unpushedReadMessages.push message of length " + messageBytes.length);
15463
+ if (this.traceEnabled) {
15464
+ this.trace("unpushedReadMessages.push message of length " + messageBytes.length);
15465
+ }
15354
15466
  this.unpushedReadMessages.push(messageBytes);
15355
15467
  }
15356
15468
  }
15357
15469
  handleTrailers(headers) {
15358
15470
  this.serverEndedCall = true;
15359
15471
  this.callEventTracker.onStreamEnd(true);
15360
- let headersString = "";
15361
- for (const header of Object.keys(headers)) {
15362
- headersString += "\t\t" + header + ": " + headers[header] + `
15472
+ if (this.traceEnabled) {
15473
+ let headersString = "";
15474
+ for (const header of Object.keys(headers)) {
15475
+ headersString += "\t\t" + header + ": " + headers[header] + `
15363
15476
  `;
15364
- }
15365
- this.trace(`Received server trailers:
15477
+ }
15478
+ this.trace(`Received server trailers:
15366
15479
  ` + headersString);
15480
+ }
15367
15481
  let metadata;
15368
15482
  try {
15369
15483
  metadata = metadata_1.Metadata.fromHttp2Headers(headers);
15370
15484
  } catch (e) {
15371
15485
  metadata = new metadata_1.Metadata;
15372
15486
  }
15373
- const metadataMap = metadata.getMap();
15487
+ const statusValues = metadata.get("grpc-status");
15374
15488
  let status;
15375
- if (typeof metadataMap["grpc-status"] === "string") {
15376
- const receivedStatus = Number(metadataMap["grpc-status"]);
15377
- this.trace("received status code " + receivedStatus + " from server");
15489
+ if (statusValues.length > 0 && typeof statusValues[0] === "string") {
15490
+ const receivedStatus = Number(statusValues[0]);
15491
+ if (this.traceEnabled) {
15492
+ this.trace("received status code " + receivedStatus + " from server");
15493
+ }
15378
15494
  metadata.remove("grpc-status");
15379
15495
  let details = "";
15380
- if (typeof metadataMap["grpc-message"] === "string") {
15496
+ const messageValues = metadata.get("grpc-message");
15497
+ if (messageValues.length > 0 && typeof messageValues[0] === "string") {
15498
+ const messageString = messageValues[0];
15381
15499
  try {
15382
- details = decodeURI(metadataMap["grpc-message"]);
15383
- } catch (e) {
15384
- details = metadataMap["grpc-message"];
15500
+ details = decodeURI(messageString);
15501
+ } catch (error) {
15502
+ details = messageString;
15385
15503
  }
15386
15504
  metadata.remove("grpc-message");
15387
- this.trace('received status details string "' + details + '" from server');
15505
+ if (this.traceEnabled) {
15506
+ this.trace('received status details string "' + details + '" from server');
15507
+ }
15388
15508
  }
15389
15509
  status = {
15390
15510
  code: receivedStatus,
@@ -15409,7 +15529,9 @@ var require_subchannel_call = __commonJS(function(exports) {
15409
15529
  return;
15410
15530
  }
15411
15531
  if (this.serverEndedCall) {
15412
- this.http2Stream.end();
15532
+ if (!this.http2Stream.writableEnded) {
15533
+ this.http2Stream.end();
15534
+ }
15413
15535
  } else {
15414
15536
  let code;
15415
15537
  if (((_a = this.finalStatus) === null || _a === undefined ? undefined : _a.code) === constants_1.Status.OK) {
@@ -15417,12 +15539,16 @@ var require_subchannel_call = __commonJS(function(exports) {
15417
15539
  } else {
15418
15540
  code = http2.constants.NGHTTP2_CANCEL;
15419
15541
  }
15420
- this.trace("close http2 stream with code " + code);
15542
+ if (this.traceEnabled) {
15543
+ this.trace("close http2 stream with code " + code);
15544
+ }
15421
15545
  this.http2Stream.close(code);
15422
15546
  }
15423
15547
  }
15424
15548
  cancelWithStatus(status, details) {
15425
- this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"');
15549
+ if (this.traceEnabled) {
15550
+ this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"');
15551
+ }
15426
15552
  this.endCall({ code: status, details, metadata: new metadata_1.Metadata });
15427
15553
  }
15428
15554
  getStatus() {
@@ -15452,7 +15578,9 @@ var require_subchannel_call = __commonJS(function(exports) {
15452
15578
  this.http2Stream.resume();
15453
15579
  }
15454
15580
  sendMessageWithContext(context, message) {
15455
- this.trace("write() called with message of length " + message.length);
15581
+ if (this.traceEnabled) {
15582
+ this.trace("write() called with message of length " + message.length);
15583
+ }
15456
15584
  const cb = (error) => {
15457
15585
  process.nextTick(() => {
15458
15586
  var _a;
@@ -15461,12 +15589,19 @@ var require_subchannel_call = __commonJS(function(exports) {
15461
15589
  code = constants_1.Status.INTERNAL;
15462
15590
  }
15463
15591
  if (error) {
15464
- this.cancelWithStatus(code, `Write error: ${error.message}`);
15592
+ this.endCall({
15593
+ code,
15594
+ details: `Write error: ${error.message}`,
15595
+ metadata: new metadata_1.Metadata,
15596
+ rstCode: this.http2Stream.rstCode
15597
+ });
15465
15598
  }
15466
15599
  (_a = context.callback) === null || _a === undefined || _a.call(context);
15467
15600
  });
15468
15601
  };
15469
- this.trace("sending data chunk of length " + message.length);
15602
+ if (this.traceEnabled) {
15603
+ this.trace("sending data chunk of length " + message.length);
15604
+ }
15470
15605
  this.callEventTracker.addMessageSent();
15471
15606
  try {
15472
15607
  this.http2Stream.write(message, cb);
@@ -15480,6 +15615,9 @@ var require_subchannel_call = __commonJS(function(exports) {
15480
15615
  }
15481
15616
  halfClose() {
15482
15617
  this.trace("end() called");
15618
+ if (this.http2Stream.destroyed || this.http2Stream.writableEnded) {
15619
+ return;
15620
+ }
15483
15621
  this.trace("calling end() on HTTP/2 stream");
15484
15622
  this.http2Stream.end();
15485
15623
  }
@@ -15563,18 +15701,24 @@ var require_transport = __commonJS(function(exports) {
15563
15701
  if (errorCode === http2.constants.NGHTTP2_ENHANCE_YOUR_CALM && opaqueData && opaqueData.equals(tooManyPingsData)) {
15564
15702
  tooManyPings = true;
15565
15703
  }
15566
- this.trace("connection closed by GOAWAY with code " + errorCode + " and data " + (opaqueData === null || opaqueData === undefined ? undefined : opaqueData.toString()));
15704
+ if (this.traceEnabled) {
15705
+ this.trace("connection closed by GOAWAY with code " + errorCode + " and data " + (opaqueData === null || opaqueData === undefined ? undefined : opaqueData.toString()));
15706
+ }
15567
15707
  this.reportDisconnectToOwner(tooManyPings);
15568
15708
  });
15569
15709
  session.once("error", (error) => {
15570
- this.trace("connection closed with error " + error.message);
15710
+ if (this.traceEnabled) {
15711
+ this.trace("connection closed with error " + error.message);
15712
+ }
15571
15713
  this.handleDisconnect();
15572
15714
  });
15573
15715
  session.socket.once("close", (hadError) => {
15574
- this.trace("connection closed. hadError=" + hadError);
15716
+ if (this.traceEnabled) {
15717
+ this.trace("connection closed. hadError=" + hadError);
15718
+ }
15575
15719
  this.handleDisconnect();
15576
15720
  });
15577
- if (logging.isTracerEnabled(TRACER_NAME)) {
15721
+ if (this.traceEnabled) {
15578
15722
  session.on("remoteSettings", (settings) => {
15579
15723
  this.trace("new settings received" + (this.session !== session ? " on the old connection" : "") + ": " + JSON.stringify(settings));
15580
15724
  });
@@ -15585,7 +15729,7 @@ var require_transport = __commonJS(function(exports) {
15585
15729
  if (this.keepaliveWithoutCalls) {
15586
15730
  this.maybeStartKeepalivePingTimer();
15587
15731
  }
15588
- if (session.socket instanceof tls_1.TLSSocket) {
15732
+ if (session.socket instanceof tls_1.TLSSocket && session.socket.authorized) {
15589
15733
  this.authContext = {
15590
15734
  transportSecurityType: "ssl",
15591
15735
  sslPeerCertificate: session.socket.getPeerCertificate()
@@ -15634,17 +15778,37 @@ var require_transport = __commonJS(function(exports) {
15634
15778
  };
15635
15779
  return socketInfo;
15636
15780
  }
15781
+ get traceEnabled() {
15782
+ return logging.isTracerEnabled(TRACER_NAME);
15783
+ }
15784
+ get keepaliveTraceEnabled() {
15785
+ return logging.isTracerEnabled("keepalive");
15786
+ }
15787
+ get flowControlTraceEnabled() {
15788
+ return logging.isTracerEnabled(FLOW_CONTROL_TRACER_NAME);
15789
+ }
15790
+ get internalsTraceEnabled() {
15791
+ return logging.isTracerEnabled("transport_internals");
15792
+ }
15637
15793
  trace(text) {
15638
- logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text);
15794
+ if (this.traceEnabled) {
15795
+ logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text);
15796
+ }
15639
15797
  }
15640
15798
  keepaliveTrace(text) {
15641
- logging.trace(constants_1.LogVerbosity.DEBUG, "keepalive", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text);
15799
+ if (this.keepaliveTraceEnabled) {
15800
+ logging.trace(constants_1.LogVerbosity.DEBUG, "keepalive", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text);
15801
+ }
15642
15802
  }
15643
15803
  flowControlTrace(text) {
15644
- logging.trace(constants_1.LogVerbosity.DEBUG, FLOW_CONTROL_TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text);
15804
+ if (this.flowControlTraceEnabled) {
15805
+ logging.trace(constants_1.LogVerbosity.DEBUG, FLOW_CONTROL_TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text);
15806
+ }
15645
15807
  }
15646
15808
  internalsTrace(text) {
15647
- logging.trace(constants_1.LogVerbosity.DEBUG, "transport_internals", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text);
15809
+ if (this.internalsTraceEnabled) {
15810
+ logging.trace(constants_1.LogVerbosity.DEBUG, "transport_internals", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text);
15811
+ }
15648
15812
  }
15649
15813
  reportDisconnectToOwner(tooManyPings) {
15650
15814
  if (this.disconnectHandled) {
@@ -15682,7 +15846,9 @@ var require_transport = __commonJS(function(exports) {
15682
15846
  if (this.channelzEnabled) {
15683
15847
  this.keepalivesSent += 1;
15684
15848
  }
15685
- this.keepaliveTrace("Sending ping with timeout " + this.keepaliveTimeoutMs + "ms");
15849
+ if (this.keepaliveTraceEnabled) {
15850
+ this.keepaliveTrace("Sending ping with timeout " + this.keepaliveTimeoutMs + "ms");
15851
+ }
15686
15852
  this.keepaliveTimer = setTimeout(() => {
15687
15853
  this.keepaliveTimer = null;
15688
15854
  this.keepaliveTrace("Ping timeout passed without response");
@@ -15694,7 +15860,9 @@ var require_transport = __commonJS(function(exports) {
15694
15860
  const pingSentSuccessfully = this.session.ping((err, duration, payload) => {
15695
15861
  this.clearKeepaliveTimeout();
15696
15862
  if (err) {
15697
- this.keepaliveTrace("Ping failed with error " + err.message);
15863
+ if (this.keepaliveTraceEnabled) {
15864
+ this.keepaliveTrace("Ping failed with error " + err.message);
15865
+ }
15698
15866
  this.handleDisconnect();
15699
15867
  } else {
15700
15868
  this.keepaliveTrace("Received ping response");
@@ -15708,7 +15876,9 @@ var require_transport = __commonJS(function(exports) {
15708
15876
  pingSendError = (e instanceof Error ? e.message : "") || "Unknown error";
15709
15877
  }
15710
15878
  if (pingSendError) {
15711
- this.keepaliveTrace("Ping send failed: " + pingSendError);
15879
+ if (this.keepaliveTraceEnabled) {
15880
+ this.keepaliveTrace("Ping send failed: " + pingSendError);
15881
+ }
15712
15882
  this.handleDisconnect();
15713
15883
  }
15714
15884
  }
@@ -15750,7 +15920,7 @@ var require_transport = __commonJS(function(exports) {
15750
15920
  }
15751
15921
  }
15752
15922
  }
15753
- createCall(metadata, host, method, listener, subchannelCallStatsTracker) {
15923
+ createCall(metadata, host, method, listener, subchannelCallStatsTracker, callId) {
15754
15924
  const headers = metadata.toHttp2Headers();
15755
15925
  headers[HTTP2_HEADER_AUTHORITY] = host;
15756
15926
  headers[HTTP2_HEADER_USER_AGENT] = this.userAgent;
@@ -15765,8 +15935,12 @@ var require_transport = __commonJS(function(exports) {
15765
15935
  this.handleDisconnect();
15766
15936
  throw e;
15767
15937
  }
15768
- this.flowControlTrace("local window size: " + this.session.state.localWindowSize + " remote window size: " + this.session.state.remoteWindowSize);
15769
- this.internalsTrace("session.closed=" + this.session.closed + " session.destroyed=" + this.session.destroyed + " session.socket.destroyed=" + this.session.socket.destroyed);
15938
+ if (this.flowControlTraceEnabled) {
15939
+ this.flowControlTrace("local window size: " + this.session.state.localWindowSize + " remote window size: " + this.session.state.remoteWindowSize);
15940
+ }
15941
+ if (this.internalsTraceEnabled) {
15942
+ this.internalsTrace("session.closed=" + this.session.closed + " session.destroyed=" + this.session.destroyed + " session.socket.destroyed=" + this.session.socket.destroyed);
15943
+ }
15770
15944
  let eventTracker;
15771
15945
  let call;
15772
15946
  if (this.channelzEnabled) {
@@ -15775,13 +15949,13 @@ var require_transport = __commonJS(function(exports) {
15775
15949
  addMessageSent: () => {
15776
15950
  var _a;
15777
15951
  this.messagesSent += 1;
15778
- this.lastMessageSentTimestamp = new Date;
15952
+ this.lastMessageSentTimestamp = Date.now();
15779
15953
  (_a = subchannelCallStatsTracker.addMessageSent) === null || _a === undefined || _a.call(subchannelCallStatsTracker);
15780
15954
  },
15781
15955
  addMessageReceived: () => {
15782
15956
  var _a;
15783
15957
  this.messagesReceived += 1;
15784
- this.lastMessageReceivedTimestamp = new Date;
15958
+ this.lastMessageReceivedTimestamp = Date.now();
15785
15959
  (_a = subchannelCallStatsTracker.addMessageReceived) === null || _a === undefined || _a.call(subchannelCallStatsTracker);
15786
15960
  },
15787
15961
  onCallEnd: (status) => {
@@ -15820,7 +15994,7 @@ var require_transport = __commonJS(function(exports) {
15820
15994
  }
15821
15995
  };
15822
15996
  }
15823
- call = new subchannel_call_1.Http2SubchannelCall(http2Stream, eventTracker, listener, this, (0, call_number_1.getNextCallNumber)());
15997
+ call = new subchannel_call_1.Http2SubchannelCall(http2Stream, eventTracker, listener, this, callId !== null && callId !== undefined ? callId : (0, call_number_1.getNextCallNumber)());
15824
15998
  this.addActiveCall(call);
15825
15999
  return call;
15826
16000
  }
@@ -15848,8 +16022,13 @@ var require_transport = __commonJS(function(exports) {
15848
16022
  this.session = null;
15849
16023
  this.isShutdown = false;
15850
16024
  }
16025
+ get traceEnabled() {
16026
+ return logging.isTracerEnabled(TRACER_NAME);
16027
+ }
15851
16028
  trace(text) {
15852
- logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, (0, uri_parser_1.uriToString)(this.channelTarget) + " " + text);
16029
+ if (this.traceEnabled) {
16030
+ logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, (0, uri_parser_1.uriToString)(this.channelTarget) + " " + text);
16031
+ }
15853
16032
  }
15854
16033
  createSession(secureConnectResult, address, options) {
15855
16034
  if (this.isShutdown) {
@@ -15886,7 +16065,9 @@ var require_transport = __commonJS(function(exports) {
15886
16065
  var _a;
15887
16066
  (_a = this.session) === null || _a === undefined || _a.destroy();
15888
16067
  errorMessage = error.message;
15889
- this.trace("connection failed with error " + errorMessage);
16068
+ if (this.traceEnabled) {
16069
+ this.trace("connection failed with error " + errorMessage);
16070
+ }
15890
16071
  if (!reportedError) {
15891
16072
  reportedError = true;
15892
16073
  reject(`${errorMessage} (${new Date().toISOString()})`);
@@ -15963,14 +16144,22 @@ var require_transport = __commonJS(function(exports) {
15963
16144
  let secureConnectResult = null;
15964
16145
  const addressString = (0, subchannel_address_1.subchannelAddressToString)(address);
15965
16146
  try {
15966
- this.trace(addressString + " Waiting for secureConnector to be ready");
16147
+ if (this.traceEnabled) {
16148
+ this.trace(addressString + " Waiting for secureConnector to be ready");
16149
+ }
15967
16150
  await secureConnector.waitForReady();
15968
- this.trace(addressString + " secureConnector is ready");
16151
+ if (this.traceEnabled) {
16152
+ this.trace(addressString + " secureConnector is ready");
16153
+ }
15969
16154
  tcpConnection = await this.tcpConnect(address, options);
15970
16155
  tcpConnection.setNoDelay();
15971
- this.trace(addressString + " Established TCP connection");
16156
+ if (this.traceEnabled) {
16157
+ this.trace(addressString + " Established TCP connection");
16158
+ }
15972
16159
  secureConnectResult = await secureConnector.connect(tcpConnection);
15973
- this.trace(addressString + " Established secure connection");
16160
+ if (this.traceEnabled) {
16161
+ this.trace(addressString + " Established secure connection");
16162
+ }
15974
16163
  return this.createSession(secureConnectResult, address, options);
15975
16164
  } catch (e) {
15976
16165
  tcpConnection === null || tcpConnection === undefined || tcpConnection.destroy();
@@ -16069,20 +16258,20 @@ var require_subchannel_pool = __commonJS(function(exports) {
16069
16258
  var require_load_balancing_call = __commonJS(function(exports) {
16070
16259
  Object.defineProperty(exports, "__esModule", { value: true });
16071
16260
  exports.LoadBalancingCall = undefined;
16261
+ var call_credentials_1 = require_call_credentials();
16072
16262
  var connectivity_state_1 = require_connectivity_state();
16073
16263
  var constants_1 = require_constants();
16074
16264
  var deadline_1 = require_deadline();
16075
16265
  var metadata_1 = require_metadata();
16076
16266
  var picker_1 = require_picker();
16077
- var uri_parser_1 = require_uri_parser();
16078
16267
  var logging = require_logging();
16079
16268
  var control_plane_status_1 = require_control_plane_status();
16080
16269
  var http2 = __require("http2");
16081
16270
  var TRACER_NAME = "load_balancing_call";
16271
+ var RESOLVED_EMPTY_METADATA = Promise.resolve(undefined);
16082
16272
 
16083
16273
  class LoadBalancingCall {
16084
16274
  constructor(channel, callConfig, methodName, host, credentials, deadline, callNumber) {
16085
- var _a, _b;
16086
16275
  this.channel = channel;
16087
16276
  this.callConfig = callConfig;
16088
16277
  this.methodName = methodName;
@@ -16099,19 +16288,13 @@ var require_load_balancing_call = __commonJS(function(exports) {
16099
16288
  this.listener = null;
16100
16289
  this.onCallEnded = null;
16101
16290
  this.childStartTime = null;
16102
- const splitPath = this.methodName.split("/");
16103
- let serviceName = "";
16104
- if (splitPath.length >= 2) {
16105
- serviceName = splitPath[1];
16106
- }
16107
- const hostname = (_b = (_a = (0, uri_parser_1.splitHostPort)(this.host)) === null || _a === undefined ? undefined : _a.host) !== null && _b !== undefined ? _b : "localhost";
16108
- this.serviceUrl = `https://${hostname}/${serviceName}`;
16109
- this.startTime = new Date;
16291
+ this.serviceUrl = this.channel.getServiceUrl(this.host, this.methodName);
16292
+ this.startTime = Date.now();
16110
16293
  }
16111
16294
  getDeadlineInfo() {
16112
16295
  var _a, _b;
16113
16296
  const deadlineInfo = [];
16114
- if (this.childStartTime) {
16297
+ if (this.childStartTime !== null) {
16115
16298
  if (this.childStartTime > this.startTime) {
16116
16299
  if ((_a = this.metadata) === null || _a === undefined ? undefined : _a.getOptions().waitForReady) {
16117
16300
  deadlineInfo.push("wait_for_ready");
@@ -16128,19 +16311,36 @@ var require_load_balancing_call = __commonJS(function(exports) {
16128
16311
  }
16129
16312
  return deadlineInfo;
16130
16313
  }
16314
+ get traceEnabled() {
16315
+ return logging.isTracerEnabled(TRACER_NAME);
16316
+ }
16131
16317
  trace(text) {
16132
- logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text);
16318
+ if (this.traceEnabled) {
16319
+ logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text);
16320
+ }
16321
+ }
16322
+ getSubchannelString(subchannel) {
16323
+ return subchannel ? "(" + subchannel.getChannelzRef().id + ") " + subchannel.getAddress() : "" + subchannel;
16133
16324
  }
16134
16325
  outputStatus(status, progress) {
16135
16326
  var _a, _b;
16136
16327
  if (!this.ended) {
16137
16328
  this.ended = true;
16138
- this.trace("ended with status: code=" + status.code + ' details="' + status.details + '" start time=' + this.startTime.toISOString());
16329
+ if (this.traceEnabled) {
16330
+ this.trace("ended with status: code=" + status.code + ' details="' + status.details + '" start time=' + new Date(this.startTime).toISOString());
16331
+ }
16139
16332
  const finalStatus = Object.assign(Object.assign({}, status), { progress });
16140
16333
  (_a = this.listener) === null || _a === undefined || _a.onReceiveStatus(finalStatus);
16141
16334
  (_b = this.onCallEnded) === null || _b === undefined || _b.call(this, finalStatus.code, finalStatus.details, finalStatus.metadata);
16335
+ this.channel.removeCallFromPickQueue(this);
16142
16336
  }
16143
16337
  }
16338
+ generateCallCredentialsMetadata(callCredentials) {
16339
+ return (0, call_credentials_1.isEmptyCallCredentials)(callCredentials) ? RESOLVED_EMPTY_METADATA : callCredentials.generateMetadata({
16340
+ method_name: this.methodName,
16341
+ service_url: this.serviceUrl
16342
+ });
16343
+ }
16144
16344
  doPick() {
16145
16345
  var _a, _b;
16146
16346
  if (this.ended) {
@@ -16152,18 +16352,20 @@ var require_load_balancing_call = __commonJS(function(exports) {
16152
16352
  this.trace("Pick called");
16153
16353
  const finalMetadata = this.metadata.clone();
16154
16354
  const pickResult = this.channel.doPick(finalMetadata, this.callConfig.pickInformation);
16155
- const subchannelString = pickResult.subchannel ? "(" + pickResult.subchannel.getChannelzRef().id + ") " + pickResult.subchannel.getAddress() : "" + pickResult.subchannel;
16156
- this.trace("Pick result: " + picker_1.PickResultType[pickResult.pickResultType] + " subchannel: " + subchannelString + " status: " + ((_a = pickResult.status) === null || _a === undefined ? undefined : _a.code) + " " + ((_b = pickResult.status) === null || _b === undefined ? undefined : _b.details));
16355
+ if (this.traceEnabled) {
16356
+ this.trace("Pick result: " + picker_1.PickResultType[pickResult.pickResultType] + " subchannel: " + this.getSubchannelString(pickResult.subchannel) + " status: " + ((_a = pickResult.status) === null || _a === undefined ? undefined : _a.code) + " " + ((_b = pickResult.status) === null || _b === undefined ? undefined : _b.details));
16357
+ }
16157
16358
  switch (pickResult.pickResultType) {
16158
16359
  case picker_1.PickResultType.COMPLETE:
16159
- const combinedCallCredentials = this.credentials.compose(pickResult.subchannel.getCallCredentials());
16160
- combinedCallCredentials.generateMetadata({ method_name: this.methodName, service_url: this.serviceUrl }).then((credsMetadata) => {
16360
+ this.generateCallCredentialsMetadata(this.credentials.compose(pickResult.subchannel.getCallCredentials())).then((credsMetadata) => {
16161
16361
  var _a;
16162
16362
  if (this.ended) {
16163
16363
  this.trace("Credentials metadata generation finished after call ended");
16164
16364
  return;
16165
16365
  }
16166
- finalMetadata.merge(credsMetadata);
16366
+ if (credsMetadata) {
16367
+ finalMetadata.merge(credsMetadata);
16368
+ }
16167
16369
  if (finalMetadata.get("authorization").length > 1) {
16168
16370
  this.outputStatus({
16169
16371
  code: constants_1.Status.INTERNAL,
@@ -16172,7 +16374,9 @@ var require_load_balancing_call = __commonJS(function(exports) {
16172
16374
  }, "PROCESSED");
16173
16375
  }
16174
16376
  if (pickResult.subchannel.getConnectivityState() !== connectivity_state_1.ConnectivityState.READY) {
16175
- this.trace("Picked subchannel " + subchannelString + " has state " + connectivity_state_1.ConnectivityState[pickResult.subchannel.getConnectivityState()] + " after getting credentials metadata. Retrying pick");
16377
+ if (this.traceEnabled) {
16378
+ this.trace("Picked subchannel " + this.getSubchannelString(pickResult.subchannel) + " has state " + connectivity_state_1.ConnectivityState[pickResult.subchannel.getConnectivityState()] + " after getting credentials metadata. Retrying pick");
16379
+ }
16176
16380
  this.doPick();
16177
16381
  return;
16178
16382
  }
@@ -16197,10 +16401,12 @@ var require_load_balancing_call = __commonJS(function(exports) {
16197
16401
  this.outputStatus(status, "PROCESSED");
16198
16402
  }
16199
16403
  }
16200
- });
16201
- this.childStartTime = new Date;
16404
+ }, this.callNumber);
16405
+ this.childStartTime = Date.now();
16202
16406
  } catch (error) {
16203
- this.trace("Failed to start call on picked subchannel " + subchannelString + " with error " + error.message);
16407
+ if (this.traceEnabled) {
16408
+ this.trace("Failed to start call on picked subchannel " + this.getSubchannelString(pickResult.subchannel) + " with error " + error.message);
16409
+ }
16204
16410
  this.outputStatus({
16205
16411
  code: constants_1.Status.INTERNAL,
16206
16412
  details: "Failed to start HTTP/2 stream with error " + error.message,
@@ -16210,7 +16416,9 @@ var require_load_balancing_call = __commonJS(function(exports) {
16210
16416
  }
16211
16417
  (_a = pickResult.onCallStarted) === null || _a === undefined || _a.call(pickResult);
16212
16418
  this.onCallEnded = pickResult.onCallEnded;
16213
- this.trace("Created child call [" + this.child.getCallNumber() + "]");
16419
+ if (this.traceEnabled) {
16420
+ this.trace("Created child call [" + this.child.getCallNumber() + "]");
16421
+ }
16214
16422
  if (this.readPending) {
16215
16423
  this.child.startRead();
16216
16424
  }
@@ -16251,7 +16459,9 @@ var require_load_balancing_call = __commonJS(function(exports) {
16251
16459
  }
16252
16460
  cancelWithStatus(status, details) {
16253
16461
  var _a;
16254
- this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"');
16462
+ if (this.traceEnabled) {
16463
+ this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"');
16464
+ }
16255
16465
  (_a = this.child) === null || _a === undefined || _a.cancelWithStatus(status, details);
16256
16466
  this.outputStatus({ code: status, details, metadata: new metadata_1.Metadata }, "PROCESSED");
16257
16467
  }
@@ -16266,7 +16476,9 @@ var require_load_balancing_call = __commonJS(function(exports) {
16266
16476
  this.doPick();
16267
16477
  }
16268
16478
  sendMessageWithContext(context, message) {
16269
- this.trace("write() called with message of length " + message.length);
16479
+ if (this.traceEnabled) {
16480
+ this.trace("write() called with message of length " + message.length);
16481
+ }
16270
16482
  if (this.child) {
16271
16483
  this.child.sendMessageWithContext(context, message);
16272
16484
  } else {
@@ -16335,7 +16547,7 @@ var require_resolving_call = __commonJS(function(exports) {
16335
16547
  this.metadata = null;
16336
16548
  this.listener = null;
16337
16549
  this.statusWatchers = [];
16338
- this.deadlineTimer = setTimeout(() => {}, 0);
16550
+ this.deadlineTimer = null;
16339
16551
  this.filterStack = null;
16340
16552
  this.deadlineStartTime = null;
16341
16553
  this.configReceivedTime = null;
@@ -16350,36 +16562,51 @@ var require_resolving_call = __commonJS(function(exports) {
16350
16562
  });
16351
16563
  }
16352
16564
  if (options.flags & constants_1.Propagate.DEADLINE) {
16353
- this.trace("Propagating deadline from parent: " + options.parentCall.getDeadline());
16565
+ if (this.traceEnabled) {
16566
+ this.trace("Propagating deadline from parent: " + options.parentCall.getDeadline());
16567
+ }
16354
16568
  this.deadline = (0, deadline_1.minDeadline)(this.deadline, options.parentCall.getDeadline());
16355
16569
  }
16356
16570
  }
16357
16571
  this.trace("Created");
16358
16572
  this.runDeadlineTimer();
16359
16573
  }
16574
+ get traceEnabled() {
16575
+ return logging.isTracerEnabled(TRACER_NAME);
16576
+ }
16360
16577
  trace(text) {
16361
- logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text);
16578
+ if (this.traceEnabled) {
16579
+ logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text);
16580
+ }
16362
16581
  }
16363
16582
  runDeadlineTimer() {
16364
- clearTimeout(this.deadlineTimer);
16365
- this.deadlineStartTime = new Date;
16366
- this.trace("Deadline: " + (0, deadline_1.deadlineToString)(this.deadline));
16583
+ if (this.deadlineTimer) {
16584
+ clearTimeout(this.deadlineTimer);
16585
+ this.deadlineTimer = null;
16586
+ }
16587
+ this.deadlineStartTime = Date.now();
16588
+ if (this.traceEnabled) {
16589
+ this.trace("Deadline: " + (0, deadline_1.deadlineToString)(this.deadline));
16590
+ }
16367
16591
  const timeout = (0, deadline_1.getRelativeTimeout)(this.deadline);
16368
16592
  if (timeout !== Infinity) {
16369
- this.trace("Deadline will be reached in " + timeout + "ms");
16593
+ if (this.traceEnabled) {
16594
+ this.trace("Deadline will be reached in " + timeout + "ms");
16595
+ }
16370
16596
  const handleDeadline = () => {
16371
- if (!this.deadlineStartTime) {
16597
+ this.deadlineTimer = null;
16598
+ if (this.deadlineStartTime === null) {
16372
16599
  this.cancelWithStatus(constants_1.Status.DEADLINE_EXCEEDED, "Deadline exceeded");
16373
16600
  return;
16374
16601
  }
16375
16602
  const deadlineInfo = [];
16376
- const deadlineEndTime = new Date;
16603
+ const deadlineEndTime = Date.now();
16377
16604
  deadlineInfo.push(`Deadline exceeded after ${(0, deadline_1.formatDateDifference)(this.deadlineStartTime, deadlineEndTime)}`);
16378
- if (this.configReceivedTime) {
16605
+ if (this.configReceivedTime !== null) {
16379
16606
  if (this.configReceivedTime > this.deadlineStartTime) {
16380
16607
  deadlineInfo.push(`name resolution: ${(0, deadline_1.formatDateDifference)(this.deadlineStartTime, this.configReceivedTime)}`);
16381
16608
  }
16382
- if (this.childStartTime) {
16609
+ if (this.childStartTime !== null) {
16383
16610
  if (this.childStartTime > this.configReceivedTime) {
16384
16611
  deadlineInfo.push(`metadata filters: ${(0, deadline_1.formatDateDifference)(this.configReceivedTime, this.childStartTime)}`);
16385
16612
  }
@@ -16407,9 +16634,14 @@ var require_resolving_call = __commonJS(function(exports) {
16407
16634
  if (!this.filterStack) {
16408
16635
  this.filterStack = this.filterStackFactory.createFilter();
16409
16636
  }
16410
- clearTimeout(this.deadlineTimer);
16637
+ if (this.deadlineTimer) {
16638
+ clearTimeout(this.deadlineTimer);
16639
+ this.deadlineTimer = null;
16640
+ }
16411
16641
  const filteredStatus = this.filterStack.receiveTrailers(status);
16412
- this.trace("ended with status: code=" + filteredStatus.code + ' details="' + filteredStatus.details + '"');
16642
+ if (this.traceEnabled) {
16643
+ this.trace("ended with status: code=" + filteredStatus.code + ' details="' + filteredStatus.details + '"');
16644
+ }
16413
16645
  this.statusWatchers.forEach((watcher) => watcher(filteredStatus));
16414
16646
  process.nextTick(() => {
16415
16647
  var _a;
@@ -16430,7 +16662,8 @@ var require_resolving_call = __commonJS(function(exports) {
16430
16662
  child.halfClose();
16431
16663
  }
16432
16664
  }, (status) => {
16433
- this.cancelWithStatus(status.code, status.details);
16665
+ var _a, _b;
16666
+ this.cancelWithStatus((_a = status.code) !== null && _a !== undefined ? _a : constants_1.Status.INTERNAL, (_b = status.details) !== null && _b !== undefined ? _b : "Failed to write message");
16434
16667
  });
16435
16668
  }
16436
16669
  getConfig() {
@@ -16452,7 +16685,7 @@ var require_resolving_call = __commonJS(function(exports) {
16452
16685
  }
16453
16686
  return;
16454
16687
  }
16455
- this.configReceivedTime = new Date;
16688
+ this.configReceivedTime = Date.now();
16456
16689
  const config = configResult.config;
16457
16690
  if (config.status !== constants_1.Status.OK) {
16458
16691
  const { code, details } = (0, control_plane_status_1.restrictControlPlaneStatusCode)(config.status, "Failed to route call to method " + this.method);
@@ -16464,18 +16697,19 @@ var require_resolving_call = __commonJS(function(exports) {
16464
16697
  return;
16465
16698
  }
16466
16699
  if (config.methodConfig.timeout) {
16467
- const configDeadline = new Date;
16468
- configDeadline.setSeconds(configDeadline.getSeconds() + config.methodConfig.timeout.seconds);
16469
- configDeadline.setMilliseconds(configDeadline.getMilliseconds() + config.methodConfig.timeout.nanos / 1e6);
16700
+ const timeoutMs = Math.floor(config.methodConfig.timeout.seconds * 1000 + config.methodConfig.timeout.nanos / 1e6);
16701
+ const configDeadline = Date.now() + timeoutMs;
16470
16702
  this.deadline = (0, deadline_1.minDeadline)(this.deadline, configDeadline);
16471
16703
  this.runDeadlineTimer();
16472
16704
  }
16473
16705
  this.filterStackFactory.push(config.dynamicFilterFactories);
16474
16706
  this.filterStack = this.filterStackFactory.createFilter();
16475
16707
  this.filterStack.sendMetadata(Promise.resolve(this.metadata)).then((filteredMetadata) => {
16476
- this.child = this.channel.createRetryingCall(config, this.method, this.host, this.credentials, this.deadline);
16477
- this.trace("Created child [" + this.child.getCallNumber() + "]");
16478
- this.childStartTime = new Date;
16708
+ this.child = this.channel.createRetryingCall(config, this.method, this.host, this.credentials, this.deadline, this.callNumber);
16709
+ if (this.traceEnabled) {
16710
+ this.trace("Created child [" + this.child.getCallNumber() + "]");
16711
+ }
16712
+ this.childStartTime = Date.now();
16479
16713
  this.child.start(filteredMetadata, {
16480
16714
  onReceiveMetadata: (metadata) => {
16481
16715
  this.trace("Received metadata");
@@ -16526,7 +16760,9 @@ var require_resolving_call = __commonJS(function(exports) {
16526
16760
  }
16527
16761
  cancelWithStatus(status, details) {
16528
16762
  var _a;
16529
- this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"');
16763
+ if (this.traceEnabled) {
16764
+ this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"');
16765
+ }
16530
16766
  (_a = this.child) === null || _a === undefined || _a.cancelWithStatus(status, details);
16531
16767
  this.outputStatus({
16532
16768
  code: status,
@@ -16545,7 +16781,9 @@ var require_resolving_call = __commonJS(function(exports) {
16545
16781
  this.getConfig();
16546
16782
  }
16547
16783
  sendMessageWithContext(context, message) {
16548
- this.trace("write() called with message of length " + message.length);
16784
+ if (this.traceEnabled) {
16785
+ this.trace("write() called with message of length " + message.length);
16786
+ }
16549
16787
  if (this.child) {
16550
16788
  this.sendMessageOnChild(context, message);
16551
16789
  } else {
@@ -16596,6 +16834,7 @@ var require_retrying_call = __commonJS(function(exports) {
16596
16834
  var deadline_1 = require_deadline();
16597
16835
  var metadata_1 = require_metadata();
16598
16836
  var logging = require_logging();
16837
+ var call_number_1 = require_call_number();
16599
16838
  var TRACER_NAME = "retrying_call";
16600
16839
 
16601
16840
  class RetryThrottler {
@@ -16684,6 +16923,7 @@ var require_retrying_call = __commonJS(function(exports) {
16684
16923
  this.transparentRetryUsed = false;
16685
16924
  this.attempts = 0;
16686
16925
  this.hedgingTimer = null;
16926
+ this.retryTimer = null;
16687
16927
  this.committedCallIndex = null;
16688
16928
  this.initialRetryBackoffSec = 0;
16689
16929
  this.nextRetryBackoffSec = 0;
@@ -16703,7 +16943,7 @@ var require_retrying_call = __commonJS(function(exports) {
16703
16943
  this.state = "TRANSPARENT_ONLY";
16704
16944
  this.maxAttempts = 1;
16705
16945
  }
16706
- this.startTime = new Date;
16946
+ this.startTime = Date.now();
16707
16947
  }
16708
16948
  getDeadlineInfo() {
16709
16949
  if (this.underlyingCalls.length === 0) {
@@ -16723,11 +16963,18 @@ var require_retrying_call = __commonJS(function(exports) {
16723
16963
  getCallNumber() {
16724
16964
  return this.callNumber;
16725
16965
  }
16966
+ get traceEnabled() {
16967
+ return logging.isTracerEnabled(TRACER_NAME);
16968
+ }
16726
16969
  trace(text) {
16727
- logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text);
16970
+ if (this.traceEnabled) {
16971
+ logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text);
16972
+ }
16728
16973
  }
16729
16974
  reportStatus(statusObject) {
16730
- this.trace("ended with status: code=" + statusObject.code + ' details="' + statusObject.details + '" start time=' + this.startTime.toISOString());
16975
+ if (this.traceEnabled) {
16976
+ this.trace("ended with status: code=" + statusObject.code + ' details="' + statusObject.details + '" start time=' + new Date(this.startTime).toISOString());
16977
+ }
16731
16978
  this.bufferTracker.freeAll(this.callNumber);
16732
16979
  this.writeBufferOffset = this.writeBufferOffset + this.writeBuffer.length;
16733
16980
  this.writeBuffer = [];
@@ -16741,7 +16988,18 @@ var require_retrying_call = __commonJS(function(exports) {
16741
16988
  });
16742
16989
  }
16743
16990
  cancelWithStatus(status, details) {
16744
- this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"');
16991
+ if (this.traceEnabled) {
16992
+ this.trace("cancelWithStatus code: " + status + ' details: "' + details + '"');
16993
+ }
16994
+ this.state = "NO_RETRY";
16995
+ if (this.retryTimer) {
16996
+ clearTimeout(this.retryTimer);
16997
+ this.retryTimer = null;
16998
+ }
16999
+ if (this.hedgingTimer) {
17000
+ clearTimeout(this.hedgingTimer);
17001
+ this.hedgingTimer = null;
17002
+ }
16745
17003
  this.reportStatus({ code: status, details, metadata: new metadata_1.Metadata });
16746
17004
  for (const { call } of this.underlyingCalls) {
16747
17005
  call.cancelWithStatus(status, details);
@@ -16788,7 +17046,9 @@ var require_retrying_call = __commonJS(function(exports) {
16788
17046
  if (this.state === "COMMITTED") {
16789
17047
  return;
16790
17048
  }
16791
- this.trace("Committing call [" + this.underlyingCalls[index].call.getCallNumber() + "] at index " + index);
17049
+ if (this.traceEnabled) {
17050
+ this.trace("Committing call [" + this.underlyingCalls[index].call.getCallNumber() + "] at index " + index);
17051
+ }
16792
17052
  this.state = "COMMITTED";
16793
17053
  (_b = (_a = this.callConfig).onCommitted) === null || _b === undefined || _b.call(_a);
16794
17054
  this.committedCallIndex = index;
@@ -16863,8 +17123,9 @@ var require_retrying_call = __commonJS(function(exports) {
16863
17123
  retryDelayMs = pushback;
16864
17124
  this.nextRetryBackoffSec = this.initialRetryBackoffSec;
16865
17125
  }
16866
- setTimeout(() => {
17126
+ this.retryTimer = setTimeout(() => {
16867
17127
  var _a, _b;
17128
+ this.retryTimer = null;
16868
17129
  if (this.state !== "RETRY") {
16869
17130
  callback(false);
16870
17131
  return;
@@ -16955,7 +17216,9 @@ var require_retrying_call = __commonJS(function(exports) {
16955
17216
  if (this.underlyingCalls[callIndex].state === "COMPLETED") {
16956
17217
  return;
16957
17218
  }
16958
- this.trace("state=" + this.state + " handling status with progress " + status.progress + " from child [" + this.underlyingCalls[callIndex].call.getCallNumber() + "] in state " + this.underlyingCalls[callIndex].state);
17219
+ if (this.traceEnabled) {
17220
+ this.trace("state=" + this.state + " handling status with progress " + status.progress + " from child [" + this.underlyingCalls[callIndex].call.getCallNumber() + "] in state " + this.underlyingCalls[callIndex].state);
17221
+ }
16959
17222
  this.underlyingCalls[callIndex].state = "COMPLETED";
16960
17223
  if (status.code === constants_1.Status.OK) {
16961
17224
  (_a = this.retryThrottler) === null || _a === undefined || _a.addCallSucceeded();
@@ -17031,24 +17294,30 @@ var require_retrying_call = __commonJS(function(exports) {
17031
17294
  (_c = (_b = this.hedgingTimer).unref) === null || _c === undefined || _c.call(_b);
17032
17295
  }
17033
17296
  startNewAttempt() {
17034
- const child = this.channel.createLoadBalancingCall(this.callConfig, this.methodName, this.host, this.credentials, this.deadline);
17035
- this.trace("Created child call [" + child.getCallNumber() + "] for attempt " + this.attempts);
17297
+ const childCallNumber = this.underlyingCalls.length > 0 ? (0, call_number_1.getNextCallNumber)() : this.callNumber;
17298
+ const child = this.channel.createLoadBalancingCall(this.callConfig, this.methodName, this.host, this.credentials, this.deadline, childCallNumber);
17299
+ if (this.traceEnabled) {
17300
+ this.trace("Created child call [" + child.getCallNumber() + "] for attempt " + this.attempts);
17301
+ }
17036
17302
  const index = this.underlyingCalls.length;
17037
17303
  this.underlyingCalls.push({
17038
17304
  state: "ACTIVE",
17039
17305
  call: child,
17040
17306
  nextMessageToSend: 0,
17041
- startTime: new Date
17307
+ startTime: Date.now()
17042
17308
  });
17043
17309
  const previousAttempts = this.attempts - 1;
17044
- const initialMetadata = this.initialMetadata.clone();
17310
+ let initialMetadata = this.initialMetadata;
17045
17311
  if (previousAttempts > 0) {
17312
+ initialMetadata = initialMetadata.clone();
17046
17313
  initialMetadata.set(PREVIONS_RPC_ATTEMPTS_METADATA_KEY, `${previousAttempts}`);
17047
17314
  }
17048
17315
  let receivedMetadata = false;
17049
17316
  child.start(initialMetadata, {
17050
17317
  onReceiveMetadata: (metadata) => {
17051
- this.trace("Received metadata from child [" + child.getCallNumber() + "]");
17318
+ if (this.traceEnabled) {
17319
+ this.trace("Received metadata from child [" + child.getCallNumber() + "]");
17320
+ }
17052
17321
  this.commitCall(index);
17053
17322
  receivedMetadata = true;
17054
17323
  if (previousAttempts > 0) {
@@ -17059,14 +17328,18 @@ var require_retrying_call = __commonJS(function(exports) {
17059
17328
  }
17060
17329
  },
17061
17330
  onReceiveMessage: (message) => {
17062
- this.trace("Received message from child [" + child.getCallNumber() + "]");
17331
+ if (this.traceEnabled) {
17332
+ this.trace("Received message from child [" + child.getCallNumber() + "]");
17333
+ }
17063
17334
  this.commitCall(index);
17064
17335
  if (this.underlyingCalls[index].state === "ACTIVE") {
17065
17336
  this.listener.onReceiveMessage(message);
17066
17337
  }
17067
17338
  },
17068
17339
  onReceiveStatus: (status) => {
17069
- this.trace("Received status from child [" + child.getCallNumber() + "]");
17340
+ if (this.traceEnabled) {
17341
+ this.trace("Received status from child [" + child.getCallNumber() + "]");
17342
+ }
17070
17343
  if (!receivedMetadata && previousAttempts > 0) {
17071
17344
  status.metadata.set(PREVIONS_RPC_ATTEMPTS_METADATA_KEY, `${previousAttempts}`);
17072
17345
  }
@@ -17111,7 +17384,9 @@ var require_retrying_call = __commonJS(function(exports) {
17111
17384
  }, bufferEntry.message.message);
17112
17385
  const nextEntry = this.getBufferEntry(messageIndex + 1);
17113
17386
  if (nextEntry.entryType === "HALF_CLOSE") {
17114
- this.trace("Sending halfClose immediately after message to child [" + childCall.call.getCallNumber() + "] - optimizing for unary/final message");
17387
+ if (this.traceEnabled) {
17388
+ this.trace("Sending halfClose immediately after message to child [" + childCall.call.getCallNumber() + "] - optimizing for unary/final message");
17389
+ }
17115
17390
  childCall.nextMessageToSend += 1;
17116
17391
  childCall.call.halfClose();
17117
17392
  }
@@ -17126,7 +17401,9 @@ var require_retrying_call = __commonJS(function(exports) {
17126
17401
  }
17127
17402
  }
17128
17403
  sendMessageWithContext(context, message) {
17129
- this.trace("write() called with message of length " + message.length);
17404
+ if (this.traceEnabled) {
17405
+ this.trace("write() called with message of length " + message.length);
17406
+ }
17130
17407
  const writeObj = {
17131
17408
  message,
17132
17409
  flags: context.flags
@@ -17187,7 +17464,9 @@ var require_retrying_call = __commonJS(function(exports) {
17187
17464
  for (const call of this.underlyingCalls) {
17188
17465
  if ((call === null || call === undefined ? undefined : call.state) === "ACTIVE") {
17189
17466
  if (call.nextMessageToSend === halfCloseIndex || call.nextMessageToSend === halfCloseIndex - 1) {
17190
- this.trace("Sending halfClose immediately to child [" + call.call.getCallNumber() + "] - all messages already sent");
17467
+ if (this.traceEnabled) {
17468
+ this.trace("Sending halfClose immediately to child [" + call.call.getCallNumber() + "] - all messages already sent");
17469
+ }
17191
17470
  call.nextMessageToSend += 1;
17192
17471
  call.call.halfClose();
17193
17472
  }
@@ -17416,7 +17695,7 @@ var require_internal_channel = __commonJS(function(exports) {
17416
17695
  this.connectivityState = connectivity_state_1.ConnectivityState.IDLE;
17417
17696
  this.currentPicker = new picker_1.UnavailablePicker;
17418
17697
  this.configSelectionQueue = [];
17419
- this.pickQueue = [];
17698
+ this.pickQueue = new Set;
17420
17699
  this.connectivityStateWatchers = [];
17421
17700
  this.callRefTimer = null;
17422
17701
  this.configSelector = null;
@@ -17426,6 +17705,7 @@ var require_internal_channel = __commonJS(function(exports) {
17426
17705
  this.idleTimer = null;
17427
17706
  this.channelzEnabled = true;
17428
17707
  this.randomChannelId = Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
17708
+ this.serviceUrlCache = new Map;
17429
17709
  if (typeof target !== "string") {
17430
17710
  throw new TypeError("Channel target must be a string");
17431
17711
  }
@@ -17483,9 +17763,9 @@ var require_internal_channel = __commonJS(function(exports) {
17483
17763
  },
17484
17764
  updateState: (connectivityState, picker) => {
17485
17765
  this.currentPicker = picker;
17486
- const queueCopy = this.pickQueue.slice();
17487
- this.pickQueue = [];
17488
- if (queueCopy.length > 0) {
17766
+ const queueCopy = this.pickQueue;
17767
+ this.pickQueue = new Set;
17768
+ if (queueCopy.size > 0) {
17489
17769
  this.callRefTimerUnref();
17490
17770
  }
17491
17771
  for (const call of queueCopy) {
@@ -17552,17 +17832,24 @@ var require_internal_channel = __commonJS(function(exports) {
17552
17832
  this.filterStackFactory = new filter_stack_1.FilterStackFactory([
17553
17833
  new compression_filter_1.CompressionFilterFactory(this, this.options)
17554
17834
  ]);
17555
- this.trace("Channel constructed with options " + JSON.stringify(options, undefined, 2));
17556
- const error = new Error;
17835
+ if (this.traceEnabled) {
17836
+ this.trace("Channel constructed with options " + JSON.stringify(options, undefined, 2));
17837
+ }
17557
17838
  if ((0, logging_1.isTracerEnabled)("channel_stacktrace")) {
17839
+ const error = new Error;
17558
17840
  (0, logging_1.trace)(constants_1.LogVerbosity.DEBUG, "channel_stacktrace", "(" + this.channelzRef.id + ") " + `Channel constructed
17559
17841
  ` + ((_f = error.stack) === null || _f === undefined ? undefined : _f.substring(error.stack.indexOf(`
17560
17842
  `) + 1)));
17561
17843
  }
17562
- this.lastActivityTimestamp = new Date;
17844
+ this.lastActivityTimestamp = Date.now();
17845
+ }
17846
+ get traceEnabled() {
17847
+ return (0, logging_1.isTracerEnabled)("channel");
17563
17848
  }
17564
17849
  trace(text, verbosityOverride) {
17565
- (0, logging_1.trace)(verbosityOverride !== null && verbosityOverride !== undefined ? verbosityOverride : constants_1.LogVerbosity.DEBUG, "channel", "(" + this.channelzRef.id + ") " + (0, uri_parser_1.uriToString)(this.target) + " " + text);
17850
+ if (this.traceEnabled) {
17851
+ (0, logging_1.trace)(verbosityOverride !== null && verbosityOverride !== undefined ? verbosityOverride : constants_1.LogVerbosity.DEBUG, "channel", "(" + this.channelzRef.id + ") " + (0, uri_parser_1.uriToString)(this.target) + " " + text);
17852
+ }
17566
17853
  }
17567
17854
  callRefTimerRef() {
17568
17855
  var _a, _b, _c, _d;
@@ -17570,14 +17857,18 @@ var require_internal_channel = __commonJS(function(exports) {
17570
17857
  this.callRefTimer = setInterval(() => {}, MAX_TIMEOUT_TIME);
17571
17858
  }
17572
17859
  if (!((_b = (_a = this.callRefTimer).hasRef) === null || _b === undefined ? undefined : _b.call(_a))) {
17573
- this.trace("callRefTimer.ref | configSelectionQueue.length=" + this.configSelectionQueue.length + " pickQueue.length=" + this.pickQueue.length);
17860
+ if (this.traceEnabled) {
17861
+ this.trace("callRefTimer.ref | configSelectionQueue.length=" + this.configSelectionQueue.length + " pickQueue.length=" + this.pickQueue.size);
17862
+ }
17574
17863
  (_d = (_c = this.callRefTimer).ref) === null || _d === undefined || _d.call(_c);
17575
17864
  }
17576
17865
  }
17577
17866
  callRefTimerUnref() {
17578
17867
  var _a, _b, _c;
17579
17868
  if (!((_a = this.callRefTimer) === null || _a === undefined ? undefined : _a.hasRef) || this.callRefTimer.hasRef()) {
17580
- this.trace("callRefTimer.unref | configSelectionQueue.length=" + this.configSelectionQueue.length + " pickQueue.length=" + this.pickQueue.length);
17869
+ if (this.traceEnabled) {
17870
+ this.trace("callRefTimer.unref | configSelectionQueue.length=" + this.configSelectionQueue.length + " pickQueue.length=" + this.pickQueue.size);
17871
+ }
17581
17872
  (_c = (_b = this.callRefTimer) === null || _b === undefined ? undefined : _b.unref) === null || _c === undefined || _c.call(_b);
17582
17873
  }
17583
17874
  }
@@ -17629,9 +17920,15 @@ var require_internal_channel = __commonJS(function(exports) {
17629
17920
  });
17630
17921
  }
17631
17922
  queueCallForPick(call) {
17632
- this.pickQueue.push(call);
17923
+ this.pickQueue.add(call);
17633
17924
  this.callRefTimerRef();
17634
17925
  }
17926
+ removeCallFromPickQueue(call) {
17927
+ this.pickQueue.delete(call);
17928
+ if (this.pickQueue.size === 0) {
17929
+ this.callRefTimerUnref();
17930
+ }
17931
+ }
17635
17932
  getConfig(method, metadata) {
17636
17933
  if (this.connectivityState !== connectivity_state_1.ConnectivityState.SHUTDOWN) {
17637
17934
  this.resolvingLoadBalancer.exitIdle();
@@ -17678,8 +17975,8 @@ var require_internal_channel = __commonJS(function(exports) {
17678
17975
  this.startIdleTimeout(this.idleTimeoutMs);
17679
17976
  return;
17680
17977
  }
17681
- const now = new Date;
17682
- const timeSinceLastActivity = now.valueOf() - this.lastActivityTimestamp.valueOf();
17978
+ const now = Date.now();
17979
+ const timeSinceLastActivity = now - this.lastActivityTimestamp;
17683
17980
  if (timeSinceLastActivity >= this.idleTimeoutMs) {
17684
17981
  this.trace("Idle timer triggered after " + this.idleTimeoutMs + "ms of inactivity");
17685
17982
  this.enterIdle();
@@ -17709,22 +18006,49 @@ var require_internal_channel = __commonJS(function(exports) {
17709
18006
  }
17710
18007
  }
17711
18008
  this.callCount -= 1;
17712
- this.lastActivityTimestamp = new Date;
18009
+ this.lastActivityTimestamp = Date.now();
17713
18010
  this.maybeStartIdleTimer();
17714
18011
  }
17715
- createLoadBalancingCall(callConfig, method, host, credentials, deadline) {
17716
- const callNumber = (0, call_number_1.getNextCallNumber)();
17717
- this.trace("createLoadBalancingCall [" + callNumber + '] method="' + method + '"');
17718
- return new load_balancing_call_1.LoadBalancingCall(this, callConfig, method, host, credentials, deadline, callNumber);
18012
+ getServiceUrl(host, methodName) {
18013
+ let methodMap = this.serviceUrlCache.get(host);
18014
+ if (methodMap === undefined) {
18015
+ if (this.serviceUrlCache.size < InternalChannel.MAX_CACHED_HOSTS) {
18016
+ methodMap = new Map;
18017
+ this.serviceUrlCache.set(host, methodMap);
18018
+ }
18019
+ }
18020
+ if (methodMap !== undefined) {
18021
+ const serviceUrl = methodMap.get(methodName);
18022
+ if (serviceUrl !== undefined) {
18023
+ return serviceUrl;
18024
+ }
18025
+ const computedServiceUrl = (0, uri_parser_1.computeServiceUrl)(host, methodName);
18026
+ if (methodMap.size < InternalChannel.MAX_METHODS_PER_HOST) {
18027
+ methodMap.set(methodName, computedServiceUrl);
18028
+ }
18029
+ return computedServiceUrl;
18030
+ }
18031
+ return (0, uri_parser_1.computeServiceUrl)(host, methodName);
17719
18032
  }
17720
- createRetryingCall(callConfig, method, host, credentials, deadline) {
17721
- const callNumber = (0, call_number_1.getNextCallNumber)();
17722
- this.trace("createRetryingCall [" + callNumber + '] method="' + method + '"');
17723
- return new retrying_call_1.RetryingCall(this, callConfig, method, host, credentials, deadline, callNumber, this.retryBufferTracker, RETRY_THROTTLER_MAP.get(this.getTarget()));
18033
+ createLoadBalancingCall(callConfig, method, host, credentials, deadline, callNumber) {
18034
+ const finalCallNumber = callNumber !== null && callNumber !== undefined ? callNumber : (0, call_number_1.getNextCallNumber)();
18035
+ if (this.traceEnabled) {
18036
+ this.trace("createLoadBalancingCall [" + finalCallNumber + '] method="' + method + '"');
18037
+ }
18038
+ return new load_balancing_call_1.LoadBalancingCall(this, callConfig, method, host, credentials, deadline, finalCallNumber);
18039
+ }
18040
+ createRetryingCall(callConfig, method, host, credentials, deadline, callNumber) {
18041
+ const finalCallNumber = callNumber !== null && callNumber !== undefined ? callNumber : (0, call_number_1.getNextCallNumber)();
18042
+ if (this.traceEnabled) {
18043
+ this.trace("createRetryingCall [" + finalCallNumber + '] method="' + method + '"');
18044
+ }
18045
+ return new retrying_call_1.RetryingCall(this, callConfig, method, host, credentials, deadline, finalCallNumber, this.retryBufferTracker, RETRY_THROTTLER_MAP.get(this.getTarget()));
17724
18046
  }
17725
18047
  createResolvingCall(method, deadline, host, parentCall, propagateFlags) {
17726
18048
  const callNumber = (0, call_number_1.getNextCallNumber)();
17727
- this.trace("createResolvingCall [" + callNumber + '] method="' + method + '", deadline=' + (0, deadline_1.deadlineToString)(deadline));
18049
+ if (this.traceEnabled) {
18050
+ this.trace("createResolvingCall [" + callNumber + '] method="' + method + '", deadline=' + (0, deadline_1.deadlineToString)(deadline));
18051
+ }
17728
18052
  const finalOptions = {
17729
18053
  deadline,
17730
18054
  flags: propagateFlags !== null && propagateFlags !== undefined ? propagateFlags : constants_1.Propagate.DEFAULTS,
@@ -17750,7 +18074,7 @@ var require_internal_channel = __commonJS(function(exports) {
17750
18074
  for (const call of this.pickQueue) {
17751
18075
  call.cancelWithStatus(constants_1.Status.UNAVAILABLE, "Channel closed before call started");
17752
18076
  }
17753
- this.pickQueue = [];
18077
+ this.pickQueue.clear();
17754
18078
  if (this.callRefTimer) {
17755
18079
  clearInterval(this.callRefTimer);
17756
18080
  }
@@ -17763,6 +18087,7 @@ var require_internal_channel = __commonJS(function(exports) {
17763
18087
  this.subchannelPool.unrefUnusedSubchannels();
17764
18088
  (_a = this.configSelector) === null || _a === undefined || _a.unref();
17765
18089
  this.configSelector = null;
18090
+ this.serviceUrlCache.clear();
17766
18091
  }
17767
18092
  getTarget() {
17768
18093
  return (0, uri_parser_1.uriToString)(this.target);
@@ -17771,7 +18096,7 @@ var require_internal_channel = __commonJS(function(exports) {
17771
18096
  const connectivityState = this.connectivityState;
17772
18097
  if (tryToConnect) {
17773
18098
  this.resolvingLoadBalancer.exitIdle();
17774
- this.lastActivityTimestamp = new Date;
18099
+ this.lastActivityTimestamp = Date.now();
17775
18100
  this.maybeStartIdleTimer();
17776
18101
  }
17777
18102
  return connectivityState;
@@ -17820,6 +18145,8 @@ var require_internal_channel = __commonJS(function(exports) {
17820
18145
  }
17821
18146
  }
17822
18147
  exports.InternalChannel = InternalChannel;
18148
+ InternalChannel.MAX_CACHED_HOSTS = 5;
18149
+ InternalChannel.MAX_METHODS_PER_HOST = 100;
17823
18150
  });
17824
18151
 
17825
18152
  // node_modules/@grpc/grpc-js/build/src/channel.js
@@ -18702,6 +19029,7 @@ var require_server_interceptors = __commonJS(function(exports) {
18702
19029
  var logging = require_logging();
18703
19030
  var tls_1 = __require("tls");
18704
19031
  var orca_1 = require_orca();
19032
+ var environment_1 = require_environment();
18705
19033
  var TRACER_NAME = "server_call";
18706
19034
  function trace(text) {
18707
19035
  logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text);
@@ -19031,7 +19359,6 @@ var require_server_interceptors = __commonJS(function(exports) {
19031
19359
  this.receivedHalfClose = false;
19032
19360
  this.streamEnded = false;
19033
19361
  this.metricsRecorder = new orca_1.PerRequestMetricRecorder;
19034
- this.stream.once("error", (err) => {});
19035
19362
  this.stream.once("close", () => {
19036
19363
  var _a;
19037
19364
  trace("Request to method " + ((_a = this.handler) === null || _a === undefined ? undefined : _a.path) + " stream closed with rstCode " + this.stream.rstCode);
@@ -19103,8 +19430,7 @@ var require_server_interceptors = __commonJS(function(exports) {
19103
19430
  return;
19104
19431
  }
19105
19432
  const timeout = +match[1] * deadlineUnitsToMs[match[2]] | 0;
19106
- const now = new Date;
19107
- this.deadline = now.setMilliseconds(now.getMilliseconds() + timeout);
19433
+ this.deadline = Date.now() + timeout;
19108
19434
  this.deadlineTimer = setTimeout(() => {
19109
19435
  const status = {
19110
19436
  code: constants_1.Status.DEADLINE_EXCEEDED,
@@ -19164,6 +19490,12 @@ var require_server_interceptors = __commonJS(function(exports) {
19164
19490
  return new Promise((resolve, reject) => {
19165
19491
  let totalLength = 0;
19166
19492
  const messageParts = [];
19493
+ decompresser.on("error", (error) => {
19494
+ reject({
19495
+ code: constants_1.Status.INTERNAL,
19496
+ details: "Failed to decompress message"
19497
+ });
19498
+ });
19167
19499
  decompresser.on("data", (chunk) => {
19168
19500
  messageParts.push(chunk);
19169
19501
  totalLength += chunk.byteLength;
@@ -19204,9 +19536,15 @@ var require_server_interceptors = __commonJS(function(exports) {
19204
19536
  try {
19205
19537
  queueEntry.parsedMessage = this.handler.deserialize(decompressedMessage);
19206
19538
  } catch (err) {
19539
+ let details;
19540
+ if (environment_1.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) {
19541
+ details = `Error deserializing request: ${err.message}`;
19542
+ } else {
19543
+ details = "Error deserializing request";
19544
+ }
19207
19545
  this.sendStatus({
19208
19546
  code: constants_1.Status.INTERNAL,
19209
- details: `Error deserializing request: ${err.message}`
19547
+ details
19210
19548
  });
19211
19549
  return;
19212
19550
  }
@@ -19286,9 +19624,15 @@ var require_server_interceptors = __commonJS(function(exports) {
19286
19624
  try {
19287
19625
  response = this.serializeMessage(message);
19288
19626
  } catch (e) {
19627
+ let details;
19628
+ if (environment_1.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) {
19629
+ details = `Error serializing response: ${(0, error_1.getErrorMessage)(e)}`;
19630
+ } else {
19631
+ details = "Error serializing response";
19632
+ }
19289
19633
  this.sendStatus({
19290
19634
  code: constants_1.Status.INTERNAL,
19291
- details: `Error serializing response: ${(0, error_1.getErrorMessage)(e)}`,
19635
+ details,
19292
19636
  metadata: null
19293
19637
  });
19294
19638
  return;
@@ -19306,9 +19650,15 @@ var require_server_interceptors = __commonJS(function(exports) {
19306
19650
  this.stream.write(response, (error) => {
19307
19651
  var _a;
19308
19652
  if (error) {
19653
+ let details;
19654
+ if (environment_1.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) {
19655
+ details = `Error writing message: ${(0, error_1.getErrorMessage)(error)}`;
19656
+ } else {
19657
+ details = "Internal server error";
19658
+ }
19309
19659
  this.sendStatus({
19310
19660
  code: constants_1.Status.INTERNAL,
19311
- details: `Error writing message: ${(0, error_1.getErrorMessage)(error)}`,
19661
+ details,
19312
19662
  metadata: null
19313
19663
  });
19314
19664
  return;
@@ -19390,15 +19740,17 @@ var require_server_interceptors = __commonJS(function(exports) {
19390
19740
  }
19391
19741
  getAuthContext() {
19392
19742
  var _a;
19393
- if (((_a = this.stream.session) === null || _a === undefined ? undefined : _a.socket) instanceof tls_1.TLSSocket) {
19394
- const peerCertificate = this.stream.session.socket.getPeerCertificate();
19395
- return {
19396
- transportSecurityType: "ssl",
19397
- sslPeerCertificate: peerCertificate.raw ? peerCertificate : undefined
19398
- };
19399
- } else {
19743
+ if (!(((_a = this.stream.session) === null || _a === undefined ? undefined : _a.socket) instanceof tls_1.TLSSocket)) {
19744
+ return {};
19745
+ }
19746
+ if (!this.stream.session.socket.authorized) {
19400
19747
  return {};
19401
19748
  }
19749
+ const peerCertificate = this.stream.session.socket.getPeerCertificate();
19750
+ return {
19751
+ transportSecurityType: "ssl",
19752
+ sslPeerCertificate: peerCertificate.raw ? peerCertificate : undefined
19753
+ };
19402
19754
  }
19403
19755
  getConnectionInfo() {
19404
19756
  return this.connectionInfo;
@@ -19489,6 +19841,7 @@ var require_server = __commonJS(function(exports) {
19489
19841
  var uri_parser_1 = require_uri_parser();
19490
19842
  var channelz_1 = require_channelz();
19491
19843
  var server_interceptors_1 = require_server_interceptors();
19844
+ var environment_1 = require_environment();
19492
19845
  var UNLIMITED_CONNECTION_AGE_MS = ~(1 << 31);
19493
19846
  var KEEPALIVE_MAX_TIME_MS = ~(1 << 31);
19494
19847
  var KEEPALIVE_TIMEOUT_MS = 20000;
@@ -20236,6 +20589,7 @@ var require_server = __commonJS(function(exports) {
20236
20589
  channelzSessionInfo === null || channelzSessionInfo === undefined || channelzSessionInfo.streamTracker.addCallFailed();
20237
20590
  }
20238
20591
  _channelzHandler(extraInterceptors, stream, headers) {
20592
+ stream.once("error", (err) => {});
20239
20593
  this.onStreamOpened(stream);
20240
20594
  const channelzSessionInfo = this.sessions.get(stream.session);
20241
20595
  this.callTracker.addCallStarted();
@@ -20255,13 +20609,13 @@ var require_server = __commonJS(function(exports) {
20255
20609
  addMessageSent: () => {
20256
20610
  if (channelzSessionInfo) {
20257
20611
  channelzSessionInfo.messagesSent += 1;
20258
- channelzSessionInfo.lastMessageSentTimestamp = new Date;
20612
+ channelzSessionInfo.lastMessageSentTimestamp = Date.now();
20259
20613
  }
20260
20614
  },
20261
20615
  addMessageReceived: () => {
20262
20616
  if (channelzSessionInfo) {
20263
20617
  channelzSessionInfo.messagesReceived += 1;
20264
- channelzSessionInfo.lastMessageReceivedTimestamp = new Date;
20618
+ channelzSessionInfo.lastMessageReceivedTimestamp = Date.now();
20265
20619
  }
20266
20620
  },
20267
20621
  onCallEnd: (status) => {
@@ -20292,6 +20646,7 @@ var require_server = __commonJS(function(exports) {
20292
20646
  }
20293
20647
  }
20294
20648
  _streamHandler(extraInterceptors, stream, headers) {
20649
+ stream.once("error", (err) => {});
20295
20650
  this.onStreamOpened(stream);
20296
20651
  if (this._verifyContentType(stream, headers) !== true) {
20297
20652
  return;
@@ -20701,9 +21056,15 @@ var require_server = __commonJS(function(exports) {
20701
21056
  try {
20702
21057
  handler.func(stream, respond);
20703
21058
  } catch (err) {
21059
+ let details;
21060
+ if (environment_1.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) {
21061
+ details = `Server method handler threw error ${err.message}`;
21062
+ } else {
21063
+ details = "Unknown error";
21064
+ }
20704
21065
  call.sendStatus({
20705
21066
  code: constants_1.Status.UNKNOWN,
20706
- details: `Server method handler threw error ${err.message}`,
21067
+ details,
20707
21068
  metadata: null
20708
21069
  });
20709
21070
  }
@@ -20737,9 +21098,15 @@ var require_server = __commonJS(function(exports) {
20737
21098
  try {
20738
21099
  handler.func(stream, respond);
20739
21100
  } catch (err) {
21101
+ let details;
21102
+ if (environment_1.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) {
21103
+ details = `Server method handler threw error ${err.message}`;
21104
+ } else {
21105
+ details = "Unknown error";
21106
+ }
20740
21107
  call.sendStatus({
20741
21108
  code: constants_1.Status.UNKNOWN,
20742
- details: `Server method handler threw error ${err.message}`,
21109
+ details,
20743
21110
  metadata: null
20744
21111
  });
20745
21112
  }
@@ -20793,9 +21160,15 @@ var require_server = __commonJS(function(exports) {
20793
21160
  try {
20794
21161
  handler.func(stream);
20795
21162
  } catch (err) {
21163
+ let details;
21164
+ if (environment_1.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) {
21165
+ details = `Server method handler threw error ${err.message}`;
21166
+ } else {
21167
+ details = "Unknown error";
21168
+ }
20796
21169
  call.sendStatus({
20797
21170
  code: constants_1.Status.UNKNOWN,
20798
- details: `Server method handler threw error ${err.message}`,
21171
+ details,
20799
21172
  metadata: null
20800
21173
  });
20801
21174
  }
@@ -20817,9 +21190,15 @@ var require_server = __commonJS(function(exports) {
20817
21190
  try {
20818
21191
  handler.func(stream);
20819
21192
  } catch (err) {
21193
+ let details;
21194
+ if (environment_1.GRPC_NODE_DEBUG_SEND_ERROR_DETAILS) {
21195
+ details = `Server method handler threw error ${err.message}`;
21196
+ } else {
21197
+ details = "Unknown error";
21198
+ }
20820
21199
  call.sendStatus({
20821
21200
  code: constants_1.Status.UNKNOWN,
20822
- details: `Server method handler threw error ${err.message}`,
21201
+ details,
20823
21202
  metadata: null
20824
21203
  });
20825
21204
  }