t3code-cli 0.12.0 → 0.14.0

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 (330) hide show
  1. package/README.md +87 -1
  2. package/dist/application.d.ts +2 -0
  3. package/dist/application.js +1 -1
  4. package/dist/auth.d.ts +50 -0
  5. package/dist/auth.js +1 -1
  6. package/dist/bin.d.ts +1 -0
  7. package/dist/bin.js +392 -630
  8. package/dist/cli.d.ts +66 -0
  9. package/dist/cli.js +1 -1
  10. package/dist/client-runtime/authorization.d.ts +2 -0
  11. package/dist/client-runtime/authorization.js +2 -0
  12. package/dist/client-runtime/connection.d.ts +2 -0
  13. package/dist/client-runtime/connection.js +2 -0
  14. package/dist/client-runtime/environment.d.ts +57 -0
  15. package/dist/client-runtime/environment.js +2 -0
  16. package/dist/client-runtime/errors.d.ts +28 -0
  17. package/dist/client-runtime/errors.js +35 -0
  18. package/dist/client-runtime/operations/projects.d.ts +2 -0
  19. package/dist/client-runtime/operations/projects.js +2 -0
  20. package/dist/client-runtime/operations.d.ts +2 -0
  21. package/dist/client-runtime/operations.js +2 -0
  22. package/dist/client-runtime/platform.d.ts +26 -0
  23. package/dist/client-runtime/platform.js +74 -0
  24. package/dist/client-runtime/relay.d.ts +121 -0
  25. package/dist/client-runtime/relay.js +245 -0
  26. package/dist/client-runtime/rpc.d.ts +2 -0
  27. package/dist/client-runtime/rpc.js +2 -0
  28. package/dist/client-runtime/state/assets.d.ts +40 -0
  29. package/dist/client-runtime/state/assets.js +53 -0
  30. package/dist/client-runtime/state/auth.d.ts +98 -0
  31. package/dist/client-runtime/state/auth.js +48 -0
  32. package/dist/client-runtime/state/connections.d.ts +2 -0
  33. package/dist/client-runtime/state/connections.js +52 -0
  34. package/dist/client-runtime/state/entities.d.ts +33 -0
  35. package/dist/client-runtime/state/entities.js +2 -0
  36. package/dist/client-runtime/state/filesystem.d.ts +42 -0
  37. package/dist/client-runtime/state/filesystem.js +48 -0
  38. package/dist/client-runtime/state/git.d.ts +43 -0
  39. package/dist/client-runtime/state/git.js +18 -0
  40. package/dist/client-runtime/state/models.d.ts +2 -0
  41. package/dist/client-runtime/state/models.js +2 -0
  42. package/dist/client-runtime/state/orchestration.d.ts +128 -0
  43. package/dist/client-runtime/state/orchestration.js +20 -0
  44. package/dist/client-runtime/state/presentation.d.ts +277 -0
  45. package/dist/client-runtime/state/presentation.js +34 -0
  46. package/dist/client-runtime/state/preview.d.ts +447 -0
  47. package/dist/client-runtime/state/preview.js +103 -0
  48. package/dist/client-runtime/state/project-grouping.d.ts +26 -0
  49. package/dist/client-runtime/state/project-grouping.js +73 -0
  50. package/dist/client-runtime/state/projects.d.ts +192 -0
  51. package/dist/client-runtime/state/projects.js +2 -0
  52. package/dist/client-runtime/state/relay.d.ts +10 -0
  53. package/dist/client-runtime/state/relay.js +19 -0
  54. package/dist/client-runtime/state/review.d.ts +28 -0
  55. package/dist/client-runtime/state/review.js +11 -0
  56. package/dist/client-runtime/state/runtime.d.ts +2 -0
  57. package/dist/client-runtime/state/runtime.js +2 -0
  58. package/dist/client-runtime/state/server.d.ts +1495 -0
  59. package/dist/client-runtime/state/server.js +207 -0
  60. package/dist/client-runtime/state/session.d.ts +532 -0
  61. package/dist/client-runtime/state/session.js +21 -0
  62. package/dist/client-runtime/state/shell.d.ts +529 -0
  63. package/dist/client-runtime/state/shell.js +2 -0
  64. package/dist/client-runtime/state/source-control.d.ts +92 -0
  65. package/dist/client-runtime/state/source-control.js +36 -0
  66. package/dist/client-runtime/state/terminal.d.ts +237 -0
  67. package/dist/client-runtime/state/terminal.js +173 -0
  68. package/dist/client-runtime/state/thread-settled.d.ts +104 -0
  69. package/dist/client-runtime/state/thread-settled.js +157 -0
  70. package/dist/client-runtime/state/thread-sort.d.ts +23 -0
  71. package/dist/client-runtime/state/thread-sort.js +47 -0
  72. package/dist/client-runtime/state/threads.d.ts +538 -0
  73. package/dist/client-runtime/state/threads.js +934 -0
  74. package/dist/client-runtime/state/vcs.d.ts +442 -0
  75. package/dist/client-runtime/state/vcs.js +756 -0
  76. package/dist/config.d.ts +84 -0
  77. package/dist/config.js +1 -1
  78. package/dist/connection.d.ts +7 -0
  79. package/dist/connection.js +1 -1
  80. package/dist/contracts.d.ts +2 -0
  81. package/dist/contracts.js +2 -1
  82. package/dist/index.d.ts +2 -0
  83. package/dist/index.js +1 -1
  84. package/dist/node.d.ts +6 -0
  85. package/dist/node.js +1 -1
  86. package/dist/orchestration.d.ts +1420 -0
  87. package/dist/orchestration.js +1 -1
  88. package/dist/preview.d.ts +2 -0
  89. package/dist/preview.js +2 -0
  90. package/dist/rolldown-runtime.js +1 -1
  91. package/dist/rpc.d.ts +6043 -0
  92. package/dist/rpc.js +1 -1
  93. package/dist/runtime.d.ts +2 -0
  94. package/dist/runtime.js +2 -2
  95. package/dist/shared/DrainableWorker.d.ts +28 -0
  96. package/dist/shared/DrainableWorker.js +24 -0
  97. package/dist/shared/KeyedCoalescingWorker.d.ts +13 -0
  98. package/dist/shared/KeyedCoalescingWorker.js +89 -0
  99. package/dist/shared/Net.d.ts +43 -0
  100. package/dist/shared/Net.js +126 -0
  101. package/dist/shared/String.d.ts +4 -0
  102. package/dist/shared/String.js +8 -0
  103. package/dist/shared/Struct.d.ts +5 -0
  104. package/dist/shared/Struct.js +2 -0
  105. package/dist/shared/advertisedEndpoint.d.ts +2 -0
  106. package/dist/shared/advertisedEndpoint.js +2 -0
  107. package/dist/shared/agentAwareness.d.ts +27 -0
  108. package/dist/shared/agentAwareness.js +54 -0
  109. package/dist/shared/backgroundActivitySettings.d.ts +23 -0
  110. package/dist/shared/backgroundActivitySettings.js +2 -0
  111. package/dist/shared/chatList.d.ts +12 -0
  112. package/dist/shared/chatList.js +14 -0
  113. package/dist/shared/cliArgs.d.ts +33 -0
  114. package/dist/shared/cliArgs.js +103 -0
  115. package/dist/shared/composerInlineTokens.d.ts +20 -0
  116. package/dist/shared/composerInlineTokens.js +72 -0
  117. package/dist/shared/composerTrigger.d.ts +26 -0
  118. package/dist/shared/composerTrigger.js +97 -0
  119. package/dist/shared/connectAuth.d.ts +58 -0
  120. package/dist/shared/connectAuth.js +89 -0
  121. package/dist/shared/devHome.d.ts +21 -0
  122. package/dist/shared/devHome.js +65 -0
  123. package/dist/shared/devProxy.d.ts +15 -0
  124. package/dist/shared/devProxy.js +22 -0
  125. package/dist/shared/dpop.d.ts +32 -0
  126. package/dist/shared/dpop.js +2724 -0
  127. package/dist/shared/dpopCommon.d.ts +2 -0
  128. package/dist/shared/dpopCommon.js +2 -0
  129. package/dist/shared/filePreview.d.ts +8 -0
  130. package/dist/shared/filePreview.js +31 -0
  131. package/dist/shared/git.d.ts +41 -0
  132. package/dist/shared/git.js +2 -0
  133. package/dist/shared/hostProcess.d.ts +13 -0
  134. package/dist/shared/hostProcess.js +2 -0
  135. package/dist/shared/httpObservability.d.ts +5 -0
  136. package/dist/shared/httpObservability.js +2 -0
  137. package/dist/shared/httpReadiness.d.ts +38 -0
  138. package/dist/shared/httpReadiness.js +110 -0
  139. package/dist/shared/keybindings.d.ts +35 -0
  140. package/dist/shared/keybindings.js +330 -0
  141. package/dist/shared/logging.d.ts +39 -0
  142. package/dist/shared/logging.js +2 -0
  143. package/dist/shared/model.d.ts +44 -0
  144. package/dist/shared/model.js +2 -0
  145. package/dist/shared/oauthScope.d.ts +23 -0
  146. package/dist/shared/oauthScope.js +2 -0
  147. package/dist/shared/observability.d.ts +105 -0
  148. package/dist/shared/observability.js +346 -0
  149. package/dist/shared/orchestrationTiming.d.ts +16 -0
  150. package/dist/shared/orchestrationTiming.js +32 -0
  151. package/dist/shared/path.d.ts +2 -0
  152. package/dist/shared/path.js +2 -0
  153. package/dist/shared/preview.d.ts +35 -0
  154. package/dist/shared/preview.js +103 -0
  155. package/dist/shared/previewViewport.d.ts +16 -0
  156. package/dist/shared/previewViewport.js +159 -0
  157. package/dist/shared/projectFavicon.d.ts +5 -0
  158. package/dist/shared/projectFavicon.js +13 -0
  159. package/dist/shared/projectScripts.d.ts +19 -0
  160. package/dist/shared/projectScripts.js +18 -0
  161. package/dist/shared/qrCode.d.ts +87 -0
  162. package/dist/shared/qrCode.js +870 -0
  163. package/dist/shared/relayAuth.d.ts +27 -0
  164. package/dist/shared/relayAuth.js +83 -0
  165. package/dist/shared/relayClient.d.ts +58 -0
  166. package/dist/shared/relayClient.js +245 -0
  167. package/dist/shared/relayJwt.d.ts +39 -0
  168. package/dist/shared/relayJwt.js +2 -0
  169. package/dist/shared/relaySigning.d.ts +4 -0
  170. package/dist/shared/relaySigning.js +2 -0
  171. package/dist/shared/relayTracing.d.ts +25 -0
  172. package/dist/shared/relayTracing.js +2 -0
  173. package/dist/shared/relayUrl.d.ts +5 -0
  174. package/dist/shared/relayUrl.js +2 -0
  175. package/dist/shared/remote.d.ts +57 -0
  176. package/dist/shared/remote.js +2 -0
  177. package/dist/shared/schemaJson.d.ts +35 -0
  178. package/dist/shared/schemaJson.js +2 -0
  179. package/dist/shared/schemaYaml.d.ts +86 -0
  180. package/dist/shared/schemaYaml.js +99 -0
  181. package/dist/shared/searchRanking.d.ts +30 -0
  182. package/dist/shared/searchRanking.js +99 -0
  183. package/dist/shared/semver.d.ts +23 -0
  184. package/dist/shared/semver.js +124 -0
  185. package/dist/shared/serverSettings.d.ts +19 -0
  186. package/dist/shared/serverSettings.js +103 -0
  187. package/dist/shared/shell.d.ts +51 -0
  188. package/dist/shared/shell.js +408 -0
  189. package/dist/shared/sourceControl.d.ts +26 -0
  190. package/dist/shared/sourceControl.js +2 -0
  191. package/dist/shared/t3ProjectFile.d.ts +27 -0
  192. package/dist/shared/t3ProjectFile.js +25 -0
  193. package/dist/shared/terminalLabels.d.ts +16 -0
  194. package/dist/shared/terminalLabels.js +28 -0
  195. package/dist/shared/toolActivity.d.ts +16 -0
  196. package/dist/shared/toolActivity.js +159 -0
  197. package/dist/shared.d.ts +43036 -0
  198. package/dist/shared.js +36722 -13117
  199. package/dist/t3tools.d.ts +2 -0
  200. package/dist/t3tools.js +2 -2
  201. package/package.json +46 -27
  202. package/src/application/thread-wait.ts +4 -0
  203. package/src/auth/error.ts +2 -8
  204. package/src/auth/index.ts +2 -0
  205. package/src/auth/pairing.ts +8 -5
  206. package/src/auth/remote-error.ts +17 -0
  207. package/src/auth/service.ts +2 -1
  208. package/src/auth/transport.ts +49 -114
  209. package/src/auth/type.ts +6 -0
  210. package/src/cli/auth.ts +7 -1
  211. package/src/connection/error.ts +4 -1
  212. package/src/connection/layer.ts +5 -2
  213. package/src/connection/prepared.ts +83 -0
  214. package/src/contracts/index.ts +8 -0
  215. package/src/orchestration/layer.ts +38 -1
  216. package/src/orchestration/service.ts +5 -0
  217. package/src/preview/index.ts +11 -0
  218. package/src/preview/service.ts +52 -0
  219. package/src/rpc/error.ts +11 -16
  220. package/src/rpc/index.ts +3 -2
  221. package/src/rpc/layer.ts +18 -51
  222. package/src/rpc/operation.ts +21 -6
  223. package/src/rpc/service.ts +2 -1
  224. package/src/rpc/session.ts +168 -0
  225. package/src/rpc/ws-group.ts +18 -26
  226. package/src/runtime/index.ts +1 -0
  227. package/src/runtime/layer.ts +11 -3
  228. package/src/sql/node-sqlite-client.ts +3 -0
  229. package/dist/src/application/actions.d.ts +0 -25
  230. package/dist/src/application/error.d.ts +0 -3
  231. package/dist/src/application/index.d.ts +0 -4
  232. package/dist/src/application/layer.d.ts +0 -117
  233. package/dist/src/application/model-selection.d.ts +0 -34
  234. package/dist/src/application/models.d.ts +0 -8
  235. package/dist/src/application/project-commands.d.ts +0 -44
  236. package/dist/src/application/projects.d.ts +0 -23
  237. package/dist/src/application/service.d.ts +0 -243
  238. package/dist/src/application/shell-sequence.d.ts +0 -101
  239. package/dist/src/application/terminals.d.ts +0 -66
  240. package/dist/src/application/thread-commands.d.ts +0 -157
  241. package/dist/src/application/thread-update.d.ts +0 -8
  242. package/dist/src/application/thread-wait.d.ts +0 -111
  243. package/dist/src/application/threads.d.ts +0 -685
  244. package/dist/src/auth/error.d.ts +0 -51
  245. package/dist/src/auth/index.d.ts +0 -10
  246. package/dist/src/auth/layer.d.ts +0 -53
  247. package/dist/src/auth/local-base-dir.d.ts +0 -8
  248. package/dist/src/auth/local-origin.d.ts +0 -18
  249. package/dist/src/auth/local-token.d.ts +0 -26
  250. package/dist/src/auth/local.d.ts +0 -24
  251. package/dist/src/auth/pairing.d.ts +0 -22
  252. package/dist/src/auth/schema.d.ts +0 -58
  253. package/dist/src/auth/service.d.ts +0 -27
  254. package/dist/src/auth/transport.d.ts +0 -22
  255. package/dist/src/auth/type.d.ts +0 -83
  256. package/dist/src/cli/env/flag.d.ts +0 -2
  257. package/dist/src/cli/env/index.d.ts +0 -2
  258. package/dist/src/cli/env/selection-layer.d.ts +0 -3
  259. package/dist/src/cli/flags.d.ts +0 -20
  260. package/dist/src/cli/format/index.d.ts +0 -1
  261. package/dist/src/cli/format/output.d.ts +0 -12
  262. package/dist/src/cli/index.d.ts +0 -5
  263. package/dist/src/cli/runtime/index.d.ts +0 -1
  264. package/dist/src/cli/runtime/service.d.ts +0 -16
  265. package/dist/src/cli/scope/index.d.ts +0 -1
  266. package/dist/src/cli/scope/resolve.d.ts +0 -20
  267. package/dist/src/cli-path/layer.d.ts +0 -3
  268. package/dist/src/cli-path/service.d.ts +0 -8
  269. package/dist/src/config/config.d.ts +0 -49
  270. package/dist/src/config/credential/cipher-node.d.ts +0 -3
  271. package/dist/src/config/credential/cipher-web.d.ts +0 -3
  272. package/dist/src/config/credential/cipher.d.ts +0 -29
  273. package/dist/src/config/credential/env.d.ts +0 -3
  274. package/dist/src/config/credential/error.d.ts +0 -8
  275. package/dist/src/config/credential/index.d.ts +0 -6
  276. package/dist/src/config/credential/service.d.ts +0 -34
  277. package/dist/src/config/env/env.d.ts +0 -55
  278. package/dist/src/config/env/index.d.ts +0 -2
  279. package/dist/src/config/env/layout.d.ts +0 -11
  280. package/dist/src/config/environment-name/index.d.ts +0 -1
  281. package/dist/src/config/environment-name/name.d.ts +0 -10
  282. package/dist/src/config/error.d.ts +0 -11
  283. package/dist/src/config/index.d.ts +0 -10
  284. package/dist/src/config/keystore/error.d.ts +0 -8
  285. package/dist/src/config/keystore/file.d.ts +0 -9
  286. package/dist/src/config/keystore/index.d.ts +0 -4
  287. package/dist/src/config/keystore/keyring-node.d.ts +0 -4
  288. package/dist/src/config/keystore/service.d.ts +0 -33
  289. package/dist/src/config/paths/index.d.ts +0 -1
  290. package/dist/src/config/paths/paths.d.ts +0 -6
  291. package/dist/src/config/persist/file-mode.d.ts +0 -4
  292. package/dist/src/config/persist/migration.d.ts +0 -68
  293. package/dist/src/config/persist/persist.d.ts +0 -40
  294. package/dist/src/config/persist/schema.d.ts +0 -68
  295. package/dist/src/config/resolve/resolve.d.ts +0 -40
  296. package/dist/src/config/selection/index.d.ts +0 -1
  297. package/dist/src/config/selection/resolve.d.ts +0 -4
  298. package/dist/src/config/selection/service.d.ts +0 -10
  299. package/dist/src/config/types.d.ts +0 -36
  300. package/dist/src/config/url/error.d.ts +0 -10
  301. package/dist/src/config/url/index.d.ts +0 -2
  302. package/dist/src/config/url/url.d.ts +0 -6
  303. package/dist/src/connection/error.d.ts +0 -8
  304. package/dist/src/connection/index.d.ts +0 -4
  305. package/dist/src/connection/layer.d.ts +0 -3
  306. package/dist/src/connection/service.d.ts +0 -13
  307. package/dist/src/connection/type.d.ts +0 -10
  308. package/dist/src/contracts/index.d.ts +0 -1
  309. package/dist/src/domain/error.d.ts +0 -57
  310. package/dist/src/domain/helpers.d.ts +0 -184
  311. package/dist/src/domain/model-config.d.ts +0 -325
  312. package/dist/src/domain/thread-activities.d.ts +0 -14
  313. package/dist/src/domain/thread-lifecycle.d.ts +0 -125
  314. package/dist/src/index.d.ts +0 -3
  315. package/dist/src/node/connection.d.ts +0 -2
  316. package/dist/src/node/index.d.ts +0 -1
  317. package/dist/src/orchestration/index.d.ts +0 -2
  318. package/dist/src/orchestration/layer.d.ts +0 -1634
  319. package/dist/src/orchestration/service.d.ts +0 -28
  320. package/dist/src/rpc/error.d.ts +0 -18
  321. package/dist/src/rpc/index.d.ts +0 -5
  322. package/dist/src/rpc/layer.d.ts +0 -6271
  323. package/dist/src/rpc/operation.d.ts +0 -6280
  324. package/dist/src/rpc/service.d.ts +0 -15
  325. package/dist/src/rpc/ws-group.d.ts +0 -2725
  326. package/dist/src/runtime/index.d.ts +0 -1
  327. package/dist/src/runtime/layer.d.ts +0 -15
  328. package/dist/src/sql/node-sqlite-client.d.ts +0 -10
  329. package/dist/src/sql/service.d.ts +0 -17
  330. package/dist/src/t3tools/index.d.ts +0 -1
@@ -0,0 +1,408 @@
1
+ import { EO as succeed, HD as as, KO as TaggedError, OE as FileSystem, Ok as Reference, TE as Path, _O as orElseSucceed, eO as fn, qD as catchTag, w as HostProcessPlatform, x as HostProcessEnvironment } from "../shared.js";
2
+ import * as NodeOS from "node:os";
3
+ import * as NodeChildProcess from "node:child_process";
4
+ import * as NodeFS from "node:fs";
5
+ import * as NodePath from "node:path";
6
+ //#region upstream-t3code/packages/shared/src/shell.ts
7
+ const PATH_CAPTURE_START = "__T3CODE_PATH_START__";
8
+ const PATH_CAPTURE_END = "__T3CODE_PATH_END__";
9
+ const SHELL_ENV_NAME_PATTERN = /^[A-Z0-9_]+$/;
10
+ const WINDOWS_PATH_DELIMITER = ";";
11
+ const POSIX_PATH_DELIMITER = ":";
12
+ const WINDOWS_SHELL_CANDIDATES = ["pwsh.exe", "powershell.exe"];
13
+ function canExecuteFile(filePath) {
14
+ try {
15
+ NodeFS.accessSync(filePath, NodeFS.constants.X_OK);
16
+ return true;
17
+ } catch {
18
+ return false;
19
+ }
20
+ }
21
+ var CommandResolutionError = class extends TaggedError("CommandResolutionError") {};
22
+ const WINDOWS_SHELL_META_CHARS = /([()\][%!^"`<>&|;, *?])/g;
23
+ /**
24
+ * Escapes a single argument for `cmd.exe` shell mode (`spawn(..., { shell: true })`
25
+ * on Windows). Node joins the command and arguments with spaces and hands the
26
+ * resulting string to `cmd.exe` without any quoting, so every dynamic argument
27
+ * must be escaped to survive both cmd.exe parsing and the target program's
28
+ * `CommandLineToArgvW` parsing. Mirrors cross-spawn's argument escaping.
29
+ */
30
+ function escapeWindowsShellArg(arg) {
31
+ let escaped = arg.replace(/(\\*)"/g, "$1$1\\\"");
32
+ escaped = escaped.replace(/(\\*)$/, "$1$1");
33
+ escaped = `"${escaped}"`;
34
+ return escaped.replace(WINDOWS_SHELL_META_CHARS, "^$1");
35
+ }
36
+ /**
37
+ * Escapes arguments for shell-mode spawns: applies {@link escapeWindowsShellArg}
38
+ * when the platform is `win32` (where `shell: true` routes through `cmd.exe`)
39
+ * and returns the arguments untouched everywhere else.
40
+ */
41
+ function sanitizeShellModeArgsForPlatform(args, platform) {
42
+ return platform === "win32" ? args.map(escapeWindowsShellArg) : [...args];
43
+ }
44
+ function resolveSpawnExecutableWithNode(command, platform, env) {
45
+ const path = platform === "win32" ? NodePath.win32 : NodePath.posix;
46
+ const windowsPathExtensions = platform === "win32" ? resolveWindowsPathExtensions(env) : [];
47
+ const candidates = resolveCommandCandidates(command, platform, windowsPathExtensions, path.extname);
48
+ const isExecutable = (candidate) => {
49
+ try {
50
+ if (!NodeFS.statSync(candidate).isFile()) return false;
51
+ if (platform === "win32") return windowsPathExtensions.includes(path.extname(candidate).toUpperCase());
52
+ return canExecuteFile(candidate);
53
+ } catch {
54
+ return false;
55
+ }
56
+ };
57
+ if (command.includes("/") || command.includes("\\")) return candidates.find(isExecutable);
58
+ for (const pathEntry of (readEnvPath(env) ?? "").split(pathDelimiterForPlatform(platform))) {
59
+ const normalizedPathEntry = stripWrappingQuotes(pathEntry.trim());
60
+ if (normalizedPathEntry.length === 0) continue;
61
+ for (const candidate of candidates) {
62
+ const candidatePath = path.join(normalizedPathEntry, candidate);
63
+ if (isExecutable(candidatePath)) return candidatePath;
64
+ }
65
+ }
66
+ }
67
+ const SpawnExecutableResolution = Reference("@t3tools/shared/shell/SpawnExecutableResolution", { defaultValue: () => resolveSpawnExecutableWithNode });
68
+ function trimNonEmpty(value) {
69
+ const trimmed = value?.trim();
70
+ return trimmed && trimmed.length > 0 ? trimmed : void 0;
71
+ }
72
+ function readUserLoginShell() {
73
+ try {
74
+ return trimNonEmpty(NodeOS.userInfo().shell);
75
+ } catch {
76
+ return;
77
+ }
78
+ }
79
+ function listLoginShellCandidates(platform, shell, userShell = readUserLoginShell()) {
80
+ const fallbackShell = platform === "darwin" ? "/bin/zsh" : platform === "linux" ? "/bin/bash" : void 0;
81
+ const seen = /* @__PURE__ */ new Set();
82
+ const candidates = [];
83
+ for (const candidate of [
84
+ trimNonEmpty(shell),
85
+ trimNonEmpty(userShell),
86
+ fallbackShell
87
+ ]) {
88
+ if (!candidate || seen.has(candidate)) continue;
89
+ seen.add(candidate);
90
+ candidates.push(candidate);
91
+ }
92
+ return candidates;
93
+ }
94
+ function extractPathFromShellOutput(output) {
95
+ const startIndex = output.indexOf(PATH_CAPTURE_START);
96
+ if (startIndex === -1) return null;
97
+ const valueStartIndex = startIndex + 21;
98
+ const endIndex = output.indexOf(PATH_CAPTURE_END, valueStartIndex);
99
+ if (endIndex === -1) return null;
100
+ const pathValue = output.slice(valueStartIndex, endIndex).trim();
101
+ return pathValue.length > 0 ? pathValue : null;
102
+ }
103
+ function readPathFromLoginShell(shell, execFile = NodeChildProcess.execFileSync) {
104
+ return readEnvironmentFromLoginShell(shell, ["PATH"], execFile).PATH;
105
+ }
106
+ function readPathFromLaunchctl(execFile = NodeChildProcess.execFileSync) {
107
+ try {
108
+ return trimNonEmpty(execFile("/bin/launchctl", ["getenv", "PATH"], {
109
+ encoding: "utf8",
110
+ timeout: 2e3
111
+ }));
112
+ } catch {
113
+ return;
114
+ }
115
+ }
116
+ function mergePathEntries(preferredPath, inheritedPath, platform) {
117
+ const delimiter = platform === "win32" ? ";" : ":";
118
+ const merged = [];
119
+ const seen = /* @__PURE__ */ new Set();
120
+ for (const pathValue of [preferredPath, inheritedPath]) {
121
+ if (!pathValue) continue;
122
+ for (const entry of pathValue.split(delimiter)) {
123
+ const trimmedEntry = entry.trim();
124
+ if (!trimmedEntry || seen.has(trimmedEntry)) continue;
125
+ seen.add(trimmedEntry);
126
+ merged.push(trimmedEntry);
127
+ }
128
+ }
129
+ return merged.length > 0 ? merged.join(delimiter) : void 0;
130
+ }
131
+ function envCaptureStart(name) {
132
+ return `__T3CODE_ENV_${name}_START__`;
133
+ }
134
+ function envCaptureEnd(name) {
135
+ return `__T3CODE_ENV_${name}_END__`;
136
+ }
137
+ function buildEnvironmentCaptureCommand(names) {
138
+ return names.map((name) => {
139
+ if (!SHELL_ENV_NAME_PATTERN.test(name)) throw new Error(`Unsupported environment variable name: ${name}`);
140
+ return [
141
+ `printf '%s\\n' '${envCaptureStart(name)}'`,
142
+ `printenv ${name} || true`,
143
+ `printf '%s\\n' '${envCaptureEnd(name)}'`
144
+ ].join("; ");
145
+ }).join("; ");
146
+ }
147
+ function buildWindowsEnvironmentCaptureCommand(names) {
148
+ return ["$ErrorActionPreference = 'Stop'", ...names.flatMap((name) => {
149
+ if (!SHELL_ENV_NAME_PATTERN.test(name)) throw new Error(`Unsupported environment variable name: ${name}`);
150
+ return [
151
+ `Write-Output '${envCaptureStart(name)}'`,
152
+ `$value = [Environment]::GetEnvironmentVariable('${name}')`,
153
+ "if ($null -ne $value -and $value.Length -gt 0) { Write-Output $value }",
154
+ `Write-Output '${envCaptureEnd(name)}'`
155
+ ];
156
+ })].join("; ");
157
+ }
158
+ function extractEnvironmentValue(output, name) {
159
+ const startMarker = envCaptureStart(name);
160
+ const endMarker = envCaptureEnd(name);
161
+ const startIndex = output.indexOf(startMarker);
162
+ if (startIndex === -1) return void 0;
163
+ const valueStartIndex = startIndex + startMarker.length;
164
+ const endIndex = output.indexOf(endMarker, valueStartIndex);
165
+ if (endIndex === -1) return void 0;
166
+ const value = output.slice(valueStartIndex, endIndex).replace(/^\r?\n/, "").replace(/\r?\n$/, "");
167
+ return value.length > 0 ? value : void 0;
168
+ }
169
+ const readEnvironmentFromLoginShell = (shell, names, execFile = NodeChildProcess.execFileSync) => {
170
+ if (names.length === 0) return {};
171
+ const output = execFile(shell, ["-ilc", buildEnvironmentCaptureCommand(names)], {
172
+ encoding: "utf8",
173
+ timeout: 5e3
174
+ });
175
+ const environment = {};
176
+ for (const name of names) {
177
+ const value = extractEnvironmentValue(output, name);
178
+ if (value !== void 0) environment[name] = value;
179
+ }
180
+ return environment;
181
+ };
182
+ const WindowsShellEnvironment = Reference("@t3tools/shared/shell/WindowsShellEnvironment", { defaultValue: () => readEnvironmentFromWindowsShell });
183
+ const CommandAvailability = Reference("@t3tools/shared/shell/CommandAvailability", { defaultValue: () => isCommandAvailable });
184
+ function readEnvironmentFromWindowsShell(names, optionsOrExecFile, maybeExecFile) {
185
+ if (names.length === 0) return {};
186
+ const options = typeof optionsOrExecFile === "function" ? {} : optionsOrExecFile ?? {};
187
+ const execFile = typeof optionsOrExecFile === "function" ? optionsOrExecFile : maybeExecFile ?? NodeChildProcess.execFileSync;
188
+ const command = buildWindowsEnvironmentCaptureCommand(names);
189
+ const args = [
190
+ "-NoLogo",
191
+ ...options.loadProfile ? [] : ["-NoProfile"],
192
+ "-NonInteractive",
193
+ "-Command",
194
+ command
195
+ ];
196
+ for (const shell of WINDOWS_SHELL_CANDIDATES) try {
197
+ const output = execFile(shell, args, {
198
+ encoding: "utf8",
199
+ timeout: 5e3
200
+ });
201
+ const environment = {};
202
+ for (const name of names) {
203
+ const value = extractEnvironmentValue(output, name);
204
+ if (value !== void 0) environment[name] = value;
205
+ }
206
+ return environment;
207
+ } catch {
208
+ continue;
209
+ }
210
+ return {};
211
+ }
212
+ function stripWrappingQuotes(value) {
213
+ return value.replace(/^"+|"+$/g, "");
214
+ }
215
+ function pathDelimiterForPlatform(platform) {
216
+ return platform === "win32" ? WINDOWS_PATH_DELIMITER : POSIX_PATH_DELIMITER;
217
+ }
218
+ function normalizePathEntryForComparison(entry, platform) {
219
+ const normalized = stripWrappingQuotes(entry.trim());
220
+ return platform === "win32" ? normalized.toLowerCase() : normalized;
221
+ }
222
+ function mergePathValues(preferredPath, inheritedPath, platform) {
223
+ const delimiter = pathDelimiterForPlatform(platform);
224
+ const merged = [];
225
+ const seen = /* @__PURE__ */ new Set();
226
+ for (const rawValue of [preferredPath, inheritedPath]) {
227
+ if (!rawValue) continue;
228
+ for (const entry of rawValue.split(delimiter)) {
229
+ const trimmed = entry.trim();
230
+ if (trimmed.length === 0) continue;
231
+ const normalized = normalizePathEntryForComparison(trimmed, platform);
232
+ if (normalized.length === 0 || seen.has(normalized)) continue;
233
+ seen.add(normalized);
234
+ merged.push(trimmed);
235
+ }
236
+ }
237
+ return merged.length > 0 ? merged.join(delimiter) : void 0;
238
+ }
239
+ function readEnvPath(env) {
240
+ return env.PATH ?? env.Path ?? env.path;
241
+ }
242
+ function resolvePathEnvironmentVariable(env) {
243
+ return readEnvPath(env) ?? "";
244
+ }
245
+ function resolveWindowsPathExtensions(env) {
246
+ const rawValue = env.PATHEXT;
247
+ const fallback = [
248
+ ".COM",
249
+ ".EXE",
250
+ ".BAT",
251
+ ".CMD"
252
+ ];
253
+ if (!rawValue) return fallback;
254
+ const parsed = [];
255
+ for (const entry of rawValue.split(";")) {
256
+ const trimmed = entry.trim();
257
+ if (trimmed.length === 0) continue;
258
+ parsed.push(trimmed.startsWith(".") ? trimmed.toUpperCase() : `.${trimmed.toUpperCase()}`);
259
+ }
260
+ return parsed.length > 0 ? Array.from(new Set(parsed)) : fallback;
261
+ }
262
+ function resolveCommandCandidates(command, platform, windowsPathExtensions, extname) {
263
+ if (platform !== "win32") return [command];
264
+ const extension = extname(command);
265
+ const normalizedExtension = extension.toUpperCase();
266
+ if (extension.length > 0 && windowsPathExtensions.includes(normalizedExtension)) {
267
+ const commandWithoutExtension = command.slice(0, -extension.length);
268
+ return Array.from(/* @__PURE__ */ new Set([
269
+ command,
270
+ `${commandWithoutExtension}${normalizedExtension}`,
271
+ `${commandWithoutExtension}${normalizedExtension.toLowerCase()}`
272
+ ]));
273
+ }
274
+ const candidates = [];
275
+ for (const candidateExtension of windowsPathExtensions) {
276
+ candidates.push(`${command}${candidateExtension}`);
277
+ candidates.push(`${command}${candidateExtension.toLowerCase()}`);
278
+ }
279
+ return Array.from(new Set(candidates));
280
+ }
281
+ const isExecutableFile = fn("shell.isExecutableFile")(function* (filePath, platform, windowsPathExtensions) {
282
+ const fileSystem = yield* FileSystem;
283
+ const path = yield* Path;
284
+ const stat = yield* fileSystem.stat(filePath).pipe(orElseSucceed(() => null));
285
+ if (stat === null || stat.type !== "File") return false;
286
+ if (platform === "win32") {
287
+ const extension = path.extname(filePath);
288
+ if (extension.length === 0) return false;
289
+ return windowsPathExtensions.includes(extension.toUpperCase());
290
+ }
291
+ return canExecuteFile(filePath);
292
+ });
293
+ const resolveCommandPathForPlatform = fn("shell.resolveCommandPathForPlatform")(function* (command, options) {
294
+ const path = yield* Path;
295
+ const platform = options.platform;
296
+ const env = options.env ?? process.env;
297
+ const windowsPathExtensions = platform === "win32" ? resolveWindowsPathExtensions(env) : [];
298
+ const commandCandidates = resolveCommandCandidates(command, platform, windowsPathExtensions, path.extname);
299
+ if (command.includes("/") || command.includes("\\")) {
300
+ for (const candidate of commandCandidates) if (yield* isExecutableFile(candidate, platform, windowsPathExtensions)) return candidate;
301
+ return yield* new CommandResolutionError({
302
+ command,
303
+ reason: "not-found"
304
+ });
305
+ }
306
+ const pathValue = resolvePathEnvironmentVariable(env);
307
+ if (pathValue.length === 0) return yield* new CommandResolutionError({
308
+ command,
309
+ reason: "not-found"
310
+ });
311
+ const pathEntries = [];
312
+ for (const entry of pathValue.split(pathDelimiterForPlatform(platform))) {
313
+ const pathEntry = stripWrappingQuotes(entry.trim());
314
+ if (pathEntry.length > 0) pathEntries.push(pathEntry);
315
+ }
316
+ for (const pathEntry of pathEntries) for (const candidate of commandCandidates) {
317
+ const candidatePath = path.join(pathEntry, candidate);
318
+ if (yield* isExecutableFile(candidatePath, platform, windowsPathExtensions)) return candidatePath;
319
+ }
320
+ return yield* new CommandResolutionError({
321
+ command,
322
+ reason: "not-found"
323
+ });
324
+ });
325
+ const resolveCommandPath = fn("shell.resolveCommandPath")(function* (command, options = {}) {
326
+ return yield* resolveCommandPathForPlatform(command, {
327
+ env: options.env ?? (yield* HostProcessEnvironment),
328
+ platform: yield* HostProcessPlatform
329
+ });
330
+ });
331
+ const resolveSpawnCommand = fn("shell.resolveSpawnCommand")(function* (command, args, options = {}) {
332
+ const platform = yield* HostProcessPlatform;
333
+ if (platform !== "win32") return {
334
+ command,
335
+ args: [...args],
336
+ shell: false
337
+ };
338
+ const hostEnvironment = yield* HostProcessEnvironment;
339
+ const env = options.env === void 0 ? hostEnvironment : options.extendEnv ? {
340
+ ...hostEnvironment,
341
+ ...options.env
342
+ } : options.env;
343
+ const resolvedCommand = (yield* SpawnExecutableResolution)(command, platform, env) ?? command;
344
+ const extension = NodePath.win32.extname(resolvedCommand).toLowerCase();
345
+ if (extension !== ".cmd" && extension !== ".bat") return {
346
+ command: resolvedCommand,
347
+ args: [...args],
348
+ shell: false
349
+ };
350
+ return {
351
+ command: escapeWindowsShellArg(resolvedCommand),
352
+ args: sanitizeShellModeArgsForPlatform(args, platform),
353
+ shell: true
354
+ };
355
+ });
356
+ const isCommandAvailable = fn("shell.isCommandAvailable")(function* (command, options = {}) {
357
+ return yield* resolveCommandPath(command, options).pipe(as(true), catchTag("CommandResolutionError", () => succeed(false)));
358
+ });
359
+ function resolveKnownWindowsCliDirs(env) {
360
+ const appData = env.APPDATA?.trim();
361
+ const localAppData = env.LOCALAPPDATA?.trim();
362
+ const userProfile = env.USERPROFILE?.trim();
363
+ return [
364
+ ...appData ? [`${appData}\\npm`] : [],
365
+ ...localAppData ? [`${localAppData}\\Programs\\nodejs`, `${localAppData}\\Volta\\bin`] : [],
366
+ ...localAppData ? [`${localAppData}\\pnpm`] : [],
367
+ ...userProfile ? [`${userProfile}\\.bun\\bin`, `${userProfile}\\scoop\\shims`] : []
368
+ ];
369
+ }
370
+ function readWindowsEnvironmentSafely(readEnvironment, names, options) {
371
+ try {
372
+ return readEnvironment(names, options);
373
+ } catch {
374
+ return {};
375
+ }
376
+ }
377
+ function mergeWindowsEnv(currentEnv, patch) {
378
+ const nextEnv = { ...currentEnv };
379
+ for (const [key, value] of Object.entries(patch)) if (value !== void 0) nextEnv[key] = value;
380
+ return nextEnv;
381
+ }
382
+ const resolveWindowsEnvironment = fn("shell.resolveWindowsEnvironment")(function* (env) {
383
+ const readEnvironment = yield* WindowsShellEnvironment;
384
+ const commandAvailable = yield* CommandAvailability;
385
+ const inheritedPath = readEnvPath(env);
386
+ const shellPath = readWindowsEnvironmentSafely(readEnvironment, ["PATH"], { loadProfile: false }).PATH;
387
+ const mergedPath = mergePathValues(shellPath, inheritedPath, "win32");
388
+ const baselinePath = mergePathValues(resolveKnownWindowsCliDirs(env).join(WINDOWS_PATH_DELIMITER), mergedPath, "win32");
389
+ const baselinePatch = baselinePath ? { PATH: baselinePath } : {};
390
+ if (yield* commandAvailable("node", { env: mergeWindowsEnv(env, baselinePatch) })) return baselinePatch;
391
+ const profiledEnvironment = readWindowsEnvironmentSafely(readEnvironment, [
392
+ "PATH",
393
+ "FNM_DIR",
394
+ "FNM_MULTISHELL_PATH"
395
+ ], { loadProfile: true });
396
+ const profiledPath = mergePathValues(profiledEnvironment.PATH, baselinePath, "win32");
397
+ const profiledPatch = {
398
+ ...profiledPath ? { PATH: profiledPath } : {},
399
+ ...profiledEnvironment.FNM_DIR ? { FNM_DIR: profiledEnvironment.FNM_DIR } : {},
400
+ ...profiledEnvironment.FNM_MULTISHELL_PATH ? { FNM_MULTISHELL_PATH: profiledEnvironment.FNM_MULTISHELL_PATH } : {}
401
+ };
402
+ return Object.keys(profiledPatch).length > 0 ? {
403
+ ...baselinePatch,
404
+ ...profiledPatch
405
+ } : baselinePatch;
406
+ });
407
+ //#endregion
408
+ export { CommandAvailability, CommandResolutionError, SpawnExecutableResolution, WindowsShellEnvironment, extractPathFromShellOutput, isCommandAvailable, listLoginShellCandidates, mergePathEntries, mergePathValues, readEnvironmentFromLoginShell, readEnvironmentFromWindowsShell, readPathFromLaunchctl, readPathFromLoginShell, resolveCommandPath, resolveKnownWindowsCliDirs, resolveSpawnCommand, resolveWindowsEnvironment };
@@ -0,0 +1,26 @@
1
+ import { _C as SourceControlProviderKind, gC as SourceControlProviderInfo } from "../shared.js";
2
+ //#region upstream-t3code/packages/shared/src/sourceControl.d.ts
3
+ interface ChangeRequestPresentation {
4
+ readonly icon: "github" | "gitlab" | "azure-devops" | "bitbucket" | "change-request";
5
+ readonly providerName: string;
6
+ readonly shortName: string;
7
+ readonly longName: string;
8
+ readonly pluralLongName: string;
9
+ readonly providerLongName: string;
10
+ readonly checkoutCommandExample?: string;
11
+ readonly urlExample: string;
12
+ }
13
+ interface ChangeRequestTerminology {
14
+ readonly shortLabel: string;
15
+ readonly singular: string;
16
+ }
17
+ declare const DEFAULT_CHANGE_REQUEST_TERMINOLOGY: ChangeRequestTerminology;
18
+ declare function resolveChangeRequestPresentation(provider: SourceControlProviderInfo | null | undefined): ChangeRequestPresentation;
19
+ declare function resolveChangeRequestPresentationForKind(kind: SourceControlProviderKind): ChangeRequestPresentation;
20
+ declare function formatChangeRequestAction(verb: "View" | "Create", presentation: ChangeRequestPresentation): string;
21
+ declare function formatCreateChangeRequestPhrase(presentation: ChangeRequestPresentation): string;
22
+ declare function getChangeRequestTerminology(provider: SourceControlProviderInfo | null | undefined): ChangeRequestTerminology;
23
+ declare function getChangeRequestTerminologyForKind(kind: SourceControlProviderKind): ChangeRequestTerminology;
24
+ declare function detectSourceControlProviderFromRemoteUrl(remoteUrl: string): SourceControlProviderInfo | null;
25
+ //#endregion
26
+ export { ChangeRequestPresentation, ChangeRequestTerminology, DEFAULT_CHANGE_REQUEST_TERMINOLOGY, detectSourceControlProviderFromRemoteUrl, formatChangeRequestAction, formatCreateChangeRequestPhrase, getChangeRequestTerminology, getChangeRequestTerminologyForKind, resolveChangeRequestPresentation, resolveChangeRequestPresentationForKind };
@@ -0,0 +1,2 @@
1
+ import { _t as resolveChangeRequestPresentationForKind, dt as detectSourceControlProviderFromRemoteUrl, ft as formatChangeRequestAction, gt as resolveChangeRequestPresentation, ht as getChangeRequestTerminologyForKind, mt as getChangeRequestTerminology, pt as formatCreateChangeRequestPhrase, ut as DEFAULT_CHANGE_REQUEST_TERMINOLOGY } from "../shared.js";
2
+ export { DEFAULT_CHANGE_REQUEST_TERMINOLOGY, detectSourceControlProviderFromRemoteUrl, formatChangeRequestAction, formatCreateChangeRequestPhrase, getChangeRequestTerminology, getChangeRequestTerminologyForKind, resolveChangeRequestPresentation, resolveChangeRequestPresentationForKind };
@@ -0,0 +1,27 @@
1
+ import * as Schema from "effect/Schema";
2
+ //#region upstream-t3code/packages/shared/src/t3ProjectFile.d.ts
3
+ /**
4
+ * Codec between the raw `t3.json` file contents (lenient JSONC string) and the
5
+ * decoded {@link T3ProjectFile}.
6
+ */
7
+ declare const T3ProjectFileFromJson: Schema.decodeTo<Schema.Struct<{
8
+ readonly $schema: Schema.optionalKey<Schema.String>;
9
+ readonly iconPath: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
10
+ readonly scripts: Schema.optionalKey<Schema.$Array<Schema.Struct<{
11
+ readonly name: Schema.decodeTo<Schema.String, Schema.String, never, never>;
12
+ readonly command: Schema.decodeTo<Schema.String, Schema.String, never, never>;
13
+ readonly icon: Schema.optionalKey<Schema.Literals<readonly ["play", "test", "lint", "configure", "build", "debug"]>>;
14
+ readonly runOnWorktreeCreate: Schema.optionalKey<Schema.Boolean>;
15
+ readonly previewUrl: Schema.optionalKey<Schema.decodeTo<Schema.String, Schema.String, never, never>>;
16
+ readonly autoOpenPreview: Schema.optionalKey<Schema.Boolean>;
17
+ }>>>;
18
+ }>, Schema.String, never, never>;
19
+ /**
20
+ * Build the publishable JSON Schema document for `t3.json` (draft 2020-12).
21
+ *
22
+ * Served from the marketing site at {@link T3_PROJECT_FILE_SCHEMA_URL} so
23
+ * editors get LSP support via a `$schema` reference.
24
+ */
25
+ declare function buildT3ProjectFileJsonSchema(): Record<string, unknown>;
26
+ //#endregion
27
+ export { T3ProjectFileFromJson, buildT3ProjectFileJsonSchema };
@@ -0,0 +1,25 @@
1
+ import { Iu as T3ProjectFile, fE as toJsonSchemaDocument, g as fromLenientJson, zu as T3_PROJECT_FILE_SCHEMA_URL } from "../shared.js";
2
+ //#region upstream-t3code/packages/shared/src/t3ProjectFile.ts
3
+ /**
4
+ * Codec between the raw `t3.json` file contents (lenient JSONC string) and the
5
+ * decoded {@link T3ProjectFile}.
6
+ */
7
+ const T3ProjectFileFromJson = fromLenientJson(T3ProjectFile);
8
+ /**
9
+ * Build the publishable JSON Schema document for `t3.json` (draft 2020-12).
10
+ *
11
+ * Served from the marketing site at {@link T3_PROJECT_FILE_SCHEMA_URL} so
12
+ * editors get LSP support via a `$schema` reference.
13
+ */
14
+ function buildT3ProjectFileJsonSchema() {
15
+ const document = toJsonSchemaDocument(T3ProjectFile);
16
+ const jsonSchema = {
17
+ $schema: "https://json-schema.org/draft/2020-12/schema",
18
+ $id: T3_PROJECT_FILE_SCHEMA_URL,
19
+ ...document.schema
20
+ };
21
+ if (document.definitions && Object.keys(document.definitions).length > 0) jsonSchema.$defs = document.definitions;
22
+ return jsonSchema;
23
+ }
24
+ //#endregion
25
+ export { T3ProjectFileFromJson, buildT3ProjectFileJsonSchema };
@@ -0,0 +1,16 @@
1
+ import { ix as TerminalSummary } from "../shared.js";
2
+ //#region upstream-t3code/packages/shared/src/terminalLabels.d.ts
3
+ /** Human-readable label for a terminal tab; matches mobile and web sidebars. */
4
+ declare function getTerminalLabel(terminalId: string): string;
5
+ /** Prefer server summary label when present; otherwise fall back to `getTerminalLabel`. */
6
+ declare function resolveTerminalSessionLabel(terminalId: string, summary: Pick<TerminalSummary, "label"> | null | undefined): string;
7
+ /**
8
+ * Client-side terminal id allocator. Ids are ALWAYS chosen by the client and sent explicitly
9
+ * on every `terminal.open` / `terminal.attach` call — the server never allocates.
10
+ *
11
+ * Returns the lowest unused `term-N` id (starting at `term-1`), skipping any ids already in
12
+ * `existingTerminalIds`.
13
+ */
14
+ declare function nextTerminalId(existingTerminalIds: ReadonlyArray<string>): string;
15
+ //#endregion
16
+ export { getTerminalLabel, nextTerminalId, resolveTerminalSessionLabel };
@@ -0,0 +1,28 @@
1
+ //#region upstream-t3code/packages/shared/src/terminalLabels.ts
2
+ /** Human-readable label for a terminal tab; matches mobile and web sidebars. */
3
+ function getTerminalLabel(terminalId) {
4
+ const numericSuffix = /^term(?:inal)?-(\d+)$/i.exec(terminalId)?.[1];
5
+ if (numericSuffix) return `Terminal ${numericSuffix}`;
6
+ return terminalId;
7
+ }
8
+ /** Prefer server summary label when present; otherwise fall back to `getTerminalLabel`. */
9
+ function resolveTerminalSessionLabel(terminalId, summary) {
10
+ const trimmed = summary?.label?.trim();
11
+ if (trimmed && trimmed.length > 0) return trimmed;
12
+ return getTerminalLabel(terminalId);
13
+ }
14
+ /**
15
+ * Client-side terminal id allocator. Ids are ALWAYS chosen by the client and sent explicitly
16
+ * on every `terminal.open` / `terminal.attach` call — the server never allocates.
17
+ *
18
+ * Returns the lowest unused `term-N` id (starting at `term-1`), skipping any ids already in
19
+ * `existingTerminalIds`.
20
+ */
21
+ function nextTerminalId(existingTerminalIds) {
22
+ const usedIds = new Set(existingTerminalIds.filter((id) => id.trim().length > 0));
23
+ let nextIndex = 1;
24
+ while (usedIds.has(`term-${nextIndex}`)) nextIndex += 1;
25
+ return `term-${nextIndex}`;
26
+ }
27
+ //#endregion
28
+ export { getTerminalLabel, nextTerminalId, resolveTerminalSessionLabel };
@@ -0,0 +1,16 @@
1
+ import { jp as ToolLifecycleItemType } from "../shared.js";
2
+ //#region upstream-t3code/packages/shared/src/toolActivity.d.ts
3
+ interface ToolActivityPresentationInput {
4
+ readonly itemType?: ToolLifecycleItemType | null | undefined;
5
+ readonly title?: string | null | undefined;
6
+ readonly detail?: string | null | undefined;
7
+ readonly data?: unknown;
8
+ readonly fallbackSummary?: string | null | undefined;
9
+ }
10
+ interface ToolActivityPresentation {
11
+ readonly summary: string;
12
+ readonly detail?: string | undefined;
13
+ }
14
+ declare function deriveToolActivityPresentation(input: ToolActivityPresentationInput): ToolActivityPresentation;
15
+ //#endregion
16
+ export { ToolActivityPresentation, ToolActivityPresentationInput, deriveToolActivityPresentation };