t3code-cli 0.8.0 → 0.9.1

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 (60) hide show
  1. package/README.md +90 -35
  2. package/dist/application.js +1 -1
  3. package/dist/auth.js +1 -2
  4. package/dist/bin.js +190 -45
  5. package/dist/cli.js +1 -1
  6. package/dist/config.js +1 -3
  7. package/dist/connection.js +1 -4
  8. package/dist/index.js +1 -4
  9. package/dist/layout.js +1 -1
  10. package/dist/orchestration.js +1 -1
  11. package/dist/rpc.js +1 -1
  12. package/dist/runtime.js +1 -2
  13. package/dist/scope.js +1 -1
  14. package/dist/shared.js +85492 -0
  15. package/dist/src/application/layer.d.ts +25 -2
  16. package/dist/src/application/projects.d.ts +1 -1
  17. package/dist/src/application/service.d.ts +21 -1
  18. package/dist/src/application/thread-commands.d.ts +27 -1
  19. package/dist/src/application/threads.d.ts +50 -1
  20. package/dist/src/domain/thread-activities.d.ts +14 -0
  21. package/dist/src/domain/thread-lifecycle.d.ts +1 -0
  22. package/dist/src/runtime/layer.d.ts +1 -1
  23. package/dist/t3tools.js +1 -1
  24. package/package.json +1 -1
  25. package/src/application/service.ts +19 -0
  26. package/src/application/thread-commands.ts +45 -0
  27. package/src/application/threads.ts +85 -0
  28. package/src/cli/error.ts +15 -0
  29. package/src/cli/message-input.ts +30 -0
  30. package/src/cli/thread-format.ts +47 -0
  31. package/src/cli/thread.ts +6 -0
  32. package/src/cli/threads/approve.ts +61 -0
  33. package/src/cli/threads/archive.ts +18 -3
  34. package/src/cli/threads/callback.ts +1 -2
  35. package/src/cli/threads/respond.ts +70 -0
  36. package/src/cli/threads/show.ts +43 -0
  37. package/src/domain/thread-activities.test.ts +321 -0
  38. package/src/domain/thread-activities.ts +244 -0
  39. package/src/domain/thread-lifecycle.ts +2 -0
  40. package/dist/Context-DueQ9iMH.js +0 -4916
  41. package/dist/Path-D8WPdPwR.js +0 -11406
  42. package/dist/Schema-DsQxYh6_.js +0 -13581
  43. package/dist/UrlParams-BA6gBvaY.js +0 -205
  44. package/dist/base-dir-R12OMDso.js +0 -20
  45. package/dist/error-BHRnjLux.js +0 -15
  46. package/dist/error-ChTsLQTu.js +0 -169
  47. package/dist/error-CjADNVm8.js +0 -54
  48. package/dist/flags-CM7_iGdA.js +0 -13371
  49. package/dist/layer-CMo36MrX.js +0 -29466
  50. package/dist/layer-DHhKS5jd.js +0 -13
  51. package/dist/layer-DUv99vsS.js +0 -72
  52. package/dist/layer-Do8wK1t6.js +0 -1508
  53. package/dist/layer-DwI3Skkh.js +0 -1223
  54. package/dist/scope-GycYiJ54.js +0 -29
  55. package/dist/service-CLmRO2Dp.js +0 -8
  56. package/dist/service-ybOWV9pL.js +0 -5
  57. package/dist/src-aiFPmAG7.js +0 -9030
  58. package/dist/transport-MI0Z3d2T.js +0 -539
  59. package/dist/url-SlsaG8nY.js +0 -165
  60. /package/dist/{chunk-B5meny8j.js → rolldown-runtime.js} +0 -0
package/dist/bin.js CHANGED
@@ -1,15 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { A as none, C as isNone, Ft as BaseProto, Mn as pipe, Nt as withFiber, O as map, On as dual, S as getOrUndefined, T as isSome, X as Prototype, _ as flatMap, an as hasProperty, b as getOrElse, d as make$8, fn as isNotNull, hn as isNullish, i as empty, j as some, k as match, l as getUnsafe, mn as isNotUndefined, n as Service, t as Reference, v as fromNullishOr, xn as isUndefined, y as fromUndefinedOr } from "./Context-DueQ9iMH.js";
3
- import { $n as makeUnsafe, Ct as serviceOption, E as effectify, F as fnUntraced, Fn as succeed$2, Ft as tryPromise, G as interrupt, Ir as sync$1, It as try_, L as forEach, Ln as sync$2, Lt as uninterruptible, Mn as mergeAll, Mt as tapError, Nn as provide, Ot as suspend, P as fn, Pn as provideMerge, Pt as timeoutOrElse, Qn as isDone, Tt as succeed, U as gen, V as forkScoped, Vt as void_, W as ignore, X as map$1, Xn as doneUnsafe, Yn as _await, a as badArgument, b as catchTags, c as addFinalizer, cr as succeed$1, d as as, dr as ConsoleRef, dt as provideService, fn as fail$1, h as callback, ht as runFork, j as flatMap$1, k as fail, kn as effect, kt as sync, l as andThen, li as fail$2, lt as provide$1, n as TypeId$4, nt as matchEffect, o as systemError, p as asVoid, pi as succeed$3, pt as result, qn as MinimumLogLevel, r as BadArgument, s as acquireRelease, st as orDie, t as Path$1, ti as map$2, ut as provideContext, v as catchFilter, x as catch_, xt as scoped } from "./Path-D8WPdPwR.js";
4
- import { Bt as runCollect, Ht as runFold, Jt as splitLines, Kt as runLast, L as fromJsonString, Mt as merge, Nt as mkString, On as nominal, P as decodeUnknownEffect, Qt as tap, Sn as offerUnsafe, Tt as fromIterable, Vt as runDrain, Yt as succeed$4, an as drain, b as Struct, bn as offer, cn as isSink, dt as FileSystem, et as optionalKey, ft as FileTypeId, gn as endUnsafe, gt as callback$1, ht as make$9, in as make$10, kt as isStream, mt as WatchBackend, nn as unwrap, nt as tag, pt as Size, rn as get, s as ErrorClass, tn as transduce, u as Literal, ut as FileDescriptor, vn as failCauseUnsafe, vt as decodeText, x as TaggedErrorClass, y as String$1, yn as make$11, yt as empty$1, zt as run$1 } from "./Schema-DsQxYh6_.js";
5
- import { A as isBoolean, C as getParamMetadata, D as string$1, E as optional$1, F as ShowHelp, I as UnknownSubcommand, L as UnrecognizedOption, M as isTrueValue, N as DuplicateOption, O as getChoiceKeys, P as InvalidValue, R as isCliError, S as extractSingleParams, T as isParam, _ as string$2, a as threadFlag, b as withDescription$1, c as worktreeFlag, d as boolean, f as choice, g as optional$2, h as map$3, i as projectPathFlag, j as isFalseValue, k as getTypeName, l as canRenderLiveTerminal, m as integer, n as modelFlags, o as threadFormatFlag, p as choiceWithValue, r as projectFlag, s as waitFormatFlag, t as formatFlag, u as resolveOutputFormat, v as withAlias, w as isFlagParam, x as argumentKind, y as withDefault, z as makeRunMain } from "./flags-CM7_iGdA.js";
6
- import { c as fromReadable, l as fromWritable } from "./layer-CMo36MrX.js";
7
- import { C as make$12, S as Crypto, x as T3Auth } from "./layer-Do8wK1t6.js";
8
- import { n as T3Config, t as Environment } from "./service-CLmRO2Dp.js";
9
- import { t as T3Application } from "./service-ybOWV9pL.js";
10
- import { i as resolveWorktreePath, r as resolveThreadId, t as resolveCommandProjectRef } from "./scope-GycYiJ54.js";
11
- import { d as latestAssistantMessage, f as threadStatus, h as CliPath, m as ThreadSessionError, p as ProjectLookupError, t as AppLayer } from "./layer-DwI3Skkh.js";
12
- import { t as NodeEnvironmentLive } from "./layer-DHhKS5jd.js";
2
+ import { $d as string$2, $f as runFold, $p as timeoutOrElse, Af as tag, Am as getOrElse, Ap as fail, Bd as waitFormatFlag, Bf as Size, Bm as BaseProto, Bp as matchEffect, Cf as String$1, Cm as Service, Cp as as, Dd as ThreadSessionError, Df as decodeUnknownSync, Dm as flatMap$1, Dp as catchTags, Ed as ProjectLookupError, Ef as decodeUnknownEffect, Em as make$12, Ep as catchFilter, Fd as modelFlags, Ff as Path$1, Fm as match, Fp as forkScoped, Gd as T3Config, Gf as empty, Gm as isUndefined, Gp as result, Hd as canRenderLiveTerminal, Hf as make$9, Hm as isNotNull, Hp as provide$1, Id as projectFlag, If as TypeId$4, Im as none, Ip as gen, J as NodeEnvironmentLive, Jd as choice, Jf as merge, Jp as serviceOption, Kd as T3Auth, Kf as fromIterable, Km as dual, Kp as runFork, Ld as projectPathFlag, Lf as FileDescriptor, Lm as some, Lp as ignore, Md as resolveWorktreePath, Mf as make$8, Mm as isNone, Mp as fn, Nd as T3Application, Nf as fromReadable, Nm as isSome, Np as fnUntraced, Od as CliPath, Of as fromJsonString, Om as fromNullishOr, Op as catch_, Pd as formatFlag, Pf as fromWritable, Pm as map$3, Pp as forEach, Qd as optional$2, Qf as runDrain, Qp as tapError, Rd as threadFlag, Rf as FileSystem, Rm as Prototype, Rp as interrupt, Sf as Literal, Sm as Reference, Sp as andThen, Tf as TaggedErrorClass, Tm as getUnsafe, Tp as callback, Ud as resolveOutputFormat, Uf as callback$1, Um as isNotUndefined, Up as provideContext, Vd as worktreeFlag, Vf as WatchBackend, Vm as hasProperty, Vp as orDie, Wd as Environment, Wf as decodeText, Wm as isNullish, Wp as provideService, X as threadStatus, Xd as integer, Xf as run$1, Xp as suspend, Y as latestAssistantMessage, Yd as choiceWithValue, Yf as mkString, Yp as succeed, Zd as map$2, Zf as runCollect, Zp as sync, _f as ShowHelp, _m as ConsoleRef, _p as systemError, af as getParamMetadata, am as effect, ap as unwrap, bf as isCliError, bm as fail$2, bp as acquireRelease, cf as optional$1, cm as provideMerge, cp as drain, df as getTypeName, dm as MinimumLogLevel, dp as failCauseUnsafe, ef as withAlias, em as tryPromise, ep as runLast, ff as isBoolean, fm as _await, fp as make$11, gf as InvalidValue, gm as succeed$1, gp as badArgument, hf as DuplicateOption, hm as makeUnsafe, hp as BadArgument, if as extractSingleParams, im as fail$1, ip as transduce, jd as resolveThreadId, jf as Crypto, jm as getOrUndefined, jp as flatMap, kd as resolveCommandProjectRef, kf as optionalKey, km as fromUndefinedOr, kp as effectify, lf as string$1, lm as succeed$2, lp as isSink, mf as isTrueValue, mm as isDone, mp as offerUnsafe, nf as withDescription$1, nm as uninterruptible, np as succeed$4, of as isFlagParam, om as mergeAll, op as get, pf as isFalseValue, pm as doneUnsafe, pp as offer, qd as boolean, qf as isStream, qm as pipe, qp as scoped, rf as argumentKind, rm as void_, rp as tap, sf as isParam, sl as ProviderUserInputAnswers, sm as provide, sp as make$10, t as AppLayer, tf as withDefault, tm as try_, tp as splitLines, uf as getChoiceKeys, um as sync$2, up as endUnsafe, vf as UnknownSubcommand, vm as sync$1, vp as nominal, wf as Struct, wm as empty$1, wp as asVoid, xf as ErrorClass, xm as succeed$3, xp as addFinalizer, yf as UnrecognizedOption, ym as map$1, yp as makeRunMain, zd as threadFormatFlag, zf as FileTypeId, zm as withFiber, zp as map } from "./shared.js";
13
3
  import * as NodeChildProcess from "node:child_process";
14
4
  import * as NodeCrypto from "node:crypto";
15
5
  import * as NFS from "node:fs";
@@ -153,11 +143,11 @@ const makeHandle = (params) => Object.assign(Object.create(HandleProto), params)
153
143
  * @since 4.0.0
154
144
  */
155
145
  const make$7 = (spawn) => {
156
- const streamString = (command, options) => spawn(command).pipe(map$1((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap);
146
+ const streamString = (command, options) => spawn(command).pipe(map((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap);
157
147
  const streamLines = (command, options) => splitLines(streamString(command, options));
158
148
  return ChildProcessSpawner.of({
159
149
  spawn,
160
- exitCode: (command) => scoped(flatMap$1(spawn(command), (handle) => handle.exitCode)),
150
+ exitCode: (command) => scoped(flatMap(spawn(command), (handle) => handle.exitCode)),
161
151
  streamString,
162
152
  streamLines,
163
153
  lines: (command, options) => runCollect(streamLines(command, options)),
@@ -534,7 +524,7 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
534
524
  const setupAdditionalFds = fnUntraced(function* (command, childProcess, additionalFds) {
535
525
  if (additionalFds.length === 0) return {
536
526
  getInputFd: () => drain,
537
- getOutputFd: () => empty$1
527
+ getOutputFd: () => empty
538
528
  };
539
529
  const inputSinks = /* @__PURE__ */ new Map();
540
530
  const outputStreams = /* @__PURE__ */ new Map();
@@ -552,7 +542,7 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
552
542
  break;
553
543
  }
554
544
  case "output": {
555
- let stream = empty$1;
545
+ let stream = empty;
556
546
  if (nodeStream && "read" in nodeStream) stream = fromReadable({
557
547
  evaluate: () => nodeStream,
558
548
  onError: (error) => toPlatformError(`fromReadable(fd${fd})`, toError(error), command)
@@ -565,7 +555,7 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
565
555
  }
566
556
  return {
567
557
  getInputFd: (fd) => inputSinks.get(fd) ?? drain,
568
- getOutputFd: (fd) => outputStreams.get(fd) ?? empty$1
558
+ getOutputFd: (fd) => outputStreams.get(fd) ?? empty
569
559
  };
570
560
  });
571
561
  const setupChildStdin = (command, childProcess, config) => suspend(() => {
@@ -583,11 +573,11 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
583
573
  let stdout = childProcess.stdout ? fromReadable({
584
574
  evaluate: () => childProcess.stdout,
585
575
  onError: (error) => toPlatformError("fromReadable(stdout)", toError(error), command)
586
- }) : empty$1;
576
+ }) : empty;
587
577
  let stderr = childProcess.stderr ? fromReadable({
588
578
  evaluate: () => childProcess.stderr,
589
579
  onError: (error) => toPlatformError("fromReadable(stderr)", toError(error), command)
590
- }) : empty$1;
580
+ }) : empty;
591
581
  if (isSink(stdoutConfig.stream)) stdout = transduce(stdout, stdoutConfig.stream);
592
582
  if (isSink(stderrConfig.stream)) stderr = transduce(stderr, stderrConfig.stream);
593
583
  const all = merge(stdout, stderr);
@@ -712,8 +702,8 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
712
702
  const stdin = yield* setupChildStdin(cmd, childProcess, stdinConfig);
713
703
  const { all, stderr, stdout } = setupChildOutputStreams(cmd, childProcess, stdoutConfig, stderrConfig);
714
704
  const { getInputFd, getOutputFd } = yield* setupAdditionalFds(cmd, childProcess, resolvedAdditionalFds);
715
- const isRunning = map$1(isDone(exitSignal), (done) => !done);
716
- const exitCode = flatMap$1(_await(exitSignal), ([code, signal]) => {
705
+ const isRunning = map(isDone(exitSignal), (done) => !done);
706
+ const exitCode = flatMap(_await(exitSignal), ([code, signal]) => {
717
707
  if (isNotNull(code)) return succeed(ExitCode(code));
718
708
  return fail(toPlatformError("exitCode", new globalThis.Error(`Process interrupted due to receipt of signal: '${signal}'`), cmd));
719
709
  });
@@ -895,7 +885,7 @@ const digest = (algorithm, data) => try_({
895
885
  * @category layers
896
886
  * @since 1.0.0
897
887
  */
898
- const layer$9 = /* @__PURE__ */ succeed$2(Crypto, /* @__PURE__ */ make$12({
888
+ const layer$9 = /* @__PURE__ */ succeed$2(Crypto, /* @__PURE__ */ make$8({
899
889
  randomBytes: NodeCrypto.randomBytes,
900
890
  digest
901
891
  }));
@@ -1005,7 +995,7 @@ const makeTempDirectoryScoped = /*#__PURE__*/ (() => {
1005
995
  const openFactory = (method) => {
1006
996
  const nodeOpen = effectify(NFS.open, handleErrnoException("FileSystem", method), handleBadArgument(method));
1007
997
  const nodeClose = effectify(NFS.close, handleErrnoException("FileSystem", method), handleBadArgument(method));
1008
- return (path, options) => pipe(acquireRelease(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie(nodeClose(fd))), map$1((fd) => makeFile(FileDescriptor(fd), options?.flag?.startsWith("a") ?? false)));
998
+ return (path, options) => pipe(acquireRelease(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie(nodeClose(fd))), map((fd) => makeFile(FileDescriptor(fd), options?.flag?.startsWith("a") ?? false)));
1009
999
  };
1010
1000
  const open = /*#__PURE__*/ openFactory("open");
1011
1001
  const makeFile = /*#__PURE__*/ (() => {
@@ -1029,7 +1019,7 @@ const makeFile = /*#__PURE__*/ (() => {
1029
1019
  this.append = append;
1030
1020
  }
1031
1021
  get stat() {
1032
- return map$1(nodeStat(this.fd), makeFileInfo);
1022
+ return map(nodeStat(this.fd), makeFileInfo);
1033
1023
  }
1034
1024
  get sync() {
1035
1025
  return nodeSync(this.fd);
@@ -1045,7 +1035,7 @@ const makeFile = /*#__PURE__*/ (() => {
1045
1035
  read(buffer) {
1046
1036
  return suspend(() => {
1047
1037
  const position = this.position;
1048
- return map$1(nodeRead(this.fd, {
1038
+ return map(nodeRead(this.fd, {
1049
1039
  buffer,
1050
1040
  position
1051
1041
  }), (bytesRead) => {
@@ -1060,7 +1050,7 @@ const makeFile = /*#__PURE__*/ (() => {
1060
1050
  return suspend(() => {
1061
1051
  const buffer = Buffer.allocUnsafeSlow(sizeNumber);
1062
1052
  const position = this.position;
1063
- return map$1(nodeReadAlloc(this.fd, {
1053
+ return map(nodeReadAlloc(this.fd, {
1064
1054
  buffer,
1065
1055
  position
1066
1056
  }), (bytesRead) => {
@@ -1074,7 +1064,7 @@ const makeFile = /*#__PURE__*/ (() => {
1074
1064
  });
1075
1065
  }
1076
1066
  truncate(length) {
1077
- return map$1(nodeTruncate(this.fd, length ? Number(length) : void 0), () => {
1067
+ return map(nodeTruncate(this.fd, length ? Number(length) : void 0), () => {
1078
1068
  if (!this.append) {
1079
1069
  const len = BigInt(length ?? 0);
1080
1070
  if (this.position > len) this.position = len;
@@ -1084,7 +1074,7 @@ const makeFile = /*#__PURE__*/ (() => {
1084
1074
  write(buffer) {
1085
1075
  return suspend(() => {
1086
1076
  const position = this.position;
1087
- return map$1(nodeWrite(this.fd, buffer, void 0, void 0, this.append ? void 0 : Number(position)), (bytesWritten) => {
1077
+ return map(nodeWrite(this.fd, buffer, void 0, void 0, this.append ? void 0 : Number(position)), (bytesWritten) => {
1088
1078
  const sizeWritten = Size(bytesWritten);
1089
1079
  if (!this.append) this.position = position + sizeWritten;
1090
1080
  return sizeWritten;
@@ -1094,7 +1084,7 @@ const makeFile = /*#__PURE__*/ (() => {
1094
1084
  writeAllChunk(buffer) {
1095
1085
  return suspend(() => {
1096
1086
  const position = this.position;
1097
- return flatMap$1(nodeWriteAll(this.fd, buffer, void 0, void 0, this.append ? void 0 : Number(position)), (bytesWritten) => {
1087
+ return flatMap(nodeWriteAll(this.fd, buffer, void 0, void 0, this.append ? void 0 : Number(position)), (bytesWritten) => {
1098
1088
  if (bytesWritten === 0) return fail(systemError({
1099
1089
  module: "FileSystem",
1100
1090
  method: "writeAll",
@@ -1173,7 +1163,7 @@ const makeFileInfo = (stat) => ({
1173
1163
  });
1174
1164
  const stat = /*#__PURE__*/ (() => {
1175
1165
  const nodeStat = /*#__PURE__*/ effectify(NFS.stat, /*#__PURE__*/ handleErrnoException("FileSystem", "stat"), /*#__PURE__*/ handleBadArgument("stat"));
1176
- return (path) => map$1(nodeStat(path), makeFileInfo);
1166
+ return (path) => map(nodeStat(path), makeFileInfo);
1177
1167
  })();
1178
1168
  const symlink = /*#__PURE__*/ (() => {
1179
1169
  const nodeSymlink = /*#__PURE__*/ effectify(NFS.symlink, /*#__PURE__*/ handleErrnoException("FileSystem", "symlink"), /*#__PURE__*/ handleBadArgument("symlink"));
@@ -1225,7 +1215,7 @@ const watchNode = (path) => callback$1((queue) => acquireRelease(sync(() => {
1225
1215
  });
1226
1216
  return watcher;
1227
1217
  }), (watcher) => sync(() => watcher.close())));
1228
- const watch = (backend, path) => stat(path).pipe(map$1((stat) => backend.pipe(flatMap((_) => _.register(path, stat)), getOrElse(() => watchNode(path)))), unwrap);
1218
+ const watch = (backend, path) => stat(path).pipe(map((stat) => backend.pipe(flatMap$1((_) => _.register(path, stat)), getOrElse(() => watchNode(path)))), unwrap);
1229
1219
  const writeFile = (path, data, options) => callback((resume, signal) => {
1230
1220
  try {
1231
1221
  NFS.writeFile(path, data, {
@@ -1240,7 +1230,7 @@ const writeFile = (path, data, options) => callback((resume, signal) => {
1240
1230
  resume(fail(handleBadArgument("writeFile")(err)));
1241
1231
  }
1242
1232
  });
1243
- const makeFileSystem = /*#__PURE__*/ map$1(/*#__PURE__*/ serviceOption(WatchBackend), (backend) => make$9({
1233
+ const makeFileSystem = /*#__PURE__*/ map(/*#__PURE__*/ serviceOption(WatchBackend), (backend) => make$9({
1244
1234
  access,
1245
1235
  chmod,
1246
1236
  chown,
@@ -1651,7 +1641,7 @@ const layer$2 = /*#__PURE__*/ effect(Terminal, /*#__PURE__*/ (/* @__PURE__ */ fn
1651
1641
  stdin.on("keypress", handleKeypress);
1652
1642
  return queue;
1653
1643
  });
1654
- const readLine = scoped(flatMap$1(get(rlRef), (readlineInterface) => callback((resume) => {
1644
+ const readLine = scoped(flatMap(get(rlRef), (readlineInterface) => callback((resume) => {
1655
1645
  const onLine = (line) => resume(succeed(line));
1656
1646
  readlineInterface.once("line", onLine);
1657
1647
  return sync(() => readlineInterface.off("line", onLine));
@@ -2668,7 +2658,7 @@ const makeCommand = (options) => {
2668
2658
  const config = options.config;
2669
2659
  const contextConfig = options.contextConfig ?? emptyConfig;
2670
2660
  const service = options.service ?? Service(`~effect/cli/Command/${options.name}`);
2671
- const annotations = options.annotations ?? empty();
2661
+ const annotations = options.annotations ?? empty$1();
2672
2662
  const globalFlags = options.globalFlags ?? [];
2673
2663
  const subcommands = options.subcommands ?? [];
2674
2664
  const handle = (input, commandPath) => isNotUndefined(options.handle) ? options.handle(input, commandPath) : fail(new ShowHelp({
@@ -2711,7 +2701,7 @@ const makeCommand = (options) => {
2711
2701
  if (visible.length === 0) continue;
2712
2702
  subcommandDocs.push({
2713
2703
  group: group.group,
2714
- commands: map$2(visible, (subcommand) => ({
2704
+ commands: map$1(visible, (subcommand) => ({
2715
2705
  name: subcommand.name,
2716
2706
  alias: subcommand.alias,
2717
2707
  shortDescription: subcommand.shortDescription,
@@ -3135,7 +3125,7 @@ const Completions = /*#__PURE__*/ action({
3135
3125
  "zsh",
3136
3126
  "fish",
3137
3127
  "sh"
3138
- ]).pipe(optional$2, /*#__PURE__*/ map$3((v) => map(v, (s) => s === "sh" ? "bash" : s)), /*#__PURE__*/ withDescription$1("Print shell completion script")),
3128
+ ]).pipe(optional$2, /*#__PURE__*/ map$2((v) => map$3(v, (s) => s === "sh" ? "bash" : s)), /*#__PURE__*/ withDescription$1("Print shell completion script")),
3139
3129
  run: (shell, { command }) => gen(function* () {
3140
3130
  if (isNone(shell)) return;
3141
3131
  const descriptor = fromCommand(command);
@@ -4083,7 +4073,7 @@ const showHelp = (command, error$1) => gen(function* () {
4083
4073
  * @category command execution
4084
4074
  * @since 4.0.0
4085
4075
  */
4086
- const run = /*#__PURE__*/ dual(2, (command, config) => Stdio.use(({ args }) => flatMap$1(args, (args) => runWith(command, config)(args))));
4076
+ const run = /*#__PURE__*/ dual(2, (command, config) => Stdio.use(({ args }) => flatMap(args, (args) => runWith(command, config)(args))));
4087
4077
  /**
4088
4078
  * Runs a command with explicitly provided arguments instead of using arguments from `Stdio`.
4089
4079
  *
@@ -4187,8 +4177,8 @@ const runWith = (command, config) => {
4187
4177
  const [, logLevel] = yield* LogLevel.flag.parse(emptyArgs);
4188
4178
  program = provideService(program, LogLevel, logLevel);
4189
4179
  const services = match(logLevel, {
4190
- onNone: () => empty(),
4191
- onSome: (level) => make$8(MinimumLogLevel, level)
4180
+ onNone: () => empty$1(),
4181
+ onSome: (level) => make$12(MinimumLogLevel, level)
4192
4182
  });
4193
4183
  yield* provideContext(program, services);
4194
4184
  }, catchFilter((error) => isCliError(error) && error._tag === "ShowHelp" ? succeed$3(error) : fail$2(error), (error) => andThen(showHelp(command, error), fail(error))), catchFilter((e) => isQuitError(e) ? succeed$3(e) : fail$2(e), (_) => interrupt));
@@ -4380,12 +4370,50 @@ var InvalidLimitError = class extends TaggedErrorClass()("InvalidLimitError", {
4380
4370
  value: String$1
4381
4371
  }) {};
4382
4372
  var MissingThreadError = class extends TaggedErrorClass()("MissingThreadError", { message: String$1 }) {};
4373
+ var SelfArchiveError = class extends TaggedErrorClass()("SelfArchiveError", {
4374
+ message: String$1,
4375
+ threadId: String$1
4376
+ }) {};
4377
+ var MissingRequestError = class extends TaggedErrorClass()("MissingRequestError", { message: String$1 }) {};
4378
+ //#endregion
4379
+ //#region src/cli/threads/approve.ts
4380
+ const approvalDecisionFlag = choice("decision", [
4381
+ "accept",
4382
+ "decline",
4383
+ "cancel"
4384
+ ]).pipe(withDescription$1("Approval decision"));
4385
+ const approveThreadCommand = make("approve", {
4386
+ thread: threadFlag,
4387
+ request: string$2("request").pipe(withDescription$1("Pending approval request id"), optional$2),
4388
+ decision: approvalDecisionFlag,
4389
+ format: formatFlag
4390
+ }, ({ thread, request, decision, format }) => gen(function* () {
4391
+ const application = yield* T3Application;
4392
+ const environment = yield* Environment;
4393
+ const output = yield* T3Output;
4394
+ const threadId = resolveThreadId({
4395
+ value: getOrUndefined(thread),
4396
+ env: environment.env
4397
+ });
4398
+ if (threadId === void 0) return yield* fail(new MissingThreadError({ message: "thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
4399
+ const requestId = getOrUndefined(request);
4400
+ if (requestId === void 0 || requestId.length === 0) return yield* fail(new MissingRequestError({ message: "request id is required: pass --request" }));
4401
+ const resolvedFormat = resolveOutputFormat(format, environment, "json");
4402
+ const result = yield* application.approveThread({
4403
+ threadId,
4404
+ requestId,
4405
+ decision
4406
+ });
4407
+ if (resolvedFormat === "json") return yield* output.printJson(result);
4408
+ return yield* output.printInfo(`approval submitted: ${result.requestId}\nsequence: ${result.dispatch.sequence}`);
4409
+ })).pipe(withDescription("respond to a pending approval request"));
4383
4410
  //#endregion
4384
4411
  //#region src/cli/threads/archive.ts
4385
4412
  const archiveThreadCommand = make("archive", {
4386
4413
  thread: threadFlag,
4414
+ force: boolean("force").pipe(withAlias("f")),
4387
4415
  format: formatFlag
4388
- }, ({ thread, format }) => gen(function* () {
4416
+ }, ({ thread, force, format }) => gen(function* () {
4389
4417
  const application = yield* T3Application;
4390
4418
  const environment = yield* Environment;
4391
4419
  const output = yield* T3Output;
@@ -4394,6 +4422,11 @@ const archiveThreadCommand = make("archive", {
4394
4422
  env: environment.env
4395
4423
  });
4396
4424
  if (threadId === void 0) return yield* fail(new MissingThreadError({ message: "thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
4425
+ const envThreadId = environment.env.T3CODE_THREAD_ID;
4426
+ if (envThreadId !== void 0 && envThreadId.length > 0 && threadId === envThreadId && !force) return yield* fail(new SelfArchiveError({
4427
+ threadId,
4428
+ message: `cannot archive thread ${threadId}: matches T3CODE_THREAD_ID (are you trying to archive yourself?). Use --force to override.`
4429
+ }));
4397
4430
  const resolvedFormat = resolveOutputFormat(format, environment, "json");
4398
4431
  const dispatch = yield* application.archiveThread(threadId);
4399
4432
  if (resolvedFormat === "json") return yield* output.printJson(dispatch);
@@ -4437,7 +4470,7 @@ const callbackThreadCommand = make("callback", {
4437
4470
  stderr: "ignore"
4438
4471
  });
4439
4472
  const handle = yield* spawner.spawn(proc);
4440
- yield* (yield* handle.unref).pipe(ignore);
4473
+ yield* handle.unref.pipe(ignore);
4441
4474
  yield* output.printInfo(`background callback scheduled: ${fromThreadId} -> ${targetThreadId} (pid: ${handle.pid})`);
4442
4475
  return;
4443
4476
  }
@@ -4467,6 +4500,50 @@ const requireCommandProjectRef = fn("requireCommandProjectRef")(function* (input
4467
4500
  });
4468
4501
  //#endregion
4469
4502
  //#region src/cli/thread-format.ts
4503
+ function formatThreadShowJson(thread) {
4504
+ return {
4505
+ id: thread.id,
4506
+ projectId: thread.projectId,
4507
+ title: thread.title,
4508
+ status: thread.status,
4509
+ session: thread.session,
4510
+ latestTurn: thread.latestTurn,
4511
+ modelSelection: thread.modelSelection,
4512
+ runtimeMode: thread.runtimeMode,
4513
+ interactionMode: thread.interactionMode,
4514
+ branch: thread.branch,
4515
+ worktreePath: thread.worktreePath,
4516
+ archivedAt: thread.archivedAt,
4517
+ createdAt: thread.createdAt,
4518
+ updatedAt: thread.updatedAt,
4519
+ messageCount: thread.messageCount,
4520
+ hasPendingApprovals: thread.hasPendingApprovals,
4521
+ hasPendingUserInput: thread.hasPendingUserInput,
4522
+ hasActionableProposedPlan: thread.hasActionableProposedPlan,
4523
+ pendingApprovals: thread.pendingApprovals,
4524
+ pendingUserInputs: thread.pendingUserInputs
4525
+ };
4526
+ }
4527
+ function formatThreadShowHuman(thread) {
4528
+ const lines = [
4529
+ `title: ${thread.title}`,
4530
+ `id: ${thread.id}`,
4531
+ `status: ${thread.status}`,
4532
+ `model: ${thread.modelSelection.instanceId}/${thread.modelSelection.model}`,
4533
+ ...thread.branch !== null ? [`branch: ${thread.branch}`] : [],
4534
+ ...thread.worktreePath !== null ? [`worktree: ${thread.worktreePath}`] : [],
4535
+ `messages: ${thread.messageCount}`
4536
+ ];
4537
+ if (thread.pendingApprovals.length > 0) {
4538
+ const requestIds = thread.pendingApprovals.map((approval) => approval.requestId).join(", ");
4539
+ lines.push(`pending approvals: ${thread.pendingApprovals.length} (${requestIds})`);
4540
+ }
4541
+ if (thread.pendingUserInputs.length > 0) {
4542
+ const requestIds = thread.pendingUserInputs.map((input) => input.requestId).join(", ");
4543
+ lines.push(`pending user inputs: ${thread.pendingUserInputs.length} (${requestIds})`);
4544
+ }
4545
+ return `${lines.join("\n")}\n`;
4546
+ }
4470
4547
  function formatThreadsHuman(threads) {
4471
4548
  return threads.map((thread) => `- ${thread.title}\n id: ${thread.id}\n status: ${threadStatus(thread)}\n updated: ${thread.updatedAt}\n`).join("");
4472
4549
  }
@@ -4559,6 +4636,55 @@ function readInitialMessage(input) {
4559
4636
  if (input.message === void 0 || input.message.length === 0) return fail(new MessageInputError({ message: "message required unless --stdin is used" }));
4560
4637
  return succeed(input.message);
4561
4638
  }
4639
+ function readJsonAnswers(input) {
4640
+ if (input.answers !== void 0 && input.answers.length > 0 && input.fromStdin) return fail(new MessageInputError({ message: "pass --answers or --stdin, not both" }));
4641
+ if (input.fromStdin) return input.readStdin().pipe(flatMap(parseJsonAnswers));
4642
+ if (input.answers === void 0 || input.answers.length === 0) return fail(new MessageInputError({ message: "answers required unless --stdin is used" }));
4643
+ return parseJsonAnswers(input.answers);
4644
+ }
4645
+ function parseJsonAnswers(text) {
4646
+ try {
4647
+ const parsed = JSON.parse(text);
4648
+ return succeed(decodeUnknownSync(ProviderUserInputAnswers)(parsed));
4649
+ } catch {
4650
+ return fail(new MessageInputError({ message: "invalid JSON in answers" }));
4651
+ }
4652
+ }
4653
+ //#endregion
4654
+ //#region src/cli/input/service.ts
4655
+ var T3Input = class extends Service()("t3cli/T3Input") {};
4656
+ const respondThreadCommand = make("respond", {
4657
+ thread: threadFlag,
4658
+ request: string$2("request").pipe(withDescription$1("Pending user-input request id"), optional$2),
4659
+ answers: string$2("answers").pipe(optional$2),
4660
+ stdin: boolean("stdin"),
4661
+ format: formatFlag
4662
+ }, ({ thread, request, answers, stdin, format }) => gen(function* () {
4663
+ const inputService = yield* T3Input;
4664
+ const parsedAnswers = yield* readJsonAnswers({
4665
+ answers: getOrUndefined(answers),
4666
+ fromStdin: stdin,
4667
+ readStdin: inputService.readStdin
4668
+ });
4669
+ const application = yield* T3Application;
4670
+ const environment = yield* Environment;
4671
+ const output = yield* T3Output;
4672
+ const threadId = resolveThreadId({
4673
+ value: getOrUndefined(thread),
4674
+ env: environment.env
4675
+ });
4676
+ if (threadId === void 0) return yield* fail(new MissingThreadError({ message: "thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
4677
+ const requestId = getOrUndefined(request);
4678
+ if (requestId === void 0 || requestId.length === 0) return yield* fail(new MissingRequestError({ message: "request id is required: pass --request" }));
4679
+ const resolvedFormat = resolveOutputFormat(format, environment, "json");
4680
+ const result = yield* application.respondToThread({
4681
+ threadId,
4682
+ requestId,
4683
+ answers: parsedAnswers
4684
+ });
4685
+ if (resolvedFormat === "json") return yield* output.printJson(result);
4686
+ return yield* output.printInfo(`user input submitted: ${result.requestId}\nsequence: ${result.dispatch.sequence}`);
4687
+ })).pipe(withDescription("respond to a pending user-input request"));
4562
4688
  //#endregion
4563
4689
  //#region src/cli/model-options.ts
4564
4690
  function buildModelOptions(input) {
@@ -4593,9 +4719,6 @@ function setBooleanOption(options, id, value) {
4593
4719
  });
4594
4720
  }
4595
4721
  //#endregion
4596
- //#region src/cli/input/service.ts
4597
- var T3Input = class extends Service()("t3cli/T3Input") {};
4598
- //#endregion
4599
4722
  //#region src/cli/wait-events.ts
4600
4723
  function printWaitEventsNdjson(output, events) {
4601
4724
  return events.pipe(tap((event) => output.printNdjson(formatWaitEventNdjson(event))), runDrain);
@@ -4632,7 +4755,7 @@ function printWaitEventsHuman(output, events, options) {
4632
4755
  if (rendered) yield* output.writeStderr("\r\x1B[2K");
4633
4756
  yield* output.writeStdout(formatWaitDoneHuman(event.thread));
4634
4757
  });
4635
- }), runLast, flatMap$1((event) => {
4758
+ }), runLast, flatMap((event) => {
4636
4759
  if (isSome(event) && event.value.type === "done") return void_;
4637
4760
  return fail(new ThreadSessionError({
4638
4761
  message: `thread wait ended without done event: ${options.threadId}`,
@@ -4717,6 +4840,25 @@ const sendThreadCommand = make("send", {
4717
4840
  return yield* output.printInfo(`message sent: ${result.threadId}`);
4718
4841
  })).pipe(withDescription("send message to existing thread"));
4719
4842
  //#endregion
4843
+ //#region src/cli/threads/show.ts
4844
+ const showThreadCommand = make("show", {
4845
+ thread: threadFlag,
4846
+ format: formatFlag
4847
+ }, ({ thread, format }) => gen(function* () {
4848
+ const application = yield* T3Application;
4849
+ const environment = yield* Environment;
4850
+ const output = yield* T3Output;
4851
+ const threadId = resolveThreadId({
4852
+ value: getOrUndefined(thread),
4853
+ env: environment.env
4854
+ });
4855
+ if (threadId === void 0) return yield* fail(new MissingThreadError({ message: "thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
4856
+ const resolvedFormat = resolveOutputFormat(format, environment, "json");
4857
+ const detail = yield* application.showThread(threadId);
4858
+ if (resolvedFormat === "json") return yield* output.printJson(formatThreadShowJson(detail));
4859
+ return yield* output.writeStdout(formatThreadShowHuman(detail));
4860
+ })).pipe(withDescription("show thread status and pending requests"));
4861
+ //#endregion
4720
4862
  //#region src/cli/threads/start.ts
4721
4863
  const startThreadCommand = make("start", {
4722
4864
  project: projectFlag,
@@ -4832,6 +4974,9 @@ function createThreadCommand() {
4832
4974
  listThreadsCommand,
4833
4975
  startThreadCommand,
4834
4976
  sendThreadCommand,
4977
+ showThreadCommand,
4978
+ approveThreadCommand,
4979
+ respondThreadCommand,
4835
4980
  archiveThreadCommand,
4836
4981
  getThreadMessagesCommand,
4837
4982
  waitForThreadCommand,
@@ -4910,7 +5055,7 @@ var T3Version = class extends Service()("t3cli/T3Version") {};
4910
5055
  //#endregion
4911
5056
  //#region src/version/layer.ts
4912
5057
  const PackageJsonSchema = fromJsonString(Struct({ version: String$1 }));
4913
- const T3VersionBundledLive = sync$2(T3Version, () => ({ version: "0.8.0" }));
5058
+ const T3VersionBundledLive = sync$2(T3Version, () => ({ version: "0.9.1" }));
4914
5059
  effect(T3Version, gen(function* () {
4915
5060
  const packageJson = yield* (yield* FileSystem).readFileString(fileURLToPath(new URL("../../package.json", import.meta.url)));
4916
5061
  return { version: (yield* decodeUnknownEffect(PackageJsonSchema)(packageJson)).version };
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as threadFlag, c as worktreeFlag, i as projectPathFlag, n as modelFlags, o as threadFormatFlag, r as projectFlag, s as waitFormatFlag, t as formatFlag } from "./flags-CM7_iGdA.js";
1
+ import { Bd as waitFormatFlag, Fd as modelFlags, Id as projectFlag, Ld as projectPathFlag, Pd as formatFlag, Rd as threadFlag, Vd as worktreeFlag, zd as threadFormatFlag } from "./shared.js";
2
2
  export { formatFlag, modelFlags, projectFlag, projectPathFlag, threadFlag, threadFormatFlag, waitFormatFlag, worktreeFlag };
package/dist/config.js CHANGED
@@ -1,4 +1,2 @@
1
- import { n as T3Config } from "./service-CLmRO2Dp.js";
2
- import { n as UrlError, t as ConfigError } from "./error-BHRnjLux.js";
3
- import { n as makeT3Config, t as T3ConfigLive } from "./layer-DUv99vsS.js";
1
+ import { Gd as T3Config, U as ConfigError, W as UrlError, h as makeT3Config, m as T3ConfigLive } from "./shared.js";
4
2
  export { ConfigError, T3Config, T3ConfigLive, UrlError, makeT3Config };
@@ -1,7 +1,4 @@
1
- import { Mn as mergeAll, Nn as provide } from "./Path-D8WPdPwR.js";
2
- import { n as T3AuthTransportLive } from "./transport-MI0Z3d2T.js";
3
- import { a as makeT3CodeConnectionProvider, i as T3CodeConnectionProviderLive, o as layerWebSocketConstructor, r as T3CodeConnectionProvider, s as layerUndici, t as T3RpcLive } from "./layer-CMo36MrX.js";
4
- import { n as T3CodeConnectionError } from "./error-ChTsLQTu.js";
1
+ import { F as T3CodeConnectionError, K as layerWebSocketConstructor, S as T3AuthTransportLive, d as T3CodeConnectionProvider, f as T3CodeConnectionProviderLive, om as mergeAll, p as makeT3CodeConnectionProvider, q as layerUndici, sm as provide, u as T3RpcLive } from "./shared.js";
5
2
  //#region src/connection/layer.ts
6
3
  function makeT3CodeRpcLayer() {
7
4
  return T3RpcLive.pipe(provide(T3AuthTransportLive));
package/dist/index.js CHANGED
@@ -1,5 +1,2 @@
1
- import { t as T3Application } from "./service-ybOWV9pL.js";
2
- import { n as AuthAppLayer, t as AppLayer } from "./layer-DwI3Skkh.js";
3
- import "./application.js";
4
- import "./runtime.js";
1
+ import { Nd as T3Application, n as AuthAppLayer, t as AppLayer } from "./shared.js";
5
2
  export { AppLayer, AuthAppLayer, T3Application };
package/dist/layout.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as resolveT3BaseDir, t as readT3LayoutFromNodeProcess } from "./base-dir-R12OMDso.js";
1
+ import { M as readT3LayoutFromNodeProcess, N as resolveT3BaseDir } from "./shared.js";
2
2
  export { readT3LayoutFromNodeProcess, resolveT3BaseDir };
@@ -1,2 +1,2 @@
1
- import { l as T3OrchestrationLayer, u as T3Orchestration } from "./layer-DwI3Skkh.js";
1
+ import { G as T3Orchestration, l as T3OrchestrationLayer } from "./shared.js";
2
2
  export { T3Orchestration, T3OrchestrationLayer };
package/dist/rpc.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as RpcError } from "./error-ChTsLQTu.js";
1
+ import { P as RpcError } from "./shared.js";
2
2
  export { RpcError };
package/dist/runtime.js CHANGED
@@ -1,3 +1,2 @@
1
- import { a as T3AuthTransportLayer, c as T3LocalAuthTokenLayer, i as T3AuthPairingLayer, l as T3OrchestrationLayer, n as AuthAppLayer, o as T3LocalAuthLayer, r as T3AuthLayer, s as T3LocalAuthOriginLayer, t as AppLayer } from "./layer-DwI3Skkh.js";
2
- import { t as NodeEnvironmentLive } from "./layer-DHhKS5jd.js";
1
+ import { J as NodeEnvironmentLive, a as T3AuthTransportLayer, c as T3LocalAuthTokenLayer, i as T3AuthPairingLayer, l as T3OrchestrationLayer, n as AuthAppLayer, o as T3LocalAuthLayer, r as T3AuthLayer, s as T3LocalAuthOriginLayer, t as AppLayer } from "./shared.js";
3
2
  export { AppLayer, AuthAppLayer, NodeEnvironmentLive, T3AuthLayer, T3AuthPairingLayer, T3AuthTransportLayer, T3LocalAuthLayer, T3LocalAuthOriginLayer, T3LocalAuthTokenLayer, T3OrchestrationLayer };
package/dist/scope.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as resolveWorktreePath, n as resolveProjectRef, r as resolveThreadId, t as resolveCommandProjectRef } from "./scope-GycYiJ54.js";
1
+ import { Ad as resolveProjectRef, Md as resolveWorktreePath, jd as resolveThreadId, kd as resolveCommandProjectRef } from "./shared.js";
2
2
  export { resolveCommandProjectRef, resolveProjectRef, resolveThreadId, resolveWorktreePath };