@mmmbuto/qwen-code-termux 0.16.1-termux → 0.18.0-termux

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 (185) hide show
  1. package/README.md +79 -109
  2. package/bundled/new-app/SKILL.md +22 -0
  3. package/bundled/qc-helper/SKILL.md +29 -24
  4. package/bundled/qc-helper/docs/_meta.ts +1 -0
  5. package/bundled/qc-helper/docs/configuration/_meta.ts +0 -3
  6. package/bundled/qc-helper/docs/configuration/settings.md +37 -31
  7. package/bundled/qc-helper/docs/configuration/themes.md +39 -0
  8. package/bundled/qc-helper/docs/features/_meta.ts +1 -3
  9. package/bundled/qc-helper/docs/features/approval-mode.md +35 -35
  10. package/bundled/qc-helper/docs/features/auto-mode.md +54 -9
  11. package/bundled/qc-helper/docs/features/channels/_meta.ts +1 -0
  12. package/bundled/qc-helper/docs/features/channels/feishu.md +170 -0
  13. package/bundled/qc-helper/docs/features/commands.md +115 -35
  14. package/bundled/qc-helper/docs/features/followup-suggestions.md +2 -2
  15. package/bundled/qc-helper/docs/features/headless.md +32 -0
  16. package/bundled/qc-helper/docs/features/markdown-rendering.md +21 -1
  17. package/bundled/qc-helper/docs/features/memory.md +22 -5
  18. package/bundled/qc-helper/docs/features/scheduled-tasks.md +1 -1
  19. package/bundled/qc-helper/docs/features/status-line.md +168 -32
  20. package/bundled/qc-helper/docs/features/sub-agents.md +60 -0
  21. package/bundled/qc-helper/docs/features/worktree.md +345 -0
  22. package/bundled/qc-helper/docs/overview.md +4 -4
  23. package/bundled/qc-helper/docs/quickstart.md +4 -4
  24. package/bundled/qc-helper/docs/qwen-serve-deploy-local.md +221 -0
  25. package/bundled/qc-helper/docs/qwen-serve.md +234 -24
  26. package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +16 -0
  27. package/bundled/qc-helper/docs/support/Uninstall.md +19 -1
  28. package/bundled/qc-helper/docs/support/troubleshooting.md +2 -1
  29. package/bundled/simplify/SKILL.md +123 -0
  30. package/chunks/agent-IDS4HMOX.js +56 -0
  31. package/chunks/agent-headless-5Q2EUSPS.js +50 -0
  32. package/chunks/{anthropicContentGenerator-SSGKR6DO.js → anthropicContentGenerator-2HBRNQ3B.js} +52 -9
  33. package/chunks/{askUserQuestion-PJWUUXKN.js → askUserQuestion-75TDJVK2.js} +45 -3
  34. package/chunks/{ca-UZ7BANMN.js → ca-BARBRL6N.js} +89 -5
  35. package/chunks/{chunk-GGNTZ2NH.js → chunk-2Y5SYSD3.js} +368 -597
  36. package/chunks/{chunk-2LA2TREA.js → chunk-3AA2DK35.js} +1448 -207
  37. package/chunks/{chunk-I2V5WXHJ.js → chunk-3AUHFMSK.js} +80 -38
  38. package/chunks/chunk-3DHXZ6EV.js +241 -0
  39. package/chunks/{chunk-PR4T27R7.js → chunk-3HTIVKZE.js} +42 -8
  40. package/chunks/chunk-3HX5LZ6R.js +1798 -0
  41. package/chunks/chunk-3PJXIDKI.js +2517 -0
  42. package/chunks/{chunk-MYAKAFEC.js → chunk-55ZMG67I.js} +7451 -3517
  43. package/chunks/{chunk-66CXYE4B.js → chunk-5IFG2VC4.js} +293 -242
  44. package/chunks/chunk-64WXLC72.js +98 -0
  45. package/chunks/{chunk-C6WMLUNB.js → chunk-72LDN5PP.js} +1 -1
  46. package/chunks/{chunk-F23NCRJ2.js → chunk-A7B4ISQP.js} +1 -1
  47. package/chunks/chunk-B7HXHOHU.js +393 -0
  48. package/chunks/{chunk-XEGHDASV.js → chunk-D3RHSPAS.js} +435 -540
  49. package/chunks/{chunk-XKS5KBFJ.js → chunk-EYENRK4D.js} +694 -384
  50. package/chunks/chunk-H6BD2ELD.js +36 -0
  51. package/chunks/{chunk-XP27SJMH.js → chunk-HR7SV7AY.js} +79 -48
  52. package/chunks/{chunk-D5NTAHYL.js → chunk-IDX6COTE.js} +7 -2
  53. package/chunks/{chunk-SHT4VJWU.js → chunk-IWKSG2AR.js} +2 -2
  54. package/chunks/chunk-J37FGIOA.js +1623 -0
  55. package/chunks/chunk-J5MDQKJL.js +2230 -0
  56. package/chunks/{chunk-USE2VQ5P.js → chunk-JTQAQBTV.js} +21 -0
  57. package/chunks/{chunk-NCTLV2NB.js → chunk-KQJMQJPI.js} +1 -1
  58. package/chunks/{chunk-5FBA5XC2.js → chunk-KRIHGKNA.js} +1 -1
  59. package/chunks/chunk-LD2XBG6Z.js +102 -0
  60. package/chunks/{chunk-MAY32HXD.js → chunk-M6VTDSVR.js} +3 -1
  61. package/chunks/chunk-MRO43B25.js +30 -0
  62. package/chunks/{chunk-N4WOREMD.js → chunk-NVFMZBX2.js} +43 -3
  63. package/chunks/chunk-OHEGWO4L.js +264 -0
  64. package/chunks/{chunk-K6O2NBMF.js → chunk-OQ7NJIY7.js} +4604 -6397
  65. package/chunks/chunk-QQDPRDVW.js +25 -0
  66. package/chunks/{chunk-KXZ4TJB4.js → chunk-SEGYWKIH.js} +1 -1
  67. package/chunks/chunk-SKBPNJEW.js +45 -0
  68. package/chunks/{chunk-4AOCVI6J.js → chunk-SNGELLWX.js} +52 -6
  69. package/chunks/{chunk-3OCRHZA3.js → chunk-TD4OPI4T.js} +56742 -44104
  70. package/chunks/{chunk-DQ4QTG7E.js → chunk-VV4F63BD.js} +11 -11
  71. package/chunks/chunk-XBY7E2FX.js +605 -0
  72. package/chunks/{chunk-JKMBWLFB.js → chunk-YILFYI5W.js} +48 -26
  73. package/chunks/chunk-YOGAOMYB.js +159 -0
  74. package/chunks/{chunk-QWSRH265.js → chunk-Z2Z3GUXZ.js} +777 -776
  75. package/chunks/{chunk-SDHRQFOS.js → chunk-ZTZ4DDQE.js} +2 -2
  76. package/chunks/computer-use-W2TYQNEE.js +825 -0
  77. package/chunks/contextCommand-6FGX3A7J.js +52 -0
  78. package/chunks/{cron-create-3ZBBN7WB.js → cron-create-APL5LU6I.js} +3 -3
  79. package/chunks/{cron-delete-NAGKKIIG.js → cron-delete-4SBJSCN4.js} +3 -3
  80. package/chunks/{cron-list-PAGRXNAI.js → cron-list-2AMGOMVO.js} +3 -3
  81. package/chunks/{de-V4IE2OOZ.js → de-YGKK2BC4.js} +89 -5
  82. package/chunks/{devtools-TWVXEJQB.js → devtools-FM6GJPYG.js} +2 -1
  83. package/chunks/{dist-4L54HRX2.js → dist-4LXD6L6X.js} +24 -5
  84. package/chunks/dist-H6ONXVLG.js +94146 -0
  85. package/chunks/{dist-XKWIWPWQ.js → dist-KAZ3SEBX.js} +1083 -3856
  86. package/chunks/{dist-BXDUQ2QY.js → dist-PK7DFCAW.js} +1 -1
  87. package/chunks/{edit-NVO3FOAK.js → edit-ZCEZC264.js} +30 -22
  88. package/chunks/{en-HGJ2SPLM.js → en-DHGYHIHX.js} +127 -6
  89. package/chunks/{enter-worktree-UEBG4WFC.js → enter-worktree-BBHCFCHG.js} +30 -20
  90. package/chunks/enterPlanMode-3M6KTD3B.js +158 -0
  91. package/chunks/{exit-worktree-UZ3MAQZN.js → exit-worktree-73YPIEQO.js} +27 -19
  92. package/chunks/exitPlanMode-TYZM6BAE.js +703 -0
  93. package/chunks/{fr-CJULI7ZX.js → fr-JXBKPJKQ.js} +89 -5
  94. package/chunks/{geminiContentGenerator-3UZFXGNT.js → geminiContentGenerator-7N2V3VW2.js} +8 -6
  95. package/chunks/{getMachineId-bsd-JXOSIJV2.js → getMachineId-bsd-4CASPIU4.js} +4 -4
  96. package/chunks/{getMachineId-darwin-TE4QRR42.js → getMachineId-darwin-HPQPEMZR.js} +4 -4
  97. package/chunks/{getMachineId-linux-S3OL52XK.js → getMachineId-linux-AUARKYHL.js} +3 -3
  98. package/chunks/{getMachineId-unsupported-DWUSBAPX.js → getMachineId-unsupported-S32ZDA2T.js} +3 -3
  99. package/chunks/{getMachineId-win-AAC5P3AP.js → getMachineId-win-4EFLHYIJ.js} +4 -4
  100. package/chunks/{glob-KNHSFFFG.js → glob-5XBCPQ2A.js} +27 -19
  101. package/chunks/{grep-LACWDZW4.js → grep-VIUU3A7X.js} +30 -19
  102. package/chunks/{ja-L7CHRQEW.js → ja-TGPZSP2B.js} +89 -5
  103. package/chunks/{keychain-token-storage-335UOLJ6.js → keychain-token-storage-6IU6ORQN.js} +3 -3
  104. package/chunks/{ls-AGXQOKSG.js → ls-JRGYIGLY.js} +4 -4
  105. package/chunks/{lsp-UDMUHNPA.js → lsp-SHMKFOAC.js} +3 -3
  106. package/chunks/{monitor-ETKWPJEH.js → monitor-6R4LIJL5.js} +40 -25
  107. package/chunks/{multipart-parser-3QWGTLK3.js → multipart-parser-AJ4WASWR.js} +2 -2
  108. package/chunks/{notebook-edit-QJJLPNYT.js → notebook-edit-5E7ULDVQ.js} +28 -20
  109. package/chunks/{openaiContentGenerator-CNNN424U.js → openaiContentGenerator-ZVHFKM3O.js} +17 -14
  110. package/chunks/{pt-M6JULLEQ.js → pt-TIBG6BIO.js} +89 -5
  111. package/chunks/{qwenContentGenerator-BOLCGK3R.js → qwenContentGenerator-B2VTVSPJ.js} +31 -23
  112. package/chunks/{qwenOAuth2-EEJGROP7.js → qwenOAuth2-2KCKWDCF.js} +6 -4
  113. package/chunks/read-file-GIT7BCDR.js +27 -0
  114. package/chunks/ripGrep-MWKFVYMS.js +48 -0
  115. package/chunks/{ru-QILM4HBC.js → ru-JBCHCK4L.js} +89 -5
  116. package/chunks/scheduler-5VOOYGBH.js +308 -0
  117. package/chunks/send-message-4QNWQJF4.js +244 -0
  118. package/chunks/{serve-OLSI7WSR.js → serve-MN6HZBWN.js} +14262 -7414
  119. package/chunks/shell-NQZQGFM2.js +56 -0
  120. package/chunks/{skill-D6YRHTTI.js → skill-WCFW4644.js} +145 -119
  121. package/chunks/{src-TMOD5X6F.js → src-7XL4G4DC.js} +88 -46
  122. package/chunks/{src-4QH4FZ6I.js → src-IHA6DTUV.js} +452 -62
  123. package/chunks/{syntheticOutput-5PVFDDJ4.js → syntheticOutput-YTYS2ZMQ.js} +4 -4
  124. package/chunks/task-create-MPORPYN6.js +19 -0
  125. package/chunks/task-list-R2YDYPZT.js +151 -0
  126. package/chunks/{task-stop-AJKPSR6R.js → task-stop-SYWJYBCM.js} +3 -3
  127. package/chunks/task-update-E4NSLKMQ.js +408 -0
  128. package/chunks/team-create-7R7KA5IP.js +314 -0
  129. package/chunks/team-delete-25OIWUPN.js +116 -0
  130. package/chunks/{todoWrite-VLAUG4CA.js → todoWrite-4YHMIF4X.js} +16 -5
  131. package/chunks/{tool-search-MZGHUUKD.js → tool-search-YBRVZCLI.js} +29 -11
  132. package/chunks/{tts-notification-K3X7X7MN.js → tts-notification-7SOEMQK4.js} +5 -4
  133. package/chunks/{web-fetch-OILB464A.js → web-fetch-MFIRHIHI.js} +5 -5
  134. package/chunks/workflow-5RIKVCIE.js +960 -0
  135. package/chunks/{write-file-BIQAA57V.js → write-file-DMQTJZOM.js} +32 -24
  136. package/chunks/{zh-PWL2NKY3.js → zh-7H5OQC4I.js} +135 -11
  137. package/chunks/{zh-TW-S3YGWICZ.js → zh-TW-P4IDHD3M.js} +128 -11
  138. package/cli.js +45402 -20570
  139. package/examples/agent/agents/diary.md +86 -0
  140. package/examples/agent/qwen-extension.json +5 -0
  141. package/examples/commands/commands/fs/grep-code.md +3 -0
  142. package/examples/commands/qwen-extension.json +5 -0
  143. package/examples/context/QWEN.md +8 -0
  144. package/examples/context/qwen-extension.json +5 -0
  145. package/examples/mcp-server/example.ts +60 -0
  146. package/examples/mcp-server/package.json +18 -0
  147. package/examples/mcp-server/qwen-extension.json +12 -0
  148. package/examples/mcp-server/tsconfig.json +13 -0
  149. package/examples/skills/qwen-extension.json +5 -0
  150. package/examples/skills/skills/synonyms/SKILL.md +48 -0
  151. package/examples/starter/QWEN.md +30 -0
  152. package/examples/starter/README.md +59 -0
  153. package/examples/starter/agents/diary.md +86 -0
  154. package/examples/starter/commands/writing/polish.md +13 -0
  155. package/examples/starter/example.ts +64 -0
  156. package/examples/starter/package.json +18 -0
  157. package/examples/starter/qwen-extension.json +12 -0
  158. package/examples/starter/skills/synonyms/SKILL.md +48 -0
  159. package/examples/starter/tsconfig.json +13 -0
  160. package/fzfWorker.js +1083 -0
  161. package/locales/ca.js +118 -5
  162. package/locales/de.js +117 -5
  163. package/locales/en.js +169 -7
  164. package/locales/fr.js +119 -5
  165. package/locales/ja.js +114 -5
  166. package/locales/pt.js +117 -5
  167. package/locales/ru.js +116 -5
  168. package/locales/zh-TW.js +161 -12
  169. package/locales/zh.js +169 -12
  170. package/package.json +4 -2
  171. package/scripts/postinstall.cjs +2 -1
  172. package/bundled/qc-helper/docs/features/checkpointing.md +0 -77
  173. package/chunks/agent-7ZN3CRHR.js +0 -48
  174. package/chunks/chunk-6PCB2DEF.js +0 -434
  175. package/chunks/chunk-EM6ETG2K.js +0 -60
  176. package/chunks/chunk-G7YTSRES.js +0 -150
  177. package/chunks/contextCommand-7IBASARL.js +0 -44
  178. package/chunks/exitPlanMode-PZAMWIRW.js +0 -227
  179. package/chunks/multipart-parser-IXGBIOIN.js +0 -384
  180. package/chunks/read-file-CCUEUFG2.js +0 -24
  181. package/chunks/ripGrep-TADOH2HK.js +0 -40
  182. package/chunks/send-message-YL44UZFC.js +0 -151
  183. package/chunks/shell-7KKKC5G7.js +0 -48
  184. package/chunks/src-IPWIHNMI.js +0 -1406
  185. package/chunks/undici-F6ZOXSS5.js +0 -8
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @license
3
- * Copyright 2025 Google LLC
3
+ * Copyright 2026 Qwen
4
+ * Copyright 2026 Davide A. Guglielmi (Termux porting patches)
4
5
  * SPDX-License-Identifier: Apache-2.0
5
6
  */
6
7
 
@@ -1,77 +0,0 @@
1
- # Checkpointing
2
-
3
- Qwen Code includes a Checkpointing feature that automatically saves a snapshot of your project's state before any file modifications are made by AI-powered tools. This allows you to safely experiment with and apply code changes, knowing you can instantly revert back to the state before the tool was run.
4
-
5
- ## How It Works
6
-
7
- When you approve a tool that modifies the file system (like `write_file` or `edit`), the CLI automatically creates a "checkpoint." This checkpoint includes:
8
-
9
- 1. **A Git Snapshot:** A commit is made in a special, shadow Git repository located in your home directory (`~/.qwen/history/<project_hash>`). This snapshot captures the complete state of your project files at that moment. It does **not** interfere with your own project's Git repository.
10
- 2. **Conversation History:** The entire conversation you've had with the agent up to that point is saved.
11
- 3. **The Tool Call:** The specific tool call that was about to be executed is also stored.
12
-
13
- If you want to undo the change or simply go back, you can use the `/restore` command. Restoring a checkpoint will:
14
-
15
- - Revert all files in your project to the state captured in the snapshot.
16
- - Restore the conversation history in the CLI.
17
- - Re-propose the original tool call, allowing you to run it again, modify it, or simply ignore it.
18
-
19
- All checkpoint data, including the Git snapshot and conversation history, is stored locally on your machine. The Git snapshot is stored in the shadow repository while the conversation history and tool calls are saved in a JSON file in your project's temporary directory, typically located at `~/.qwen/tmp/<project_hash>/checkpoints`.
20
-
21
- ## Enabling the Feature
22
-
23
- The Checkpointing feature is disabled by default. To enable it, you can either use a command-line flag or edit your `settings.json` file.
24
-
25
- ### Using the Command-Line Flag
26
-
27
- You can enable checkpointing for the current session by using the `--checkpointing` flag when starting Qwen Code:
28
-
29
- ```bash
30
- qwen --checkpointing
31
- ```
32
-
33
- ### Using the `settings.json` File
34
-
35
- To enable checkpointing by default for all sessions, you need to edit your `settings.json` file.
36
-
37
- Add the following key to your `settings.json`:
38
-
39
- ```json
40
- {
41
- "general": {
42
- "checkpointing": {
43
- "enabled": true
44
- }
45
- }
46
- }
47
- ```
48
-
49
- ## Using the `/restore` Command
50
-
51
- Once enabled, checkpoints are created automatically. To manage them, you use the `/restore` command.
52
-
53
- ### List Available Checkpoints
54
-
55
- To see a list of all saved checkpoints for the current project, simply run:
56
-
57
- ```
58
- /restore
59
- ```
60
-
61
- The CLI will display a list of available checkpoint files. These file names are typically composed of a timestamp, the name of the file being modified, and the name of the tool that was about to be run (e.g., `2025-06-22T10-00-00_000Z-my-file.txt-write_file`).
62
-
63
- ### Restore a Specific Checkpoint
64
-
65
- To restore your project to a specific checkpoint, use the checkpoint file from the list:
66
-
67
- ```
68
- /restore <checkpoint_file>
69
- ```
70
-
71
- For example:
72
-
73
- ```
74
- /restore 2025-06-22T10-00-00_000Z-my-file.txt-write_file
75
- ```
76
-
77
- After running the command, your files and conversation will be immediately restored to the state they were in when the checkpoint was created, and the original tool prompt will reappear.
@@ -1,48 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import {
4
- AgentTool,
5
- TOOL_REGISTRY_REBUILT,
6
- createApprovalModeOverride,
7
- hasRebuiltToolRegistry,
8
- rebuildToolRegistryOnOverride,
9
- resolveSubagentApprovalMode
10
- } from "./chunk-3OCRHZA3.js";
11
- import "./chunk-K5PGHDBN.js";
12
- import "./chunk-N4WOREMD.js";
13
- import "./chunk-O4PICXES.js";
14
- import "./chunk-TW522KN6.js";
15
- import "./chunk-MLZQVCF3.js";
16
- import "./chunk-G7YTSRES.js";
17
- import "./chunk-4AOCVI6J.js";
18
- import "./chunk-77WXWU44.js";
19
- import "./chunk-F23NCRJ2.js";
20
- import "./chunk-6PCB2DEF.js";
21
- import "./chunk-K6O2NBMF.js";
22
- import "./chunk-UWCTAVOD.js";
23
- import "./chunk-OFEVLU4C.js";
24
- import "./chunk-PR4T27R7.js";
25
- import "./chunk-MAY32HXD.js";
26
- import "./chunk-D5NTAHYL.js";
27
- import "./chunk-MYAKAFEC.js";
28
- import "./chunk-66CXYE4B.js";
29
- import "./chunk-NCTLV2NB.js";
30
- import "./chunk-XEGHDASV.js";
31
- import "./chunk-GGNTZ2NH.js";
32
- import "./chunk-KXZ4TJB4.js";
33
- import "./chunk-XP27SJMH.js";
34
- import "./chunk-XKS5KBFJ.js";
35
- import "./chunk-ZERZSAZL.js";
36
- import "./chunk-QN5NZ3UQ.js";
37
- import "./chunk-BR4QREVK.js";
38
- import "./chunk-QWSRH265.js";
39
- import "./chunk-A4BMJM77.js";
40
- import "./chunk-J2S4EL5Y.js";
41
- export {
42
- AgentTool,
43
- TOOL_REGISTRY_REBUILT,
44
- createApprovalModeOverride,
45
- hasRebuiltToolRegistry,
46
- rebuildToolRegistryOnOverride,
47
- resolveSubagentApprovalMode
48
- };
@@ -1,434 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import {
4
- createDebugLogger
5
- } from "./chunk-XP27SJMH.js";
6
- import {
7
- require_undici
8
- } from "./chunk-XKS5KBFJ.js";
9
- import {
10
- init_esbuild_shims
11
- } from "./chunk-A4BMJM77.js";
12
- import {
13
- __name,
14
- __toESM
15
- } from "./chunk-J2S4EL5Y.js";
16
-
17
- // packages/core/src/utils/runtimeFetchOptions.ts
18
- init_esbuild_shims();
19
- var import_undici = __toESM(require_undici(), 1);
20
- var debugLogger = createDebugLogger("RUNTIME_FETCH");
21
- function detectRuntime() {
22
- if (typeof process !== "undefined" && process.versions?.["bun"]) {
23
- return "bun";
24
- }
25
- if (typeof process !== "undefined" && process.versions?.node) {
26
- return "node";
27
- }
28
- return "unknown";
29
- }
30
- __name(detectRuntime, "detectRuntime");
31
- function buildRuntimeFetchOptions(sdkType, proxyUrl) {
32
- const runtime = detectRuntime();
33
- switch (runtime) {
34
- case "bun": {
35
- if (sdkType === "openai") {
36
- return {
37
- fetchOptions: {
38
- timeout: false
39
- }
40
- };
41
- } else {
42
- const bunFetch = /* @__PURE__ */ __name(async (input, init) => {
43
- const bunFetchOptions = {
44
- ...init,
45
- // @ts-expect-error - Bun-specific timeout option
46
- timeout: false
47
- };
48
- return fetch(input, bunFetchOptions);
49
- }, "bunFetch");
50
- return {
51
- fetch: bunFetch
52
- };
53
- }
54
- }
55
- case "node": {
56
- return buildFetchOptionsWithDispatcher(sdkType, proxyUrl);
57
- }
58
- default: {
59
- return buildFetchOptionsWithDispatcher(sdkType, proxyUrl);
60
- }
61
- }
62
- }
63
- __name(buildRuntimeFetchOptions, "buildRuntimeFetchOptions");
64
- var dispatcherCache = /* @__PURE__ */ new Map();
65
- var proxyFailureCounts = /* @__PURE__ */ new Map();
66
- var NO_DISPATCHER_FALLBACK = {
67
- openai: void 0,
68
- anthropic: {}
69
- };
70
- function getOrCreateSharedDispatcher(proxyUrl) {
71
- const cached = dispatcherCache.get(proxyUrl);
72
- if (cached) {
73
- return cached;
74
- }
75
- const dispatcher = new import_undici.ProxyAgent({
76
- uri: proxyUrl,
77
- headersTimeout: 0,
78
- bodyTimeout: 0,
79
- keepAliveTimeout: 6e4
80
- });
81
- dispatcherCache.set(proxyUrl, dispatcher);
82
- return dispatcher;
83
- }
84
- __name(getOrCreateSharedDispatcher, "getOrCreateSharedDispatcher");
85
- function extractHostnameFromProxyUrl(proxyUrl) {
86
- try {
87
- const url = new URL(proxyUrl);
88
- if (url.hostname) {
89
- return url.port ? `${url.hostname}:${url.port}` : url.hostname;
90
- }
91
- } catch {
92
- }
93
- const match = proxyUrl.match(/@([^:/\s]+)(:\d+)?/);
94
- return match ? match[1] + (match[2] ?? "") : redactProxyCredentials(proxyUrl);
95
- }
96
- __name(extractHostnameFromProxyUrl, "extractHostnameFromProxyUrl");
97
- function hasPlausibleProxyPort(host) {
98
- const portMatch = host.match(/:(\d{1,5})$/);
99
- if (!portMatch) {
100
- return false;
101
- }
102
- const port = Number(portMatch[1]);
103
- return port >= 80 && port <= 65535;
104
- }
105
- __name(hasPlausibleProxyPort, "hasPlausibleProxyPort");
106
- function hasLocalOrProxyLikeHost(host) {
107
- const hostWithoutPort = host.replace(/:\d{1,5}$/, "").toLowerCase();
108
- if (hostWithoutPort === "localhost") {
109
- return true;
110
- }
111
- if (/^\d{1,3}(\.\d{1,3}){3}$/.test(hostWithoutPort)) {
112
- return true;
113
- }
114
- return hostWithoutPort.split(/[.-]/).some((label) => /^(proxy|gateway|gw|squid)\d*$/.test(label));
115
- }
116
- __name(hasLocalOrProxyLikeHost, "hasLocalOrProxyLikeHost");
117
- function hasNetworkErrorContext(message, offset) {
118
- const context = message.slice(Math.max(0, offset - 80), offset).toLowerCase();
119
- return /\b(connect|dispatcher|econnrefused|econnreset|enotfound|etimedout|proxy|tunnel)\b/.test(
120
- context
121
- );
122
- }
123
- __name(hasNetworkErrorContext, "hasNetworkErrorContext");
124
- function shouldRedactTokenOnlyCredential(host, message, offset) {
125
- return hasPlausibleProxyPort(host) && (hasLocalOrProxyLikeHost(host) || hasNetworkErrorContext(message, offset));
126
- }
127
- __name(shouldRedactTokenOnlyCredential, "shouldRedactTokenOnlyCredential");
128
- function redactProxyCredentials(message) {
129
- let result = message.replace(/\/\/[^/\s]*@/g, "//<redacted>@");
130
- result = result.replace(
131
- /(^|[\s([=:])([^\s/@()[\]=]+@[^@\s/()[\]=]+)/g,
132
- (match, prefix, candidate, offset, message2) => {
133
- const atIndex = candidate.indexOf("@");
134
- const userInfo = candidate.slice(0, atIndex);
135
- const host = candidate.slice(atIndex + 1);
136
- if (!userInfo.includes(":") && !shouldRedactTokenOnlyCredential(host, message2, offset)) {
137
- return match;
138
- }
139
- return `${prefix}<redacted>@${host}`;
140
- }
141
- );
142
- return result;
143
- }
144
- __name(redactProxyCredentials, "redactProxyCredentials");
145
- function redactProxyError(error) {
146
- return redactProxyErrorValue(error, /* @__PURE__ */ new WeakMap());
147
- }
148
- __name(redactProxyError, "redactProxyError");
149
- function redactProxyErrorValue(error, seen) {
150
- if (typeof error === "string") {
151
- return redactProxyCredentials(error);
152
- }
153
- if (!error || typeof error !== "object") {
154
- return error;
155
- }
156
- if (seen.has(error)) {
157
- return seen.get(error);
158
- }
159
- const errorRecord = error;
160
- const needsClone = shouldCloneForRedaction(error, errorRecord);
161
- const redactedMessage = typeof errorRecord.message === "string" ? redactProxyCredentials(errorRecord.message) : void 0;
162
- const redactedStack = typeof errorRecord.stack === "string" ? redactProxyCredentials(errorRecord.stack) : void 0;
163
- let redactedCause = errorRecord.cause;
164
- let redactedErrors = errorRecord.errors;
165
- if (needsClone) {
166
- const clone = Object.create(Object.getPrototypeOf(error));
167
- seen.set(error, clone);
168
- if (errorRecord.cause !== void 0) {
169
- redactedCause = redactProxyErrorValue(errorRecord.cause, seen);
170
- }
171
- if (errorRecord.errors !== void 0) {
172
- redactedErrors = redactProxyErrorCollection(errorRecord.errors, seen);
173
- }
174
- cloneErrorWithRedactedFields(
175
- error,
176
- clone,
177
- redactedMessage,
178
- redactedStack,
179
- redactedCause,
180
- redactedErrors
181
- );
182
- return clone;
183
- }
184
- seen.set(error, error);
185
- try {
186
- if (redactedMessage !== void 0) {
187
- errorRecord.message = redactedMessage;
188
- }
189
- if (redactedStack !== void 0) {
190
- errorRecord.stack = redactedStack;
191
- }
192
- if (errorRecord.cause !== void 0) {
193
- redactedCause = redactProxyErrorValue(errorRecord.cause, seen);
194
- errorRecord.cause = redactedCause;
195
- }
196
- if (errorRecord.errors !== void 0) {
197
- redactedErrors = redactProxyErrorCollection(errorRecord.errors, seen);
198
- errorRecord.errors = redactedErrors;
199
- }
200
- return error;
201
- } catch {
202
- const clone = Object.create(Object.getPrototypeOf(error));
203
- seen.set(error, clone);
204
- if (errorRecord.cause !== void 0) {
205
- redactedCause = redactProxyErrorValue(errorRecord.cause, seen);
206
- }
207
- if (errorRecord.errors !== void 0) {
208
- redactedErrors = redactProxyErrorCollection(errorRecord.errors, seen);
209
- }
210
- cloneErrorWithRedactedFields(
211
- error,
212
- clone,
213
- redactedMessage,
214
- redactedStack,
215
- redactedCause,
216
- redactedErrors
217
- );
218
- return clone;
219
- }
220
- }
221
- __name(redactProxyErrorValue, "redactProxyErrorValue");
222
- function redactProxyErrorCollection(errors, seen) {
223
- if (!Array.isArray(errors)) {
224
- return redactProxyErrorValue(errors, seen);
225
- }
226
- if (seen.has(errors)) {
227
- return seen.get(errors);
228
- }
229
- const redactedErrors = [];
230
- seen.set(errors, redactedErrors);
231
- for (const error of errors) {
232
- redactedErrors.push(redactProxyErrorValue(error, seen));
233
- }
234
- return redactedErrors;
235
- }
236
- __name(redactProxyErrorCollection, "redactProxyErrorCollection");
237
- function shouldCloneForRedaction(error, errorRecord) {
238
- return typeof errorRecord.message === "string" && !canAssignProperty(error, "message") || typeof errorRecord.stack === "string" && !canAssignProperty(error, "stack") || errorRecord.cause !== void 0 && !canAssignProperty(error, "cause") || errorRecord.errors !== void 0 && !canAssignProperty(error, "errors");
239
- }
240
- __name(shouldCloneForRedaction, "shouldCloneForRedaction");
241
- function canAssignProperty(target, key) {
242
- let current = target;
243
- while (current) {
244
- const descriptor = Object.getOwnPropertyDescriptor(current, key);
245
- if (descriptor) {
246
- if ("writable" in descriptor) {
247
- return descriptor.writable === true;
248
- }
249
- return typeof descriptor.set === "function";
250
- }
251
- current = Object.getPrototypeOf(current);
252
- }
253
- return Object.isExtensible(target);
254
- }
255
- __name(canAssignProperty, "canAssignProperty");
256
- function cloneErrorWithRedactedFields(error, clone, redactedMessage, redactedStack, redactedCause, redactedErrors) {
257
- const copiedKeys = /* @__PURE__ */ new Set();
258
- for (const key of Reflect.ownKeys(error)) {
259
- const descriptor = Object.getOwnPropertyDescriptor(error, key);
260
- if (!descriptor) {
261
- continue;
262
- }
263
- copiedKeys.add(key);
264
- const updatedDescriptor = getRedactedPropertyDescriptor(
265
- key,
266
- descriptor,
267
- redactedMessage,
268
- redactedStack,
269
- redactedCause,
270
- redactedErrors
271
- );
272
- try {
273
- Object.defineProperty(clone, key, updatedDescriptor);
274
- } catch {
275
- }
276
- }
277
- defineMissingRedactedValue(clone, copiedKeys, "message", redactedMessage);
278
- defineMissingRedactedValue(clone, copiedKeys, "stack", redactedStack);
279
- defineMissingRedactedValue(clone, copiedKeys, "cause", redactedCause);
280
- defineMissingRedactedValue(clone, copiedKeys, "errors", redactedErrors);
281
- }
282
- __name(cloneErrorWithRedactedFields, "cloneErrorWithRedactedFields");
283
- function getRedactedPropertyDescriptor(key, descriptor, redactedMessage, redactedStack, redactedCause, redactedErrors) {
284
- const redactedValue = key === "message" ? redactedMessage : key === "stack" ? redactedStack : key === "cause" ? redactedCause : key === "errors" ? redactedErrors : void 0;
285
- if (redactedValue === void 0) {
286
- return { ...descriptor };
287
- }
288
- if ("value" in descriptor) {
289
- return { ...descriptor, value: redactedValue };
290
- }
291
- return {
292
- configurable: descriptor.configurable,
293
- enumerable: descriptor.enumerable,
294
- value: redactedValue,
295
- writable: true
296
- };
297
- }
298
- __name(getRedactedPropertyDescriptor, "getRedactedPropertyDescriptor");
299
- function defineMissingRedactedValue(target, copiedKeys, key, value) {
300
- if (value === void 0 || copiedKeys.has(key)) {
301
- return;
302
- }
303
- try {
304
- Object.defineProperty(target, key, {
305
- configurable: true,
306
- enumerable: false,
307
- value,
308
- writable: true
309
- });
310
- } catch {
311
- }
312
- }
313
- __name(defineMissingRedactedValue, "defineMissingRedactedValue");
314
- function recordProxyFailure(hostname) {
315
- const failureCount = (proxyFailureCounts.get(hostname) ?? 0) + 1;
316
- proxyFailureCounts.set(hostname, failureCount);
317
- return failureCount;
318
- }
319
- __name(recordProxyFailure, "recordProxyFailure");
320
- function buildFetchOptionsWithDispatcher(sdkType, proxyUrl) {
321
- if (!proxyUrl) {
322
- return NO_DISPATCHER_FALLBACK[sdkType];
323
- }
324
- try {
325
- const dispatcher = getOrCreateSharedDispatcher(proxyUrl);
326
- return { fetchOptions: { dispatcher }, fetch: import_undici.fetch };
327
- } catch (error) {
328
- const hostname = extractHostnameFromProxyUrl(proxyUrl);
329
- const failureCount = recordProxyFailure(hostname);
330
- const failureLabel = failureCount === 1 ? "first failure" : `failure #${failureCount}`;
331
- const errorMessage = error instanceof Error ? error.message : String(error);
332
- const redactedMessage = redactProxyCredentials(errorMessage);
333
- const logMessage = `Failed to create proxy dispatcher for ${hostname} (${failureLabel}), falling back to direct connection: ${redactedMessage}`;
334
- debugLogger.warn(logMessage);
335
- console.error(`[RUNTIME_FETCH] ${logMessage}`);
336
- return NO_DISPATCHER_FALLBACK[sdkType];
337
- }
338
- }
339
- __name(buildFetchOptionsWithDispatcher, "buildFetchOptionsWithDispatcher");
340
-
341
- // packages/core/src/utils/request-tokenizer/textTokenizer.ts
342
- init_esbuild_shims();
343
- var TextTokenizer = class {
344
- static {
345
- __name(this, "TextTokenizer");
346
- }
347
- /**
348
- * Calculate tokens for text content
349
- *
350
- * @param text - The text to estimate tokens for
351
- * @returns The estimated token count
352
- */
353
- async calculateTokens(text) {
354
- return this.calculateTokensSync(text);
355
- }
356
- /**
357
- * Calculate tokens for multiple text strings
358
- *
359
- * @param texts - Array of text strings to estimate tokens for
360
- * @returns Array of token counts corresponding to each input text
361
- */
362
- async calculateTokensBatch(texts) {
363
- return texts.map((text) => this.calculateTokensSync(text));
364
- }
365
- calculateTokensSync(text) {
366
- if (!text || text.length === 0) {
367
- return 0;
368
- }
369
- let asciiChars = 0;
370
- let nonAsciiChars = 0;
371
- for (let i = 0; i < text.length; i++) {
372
- const charCode = text.charCodeAt(i);
373
- if (charCode < 128) {
374
- asciiChars++;
375
- } else {
376
- nonAsciiChars++;
377
- }
378
- }
379
- const tokens = asciiChars / 4 + nonAsciiChars * 1.1;
380
- return Math.ceil(tokens);
381
- }
382
- };
383
-
384
- // packages/core/src/utils/request-tokenizer/supportedImageFormats.ts
385
- init_esbuild_shims();
386
- var SUPPORTED_IMAGE_MIME_TYPES = [
387
- "image/bmp",
388
- "image/jpeg",
389
- "image/jpg",
390
- // Alternative MIME type for JPEG
391
- "image/png",
392
- "image/tiff",
393
- "image/webp",
394
- "image/heic"
395
- ];
396
- function isSupportedImageMimeType(mimeType) {
397
- return SUPPORTED_IMAGE_MIME_TYPES.includes(
398
- mimeType
399
- );
400
- }
401
- __name(isSupportedImageMimeType, "isSupportedImageMimeType");
402
- function getSupportedImageFormatsString() {
403
- return SUPPORTED_IMAGE_MIME_TYPES.map(
404
- (type) => type.replace("image/", "").toUpperCase()
405
- ).join(", ");
406
- }
407
- __name(getSupportedImageFormatsString, "getSupportedImageFormatsString");
408
- function getUnsupportedImageFormatWarning() {
409
- return `Only the following image formats are supported: ${getSupportedImageFormatsString()}. Other formats may not work as expected.`;
410
- }
411
- __name(getUnsupportedImageFormatWarning, "getUnsupportedImageFormatWarning");
412
-
413
- export {
414
- detectRuntime,
415
- buildRuntimeFetchOptions,
416
- getOrCreateSharedDispatcher,
417
- redactProxyCredentials,
418
- redactProxyError,
419
- TextTokenizer,
420
- SUPPORTED_IMAGE_MIME_TYPES,
421
- isSupportedImageMimeType,
422
- getSupportedImageFormatsString,
423
- getUnsupportedImageFormatWarning
424
- };
425
- /**
426
- * @license
427
- * Copyright 2025 Qwen Team
428
- * SPDX-License-Identifier: Apache-2.0
429
- */
430
- /**
431
- * @license
432
- * Copyright 2025 Qwen
433
- * SPDX-License-Identifier: Apache-2.0
434
- */
@@ -1,60 +0,0 @@
1
- // Force strict mode and setup for ESM
2
- "use strict";
3
- import {
4
- init_esbuild_shims
5
- } from "./chunk-A4BMJM77.js";
6
- import {
7
- __esm,
8
- __name
9
- } from "./chunk-J2S4EL5Y.js";
10
-
11
- // node_modules/data-uri-to-buffer/dist/index.js
12
- function dataUriToBuffer(uri) {
13
- if (!/^data:/i.test(uri)) {
14
- throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');
15
- }
16
- uri = uri.replace(/\r?\n/g, "");
17
- const firstComma = uri.indexOf(",");
18
- if (firstComma === -1 || firstComma <= 4) {
19
- throw new TypeError("malformed data: URI");
20
- }
21
- const meta = uri.substring(5, firstComma).split(";");
22
- let charset = "";
23
- let base64 = false;
24
- const type = meta[0] || "text/plain";
25
- let typeFull = type;
26
- for (let i = 1; i < meta.length; i++) {
27
- if (meta[i] === "base64") {
28
- base64 = true;
29
- } else if (meta[i]) {
30
- typeFull += `;${meta[i]}`;
31
- if (meta[i].indexOf("charset=") === 0) {
32
- charset = meta[i].substring(8);
33
- }
34
- }
35
- }
36
- if (!meta[0] && !charset.length) {
37
- typeFull += ";charset=US-ASCII";
38
- charset = "US-ASCII";
39
- }
40
- const encoding = base64 ? "base64" : "ascii";
41
- const data = unescape(uri.substring(firstComma + 1));
42
- const buffer = Buffer.from(data, encoding);
43
- buffer.type = type;
44
- buffer.typeFull = typeFull;
45
- buffer.charset = charset;
46
- return buffer;
47
- }
48
- var dist_default;
49
- var init_dist = __esm({
50
- "node_modules/data-uri-to-buffer/dist/index.js"() {
51
- init_esbuild_shims();
52
- __name(dataUriToBuffer, "dataUriToBuffer");
53
- dist_default = dataUriToBuffer;
54
- }
55
- });
56
-
57
- export {
58
- dist_default,
59
- init_dist
60
- };