@psnext/slingcli 2.4.20260525-4 → 2.4.20260527-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 (243) hide show
  1. package/bin/sling.js +4 -1
  2. package/node_modules/@aws-sdk/core/package.json +2 -2
  3. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  4. package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/fromHttp.js +12 -6
  5. package/node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/fromHttp.js +12 -6
  6. package/node_modules/@aws-sdk/credential-provider-http/package.json +3 -2
  7. package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
  8. package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
  9. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  10. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  11. package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +3 -3
  12. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  13. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  14. package/node_modules/@aws-sdk/middleware-websocket/package.json +2 -2
  15. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
  16. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
  17. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
  18. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
  19. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
  20. package/node_modules/@aws-sdk/nested-clients/package.json +3 -3
  21. package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +1 -2
  22. package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
  23. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +18 -24
  24. package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  25. package/node_modules/@earendil-works/pi-ai/dist/cli.js +14 -0
  26. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +78 -63
  27. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +2 -1
  28. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +8 -22
  29. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +1 -1
  30. package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.js +1 -1
  31. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js +60 -40
  32. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js +1 -1
  33. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js +1 -1
  34. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.js +55 -0
  35. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.js +45 -69
  36. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.js +1 -0
  37. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +5 -2
  38. package/node_modules/@earendil-works/pi-ai/package.json +4 -3
  39. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/file-processor.js +2 -3
  40. package/node_modules/@earendil-works/pi-coding-agent/dist/config.js +18 -12
  41. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-runtime.js +2 -1
  42. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-services.js +3 -2
  43. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js +8 -2
  44. package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.js +2 -1
  45. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js +18 -24
  46. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/index.js +8 -6
  47. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/template.js +6 -3
  48. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.js +12 -29
  49. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-registry.js +5 -1
  50. package/node_modules/@earendil-works/pi-coding-agent/dist/core/output-guard.js +52 -22
  51. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js +63 -36
  52. package/node_modules/@earendil-works/pi-coding-agent/dist/core/prompt-templates.js +6 -20
  53. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.js +38 -31
  54. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.js +9 -4
  55. package/node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.js +32 -24
  56. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.js +6 -13
  57. package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.js +8 -22
  58. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.js +54 -53
  59. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit-diff.js +8 -1
  60. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit.js +44 -81
  61. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/file-mutation-queue.js +27 -12
  62. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/find.js +2 -3
  63. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/grep.js +3 -3
  64. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/ls.js +5 -5
  65. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/output-accumulator.js +9 -3
  66. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/path-utils.js +39 -21
  67. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/read.js +9 -8
  68. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/truncate.js +12 -2
  69. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/write.js +20 -35
  70. package/node_modules/@earendil-works/pi-coding-agent/dist/main.js +5 -6
  71. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.js +1 -1
  72. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/footer.js +14 -5
  73. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +29 -4
  74. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/user-message.js +1 -1
  75. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js +4 -4
  76. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js +37 -28
  77. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-client.js +64 -7
  78. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-mode.js +15 -3
  79. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/clipboard-native.js +14 -8
  80. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-core.js +124 -0
  81. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-worker.js +31 -0
  82. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize.js +75 -115
  83. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/paths.js +33 -7
  84. package/node_modules/@earendil-works/pi-coding-agent/npm-shrinkwrap.json +13 -26
  85. package/node_modules/@earendil-works/pi-coding-agent/package.json +6 -6
  86. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +40 -55
  87. package/node_modules/@earendil-works/pi-tui/dist/components/input.js +2 -2
  88. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +12 -2
  89. package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js +53 -0
  90. package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +4 -1
  91. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +38 -16
  92. package/node_modules/@earendil-works/pi-tui/dist/utils.js +19 -12
  93. package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-arm64/darwin-modifiers.node +0 -0
  94. package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
  95. package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
  96. package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
  97. package/node_modules/@earendil-works/pi-tui/package.json +3 -5
  98. package/node_modules/@smithy/node-http-handler/package.json +2 -2
  99. package/node_modules/undici/lib/api/api-request.js +1 -1
  100. package/node_modules/undici/lib/cache/sqlite-cache-store.js +3 -3
  101. package/node_modules/undici/lib/core/connect.js +16 -0
  102. package/node_modules/undici/lib/core/request.js +17 -2
  103. package/node_modules/undici/lib/core/socks5-client.js +10 -5
  104. package/node_modules/undici/lib/core/socks5-utils.js +17 -22
  105. package/node_modules/undici/lib/dispatcher/client-h1.js +64 -20
  106. package/node_modules/undici/lib/dispatcher/client.js +6 -2
  107. package/node_modules/undici/lib/dispatcher/h2c-client.js +1 -1
  108. package/node_modules/undici/lib/mock/mock-call-history.js +15 -15
  109. package/node_modules/undici/lib/util/cache.js +8 -7
  110. package/node_modules/undici/lib/web/fetch/formdata-parser.js +17 -6
  111. package/node_modules/undici/lib/web/fetch/index.js +5 -2
  112. package/node_modules/undici/lib/web/webidl/index.js +5 -5
  113. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +1 -7
  114. package/node_modules/undici/package.json +1 -1
  115. package/package.json +6 -6
  116. package/slingshot/index.js +269 -266
  117. package/node_modules/koffi/CHANGELOG.md +0 -1093
  118. package/node_modules/koffi/LICENSE.txt +0 -22
  119. package/node_modules/koffi/README.md +0 -43
  120. package/node_modules/koffi/build/koffi/darwin_arm64/koffi.node +0 -0
  121. package/node_modules/koffi/build/koffi/darwin_x64/koffi.node +0 -0
  122. package/node_modules/koffi/build/koffi/freebsd_arm64/koffi.node +0 -0
  123. package/node_modules/koffi/build/koffi/freebsd_ia32/koffi.node +0 -0
  124. package/node_modules/koffi/build/koffi/freebsd_x64/koffi.node +0 -0
  125. package/node_modules/koffi/build/koffi/linux_arm64/koffi.node +0 -0
  126. package/node_modules/koffi/build/koffi/linux_armhf/koffi.node +0 -0
  127. package/node_modules/koffi/build/koffi/linux_ia32/koffi.node +0 -0
  128. package/node_modules/koffi/build/koffi/linux_loong64/koffi.node +0 -0
  129. package/node_modules/koffi/build/koffi/linux_riscv64d/koffi.node +0 -0
  130. package/node_modules/koffi/build/koffi/linux_x64/koffi.node +0 -0
  131. package/node_modules/koffi/build/koffi/musl_arm64/koffi.node +0 -0
  132. package/node_modules/koffi/build/koffi/musl_x64/koffi.node +0 -0
  133. package/node_modules/koffi/build/koffi/openbsd_ia32/koffi.node +0 -0
  134. package/node_modules/koffi/build/koffi/openbsd_x64/koffi.node +0 -0
  135. package/node_modules/koffi/build/koffi/win32_arm64/koffi.exp +0 -0
  136. package/node_modules/koffi/build/koffi/win32_arm64/koffi.lib +0 -0
  137. package/node_modules/koffi/build/koffi/win32_arm64/koffi.node +0 -0
  138. package/node_modules/koffi/build/koffi/win32_ia32/koffi.exp +0 -0
  139. package/node_modules/koffi/build/koffi/win32_ia32/koffi.lib +0 -0
  140. package/node_modules/koffi/build/koffi/win32_ia32/koffi.node +0 -0
  141. package/node_modules/koffi/build/koffi/win32_x64/koffi.exp +0 -0
  142. package/node_modules/koffi/build/koffi/win32_x64/koffi.lib +0 -0
  143. package/node_modules/koffi/build/koffi/win32_x64/koffi.node +0 -0
  144. package/node_modules/koffi/doc/benchmarks.md +0 -126
  145. package/node_modules/koffi/doc/callbacks.md +0 -210
  146. package/node_modules/koffi/doc/contribute.md +0 -148
  147. package/node_modules/koffi/doc/functions.md +0 -250
  148. package/node_modules/koffi/doc/index.md +0 -61
  149. package/node_modules/koffi/doc/input.md +0 -471
  150. package/node_modules/koffi/doc/migration.md +0 -159
  151. package/node_modules/koffi/doc/misc.md +0 -180
  152. package/node_modules/koffi/doc/output.md +0 -305
  153. package/node_modules/koffi/doc/packaging.md +0 -88
  154. package/node_modules/koffi/doc/platforms.md +0 -36
  155. package/node_modules/koffi/doc/pointers.md +0 -328
  156. package/node_modules/koffi/doc/start.md +0 -118
  157. package/node_modules/koffi/doc/unions.md +0 -186
  158. package/node_modules/koffi/doc/variables.md +0 -102
  159. package/node_modules/koffi/index.d.ts +0 -288
  160. package/node_modules/koffi/index.js +0 -634
  161. package/node_modules/koffi/indirect.js +0 -533
  162. package/node_modules/koffi/lib/native/base/base.cc +0 -11015
  163. package/node_modules/koffi/lib/native/base/base.hh +0 -6003
  164. package/node_modules/koffi/lib/native/base/crc.inc +0 -2214
  165. package/node_modules/koffi/lib/native/base/crc_gen.py +0 -72
  166. package/node_modules/koffi/lib/native/base/mimetypes.inc +0 -1248
  167. package/node_modules/koffi/lib/native/base/mimetypes_gen.py +0 -58
  168. package/node_modules/koffi/lib/native/base/tower.cc +0 -821
  169. package/node_modules/koffi/lib/native/base/tower.hh +0 -81
  170. package/node_modules/koffi/lib/native/base/unicode.inc +0 -408
  171. package/node_modules/koffi/lib/native/base/unicode_gen.py +0 -152
  172. package/node_modules/koffi/package.json +0 -38
  173. package/node_modules/koffi/src/cnoke/LICENSE.txt +0 -22
  174. package/node_modules/koffi/src/cnoke/README.md +0 -99
  175. package/node_modules/koffi/src/cnoke/assets/FindCNoke.cmake +0 -127
  176. package/node_modules/koffi/src/cnoke/assets/toolchains.json +0 -126
  177. package/node_modules/koffi/src/cnoke/assets/win_delay_hook.c +0 -36
  178. package/node_modules/koffi/src/cnoke/cnoke.js +0 -170
  179. package/node_modules/koffi/src/cnoke/package.json +0 -24
  180. package/node_modules/koffi/src/cnoke/src/builder.js +0 -511
  181. package/node_modules/koffi/src/cnoke/src/index.js +0 -10
  182. package/node_modules/koffi/src/cnoke/src/tools.js +0 -407
  183. package/node_modules/koffi/src/koffi/CMakeLists.txt +0 -182
  184. package/node_modules/koffi/src/koffi/src/abi_arm32.cc +0 -1018
  185. package/node_modules/koffi/src/koffi/src/abi_arm32_asm.S +0 -169
  186. package/node_modules/koffi/src/koffi/src/abi_arm64.cc +0 -1295
  187. package/node_modules/koffi/src/koffi/src/abi_arm64_asm.S +0 -195
  188. package/node_modules/koffi/src/koffi/src/abi_arm64_asm.asm +0 -174
  189. package/node_modules/koffi/src/koffi/src/abi_loong64.cc +0 -5
  190. package/node_modules/koffi/src/koffi/src/abi_loong64_asm.S +0 -204
  191. package/node_modules/koffi/src/koffi/src/abi_riscv64.cc +0 -915
  192. package/node_modules/koffi/src/koffi/src/abi_riscv64_asm.S +0 -203
  193. package/node_modules/koffi/src/koffi/src/abi_x64_sysv.cc +0 -939
  194. package/node_modules/koffi/src/koffi/src/abi_x64_sysv_asm.S +0 -231
  195. package/node_modules/koffi/src/koffi/src/abi_x64_win.cc +0 -715
  196. package/node_modules/koffi/src/koffi/src/abi_x64_win_asm.S +0 -166
  197. package/node_modules/koffi/src/koffi/src/abi_x64_win_asm.asm +0 -192
  198. package/node_modules/koffi/src/koffi/src/abi_x86.cc +0 -860
  199. package/node_modules/koffi/src/koffi/src/abi_x86_asm.S +0 -193
  200. package/node_modules/koffi/src/koffi/src/abi_x86_asm.asm +0 -177
  201. package/node_modules/koffi/src/koffi/src/call.cc +0 -1326
  202. package/node_modules/koffi/src/koffi/src/call.hh +0 -179
  203. package/node_modules/koffi/src/koffi/src/errno.inc +0 -462
  204. package/node_modules/koffi/src/koffi/src/ffi.cc +0 -2702
  205. package/node_modules/koffi/src/koffi/src/ffi.hh +0 -354
  206. package/node_modules/koffi/src/koffi/src/init.js +0 -105
  207. package/node_modules/koffi/src/koffi/src/parser.cc +0 -220
  208. package/node_modules/koffi/src/koffi/src/parser.hh +0 -54
  209. package/node_modules/koffi/src/koffi/src/util.cc +0 -1807
  210. package/node_modules/koffi/src/koffi/src/util.hh +0 -221
  211. package/node_modules/koffi/src/koffi/src/uv.cc +0 -193
  212. package/node_modules/koffi/src/koffi/src/uv.def +0 -10
  213. package/node_modules/koffi/src/koffi/src/uv.hh +0 -40
  214. package/node_modules/koffi/src/koffi/src/win32.cc +0 -198
  215. package/node_modules/koffi/src/koffi/src/win32.hh +0 -119
  216. package/node_modules/koffi/src/koffi/tools/write_trampolines.js +0 -77
  217. package/node_modules/koffi/vendor/node-addon-api/LICENSE.md +0 -9
  218. package/node_modules/koffi/vendor/node-addon-api/README.md +0 -95
  219. package/node_modules/koffi/vendor/node-addon-api/napi-inl.deprecated.h +0 -186
  220. package/node_modules/koffi/vendor/node-addon-api/napi-inl.h +0 -7033
  221. package/node_modules/koffi/vendor/node-addon-api/napi.h +0 -3309
  222. package/node_modules/koffi/vendor/node-api-headers/LICENSE +0 -21
  223. package/node_modules/koffi/vendor/node-api-headers/README.md +0 -95
  224. package/node_modules/koffi/vendor/node-api-headers/def/js_native_api.def +0 -125
  225. package/node_modules/koffi/vendor/node-api-headers/def/node_api.def +0 -157
  226. package/node_modules/koffi/vendor/node-api-headers/include/js_native_api.h +0 -591
  227. package/node_modules/koffi/vendor/node-api-headers/include/js_native_api_types.h +0 -210
  228. package/node_modules/koffi/vendor/node-api-headers/include/node_api.h +0 -265
  229. package/node_modules/koffi/vendor/node-api-headers/include/node_api_types.h +0 -58
  230. package/node_modules/koffi/vendor/node-api-headers/include/uv/aix.h +0 -32
  231. package/node_modules/koffi/vendor/node-api-headers/include/uv/bsd.h +0 -34
  232. package/node_modules/koffi/vendor/node-api-headers/include/uv/darwin.h +0 -61
  233. package/node_modules/koffi/vendor/node-api-headers/include/uv/errno.h +0 -483
  234. package/node_modules/koffi/vendor/node-api-headers/include/uv/linux.h +0 -34
  235. package/node_modules/koffi/vendor/node-api-headers/include/uv/os390.h +0 -33
  236. package/node_modules/koffi/vendor/node-api-headers/include/uv/posix.h +0 -31
  237. package/node_modules/koffi/vendor/node-api-headers/include/uv/sunos.h +0 -44
  238. package/node_modules/koffi/vendor/node-api-headers/include/uv/threadpool.h +0 -37
  239. package/node_modules/koffi/vendor/node-api-headers/include/uv/tree.h +0 -521
  240. package/node_modules/koffi/vendor/node-api-headers/include/uv/unix.h +0 -512
  241. package/node_modules/koffi/vendor/node-api-headers/include/uv/version.h +0 -43
  242. package/node_modules/koffi/vendor/node-api-headers/include/uv/win.h +0 -698
  243. package/node_modules/koffi/vendor/node-api-headers/include/uv.h +0 -1990
@@ -1,354 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
3
-
4
- #pragma once
5
-
6
- #include "lib/native/base/base.hh"
7
-
8
- #include <napi.h>
9
-
10
- namespace K {
11
-
12
- static const Size DefaultSyncStackSize = Mebibytes(1);
13
- static const Size DefaultSyncHeapSize = Mebibytes(2);
14
- static const Size DefaultAsyncStackSize = Kibibytes(128);
15
- static const Size DefaultAsyncHeapSize = Kibibytes(128);
16
- static const int DefaultResidentAsyncPools = 4;
17
- static const int DefaultMaxAsyncCalls = 256;
18
- static const Size DefaultMaxTypeSize = Mebibytes(64);
19
-
20
- static const int MaxAsyncCalls = 4096;
21
- static const Size MaxParameters = 64;
22
- static const Size MaxTrampolines = 8192;
23
-
24
- enum class PrimitiveKind {
25
- // Void is explictly not first so that it is not 0, for reasons related to N-API type tags.
26
- // Look at TypeInfo definition for more information!
27
- Bool,
28
- Void,
29
- Int8,
30
- UInt8,
31
- Int16,
32
- Int16S, // Keep behind Int16
33
- UInt16,
34
- UInt16S, // Keep behind UInt16
35
- Int32,
36
- Int32S, // Keep behind Int32
37
- UInt32,
38
- UInt32S, // Keep behind UInt32
39
- Int64,
40
- Int64S, // Keep behind Int64
41
- UInt64,
42
- UInt64S, // Keep behind UInt64
43
- String,
44
- String16,
45
- String32,
46
- Pointer,
47
- Record,
48
- Union,
49
- Array,
50
- Float32,
51
- Float64,
52
- Prototype,
53
- Callback
54
- };
55
- static const char *const PrimitiveKindNames[] = {
56
- "Bool",
57
- "Void",
58
- "Int8",
59
- "UInt8",
60
- "Int16",
61
- "Int16S",
62
- "UInt16",
63
- "UInt16S",
64
- "Int32",
65
- "Int32S",
66
- "UInt32",
67
- "UInt32S",
68
- "Int64",
69
- "Int64S",
70
- "UInt64",
71
- "UInt64S",
72
- "String",
73
- "String16",
74
- "String32",
75
- "Pointer",
76
- "Record",
77
- "Union",
78
- "Array",
79
- "Float32",
80
- "Float64",
81
- "Prototype",
82
- "Callback"
83
- };
84
-
85
- struct TypeInfo;
86
- struct RecordMember;
87
- struct FunctionInfo;
88
- struct CallData;
89
-
90
- typedef void DisposeFunc (Napi::Env env, const TypeInfo *type, const void *ptr);
91
-
92
- enum class TypeFlag {
93
- IsIncomplete = 1 << 0,
94
- HasTypedArray = 1 << 1,
95
- IsCharLike = 1 << 2
96
- };
97
-
98
- enum class ArrayHint {
99
- Array,
100
- Typed,
101
- String
102
- };
103
- static const char *const ArrayHintNames[] = {
104
- "Array",
105
- "Typed",
106
- "String"
107
- };
108
-
109
- struct TypeInfo {
110
- const char *name;
111
-
112
- // Make sure primitie ends up as the upper N-API tag value when we cast TypeInfo pointers to
113
- // napi_type_tag pointers. Yes, I want to do this. We don't do strict aliasing here.
114
- // N.B. Some node versions don't like when one of the two tag values is 0, so make sure
115
- // this does not happen! It would happen if primitive is 0 and size is 0. To avoid this
116
- // situation, PrimitiveKind::Void (the only type with size 0) is explictly not 0.
117
- alignas(8) PrimitiveKind primitive;
118
- int32_t size;
119
- int16_t align;
120
- uint16_t flags;
121
-
122
- DisposeFunc *dispose;
123
- Napi::FunctionReference dispose_ref;
124
-
125
- HeapArray<RecordMember> members; // Record only
126
- union {
127
- const void *marker;
128
- const TypeInfo *type; // Pointer or array
129
- const FunctionInfo *proto; // Callback only
130
- } ref;
131
- ArrayHint hint; // Array only
132
- const char *countedby; // Pointer or array
133
-
134
- mutable Napi::FunctionReference construct; // Union only
135
- mutable Napi::ObjectReference defn;
136
-
137
- K_HASHTABLE_HANDLER(TypeInfo, name);
138
- };
139
-
140
- struct RecordMember {
141
- const char *name;
142
- const TypeInfo *type;
143
- int32_t offset;
144
- Size countedby;
145
- };
146
-
147
- struct LibraryHolder {
148
- void *module = nullptr; // HMODULE on Windows
149
- mutable std::atomic_int refcount { 1 };
150
-
151
- LibraryHolder(void *module) : module(module) {}
152
- ~LibraryHolder() { Unload(); }
153
-
154
- void Unload();
155
-
156
- const LibraryHolder *Ref() const;
157
- void Unref() const;
158
- };
159
-
160
- enum class CallConvention {
161
- Cdecl,
162
- Stdcall,
163
- Fastcall,
164
- Thiscall
165
- };
166
- static const char *const CallConventionNames[] = {
167
- "Cdecl",
168
- "Stdcall",
169
- "Fastcall",
170
- "Thiscall"
171
- };
172
-
173
- struct ParameterInfo {
174
- const TypeInfo *type;
175
- int directions;
176
- bool variadic;
177
- int8_t offset;
178
-
179
- // ABI-specific part
180
-
181
- #if defined(_M_X64)
182
- bool regular;
183
- #elif defined(__x86_64__)
184
- bool use_memory;
185
- int8_t gpr_count;
186
- int8_t xmm_count;
187
- bool gpr_first;
188
- #elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64)
189
- bool use_memory; // Only used for return value on ARM32
190
- int8_t gpr_count;
191
- int8_t vec_count;
192
- int8_t vec_bytes; // ARM64
193
- #elif defined(__i386__) || defined(_M_IX86)
194
- bool trivial; // Only matters for return value
195
- int8_t fast;
196
- #elif __riscv_xlen == 64 || defined(__loongarch64)
197
- bool use_memory;
198
- int8_t gpr_count;
199
- int8_t vec_count;
200
- bool gpr_first; // Only for structs
201
- int8_t reg_size[2];
202
- #endif
203
- };
204
-
205
- struct ValueCast {
206
- Napi::Reference<Napi::Value> ref;
207
- const TypeInfo *type;
208
- };
209
-
210
- // Also used for callbacks, even though many members are not used in this case
211
- struct FunctionInfo {
212
- mutable std::atomic_int refcount { 1 };
213
-
214
- const char *name;
215
- const char *decorated_name; // Only set for some platforms/calling conventions
216
- #if defined(_WIN32)
217
- int ordinal_name = -1;
218
- #endif
219
- const LibraryHolder *lib = nullptr;
220
-
221
- void *native;
222
- CallConvention convention;
223
-
224
- ParameterInfo ret;
225
- HeapArray<ParameterInfo> parameters;
226
- int8_t required_parameters;
227
- int8_t out_parameters;
228
- bool variadic;
229
-
230
- // ABI-specific part
231
-
232
- Size args_size;
233
- #if defined(__i386__) || defined(_M_IX86)
234
- bool fast;
235
- #else
236
- bool forward_fp;
237
- #endif
238
-
239
- ~FunctionInfo();
240
-
241
- const FunctionInfo *Ref() const;
242
- void Unref() const;
243
- };
244
-
245
- struct InstanceMemory {
246
- ~InstanceMemory();
247
-
248
- Span<uint8_t> stack;
249
- Span<uint8_t> stack0;
250
- Span<uint8_t> heap;
251
-
252
- bool busy;
253
- bool temporary;
254
- int depth;
255
- };
256
-
257
- struct InstanceData {
258
- ~InstanceData();
259
-
260
- BucketArray<TypeInfo> types;
261
- HashMap<const char *, const TypeInfo *> types_map;
262
- BucketArray<FunctionInfo> callbacks;
263
- Size base_types_count;
264
-
265
- bool debug;
266
-
267
- const TypeInfo *void_type;
268
- const TypeInfo *char_type;
269
- const TypeInfo *char16_type;
270
- const TypeInfo *char32_type;
271
- const TypeInfo *str_type;
272
- const TypeInfo *str16_type;
273
- const TypeInfo *str32_type;
274
-
275
- Napi::Reference<Napi::Symbol> active_symbol;
276
-
277
- std::mutex mem_mutex;
278
- LocalArray<InstanceMemory *, 17> memories;
279
- int temporaries = 0;
280
-
281
- std::thread::id main_thread_id;
282
- napi_threadsafe_function broker = nullptr;
283
-
284
- #if defined(_WIN32)
285
- void *main_stack_max;
286
- void *main_stack_min;
287
-
288
- uint32_t last_error = 0;
289
- #endif
290
-
291
- BucketArray<BlockAllocator> encode_allocators;
292
- HashMap<void *, BlockAllocator *> encode_map;
293
-
294
- HashMap<void *, int16_t> trampolines_map;
295
-
296
- BlockAllocator str_alloc;
297
-
298
- struct {
299
- Size sync_stack_size = DefaultSyncStackSize;
300
- Size sync_heap_size = DefaultSyncHeapSize;
301
- Size async_stack_size = DefaultAsyncStackSize;
302
- Size async_heap_size = DefaultAsyncHeapSize;
303
- int resident_async_pools = DefaultResidentAsyncPools;
304
- int max_temporaries = DefaultMaxAsyncCalls - DefaultResidentAsyncPools;
305
- Size max_type_size = DefaultMaxTypeSize;
306
- } config;
307
-
308
- struct {
309
- int64_t disposed = 0;
310
- } stats;
311
- };
312
- static_assert(DefaultResidentAsyncPools <= K_LEN(InstanceData::memories.data) - 1);
313
- static_assert(DefaultMaxAsyncCalls >= DefaultResidentAsyncPools);
314
- static_assert(MaxAsyncCalls >= DefaultMaxAsyncCalls);
315
-
316
- struct TrampolineInfo {
317
- InstanceData *instance;
318
-
319
- const FunctionInfo *proto;
320
- Napi::FunctionReference func;
321
- Napi::Reference<Napi::Value> recv;
322
-
323
- bool used;
324
- };
325
-
326
- struct SharedData {
327
- std::mutex mutex;
328
-
329
- TrampolineInfo trampolines[MaxTrampolines];
330
- LocalArray<int16_t, MaxTrampolines> available;
331
-
332
- SharedData()
333
- {
334
- available.len = MaxTrampolines;
335
-
336
- for (int16_t i = 0; i < MaxTrampolines; i++) {
337
- available[i] = i;
338
- }
339
- }
340
- };
341
- static_assert(MaxTrampolines <= INT16_MAX);
342
-
343
- extern SharedData shared;
344
-
345
- InstanceMemory *AllocateMemory(InstanceData *instance, Size stack_size, Size heap_size);
346
- void ReleaseMemory(InstanceData *instance, InstanceMemory *mem);
347
-
348
- Napi::Value TranslateNormalCall(const Napi::CallbackInfo &info);
349
- Napi::Value TranslateVariadicCall(const Napi::CallbackInfo &info);
350
- Napi::Value TranslateAsyncCall(const Napi::CallbackInfo &info);
351
-
352
- bool InitAsyncBroker(Napi::Env env, InstanceData *instance);
353
-
354
- }
@@ -1,105 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
3
-
4
- const fs = require('fs');
5
- const path = require('path');
6
- const util = require('util');
7
- const { get_napi_version, determine_arch } = require('../../cnoke/src/tools.js');
8
- const pkg = require('../package.json');
9
-
10
- function detect() {
11
- if (process.versions.napi == null || process.versions.napi < pkg.cnoke.napi) {
12
- let major = parseInt(process.versions.node, 10);
13
- let required = get_napi_version(pkg.cnoke.napi, major);
14
-
15
- if (required != null) {
16
- throw new Error(`This engine is based on Node ${process.versions.node}, but ${pkg.name} requires Node >= ${required} in the Node ${major}.x branch (N-API >= ${pkg.cnoke.napi})`);
17
- } else {
18
- throw new Error(`This engine is based on Node ${process.versions.node}, but ${pkg.name} does not support the Node ${major}.x branch (N-API < ${pkg.cnoke.napi})`);
19
- }
20
- }
21
-
22
- let arch = determine_arch();
23
- let triplet = `${process.platform}_${arch}`;
24
-
25
- return triplet;
26
- }
27
-
28
- function init(triplet, native) {
29
- if (native == null) {
30
- let roots = [path.join(__dirname, '..')];
31
- let triplets = [triplet];
32
-
33
- if (process.resourcesPath != null)
34
- roots.push(process.resourcesPath);
35
- if (triplet.startsWith('linux_')) {
36
- let musl = triplet.replace(/^linux_/, 'musl_');
37
- triplets.push(musl);
38
- }
39
-
40
- let filenames = roots.flatMap(root => triplets.flatMap(triplet => [
41
- `${root}/koffi/build/koffi/${triplet}/koffi.node`,
42
- `${root}/build/koffi/${triplet}/koffi.node`,
43
- `${root}/koffi/${triplet}/koffi.node`,
44
- `${root}/node_modules/koffi/build/koffi/${triplet}/koffi.node`,
45
- `${root}/../../bin/Koffi/${triplet}/koffi.node`
46
- ]));
47
-
48
- let first_err = null;
49
-
50
- for (let filename of filenames) {
51
- if (!fs.existsSync(filename))
52
- continue;
53
-
54
- try {
55
- // Trick so that webpack does not try to do anything with require() call
56
- native = eval('require')(filename);
57
- } catch (err) {
58
- if (first_err == null)
59
- first_err = err;
60
- continue;
61
- }
62
-
63
- break;
64
- }
65
-
66
- if (first_err != null)
67
- throw first_err;
68
- }
69
-
70
- if (native == null)
71
- throw new Error('Cannot find the native Koffi module; did you bundle it correctly?');
72
- if (native.version != pkg.version)
73
- throw new Error('Mismatched native Koffi modules');
74
-
75
- let mod = wrap(native);
76
- return mod;
77
- }
78
-
79
- function wrap(native) {
80
- let obj = {
81
- ...native,
82
-
83
- // Deprecated functions
84
- handle: util.deprecate(native.opaque, 'The koffi.handle() function was deprecated in Koffi 2.1, use koffi.opaque() instead', 'KOFFI001'),
85
- callback: util.deprecate(native.proto, 'The koffi.callback() function was deprecated in Koffi 2.4, use koffi.proto() instead', 'KOFFI002')
86
- };
87
-
88
- obj.load = (...args) => {
89
- let lib = native.load(...args);
90
-
91
- lib.cdecl = util.deprecate((...args) => lib.func('__cdecl', ...args), 'The koffi.cdecl() function was deprecated in Koffi 2.7, use koffi.func(...) instead', 'KOFFI003');
92
- lib.stdcall = util.deprecate((...args) => lib.func('__stdcall', ...args), 'The koffi.stdcall() function was deprecated in Koffi 2.7, use koffi.func("__stdcall", ...) instead', 'KOFFI004');
93
- lib.fastcall = util.deprecate((...args) => lib.func('__fastcall', ...args), 'The koffi.fastcall() function was deprecated in Koffi 2.7, use koffi.func("__fastcall", ...) instead', 'KOFFI005');
94
- lib.thiscall = util.deprecate((...args) => lib.func('__thiscall', ...args), 'The koffi.thiscall() function was deprecated in Koffi 2.7, use koffi.func("__thiscall", ...) instead', 'KOFFI006');
95
-
96
- return lib;
97
- };
98
-
99
- return obj;
100
- }
101
-
102
- module.exports = {
103
- detect,
104
- init
105
- };
@@ -1,220 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- // SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
3
-
4
- #include "lib/native/base/base.hh"
5
- #include "ffi.hh"
6
- #include "parser.hh"
7
-
8
- #include <napi.h>
9
-
10
- namespace K {
11
-
12
- bool PrototypeParser::Parse(const char *str, bool concrete, FunctionInfo *out_func)
13
- {
14
- tokens.Clear();
15
- offset = 0;
16
- valid = true;
17
-
18
- Tokenize(str);
19
-
20
- out_func->ret.type = ParseType(nullptr);
21
- if (!CanReturnType(out_func->ret.type)) {
22
- MarkError("You are not allowed to directly return %1 values (maybe try %1 *)", out_func->ret.type->name);
23
- return false;
24
- }
25
- offset += (offset < tokens.len && DetectCallConvention(tokens[offset], &out_func->convention));
26
-
27
- if (offset >= tokens.len) {
28
- MarkError("Unexpected end of prototype, expected identifier");
29
- return false;
30
- }
31
- if (IsIdentifier(tokens[offset])) {
32
- Span<const char> tok = tokens[offset++];
33
- out_func->name = DuplicateString(tok, &instance->str_alloc).ptr;
34
- } else if (!concrete) {
35
- // Leave anonymous naming responsibility to caller
36
- out_func->name = nullptr;
37
- } else {
38
- MarkError("Unexpected token '%1', expected identifier", tokens[offset]);
39
- return false;
40
- }
41
-
42
- Consume("(");
43
- offset += (offset + 1 < tokens.len && tokens[offset] == "void" && tokens[offset + 1] == ")");
44
- if (offset < tokens.len && tokens[offset] != ")") {
45
- for (;;) {
46
- ParameterInfo param = {};
47
-
48
- if (Match("...")) {
49
- out_func->variadic = true;
50
- break;
51
- }
52
-
53
- param.type = ParseType(&param.directions);
54
-
55
- if (!CanPassType(param.type, param.directions)) {
56
- MarkError("Type %1 cannot be used as a parameter", param.type->name);
57
- return false;
58
- }
59
- if (out_func->parameters.len >= MaxParameters) {
60
- MarkError("Functions cannot have more than %1 parameters", MaxParameters);
61
- return false;
62
- }
63
- if ((param.directions & 2) && ++out_func->out_parameters >= MaxParameters) {
64
- MarkError("Functions cannot have more than out %1 parameters", MaxParameters);
65
- return false;
66
- }
67
-
68
- param.offset = (int8_t)out_func->parameters.len;
69
-
70
- out_func->parameters.Append(param);
71
-
72
- offset += (offset < tokens.len && IsIdentifier(tokens[offset]));
73
- if (offset >= tokens.len || tokens[offset] != ",")
74
- break;
75
- offset++;
76
- }
77
- }
78
- Consume(")");
79
-
80
- out_func->required_parameters = (int8_t)out_func->parameters.len;
81
-
82
- Match(";");
83
- if (offset < tokens.len) {
84
- MarkError("Unexpected token '%1' after prototype", tokens[offset]);
85
- }
86
-
87
- return valid;
88
- }
89
-
90
- void PrototypeParser::Tokenize(const char *str)
91
- {
92
- for (Size i = 0; str[i]; i++) {
93
- char c = str[i];
94
-
95
- if (IsAsciiWhite(c)) {
96
- continue;
97
- } else if (IsXidStart(c)) {
98
- Size j = i;
99
- while (str[++j] && IsXidContinue(str[j]));
100
-
101
- Span<const char> tok = MakeSpan(str + i, j - i);
102
- tokens.Append(tok);
103
-
104
- i = j - 1;
105
- } else if (IsAsciiDigit(c)) {
106
- Size j = i;
107
- while (str[++j] && IsAsciiDigit(str[j]));
108
- if (str[j] == '.') {
109
- while (str[++j] && IsAsciiDigit(str[j]));
110
- }
111
-
112
- Span<const char> tok = MakeSpan(str + i, j - i);
113
- tokens.Append(tok);
114
-
115
- i = j - 1;
116
- } else if (c == '.' && str[i + 1] == '.' && str[i + 2] == '.') {
117
- tokens.Append("...");
118
- i += 2;
119
- } else {
120
- Span<const char> tok = MakeSpan(str + i, 1);
121
- tokens.Append(tok);
122
- }
123
- }
124
- }
125
-
126
- const TypeInfo *PrototypeParser::ParseType(int *out_directions)
127
- {
128
- Size start = offset;
129
-
130
- if (offset >= tokens.len) {
131
- MarkError("Unexpected end of prototype, expected type");
132
- return instance->void_type;
133
- } else if (!IsIdentifier(tokens[offset])) {
134
- MarkError("Unexpected token '%1', expected type", tokens[offset]);
135
- return instance->void_type;
136
- }
137
-
138
- while (++offset < tokens.len && IsIdentifier(tokens[offset]));
139
- offset--;
140
- while (++offset < tokens.len && (tokens[offset] == '*' ||
141
- tokens[offset] == '!' ||
142
- tokens[offset] == "const"));
143
- if (offset < tokens.len && tokens[offset] == "[") [[unlikely]] {
144
- MarkError("Array types decay to pointers in prototypes (C standard), use pointers");
145
- return instance->void_type;
146
- }
147
- offset--;
148
-
149
- if (out_directions) {
150
- if (offset > start) {
151
- int directions = ResolveDirections(tokens[start]);
152
-
153
- if (directions) {
154
- *out_directions = directions;
155
- start++;
156
- } else {
157
- *out_directions = 1;
158
- }
159
- } else {
160
- *out_directions = 1;
161
- }
162
- }
163
-
164
- while (offset >= start) {
165
- Span<const char> str = MakeSpan(tokens[start].ptr, tokens[offset].end() - tokens[start].ptr);
166
- const TypeInfo *type = ResolveType(env, str);
167
-
168
- if (type) {
169
- offset++;
170
- return type;
171
- }
172
- if (env.IsExceptionPending()) [[unlikely]]
173
- return instance->void_type;
174
-
175
- offset--;
176
- }
177
- offset = start;
178
-
179
- MarkError("Unknown or invalid type name '%1'", tokens[offset]);
180
- return instance->void_type;
181
- }
182
-
183
- bool PrototypeParser::Consume(const char *expect)
184
- {
185
- if (offset >= tokens.len) {
186
- MarkError("Unexpected end of prototype, expected '%1'", expect);
187
- return false;
188
- }
189
- if (tokens[offset] != expect) {
190
- MarkError("Unexpected token '%1', expected '%2'", tokens[offset], expect);
191
- return false;
192
- }
193
-
194
- offset++;
195
- return true;
196
- }
197
-
198
- bool PrototypeParser::Match(const char *expect)
199
- {
200
- if (offset < tokens.len && tokens[offset] == expect) {
201
- offset++;
202
- return true;
203
- } else {
204
- return false;
205
- }
206
- }
207
-
208
- bool PrototypeParser::IsIdentifier(Span<const char> tok) const
209
- {
210
- K_ASSERT(tok.len);
211
- return IsAsciiAlpha(tok[0]) || tok[0] == '_';
212
- }
213
-
214
- bool ParsePrototype(Napi::Env env, const char *str, bool concrete, FunctionInfo *out_func)
215
- {
216
- PrototypeParser parser(env);
217
- return parser.Parse(str, concrete, out_func);
218
- }
219
-
220
- }