t3code-cli 0.10.0 → 0.12.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 (328) hide show
  1. package/README.md +75 -11
  2. package/dist/application.js +2 -2
  3. package/dist/auth.js +1 -1
  4. package/dist/bin.js +86754 -2675
  5. package/dist/cli.js +15 -2
  6. package/dist/config.js +120 -2
  7. package/dist/connection.js +2 -12
  8. package/dist/index.js +1 -1
  9. package/dist/node.js +6 -0
  10. package/dist/orchestration.js +2 -2
  11. package/dist/rpc.js +2 -2
  12. package/dist/runtime.js +2 -2
  13. package/dist/shared.js +43850 -38040
  14. package/dist/src/application/actions.d.ts +25 -0
  15. package/dist/src/application/index.d.ts +3 -2
  16. package/dist/src/application/layer.d.ts +99 -842
  17. package/dist/src/application/model-selection.d.ts +17 -2
  18. package/dist/src/application/models.d.ts +1 -87
  19. package/dist/src/application/project-commands.d.ts +31 -2
  20. package/dist/src/application/projects.d.ts +15 -137
  21. package/dist/src/application/service.d.ts +147 -5
  22. package/dist/src/application/shell-sequence.d.ts +5 -4
  23. package/dist/src/application/terminals.d.ts +66 -0
  24. package/dist/src/application/thread-commands.d.ts +48 -1
  25. package/dist/src/application/thread-update.d.ts +8 -0
  26. package/dist/src/application/thread-wait.d.ts +4 -6
  27. package/dist/src/application/threads.d.ts +36 -14
  28. package/dist/src/auth/error.d.ts +2 -1
  29. package/dist/src/auth/index.d.ts +1 -1
  30. package/dist/src/auth/layer.d.ts +34 -6
  31. package/dist/src/auth/local-base-dir.d.ts +5 -2
  32. package/dist/src/auth/local-origin.d.ts +3 -3
  33. package/dist/src/auth/local-token.d.ts +3 -3
  34. package/dist/src/auth/service.d.ts +15 -3
  35. package/dist/src/auth/type.d.ts +40 -1
  36. package/dist/src/cli/env/flag.d.ts +2 -0
  37. package/dist/src/cli/env/index.d.ts +2 -0
  38. package/dist/src/cli/env/selection-layer.d.ts +3 -0
  39. package/dist/src/cli/flags.d.ts +5 -0
  40. package/dist/src/cli/format/index.d.ts +1 -0
  41. package/dist/src/cli/format/output.d.ts +12 -0
  42. package/dist/src/cli/index.d.ts +4 -0
  43. package/dist/src/cli/runtime/index.d.ts +1 -0
  44. package/dist/src/cli/runtime/service.d.ts +16 -0
  45. package/dist/src/{scope → cli/scope}/resolve.d.ts +5 -4
  46. package/dist/src/config/config.d.ts +49 -0
  47. package/dist/src/config/credential/cipher-node.d.ts +3 -0
  48. package/dist/src/config/credential/cipher-web.d.ts +3 -0
  49. package/dist/src/config/credential/cipher.d.ts +29 -0
  50. package/dist/src/config/credential/env.d.ts +3 -0
  51. package/dist/src/config/credential/error.d.ts +8 -0
  52. package/dist/src/config/credential/index.d.ts +6 -0
  53. package/dist/src/config/credential/service.d.ts +34 -0
  54. package/dist/src/config/env/env.d.ts +55 -0
  55. package/dist/src/config/env/index.d.ts +2 -0
  56. package/dist/src/{layout/base-dir.d.ts → config/env/layout.d.ts} +0 -1
  57. package/dist/src/config/environment-name/index.d.ts +1 -0
  58. package/dist/src/config/environment-name/name.d.ts +10 -0
  59. package/dist/src/config/error.d.ts +4 -11
  60. package/dist/src/config/index.d.ts +10 -5
  61. package/dist/src/config/keystore/error.d.ts +8 -0
  62. package/dist/src/config/keystore/file.d.ts +9 -0
  63. package/dist/src/config/keystore/index.d.ts +4 -0
  64. package/dist/src/config/keystore/keyring-node.d.ts +4 -0
  65. package/dist/src/config/keystore/service.d.ts +33 -0
  66. package/dist/src/config/paths/index.d.ts +1 -0
  67. package/dist/src/config/paths/paths.d.ts +6 -0
  68. package/dist/src/config/persist/file-mode.d.ts +4 -0
  69. package/dist/src/config/persist/migration.d.ts +68 -0
  70. package/dist/src/config/persist/persist.d.ts +40 -0
  71. package/dist/src/config/persist/schema.d.ts +68 -0
  72. package/dist/src/config/resolve/resolve.d.ts +40 -0
  73. package/dist/src/config/selection/index.d.ts +1 -0
  74. package/dist/src/config/selection/resolve.d.ts +4 -0
  75. package/dist/src/config/selection/service.d.ts +10 -0
  76. package/dist/src/config/types.d.ts +36 -0
  77. package/dist/src/config/url/error.d.ts +10 -0
  78. package/dist/src/config/url/index.d.ts +2 -0
  79. package/dist/src/connection/index.d.ts +0 -1
  80. package/dist/src/contracts/index.d.ts +1 -1
  81. package/dist/src/domain/error.d.ts +27 -1
  82. package/dist/src/domain/helpers.d.ts +8 -2
  83. package/dist/src/domain/model-config.d.ts +30 -1
  84. package/dist/src/domain/thread-activities.d.ts +1 -1
  85. package/dist/src/domain/thread-lifecycle.d.ts +3 -2
  86. package/dist/src/index.d.ts +1 -2
  87. package/dist/src/{connection/node.d.ts → node/connection.d.ts} +1 -1
  88. package/dist/src/node/index.d.ts +1 -0
  89. package/dist/src/orchestration/index.d.ts +1 -1
  90. package/dist/src/orchestration/layer.d.ts +120 -829
  91. package/dist/src/orchestration/service.d.ts +2 -1
  92. package/dist/src/rpc/error.d.ts +5 -3
  93. package/dist/src/rpc/index.d.ts +5 -1
  94. package/dist/src/rpc/layer.d.ts +1166 -40
  95. package/dist/src/rpc/operation.d.ts +6280 -0
  96. package/dist/src/rpc/ws-group.d.ts +372 -27
  97. package/dist/src/runtime/index.d.ts +1 -2
  98. package/dist/src/runtime/layer.d.ts +12 -8
  99. package/dist/src/t3tools/index.d.ts +1 -1
  100. package/dist/t3tools.js +2 -2
  101. package/package.json +27 -19
  102. package/src/application/actions.test.ts +328 -0
  103. package/src/application/actions.ts +475 -0
  104. package/src/application/index.ts +32 -2
  105. package/src/application/layer.ts +43 -5
  106. package/src/application/model-selection.ts +70 -4
  107. package/src/application/models.ts +14 -14
  108. package/src/application/project-commands.ts +38 -5
  109. package/src/application/projects.ts +49 -20
  110. package/src/application/service.ts +275 -78
  111. package/src/application/shell-sequence.ts +6 -8
  112. package/src/application/terminals.ts +208 -0
  113. package/src/application/thread-commands.test.ts +43 -0
  114. package/src/application/thread-commands.ts +82 -1
  115. package/src/application/thread-update.ts +72 -0
  116. package/src/application/thread-wait.ts +47 -48
  117. package/src/application/threads.test.ts +172 -0
  118. package/src/application/threads.ts +128 -45
  119. package/src/auth/error.ts +2 -1
  120. package/src/auth/index.ts +7 -0
  121. package/src/auth/layer.test-utils.ts +34 -0
  122. package/src/auth/layer.ts +116 -34
  123. package/src/auth/local-base-dir.ts +13 -6
  124. package/src/auth/local-origin.ts +10 -7
  125. package/src/auth/local-token.ts +28 -23
  126. package/src/auth/service.test.ts +200 -0
  127. package/src/auth/service.ts +27 -3
  128. package/src/auth/transport.ts +2 -2
  129. package/src/auth/type.ts +47 -1
  130. package/src/bin.ts +26 -6
  131. package/src/cli/action-format.ts +110 -0
  132. package/src/cli/action.ts +398 -0
  133. package/src/cli/app.ts +8 -0
  134. package/src/cli/auth.ts +76 -23
  135. package/src/cli/env/flag.ts +8 -0
  136. package/src/cli/env/index.ts +2 -0
  137. package/src/cli/env/selection-layer.test.ts +49 -0
  138. package/src/cli/env/selection-layer.ts +27 -0
  139. package/src/cli/env.ts +107 -0
  140. package/src/cli/error.ts +26 -3
  141. package/src/cli/extra-args.test.ts +32 -0
  142. package/src/cli/extra-args.ts +22 -0
  143. package/src/cli/flags.ts +26 -1
  144. package/src/cli/format/auth.ts +92 -0
  145. package/src/cli/format/human.ts +131 -0
  146. package/src/cli/format/index.ts +12 -0
  147. package/src/cli/format/model.ts +29 -0
  148. package/src/cli/format/output.ts +51 -0
  149. package/src/cli/format/project.ts +32 -0
  150. package/src/cli/format/terminal.ts +87 -0
  151. package/src/cli/format/thread.test.ts +34 -0
  152. package/src/cli/format/thread.ts +185 -0
  153. package/src/cli/index.ts +20 -0
  154. package/src/cli/input/layer.ts +20 -0
  155. package/src/cli/input/service.ts +1 -0
  156. package/src/cli/interaction/confirm.ts +64 -0
  157. package/src/cli/interaction/self-action.ts +36 -0
  158. package/src/cli/message-input.ts +1 -1
  159. package/src/cli/model.ts +9 -5
  160. package/src/cli/project.ts +15 -8
  161. package/src/cli/projects/delete.ts +51 -0
  162. package/src/cli/require.ts +9 -7
  163. package/src/cli/runtime/index.ts +1 -0
  164. package/src/cli/runtime/service.ts +28 -0
  165. package/src/{scope → cli/scope}/resolve.ts +11 -9
  166. package/src/cli/terminal/attach.ts +29 -0
  167. package/src/cli/terminal/create.ts +55 -0
  168. package/src/cli/terminal/destroy.ts +62 -0
  169. package/src/cli/terminal/encoding.test.ts +63 -0
  170. package/src/cli/terminal/encoding.ts +23 -0
  171. package/src/cli/terminal/error.ts +14 -0
  172. package/src/cli/terminal/io-node-layer.ts +82 -0
  173. package/src/cli/terminal/io-service.ts +25 -0
  174. package/src/cli/terminal/list.ts +36 -0
  175. package/src/cli/terminal/read.test-utils.ts +48 -0
  176. package/src/cli/terminal/read.test.ts +35 -0
  177. package/src/cli/terminal/read.ts +99 -0
  178. package/src/cli/terminal/scope.ts +35 -0
  179. package/src/cli/terminal/shared.ts +250 -0
  180. package/src/cli/terminal/stream.ts +61 -0
  181. package/src/cli/terminal/wait.test.ts +148 -0
  182. package/src/cli/terminal/wait.ts +223 -0
  183. package/src/cli/terminal/write.test.ts +34 -0
  184. package/src/cli/terminal/write.ts +133 -0
  185. package/src/cli/terminal.ts +26 -0
  186. package/src/cli/thread.ts +8 -0
  187. package/src/cli/threads/approve.ts +11 -7
  188. package/src/cli/threads/archive.ts +23 -25
  189. package/src/cli/threads/callback.ts +6 -4
  190. package/src/cli/threads/delete.ts +67 -0
  191. package/src/cli/threads/interrupt.ts +57 -0
  192. package/src/cli/threads/list.test.ts +71 -0
  193. package/src/cli/threads/list.ts +25 -13
  194. package/src/cli/threads/messages.ts +11 -7
  195. package/src/cli/threads/respond.ts +11 -7
  196. package/src/cli/threads/send.ts +39 -9
  197. package/src/cli/threads/show.ts +11 -7
  198. package/src/cli/threads/start.ts +18 -13
  199. package/src/cli/threads/unarchive.ts +48 -0
  200. package/src/cli/threads/update.ts +155 -0
  201. package/src/cli/threads/wait.ts +11 -7
  202. package/src/cli/wait-events.ts +1 -1
  203. package/src/config/config.ts +260 -0
  204. package/src/config/credential/cipher-node.ts +40 -0
  205. package/src/config/credential/cipher-web.ts +82 -0
  206. package/src/config/credential/cipher.ts +39 -0
  207. package/src/config/credential/env.ts +13 -0
  208. package/src/config/credential/error.ts +9 -0
  209. package/src/config/credential/index.ts +6 -0
  210. package/src/config/credential/service.test-utils.ts +25 -0
  211. package/src/config/credential/service.test.ts +116 -0
  212. package/src/config/credential/service.ts +205 -0
  213. package/src/config/env/env.test-utils.ts +14 -0
  214. package/src/config/env/env.ts +81 -0
  215. package/src/config/env/index.ts +2 -0
  216. package/src/{layout/base-dir.ts → config/env/layout.ts} +0 -9
  217. package/src/config/environment-name/index.ts +7 -0
  218. package/src/config/environment-name/name.test.ts +66 -0
  219. package/src/config/environment-name/name.ts +49 -0
  220. package/src/config/error.ts +6 -8
  221. package/src/config/index.ts +16 -5
  222. package/src/config/keystore/error.ts +9 -0
  223. package/src/config/keystore/file.ts +96 -0
  224. package/src/config/keystore/index.ts +4 -0
  225. package/src/config/keystore/keyring-node.test.ts +12 -0
  226. package/src/config/keystore/keyring-node.ts +100 -0
  227. package/src/config/keystore/service.test-utils.ts +15 -0
  228. package/src/config/keystore/service.test.ts +18 -0
  229. package/src/config/keystore/service.ts +29 -0
  230. package/src/config/layer.test-utils.ts +45 -0
  231. package/src/config/layer.test.ts +209 -0
  232. package/src/config/paths/index.ts +1 -0
  233. package/src/config/paths/paths.ts +36 -0
  234. package/src/config/persist/file-mode.ts +21 -0
  235. package/src/config/persist/migration.test.ts +71 -0
  236. package/src/config/persist/migration.ts +82 -0
  237. package/src/config/persist/persist.test.ts +113 -0
  238. package/src/config/persist/persist.ts +65 -0
  239. package/src/config/persist/schema.ts +37 -0
  240. package/src/config/platform.test-utils.ts +20 -0
  241. package/src/config/resolve/resolve.test-utils.ts +20 -0
  242. package/src/config/resolve/resolve.test.ts +137 -0
  243. package/src/config/resolve/resolve.ts +104 -0
  244. package/src/config/selection/index.ts +1 -0
  245. package/src/config/selection/resolve.ts +14 -0
  246. package/src/config/selection/service.ts +29 -0
  247. package/src/config/temp-home.test-utils.ts +7 -0
  248. package/src/config/types.ts +49 -0
  249. package/src/config/url/error.ts +8 -0
  250. package/src/config/url/index.ts +7 -0
  251. package/src/config/url/url.test.ts +31 -0
  252. package/src/connection/index.ts +0 -1
  253. package/src/contracts/index.ts +1 -1
  254. package/src/domain/error.ts +39 -1
  255. package/src/domain/helpers.test.ts +1 -1
  256. package/src/domain/helpers.ts +1 -1
  257. package/src/domain/model-config.ts +5 -1
  258. package/src/domain/thread-activities.test.ts +1 -1
  259. package/src/domain/thread-activities.ts +1 -1
  260. package/src/domain/thread-lifecycle.test.ts +1 -1
  261. package/src/domain/thread-lifecycle.ts +15 -1
  262. package/src/effect.test-utils.ts +25 -0
  263. package/src/index.ts +1 -1
  264. package/src/{connection/node.ts → node/connection.ts} +1 -1
  265. package/src/node/index.ts +1 -0
  266. package/src/orchestration/index.ts +1 -1
  267. package/src/orchestration/layer.ts +34 -86
  268. package/src/orchestration/service.ts +5 -1
  269. package/src/rpc/error.ts +12 -2
  270. package/src/rpc/index.ts +5 -1
  271. package/src/rpc/layer.ts +1 -1
  272. package/src/rpc/operation.ts +83 -0
  273. package/src/rpc/ws-group.ts +25 -1
  274. package/src/runtime/index.ts +2 -1
  275. package/src/runtime/layer.test-utils.ts +32 -0
  276. package/src/runtime/layer.test.ts +66 -0
  277. package/src/runtime/layer.ts +22 -11
  278. package/src/t3tools/index.ts +1 -1
  279. package/src/types/marked-terminal.d.ts +11 -0
  280. package/dist/layout.js +0 -2
  281. package/dist/scope.js +0 -2
  282. package/dist/src/cli/output-format.d.ts +0 -9
  283. package/dist/src/config/layer.d.ts +0 -22
  284. package/dist/src/config/service.d.ts +0 -22
  285. package/dist/src/environment/layer.d.ts +0 -3
  286. package/dist/src/environment/service.d.ts +0 -12
  287. package/dist/src/layout/index.d.ts +0 -1
  288. package/dist/upstream-t3code/packages/contracts/src/auth.d.ts +0 -441
  289. package/dist/upstream-t3code/packages/contracts/src/baseSchemas.d.ts +0 -38
  290. package/dist/upstream-t3code/packages/contracts/src/desktopBootstrap.d.ts +0 -14
  291. package/dist/upstream-t3code/packages/contracts/src/editor.d.ts +0 -124
  292. package/dist/upstream-t3code/packages/contracts/src/environment.d.ts +0 -64
  293. package/dist/upstream-t3code/packages/contracts/src/environmentHttp.d.ts +0 -785
  294. package/dist/upstream-t3code/packages/contracts/src/filesystem.d.ts +0 -26
  295. package/dist/upstream-t3code/packages/contracts/src/git.d.ts +0 -500
  296. package/dist/upstream-t3code/packages/contracts/src/index.d.ts +0 -25
  297. package/dist/upstream-t3code/packages/contracts/src/ipc.d.ts +0 -496
  298. package/dist/upstream-t3code/packages/contracts/src/keybindings.d.ts +0 -133
  299. package/dist/upstream-t3code/packages/contracts/src/model.d.ts +0 -112
  300. package/dist/upstream-t3code/packages/contracts/src/orchestration.d.ts +0 -7338
  301. package/dist/upstream-t3code/packages/contracts/src/project.d.ts +0 -45
  302. package/dist/upstream-t3code/packages/contracts/src/provider.d.ts +0 -130
  303. package/dist/upstream-t3code/packages/contracts/src/providerInstance.d.ts +0 -99
  304. package/dist/upstream-t3code/packages/contracts/src/providerRuntime.d.ts +0 -4450
  305. package/dist/upstream-t3code/packages/contracts/src/relay.d.ts +0 -1262
  306. package/dist/upstream-t3code/packages/contracts/src/relayClient.d.ts +0 -48
  307. package/dist/upstream-t3code/packages/contracts/src/remoteAccess.d.ts +0 -45
  308. package/dist/upstream-t3code/packages/contracts/src/review.d.ts +0 -37
  309. package/dist/upstream-t3code/packages/contracts/src/rpc.d.ts +0 -8710
  310. package/dist/upstream-t3code/packages/contracts/src/server.d.ts +0 -2336
  311. package/dist/upstream-t3code/packages/contracts/src/settings.d.ts +0 -292
  312. package/dist/upstream-t3code/packages/contracts/src/sourceControl.d.ts +0 -177
  313. package/dist/upstream-t3code/packages/contracts/src/terminal.d.ts +0 -333
  314. package/dist/upstream-t3code/packages/contracts/src/vcs.d.ts +0 -148
  315. package/src/cli/auth-format.ts +0 -45
  316. package/src/cli/model-format.ts +0 -18
  317. package/src/cli/output-format.ts +0 -41
  318. package/src/cli/project-format.ts +0 -11
  319. package/src/cli/thread-format.ts +0 -121
  320. package/src/config/layer.ts +0 -105
  321. package/src/config/service.ts +0 -26
  322. package/src/environment/layer.ts +0 -12
  323. package/src/environment/service.ts +0 -13
  324. package/src/layout/index.ts +0 -1
  325. /package/dist/src/{scope → cli/scope}/index.d.ts +0 -0
  326. /package/dist/src/config/{url.d.ts → url/url.d.ts} +0 -0
  327. /package/src/{scope → cli/scope}/index.ts +0 -0
  328. /package/src/config/{url.ts → url/url.ts} +0 -0
@@ -2,25 +2,25 @@ import * as Effect from "effect/Effect";
2
2
 
3
3
  import { filterProvidersForModelListing } from "../domain/model-config.ts";
4
4
  import { T3Orchestration } from "../orchestration/service.ts";
5
+ import type { T3ModelApplicationService } from "./service.ts";
5
6
 
6
7
  export const makeModelsApplication = Effect.fn("makeModelsApplication")(function* () {
7
8
  const orchestration = yield* T3Orchestration;
8
9
 
9
- const listModels = Effect.fn("T3Application.listModels")(function* (input: {
10
- readonly all?: boolean;
11
- readonly provider?: string;
12
- }) {
13
- const config = yield* orchestration.getServerConfig();
14
- return filterProvidersForModelListing({
15
- providers: config.providers,
16
- all: input.all === true,
17
- ...(input.provider !== undefined && input.provider.length > 0
18
- ? { provider: input.provider }
19
- : {}),
20
- });
21
- });
10
+ const listModels: T3ModelApplicationService["listModels"] = Effect.fn("T3Application.listModels")(
11
+ function* (input: { readonly all?: boolean; readonly provider?: string }) {
12
+ const config = yield* orchestration.getServerConfig();
13
+ return filterProvidersForModelListing({
14
+ providers: config.providers,
15
+ all: input.all === true,
16
+ ...(input.provider !== undefined && input.provider.length > 0
17
+ ? { provider: input.provider }
18
+ : {}),
19
+ });
20
+ },
21
+ );
22
22
 
23
23
  return {
24
24
  listModels,
25
- };
25
+ } satisfies T3ModelApplicationService;
26
26
  });
@@ -2,18 +2,16 @@ import * as Crypto from "effect/Crypto";
2
2
  import * as DateTime from "effect/DateTime";
3
3
  import * as Effect from "effect/Effect";
4
4
  import * as Path from "effect/Path";
5
- import { CommandId, ProjectId, type ClientOrchestrationCommand } from "#t3tools/contracts";
6
-
7
- import { Environment } from "../environment/service.ts";
5
+ import { CommandId, ProjectId, type ClientOrchestrationCommand } from "@t3tools/contracts";
8
6
 
9
7
  export const makeProjectCreateCommand = Effect.fn("makeProjectCreateCommand")(function* (input: {
10
8
  readonly path: string;
11
9
  readonly title?: string;
10
+ readonly cwd: string;
12
11
  }) {
13
12
  const path = yield* Path.Path;
14
13
  const crypto = yield* Crypto.Crypto;
15
- const environment = yield* Environment;
16
- const workspaceRoot = path.resolve(environment.cwd, input.path);
14
+ const workspaceRoot = path.resolve(input.cwd, input.path);
17
15
  const projectId = ProjectId.make(yield* crypto.randomUUIDv4.pipe(Effect.orDie));
18
16
  const title = input.title?.trim();
19
17
  const createdAt = DateTime.formatIso(yield* DateTime.now);
@@ -28,3 +26,38 @@ export const makeProjectCreateCommand = Effect.fn("makeProjectCreateCommand")(fu
28
26
  createdAt,
29
27
  } satisfies Extract<ClientOrchestrationCommand, { readonly type: "project.create" }>;
30
28
  });
29
+
30
+ export const makeProjectDeleteCommand = Effect.fn("makeProjectDeleteCommand")(function* (input: {
31
+ readonly projectId: string;
32
+ readonly force?: boolean;
33
+ }) {
34
+ const crypto = yield* Crypto.Crypto;
35
+ return {
36
+ type: "project.delete",
37
+ commandId: CommandId.make(
38
+ `t3cli:project-delete:${yield* crypto.randomUUIDv4.pipe(Effect.orDie)}`,
39
+ ),
40
+ projectId: ProjectId.make(input.projectId),
41
+ ...(input.force === true ? { force: true } : {}),
42
+ } satisfies Extract<ClientOrchestrationCommand, { readonly type: "project.delete" }>;
43
+ });
44
+
45
+ export const makeProjectMetaUpdateCommand = Effect.fn("makeProjectMetaUpdateCommand")(
46
+ function* (input: {
47
+ readonly projectId: string;
48
+ readonly scripts: Extract<
49
+ ClientOrchestrationCommand,
50
+ { readonly type: "project.meta.update" }
51
+ >["scripts"];
52
+ }) {
53
+ const crypto = yield* Crypto.Crypto;
54
+ return {
55
+ type: "project.meta.update",
56
+ commandId: CommandId.make(
57
+ `t3cli:project-meta-update:${yield* crypto.randomUUIDv4.pipe(Effect.orDie)}`,
58
+ ),
59
+ projectId: ProjectId.make(input.projectId),
60
+ scripts: input.scripts,
61
+ } satisfies Extract<ClientOrchestrationCommand, { readonly type: "project.meta.update" }>;
62
+ },
63
+ );
@@ -2,35 +2,52 @@ import * as Crypto from "effect/Crypto";
2
2
  import * as Effect from "effect/Effect";
3
3
  import * as Path from "effect/Path";
4
4
 
5
- import { Environment } from "../environment/service.ts";
5
+ import { CliRuntime } from "../cli/runtime/service.ts";
6
6
  import { T3Orchestration } from "../orchestration/service.ts";
7
- import { ProjectCreateVisibilityError } from "../domain/error.ts";
8
- import { findProjectById } from "../domain/helpers.ts";
9
- import { makeProjectCreateCommand } from "./project-commands.ts";
7
+ import { ProjectCreateVisibilityError, ProjectLookupError } from "../domain/error.ts";
8
+ import { findProjectById, resolveProjectScope } from "../domain/helpers.ts";
9
+ import { makeProjectCreateCommand, makeProjectDeleteCommand } from "./project-commands.ts";
10
10
  import { waitForShellSequence } from "./shell-sequence.ts";
11
+ import type { T3ProjectApplicationService } from "./service.ts";
11
12
 
12
13
  export const makeProjectApplication = Effect.fn("makeProjectApplication")(function* () {
13
14
  const orchestration = yield* T3Orchestration;
14
15
  const crypto = yield* Crypto.Crypto;
15
16
  const path = yield* Path.Path;
16
- const environment = yield* Environment;
17
- const loadShell = Effect.fn("T3ApplicationLive.loadShell")(function* () {
17
+ const cliRuntime = yield* CliRuntime;
18
+ const loadShell: T3ProjectApplicationService["loadShell"] = Effect.fn(
19
+ "T3ApplicationLive.loadShell",
20
+ )(function* () {
18
21
  return yield* orchestration.getShellSnapshot();
19
22
  });
20
- const addProject = Effect.fn("T3ApplicationLive.addProject")(function* (projectInput: {
21
- readonly path: string;
22
- readonly title?: string;
23
- }) {
24
- const command = yield* makeProjectCreateCommand(projectInput).pipe(
25
- Effect.provideService(Path.Path, path),
26
- Effect.provideService(Crypto.Crypto, crypto),
27
- Effect.provideService(Environment, environment),
28
- );
23
+ const resolveProject: T3ProjectApplicationService["resolveProject"] = Effect.fn(
24
+ "T3ApplicationLive.resolveProject",
25
+ )(function* (projectRef: string) {
26
+ const snapshot = yield* orchestration.getShellSnapshot();
27
+ const scope = yield* resolveProjectScope(snapshot, {
28
+ ref: projectRef,
29
+ }).pipe(Effect.provideService(Path.Path, path));
30
+ if (scope === undefined) {
31
+ return yield* Effect.fail(
32
+ new ProjectLookupError({
33
+ message: `project not found: ${projectRef}`,
34
+ ref: projectRef,
35
+ }),
36
+ );
37
+ }
38
+ return scope.project;
39
+ });
40
+ const addProject: T3ProjectApplicationService["addProject"] = Effect.fn(
41
+ "T3ApplicationLive.addProject",
42
+ )(function* (projectInput: { readonly path: string; readonly title?: string }) {
43
+ const command = yield* makeProjectCreateCommand({
44
+ ...projectInput,
45
+ cwd: cliRuntime.cwd,
46
+ }).pipe(Effect.provideService(Path.Path, path), Effect.provideService(Crypto.Crypto, crypto));
29
47
  const dispatch = yield* orchestration.dispatch(command);
30
- const snapshot = yield* waitForShellSequence({
31
- orchestration,
32
- sequence: dispatch.sequence,
33
- });
48
+ const snapshot = yield* waitForShellSequence({ sequence: dispatch.sequence }).pipe(
49
+ Effect.provideService(T3Orchestration, orchestration),
50
+ );
34
51
  const project = findProjectById(snapshot, command.projectId);
35
52
  if (project === null) {
36
53
  return yield* Effect.fail(
@@ -42,9 +59,21 @@ export const makeProjectApplication = Effect.fn("makeProjectApplication")(functi
42
59
  }
43
60
  return { dispatch, project };
44
61
  });
62
+ const deleteProject: T3ProjectApplicationService["deleteProject"] = Effect.fn(
63
+ "T3ApplicationLive.deleteProject",
64
+ )(function* (input: { readonly projectId: string; readonly force?: boolean }) {
65
+ const command = yield* makeProjectDeleteCommand({
66
+ projectId: input.projectId,
67
+ ...(input.force === true ? { force: true } : {}),
68
+ }).pipe(Effect.provideService(Crypto.Crypto, crypto));
69
+ const dispatch = yield* orchestration.dispatch(command);
70
+ return { projectId: input.projectId, dispatch };
71
+ });
45
72
 
46
73
  return {
47
74
  loadShell,
48
75
  addProject,
49
- };
76
+ resolveProject,
77
+ deleteProject,
78
+ } satisfies T3ProjectApplicationService;
50
79
  });
@@ -9,9 +9,15 @@ import type {
9
9
  OrchestrationShellSnapshot,
10
10
  OrchestrationThread,
11
11
  OrchestrationThreadShell,
12
+ ProjectScript,
13
+ ProjectScriptIcon,
12
14
  ProviderUserInputAnswers,
13
15
  ServerProvider,
14
- } from "#t3tools/contracts";
16
+ TerminalAttachStreamEvent,
17
+ TerminalMetadataStreamEvent,
18
+ TerminalSessionSnapshot,
19
+ TerminalSummary,
20
+ } from "@t3tools/contracts";
15
21
 
16
22
  import type { ApplicationError } from "./error.ts";
17
23
  import type { ThreadShow } from "./threads.ts";
@@ -26,6 +32,23 @@ export type StartThreadInput = {
26
32
  readonly worktreePath?: string;
27
33
  };
28
34
 
35
+ export type CreateTerminalInput = {
36
+ readonly threadId: string;
37
+ readonly terminalId?: string;
38
+ readonly command?: string;
39
+ readonly env?: Readonly<Record<string, string>>;
40
+ };
41
+
42
+ export type TerminalRef = {
43
+ readonly threadId: string;
44
+ readonly terminalId: string;
45
+ };
46
+
47
+ export type TerminalAttachTarget = TerminalRef & {
48
+ readonly cwd: string;
49
+ readonly worktreePath: string | null;
50
+ };
51
+
29
52
  export type SendThreadInput = {
30
53
  readonly threadId: string;
31
54
  readonly message: string;
@@ -38,6 +61,18 @@ export type CallbackThreadInput = {
38
61
  readonly prompt: string;
39
62
  };
40
63
 
64
+ export type ListThreadsInclude = "active" | "archived" | "all";
65
+
66
+ export type UpdateThreadInput = {
67
+ readonly threadId: string;
68
+ readonly title?: string;
69
+ readonly provider?: string;
70
+ readonly model?: string;
71
+ readonly options?: NonNullable<ModelSelection["options"]>;
72
+ readonly branch?: string | null;
73
+ readonly worktreePath?: string | null;
74
+ };
75
+
41
76
  export type StartThreadPolicy = {
42
77
  readonly until: "dispatch" | "visible" | "complete";
43
78
  };
@@ -48,82 +83,244 @@ export type WaitEvent =
48
83
  | { readonly type: "status"; readonly status: string; readonly threadId: string }
49
84
  | { readonly type: "done"; readonly thread: OrchestrationThread };
50
85
 
51
- export class T3Application extends Context.Service<
52
- T3Application,
53
- {
54
- readonly loadShell: () => Effect.Effect<OrchestrationShellSnapshot, ApplicationError>;
55
- readonly listModels: (input: {
56
- readonly all?: boolean;
57
- readonly provider?: string;
58
- }) => Effect.Effect<ReadonlyArray<ServerProvider>, ApplicationError>;
59
- readonly addProject: (input: {
60
- readonly path: string;
61
- readonly title?: string;
62
- }) => Effect.Effect<
63
- { readonly dispatch: DispatchResult; readonly project: OrchestrationProjectShell },
64
- ApplicationError
65
- >;
66
- readonly listThreads: (projectRef: string) => Effect.Effect<
67
- {
68
- readonly project: OrchestrationProjectShell;
69
- readonly threads: ReadonlyArray<OrchestrationThreadShell>;
70
- },
71
- ApplicationError
72
- >;
73
- readonly getThreadMessages: (
74
- threadId: string,
75
- ) => Effect.Effect<OrchestrationThread, ApplicationError>;
76
- readonly showThread: (threadId: string) => Effect.Effect<ThreadShow, ApplicationError>;
77
- readonly approveThread: (input: {
86
+ export type ProjectActionSelector =
87
+ | { readonly id: string; readonly name?: never }
88
+ | { readonly id?: never; readonly name: string };
89
+
90
+ export type AddProjectActionInput = {
91
+ readonly projectRef: string;
92
+ readonly id?: string;
93
+ readonly name: string;
94
+ readonly command: string;
95
+ readonly icon?: ProjectScriptIcon;
96
+ readonly setup?: boolean;
97
+ readonly previewUrl?: string;
98
+ readonly autoOpenPreview?: boolean;
99
+ };
100
+
101
+ export type UpdateProjectActionInput = {
102
+ readonly projectRef: string;
103
+ readonly selector: ProjectActionSelector;
104
+ readonly name?: string;
105
+ readonly command?: string;
106
+ readonly icon?: ProjectScriptIcon;
107
+ readonly setup?: boolean;
108
+ readonly previewUrl?: string | null;
109
+ readonly autoOpenPreview?: boolean | null;
110
+ };
111
+
112
+ export type ProjectActionMutationResult = {
113
+ readonly dispatch: DispatchResult;
114
+ readonly project: OrchestrationProjectShell;
115
+ readonly action: ProjectScript;
116
+ };
117
+
118
+ export type ProjectActionDeleteResult = {
119
+ readonly dispatch: DispatchResult;
120
+ readonly project: OrchestrationProjectShell;
121
+ readonly action: ProjectScript;
122
+ };
123
+
124
+ export type ProjectActionRunResult = {
125
+ readonly project: OrchestrationProjectShell;
126
+ readonly action: ProjectScript;
127
+ readonly terminal: TerminalSessionSnapshot;
128
+ };
129
+
130
+ export type T3ActionApplicationService = {
131
+ readonly listActions: (projectRef: string) => Effect.Effect<
132
+ {
133
+ readonly project: OrchestrationProjectShell;
134
+ readonly actions: ReadonlyArray<ProjectScript>;
135
+ },
136
+ ApplicationError
137
+ >;
138
+ readonly addAction: (
139
+ input: AddProjectActionInput,
140
+ ) => Effect.Effect<ProjectActionMutationResult, ApplicationError>;
141
+ readonly updateAction: (
142
+ input: UpdateProjectActionInput,
143
+ ) => Effect.Effect<ProjectActionMutationResult, ApplicationError>;
144
+ readonly deleteAction: (input: {
145
+ readonly projectRef: string;
146
+ readonly selector: ProjectActionSelector;
147
+ }) => Effect.Effect<ProjectActionDeleteResult, ApplicationError>;
148
+ readonly runAction: (input: {
149
+ readonly threadId: string;
150
+ readonly selector: ProjectActionSelector;
151
+ readonly terminalId?: string;
152
+ }) => Effect.Effect<ProjectActionRunResult, ApplicationError>;
153
+ };
154
+
155
+ export class T3ActionApplication extends Context.Service<
156
+ T3ActionApplication,
157
+ T3ActionApplicationService
158
+ >()("t3cli/T3ActionApplication") {}
159
+
160
+ export type T3ModelApplicationService = {
161
+ readonly listModels: (input: {
162
+ readonly all?: boolean;
163
+ readonly provider?: string;
164
+ }) => Effect.Effect<ReadonlyArray<ServerProvider>, ApplicationError>;
165
+ };
166
+
167
+ export class T3ModelApplication extends Context.Service<
168
+ T3ModelApplication,
169
+ T3ModelApplicationService
170
+ >()("t3cli/T3ModelApplication") {}
171
+
172
+ export type T3ProjectApplicationService = {
173
+ readonly loadShell: () => Effect.Effect<OrchestrationShellSnapshot, ApplicationError>;
174
+ readonly addProject: (input: {
175
+ readonly path: string;
176
+ readonly title?: string;
177
+ }) => Effect.Effect<
178
+ { readonly dispatch: DispatchResult; readonly project: OrchestrationProjectShell },
179
+ ApplicationError
180
+ >;
181
+ readonly resolveProject: (
182
+ projectRef: string,
183
+ ) => Effect.Effect<OrchestrationProjectShell, ApplicationError>;
184
+ readonly deleteProject: (input: {
185
+ readonly projectId: string;
186
+ readonly force?: boolean;
187
+ }) => Effect.Effect<
188
+ { readonly projectId: string; readonly dispatch: DispatchResult },
189
+ ApplicationError
190
+ >;
191
+ };
192
+
193
+ export class T3ProjectApplication extends Context.Service<
194
+ T3ProjectApplication,
195
+ T3ProjectApplicationService
196
+ >()("t3cli/T3ProjectApplication") {}
197
+
198
+ export type T3ThreadApplicationService = {
199
+ readonly listThreads: (
200
+ projectRef: string,
201
+ options?: {
202
+ readonly include?: ListThreadsInclude;
203
+ },
204
+ ) => Effect.Effect<
205
+ {
206
+ readonly project: OrchestrationProjectShell;
207
+ readonly threads: ReadonlyArray<OrchestrationThreadShell>;
208
+ },
209
+ ApplicationError
210
+ >;
211
+ readonly getThreadMessages: (
212
+ threadId: string,
213
+ ) => Effect.Effect<OrchestrationThread, ApplicationError>;
214
+ readonly showThread: (threadId: string) => Effect.Effect<ThreadShow, ApplicationError>;
215
+ readonly approveThread: (input: {
216
+ readonly threadId: string;
217
+ readonly requestId: string;
218
+ readonly decision: "accept" | "decline" | "cancel";
219
+ }) => Effect.Effect<
220
+ { readonly threadId: string; readonly requestId: string; readonly dispatch: DispatchResult },
221
+ ApplicationError
222
+ >;
223
+ readonly respondToThread: (input: {
224
+ readonly threadId: string;
225
+ readonly requestId: string;
226
+ readonly answers: ProviderUserInputAnswers;
227
+ }) => Effect.Effect<
228
+ { readonly threadId: string; readonly requestId: string; readonly dispatch: DispatchResult },
229
+ ApplicationError
230
+ >;
231
+ readonly archiveThread: (threadId: string) => Effect.Effect<DispatchResult, ApplicationError>;
232
+ readonly interruptThread: (threadId: string) => Effect.Effect<DispatchResult, ApplicationError>;
233
+ readonly unarchiveThread: (threadId: string) => Effect.Effect<DispatchResult, ApplicationError>;
234
+ readonly deleteThread: (
235
+ threadId: string,
236
+ ) => Effect.Effect<
237
+ { readonly threadId: string; readonly dispatch: DispatchResult },
238
+ ApplicationError
239
+ >;
240
+ readonly updateThread: (
241
+ input: UpdateThreadInput,
242
+ ) => Effect.Effect<DispatchResult, ApplicationError>;
243
+ readonly startThread: (
244
+ input: StartThreadInput,
245
+ policy?: StartThreadPolicy,
246
+ ) => Effect.Effect<
247
+ {
248
+ readonly dispatch: DispatchResult;
249
+ readonly project: OrchestrationProjectShell;
78
250
  readonly threadId: string;
79
- readonly requestId: string;
80
- readonly decision: "accept" | "decline" | "cancel";
81
- }) => Effect.Effect<
82
- { readonly threadId: string; readonly requestId: string; readonly dispatch: DispatchResult },
83
- ApplicationError
84
- >;
85
- readonly respondToThread: (input: {
251
+ readonly thread?: OrchestrationThread;
252
+ },
253
+ ApplicationError
254
+ >;
255
+ readonly sendThread: (
256
+ input: SendThreadInput,
257
+ policy?: StartThreadPolicy,
258
+ ) => Effect.Effect<
259
+ {
260
+ readonly dispatch: DispatchResult;
86
261
  readonly threadId: string;
87
- readonly requestId: string;
88
- readonly answers: ProviderUserInputAnswers;
89
- }) => Effect.Effect<
90
- { readonly threadId: string; readonly requestId: string; readonly dispatch: DispatchResult },
91
- ApplicationError
92
- >;
93
- readonly archiveThread: (threadId: string) => Effect.Effect<DispatchResult, ApplicationError>;
94
- readonly startThread: (
95
- input: StartThreadInput,
96
- policy?: StartThreadPolicy,
97
- ) => Effect.Effect<
98
- {
99
- readonly dispatch: DispatchResult;
100
- readonly project: OrchestrationProjectShell;
101
- readonly threadId: string;
102
- readonly thread?: OrchestrationThread;
103
- },
104
- ApplicationError
105
- >;
106
- readonly sendThread: (
107
- input: SendThreadInput,
108
- policy?: StartThreadPolicy,
109
- ) => Effect.Effect<
110
- {
111
- readonly dispatch: DispatchResult;
112
- readonly threadId: string;
113
- readonly thread?: OrchestrationThread;
114
- },
115
- ApplicationError
116
- >;
117
- readonly watchThread: (threadId: string) => Stream.Stream<WaitEvent, ApplicationError>;
118
- readonly waitForThread: (
119
- threadId: string,
120
- ) => Effect.Effect<OrchestrationThread, ApplicationError>;
121
- readonly callbackThread: (input: CallbackThreadInput) => Effect.Effect<
122
- {
123
- readonly dispatch: DispatchResult;
124
- readonly targetThreadId: string;
125
- },
126
- ApplicationError
127
- >;
128
- }
129
- >()("t3cli/T3Application") {}
262
+ readonly thread?: OrchestrationThread;
263
+ },
264
+ ApplicationError
265
+ >;
266
+ readonly watchThread: (threadId: string) => Stream.Stream<WaitEvent, ApplicationError>;
267
+ readonly waitForThread: (
268
+ threadId: string,
269
+ ) => Effect.Effect<OrchestrationThread, ApplicationError>;
270
+ readonly callbackThread: (input: CallbackThreadInput) => Effect.Effect<
271
+ {
272
+ readonly dispatch: DispatchResult;
273
+ readonly targetThreadId: string;
274
+ },
275
+ ApplicationError
276
+ >;
277
+ };
278
+
279
+ export class T3ThreadApplication extends Context.Service<
280
+ T3ThreadApplication,
281
+ T3ThreadApplicationService
282
+ >()("t3cli/T3ThreadApplication") {}
283
+
284
+ export type T3TerminalApplicationService = {
285
+ readonly listTerminals: (
286
+ threadId: string,
287
+ ) => Effect.Effect<ReadonlyArray<TerminalSummary>, ApplicationError>;
288
+ readonly getTerminal: (terminal: TerminalRef) => Effect.Effect<TerminalSummary, ApplicationError>;
289
+ readonly createTerminal: (
290
+ input: CreateTerminalInput,
291
+ ) => Effect.Effect<TerminalSessionSnapshot, ApplicationError>;
292
+ readonly attachTerminal: (input: {
293
+ readonly terminal: TerminalAttachTarget;
294
+ readonly cols?: number;
295
+ readonly rows?: number;
296
+ }) => Stream.Stream<TerminalAttachStreamEvent, ApplicationError>;
297
+ readonly watchTerminalMetadata: () => Stream.Stream<
298
+ TerminalMetadataStreamEvent,
299
+ ApplicationError
300
+ >;
301
+ readonly writeTerminal: (input: {
302
+ readonly terminal: TerminalRef;
303
+ readonly data: string;
304
+ }) => Effect.Effect<void, ApplicationError>;
305
+ readonly resizeTerminal: (input: {
306
+ readonly terminal: TerminalRef;
307
+ readonly cols: number;
308
+ readonly rows: number;
309
+ }) => Effect.Effect<void, ApplicationError>;
310
+ readonly destroyTerminal: (terminal: TerminalRef) => Effect.Effect<void, ApplicationError>;
311
+ };
312
+
313
+ export class T3TerminalApplication extends Context.Service<
314
+ T3TerminalApplication,
315
+ T3TerminalApplicationService
316
+ >()("t3cli/T3TerminalApplication") {}
317
+
318
+ export type T3ApplicationService = T3ModelApplicationService &
319
+ T3ActionApplicationService &
320
+ T3ProjectApplicationService &
321
+ T3ThreadApplicationService &
322
+ T3TerminalApplicationService;
323
+
324
+ export class T3Application extends Context.Service<T3Application, T3ApplicationService>()(
325
+ "t3cli/T3Application",
326
+ ) {}
@@ -1,17 +1,15 @@
1
1
  import * as Effect from "effect/Effect";
2
2
  import * as Option from "effect/Option";
3
3
  import * as Stream from "effect/Stream";
4
- import { ORCHESTRATION_WS_METHODS } from "#t3tools/contracts";
4
+ import { ORCHESTRATION_WS_METHODS } from "@t3tools/contracts";
5
5
 
6
- import type { Orchestration } from "../orchestration/service.ts";
6
+ import { T3Orchestration } from "../orchestration/service.ts";
7
7
  import { RpcError } from "../rpc/error.ts";
8
8
 
9
- export function waitForShellSequence(input: {
10
- readonly orchestration: Orchestration;
11
- readonly sequence: number;
12
- }) {
9
+ export function waitForShellSequence(input: { readonly sequence: number }) {
13
10
  return Effect.gen(function* () {
14
- const sequence = yield* input.orchestration.watchShellSequence().pipe(
11
+ const orchestration = yield* T3Orchestration;
12
+ const sequence = yield* orchestration.watchShellSequence().pipe(
15
13
  Stream.filter((snapshotSequence) => snapshotSequence >= input.sequence),
16
14
  Stream.runHead,
17
15
  Effect.scoped,
@@ -24,6 +22,6 @@ export function waitForShellSequence(input: {
24
22
  }),
25
23
  );
26
24
  }
27
- return yield* input.orchestration.getShellSnapshot();
25
+ return yield* orchestration.getShellSnapshot();
28
26
  });
29
27
  }