@psnext/slingcli 2.5.20260615-2 → 2.5.20260617-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 (195) hide show
  1. package/node_modules/@aws-sdk/core/dist-cjs/index.js +45 -50
  2. package/node_modules/@aws-sdk/core/dist-cjs/submodules/account-id-endpoint/index.js +2 -4
  3. package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.browser.js +21 -22
  4. package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.js +51 -51
  5. package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.native.js +21 -22
  6. package/node_modules/@aws-sdk/core/dist-cjs/submodules/httpAuthSchemes/index.js +19 -21
  7. package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +107 -109
  8. package/node_modules/@aws-sdk/core/dist-cjs/submodules/util/index.js +2 -4
  9. package/node_modules/@aws-sdk/core/package.json +8 -8
  10. package/node_modules/@aws-sdk/credential-provider-env/dist-cjs/index.js +4 -6
  11. package/node_modules/@aws-sdk/credential-provider-env/package.json +6 -6
  12. package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/checkUrl.js +3 -7
  13. package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/fromHttp.browser.js +12 -16
  14. package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/fromHttp.js +16 -21
  15. package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/requestHelpers.js +14 -18
  16. package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/retry-wrapper.js +1 -5
  17. package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/index.browser.js +2 -5
  18. package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/index.js +2 -7
  19. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/dist-cjs/index.js +11 -13
  20. package/node_modules/@aws-sdk/credential-provider-http/node_modules/@smithy/node-http-handler/package.json +7 -7
  21. package/node_modules/@aws-sdk/credential-provider-http/package.json +6 -6
  22. package/node_modules/@aws-sdk/credential-provider-ini/dist-cjs/index.js +47 -41
  23. package/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveProcessCredentials.js +8 -4
  24. package/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveWebIdentityCredentials.js +14 -10
  25. package/node_modules/@aws-sdk/credential-provider-ini/package.json +13 -13
  26. package/node_modules/@aws-sdk/credential-provider-login/dist-cjs/index.js +31 -33
  27. package/node_modules/@aws-sdk/credential-provider-login/package.json +7 -7
  28. package/node_modules/@aws-sdk/credential-provider-node/dist-cjs/index.js +16 -18
  29. package/node_modules/@aws-sdk/credential-provider-node/package.json +11 -11
  30. package/node_modules/@aws-sdk/credential-provider-process/dist-cjs/index.js +11 -13
  31. package/node_modules/@aws-sdk/credential-provider-process/package.json +6 -6
  32. package/node_modules/@aws-sdk/credential-provider-sso/dist-cjs/index.js +22 -24
  33. package/node_modules/@aws-sdk/credential-provider-sso/dist-cjs/loadSso-BGYXHf8s.js +3 -0
  34. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-cjs/index.js +26 -28
  35. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +7 -7
  36. package/node_modules/@aws-sdk/credential-provider-sso/package.json +8 -8
  37. package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/fromTokenFile.js +10 -14
  38. package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/fromWebToken.js +2 -6
  39. package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/index.js +3 -27
  40. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +7 -7
  41. package/node_modules/@aws-sdk/eventstream-handler-node/dist-cjs/index.js +7 -9
  42. package/node_modules/@aws-sdk/eventstream-handler-node/package.json +5 -5
  43. package/node_modules/@aws-sdk/middleware-eventstream/dist-cjs/index.js +3 -5
  44. package/node_modules/@aws-sdk/middleware-eventstream/package.json +5 -5
  45. package/node_modules/@aws-sdk/middleware-websocket/dist-cjs/index.js +16 -18
  46. package/node_modules/@aws-sdk/middleware-websocket/package.json +6 -6
  47. package/node_modules/@aws-sdk/nested-clients/dist-cjs/index.js +0 -1
  48. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +82 -84
  49. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +158 -119
  50. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +80 -82
  51. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +80 -82
  52. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +99 -101
  53. package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/commands/CreateOAuth2TokenCommand.js +4 -1
  54. package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/endpoint/bdd.js +70 -35
  55. package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/endpoint/endpointResolver.js +1 -1
  56. package/node_modules/@aws-sdk/nested-clients/dist-es/submodules/signin/models/enums.js +3 -0
  57. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/endpoint/EndpointParameters.d.ts +1 -0
  58. package/node_modules/@aws-sdk/nested-clients/dist-types/submodules/signin/models/enums.d.ts +12 -0
  59. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/endpoint/EndpointParameters.d.ts +1 -0
  60. package/node_modules/@aws-sdk/nested-clients/dist-types/ts3.4/submodules/signin/models/enums.d.ts +3 -0
  61. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/dist-cjs/index.js +11 -13
  62. package/node_modules/@aws-sdk/nested-clients/node_modules/@smithy/node-http-handler/package.json +7 -7
  63. package/node_modules/@aws-sdk/nested-clients/package.json +9 -8
  64. package/node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/index.js +4 -6
  65. package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +5 -5
  66. package/node_modules/@aws-sdk/types/dist-cjs/index.js +7 -8
  67. package/node_modules/@aws-sdk/types/package.json +4 -4
  68. package/node_modules/@aws-sdk/util-locate-window/dist-cjs/index.js +0 -2
  69. package/node_modules/@aws-sdk/util-locate-window/package.json +4 -4
  70. package/node_modules/@aws-sdk/xml-builder/dist-cjs/index.js +2 -4
  71. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-external/nodable_entities.js +4 -7
  72. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.browser.js +2 -5
  73. package/node_modules/@aws-sdk/xml-builder/dist-cjs/xml-parser.js +7 -10
  74. package/node_modules/@aws-sdk/xml-builder/package.json +4 -4
  75. package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  76. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +21 -57
  77. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +277 -175
  78. package/node_modules/@earendil-works/pi-ai/dist/models.js +4 -1
  79. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +52 -34
  80. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +11 -9
  81. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +7 -4
  82. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare.js +4 -3
  83. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.js +15 -5
  84. package/node_modules/@earendil-works/pi-ai/dist/providers/google.js +2 -1
  85. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js +18 -17
  86. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js +21 -8
  87. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.js +2 -1
  88. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js +8 -7
  89. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js +1 -0
  90. package/node_modules/@earendil-works/pi-ai/dist/stream.js +1 -1
  91. package/node_modules/@earendil-works/pi-ai/dist/utils/node-http-proxy.js +17 -22
  92. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.js +2 -1
  93. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.js +3 -2
  94. package/node_modules/@earendil-works/pi-ai/dist/utils/provider-env.js +44 -0
  95. package/node_modules/@earendil-works/pi-ai/package.json +1 -1
  96. package/node_modules/@earendil-works/pi-coding-agent/dist/bun/restore-sandbox-env.js +4 -0
  97. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.js +1 -1
  98. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js +10 -7
  99. package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.js +8 -1
  100. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/branch-summarization.js +2 -2
  101. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js +10 -10
  102. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/vendor/marked.min.js +75 -3
  103. package/node_modules/@earendil-works/pi-coding-agent/dist/core/http-dispatcher.js +17 -1
  104. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-registry.js +8 -4
  105. package/node_modules/@earendil-works/pi-coding-agent/dist/core/project-trust.js +1 -1
  106. package/node_modules/@earendil-works/pi-coding-agent/dist/core/provider-attribution.js +10 -0
  107. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resolve-config-value.js +19 -19
  108. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.js +2 -0
  109. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js +6 -6
  110. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.js +4 -0
  111. package/node_modules/@earendil-works/pi-coding-agent/dist/main.js +17 -5
  112. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/footer.js +4 -0
  113. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +0 -1
  114. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/session-selector.js +0 -5
  115. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js +6 -6
  116. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/child-process.js +23 -5
  117. package/node_modules/@earendil-works/pi-coding-agent/npm-shrinkwrap.json +17 -17
  118. package/node_modules/@earendil-works/pi-coding-agent/package.json +4 -4
  119. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +5 -1
  120. package/node_modules/@earendil-works/pi-tui/package.json +2 -2
  121. package/node_modules/@smithy/core/dist-cjs/index.js +13 -15
  122. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +29 -31
  123. package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.browser.js +2 -4
  124. package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.js +7 -9
  125. package/node_modules/@smithy/core/dist-cjs/submodules/checksum/index.native.js +3 -5
  126. package/node_modules/@smithy/core/dist-cjs/submodules/client/index.js +22 -23
  127. package/node_modules/@smithy/core/dist-cjs/submodules/config/index.browser.js +10 -11
  128. package/node_modules/@smithy/core/dist-cjs/submodules/config/index.js +38 -39
  129. package/node_modules/@smithy/core/dist-cjs/submodules/config/index.native.js +10 -11
  130. package/node_modules/@smithy/core/dist-cjs/submodules/endpoints/index.browser.js +14 -17
  131. package/node_modules/@smithy/core/dist-cjs/submodules/endpoints/index.js +20 -23
  132. package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.browser.js +9 -11
  133. package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +11 -13
  134. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +59 -60
  135. package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.browser.js +23 -24
  136. package/node_modules/@smithy/core/dist-cjs/submodules/retry/index.js +25 -26
  137. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +5 -7
  138. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.browser.js +4 -6
  139. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +23 -25
  140. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.native.js +4 -6
  141. package/node_modules/@smithy/core/dist-cjs/submodules/transport/index.js +2 -4
  142. package/node_modules/@smithy/core/dist-es/legacy-root-exports/middleware-http-auth-scheme/httpAuthSchemeMiddleware.js +1 -1
  143. package/node_modules/@smithy/core/dist-es/legacy-root-exports/middleware-http-signing/httpSigningMiddleware.js +1 -1
  144. package/node_modules/@smithy/core/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +1 -1
  145. package/node_modules/@smithy/core/dist-es/submodules/endpoints/middleware-endpoint/endpointMiddleware.js +1 -1
  146. package/node_modules/@smithy/core/dist-types/submodules/schema/TypeRegistry.d.ts +1 -1
  147. package/node_modules/@smithy/core/package.json +7 -6
  148. package/node_modules/@smithy/credential-provider-imds/dist-cjs/index.js +23 -24
  149. package/node_modules/@smithy/credential-provider-imds/package.json +6 -6
  150. package/node_modules/@smithy/fetch-http-handler/dist-cjs/index.js +6 -8
  151. package/node_modules/@smithy/fetch-http-handler/package.json +7 -7
  152. package/node_modules/@smithy/signature-v4/dist-cjs/index.js +27 -29
  153. package/node_modules/@smithy/signature-v4/package.json +6 -6
  154. package/node_modules/@smithy/types/dist-cjs/index.js +23 -18
  155. package/node_modules/@smithy/types/package.json +4 -4
  156. package/node_modules/marked/README.md +13 -4
  157. package/node_modules/marked/bin/main.js +16 -14
  158. package/node_modules/marked/bin/marked.js +2 -1
  159. package/node_modules/marked/lib/marked.d.ts +157 -125
  160. package/node_modules/marked/lib/marked.esm.js +67 -2179
  161. package/node_modules/marked/lib/marked.esm.js.map +3 -3
  162. package/node_modules/marked/lib/marked.umd.js +67 -2201
  163. package/node_modules/marked/lib/marked.umd.js.map +3 -3
  164. package/node_modules/marked/man/marked.1 +4 -2
  165. package/node_modules/marked/man/marked.1.md +2 -1
  166. package/node_modules/marked/package.json +27 -35
  167. package/node_modules/undici/docs/docs/api/Client.md +3 -0
  168. package/node_modules/undici/docs/docs/api/Cookies.md +27 -0
  169. package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +1 -0
  170. package/node_modules/undici/lib/core/socks5-client.js +14 -4
  171. package/node_modules/undici/lib/core/socks5-utils.js +18 -4
  172. package/node_modules/undici/lib/dispatcher/agent.js +1 -1
  173. package/node_modules/undici/lib/dispatcher/balanced-pool.js +1 -1
  174. package/node_modules/undici/lib/dispatcher/client-h1.js +69 -1
  175. package/node_modules/undici/lib/dispatcher/client.js +3 -2
  176. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +19 -0
  177. package/node_modules/undici/lib/dispatcher/pool.js +1 -1
  178. package/node_modules/undici/lib/dispatcher/proxy-agent.js +2 -1
  179. package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +45 -34
  180. package/node_modules/undici/lib/util/cache.js +8 -2
  181. package/node_modules/undici/lib/web/cookies/parse.js +17 -25
  182. package/node_modules/undici/lib/web/websocket/permessage-deflate.js +13 -31
  183. package/node_modules/undici/lib/web/websocket/receiver.js +80 -23
  184. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -1
  185. package/node_modules/undici/lib/web/websocket/websocket.js +8 -1
  186. package/node_modules/undici/package.json +1 -1
  187. package/node_modules/undici/types/client.d.ts +16 -0
  188. package/package.json +6 -6
  189. package/slingshot/index.js +253 -253
  190. package/node_modules/@aws-sdk/credential-provider-sso/dist-cjs/loadSso-BKDNrsal.js +0 -8
  191. package/node_modules/marked/lib/marked.cjs +0 -2211
  192. package/node_modules/marked/lib/marked.cjs.map +0 -7
  193. package/node_modules/marked/lib/marked.d.cts +0 -728
  194. package/node_modules/marked/marked.min.js +0 -69
  195. /package/node_modules/marked/{LICENSE.md → LICENSE} +0 -0
@@ -1,12 +1,11 @@
1
1
  'use strict'
2
2
 
3
- const net = require('node:net')
4
3
  const { URL } = require('node:url')
5
4
 
6
5
  let tls // include tls conditionally since it is not always available
7
6
  const DispatcherBase = require('./dispatcher-base')
8
7
  const { InvalidArgumentError } = require('../core/errors')
9
- const { Socks5Client } = require('../core/socks5-client')
8
+ const { Socks5Client, STATES } = require('../core/socks5-client')
10
9
  const { kDispatch, kClose, kDestroy } = require('../core/symbols')
11
10
  const Pool = require('./pool')
12
11
  const buildConnector = require('../core/connect')
@@ -17,8 +16,10 @@ const debug = debuglog('undici:socks5-proxy')
17
16
  const kProxyUrl = Symbol('proxy url')
18
17
  const kProxyHeaders = Symbol('proxy headers')
19
18
  const kProxyAuth = Symbol('proxy auth')
20
- const kPool = Symbol('pool')
19
+ const kProxyProtocol = Symbol('proxy protocol')
20
+ const kPools = Symbol('pools')
21
21
  const kConnector = Symbol('connector')
22
+ const kRequestTls = Symbol('request tls settings')
22
23
 
23
24
  // Static flag to ensure warning is only emitted once per process
24
25
  let experimentalWarningEmitted = false
@@ -52,6 +53,8 @@ class Socks5ProxyAgent extends DispatcherBase {
52
53
 
53
54
  this[kProxyUrl] = url
54
55
  this[kProxyHeaders] = options.headers || {}
56
+ this[kProxyProtocol] = options.proxyTls ? 'https:' : 'http:'
57
+ this[kRequestTls] = options.requestTls
55
58
 
56
59
  // Extract auth from URL or options
57
60
  this[kProxyAuth] = {
@@ -65,8 +68,8 @@ class Socks5ProxyAgent extends DispatcherBase {
65
68
  servername: options.proxyTls?.servername || url.hostname
66
69
  })
67
70
 
68
- // Pool for the actual HTTP connections (with SOCKS5 tunnel connect function)
69
- this[kPool] = null
71
+ // Pools for the actual HTTP connections (with SOCKS5 tunnel connect function), keyed by origin
72
+ this[kPools] = new Map()
70
73
  }
71
74
 
72
75
  /**
@@ -80,23 +83,18 @@ class Socks5ProxyAgent extends DispatcherBase {
80
83
 
81
84
  // Connect to the SOCKS5 proxy
82
85
  const socket = await new Promise((resolve, reject) => {
83
- const onConnect = () => {
84
- socket.removeListener('error', onError)
85
- resolve(socket)
86
- }
87
-
88
- const onError = (err) => {
89
- socket.removeListener('connect', onConnect)
90
- reject(err)
91
- }
92
-
93
- const socket = net.connect({
86
+ this[kConnector]({
87
+ hostname: proxyHost,
94
88
  host: proxyHost,
95
- port: proxyPort
89
+ port: proxyPort,
90
+ protocol: this[kProxyProtocol]
91
+ }, (err, socket) => {
92
+ if (err) {
93
+ reject(err)
94
+ } else {
95
+ resolve(socket)
96
+ }
96
97
  })
97
-
98
- socket.once('connect', onConnect)
99
- socket.once('error', onError)
100
98
  })
101
99
 
102
100
  // Create SOCKS5 client
@@ -130,7 +128,7 @@ class Socks5ProxyAgent extends DispatcherBase {
130
128
  }
131
129
 
132
130
  // Check if already authenticated (for NO_AUTH method)
133
- if (socks5Client.state === 'authenticated') {
131
+ if (socks5Client.state === STATES.AUTHENTICATED) {
134
132
  clearTimeout(timeout)
135
133
  resolve()
136
134
  } else {
@@ -171,15 +169,17 @@ class Socks5ProxyAgent extends DispatcherBase {
171
169
  /**
172
170
  * Dispatch a request through the SOCKS5 proxy
173
171
  */
174
- async [kDispatch] (opts, handler) {
172
+ [kDispatch] (opts, handler) {
175
173
  const { origin } = opts
176
174
 
177
175
  debug('dispatching request to', origin, 'via SOCKS5')
178
176
 
179
177
  try {
180
- // Create Pool with custom connect function if we don't have one yet
181
- if (!this[kPool] || this[kPool].destroyed || this[kPool].closed) {
182
- this[kPool] = new Pool(origin, {
178
+ const originKey = String(origin)
179
+ let pool = this[kPools].get(originKey)
180
+ // Create a Pool per origin so requests are not routed to the wrong host
181
+ if (!pool || pool.destroyed || pool.closed) {
182
+ pool = new Pool(origin, {
183
183
  pipelining: opts.pipelining,
184
184
  connections: opts.connections,
185
185
  connect: async (connectOpts, callback) => {
@@ -201,9 +201,9 @@ class Socks5ProxyAgent extends DispatcherBase {
201
201
  }
202
202
  debug('upgrading to TLS')
203
203
  finalSocket = tls.connect({
204
+ ...this[kRequestTls],
204
205
  socket,
205
- servername: targetHost,
206
- ...connectOpts.tls || {}
206
+ servername: this[kRequestTls]?.servername || targetHost
207
207
  })
208
208
 
209
209
  await new Promise((resolve, reject) => {
@@ -219,14 +219,19 @@ class Socks5ProxyAgent extends DispatcherBase {
219
219
  }
220
220
  }
221
221
  })
222
+ this[kPools].set(originKey, pool)
222
223
  }
223
224
 
224
- // Dispatch the request through the pool
225
- return this[kPool][kDispatch](opts, handler)
225
+ // Dispatch the request through the per-origin pool
226
+ return pool[kDispatch](opts, handler)
226
227
  } catch (err) {
227
228
  debug('dispatch error:', err)
228
- if (typeof handler.onError === 'function') {
229
+ if (typeof handler.onResponseError === 'function') {
230
+ handler.onResponseError(null, err)
231
+ return false
232
+ } else if (typeof handler.onError === 'function') {
229
233
  handler.onError(err)
234
+ return false
230
235
  } else {
231
236
  throw err
232
237
  }
@@ -234,15 +239,21 @@ class Socks5ProxyAgent extends DispatcherBase {
234
239
  }
235
240
 
236
241
  async [kClose] () {
237
- if (this[kPool]) {
238
- await this[kPool].close()
242
+ const closePromises = []
243
+ for (const pool of this[kPools].values()) {
244
+ closePromises.push(pool.close())
239
245
  }
246
+ this[kPools].clear()
247
+ await Promise.all(closePromises)
240
248
  }
241
249
 
242
250
  async [kDestroy] (err) {
243
- if (this[kPool]) {
244
- await this[kPool].destroy(err)
251
+ const destroyPromises = []
252
+ for (const pool of this[kPools].values()) {
253
+ destroyPromises.push(pool.destroy(err))
245
254
  }
255
+ this[kPools].clear()
256
+ await Promise.all(destroyPromises)
246
257
  }
247
258
  }
248
259
 
@@ -228,6 +228,10 @@ function parseCacheControlHeader (header) {
228
228
  headers[headers.length - 1] = lastHeader
229
229
  }
230
230
 
231
+ for (let j = 0; j < headers.length; j++) {
232
+ headers[j] = headers[j].trim()
233
+ }
234
+
231
235
  if (key in output) {
232
236
  output[key] = output[key].concat(headers)
233
237
  } else {
@@ -236,10 +240,12 @@ function parseCacheControlHeader (header) {
236
240
  }
237
241
  } else {
238
242
  // Something like `no-cache="some-header"`
243
+ const fieldName = value.trim()
244
+
239
245
  if (key in output) {
240
- output[key] = output[key].concat(value)
246
+ output[key] = output[key].concat(fieldName)
241
247
  } else {
242
- output[key] = [value]
248
+ output[key] = [fieldName]
243
249
  }
244
250
  }
245
251
 
@@ -4,7 +4,6 @@ const { collectASequenceOfCodePointsFast } = require('../infra')
4
4
  const { maxNameValuePairSize, maxAttributeValueSize } = require('./constants')
5
5
  const { isCTLExcludingHtab } = require('./util')
6
6
  const assert = require('node:assert')
7
- const { unescape: qsUnescape } = require('node:querystring')
8
7
 
9
8
  /**
10
9
  * @description Parses the field-value attributes of a set-cookie header string.
@@ -82,7 +81,7 @@ function parseSetCookie (header) {
82
81
  // store arbitrary data in a cookie-value SHOULD encode that data, for
83
82
  // example, using Base64 [RFC4648].
84
83
  return {
85
- name, value: qsUnescape(value), ...parseUnparsedAttributes(unparsedAttributes)
84
+ name, value, ...parseUnparsedAttributes(unparsedAttributes)
86
85
  }
87
86
  }
88
87
 
@@ -280,32 +279,25 @@ function parseUnparsedAttributes (unparsedAttributes, cookieAttributeList = {})
280
279
  // If the attribute-name case-insensitively matches the string
281
280
  // "SameSite", the user agent MUST process the cookie-av as follows:
282
281
 
283
- // 1. Let enforcement be "Default".
284
- let enforcement = 'Default'
285
-
286
282
  const attributeValueLowercase = attributeValue.toLowerCase()
287
- // 2. If cookie-av's attribute-value is a case-insensitive match for
288
- // "None", set enforcement to "None".
289
- if (attributeValueLowercase.includes('none')) {
290
- enforcement = 'None'
291
- }
292
283
 
293
- // 3. If cookie-av's attribute-value is a case-insensitive match for
294
- // "Strict", set enforcement to "Strict".
295
- if (attributeValueLowercase.includes('strict')) {
296
- enforcement = 'Strict'
284
+ // 1. If cookie-av's attribute-value is a case-insensitive match for
285
+ // "None", append an attribute to the cookie-attribute-list with an
286
+ // attribute-name of "SameSite" and an attribute-value of "None".
287
+ if (attributeValueLowercase === 'none') {
288
+ cookieAttributeList.sameSite = 'None'
289
+ } else if (attributeValueLowercase === 'strict') {
290
+ // 2. If cookie-av's attribute-value is a case-insensitive match for
291
+ // "Strict", append an attribute to the cookie-attribute-list with
292
+ // an attribute-name of "SameSite" and an attribute-value of
293
+ // "Strict".
294
+ cookieAttributeList.sameSite = 'Strict'
295
+ } else if (attributeValueLowercase === 'lax') {
296
+ // 3. If cookie-av's attribute-value is a case-insensitive match for
297
+ // "Lax", append an attribute to the cookie-attribute-list with an
298
+ // attribute-name of "SameSite" and an attribute-value of "Lax".
299
+ cookieAttributeList.sameSite = 'Lax'
297
300
  }
298
-
299
- // 4. If cookie-av's attribute-value is a case-insensitive match for
300
- // "Lax", set enforcement to "Lax".
301
- if (attributeValueLowercase.includes('lax')) {
302
- enforcement = 'Lax'
303
- }
304
-
305
- // 5. Append an attribute to the cookie-attribute-list with an
306
- // attribute-name of "SameSite" and an attribute-value of
307
- // enforcement.
308
- cookieAttributeList.sameSite = enforcement
309
301
  } else {
310
302
  cookieAttributeList.unparsed ??= []
311
303
 
@@ -8,40 +8,35 @@ const tail = Buffer.from([0x00, 0x00, 0xff, 0xff])
8
8
  const kBuffer = Symbol('kBuffer')
9
9
  const kLength = Symbol('kLength')
10
10
 
11
- // Default maximum decompressed message size: 4 MB
12
- const kDefaultMaxDecompressedSize = 4 * 1024 * 1024
13
-
14
11
  class PerMessageDeflate {
15
12
  /** @type {import('node:zlib').InflateRaw} */
16
13
  #inflate
17
14
 
18
15
  #options = {}
19
16
 
20
- /** @type {boolean} */
21
- #aborted = false
22
-
23
- /** @type {Function|null} */
24
- #currentCallback = null
17
+ #maxPayloadSize = 0
25
18
 
26
19
  /**
27
20
  * @param {Map<string, string>} extensions
28
21
  */
29
- constructor (extensions) {
22
+ constructor (extensions, options) {
30
23
  this.#options.serverNoContextTakeover = extensions.has('server_no_context_takeover')
31
24
  this.#options.serverMaxWindowBits = extensions.get('server_max_window_bits')
25
+
26
+ this.#maxPayloadSize = options.maxPayloadSize
32
27
  }
33
28
 
29
+ /**
30
+ * Decompress a compressed payload.
31
+ * @param {Buffer} chunk Compressed data
32
+ * @param {boolean} fin Final fragment flag
33
+ * @param {Function} callback Callback function
34
+ */
34
35
  decompress (chunk, fin, callback) {
35
36
  // An endpoint uses the following algorithm to decompress a message.
36
37
  // 1. Append 4 octets of 0x00 0x00 0xff 0xff to the tail end of the
37
38
  // payload of the message.
38
39
  // 2. Decompress the resulting data using DEFLATE.
39
-
40
- if (this.#aborted) {
41
- callback(new MessageSizeExceededError())
42
- return
43
- }
44
-
45
40
  if (!this.#inflate) {
46
41
  let windowBits = Z_DEFAULT_WINDOWBITS
47
42
 
@@ -64,23 +59,12 @@ class PerMessageDeflate {
64
59
  this.#inflate[kLength] = 0
65
60
 
66
61
  this.#inflate.on('data', (data) => {
67
- if (this.#aborted) {
68
- return
69
- }
70
-
71
62
  this.#inflate[kLength] += data.length
72
63
 
73
- if (this.#inflate[kLength] > kDefaultMaxDecompressedSize) {
74
- this.#aborted = true
64
+ if (this.#maxPayloadSize > 0 && this.#inflate[kLength] > this.#maxPayloadSize) {
65
+ callback(new MessageSizeExceededError())
75
66
  this.#inflate.removeAllListeners()
76
- this.#inflate.destroy()
77
67
  this.#inflate = null
78
-
79
- if (this.#currentCallback) {
80
- const cb = this.#currentCallback
81
- this.#currentCallback = null
82
- cb(new MessageSizeExceededError())
83
- }
84
68
  return
85
69
  }
86
70
 
@@ -93,14 +77,13 @@ class PerMessageDeflate {
93
77
  })
94
78
  }
95
79
 
96
- this.#currentCallback = callback
97
80
  this.#inflate.write(chunk)
98
81
  if (fin) {
99
82
  this.#inflate.write(tail)
100
83
  }
101
84
 
102
85
  this.#inflate.flush(() => {
103
- if (this.#aborted || !this.#inflate) {
86
+ if (!this.#inflate) {
104
87
  return
105
88
  }
106
89
 
@@ -108,7 +91,6 @@ class PerMessageDeflate {
108
91
 
109
92
  this.#inflate[kBuffer].length = 0
110
93
  this.#inflate[kLength] = 0
111
- this.#currentCallback = null
112
94
 
113
95
  callback(null, full)
114
96
  })
@@ -39,18 +39,27 @@ class ByteParser extends Writable {
39
39
  /** @type {import('./websocket').Handler} */
40
40
  #handler
41
41
 
42
+ /** @type {number} */
43
+ #maxFragments
44
+
45
+ /** @type {number} */
46
+ #maxPayloadSize
47
+
42
48
  /**
43
49
  * @param {import('./websocket').Handler} handler
44
50
  * @param {Map<string, string>|null} extensions
51
+ * @param {{ maxFragments?: number, maxPayloadSize?: number }} [options]
45
52
  */
46
- constructor (handler, extensions) {
53
+ constructor (handler, extensions, options = {}) {
47
54
  super()
48
55
 
49
56
  this.#handler = handler
50
57
  this.#extensions = extensions == null ? new Map() : extensions
58
+ this.#maxFragments = options.maxFragments ?? 0
59
+ this.#maxPayloadSize = options.maxPayloadSize ?? 0
51
60
 
52
61
  if (this.#extensions.has('permessage-deflate')) {
53
- this.#extensions.set('permessage-deflate', new PerMessageDeflate(extensions))
62
+ this.#extensions.set('permessage-deflate', new PerMessageDeflate(extensions, options))
54
63
  }
55
64
  }
56
65
 
@@ -66,6 +75,19 @@ class ByteParser extends Writable {
66
75
  this.run(callback)
67
76
  }
68
77
 
78
+ #validatePayloadLength () {
79
+ if (
80
+ this.#maxPayloadSize > 0 &&
81
+ !isControlFrame(this.#info.opcode) &&
82
+ this.#info.payloadLength + this.#fragmentsBytes > this.#maxPayloadSize
83
+ ) {
84
+ failWebsocketConnection(this.#handler, 1009, 'Payload size exceeds maximum allowed size')
85
+ return false
86
+ }
87
+
88
+ return true
89
+ }
90
+
69
91
  /**
70
92
  * Runs whenever a new chunk is received.
71
93
  * Callback is called whenever there are no more chunks buffering,
@@ -154,6 +176,10 @@ class ByteParser extends Writable {
154
176
  if (payloadLength <= 125) {
155
177
  this.#info.payloadLength = payloadLength
156
178
  this.#state = parserStates.READ_DATA
179
+
180
+ if (!this.#validatePayloadLength()) {
181
+ return
182
+ }
157
183
  } else if (payloadLength === 126) {
158
184
  this.#state = parserStates.PAYLOADLENGTH_16
159
185
  } else if (payloadLength === 127) {
@@ -178,6 +204,10 @@ class ByteParser extends Writable {
178
204
 
179
205
  this.#info.payloadLength = buffer.readUInt16BE(0)
180
206
  this.#state = parserStates.READ_DATA
207
+
208
+ if (!this.#validatePayloadLength()) {
209
+ return
210
+ }
181
211
  } else if (this.#state === parserStates.PAYLOADLENGTH_64) {
182
212
  if (this.#byteOffset < 8) {
183
213
  return callback()
@@ -200,6 +230,10 @@ class ByteParser extends Writable {
200
230
 
201
231
  this.#info.payloadLength = lower
202
232
  this.#state = parserStates.READ_DATA
233
+
234
+ if (!this.#validatePayloadLength()) {
235
+ return
236
+ }
203
237
  } else if (this.#state === parserStates.READ_DATA) {
204
238
  if (this.#byteOffset < this.#info.payloadLength) {
205
239
  return callback()
@@ -212,7 +246,9 @@ class ByteParser extends Writable {
212
246
  this.#state = parserStates.INFO
213
247
  } else {
214
248
  if (!this.#info.compressed) {
215
- this.writeFragments(body)
249
+ if (!this.writeFragments(body)) {
250
+ return
251
+ }
216
252
 
217
253
  // If the frame is not fragmented, a message has been received.
218
254
  // If the frame is fragmented, it will terminate with a fin bit set
@@ -224,29 +260,41 @@ class ByteParser extends Writable {
224
260
 
225
261
  this.#state = parserStates.INFO
226
262
  } else {
227
- this.#extensions.get('permessage-deflate').decompress(body, this.#info.fin, (error, data) => {
228
- if (error) {
229
- // Use 1009 (Message Too Big) for decompression size limit errors
230
- const code = error instanceof MessageSizeExceededError ? 1009 : 1007
231
- failWebsocketConnection(this.#handler, code, error.message)
232
- return
233
- }
234
-
235
- this.writeFragments(data)
263
+ this.#extensions.get('permessage-deflate').decompress(
264
+ body,
265
+ this.#info.fin,
266
+ (error, data) => {
267
+ if (error) {
268
+ const code = error instanceof MessageSizeExceededError ? 1009 : 1007
269
+ failWebsocketConnection(this.#handler, code, error.message)
270
+ return
271
+ }
272
+
273
+ if (!this.writeFragments(data)) {
274
+ return
275
+ }
276
+
277
+ // Check cumulative fragment size
278
+ if (this.#maxPayloadSize > 0 && this.#fragmentsBytes > this.#maxPayloadSize) {
279
+ failWebsocketConnection(this.#handler, 1009, new MessageSizeExceededError().message)
280
+ return
281
+ }
282
+
283
+ if (!this.#info.fin) {
284
+ this.#state = parserStates.INFO
285
+ this.#loop = true
286
+ this.run(callback)
287
+ return
288
+ }
289
+
290
+ websocketMessageReceived(this.#handler, this.#info.binaryType, this.consumeFragments())
236
291
 
237
- if (!this.#info.fin) {
238
- this.#state = parserStates.INFO
239
292
  this.#loop = true
293
+ this.#state = parserStates.INFO
240
294
  this.run(callback)
241
- return
242
- }
243
-
244
- websocketMessageReceived(this.#handler, this.#info.binaryType, this.consumeFragments())
245
-
246
- this.#loop = true
247
- this.#state = parserStates.INFO
248
- this.run(callback)
249
- })
295
+ },
296
+ this.#fragmentsBytes
297
+ )
250
298
 
251
299
  this.#loop = false
252
300
  break
@@ -305,8 +353,17 @@ class ByteParser extends Writable {
305
353
  }
306
354
 
307
355
  writeFragments (fragment) {
356
+ if (
357
+ this.#maxFragments > 0 &&
358
+ this.#fragments.length === this.#maxFragments
359
+ ) {
360
+ failWebsocketConnection(this.#handler, 1008, 'Too many message fragments')
361
+ return false
362
+ }
363
+
308
364
  this.#fragmentsBytes += fragment.length
309
365
  this.#fragments.push(fragment)
366
+ return true
310
367
  }
311
368
 
312
369
  consumeFragments () {
@@ -258,7 +258,14 @@ class WebSocketStream {
258
258
  #onConnectionEstablished (response, parsedExtensions) {
259
259
  this.#handler.socket = response.socket
260
260
 
261
- const parser = new ByteParser(this.#handler, parsedExtensions)
261
+ // Get options from dispatcher options
262
+ const maxFragments = this.#handler.controller.dispatcher?.webSocketOptions?.maxFragments
263
+ const maxPayloadSize = this.#handler.controller.dispatcher?.webSocketOptions?.maxPayloadSize
264
+
265
+ const parser = new ByteParser(this.#handler, parsedExtensions, {
266
+ maxFragments,
267
+ maxPayloadSize
268
+ })
262
269
  parser.on('drain', () => this.#handler.onParserDrain())
263
270
  parser.on('error', (err) => this.#handler.onParserError(err))
264
271
 
@@ -468,7 +468,14 @@ class WebSocket extends EventTarget {
468
468
  // once this happens, the connection is open
469
469
  this.#handler.socket = response.socket
470
470
 
471
- const parser = new ByteParser(this.#handler, parsedExtensions)
471
+ const webSocketOptions = this.#handler.controller.dispatcher?.webSocketOptions
472
+ const maxFragments = webSocketOptions?.maxFragments
473
+ const maxPayloadSize = webSocketOptions?.maxPayloadSize
474
+
475
+ const parser = new ByteParser(this.#handler, parsedExtensions, {
476
+ maxFragments,
477
+ maxPayloadSize
478
+ })
472
479
  parser.on('drain', () => this.#handler.onParserDrain())
473
480
  parser.on('error', (err) => this.#handler.onParserError(err))
474
481
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "undici",
3
- "version": "7.27.2",
3
+ "version": "7.28.0",
4
4
  "description": "An HTTP/1.1 client, written from scratch for Node.js",
5
5
  "homepage": "https://undici.nodejs.org",
6
6
  "bugs": {
@@ -107,6 +107,8 @@ export declare namespace Client {
107
107
  * @default 60000
108
108
  */
109
109
  pingInterval?: number;
110
+ /** WebSocket-specific configuration options. */
111
+ webSocket?: WebSocketOptions;
110
112
  }
111
113
  export interface SocketInfo {
112
114
  localAddress?: string
@@ -118,6 +120,20 @@ export declare namespace Client {
118
120
  bytesWritten?: number
119
121
  bytesRead?: number
120
122
  }
123
+ export interface WebSocketOptions {
124
+ /**
125
+ * Maximum number of fragments in a message. Set to 0 to disable the limit.
126
+ * @default 131072
127
+ */
128
+ maxFragments?: number;
129
+ /**
130
+ * Maximum allowed payload size in bytes for WebSocket messages.
131
+ * Applied to uncompressed messages, compressed frame payloads, and decompressed (permessage-deflate) messages.
132
+ * Set to 0 to disable the limit.
133
+ * @default 134217728 (128 MB)
134
+ */
135
+ maxPayloadSize?: number;
136
+ }
121
137
  }
122
138
 
123
139
  export default Client
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@psnext/slingcli",
3
- "version": "2.5.20260615-2",
3
+ "version": "2.5.20260617-2",
4
4
  "description": "Connects Sling CLI to Publicis Sapient Slingshot enterprise LLM gateway. Bundles the pi coding-agent runtime.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -29,12 +29,12 @@
29
29
  "type": "git",
30
30
  "url": "git+https://pscode.lioncloud.net/psaiproducts/slingcli.git"
31
31
  },
32
- "slingVersion": "2.5.20260615-2",
32
+ "slingVersion": "2.5.20260617-2",
33
33
  "dependencies": {
34
- "@earendil-works/pi-tui": "file:../.sling-pack/earendil-works-pi-tui-0.79.3.tgz",
35
- "@earendil-works/pi-ai": "file:../.sling-pack/earendil-works-pi-ai-0.79.3.tgz",
36
- "@earendil-works/pi-agent-core": "file:../.sling-pack/earendil-works-pi-agent-core-0.79.3.tgz",
37
- "@earendil-works/pi-coding-agent": "file:../.sling-pack/earendil-works-pi-coding-agent-0.79.3.tgz",
34
+ "@earendil-works/pi-tui": "file:../.sling-pack/earendil-works-pi-tui-0.79.6.tgz",
35
+ "@earendil-works/pi-ai": "file:../.sling-pack/earendil-works-pi-ai-0.79.6.tgz",
36
+ "@earendil-works/pi-agent-core": "file:../.sling-pack/earendil-works-pi-agent-core-0.79.6.tgz",
37
+ "@earendil-works/pi-coding-agent": "file:../.sling-pack/earendil-works-pi-coding-agent-0.79.6.tgz",
38
38
  "undici": "^7.19.1",
39
39
  "semver": "^7.6.0"
40
40
  },