t3code-cli 0.14.1 → 0.15.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.
- package/README.md +37 -1
- package/dist/application.d.ts +2 -2
- package/dist/application.js +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +1 -1
- package/dist/bin.js +1305 -424
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -1
- package/dist/client-runtime/authorization.d.ts +1 -1
- package/dist/client-runtime/authorization.js +1 -1
- package/dist/client-runtime/connection.d.ts +1 -1
- package/dist/client-runtime/connection.js +1 -1
- package/dist/client-runtime/environment.d.ts +7 -1
- package/dist/client-runtime/environment.js +1 -1
- package/dist/client-runtime/errors.js +1 -1
- package/dist/client-runtime/operations/projects.d.ts +2 -2
- package/dist/client-runtime/operations/projects.js +2 -2
- package/dist/client-runtime/operations.d.ts +2 -2
- package/dist/client-runtime/operations.js +2 -2
- package/dist/client-runtime/platform.d.ts +1 -1
- package/dist/client-runtime/platform.js +1 -1
- package/dist/client-runtime/relay.d.ts +13 -2
- package/dist/client-runtime/relay.js +12 -2
- package/dist/client-runtime/rpc.d.ts +2 -2
- package/dist/client-runtime/rpc.js +2 -2
- package/dist/client-runtime/state/assets.d.ts +17 -11
- package/dist/client-runtime/state/assets.js +1 -1
- package/dist/client-runtime/state/auth.d.ts +1 -1
- package/dist/client-runtime/state/auth.js +1 -1
- package/dist/client-runtime/state/connections.js +1 -1
- package/dist/client-runtime/state/entities.d.ts +1 -1
- package/dist/client-runtime/state/entities.js +1 -1
- package/dist/client-runtime/state/filesystem.d.ts +1 -1
- package/dist/client-runtime/state/filesystem.js +1 -1
- package/dist/client-runtime/state/git.d.ts +6 -5
- package/dist/client-runtime/state/git.js +1 -1
- package/dist/client-runtime/state/models.d.ts +1 -1
- package/dist/client-runtime/state/models.js +1 -1
- package/dist/client-runtime/state/orchestration.d.ts +42 -2
- package/dist/client-runtime/state/orchestration.js +13 -1
- package/dist/client-runtime/state/presentation.d.ts +15 -3
- package/dist/client-runtime/state/presentation.js +1 -1
- package/dist/client-runtime/state/preview.d.ts +58 -48
- package/dist/client-runtime/state/preview.js +3 -2
- package/dist/client-runtime/state/project-grouping.d.ts +26 -2
- package/dist/client-runtime/state/project-grouping.js +83 -3
- package/dist/client-runtime/state/projects.d.ts +24 -18
- package/dist/client-runtime/state/projects.js +1 -1
- package/dist/client-runtime/state/pull-requests.d.ts +478 -0
- package/dist/client-runtime/state/pull-requests.js +172 -0
- package/dist/client-runtime/state/relay.d.ts +1 -1
- package/dist/client-runtime/state/relay.js +1 -1
- package/dist/client-runtime/state/review.d.ts +16 -1
- package/dist/client-runtime/state/review.js +27 -6
- package/dist/client-runtime/state/runtime.d.ts +2 -2
- package/dist/client-runtime/state/runtime.js +2 -2
- package/dist/client-runtime/state/server.d.ts +311 -172
- package/dist/client-runtime/state/server.js +192 -16
- package/dist/client-runtime/state/session.d.ts +77 -7
- package/dist/client-runtime/state/session.js +32 -3
- package/dist/client-runtime/state/shell.d.ts +47 -7
- package/dist/client-runtime/state/shell.js +1 -1
- package/dist/client-runtime/state/source-control.d.ts +2 -2
- package/dist/client-runtime/state/source-control.js +1 -1
- package/dist/client-runtime/state/subagentRuntime.d.ts +145 -0
- package/dist/client-runtime/state/subagentRuntime.js +521 -0
- package/dist/client-runtime/state/terminal.d.ts +17 -17
- package/dist/client-runtime/state/terminal.js +1 -1
- package/dist/client-runtime/state/thread-search.d.ts +23 -0
- package/dist/client-runtime/state/thread-search.js +38 -0
- package/dist/client-runtime/state/thread-settled.d.ts +32 -4
- package/dist/client-runtime/state/thread-settled.js +2 -157
- package/dist/client-runtime/state/thread-sort.d.ts +59 -2
- package/dist/client-runtime/state/thread-sort.js +128 -2
- package/dist/client-runtime/state/threads.d.ts +115 -3
- package/dist/client-runtime/state/threads.js +309 -28
- package/dist/client-runtime/state/vcs.d.ts +14 -14
- package/dist/client-runtime/state/vcs.js +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/connection.d.ts +1 -1
- package/dist/connection.js +1 -1
- package/dist/contracts.d.ts +1 -1
- package/dist/contracts.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +1 -1
- package/dist/orchestration.d.ts +155 -6
- package/dist/orchestration.js +2 -2
- package/dist/preview.d.ts +1 -1
- package/dist/preview.js +1 -1
- package/dist/rpc.d.ts +887 -360
- package/dist/rpc.js +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +1 -1
- package/dist/shared/DrainableWorker.js +1 -1
- package/dist/shared/KeyedCoalescingWorker.js +1 -1
- package/dist/shared/Net.d.ts +6 -0
- package/dist/shared/Net.js +2 -1
- package/dist/shared/advertisedEndpoint.d.ts +1 -1
- package/dist/shared/advertisedEndpoint.js +1 -1
- package/dist/shared/agentAwareness.d.ts +1 -1
- package/dist/shared/backgroundActivitySettings.d.ts +1 -1
- package/dist/shared/composerInlineTokens.js +1 -1
- package/dist/shared/connectAuth.d.ts +23 -4
- package/dist/shared/connectAuth.js +40 -7
- package/dist/shared/devHome.js +1 -1
- package/dist/shared/dpop.js +1 -1
- package/dist/shared/git.d.ts +1 -1
- package/dist/shared/httpObservability.js +1 -1
- package/dist/shared/httpReadiness.js +1 -1
- package/dist/shared/keybindings.d.ts +2 -2
- package/dist/shared/keybindings.js +15 -1
- package/dist/shared/model.d.ts +1 -1
- package/dist/shared/oauthScope.js +1 -1
- package/dist/shared/observability.d.ts +8 -1
- package/dist/shared/observability.js +49 -5
- package/dist/shared/path.js +1 -1
- package/dist/shared/preview.js +1 -1
- package/dist/shared/previewViewport.d.ts +1 -1
- package/dist/shared/previewViewport.js +1 -1
- package/dist/shared/projectFavicon.d.ts +2 -1
- package/dist/shared/projectFavicon.js +13 -1
- package/dist/shared/projectScripts.d.ts +1 -1
- package/dist/shared/relayAuth.js +1 -1
- package/dist/shared/relayClient.d.ts +1 -1
- package/dist/shared/relayClient.js +1 -1
- package/dist/shared/relayJwt.js +1 -1
- package/dist/shared/relayTracing.js +1 -1
- package/dist/shared/relayUrl.js +1 -1
- package/dist/shared/remote.js +1 -1
- package/dist/shared/schemaYaml.js +3 -3
- package/dist/shared/semver.js +1 -1
- package/dist/shared/serverSettings.d.ts +1 -1
- package/dist/shared/serverSettings.js +1 -1
- package/dist/shared/shell.d.ts +6 -1
- package/dist/shared/shell.js +42 -4
- package/dist/shared/sourceControl.d.ts +1 -1
- package/dist/shared/t3ProjectFile.d.ts +9 -1
- package/dist/shared/t3ProjectFile.js +12 -2
- package/dist/shared/terminalLabels.d.ts +1 -1
- package/dist/shared/threadEnvMode.d.ts +29 -0
- package/dist/shared/threadEnvMode.js +24 -0
- package/dist/shared/toolActivity.d.ts +1 -1
- package/dist/shared/usageFormat.d.ts +34 -0
- package/dist/shared/usageFormat.js +176 -0
- package/dist/shared/usageMerge.d.ts +78 -0
- package/dist/shared/usageMerge.js +241 -0
- package/dist/shared.d.ts +8268 -1372
- package/dist/shared.js +22185 -19774
- package/dist/t3tools.d.ts +2 -2
- package/dist/t3tools.js +2 -2
- package/package.json +5 -5
- package/src/application/error.ts +2 -2
- package/src/application/index.ts +2 -0
- package/src/application/service.ts +43 -5
- package/src/application/thread-commands.ts +78 -0
- package/src/application/threads.ts +156 -17
- package/src/cli/app.ts +4 -0
- package/src/cli/ask-lifecycle.ts +331 -0
- package/src/cli/ask.ts +390 -0
- package/src/cli/error.ts +70 -0
- package/src/cli/format/thread.ts +49 -7
- package/src/cli/search.ts +48 -0
- package/src/cli/thread.ts +12 -0
- package/src/cli/threads/messages.ts +33 -3
- package/src/cli/threads/pin.ts +46 -0
- package/src/cli/threads/send.ts +5 -1
- package/src/cli/threads/settle.ts +46 -0
- package/src/cli/threads/snooze.ts +117 -0
- package/src/cli/threads/start.ts +6 -1
- package/src/cli/threads/unpin.ts +48 -0
- package/src/cli/threads/unsettle.ts +48 -0
- package/src/cli/threads/unsnooze.ts +48 -0
- package/src/config/persist/schema.ts +1 -1
- package/src/connection/prepared.ts +12 -2
- package/src/orchestration/error.ts +10 -0
- package/src/orchestration/index.ts +1 -0
- package/src/orchestration/layer.ts +78 -0
- package/src/orchestration/service.ts +16 -3
- package/src/rpc/error.ts +2 -0
- package/src/rpc/operation.ts +2 -0
- package/src/rpc/ws-group.ts +3 -0
- package/src/runtime/layer.ts +9 -4
package/dist/bin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { a as __toESM, i as __require, t as __commonJSMin } from "./rolldown-runtime.js";
|
|
3
|
-
import { $
|
|
3
|
+
import { $A as runHead, $E as resolveThreadId, $M as succeed$2, $O as toggle, $j as ignore, $k as value$2, AA as callback$1, AN as Service, AO as withDescription$1, Aj as andThen, Ak as DurationFromString, BA as fromIterable, BD as forceFlag, BN as getOrUndefined, BO as isParam, Bj as effectify, CA as Path$1, CM as sync, CN as format, CO as parseConfig, Cj as BadArgument, Ck as QuitError, DA as Size, DM as timeoutOrElse, DO as optional$2, Dj as acquireRelease, EA as FileTypeId, EO as integer$1, Ej as makeRunMain, Ek as make$11, FN as fromNullishOr, FO as extractSingleParams, GD as replaceFlag, GN as none, GO as confirm, Gj as flatMap, Gk as decodeUnknownOption, HA as isStream, HD as modelFlags, HN as isSome, HO as optional$1, IA as empty, IN as fromUndefinedOr, Ij as catchFilter, Is as layerNode$1, JD as threadFormatFlag, JO as integer, Jj as forEach, KA as merge, KD as selfActionForceFlag, KN as some, KO as date, Kj as fn, Kk as decodeUnknownSync, LA as filter, LN as getOrElse, LO as getParamMetadata, Lj as catchTag, Lk as String$1, MM as uninterruptible, MN as make$12, MO as error, Mj as as, Mk as Literal, NM as void_, NN as flatMap$1, NO as log, Nj as asVoid, OA as WatchBackend, OM as tryPromise, ON as toMillis, OO as string$2, Oj as addFinalizer, Ok as DateTimeUtcFromString, PA as decodeText, PO as argumentKind, Pj as callback, QA as runForEach, QD as canRenderLiveTerminal, QM as provideMerge, QO as text, Qj as gen, RO as getUnderlyingSingleOrThrow, Rj as catchTags, Rk as Struct, SM as suspend, SN as succeed$3, SO as toImpl, Sj as unbounded, TA as FileSystem, TO as choice, Tj as systemError, Tk as isQuitError, UA as map$1, UD as projectFlag, UM as fail$1, UO as string$1, Uj as fail, VA as fromQueue, VD as formatFlag, VN as isNone, VO as mapEffect$1, Vs as layer$13, WD as projectPathFlag, WN as match, WO as variadic$1, Wk as decodeUnknownEffect, XA as runDrain, XD as worktreeFlag, XM as mergeAll, XO as run$3, Xs as resolveSnoozePresets, YA as run$2, YD as waitFormatFlag, YM as effect, YO as password, ZA as runFold, ZD as yesFlag, ZE as resolveCommandProjectRef, ZM as provide, ZO as select, Zj as forkScoped, Zk as optionalKey, _M as runFork, _N as fail$2, _O as getGlobalFlagsForCommandTree, _j as offerUnsafe, _k as UnrecognizedOption, aA as make$5, aD as T3Config, aM as match$1, aN as make$13, ac as derivePendingUserInputs, aj as tap, ak as magenta, bN as isResult, bO as checkForDuplicateFlags, cA as ExitCode, cO as T3Application, cP as dual, cc as threadStatus, cj as get$1, ck as getChoiceKeys, dA as makeHandle, dM as orDie, dP as pipeArguments, dj as isSink, dk as isFalseValue, dw as ProviderUserInputAnswers, eA as Crypto, eD as resolveWorktreePath, eM as interrupt, eN as sync$1, eO as humanJsonNdjsonFormatChoices, ej as runLast, ek as annotate, fk as isTrueValue, gM as result$1, gO as getGlobalFlagsForCommandPath, gj as offer, gk as UnknownSubcommand, hM as provideService, hO as Wizard, hj as make$9, hk as ShowHelp, iA as fdName, iD as layer$12, iM as mapError, iN as isDone, iO as resolveOutputFormat, iP as isNullish, ic as derivePendingApprovals, ij as takeUntil, ik as green, jN as empty$1, jO as Formatter, kA as make$8, kM as try_, kN as Reference, kO as withDefault, lA as ProcessId, lM as onInterrupt, lP as identity$1, lj as make$10, lk as getTypeName, mM as provideContext, mO as LogLevel, mj as failCauseUnsafe, mk as InvalidValue, nA as fromReadable, nD as ThreadSessionError, nN as _await, nO as isAgentEnvironment, nP as isNotNull, nc as cliEnvironmentSetting, nj as succeed$5, nk as bold, oA as parseFdName, oM as matchEffect, oN as makeUnsafe, oO as loadT3CliEnv, oc as isThreadActive, oj as transduce, ok as red, pM as provide$1, pO as BuiltIns, pj as endUnsafe, qD as threadFlag, qO as float, qj as fnUntraced, qk as fromJsonString, rA as fromWritable, rD as CliRuntime, rM as map, rN as doneUnsafe, rO as isInteractiveHumanTerminal, rP as isNotUndefined, rc as T3Auth, rk as cyanBright, sA as ChildProcessSpawner, sN as succeed$4, sP as isUndefined, sc as latestAssistantMessage, sj as unwrap, sk as white, tA as make$7, tD as ProjectLookupError, tN as MinimumLogLevel, tP as hasProperty, tc as CliPath, tk as blackBright, uA as make$6, uN as succeed$1, uP as pipe, uj as drain, uk as isBoolean, vA as formatIso, vM as scoped, vO as getHelpForCommandPath, vj as poll, vk as isCliError, wA as TypeId$2, wO as boolean, wj as badArgument, wk as Terminal, xM as succeed, xN as isSuccess, xO as makeCommand, xj as take, yA as nowAsDate, yM as serviceOption, yO as TypeId$3, yj as shutdown, zD as envNameFlag, zO as isFlagParam, zj as catch_, zk as TaggedErrorClass, zn as BaseAppLayer, zs as layerNode } from "./shared.js";
|
|
4
4
|
import * as OS from "node:os";
|
|
5
5
|
import os, { homedir } from "node:os";
|
|
6
6
|
import * as NodeChildProcess from "node:child_process";
|
|
@@ -14,7 +14,7 @@ import * as readline from "node:readline";
|
|
|
14
14
|
import process$1 from "node:process";
|
|
15
15
|
import tty from "node:tty";
|
|
16
16
|
//#endregion
|
|
17
|
-
//#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.
|
|
17
|
+
//#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.103_effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c566_933a6d6775be5e2696c624c811da82a4/node_modules/@effect/platform-node/dist/NodeRuntime.js
|
|
18
18
|
/**
|
|
19
19
|
* Node.js process runner for Effect programs.
|
|
20
20
|
*
|
|
@@ -66,7 +66,18 @@ const runMain = /* @__PURE__ */ makeRunMain(({ fiber, teardown }) => {
|
|
|
66
66
|
process.on("SIGTERM", onSigint);
|
|
67
67
|
});
|
|
68
68
|
//#endregion
|
|
69
|
-
//#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.
|
|
69
|
+
//#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.107_effect@4.0.0-beta.103_patch_hash=af36b7948b_4e5b8af3fb2887013aca0b70cb08d812/node_modules/@effect/platform-node-shared/dist/internal/nodeChildProcessSpawner.js
|
|
70
|
+
const buildSpawnOptions = (options, base, platform) => {
|
|
71
|
+
const detached = options.detached ?? platform !== "win32";
|
|
72
|
+
return {
|
|
73
|
+
...base,
|
|
74
|
+
detached,
|
|
75
|
+
shell: options.shell,
|
|
76
|
+
windowsHide: options.windowsHide ?? !detached
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.107_effect@4.0.0-beta.103_patch_hash=af36b7948b_4e5b8af3fb2887013aca0b70cb08d812/node_modules/@effect/platform-node-shared/dist/internal/utils.js
|
|
70
81
|
/** @internal */
|
|
71
82
|
const handleErrnoException = (module, method) => (err, [path]) => {
|
|
72
83
|
let reason = "Unknown";
|
|
@@ -103,7 +114,7 @@ const handleErrnoException = (module, method) => (err, [path]) => {
|
|
|
103
114
|
});
|
|
104
115
|
};
|
|
105
116
|
//#endregion
|
|
106
|
-
//#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.
|
|
117
|
+
//#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.107_effect@4.0.0-beta.103_patch_hash=af36b7948b_4e5b8af3fb2887013aca0b70cb08d812/node_modules/@effect/platform-node-shared/dist/NodeChildProcessSpawner.js
|
|
107
118
|
const toError = (error) => error instanceof globalThis.Error ? error : new globalThis.Error(String(error));
|
|
108
119
|
const toPlatformError = (method, error, command) => {
|
|
109
120
|
const { commands } = flattenCommand(command);
|
|
@@ -113,6 +124,12 @@ const toPlatformError = (method, error, command) => {
|
|
|
113
124
|
}, "");
|
|
114
125
|
return handleErrnoException("ChildProcess", method)(error, [commandStr]);
|
|
115
126
|
};
|
|
127
|
+
const taskkill = (childProcess, onExit = () => {}) => NodeChildProcess.execFile("taskkill", [
|
|
128
|
+
"/pid",
|
|
129
|
+
String(childProcess.pid),
|
|
130
|
+
"/T",
|
|
131
|
+
"/F"
|
|
132
|
+
], { windowsHide: true }, onExit);
|
|
116
133
|
/**
|
|
117
134
|
* Layer that provides the `NodeChildProcessSpawner` implementation.
|
|
118
135
|
*
|
|
@@ -286,7 +303,7 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
|
|
|
286
303
|
});
|
|
287
304
|
const killProcessGroup = (command, childProcess, signal) => {
|
|
288
305
|
if (globalThis.process.platform === "win32") return callback((resume) => {
|
|
289
|
-
|
|
306
|
+
taskkill(childProcess, (error) => {
|
|
290
307
|
if (error) resume(fail(toPlatformError("kill", toError(error), command)));
|
|
291
308
|
else resume(void_);
|
|
292
309
|
});
|
|
@@ -300,7 +317,7 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
|
|
|
300
317
|
};
|
|
301
318
|
const killProcessGroupOnExit = (childProcess, signal) => {
|
|
302
319
|
if (globalThis.process.platform === "win32") {
|
|
303
|
-
|
|
320
|
+
taskkill(childProcess);
|
|
304
321
|
return;
|
|
305
322
|
}
|
|
306
323
|
try {
|
|
@@ -349,13 +366,11 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
|
|
|
349
366
|
const cwd = yield* resolveWorkingDirectory(cmd.options);
|
|
350
367
|
const env = resolveEnvironment(cmd.options);
|
|
351
368
|
const stdio = buildStdioArray(stdinConfig, stdoutConfig, stderrConfig, resolvedAdditionalFds);
|
|
352
|
-
const [childProcess, exitSignal] = yield* acquireRelease(spawn(cmd, {
|
|
369
|
+
const [childProcess, exitSignal] = yield* acquireRelease(spawn(cmd, buildSpawnOptions(cmd.options, {
|
|
353
370
|
cwd,
|
|
354
371
|
env,
|
|
355
|
-
stdio
|
|
356
|
-
|
|
357
|
-
shell: cmd.options.shell
|
|
358
|
-
}), fnUntraced(function* ([childProcess, exitSignal]) {
|
|
372
|
+
stdio
|
|
373
|
+
}, process.platform)), fnUntraced(function* ([childProcess, exitSignal]) {
|
|
359
374
|
const exited = yield* isDone(exitSignal);
|
|
360
375
|
const killWithTimeout = withTimeout(childProcess, cmd, cmd.options);
|
|
361
376
|
if (exited) {
|
|
@@ -451,6 +466,7 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
|
|
|
451
466
|
}
|
|
452
467
|
}
|
|
453
468
|
const handle = handles[handles.length - 1];
|
|
469
|
+
const kill = (options) => forEach([...handles].reverse(), (handle) => ignore(handle.kill(options)), { discard: true });
|
|
454
470
|
const unref = gen(function* () {
|
|
455
471
|
const rerefs = [];
|
|
456
472
|
for (const handle of handles) rerefs.push(yield* handle.unref);
|
|
@@ -460,7 +476,7 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
|
|
|
460
476
|
pid: handle.pid,
|
|
461
477
|
exitCode: handle.exitCode,
|
|
462
478
|
isRunning: handle.isRunning,
|
|
463
|
-
kill
|
|
479
|
+
kill,
|
|
464
480
|
stdin: handle.stdin,
|
|
465
481
|
stdout: handle.stdout,
|
|
466
482
|
stderr: handle.stderr,
|
|
@@ -505,7 +521,7 @@ const flattenCommand = (command) => {
|
|
|
505
521
|
};
|
|
506
522
|
};
|
|
507
523
|
//#endregion
|
|
508
|
-
//#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.
|
|
524
|
+
//#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.107_effect@4.0.0-beta.103_patch_hash=af36b7948b_4e5b8af3fb2887013aca0b70cb08d812/node_modules/@effect/platform-node-shared/dist/NodeCrypto.js
|
|
509
525
|
/**
|
|
510
526
|
* Node-compatible implementation of Effect's `Crypto` service.
|
|
511
527
|
*
|
|
@@ -535,7 +551,7 @@ const digest = (algorithm, data) => try_({
|
|
|
535
551
|
})
|
|
536
552
|
});
|
|
537
553
|
//#endregion
|
|
538
|
-
//#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.
|
|
554
|
+
//#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.103_effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c566_933a6d6775be5e2696c624c811da82a4/node_modules/@effect/platform-node/dist/NodeCrypto.js
|
|
539
555
|
/**
|
|
540
556
|
* The `NodeCrypto` module provides the Node.js `Crypto` service layer for
|
|
541
557
|
* Effect programs. Provide {@link layer} at the edge of a Node application,
|
|
@@ -560,7 +576,7 @@ const layer$9 = /* @__PURE__ */ succeed$2(Crypto, /* @__PURE__ */ make$7({
|
|
|
560
576
|
digest
|
|
561
577
|
}));
|
|
562
578
|
//#endregion
|
|
563
|
-
//#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.
|
|
579
|
+
//#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.107_effect@4.0.0-beta.103_patch_hash=af36b7948b_4e5b8af3fb2887013aca0b70cb08d812/node_modules/@effect/platform-node-shared/dist/NodeFileSystem.js
|
|
564
580
|
/**
|
|
565
581
|
* Shared Node-compatible implementation of Effect's `FileSystem` service.
|
|
566
582
|
*
|
|
@@ -649,7 +665,7 @@ const makeTempDirectoryScoped = /*#__PURE__*/ (() => {
|
|
|
649
665
|
const openFactory = (method) => {
|
|
650
666
|
const nodeOpen = effectify(NFS.open, handleErrnoException("FileSystem", method), handleBadArgument(method));
|
|
651
667
|
const nodeClose = effectify(NFS.close, handleErrnoException("FileSystem", method), handleBadArgument(method));
|
|
652
|
-
return (path, options) => pipe(acquireRelease(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie(nodeClose(fd))), map((fd) => makeFile(
|
|
668
|
+
return (path, options) => pipe(acquireRelease(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie(nodeClose(fd))), map((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false)));
|
|
653
669
|
};
|
|
654
670
|
const open = /*#__PURE__*/ openFactory("open");
|
|
655
671
|
const makeFile = /*#__PURE__*/ (() => {
|
|
@@ -683,7 +699,7 @@ const makeFile = /*#__PURE__*/ (() => {
|
|
|
683
699
|
return sync(() => {
|
|
684
700
|
if (from === "start") this.position = offsetSize;
|
|
685
701
|
else if (from === "current") this.position = this.position + offsetSize;
|
|
686
|
-
return this.position;
|
|
702
|
+
return Size(this.position);
|
|
687
703
|
});
|
|
688
704
|
}
|
|
689
705
|
read(buffer) {
|
|
@@ -831,8 +847,8 @@ const utimes = /*#__PURE__*/ (() => {
|
|
|
831
847
|
const nodeUtimes = /*#__PURE__*/ effectify(NFS.utimes, /*#__PURE__*/ handleErrnoException("FileSystem", "utime"), /*#__PURE__*/ handleBadArgument("utime"));
|
|
832
848
|
return (path, atime, mtime) => nodeUtimes(path, atime, mtime);
|
|
833
849
|
})();
|
|
834
|
-
const watchNode = (path) => callback$1((queue) => acquireRelease(sync(() => {
|
|
835
|
-
const watcher = NFS.watch(path, { recursive:
|
|
850
|
+
const watchNode = (path, options) => callback$1((queue) => acquireRelease(sync(() => {
|
|
851
|
+
const watcher = NFS.watch(path, { recursive: options?.recursive ?? false }, (event, path) => {
|
|
836
852
|
if (!path) return;
|
|
837
853
|
switch (event) {
|
|
838
854
|
case "rename":
|
|
@@ -869,7 +885,7 @@ const watchNode = (path) => callback$1((queue) => acquireRelease(sync(() => {
|
|
|
869
885
|
});
|
|
870
886
|
return watcher;
|
|
871
887
|
}), (watcher) => sync(() => watcher.close())));
|
|
872
|
-
const watch = (backend, path) => stat(path).pipe(map((stat) => backend.pipe(flatMap$1((_) => _.register(path, stat)), getOrElse(() => watchNode(path)))), unwrap);
|
|
888
|
+
const watch = (backend, path, options) => stat(path).pipe(map((stat) => backend.pipe(flatMap$1((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, options)))), unwrap);
|
|
873
889
|
const writeFile = (path, data, options) => callback((resume, signal) => {
|
|
874
890
|
try {
|
|
875
891
|
NFS.writeFile(path, data, {
|
|
@@ -908,13 +924,13 @@ const makeFileSystem = /*#__PURE__*/ map(/*#__PURE__*/ serviceOption(WatchBacken
|
|
|
908
924
|
symlink,
|
|
909
925
|
truncate,
|
|
910
926
|
utimes,
|
|
911
|
-
watch(path) {
|
|
912
|
-
return watch(backend, path);
|
|
927
|
+
watch(path, options) {
|
|
928
|
+
return watch(backend, path, options);
|
|
913
929
|
},
|
|
914
930
|
writeFile
|
|
915
931
|
}));
|
|
916
932
|
//#endregion
|
|
917
|
-
//#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.
|
|
933
|
+
//#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.103_effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c566_933a6d6775be5e2696c624c811da82a4/node_modules/@effect/platform-node/dist/NodeFileSystem.js
|
|
918
934
|
/**
|
|
919
935
|
* Node.js `FileSystem` layer for programs that perform real filesystem I/O.
|
|
920
936
|
*
|
|
@@ -933,7 +949,7 @@ const makeFileSystem = /*#__PURE__*/ map(/*#__PURE__*/ serviceOption(WatchBacken
|
|
|
933
949
|
*/
|
|
934
950
|
const layer$7 = /* @__PURE__ */ effect(FileSystem)(makeFileSystem);
|
|
935
951
|
//#endregion
|
|
936
|
-
//#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.
|
|
952
|
+
//#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.107_effect@4.0.0-beta.103_patch_hash=af36b7948b_4e5b8af3fb2887013aca0b70cb08d812/node_modules/@effect/platform-node-shared/dist/NodePath.js
|
|
937
953
|
/**
|
|
938
954
|
* Node-backed provider for Effect's `Path` service.
|
|
939
955
|
*
|
|
@@ -944,26 +960,34 @@ const layer$7 = /* @__PURE__ */ effect(FileSystem)(makeFileSystem);
|
|
|
944
960
|
*
|
|
945
961
|
* @since 4.0.0
|
|
946
962
|
*/
|
|
947
|
-
const
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
963
|
+
const fileUrlOps = (windows) => ({
|
|
964
|
+
fromFileUrl: (url) => try_({
|
|
965
|
+
try: () => NodeUrl.fileURLToPath(url, { windows }),
|
|
966
|
+
catch: (cause) => new BadArgument({
|
|
967
|
+
module: "Path",
|
|
968
|
+
method: "fromFileUrl",
|
|
969
|
+
cause
|
|
970
|
+
})
|
|
971
|
+
}),
|
|
972
|
+
toFileUrl: (path) => try_({
|
|
973
|
+
try: () => NodeUrl.pathToFileURL(path, { windows }),
|
|
974
|
+
catch: (cause) => new BadArgument({
|
|
975
|
+
module: "Path",
|
|
976
|
+
method: "toFileUrl",
|
|
977
|
+
cause
|
|
978
|
+
})
|
|
953
979
|
})
|
|
954
980
|
});
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
981
|
+
({
|
|
982
|
+
...Path.posix,
|
|
983
|
+
.../*#__PURE__*/ fileUrlOps(false)
|
|
984
|
+
});
|
|
985
|
+
({
|
|
986
|
+
...Path.win32,
|
|
987
|
+
.../*#__PURE__*/ fileUrlOps(true)
|
|
962
988
|
});
|
|
963
|
-
({ ...Path.posix });
|
|
964
|
-
({ ...Path.win32 });
|
|
965
989
|
//#endregion
|
|
966
|
-
//#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.
|
|
990
|
+
//#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.103_effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c566_933a6d6775be5e2696c624c811da82a4/node_modules/@effect/platform-node/dist/NodePath.js
|
|
967
991
|
/**
|
|
968
992
|
* Node.js layers for Effect's `Path` service.
|
|
969
993
|
*
|
|
@@ -984,11 +1008,10 @@ const toFileUrl = (path) => try_({
|
|
|
984
1008
|
const layer$5 = /* @__PURE__ */ succeed$2(Path$1)({
|
|
985
1009
|
[TypeId$2]: TypeId$2,
|
|
986
1010
|
...Path,
|
|
987
|
-
|
|
988
|
-
toFileUrl
|
|
1011
|
+
.../*#__PURE__*/ fileUrlOps(void 0)
|
|
989
1012
|
});
|
|
990
1013
|
//#endregion
|
|
991
|
-
//#region node_modules/.pnpm/effect@4.0.0-beta.
|
|
1014
|
+
//#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/Stdio.js
|
|
992
1015
|
/**
|
|
993
1016
|
* Service contract for command-line arguments and standard input, output, and
|
|
994
1017
|
* error output. It lets programs depend on standard I/O through the Effect
|
|
@@ -1053,7 +1076,7 @@ const make$2 = (options) => ({
|
|
|
1053
1076
|
...options
|
|
1054
1077
|
});
|
|
1055
1078
|
//#endregion
|
|
1056
|
-
//#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.
|
|
1079
|
+
//#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.103_effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c566_933a6d6775be5e2696c624c811da82a4/node_modules/@effect/platform-node/dist/NodeStdio.js
|
|
1057
1080
|
/**
|
|
1058
1081
|
* Node.js `Stdio` layer for the current process.
|
|
1059
1082
|
*
|
|
@@ -1073,6 +1096,8 @@ const make$2 = (options) => ({
|
|
|
1073
1096
|
*/
|
|
1074
1097
|
const layer$3 = /* @__PURE__ */ succeed$2(Stdio, /*#__PURE__*/ make$2({
|
|
1075
1098
|
args: /*#__PURE__*/ sync(() => process.argv.slice(2)),
|
|
1099
|
+
stdinIsTerminal: /*#__PURE__*/ sync(() => process.stdin.isTTY === true),
|
|
1100
|
+
stdoutIsTerminal: /*#__PURE__*/ sync(() => process.stdout.isTTY === true),
|
|
1076
1101
|
stdout: (options) => fromWritable({
|
|
1077
1102
|
evaluate: () => process.stdout,
|
|
1078
1103
|
onError: (cause) => systemError({
|
|
@@ -1114,23 +1139,50 @@ const layer$3 = /* @__PURE__ */ succeed$2(Stdio, /*#__PURE__*/ make$2({
|
|
|
1114
1139
|
const layer$2 = /*#__PURE__*/ effect(Terminal, /*#__PURE__*/ (/* @__PURE__ */ fnUntraced(function* (shouldQuit = defaultShouldQuit) {
|
|
1115
1140
|
const stdin = process.stdin;
|
|
1116
1141
|
const stdout = process.stdout;
|
|
1117
|
-
const
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1142
|
+
const lines = yield* make$9();
|
|
1143
|
+
let inputEnded = stdin.readableEnded;
|
|
1144
|
+
let readlineActive = false;
|
|
1145
|
+
const onStdinEnd = () => {
|
|
1146
|
+
inputEnded = true;
|
|
1147
|
+
if (!readlineActive) endUnsafe(lines);
|
|
1148
|
+
};
|
|
1149
|
+
stdin.once("end", onStdinEnd);
|
|
1150
|
+
yield* addFinalizer(() => sync(() => stdin.off("end", onStdinEnd)));
|
|
1151
|
+
const rlRef = yield* make$10({
|
|
1152
|
+
acquire: acquireRelease(sync(() => {
|
|
1153
|
+
const rl = readline.createInterface({
|
|
1154
|
+
input: stdin,
|
|
1155
|
+
escapeCodeTimeout: 50
|
|
1156
|
+
});
|
|
1157
|
+
const onLine = (line) => offerUnsafe(lines, line);
|
|
1158
|
+
const onClose = () => {
|
|
1159
|
+
readlineActive = false;
|
|
1160
|
+
endUnsafe(lines);
|
|
1161
|
+
};
|
|
1162
|
+
readlineActive = true;
|
|
1163
|
+
readline.emitKeypressEvents(stdin, rl);
|
|
1164
|
+
rl.on("line", onLine);
|
|
1165
|
+
rl.once("close", onClose);
|
|
1166
|
+
if (stdin.isTTY) stdin.setRawMode(true);
|
|
1167
|
+
return {
|
|
1168
|
+
rl,
|
|
1169
|
+
onClose,
|
|
1170
|
+
onLine
|
|
1171
|
+
};
|
|
1172
|
+
}), ({ rl, onClose, onLine }) => sync(() => {
|
|
1173
|
+
readlineActive = false;
|
|
1174
|
+
rl.off("line", onLine);
|
|
1175
|
+
rl.off("close", onClose);
|
|
1176
|
+
if (stdin.isTTY) stdin.setRawMode(false);
|
|
1177
|
+
rl.close();
|
|
1178
|
+
if (inputEnded) endUnsafe(lines);
|
|
1179
|
+
})),
|
|
1180
|
+
idleTimeToLive: "10 millis"
|
|
1181
|
+
});
|
|
1129
1182
|
const columns = sync(() => stdout.columns ?? 0);
|
|
1130
1183
|
const rows = sync(() => stdout.rows ?? 0);
|
|
1131
1184
|
const readInput = gen(function* () {
|
|
1132
|
-
yield*
|
|
1133
|
-
const queue = yield* make$10();
|
|
1185
|
+
const queue = yield* make$9();
|
|
1134
1186
|
const handleKeypress = (s, k) => {
|
|
1135
1187
|
const userInput = {
|
|
1136
1188
|
input: fromUndefinedOr(s),
|
|
@@ -1144,15 +1196,28 @@ const layer$2 = /*#__PURE__*/ effect(Terminal, /*#__PURE__*/ (/* @__PURE__ */ fn
|
|
|
1144
1196
|
offerUnsafe(queue, userInput);
|
|
1145
1197
|
if (shouldQuit(userInput)) endUnsafe(queue);
|
|
1146
1198
|
};
|
|
1147
|
-
|
|
1199
|
+
const keepAlive = setInterval(() => {}, 2147483647);
|
|
1200
|
+
const handleEnd = () => {
|
|
1201
|
+
clearInterval(keepAlive);
|
|
1202
|
+
endUnsafe(queue);
|
|
1203
|
+
};
|
|
1204
|
+
yield* addFinalizer(() => sync(() => {
|
|
1205
|
+
clearInterval(keepAlive);
|
|
1206
|
+
stdin.off("keypress", handleKeypress);
|
|
1207
|
+
stdin.off("end", handleEnd);
|
|
1208
|
+
}));
|
|
1148
1209
|
stdin.on("keypress", handleKeypress);
|
|
1210
|
+
if (inputEnded) handleEnd();
|
|
1211
|
+
else {
|
|
1212
|
+
yield* get$1(rlRef);
|
|
1213
|
+
stdin.once("end", handleEnd);
|
|
1214
|
+
}
|
|
1149
1215
|
return queue;
|
|
1150
1216
|
});
|
|
1151
|
-
const readLine =
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
})));
|
|
1217
|
+
const readLine = suspend(() => poll(lines).pipe(flatMap(match({
|
|
1218
|
+
onNone: () => scoped(andThen(get$1(rlRef), take(lines))),
|
|
1219
|
+
onSome: succeed
|
|
1220
|
+
})), mapError(() => new QuitError({}))));
|
|
1156
1221
|
const display = (prompt) => uninterruptible(callback((resume) => {
|
|
1157
1222
|
stdout.write(prompt, (err) => isNullish(err) ? resume(void_) : resume(fail(badArgument({
|
|
1158
1223
|
module: "Terminal",
|
|
@@ -1173,7 +1238,7 @@ function defaultShouldQuit(input) {
|
|
|
1173
1238
|
return input.key.ctrl && (input.key.name === "c" || input.key.name === "d");
|
|
1174
1239
|
}
|
|
1175
1240
|
//#endregion
|
|
1176
|
-
//#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.
|
|
1241
|
+
//#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.103_effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c566_933a6d6775be5e2696c624c811da82a4/node_modules/@effect/platform-node/dist/NodeServices.js
|
|
1177
1242
|
/**
|
|
1178
1243
|
* Provides the default Node implementations for child process spawning,
|
|
1179
1244
|
* filesystem, path, stdio, and terminal services.
|
|
@@ -1183,16 +1248,17 @@ function defaultShouldQuit(input) {
|
|
|
1183
1248
|
*/
|
|
1184
1249
|
const layer = /*#__PURE__*/ provideMerge(layer$11, /*#__PURE__*/ mergeAll(layer$7, layer$9, layer$5, layer$3, layer$2));
|
|
1185
1250
|
//#endregion
|
|
1186
|
-
//#region node_modules/.pnpm/effect@4.0.0-beta.
|
|
1251
|
+
//#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/cli/Argument.js
|
|
1187
1252
|
/**
|
|
1188
1253
|
* Creates a positional string argument.
|
|
1189
1254
|
*
|
|
1190
1255
|
* **Example** (Creating a string argument)
|
|
1191
1256
|
*
|
|
1192
|
-
* ```ts
|
|
1257
|
+
* ```ts import.meta.vitest
|
|
1193
1258
|
* import { Argument } from "effect/unstable/cli"
|
|
1194
1259
|
*
|
|
1195
1260
|
* const filename = Argument.string("filename")
|
|
1261
|
+
* filename.kind // => "argument"
|
|
1196
1262
|
* ```
|
|
1197
1263
|
*
|
|
1198
1264
|
* @category constructors
|
|
@@ -1204,10 +1270,11 @@ const string = (name) => string$1(argumentKind, name);
|
|
|
1204
1270
|
*
|
|
1205
1271
|
* **Example** (Making an argument optional)
|
|
1206
1272
|
*
|
|
1207
|
-
* ```ts
|
|
1273
|
+
* ```ts import.meta.vitest
|
|
1208
1274
|
* import { Argument } from "effect/unstable/cli"
|
|
1209
1275
|
*
|
|
1210
1276
|
* const optionalVersion = Argument.string("version").pipe(Argument.optional)
|
|
1277
|
+
* optionalVersion.kind // => "argument"
|
|
1211
1278
|
* ```
|
|
1212
1279
|
*
|
|
1213
1280
|
* @category combinators
|
|
@@ -1219,7 +1286,7 @@ const optional = (arg) => optional$1(arg);
|
|
|
1219
1286
|
*
|
|
1220
1287
|
* **Example** (Accepting multiple values)
|
|
1221
1288
|
*
|
|
1222
|
-
* ```ts
|
|
1289
|
+
* ```ts import.meta.vitest
|
|
1223
1290
|
* import { Argument } from "effect/unstable/cli"
|
|
1224
1291
|
*
|
|
1225
1292
|
* // Accept any number of files
|
|
@@ -1234,6 +1301,8 @@ const optional = (arg) => optional$1(arg);
|
|
|
1234
1301
|
* const limitedFiles = Argument.string("files").pipe(
|
|
1235
1302
|
* Argument.variadic({ min: 1, max: 5 })
|
|
1236
1303
|
* )
|
|
1304
|
+
*
|
|
1305
|
+
* const kinds = [anyFiles.kind, atLeastOneFile.kind, limitedFiles.kind] // => ["argument", "argument", "argument"]
|
|
1237
1306
|
* ```
|
|
1238
1307
|
*
|
|
1239
1308
|
* @category combinators
|
|
@@ -1245,9 +1314,27 @@ const variadic = /*#__PURE__*/ dual((args) => isParam(args[0]), (self, options)
|
|
|
1245
1314
|
*
|
|
1246
1315
|
* **Example** (Validating values effectfully)
|
|
1247
1316
|
*
|
|
1248
|
-
* ```ts
|
|
1249
|
-
* import { Effect } from "effect"
|
|
1317
|
+
* ```ts import.meta.vitest
|
|
1318
|
+
* import { Effect, FileSystem, Layer, Path, Stdio, Terminal } from "effect"
|
|
1250
1319
|
* import { Argument, CliError } from "effect/unstable/cli"
|
|
1320
|
+
* import { ChildProcessSpawner } from "effect/unstable/process"
|
|
1321
|
+
*
|
|
1322
|
+
* const CliTestLayer = Layer.mergeAll(
|
|
1323
|
+
* FileSystem.layerNoop({}),
|
|
1324
|
+
* Path.layer,
|
|
1325
|
+
* Stdio.layerTest({}),
|
|
1326
|
+
* Layer.succeed(Terminal.Terminal, Terminal.make({
|
|
1327
|
+
* columns: Effect.succeed(80),
|
|
1328
|
+
* rows: Effect.succeed(24),
|
|
1329
|
+
* readInput: Effect.die("unused"),
|
|
1330
|
+
* readLine: Effect.die("unused"),
|
|
1331
|
+
* display: () => Effect.void
|
|
1332
|
+
* })),
|
|
1333
|
+
* Layer.succeed(
|
|
1334
|
+
* ChildProcessSpawner.ChildProcessSpawner,
|
|
1335
|
+
* ChildProcessSpawner.make(() => Effect.die("unused"))
|
|
1336
|
+
* )
|
|
1337
|
+
* )
|
|
1251
1338
|
*
|
|
1252
1339
|
* const files = Argument.string("files").pipe(
|
|
1253
1340
|
* Argument.mapEffect((file) =>
|
|
@@ -1260,6 +1347,11 @@ const variadic = /*#__PURE__*/ dual((args) => isParam(args[0]), (self, options)
|
|
|
1260
1347
|
* )
|
|
1261
1348
|
* )
|
|
1262
1349
|
* )
|
|
1350
|
+
*
|
|
1351
|
+
* const [, value] = await Effect.runPromise(
|
|
1352
|
+
* files.parse({ arguments: ["notes.txt"], flags: {} }).pipe(Effect.provide(CliTestLayer))
|
|
1353
|
+
* )
|
|
1354
|
+
* value // => "notes.txt"
|
|
1263
1355
|
* ```
|
|
1264
1356
|
*
|
|
1265
1357
|
* @category combinators
|
|
@@ -1267,7 +1359,7 @@ const variadic = /*#__PURE__*/ dual((args) => isParam(args[0]), (self, options)
|
|
|
1267
1359
|
*/
|
|
1268
1360
|
const mapEffect = /*#__PURE__*/ dual(2, (self, f) => mapEffect$1(self, f));
|
|
1269
1361
|
//#endregion
|
|
1270
|
-
//#region node_modules/.pnpm/effect@4.0.0-beta.
|
|
1362
|
+
//#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/cli/CliConfig.js
|
|
1271
1363
|
/**
|
|
1272
1364
|
* Configuration for Effect CLI command execution.
|
|
1273
1365
|
*
|
|
@@ -1294,7 +1386,7 @@ var CliConfig = class extends Reference("effect/unstable/cli/CliConfig", { defau
|
|
|
1294
1386
|
*/
|
|
1295
1387
|
const defaults = { builtIns: BuiltIns };
|
|
1296
1388
|
//#endregion
|
|
1297
|
-
//#region node_modules/.pnpm/effect@4.0.0-beta.
|
|
1389
|
+
//#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/cli/internal/lexer.js
|
|
1298
1390
|
/** @internal */
|
|
1299
1391
|
function lex(argv) {
|
|
1300
1392
|
const endIndex = argv.indexOf("--");
|
|
@@ -1314,12 +1406,20 @@ const lexTokens = (args) => {
|
|
|
1314
1406
|
value: arg
|
|
1315
1407
|
});
|
|
1316
1408
|
else if (arg.startsWith("--")) {
|
|
1317
|
-
const
|
|
1318
|
-
|
|
1409
|
+
const equalIndex = arg.indexOf("=");
|
|
1410
|
+
if (equalIndex !== -1) {
|
|
1411
|
+
const name = arg.slice(2, equalIndex);
|
|
1412
|
+
const value = arg.slice(equalIndex + 1);
|
|
1413
|
+
tokens.push({
|
|
1414
|
+
_tag: "LongOption",
|
|
1415
|
+
name,
|
|
1416
|
+
raw: arg,
|
|
1417
|
+
value
|
|
1418
|
+
});
|
|
1419
|
+
} else tokens.push({
|
|
1319
1420
|
_tag: "LongOption",
|
|
1320
|
-
name,
|
|
1321
|
-
raw: arg
|
|
1322
|
-
value
|
|
1421
|
+
name: arg.slice(2),
|
|
1422
|
+
raw: arg
|
|
1323
1423
|
});
|
|
1324
1424
|
} else if (arg.length > 1) {
|
|
1325
1425
|
const flags = arg.slice(1);
|
|
@@ -1345,7 +1445,7 @@ const lexTokens = (args) => {
|
|
|
1345
1445
|
return tokens;
|
|
1346
1446
|
};
|
|
1347
1447
|
//#endregion
|
|
1348
|
-
//#region node_modules/.pnpm/effect@4.0.0-beta.
|
|
1448
|
+
//#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/cli/internal/auto-suggest.js
|
|
1349
1449
|
/**
|
|
1350
1450
|
* Simple Levenshtein distance implementation (small N, no perf worries)
|
|
1351
1451
|
*/
|
|
@@ -1373,7 +1473,7 @@ const suggest = (input, candidates) => {
|
|
|
1373
1473
|
return distances.filter(([d]) => d === minDistance).map(([, c]) => c);
|
|
1374
1474
|
};
|
|
1375
1475
|
//#endregion
|
|
1376
|
-
//#region node_modules/.pnpm/effect@4.0.0-beta.
|
|
1476
|
+
//#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/cli/internal/parser.js
|
|
1377
1477
|
/**
|
|
1378
1478
|
* Parsing Pipeline for CLI Commands
|
|
1379
1479
|
* ==================================
|
|
@@ -1431,13 +1531,13 @@ const parseArgs = (lexResult, command, commandPath = []) => gen(function* () {
|
|
|
1431
1531
|
};
|
|
1432
1532
|
const subLex = {
|
|
1433
1533
|
tokens: result.childTokens,
|
|
1434
|
-
trailingOperands:
|
|
1534
|
+
trailingOperands: afterEndOfOptions
|
|
1435
1535
|
};
|
|
1436
1536
|
const subParsed = yield* parseArgs(subLex, result.sub, newCommandPath);
|
|
1437
1537
|
const allErrors = [...result.errors, ...subParsed.errors ?? []];
|
|
1438
1538
|
return {
|
|
1439
1539
|
flags: result.flags,
|
|
1440
|
-
arguments:
|
|
1540
|
+
arguments: [],
|
|
1441
1541
|
subcommand: some({
|
|
1442
1542
|
name: result.sub.name,
|
|
1443
1543
|
parsedInput: subParsed
|
|
@@ -1901,7 +2001,7 @@ const scanCommandLevel = (tokens, context) => {
|
|
|
1901
2001
|
return toLeafResult(state);
|
|
1902
2002
|
};
|
|
1903
2003
|
//#endregion
|
|
1904
|
-
//#region node_modules/.pnpm/effect@4.0.0-beta.
|
|
2004
|
+
//#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/cli/internal/wizard.js
|
|
1905
2005
|
const run$1 = /*#__PURE__*/ fnUntraced(function* (command, options) {
|
|
1906
2006
|
const commandPath = options?.commandPath ?? [command.name];
|
|
1907
2007
|
const selected = getCommandAtPath(command, commandPath);
|
|
@@ -2061,7 +2161,7 @@ const wrapCommand = (commandLine) => {
|
|
|
2061
2161
|
};
|
|
2062
2162
|
const formatShellArg = (arg) => /^[A-Za-z0-9_./:@%+=,-]+$/.test(arg) ? arg : `'${arg.replaceAll("'", `'"'"'`)}'`;
|
|
2063
2163
|
//#endregion
|
|
2064
|
-
//#region node_modules/.pnpm/effect@4.0.0-beta.
|
|
2164
|
+
//#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/cli/Command.js
|
|
2065
2165
|
/**
|
|
2066
2166
|
* Returns `true` if the provided value is a `Command`.
|
|
2067
2167
|
*
|
|
@@ -2086,9 +2186,27 @@ const isCommand = (u) => hasProperty(u, TypeId$3);
|
|
|
2086
2186
|
*
|
|
2087
2187
|
* **Example** (Creating commands)
|
|
2088
2188
|
*
|
|
2089
|
-
* ```ts
|
|
2090
|
-
* import {
|
|
2189
|
+
* ```ts import.meta.vitest
|
|
2190
|
+
* import { Effect, FileSystem, Layer, Path, Stdio, Terminal } from "effect"
|
|
2091
2191
|
* import { Argument, Command, Flag } from "effect/unstable/cli"
|
|
2192
|
+
* import { ChildProcessSpawner } from "effect/unstable/process"
|
|
2193
|
+
*
|
|
2194
|
+
* const CliTestLayer = Layer.mergeAll(
|
|
2195
|
+
* FileSystem.layerNoop({}),
|
|
2196
|
+
* Path.layer,
|
|
2197
|
+
* Stdio.layerTest({}),
|
|
2198
|
+
* Layer.succeed(Terminal.Terminal, Terminal.make({
|
|
2199
|
+
* columns: Effect.succeed(80),
|
|
2200
|
+
* rows: Effect.succeed(24),
|
|
2201
|
+
* readInput: Effect.die("unused"),
|
|
2202
|
+
* readLine: Effect.die("unused"),
|
|
2203
|
+
* display: () => Effect.void
|
|
2204
|
+
* })),
|
|
2205
|
+
* Layer.succeed(
|
|
2206
|
+
* ChildProcessSpawner.ChildProcessSpawner,
|
|
2207
|
+
* ChildProcessSpawner.make(() => Effect.die("unused"))
|
|
2208
|
+
* )
|
|
2209
|
+
* )
|
|
2092
2210
|
*
|
|
2093
2211
|
* // Simple command with no configuration
|
|
2094
2212
|
* const version = Command.make("version")
|
|
@@ -2113,19 +2231,29 @@ const isCommand = (u) => hasProperty(u, TypeId$3);
|
|
|
2113
2231
|
* })
|
|
2114
2232
|
*
|
|
2115
2233
|
* // Command with handler
|
|
2234
|
+
* const output: Array<string> = []
|
|
2116
2235
|
* const deployWithHandler = Command.make("deploy", {
|
|
2117
2236
|
* environment: Flag.string("env"),
|
|
2118
2237
|
* force: Flag.boolean("force")
|
|
2119
2238
|
* }, (config) =>
|
|
2120
2239
|
* Effect.gen(function*() {
|
|
2121
|
-
* yield*
|
|
2240
|
+
* yield* Effect.sync(() => output.push(`Starting deployment to ${config.environment}`))
|
|
2122
2241
|
*
|
|
2123
2242
|
* if (!config.force && config.environment === "production") {
|
|
2124
2243
|
* return yield* Effect.fail("Production deployments require --force flag")
|
|
2125
2244
|
* }
|
|
2126
2245
|
*
|
|
2127
|
-
* yield*
|
|
2246
|
+
* yield* Effect.sync(() => output.push("Deployment completed successfully"))
|
|
2128
2247
|
* }))
|
|
2248
|
+
*
|
|
2249
|
+
* await Effect.runPromise(
|
|
2250
|
+
* Command.runWith(deployWithHandler, { version: "1.0.0" })([
|
|
2251
|
+
* "--env",
|
|
2252
|
+
* "staging",
|
|
2253
|
+
* "--force"
|
|
2254
|
+
* ]).pipe(Effect.provide(CliTestLayer))
|
|
2255
|
+
* )
|
|
2256
|
+
* output // => ["Starting deployment to staging", "Deployment completed successfully"]
|
|
2129
2257
|
* ```
|
|
2130
2258
|
*
|
|
2131
2259
|
* @category constructors
|
|
@@ -2183,9 +2311,27 @@ const normalizeSubcommandEntries = (entries) => {
|
|
|
2183
2311
|
*
|
|
2184
2312
|
* **Example** (Adding subcommands)
|
|
2185
2313
|
*
|
|
2186
|
-
* ```ts
|
|
2187
|
-
* import {
|
|
2314
|
+
* ```ts import.meta.vitest
|
|
2315
|
+
* import { Effect, FileSystem, Layer, Path, Stdio, Terminal } from "effect"
|
|
2188
2316
|
* import { Command, Flag } from "effect/unstable/cli"
|
|
2317
|
+
* import { ChildProcessSpawner } from "effect/unstable/process"
|
|
2318
|
+
*
|
|
2319
|
+
* const CliTestLayer = Layer.mergeAll(
|
|
2320
|
+
* FileSystem.layerNoop({}),
|
|
2321
|
+
* Path.layer,
|
|
2322
|
+
* Stdio.layerTest({}),
|
|
2323
|
+
* Layer.succeed(Terminal.Terminal, Terminal.make({
|
|
2324
|
+
* columns: Effect.succeed(80),
|
|
2325
|
+
* rows: Effect.succeed(24),
|
|
2326
|
+
* readInput: Effect.die("unused"),
|
|
2327
|
+
* readLine: Effect.die("unused"),
|
|
2328
|
+
* display: () => Effect.void
|
|
2329
|
+
* })),
|
|
2330
|
+
* Layer.succeed(
|
|
2331
|
+
* ChildProcessSpawner.ChildProcessSpawner,
|
|
2332
|
+
* ChildProcessSpawner.make(() => Effect.die("unused"))
|
|
2333
|
+
* )
|
|
2334
|
+
* )
|
|
2189
2335
|
*
|
|
2190
2336
|
* // Parent command with shared flags
|
|
2191
2337
|
* const git = Command.make("git").pipe(
|
|
@@ -2195,19 +2341,29 @@ const normalizeSubcommandEntries = (entries) => {
|
|
|
2195
2341
|
* )
|
|
2196
2342
|
*
|
|
2197
2343
|
* // Subcommand that accesses parent config
|
|
2344
|
+
* const output: Array<string> = []
|
|
2198
2345
|
* const clone = Command.make("clone", {
|
|
2199
2346
|
* repository: Flag.string("repo")
|
|
2200
2347
|
* }, (config) =>
|
|
2201
2348
|
* Effect.gen(function*() {
|
|
2202
2349
|
* const parent = yield* git // Access parent's parsed config
|
|
2203
2350
|
* if (parent.verbose) {
|
|
2204
|
-
* yield*
|
|
2351
|
+
* yield* Effect.sync(() => output.push("Verbose mode enabled"))
|
|
2205
2352
|
* }
|
|
2206
|
-
* yield*
|
|
2353
|
+
* yield* Effect.sync(() => output.push(`Cloning ${config.repository}`))
|
|
2207
2354
|
* }))
|
|
2208
2355
|
*
|
|
2209
2356
|
* const app = git.pipe(Command.withSubcommands([clone]))
|
|
2210
|
-
*
|
|
2357
|
+
*
|
|
2358
|
+
* await Effect.runPromise(
|
|
2359
|
+
* Command.runWith(app, { version: "1.0.0" })([
|
|
2360
|
+
* "--verbose",
|
|
2361
|
+
* "clone",
|
|
2362
|
+
* "--repo",
|
|
2363
|
+
* "github.com/foo/bar"
|
|
2364
|
+
* ]).pipe(Effect.provide(CliTestLayer))
|
|
2365
|
+
* )
|
|
2366
|
+
* output // => ["Verbose mode enabled", "Cloning github.com/foo/bar"]
|
|
2211
2367
|
* ```
|
|
2212
2368
|
*
|
|
2213
2369
|
* @category combinators
|
|
@@ -2290,18 +2446,42 @@ const withGlobalFlags = /*#__PURE__*/ dual(2, (self, globalFlags) => {
|
|
|
2290
2446
|
*
|
|
2291
2447
|
* **Example** (Setting descriptions)
|
|
2292
2448
|
*
|
|
2293
|
-
* ```ts
|
|
2294
|
-
* import {
|
|
2449
|
+
* ```ts import.meta.vitest
|
|
2450
|
+
* import { Effect, FileSystem, Layer, Path, Stdio, Terminal } from "effect"
|
|
2295
2451
|
* import { Command, Flag } from "effect/unstable/cli"
|
|
2452
|
+
* import { ChildProcessSpawner } from "effect/unstable/process"
|
|
2453
|
+
*
|
|
2454
|
+
* const CliTestLayer = Layer.mergeAll(
|
|
2455
|
+
* FileSystem.layerNoop({}),
|
|
2456
|
+
* Path.layer,
|
|
2457
|
+
* Stdio.layerTest({}),
|
|
2458
|
+
* Layer.succeed(Terminal.Terminal, Terminal.make({
|
|
2459
|
+
* columns: Effect.succeed(80),
|
|
2460
|
+
* rows: Effect.succeed(24),
|
|
2461
|
+
* readInput: Effect.die("unused"),
|
|
2462
|
+
* readLine: Effect.die("unused"),
|
|
2463
|
+
* display: () => Effect.void
|
|
2464
|
+
* })),
|
|
2465
|
+
* Layer.succeed(
|
|
2466
|
+
* ChildProcessSpawner.ChildProcessSpawner,
|
|
2467
|
+
* ChildProcessSpawner.make(() => Effect.die("unused"))
|
|
2468
|
+
* )
|
|
2469
|
+
* )
|
|
2296
2470
|
*
|
|
2471
|
+
* const output: Array<string> = []
|
|
2297
2472
|
* const deploy = Command.make("deploy", {
|
|
2298
2473
|
* environment: Flag.string("env")
|
|
2299
2474
|
* }, (config) =>
|
|
2300
2475
|
* Effect.gen(function*() {
|
|
2301
|
-
* yield*
|
|
2476
|
+
* yield* Effect.sync(() => output.push(`Deploying to ${config.environment}`))
|
|
2302
2477
|
* })).pipe(
|
|
2303
2478
|
* Command.withDescription("Deploy the application to a specified environment")
|
|
2304
2479
|
* )
|
|
2480
|
+
*
|
|
2481
|
+
* await Effect.runPromise(
|
|
2482
|
+
* Command.runWith(deploy, { version: "1.0.0" })(["--env", "staging"]).pipe(Effect.provide(CliTestLayer))
|
|
2483
|
+
* )
|
|
2484
|
+
* output // => ["Deploying to staging"]
|
|
2305
2485
|
* ```
|
|
2306
2486
|
*
|
|
2307
2487
|
* @category combinators
|
|
@@ -2350,26 +2530,50 @@ const showHelp = (command, error$1) => gen(function* () {
|
|
|
2350
2530
|
*
|
|
2351
2531
|
* **Example** (Running commands with standard input)
|
|
2352
2532
|
*
|
|
2353
|
-
* ```ts
|
|
2354
|
-
* import {
|
|
2533
|
+
* ```ts import.meta.vitest
|
|
2534
|
+
* import { Effect, FileSystem, Layer, Path, Stdio, Terminal } from "effect"
|
|
2355
2535
|
* import { Command, Flag } from "effect/unstable/cli"
|
|
2536
|
+
* import { ChildProcessSpawner } from "effect/unstable/process"
|
|
2356
2537
|
*
|
|
2538
|
+
* const CliTestLayer = Layer.mergeAll(
|
|
2539
|
+
* FileSystem.layerNoop({}),
|
|
2540
|
+
* Path.layer,
|
|
2541
|
+
* Stdio.layerTest({
|
|
2542
|
+
* args: Effect.succeed(["--name", "Alice"])
|
|
2543
|
+
* }),
|
|
2544
|
+
* Layer.succeed(Terminal.Terminal, Terminal.make({
|
|
2545
|
+
* columns: Effect.succeed(80),
|
|
2546
|
+
* rows: Effect.succeed(24),
|
|
2547
|
+
* readInput: Effect.die("unused"),
|
|
2548
|
+
* readLine: Effect.die("unused"),
|
|
2549
|
+
* display: () => Effect.void
|
|
2550
|
+
* })),
|
|
2551
|
+
* Layer.succeed(
|
|
2552
|
+
* ChildProcessSpawner.ChildProcessSpawner,
|
|
2553
|
+
* ChildProcessSpawner.make(() => Effect.die("unused"))
|
|
2554
|
+
* )
|
|
2555
|
+
* )
|
|
2556
|
+
*
|
|
2557
|
+
* const output: Array<string> = []
|
|
2357
2558
|
* const greetCommand = Command.make("greet", {
|
|
2358
2559
|
* name: Flag.string("name")
|
|
2359
2560
|
* }, (config) =>
|
|
2360
2561
|
* Effect.gen(function*() {
|
|
2361
|
-
* yield*
|
|
2562
|
+
* yield* Effect.sync(() => output.push(`Hello, ${config.name}!`))
|
|
2362
2563
|
* }))
|
|
2363
2564
|
*
|
|
2364
2565
|
* // Automatically gets args from the Stdio service
|
|
2365
2566
|
* const program = Command.run(greetCommand, {
|
|
2366
2567
|
* version: "1.0.0"
|
|
2367
2568
|
* })
|
|
2569
|
+
*
|
|
2570
|
+
* await Effect.runPromise(program.pipe(Effect.provide(CliTestLayer)))
|
|
2571
|
+
* output // => ["Hello, Alice!"]
|
|
2368
2572
|
* ```
|
|
2369
2573
|
*
|
|
2370
2574
|
* @see {@link runWith} for running a command with an explicit argument array
|
|
2371
2575
|
*
|
|
2372
|
-
* @category
|
|
2576
|
+
* @category running
|
|
2373
2577
|
* @since 4.0.0
|
|
2374
2578
|
*/
|
|
2375
2579
|
const run = /*#__PURE__*/ dual(2, (command, config) => Stdio.use(({ args }) => flatMap(args, (args) => runWith(command, config)(args))));
|
|
@@ -2383,17 +2587,36 @@ const run = /*#__PURE__*/ dual(2, (command, config) => Stdio.use(({ args }) => f
|
|
|
2383
2587
|
*
|
|
2384
2588
|
* **Example** (Running commands with explicit arguments)
|
|
2385
2589
|
*
|
|
2386
|
-
* ```ts
|
|
2387
|
-
* import {
|
|
2590
|
+
* ```ts import.meta.vitest
|
|
2591
|
+
* import { Effect, FileSystem, Layer, Path, Stdio, Terminal } from "effect"
|
|
2388
2592
|
* import { Command, Flag } from "effect/unstable/cli"
|
|
2593
|
+
* import { ChildProcessSpawner } from "effect/unstable/process"
|
|
2389
2594
|
*
|
|
2595
|
+
* const CliTestLayer = Layer.mergeAll(
|
|
2596
|
+
* FileSystem.layerNoop({}),
|
|
2597
|
+
* Path.layer,
|
|
2598
|
+
* Stdio.layerTest({}),
|
|
2599
|
+
* Layer.succeed(Terminal.Terminal, Terminal.make({
|
|
2600
|
+
* columns: Effect.succeed(80),
|
|
2601
|
+
* rows: Effect.succeed(24),
|
|
2602
|
+
* readInput: Effect.die("unused"),
|
|
2603
|
+
* readLine: Effect.die("unused"),
|
|
2604
|
+
* display: () => Effect.void
|
|
2605
|
+
* })),
|
|
2606
|
+
* Layer.succeed(
|
|
2607
|
+
* ChildProcessSpawner.ChildProcessSpawner,
|
|
2608
|
+
* ChildProcessSpawner.make(() => Effect.die("unused"))
|
|
2609
|
+
* )
|
|
2610
|
+
* )
|
|
2611
|
+
*
|
|
2612
|
+
* const output: Array<string> = []
|
|
2390
2613
|
* const greet = Command.make("greet", {
|
|
2391
2614
|
* name: Flag.string("name"),
|
|
2392
2615
|
* count: Flag.integer("count").pipe(Flag.withDefault(1))
|
|
2393
2616
|
* }, (config) =>
|
|
2394
2617
|
* Effect.gen(function*() {
|
|
2395
2618
|
* for (let i = 0; i < config.count; i++) {
|
|
2396
|
-
* yield*
|
|
2619
|
+
* yield* Effect.sync(() => output.push(`Hello, ${config.name}!`))
|
|
2397
2620
|
* }
|
|
2398
2621
|
* }))
|
|
2399
2622
|
*
|
|
@@ -2401,18 +2624,14 @@ const run = /*#__PURE__*/ dual(2, (command, config) => Stdio.use(({ args }) => f
|
|
|
2401
2624
|
* const testProgram = Effect.gen(function*() {
|
|
2402
2625
|
* const runCommand = Command.runWith(greet, { version: "1.0.0" })
|
|
2403
2626
|
*
|
|
2404
|
-
* // Test normal execution
|
|
2405
2627
|
* yield* runCommand(["--name", "Alice", "--count", "2"])
|
|
2406
|
-
*
|
|
2407
|
-
* // Test help display
|
|
2408
|
-
* yield* runCommand(["--help"])
|
|
2409
|
-
*
|
|
2410
|
-
* // Test version display
|
|
2411
|
-
* yield* runCommand(["--version"])
|
|
2412
2628
|
* })
|
|
2629
|
+
*
|
|
2630
|
+
* await Effect.runPromise(testProgram.pipe(Effect.provide(CliTestLayer)))
|
|
2631
|
+
* output // => ["Hello, Alice!", "Hello, Alice!"]
|
|
2413
2632
|
* ```
|
|
2414
2633
|
*
|
|
2415
|
-
* @category
|
|
2634
|
+
* @category running
|
|
2416
2635
|
* @since 4.0.0
|
|
2417
2636
|
*/
|
|
2418
2637
|
const runWith = (command, config) => {
|
|
@@ -86150,9 +86369,46 @@ var SelfActionError = class extends TaggedErrorClass()("SelfActionError", {
|
|
|
86150
86369
|
}) {};
|
|
86151
86370
|
var DestructiveConfirmationRequiredError = class extends TaggedErrorClass()("DestructiveConfirmationRequiredError", { message: String$1 }) {};
|
|
86152
86371
|
var InvalidFlagCombinationError = class extends TaggedErrorClass()("InvalidFlagCombinationError", { message: String$1 }) {};
|
|
86372
|
+
var InvalidAskTimeoutError = class extends TaggedErrorClass()("InvalidAskTimeoutError", {
|
|
86373
|
+
message: String$1,
|
|
86374
|
+
value: String$1
|
|
86375
|
+
}) {};
|
|
86376
|
+
var AskThreadArchivedError = class extends TaggedErrorClass()("AskThreadArchivedError", {
|
|
86377
|
+
message: String$1,
|
|
86378
|
+
threadId: String$1
|
|
86379
|
+
}) {};
|
|
86380
|
+
var AskThreadBusyError = class extends TaggedErrorClass()("AskThreadBusyError", {
|
|
86381
|
+
message: String$1,
|
|
86382
|
+
threadId: String$1
|
|
86383
|
+
}) {};
|
|
86384
|
+
var AskThreadPendingRequestError = class extends TaggedErrorClass()("AskThreadPendingRequestError", {
|
|
86385
|
+
message: String$1,
|
|
86386
|
+
threadId: String$1
|
|
86387
|
+
}) {};
|
|
86388
|
+
var AskProjectMismatchError = class extends TaggedErrorClass()("AskProjectMismatchError", {
|
|
86389
|
+
message: String$1,
|
|
86390
|
+
threadId: String$1,
|
|
86391
|
+
projectId: String$1
|
|
86392
|
+
}) {};
|
|
86393
|
+
var AskNoAnswerError = class extends TaggedErrorClass()("AskNoAnswerError", {
|
|
86394
|
+
message: String$1,
|
|
86395
|
+
threadId: String$1
|
|
86396
|
+
}) {};
|
|
86397
|
+
var AskTimeoutError = class extends TaggedErrorClass()("AskTimeoutError", {
|
|
86398
|
+
message: String$1,
|
|
86399
|
+
timeout: String$1
|
|
86400
|
+
}) {};
|
|
86153
86401
|
var MissingRequestError = class extends TaggedErrorClass()("MissingRequestError", { message: String$1 }) {};
|
|
86154
86402
|
var MissingUpdateFieldsError = class extends TaggedErrorClass()("MissingUpdateFieldsError", { message: String$1 }) {};
|
|
86155
86403
|
var ConflictingUpdateFlagsError = class extends TaggedErrorClass()("ConflictingUpdateFlagsError", { message: String$1 }) {};
|
|
86404
|
+
var InvalidSnoozeUntilError = class extends TaggedErrorClass()("InvalidSnoozeUntilError", {
|
|
86405
|
+
message: String$1,
|
|
86406
|
+
value: String$1
|
|
86407
|
+
}) {};
|
|
86408
|
+
var UnavailableSnoozePresetError = class extends TaggedErrorClass()("UnavailableSnoozePresetError", {
|
|
86409
|
+
message: String$1,
|
|
86410
|
+
preset: String$1
|
|
86411
|
+
}) {};
|
|
86156
86412
|
const extraArgsConfig = { extraArgs: string("extra").pipe(variadic(), mapEffect((extra) => extra.length === 0 ? void_ : fail(new InvalidValue({
|
|
86157
86413
|
option: "extra",
|
|
86158
86414
|
value: extra[0] ?? "",
|
|
@@ -86320,7 +86576,7 @@ const result = (self) => {
|
|
|
86320
86576
|
};
|
|
86321
86577
|
};
|
|
86322
86578
|
//#endregion
|
|
86323
|
-
//#region node_modules/.pnpm/effect@4.0.0-beta.
|
|
86579
|
+
//#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/Match.js
|
|
86324
86580
|
/**
|
|
86325
86581
|
* Builds pattern matchers for TypeScript values.
|
|
86326
86582
|
*
|
|
@@ -86352,7 +86608,7 @@ const result = (self) => {
|
|
|
86352
86608
|
*
|
|
86353
86609
|
* **Example** (Matching an Object by Property)
|
|
86354
86610
|
*
|
|
86355
|
-
* ```ts
|
|
86611
|
+
* ```ts import.meta.vitest
|
|
86356
86612
|
* import { Match } from "effect"
|
|
86357
86613
|
*
|
|
86358
86614
|
* const input = { name: "John", age: 30 }
|
|
@@ -86368,8 +86624,7 @@ const result = (self) => {
|
|
|
86368
86624
|
* Match.orElse(() => "Oh, not John")
|
|
86369
86625
|
* )
|
|
86370
86626
|
*
|
|
86371
|
-
*
|
|
86372
|
-
* // Output: "John is 30 years old"
|
|
86627
|
+
* result // => "John is 30 years old"
|
|
86373
86628
|
* ```
|
|
86374
86629
|
*
|
|
86375
86630
|
* @see {@link type} for creating a matcher from a specific type.
|
|
@@ -86395,7 +86650,7 @@ const value = value$1;
|
|
|
86395
86650
|
*
|
|
86396
86651
|
* **Example** (Matching with values and predicates)
|
|
86397
86652
|
*
|
|
86398
|
-
* ```ts
|
|
86653
|
+
* ```ts import.meta.vitest
|
|
86399
86654
|
* import { Match } from "effect"
|
|
86400
86655
|
*
|
|
86401
86656
|
* // Create a matcher for objects with an "age" property
|
|
@@ -86411,14 +86666,11 @@ const value = value$1;
|
|
|
86411
86666
|
* Match.orElse((user: { age: number }) => `${user.age} is too young`)
|
|
86412
86667
|
* )
|
|
86413
86668
|
*
|
|
86414
|
-
*
|
|
86415
|
-
* // Output: "Age: 20"
|
|
86669
|
+
* match({ age: 20 }) // => "Age: 20"
|
|
86416
86670
|
*
|
|
86417
|
-
*
|
|
86418
|
-
* // Output: "You can vote"
|
|
86671
|
+
* match({ age: 18 }) // => "You can vote"
|
|
86419
86672
|
*
|
|
86420
|
-
*
|
|
86421
|
-
* // Output: "4 is too young"
|
|
86673
|
+
* match({ age: 4 }) // => "4 is too young"
|
|
86422
86674
|
* ```
|
|
86423
86675
|
*
|
|
86424
86676
|
* @see {@link whenOr} for handling any one of several patterns with the same handler
|
|
@@ -86426,7 +86678,7 @@ const value = value$1;
|
|
|
86426
86678
|
* @see {@link not} for handling inputs that do not match a pattern
|
|
86427
86679
|
* @see {@link orElse} for providing a fallback when no pattern case matches
|
|
86428
86680
|
*
|
|
86429
|
-
* @category
|
|
86681
|
+
* @category defining patterns
|
|
86430
86682
|
* @since 4.0.0
|
|
86431
86683
|
*/
|
|
86432
86684
|
const when = when$1;
|
|
@@ -86445,7 +86697,7 @@ const when = when$1;
|
|
|
86445
86697
|
*
|
|
86446
86698
|
* **Example** (Matching a discriminated union by tag)
|
|
86447
86699
|
*
|
|
86448
|
-
* ```ts
|
|
86700
|
+
* ```ts import.meta.vitest
|
|
86449
86701
|
* import { Match } from "effect"
|
|
86450
86702
|
*
|
|
86451
86703
|
* type Event =
|
|
@@ -86464,14 +86716,12 @@ const when = when$1;
|
|
|
86464
86716
|
* Match.exhaustive
|
|
86465
86717
|
* )
|
|
86466
86718
|
*
|
|
86467
|
-
*
|
|
86468
|
-
* // Output: "Ok!"
|
|
86719
|
+
* match({ _tag: "success", data: "Hello" }) // => "Ok!"
|
|
86469
86720
|
*
|
|
86470
|
-
*
|
|
86471
|
-
* // Output: "Error: Oops!"
|
|
86721
|
+
* match({ _tag: "error", error: new Error("Oops!") }) // => "Error: Oops!"
|
|
86472
86722
|
* ```
|
|
86473
86723
|
*
|
|
86474
|
-
* @category
|
|
86724
|
+
* @category defining patterns
|
|
86475
86725
|
* @since 4.0.0
|
|
86476
86726
|
*/
|
|
86477
86727
|
const tag = tag$1;
|
|
@@ -86491,7 +86741,7 @@ const tag = tag$1;
|
|
|
86491
86741
|
*
|
|
86492
86742
|
* **Example** (Providing a default value when no patterns match)
|
|
86493
86743
|
*
|
|
86494
|
-
* ```ts
|
|
86744
|
+
* ```ts import.meta.vitest
|
|
86495
86745
|
* import { Match } from "effect"
|
|
86496
86746
|
*
|
|
86497
86747
|
* // Create a matcher for string or number values
|
|
@@ -86502,11 +86752,9 @@ const tag = tag$1;
|
|
|
86502
86752
|
* Match.orElse(() => "fallback")
|
|
86503
86753
|
* )
|
|
86504
86754
|
*
|
|
86505
|
-
*
|
|
86506
|
-
* // Output: "ok"
|
|
86755
|
+
* match("a") // => "ok"
|
|
86507
86756
|
*
|
|
86508
|
-
*
|
|
86509
|
-
* // Output: "fallback"
|
|
86757
|
+
* match("b") // => "fallback"
|
|
86510
86758
|
* ```
|
|
86511
86759
|
*
|
|
86512
86760
|
* @see {@link option} for finalizing unmatched input as `Option.none`
|
|
@@ -86905,6 +87153,719 @@ function buildUpdatePatch(input) {
|
|
|
86905
87153
|
});
|
|
86906
87154
|
}
|
|
86907
87155
|
//#endregion
|
|
87156
|
+
//#region src/cli/format/thread.ts
|
|
87157
|
+
function formatThreadShowJson(thread) {
|
|
87158
|
+
return {
|
|
87159
|
+
id: thread.id,
|
|
87160
|
+
projectId: thread.projectId,
|
|
87161
|
+
title: thread.title,
|
|
87162
|
+
status: thread.status,
|
|
87163
|
+
session: thread.session,
|
|
87164
|
+
latestTurn: thread.latestTurn,
|
|
87165
|
+
modelSelection: thread.modelSelection,
|
|
87166
|
+
runtimeMode: thread.runtimeMode,
|
|
87167
|
+
interactionMode: thread.interactionMode,
|
|
87168
|
+
branch: thread.branch,
|
|
87169
|
+
worktreePath: thread.worktreePath,
|
|
87170
|
+
archivedAt: thread.archivedAt,
|
|
87171
|
+
createdAt: thread.createdAt,
|
|
87172
|
+
updatedAt: thread.updatedAt,
|
|
87173
|
+
messageCount: thread.messageCount,
|
|
87174
|
+
hasPendingApprovals: thread.hasPendingApprovals,
|
|
87175
|
+
hasPendingUserInput: thread.hasPendingUserInput,
|
|
87176
|
+
hasActionableProposedPlan: thread.hasActionableProposedPlan,
|
|
87177
|
+
pendingApprovals: thread.pendingApprovals,
|
|
87178
|
+
pendingUserInputs: thread.pendingUserInputs
|
|
87179
|
+
};
|
|
87180
|
+
}
|
|
87181
|
+
function formatThreadShowHuman(thread) {
|
|
87182
|
+
const sections = [formatRecord([
|
|
87183
|
+
{
|
|
87184
|
+
field: "title",
|
|
87185
|
+
value: thread.title
|
|
87186
|
+
},
|
|
87187
|
+
{
|
|
87188
|
+
field: "id",
|
|
87189
|
+
value: thread.id
|
|
87190
|
+
},
|
|
87191
|
+
{
|
|
87192
|
+
field: "project",
|
|
87193
|
+
value: thread.projectId
|
|
87194
|
+
},
|
|
87195
|
+
{
|
|
87196
|
+
field: "status",
|
|
87197
|
+
value: thread.status
|
|
87198
|
+
},
|
|
87199
|
+
{
|
|
87200
|
+
field: "model",
|
|
87201
|
+
value: `${thread.modelSelection.instanceId}/${thread.modelSelection.model}`
|
|
87202
|
+
},
|
|
87203
|
+
{
|
|
87204
|
+
field: "runtime",
|
|
87205
|
+
value: thread.runtimeMode
|
|
87206
|
+
},
|
|
87207
|
+
{
|
|
87208
|
+
field: "interaction",
|
|
87209
|
+
value: thread.interactionMode
|
|
87210
|
+
},
|
|
87211
|
+
...thread.branch !== null ? [{
|
|
87212
|
+
field: "branch",
|
|
87213
|
+
value: thread.branch
|
|
87214
|
+
}] : [],
|
|
87215
|
+
...thread.worktreePath !== null ? [{
|
|
87216
|
+
field: "worktree",
|
|
87217
|
+
value: thread.worktreePath
|
|
87218
|
+
}] : [],
|
|
87219
|
+
...thread.archivedAt !== null ? [{
|
|
87220
|
+
field: "archived",
|
|
87221
|
+
value: thread.archivedAt
|
|
87222
|
+
}] : [],
|
|
87223
|
+
{
|
|
87224
|
+
field: "messages",
|
|
87225
|
+
value: String(thread.messageCount)
|
|
87226
|
+
},
|
|
87227
|
+
{
|
|
87228
|
+
field: "updated",
|
|
87229
|
+
value: thread.updatedAt
|
|
87230
|
+
}
|
|
87231
|
+
])];
|
|
87232
|
+
if (thread.pendingApprovals.length > 0) sections.push(`\npending approvals\n${formatTable([
|
|
87233
|
+
{
|
|
87234
|
+
header: "request",
|
|
87235
|
+
value: (approval) => approval.requestId,
|
|
87236
|
+
maxWidth: 40
|
|
87237
|
+
},
|
|
87238
|
+
{
|
|
87239
|
+
header: "kind",
|
|
87240
|
+
value: (approval) => approval.requestKind,
|
|
87241
|
+
maxWidth: 16
|
|
87242
|
+
},
|
|
87243
|
+
{
|
|
87244
|
+
header: "created",
|
|
87245
|
+
value: (approval) => approval.createdAt,
|
|
87246
|
+
maxWidth: 28
|
|
87247
|
+
},
|
|
87248
|
+
{
|
|
87249
|
+
header: "detail",
|
|
87250
|
+
value: (approval) => approval.detail ?? "-",
|
|
87251
|
+
maxWidth: 72
|
|
87252
|
+
}
|
|
87253
|
+
], thread.pendingApprovals)}`);
|
|
87254
|
+
if (thread.pendingUserInputs.length > 0) sections.push(`\npending user inputs\n${formatTable([
|
|
87255
|
+
{
|
|
87256
|
+
header: "request",
|
|
87257
|
+
value: (input) => input.requestId,
|
|
87258
|
+
maxWidth: 40
|
|
87259
|
+
},
|
|
87260
|
+
{
|
|
87261
|
+
header: "questions",
|
|
87262
|
+
value: (input) => String(input.questions.length),
|
|
87263
|
+
maxWidth: 9
|
|
87264
|
+
},
|
|
87265
|
+
{
|
|
87266
|
+
header: "created",
|
|
87267
|
+
value: (input) => input.createdAt,
|
|
87268
|
+
maxWidth: 28
|
|
87269
|
+
},
|
|
87270
|
+
{
|
|
87271
|
+
header: "prompt",
|
|
87272
|
+
value: (input) => input.questions.map((question) => question.question).join("\n"),
|
|
87273
|
+
maxWidth: 72
|
|
87274
|
+
}
|
|
87275
|
+
], thread.pendingUserInputs)}`);
|
|
87276
|
+
return `${sections.join("\n")}\n`;
|
|
87277
|
+
}
|
|
87278
|
+
function formatThreadsHuman(threads) {
|
|
87279
|
+
if (threads.length === 0) return "no threads\n";
|
|
87280
|
+
return `${formatTable([
|
|
87281
|
+
{
|
|
87282
|
+
header: "title",
|
|
87283
|
+
value: (thread) => thread.title,
|
|
87284
|
+
maxWidth: 36
|
|
87285
|
+
},
|
|
87286
|
+
{
|
|
87287
|
+
header: "id",
|
|
87288
|
+
value: (thread) => thread.id,
|
|
87289
|
+
maxWidth: 40
|
|
87290
|
+
},
|
|
87291
|
+
{
|
|
87292
|
+
header: "status",
|
|
87293
|
+
value: (thread) => threadStatus(thread),
|
|
87294
|
+
maxWidth: 18
|
|
87295
|
+
},
|
|
87296
|
+
{
|
|
87297
|
+
header: "updated",
|
|
87298
|
+
value: (thread) => thread.updatedAt,
|
|
87299
|
+
maxWidth: 28
|
|
87300
|
+
},
|
|
87301
|
+
{
|
|
87302
|
+
header: "flags",
|
|
87303
|
+
value: formatThreadFlags,
|
|
87304
|
+
maxWidth: 34
|
|
87305
|
+
}
|
|
87306
|
+
], threads)}\n`;
|
|
87307
|
+
}
|
|
87308
|
+
function formatThreadSearchHuman(matches) {
|
|
87309
|
+
if (matches.length === 0) return "no matches\n";
|
|
87310
|
+
return `${matches.map((match) => formatRecord([
|
|
87311
|
+
{
|
|
87312
|
+
field: "thread",
|
|
87313
|
+
value: match.threadTitle ?? "-"
|
|
87314
|
+
},
|
|
87315
|
+
{
|
|
87316
|
+
field: "thread id",
|
|
87317
|
+
value: match.threadId
|
|
87318
|
+
},
|
|
87319
|
+
{
|
|
87320
|
+
field: "project",
|
|
87321
|
+
value: match.projectTitle ?? "-"
|
|
87322
|
+
},
|
|
87323
|
+
{
|
|
87324
|
+
field: "project id",
|
|
87325
|
+
value: match.projectId
|
|
87326
|
+
},
|
|
87327
|
+
{
|
|
87328
|
+
field: "workspace",
|
|
87329
|
+
value: match.workspaceRoot ?? "-"
|
|
87330
|
+
},
|
|
87331
|
+
{
|
|
87332
|
+
field: "branch",
|
|
87333
|
+
value: match.branch ?? "-"
|
|
87334
|
+
},
|
|
87335
|
+
{
|
|
87336
|
+
field: "worktree",
|
|
87337
|
+
value: match.worktreePath ?? "-"
|
|
87338
|
+
},
|
|
87339
|
+
{
|
|
87340
|
+
field: "source",
|
|
87341
|
+
value: match.source
|
|
87342
|
+
},
|
|
87343
|
+
{
|
|
87344
|
+
field: "created",
|
|
87345
|
+
value: match.messageCreatedAt ?? "-"
|
|
87346
|
+
},
|
|
87347
|
+
{
|
|
87348
|
+
field: "snippet",
|
|
87349
|
+
value: match.snippet
|
|
87350
|
+
}
|
|
87351
|
+
])).join("\n\n")}\n`;
|
|
87352
|
+
}
|
|
87353
|
+
function formatThreadDeletedHuman(input) {
|
|
87354
|
+
return `thread deleted: ${input.threadId} (sequence ${input.dispatch.sequence})`;
|
|
87355
|
+
}
|
|
87356
|
+
function formatThreadStartedHuman(input) {
|
|
87357
|
+
return `thread started\n${formatRecord([
|
|
87358
|
+
{
|
|
87359
|
+
field: "title",
|
|
87360
|
+
value: input.thread.title
|
|
87361
|
+
},
|
|
87362
|
+
{
|
|
87363
|
+
field: "id",
|
|
87364
|
+
value: input.thread.id
|
|
87365
|
+
},
|
|
87366
|
+
{
|
|
87367
|
+
field: "status",
|
|
87368
|
+
value: threadStatus(input.thread)
|
|
87369
|
+
},
|
|
87370
|
+
{
|
|
87371
|
+
field: "sequence",
|
|
87372
|
+
value: String(input.sequence)
|
|
87373
|
+
}
|
|
87374
|
+
])}`;
|
|
87375
|
+
}
|
|
87376
|
+
function formatThreadMessagesHuman(snapshot, limit) {
|
|
87377
|
+
const transcript = formatChatTranscript(limit === 0 ? snapshot.thread.messages : snapshot.thread.messages.slice(-limit));
|
|
87378
|
+
return snapshot.page?.hasMore === true && snapshot.page.beforeCursor !== null ? `${transcript}\nearlier turns available\nbefore cursor: ${snapshot.page.beforeCursor}\n` : transcript;
|
|
87379
|
+
}
|
|
87380
|
+
function formatWaitDoneHuman(thread) {
|
|
87381
|
+
const latest = latestAssistantMessage(thread);
|
|
87382
|
+
return `status: ${threadStatus(thread)}\n${latest !== void 0 ? `\n${formatChatTranscript([latest])}` : ""}`;
|
|
87383
|
+
}
|
|
87384
|
+
function formatThreadMessagesJson(snapshot, full) {
|
|
87385
|
+
return full ? {
|
|
87386
|
+
...snapshot,
|
|
87387
|
+
page: snapshot.page ?? null
|
|
87388
|
+
} : {
|
|
87389
|
+
snapshotSequence: snapshot.snapshotSequence,
|
|
87390
|
+
thread: stripThreadMessages(snapshot.thread),
|
|
87391
|
+
messages: snapshot.thread.messages,
|
|
87392
|
+
page: snapshot.page ?? null
|
|
87393
|
+
};
|
|
87394
|
+
}
|
|
87395
|
+
function formatWaitEventNdjson(event) {
|
|
87396
|
+
if (event.type !== "thread" && event.type !== "done") return event;
|
|
87397
|
+
const compactThread = stripThreadHeavy(event.thread);
|
|
87398
|
+
return event.type === "done" ? {
|
|
87399
|
+
type: "done",
|
|
87400
|
+
thread: compactThread,
|
|
87401
|
+
latestAssistantMessage: latestAssistantMessage(event.thread) ?? null
|
|
87402
|
+
} : {
|
|
87403
|
+
type: "thread",
|
|
87404
|
+
thread: compactThread,
|
|
87405
|
+
messageCount: event.thread.messages.length
|
|
87406
|
+
};
|
|
87407
|
+
}
|
|
87408
|
+
function stripThreadMessages(thread) {
|
|
87409
|
+
const { messages: _messages, ...rest } = thread;
|
|
87410
|
+
return rest;
|
|
87411
|
+
}
|
|
87412
|
+
function formatThreadFlags(thread) {
|
|
87413
|
+
const flags = [
|
|
87414
|
+
thread.archivedAt !== null ? "archived" : null,
|
|
87415
|
+
thread.hasPendingApprovals ? "approval" : null,
|
|
87416
|
+
thread.hasPendingUserInput ? "input" : null,
|
|
87417
|
+
thread.hasActionableProposedPlan ? "plan" : null
|
|
87418
|
+
].filter((flag) => flag !== null);
|
|
87419
|
+
return flags.length > 0 ? flags.join(", ") : "-";
|
|
87420
|
+
}
|
|
87421
|
+
function stripThreadHeavy(thread) {
|
|
87422
|
+
const { messages: _messages, activities: _activities, proposedPlans: _proposedPlans, checkpoints: _checkpoints, ...rest } = thread;
|
|
87423
|
+
return rest;
|
|
87424
|
+
}
|
|
87425
|
+
//#endregion
|
|
87426
|
+
//#region src/cli/ask-lifecycle.ts
|
|
87427
|
+
const archivePolicyChoices = [
|
|
87428
|
+
"never",
|
|
87429
|
+
"always",
|
|
87430
|
+
"on-success",
|
|
87431
|
+
"on-failure"
|
|
87432
|
+
];
|
|
87433
|
+
function resolveAskFormat(format, cliRuntime, t3CliEnv) {
|
|
87434
|
+
if (format !== "auto") return format;
|
|
87435
|
+
return isInteractiveHumanTerminal(cliRuntime, t3CliEnv) ? "human" : "json";
|
|
87436
|
+
}
|
|
87437
|
+
function ensureAskTargetAvailable(thread) {
|
|
87438
|
+
if (thread.archivedAt !== null) return fail(new AskThreadArchivedError({
|
|
87439
|
+
message: `thread is archived: ${thread.id}`,
|
|
87440
|
+
threadId: thread.id
|
|
87441
|
+
}));
|
|
87442
|
+
if (thread.hasPendingApprovals || thread.hasPendingUserInput) return fail(new AskThreadPendingRequestError({
|
|
87443
|
+
message: `thread has a pending approval or user-input request: ${thread.id}`,
|
|
87444
|
+
threadId: thread.id
|
|
87445
|
+
}));
|
|
87446
|
+
return void_;
|
|
87447
|
+
}
|
|
87448
|
+
function waitForAskThread(application, output, input) {
|
|
87449
|
+
let lastStatus = "";
|
|
87450
|
+
let turnComplete = false;
|
|
87451
|
+
const observeAskThread = (thread) => {
|
|
87452
|
+
const observation = inspectAskTurn(thread, input.messageId, input.state.askTurnId);
|
|
87453
|
+
input.state.askTurnId = observation.turnId;
|
|
87454
|
+
if (observation.status === "failed") return fail(new ThreadSessionError({
|
|
87455
|
+
threadId: input.threadId,
|
|
87456
|
+
message: observation.message
|
|
87457
|
+
}));
|
|
87458
|
+
turnComplete = observation.status === "complete";
|
|
87459
|
+
return void_;
|
|
87460
|
+
};
|
|
87461
|
+
return gen(function* () {
|
|
87462
|
+
if (input.format === "human") yield* output.writeStderr(`waiting for ${input.threadId}...\n`);
|
|
87463
|
+
const event = getOrUndefined(yield* application.watchThread(input.threadId).pipe(tap((event) => gen(function* () {
|
|
87464
|
+
if (event.type === "thread" || event.type === "done") yield* observeAskThread(event.thread);
|
|
87465
|
+
else if (event.type === "status") {
|
|
87466
|
+
const thread = (yield* application.getThreadMessages({ threadId: input.threadId })).thread;
|
|
87467
|
+
yield* observeAskThread(thread);
|
|
87468
|
+
if (!turnComplete) yield* ensureNoPendingRequest({
|
|
87469
|
+
id: thread.id,
|
|
87470
|
+
hasPendingApprovals: derivePendingApprovals(thread.activities).length > 0,
|
|
87471
|
+
hasPendingUserInput: derivePendingUserInputs(thread.activities).length > 0
|
|
87472
|
+
});
|
|
87473
|
+
}
|
|
87474
|
+
if (input.format === "ndjson") {
|
|
87475
|
+
yield* output.printNdjson(formatWaitEventNdjson(event));
|
|
87476
|
+
return;
|
|
87477
|
+
}
|
|
87478
|
+
if (input.format === "human" && event.type === "status" && event.status !== lastStatus) {
|
|
87479
|
+
lastStatus = event.status;
|
|
87480
|
+
yield* output.writeStderr(`${input.threadId}: ${event.status}\n`);
|
|
87481
|
+
}
|
|
87482
|
+
})), takeUntil((event) => turnComplete || event.type === "done"), runLast));
|
|
87483
|
+
if (!turnComplete && event?.type !== "done") return yield* fail(new ThreadSessionError({
|
|
87484
|
+
message: `thread wait ended without a terminal event: ${input.threadId}`,
|
|
87485
|
+
threadId: input.threadId
|
|
87486
|
+
}));
|
|
87487
|
+
return yield* void_;
|
|
87488
|
+
});
|
|
87489
|
+
}
|
|
87490
|
+
function selectAskAnswer(thread, messageId, turnId) {
|
|
87491
|
+
const userIndex = thread.messages.findIndex((message) => message.id === messageId && message.role === "user");
|
|
87492
|
+
if (userIndex === -1) return;
|
|
87493
|
+
const following = thread.messages.slice(userIndex + 1);
|
|
87494
|
+
const nextUserIndex = following.findIndex((message) => message.role === "user");
|
|
87495
|
+
return (nextUserIndex === -1 ? following : following.slice(0, nextUserIndex)).filter((message) => message.role === "assistant" && !message.streaming && message.text.trim().length > 0 && (turnId === null || message.turnId === turnId)).at(-1);
|
|
87496
|
+
}
|
|
87497
|
+
function inspectAskTurn(thread, messageId, knownTurnId) {
|
|
87498
|
+
const userIndex = thread.messages.findIndex((message) => message.id === messageId && message.role === "user");
|
|
87499
|
+
const userMessage = userIndex === -1 ? void 0 : thread.messages[userIndex];
|
|
87500
|
+
if (userMessage === void 0) return {
|
|
87501
|
+
status: "waiting",
|
|
87502
|
+
turnId: knownTurnId
|
|
87503
|
+
};
|
|
87504
|
+
const following = thread.messages.slice(userIndex + 1);
|
|
87505
|
+
const nextUserIndex = following.findIndex((message) => message.role === "user");
|
|
87506
|
+
const messageTurnId = (nextUserIndex === -1 ? following : following.slice(0, nextUserIndex)).findLast((message) => message.role === "assistant" && message.turnId !== null)?.turnId ?? null;
|
|
87507
|
+
const latestTurn = thread.latestTurn;
|
|
87508
|
+
const requestedTurnId = latestTurn?.requestedAt === userMessage.createdAt ? latestTurn.turnId : null;
|
|
87509
|
+
const turnId = knownTurnId ?? requestedTurnId ?? messageTurnId ?? thread.session?.activeTurnId ?? null;
|
|
87510
|
+
if (turnId === null) return {
|
|
87511
|
+
status: nextUserIndex === -1 ? "waiting" : "complete",
|
|
87512
|
+
turnId
|
|
87513
|
+
};
|
|
87514
|
+
const askIsLatest = latestTurn?.turnId === turnId;
|
|
87515
|
+
if (askIsLatest && (latestTurn.state === "error" || thread.session?.status === "error")) return {
|
|
87516
|
+
status: "failed",
|
|
87517
|
+
turnId,
|
|
87518
|
+
message: thread.session?.lastError ?? "thread ended with error"
|
|
87519
|
+
};
|
|
87520
|
+
const sessionRunning = thread.session?.status === "starting" || thread.session?.status === "running";
|
|
87521
|
+
return {
|
|
87522
|
+
status: nextUserIndex !== -1 || askIsLatest && (latestTurn.state !== "running" || thread.session?.activeTurnId !== turnId && !sessionRunning) ? "complete" : "waiting",
|
|
87523
|
+
turnId
|
|
87524
|
+
};
|
|
87525
|
+
}
|
|
87526
|
+
function finalizeArchive(application, output, state, succeeded) {
|
|
87527
|
+
if (state.archiveResult !== void 0) return succeed(state.archiveResult);
|
|
87528
|
+
const shouldArchive = state.archivePolicy === "always" || state.archivePolicy === "on-success" && succeeded || state.archivePolicy === "on-failure" && !succeeded;
|
|
87529
|
+
if (!state.createdThread && !state.dispatched || state.threadId === void 0 || !shouldArchive) {
|
|
87530
|
+
const result = {
|
|
87531
|
+
policy: state.archivePolicy,
|
|
87532
|
+
status: "skipped"
|
|
87533
|
+
};
|
|
87534
|
+
state.archiveResult = result;
|
|
87535
|
+
return succeed(result);
|
|
87536
|
+
}
|
|
87537
|
+
const threadId = state.threadId;
|
|
87538
|
+
return application.archiveThread(threadId).pipe(matchEffect({
|
|
87539
|
+
onFailure: (error) => gen(function* () {
|
|
87540
|
+
const result = {
|
|
87541
|
+
policy: state.archivePolicy,
|
|
87542
|
+
status: "failed",
|
|
87543
|
+
error: error.message
|
|
87544
|
+
};
|
|
87545
|
+
state.archiveResult = result;
|
|
87546
|
+
yield* output.writeStderr(`warning: failed to archive thread ${threadId}: ${error.message}\n`).pipe(ignore);
|
|
87547
|
+
return result;
|
|
87548
|
+
}),
|
|
87549
|
+
onSuccess: (dispatch) => {
|
|
87550
|
+
const result = {
|
|
87551
|
+
policy: state.archivePolicy,
|
|
87552
|
+
status: "archived",
|
|
87553
|
+
sequence: dispatch.sequence
|
|
87554
|
+
};
|
|
87555
|
+
state.archiveResult = result;
|
|
87556
|
+
return succeed(result);
|
|
87557
|
+
}
|
|
87558
|
+
}));
|
|
87559
|
+
}
|
|
87560
|
+
function cleanupInterruptedAsk(application, output, state) {
|
|
87561
|
+
if (state.threadId === void 0) return void_;
|
|
87562
|
+
const threadId = state.threadId;
|
|
87563
|
+
return gen(function* () {
|
|
87564
|
+
if (state.dispatched && state.askTurnId !== null) yield* application.interruptThreadTurn(threadId, state.askTurnId).pipe(matchEffect({
|
|
87565
|
+
onFailure: (error) => output.writeStderr(`warning: failed to interrupt thread ${threadId}: ${error.message}\n`).pipe(ignore),
|
|
87566
|
+
onSuccess: () => void_
|
|
87567
|
+
}));
|
|
87568
|
+
yield* finalizeArchive(application, output, state, false);
|
|
87569
|
+
}).pipe(asVoid);
|
|
87570
|
+
}
|
|
87571
|
+
function ensureTrailingNewline(text) {
|
|
87572
|
+
return text.endsWith("\n") ? text : `${text}\n`;
|
|
87573
|
+
}
|
|
87574
|
+
function ensureNoPendingRequest(thread) {
|
|
87575
|
+
if (!thread.hasPendingApprovals && !thread.hasPendingUserInput) return void_;
|
|
87576
|
+
return fail(new AskThreadPendingRequestError({
|
|
87577
|
+
message: `thread requested approval or user input instead of answering: ${thread.id}`,
|
|
87578
|
+
threadId: thread.id
|
|
87579
|
+
}));
|
|
87580
|
+
}
|
|
87581
|
+
//#endregion
|
|
87582
|
+
//#region src/cli/input/service.ts
|
|
87583
|
+
var T3Input = class extends Service()("t3cli/T3Input") {};
|
|
87584
|
+
//#endregion
|
|
87585
|
+
//#region src/cli/interaction/self-action.ts
|
|
87586
|
+
const requireSelfActionConfirmation = fn("requireSelfActionConfirmation")(function* (input) {
|
|
87587
|
+
if (input.force) return;
|
|
87588
|
+
if (!isAgentEnvironment(input.t3CliEnv)) return;
|
|
87589
|
+
const callerThreadId = input.t3CliEnv.scope.t3codeThreadId;
|
|
87590
|
+
if (callerThreadId === void 0 || callerThreadId.length === 0) return;
|
|
87591
|
+
if (input.threadId !== callerThreadId) return;
|
|
87592
|
+
yield* fail(new SelfActionError({
|
|
87593
|
+
threadId: input.threadId,
|
|
87594
|
+
message: `cannot ${input.action} thread ${input.threadId}: command targets the calling thread. Pass --force to confirm.`
|
|
87595
|
+
}));
|
|
87596
|
+
});
|
|
87597
|
+
//#endregion
|
|
87598
|
+
//#region src/cli/message-input.ts
|
|
87599
|
+
function readInitialMessage(input) {
|
|
87600
|
+
if (input.message !== void 0 && input.message.length > 0 && input.fromStdin) return fail(new MessageInputError({ message: "pass message argument or --stdin, not both" }));
|
|
87601
|
+
if (input.fromStdin) return input.readStdin();
|
|
87602
|
+
if (input.message === void 0 || input.message.length === 0) return fail(new MessageInputError({ message: "message required unless --stdin is used" }));
|
|
87603
|
+
return succeed(input.message);
|
|
87604
|
+
}
|
|
87605
|
+
function readJsonAnswers(input) {
|
|
87606
|
+
if (input.answers !== void 0 && input.answers.length > 0 && input.fromStdin) return fail(new MessageInputError({ message: "pass --answers or --stdin, not both" }));
|
|
87607
|
+
if (input.fromStdin) return input.readStdin().pipe(flatMap(parseJsonAnswers));
|
|
87608
|
+
if (input.answers === void 0 || input.answers.length === 0) return fail(new MessageInputError({ message: "answers required unless --stdin is used" }));
|
|
87609
|
+
return parseJsonAnswers(input.answers);
|
|
87610
|
+
}
|
|
87611
|
+
function parseJsonAnswers(text) {
|
|
87612
|
+
try {
|
|
87613
|
+
const parsed = JSON.parse(text);
|
|
87614
|
+
return succeed(decodeUnknownSync(ProviderUserInputAnswers)(parsed));
|
|
87615
|
+
} catch {
|
|
87616
|
+
return fail(new MessageInputError({ message: "invalid JSON in answers" }));
|
|
87617
|
+
}
|
|
87618
|
+
}
|
|
87619
|
+
//#endregion
|
|
87620
|
+
//#region src/cli/model-options.ts
|
|
87621
|
+
function buildModelOptions(input) {
|
|
87622
|
+
const options = /* @__PURE__ */ new Map();
|
|
87623
|
+
const optionRecord = getOrUndefined(input.option);
|
|
87624
|
+
if (optionRecord !== void 0) for (const [id, value] of Object.entries(optionRecord)) options.set(id, {
|
|
87625
|
+
id,
|
|
87626
|
+
value: parseModelOptionValue(value)
|
|
87627
|
+
});
|
|
87628
|
+
setStringOption(options, "reasoningEffort", getOrUndefined(input.reasoningEffort));
|
|
87629
|
+
setStringOption(options, "effort", getOrUndefined(input.effort));
|
|
87630
|
+
setBooleanOption(options, "fastMode", getOrUndefined(input.fastMode));
|
|
87631
|
+
setBooleanOption(options, "thinking", getOrUndefined(input.thinking));
|
|
87632
|
+
return [...options.values()];
|
|
87633
|
+
}
|
|
87634
|
+
function parseModelOptionValue(value) {
|
|
87635
|
+
const normalized = value.trim().toLowerCase();
|
|
87636
|
+
if (normalized === "true") return true;
|
|
87637
|
+
if (normalized === "false") return false;
|
|
87638
|
+
return value;
|
|
87639
|
+
}
|
|
87640
|
+
function setStringOption(options, id, value) {
|
|
87641
|
+
if (value !== void 0 && value.length > 0) options.set(id, {
|
|
87642
|
+
id,
|
|
87643
|
+
value
|
|
87644
|
+
});
|
|
87645
|
+
}
|
|
87646
|
+
function setBooleanOption(options, id, value) {
|
|
87647
|
+
if (value !== void 0) options.set(id, {
|
|
87648
|
+
id,
|
|
87649
|
+
value
|
|
87650
|
+
});
|
|
87651
|
+
}
|
|
87652
|
+
//#endregion
|
|
87653
|
+
//#region src/cli/ask.ts
|
|
87654
|
+
const askThreadFlag = string$2("thread").pipe(withDescription$1("Existing thread id; T3CODE_THREAD_ID is not used"), optional$2);
|
|
87655
|
+
const archivePolicyFlag = choice("archive", archivePolicyChoices).pipe(withDescription$1("Archive policy (default: on-success for created threads, never for existing threads)"), optional$2);
|
|
87656
|
+
const timeoutFlag = string$2("timeout").pipe(withDescription$1("Response timeout, such as 30s, 5m, or 1h"), optional$2);
|
|
87657
|
+
const askFormatFlag = choice("format", humanJsonNdjsonFormatChoices).pipe(withDefault("human"));
|
|
87658
|
+
const askCommand = make("ask", {
|
|
87659
|
+
project: projectFlag,
|
|
87660
|
+
thread: askThreadFlag,
|
|
87661
|
+
force: selfActionForceFlag,
|
|
87662
|
+
message: string("message").pipe(optional),
|
|
87663
|
+
stdin: boolean("stdin"),
|
|
87664
|
+
title: string$2("title").pipe(optional$2),
|
|
87665
|
+
worktree: worktreeFlag,
|
|
87666
|
+
provider: string$2("provider").pipe(optional$2),
|
|
87667
|
+
model: string$2("model").pipe(optional$2),
|
|
87668
|
+
...modelFlags,
|
|
87669
|
+
archive: archivePolicyFlag,
|
|
87670
|
+
timeout: timeoutFlag,
|
|
87671
|
+
format: askFormatFlag,
|
|
87672
|
+
...extraArgsConfig
|
|
87673
|
+
}, ({ project, thread, force, message, stdin, title, worktree, provider, model, option, reasoningEffort, effort, fastMode, thinking, archive, timeout, format: format$1 }) => gen(function* () {
|
|
87674
|
+
const explicitThreadId = getOrUndefined(thread);
|
|
87675
|
+
const created = explicitThreadId === void 0;
|
|
87676
|
+
const titleValue = getOrUndefined(title);
|
|
87677
|
+
const providerValue = getOrUndefined(provider);
|
|
87678
|
+
const modelValue = getOrUndefined(model);
|
|
87679
|
+
const createOnlyFlags = [
|
|
87680
|
+
isSome(title) ? "--title" : null,
|
|
87681
|
+
isSome(worktree) ? "--worktree" : null,
|
|
87682
|
+
isSome(provider) ? "--provider" : null,
|
|
87683
|
+
isSome(model) ? "--model" : null
|
|
87684
|
+
].filter((flag) => flag !== null);
|
|
87685
|
+
if (!created && createOnlyFlags.length > 0) return yield* fail(new InvalidFlagCombinationError({ message: `${createOnlyFlags.join(", ")} cannot be used with --thread` }));
|
|
87686
|
+
if (created && force) return yield* fail(new InvalidFlagCombinationError({ message: "--force can only be used with --thread" }));
|
|
87687
|
+
const timeoutValue = getOrUndefined(timeout);
|
|
87688
|
+
const timeoutDuration = timeoutValue === void 0 ? void 0 : yield* parseAskTimeout(timeoutValue);
|
|
87689
|
+
const archivePolicy = getOrElse(archive, () => created ? "on-success" : "never");
|
|
87690
|
+
const application = yield* T3Application;
|
|
87691
|
+
const cliRuntime = yield* CliRuntime;
|
|
87692
|
+
const t3CliEnv = yield* loadT3CliEnv;
|
|
87693
|
+
const input = yield* T3Input;
|
|
87694
|
+
const output = yield* T3Output;
|
|
87695
|
+
const resolvedFormat = resolveAskFormat(format$1, cliRuntime, t3CliEnv);
|
|
87696
|
+
const options = buildModelOptions({
|
|
87697
|
+
option,
|
|
87698
|
+
reasoningEffort,
|
|
87699
|
+
effort,
|
|
87700
|
+
fastMode,
|
|
87701
|
+
thinking
|
|
87702
|
+
});
|
|
87703
|
+
const state = {
|
|
87704
|
+
archivePolicy,
|
|
87705
|
+
threadId: explicitThreadId,
|
|
87706
|
+
createdThread: false,
|
|
87707
|
+
dispatched: false,
|
|
87708
|
+
askTurnId: null,
|
|
87709
|
+
archiveResult: void 0
|
|
87710
|
+
};
|
|
87711
|
+
const responseWithCleanup = gen(function* () {
|
|
87712
|
+
const text = yield* readInitialMessage({
|
|
87713
|
+
message: getOrUndefined(message),
|
|
87714
|
+
fromStdin: stdin,
|
|
87715
|
+
readStdin: input.readStdin
|
|
87716
|
+
});
|
|
87717
|
+
let dispatch;
|
|
87718
|
+
let askMessageId;
|
|
87719
|
+
if (explicitThreadId === void 0) {
|
|
87720
|
+
const projectRef = yield* requireCommandProjectRef({ project });
|
|
87721
|
+
const resolvedProject = yield* application.resolveProject(projectRef);
|
|
87722
|
+
const worktreePath = resolveWorktreePath({
|
|
87723
|
+
value: getOrUndefined(worktree),
|
|
87724
|
+
scope: t3CliEnv.scope
|
|
87725
|
+
});
|
|
87726
|
+
const result = yield* application.startThread({
|
|
87727
|
+
message: text,
|
|
87728
|
+
projectRef: resolvedProject.id,
|
|
87729
|
+
...titleValue !== void 0 ? { title: titleValue } : {},
|
|
87730
|
+
...worktreePath !== void 0 ? { worktreePath } : {},
|
|
87731
|
+
...providerValue !== void 0 ? { provider: providerValue } : {},
|
|
87732
|
+
...modelValue !== void 0 ? { model: modelValue } : {},
|
|
87733
|
+
...options.length > 0 ? { options } : {}
|
|
87734
|
+
}, {
|
|
87735
|
+
until: "dispatch",
|
|
87736
|
+
onThreadCreated: (threadId) => sync(() => {
|
|
87737
|
+
state.threadId = threadId;
|
|
87738
|
+
state.createdThread = true;
|
|
87739
|
+
})
|
|
87740
|
+
});
|
|
87741
|
+
state.dispatched = true;
|
|
87742
|
+
dispatch = result.dispatch;
|
|
87743
|
+
askMessageId = result.messageId;
|
|
87744
|
+
} else {
|
|
87745
|
+
const summary = yield* application.getThreadSummary(explicitThreadId);
|
|
87746
|
+
yield* ensureAskTargetAvailable(summary);
|
|
87747
|
+
const projectRef = getOrUndefined(project);
|
|
87748
|
+
if (projectRef !== void 0) {
|
|
87749
|
+
const resolvedProject = yield* application.resolveProject(projectRef);
|
|
87750
|
+
if (summary.projectId !== resolvedProject.id) return yield* fail(new AskProjectMismatchError({
|
|
87751
|
+
message: `thread ${explicitThreadId} belongs to project ${summary.projectId}, not ${resolvedProject.id}`,
|
|
87752
|
+
threadId: explicitThreadId,
|
|
87753
|
+
projectId: resolvedProject.id
|
|
87754
|
+
}));
|
|
87755
|
+
}
|
|
87756
|
+
yield* requireSelfActionConfirmation({
|
|
87757
|
+
threadId: explicitThreadId,
|
|
87758
|
+
force,
|
|
87759
|
+
cliRuntime,
|
|
87760
|
+
t3CliEnv,
|
|
87761
|
+
action: "ask"
|
|
87762
|
+
});
|
|
87763
|
+
const targetThread = (yield* application.getThreadMessages({ threadId: explicitThreadId })).thread;
|
|
87764
|
+
if (isThreadActive(targetThread)) return yield* fail(new AskThreadBusyError({
|
|
87765
|
+
message: `thread is busy: ${explicitThreadId}`,
|
|
87766
|
+
threadId: explicitThreadId
|
|
87767
|
+
}));
|
|
87768
|
+
const result = yield* application.sendThread({
|
|
87769
|
+
threadId: explicitThreadId,
|
|
87770
|
+
message: text,
|
|
87771
|
+
...options.length > 0 ? { options } : {}
|
|
87772
|
+
}, { until: "dispatch" });
|
|
87773
|
+
state.dispatched = true;
|
|
87774
|
+
dispatch = result.dispatch;
|
|
87775
|
+
askMessageId = result.messageId;
|
|
87776
|
+
}
|
|
87777
|
+
const threadId = state.threadId;
|
|
87778
|
+
if (threadId === void 0) return yield* fail(new AskNoAnswerError({
|
|
87779
|
+
message: "ask did not resolve a thread id",
|
|
87780
|
+
threadId: "unknown"
|
|
87781
|
+
}));
|
|
87782
|
+
if (resolvedFormat === "ndjson") yield* output.printNdjson({
|
|
87783
|
+
type: "dispatch",
|
|
87784
|
+
sequence: dispatch.sequence
|
|
87785
|
+
});
|
|
87786
|
+
yield* application.awaitShellSequence(dispatch.sequence);
|
|
87787
|
+
yield* waitForAskThread(application, output, {
|
|
87788
|
+
threadId,
|
|
87789
|
+
format: resolvedFormat,
|
|
87790
|
+
messageId: askMessageId,
|
|
87791
|
+
state
|
|
87792
|
+
});
|
|
87793
|
+
const finalSnapshot = yield* application.getThreadMessages({ threadId });
|
|
87794
|
+
const observation = inspectAskTurn(finalSnapshot.thread, askMessageId, state.askTurnId);
|
|
87795
|
+
if (observation.status === "failed") return yield* fail(new ThreadSessionError({
|
|
87796
|
+
threadId,
|
|
87797
|
+
message: observation.message
|
|
87798
|
+
}));
|
|
87799
|
+
const answer = selectAskAnswer(finalSnapshot.thread, askMessageId, observation.turnId);
|
|
87800
|
+
if (answer === void 0) return yield* fail(new AskNoAnswerError({
|
|
87801
|
+
message: `thread completed without a new final answer: ${threadId}`,
|
|
87802
|
+
threadId
|
|
87803
|
+
}));
|
|
87804
|
+
return {
|
|
87805
|
+
answer: answer.text,
|
|
87806
|
+
threadId,
|
|
87807
|
+
turnId: answer.turnId,
|
|
87808
|
+
created,
|
|
87809
|
+
dispatch
|
|
87810
|
+
};
|
|
87811
|
+
}).pipe(onInterrupt(() => cleanupInterruptedAsk(application, output, state)));
|
|
87812
|
+
return yield* (timeoutDuration === void 0 ? responseWithCleanup : responseWithCleanup.pipe(timeoutOrElse({
|
|
87813
|
+
duration: timeoutDuration,
|
|
87814
|
+
orElse: () => fail(new AskTimeoutError({
|
|
87815
|
+
message: `ask timed out after ${timeoutValue ?? format(timeoutDuration)}`,
|
|
87816
|
+
timeout: timeoutValue ?? format(timeoutDuration)
|
|
87817
|
+
}))
|
|
87818
|
+
}))).pipe(matchEffect({
|
|
87819
|
+
onFailure: (error) => finalizeArchive(application, output, state, false).pipe(flatMap(() => fail(error))),
|
|
87820
|
+
onSuccess: (result) => gen(function* () {
|
|
87821
|
+
const archiveResult = yield* finalizeArchive(application, output, state, true);
|
|
87822
|
+
const formatted = {
|
|
87823
|
+
answer: result.answer,
|
|
87824
|
+
threadId: result.threadId,
|
|
87825
|
+
turnId: result.turnId,
|
|
87826
|
+
created: result.created,
|
|
87827
|
+
dispatch: result.dispatch,
|
|
87828
|
+
archive: archiveResult
|
|
87829
|
+
};
|
|
87830
|
+
if (resolvedFormat === "json") return yield* output.printJson(formatted);
|
|
87831
|
+
if (resolvedFormat === "ndjson") return yield* output.printNdjson({
|
|
87832
|
+
type: "result",
|
|
87833
|
+
...formatted
|
|
87834
|
+
});
|
|
87835
|
+
return yield* output.writeStdout(ensureTrailingNewline(result.answer));
|
|
87836
|
+
})
|
|
87837
|
+
}));
|
|
87838
|
+
})).pipe(withDescription("ask a project or existing thread and wait for one answer"));
|
|
87839
|
+
function parseAskTimeout(value) {
|
|
87840
|
+
const trimmed = value.trim();
|
|
87841
|
+
const shorthand = /^([0-9]+(?:\.[0-9]+)?)(ms|s|m|h|d|w)$/.exec(trimmed);
|
|
87842
|
+
let input = trimmed;
|
|
87843
|
+
if (shorthand !== null) {
|
|
87844
|
+
const amount = shorthand[1];
|
|
87845
|
+
const unit = shorthand[2];
|
|
87846
|
+
const expandedUnit = unit === void 0 ? void 0 : {
|
|
87847
|
+
ms: "millis",
|
|
87848
|
+
s: "seconds",
|
|
87849
|
+
m: "minutes",
|
|
87850
|
+
h: "hours",
|
|
87851
|
+
d: "days",
|
|
87852
|
+
w: "weeks"
|
|
87853
|
+
}[unit];
|
|
87854
|
+
if (amount !== void 0 && expandedUnit !== void 0) input = `${amount} ${expandedUnit}`;
|
|
87855
|
+
}
|
|
87856
|
+
const parsed = decodeUnknownOption(DurationFromString)(input);
|
|
87857
|
+
if (isNone(parsed)) return fail(new InvalidAskTimeoutError({
|
|
87858
|
+
message: `invalid timeout: ${value}`,
|
|
87859
|
+
value
|
|
87860
|
+
}));
|
|
87861
|
+
const millis = toMillis(parsed.value);
|
|
87862
|
+
if (!Number.isFinite(millis) || millis <= 0) return fail(new InvalidAskTimeoutError({
|
|
87863
|
+
message: `timeout must be a positive finite duration: ${value}`,
|
|
87864
|
+
value
|
|
87865
|
+
}));
|
|
87866
|
+
return succeed(parsed.value);
|
|
87867
|
+
}
|
|
87868
|
+
//#endregion
|
|
86908
87869
|
//#region src/cli/format/auth.ts
|
|
86909
87870
|
function formatAuthPaired(result) {
|
|
86910
87871
|
return `paired\n${formatRecord([
|
|
@@ -87564,9 +88525,6 @@ function formatWaitHuman(input) {
|
|
|
87564
88525
|
return details.length > 0 ? `terminal ${input.status}: ${input.terminalId} (${input.threadId}) ${details}` : `terminal ${input.status}: ${input.terminalId} (${input.threadId})`;
|
|
87565
88526
|
}
|
|
87566
88527
|
//#endregion
|
|
87567
|
-
//#region src/cli/input/service.ts
|
|
87568
|
-
var T3Input = class extends Service()("t3cli/T3Input") {};
|
|
87569
|
-
//#endregion
|
|
87570
88528
|
//#region src/cli/terminal/write.ts
|
|
87571
88529
|
const writeTerminalCommand = make("write", {
|
|
87572
88530
|
thread: threadFlag,
|
|
@@ -87827,6 +88785,31 @@ const addCommand = make("add", {
|
|
|
87827
88785
|
else yield* output.printInfo(formatProjectAddedHuman(result.project));
|
|
87828
88786
|
})).pipe(withDescription("add project"));
|
|
87829
88787
|
//#endregion
|
|
88788
|
+
//#region src/cli/search.ts
|
|
88789
|
+
const searchThreadsCommand = make("search", {
|
|
88790
|
+
query: string("query"),
|
|
88791
|
+
limit: integer$1("limit").pipe(withDescription$1("Maximum matches (1-50, default: 50)"), optional$2),
|
|
88792
|
+
format: formatFlag,
|
|
88793
|
+
...extraArgsConfig
|
|
88794
|
+
}, ({ query, limit, format }) => gen(function* () {
|
|
88795
|
+
const value = getOrUndefined(limit);
|
|
88796
|
+
if (value !== void 0 && (value < 1 || value > 50)) return yield* fail(new InvalidLimitError({
|
|
88797
|
+
message: `invalid limit: ${value}`,
|
|
88798
|
+
value: String(value)
|
|
88799
|
+
}));
|
|
88800
|
+
const application = yield* T3Application;
|
|
88801
|
+
const cliRuntime = yield* CliRuntime;
|
|
88802
|
+
const t3CliEnv = yield* loadT3CliEnv;
|
|
88803
|
+
const output = yield* T3Output;
|
|
88804
|
+
const resolvedFormat = resolveOutputFormat(format, cliRuntime, t3CliEnv, "json");
|
|
88805
|
+
const matches = yield* application.searchThreads({
|
|
88806
|
+
query,
|
|
88807
|
+
...value !== void 0 ? { limit: value } : {}
|
|
88808
|
+
});
|
|
88809
|
+
if (resolvedFormat === "json") return yield* output.printJson(matches);
|
|
88810
|
+
return yield* output.writeStdout(formatThreadSearchHuman(matches));
|
|
88811
|
+
})).pipe(withDescription("search threads by conversation content"));
|
|
88812
|
+
//#endregion
|
|
87830
88813
|
//#region src/cli/threads/approve.ts
|
|
87831
88814
|
const approvalDecisionFlag = choice("decision", [
|
|
87832
88815
|
"accept",
|
|
@@ -87861,19 +88844,6 @@ const approveThreadCommand = make("approve", {
|
|
|
87861
88844
|
return yield* output.printInfo(`approval submitted: ${result.requestId} (sequence ${result.dispatch.sequence})`);
|
|
87862
88845
|
})).pipe(withDescription("respond to a pending approval request"));
|
|
87863
88846
|
//#endregion
|
|
87864
|
-
//#region src/cli/interaction/self-action.ts
|
|
87865
|
-
const requireSelfActionConfirmation = fn("requireSelfActionConfirmation")(function* (input) {
|
|
87866
|
-
if (input.force) return;
|
|
87867
|
-
if (!isAgentEnvironment(input.t3CliEnv)) return;
|
|
87868
|
-
const callerThreadId = input.t3CliEnv.scope.t3codeThreadId;
|
|
87869
|
-
if (callerThreadId === void 0 || callerThreadId.length === 0) return;
|
|
87870
|
-
if (input.threadId !== callerThreadId) return;
|
|
87871
|
-
yield* fail(new SelfActionError({
|
|
87872
|
-
threadId: input.threadId,
|
|
87873
|
-
message: `cannot ${input.action} thread ${input.threadId}: command targets the calling thread. Pass --force to confirm.`
|
|
87874
|
-
}));
|
|
87875
|
-
});
|
|
87876
|
-
//#endregion
|
|
87877
88847
|
//#region src/cli/threads/archive.ts
|
|
87878
88848
|
const archiveThreadCommand = make("archive", {
|
|
87879
88849
|
thread: threadFlag,
|
|
@@ -87954,225 +88924,6 @@ const callbackThreadCommand = make("callback", {
|
|
|
87954
88924
|
yield* output.printInfo(`callback sent to ${result.targetThreadId} (dispatch: ${result.dispatch.sequence})`);
|
|
87955
88925
|
})).pipe(withDescription("watch a thread and send a message when it completes"));
|
|
87956
88926
|
//#endregion
|
|
87957
|
-
//#region src/cli/format/thread.ts
|
|
87958
|
-
function formatThreadShowJson(thread) {
|
|
87959
|
-
return {
|
|
87960
|
-
id: thread.id,
|
|
87961
|
-
projectId: thread.projectId,
|
|
87962
|
-
title: thread.title,
|
|
87963
|
-
status: thread.status,
|
|
87964
|
-
session: thread.session,
|
|
87965
|
-
latestTurn: thread.latestTurn,
|
|
87966
|
-
modelSelection: thread.modelSelection,
|
|
87967
|
-
runtimeMode: thread.runtimeMode,
|
|
87968
|
-
interactionMode: thread.interactionMode,
|
|
87969
|
-
branch: thread.branch,
|
|
87970
|
-
worktreePath: thread.worktreePath,
|
|
87971
|
-
archivedAt: thread.archivedAt,
|
|
87972
|
-
createdAt: thread.createdAt,
|
|
87973
|
-
updatedAt: thread.updatedAt,
|
|
87974
|
-
messageCount: thread.messageCount,
|
|
87975
|
-
hasPendingApprovals: thread.hasPendingApprovals,
|
|
87976
|
-
hasPendingUserInput: thread.hasPendingUserInput,
|
|
87977
|
-
hasActionableProposedPlan: thread.hasActionableProposedPlan,
|
|
87978
|
-
pendingApprovals: thread.pendingApprovals,
|
|
87979
|
-
pendingUserInputs: thread.pendingUserInputs
|
|
87980
|
-
};
|
|
87981
|
-
}
|
|
87982
|
-
function formatThreadShowHuman(thread) {
|
|
87983
|
-
const sections = [formatRecord([
|
|
87984
|
-
{
|
|
87985
|
-
field: "title",
|
|
87986
|
-
value: thread.title
|
|
87987
|
-
},
|
|
87988
|
-
{
|
|
87989
|
-
field: "id",
|
|
87990
|
-
value: thread.id
|
|
87991
|
-
},
|
|
87992
|
-
{
|
|
87993
|
-
field: "project",
|
|
87994
|
-
value: thread.projectId
|
|
87995
|
-
},
|
|
87996
|
-
{
|
|
87997
|
-
field: "status",
|
|
87998
|
-
value: thread.status
|
|
87999
|
-
},
|
|
88000
|
-
{
|
|
88001
|
-
field: "model",
|
|
88002
|
-
value: `${thread.modelSelection.instanceId}/${thread.modelSelection.model}`
|
|
88003
|
-
},
|
|
88004
|
-
{
|
|
88005
|
-
field: "runtime",
|
|
88006
|
-
value: thread.runtimeMode
|
|
88007
|
-
},
|
|
88008
|
-
{
|
|
88009
|
-
field: "interaction",
|
|
88010
|
-
value: thread.interactionMode
|
|
88011
|
-
},
|
|
88012
|
-
...thread.branch !== null ? [{
|
|
88013
|
-
field: "branch",
|
|
88014
|
-
value: thread.branch
|
|
88015
|
-
}] : [],
|
|
88016
|
-
...thread.worktreePath !== null ? [{
|
|
88017
|
-
field: "worktree",
|
|
88018
|
-
value: thread.worktreePath
|
|
88019
|
-
}] : [],
|
|
88020
|
-
...thread.archivedAt !== null ? [{
|
|
88021
|
-
field: "archived",
|
|
88022
|
-
value: thread.archivedAt
|
|
88023
|
-
}] : [],
|
|
88024
|
-
{
|
|
88025
|
-
field: "messages",
|
|
88026
|
-
value: String(thread.messageCount)
|
|
88027
|
-
},
|
|
88028
|
-
{
|
|
88029
|
-
field: "updated",
|
|
88030
|
-
value: thread.updatedAt
|
|
88031
|
-
}
|
|
88032
|
-
])];
|
|
88033
|
-
if (thread.pendingApprovals.length > 0) sections.push(`\npending approvals\n${formatTable([
|
|
88034
|
-
{
|
|
88035
|
-
header: "request",
|
|
88036
|
-
value: (approval) => approval.requestId,
|
|
88037
|
-
maxWidth: 40
|
|
88038
|
-
},
|
|
88039
|
-
{
|
|
88040
|
-
header: "kind",
|
|
88041
|
-
value: (approval) => approval.requestKind,
|
|
88042
|
-
maxWidth: 16
|
|
88043
|
-
},
|
|
88044
|
-
{
|
|
88045
|
-
header: "created",
|
|
88046
|
-
value: (approval) => approval.createdAt,
|
|
88047
|
-
maxWidth: 28
|
|
88048
|
-
},
|
|
88049
|
-
{
|
|
88050
|
-
header: "detail",
|
|
88051
|
-
value: (approval) => approval.detail ?? "-",
|
|
88052
|
-
maxWidth: 72
|
|
88053
|
-
}
|
|
88054
|
-
], thread.pendingApprovals)}`);
|
|
88055
|
-
if (thread.pendingUserInputs.length > 0) sections.push(`\npending user inputs\n${formatTable([
|
|
88056
|
-
{
|
|
88057
|
-
header: "request",
|
|
88058
|
-
value: (input) => input.requestId,
|
|
88059
|
-
maxWidth: 40
|
|
88060
|
-
},
|
|
88061
|
-
{
|
|
88062
|
-
header: "questions",
|
|
88063
|
-
value: (input) => String(input.questions.length),
|
|
88064
|
-
maxWidth: 9
|
|
88065
|
-
},
|
|
88066
|
-
{
|
|
88067
|
-
header: "created",
|
|
88068
|
-
value: (input) => input.createdAt,
|
|
88069
|
-
maxWidth: 28
|
|
88070
|
-
},
|
|
88071
|
-
{
|
|
88072
|
-
header: "prompt",
|
|
88073
|
-
value: (input) => input.questions.map((question) => question.question).join("\n"),
|
|
88074
|
-
maxWidth: 72
|
|
88075
|
-
}
|
|
88076
|
-
], thread.pendingUserInputs)}`);
|
|
88077
|
-
return `${sections.join("\n")}\n`;
|
|
88078
|
-
}
|
|
88079
|
-
function formatThreadsHuman(threads) {
|
|
88080
|
-
if (threads.length === 0) return "no threads\n";
|
|
88081
|
-
return `${formatTable([
|
|
88082
|
-
{
|
|
88083
|
-
header: "title",
|
|
88084
|
-
value: (thread) => thread.title,
|
|
88085
|
-
maxWidth: 36
|
|
88086
|
-
},
|
|
88087
|
-
{
|
|
88088
|
-
header: "id",
|
|
88089
|
-
value: (thread) => thread.id,
|
|
88090
|
-
maxWidth: 40
|
|
88091
|
-
},
|
|
88092
|
-
{
|
|
88093
|
-
header: "status",
|
|
88094
|
-
value: (thread) => threadStatus(thread),
|
|
88095
|
-
maxWidth: 18
|
|
88096
|
-
},
|
|
88097
|
-
{
|
|
88098
|
-
header: "updated",
|
|
88099
|
-
value: (thread) => thread.updatedAt,
|
|
88100
|
-
maxWidth: 28
|
|
88101
|
-
},
|
|
88102
|
-
{
|
|
88103
|
-
header: "flags",
|
|
88104
|
-
value: formatThreadFlags,
|
|
88105
|
-
maxWidth: 34
|
|
88106
|
-
}
|
|
88107
|
-
], threads)}\n`;
|
|
88108
|
-
}
|
|
88109
|
-
function formatThreadDeletedHuman(input) {
|
|
88110
|
-
return `thread deleted: ${input.threadId} (sequence ${input.dispatch.sequence})`;
|
|
88111
|
-
}
|
|
88112
|
-
function formatThreadStartedHuman(input) {
|
|
88113
|
-
return `thread started\n${formatRecord([
|
|
88114
|
-
{
|
|
88115
|
-
field: "title",
|
|
88116
|
-
value: input.thread.title
|
|
88117
|
-
},
|
|
88118
|
-
{
|
|
88119
|
-
field: "id",
|
|
88120
|
-
value: input.thread.id
|
|
88121
|
-
},
|
|
88122
|
-
{
|
|
88123
|
-
field: "status",
|
|
88124
|
-
value: threadStatus(input.thread)
|
|
88125
|
-
},
|
|
88126
|
-
{
|
|
88127
|
-
field: "sequence",
|
|
88128
|
-
value: String(input.sequence)
|
|
88129
|
-
}
|
|
88130
|
-
])}`;
|
|
88131
|
-
}
|
|
88132
|
-
function formatThreadMessagesHuman(thread, limit) {
|
|
88133
|
-
return formatChatTranscript(limit === 0 ? thread.messages : thread.messages.slice(-limit));
|
|
88134
|
-
}
|
|
88135
|
-
function formatWaitDoneHuman(thread) {
|
|
88136
|
-
const latest = latestAssistantMessage(thread);
|
|
88137
|
-
return `status: ${threadStatus(thread)}\n${latest !== void 0 ? `\n${formatChatTranscript([latest])}` : ""}`;
|
|
88138
|
-
}
|
|
88139
|
-
function formatThreadMessagesJson(thread, full) {
|
|
88140
|
-
return full ? thread : {
|
|
88141
|
-
thread: stripThreadMessages(thread),
|
|
88142
|
-
messages: thread.messages
|
|
88143
|
-
};
|
|
88144
|
-
}
|
|
88145
|
-
function formatWaitEventNdjson(event) {
|
|
88146
|
-
if (event.type !== "thread" && event.type !== "done") return event;
|
|
88147
|
-
const compactThread = stripThreadHeavy(event.thread);
|
|
88148
|
-
return event.type === "done" ? {
|
|
88149
|
-
type: "done",
|
|
88150
|
-
thread: compactThread,
|
|
88151
|
-
latestAssistantMessage: latestAssistantMessage(event.thread) ?? null
|
|
88152
|
-
} : {
|
|
88153
|
-
type: "thread",
|
|
88154
|
-
thread: compactThread,
|
|
88155
|
-
messageCount: event.thread.messages.length
|
|
88156
|
-
};
|
|
88157
|
-
}
|
|
88158
|
-
function stripThreadMessages(thread) {
|
|
88159
|
-
const { messages: _messages, ...rest } = thread;
|
|
88160
|
-
return rest;
|
|
88161
|
-
}
|
|
88162
|
-
function formatThreadFlags(thread) {
|
|
88163
|
-
const flags = [
|
|
88164
|
-
thread.archivedAt !== null ? "archived" : null,
|
|
88165
|
-
thread.hasPendingApprovals ? "approval" : null,
|
|
88166
|
-
thread.hasPendingUserInput ? "input" : null,
|
|
88167
|
-
thread.hasActionableProposedPlan ? "plan" : null
|
|
88168
|
-
].filter((flag) => flag !== null);
|
|
88169
|
-
return flags.length > 0 ? flags.join(", ") : "-";
|
|
88170
|
-
}
|
|
88171
|
-
function stripThreadHeavy(thread) {
|
|
88172
|
-
const { messages: _messages, activities: _activities, proposedPlans: _proposedPlans, checkpoints: _checkpoints, ...rest } = thread;
|
|
88173
|
-
return rest;
|
|
88174
|
-
}
|
|
88175
|
-
//#endregion
|
|
88176
88927
|
//#region src/cli/threads/delete.ts
|
|
88177
88928
|
const deleteThreadCommand = make("delete", {
|
|
88178
88929
|
thread: threadFlag,
|
|
@@ -88244,27 +88995,26 @@ const interruptThreadCommand = make("interrupt", {
|
|
|
88244
88995
|
return yield* output.printInfo(`thread interrupted: ${threadId} (sequence ${dispatch.sequence})`);
|
|
88245
88996
|
})).pipe(withDescription("interrupt running thread turn"));
|
|
88246
88997
|
//#endregion
|
|
88247
|
-
//#region src/cli/
|
|
88248
|
-
|
|
88249
|
-
|
|
88250
|
-
|
|
88251
|
-
|
|
88252
|
-
|
|
88253
|
-
|
|
88254
|
-
|
|
88255
|
-
|
|
88256
|
-
|
|
88257
|
-
|
|
88258
|
-
|
|
88259
|
-
|
|
88260
|
-
|
|
88261
|
-
|
|
88262
|
-
|
|
88263
|
-
|
|
88264
|
-
|
|
88265
|
-
|
|
88266
|
-
|
|
88267
|
-
}
|
|
88998
|
+
//#region src/cli/threads/pin.ts
|
|
88999
|
+
const pinThreadCommand = make("pin", {
|
|
89000
|
+
thread: threadFlag,
|
|
89001
|
+
format: formatFlag,
|
|
89002
|
+
...extraArgsConfig
|
|
89003
|
+
}, ({ thread, format }) => gen(function* () {
|
|
89004
|
+
const application = yield* T3Application;
|
|
89005
|
+
const cliRuntime = yield* CliRuntime;
|
|
89006
|
+
const t3CliEnv = yield* loadT3CliEnv;
|
|
89007
|
+
const output = yield* T3Output;
|
|
89008
|
+
const threadId = resolveThreadId({
|
|
89009
|
+
value: getOrUndefined(thread),
|
|
89010
|
+
scope: t3CliEnv.scope
|
|
89011
|
+
});
|
|
89012
|
+
if (threadId === void 0) return yield* fail(new MissingThreadError({ message: "thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
|
|
89013
|
+
const resolvedFormat = resolveOutputFormat(format, cliRuntime, t3CliEnv, "json");
|
|
89014
|
+
const dispatch = yield* application.pinThread(threadId);
|
|
89015
|
+
if (resolvedFormat === "json") return yield* output.printJson(dispatch);
|
|
89016
|
+
return yield* output.printInfo(`thread pinned: ${threadId} (sequence ${dispatch.sequence})`);
|
|
89017
|
+
})).pipe(withDescription("pin thread"));
|
|
88268
89018
|
const respondThreadCommand = make("respond", {
|
|
88269
89019
|
thread: threadFlag,
|
|
88270
89020
|
request: string$2("request").pipe(withDescription$1("Pending user-input request id"), optional$2),
|
|
@@ -88300,6 +89050,74 @@ const respondThreadCommand = make("respond", {
|
|
|
88300
89050
|
return yield* output.printInfo(`user input submitted: ${result.requestId} (sequence ${result.dispatch.sequence})`);
|
|
88301
89051
|
})).pipe(withDescription("respond to a pending user-input request"));
|
|
88302
89052
|
//#endregion
|
|
89053
|
+
//#region src/cli/threads/settle.ts
|
|
89054
|
+
const settleThreadCommand = make("settle", {
|
|
89055
|
+
thread: threadFlag,
|
|
89056
|
+
format: formatFlag,
|
|
89057
|
+
...extraArgsConfig
|
|
89058
|
+
}, ({ thread, format }) => gen(function* () {
|
|
89059
|
+
const application = yield* T3Application;
|
|
89060
|
+
const cliRuntime = yield* CliRuntime;
|
|
89061
|
+
const t3CliEnv = yield* loadT3CliEnv;
|
|
89062
|
+
const output = yield* T3Output;
|
|
89063
|
+
const threadId = resolveThreadId({
|
|
89064
|
+
value: getOrUndefined(thread),
|
|
89065
|
+
scope: t3CliEnv.scope
|
|
89066
|
+
});
|
|
89067
|
+
if (threadId === void 0) return yield* fail(new MissingThreadError({ message: "thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
|
|
89068
|
+
const resolvedFormat = resolveOutputFormat(format, cliRuntime, t3CliEnv, "json");
|
|
89069
|
+
const dispatch = yield* application.settleThread(threadId);
|
|
89070
|
+
if (resolvedFormat === "json") return yield* output.printJson(dispatch);
|
|
89071
|
+
return yield* output.printInfo(`thread settled: ${threadId} (sequence ${dispatch.sequence})`);
|
|
89072
|
+
})).pipe(withDescription("settle thread"));
|
|
89073
|
+
const snoozeThreadCommand = make("snooze", {
|
|
89074
|
+
thread: threadFlag,
|
|
89075
|
+
until: string$2("until").pipe(optional$2),
|
|
89076
|
+
preset: choice("preset", [
|
|
89077
|
+
"hour",
|
|
89078
|
+
"evening",
|
|
89079
|
+
"tomorrow",
|
|
89080
|
+
"next-week"
|
|
89081
|
+
]).pipe(optional$2),
|
|
89082
|
+
format: formatFlag,
|
|
89083
|
+
...extraArgsConfig
|
|
89084
|
+
}, ({ thread, until, preset, format }) => gen(function* () {
|
|
89085
|
+
const application = yield* T3Application;
|
|
89086
|
+
const cliRuntime = yield* CliRuntime;
|
|
89087
|
+
const t3CliEnv = yield* loadT3CliEnv;
|
|
89088
|
+
const output = yield* T3Output;
|
|
89089
|
+
const threadId = resolveThreadId({
|
|
89090
|
+
value: getOrUndefined(thread),
|
|
89091
|
+
scope: t3CliEnv.scope
|
|
89092
|
+
});
|
|
89093
|
+
if (threadId === void 0) return yield* fail(new MissingThreadError({ message: "thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
|
|
89094
|
+
const untilValue = getOrUndefined(until);
|
|
89095
|
+
const presetValue = getOrUndefined(preset);
|
|
89096
|
+
if (untilValue !== void 0 && presetValue !== void 0) return yield* fail(new InvalidFlagCombinationError({ message: "exactly one of --until or --preset is required" }));
|
|
89097
|
+
let snoozedUntil;
|
|
89098
|
+
if (untilValue !== void 0) snoozedUntil = yield* decodeUnknownEffect(DateTimeUtcFromString)(untilValue).pipe(map(formatIso), mapError(() => new InvalidSnoozeUntilError({
|
|
89099
|
+
message: `invalid ISO-8601 snooze time: ${untilValue}`,
|
|
89100
|
+
value: untilValue
|
|
89101
|
+
})));
|
|
89102
|
+
else if (presetValue !== void 0) snoozedUntil = yield* resolveSnoozePreset(presetValue);
|
|
89103
|
+
else return yield* fail(new InvalidFlagCombinationError({ message: "exactly one of --until or --preset is required" }));
|
|
89104
|
+
const resolvedFormat = resolveOutputFormat(format, cliRuntime, t3CliEnv, "json");
|
|
89105
|
+
const dispatch = yield* application.snoozeThread({
|
|
89106
|
+
threadId,
|
|
89107
|
+
snoozedUntil
|
|
89108
|
+
});
|
|
89109
|
+
if (resolvedFormat === "json") return yield* output.printJson(dispatch);
|
|
89110
|
+
return yield* output.printInfo(`thread snoozed: ${threadId} until ${snoozedUntil} (sequence ${dispatch.sequence})`);
|
|
89111
|
+
})).pipe(withDescription("snooze thread"));
|
|
89112
|
+
const resolveSnoozePreset = fn("resolveSnoozePreset")(function* (presetId) {
|
|
89113
|
+
const preset = resolveSnoozePresets(yield* nowAsDate).find((candidate) => candidate.id === presetId);
|
|
89114
|
+
if (preset === void 0) return yield* fail(new UnavailableSnoozePresetError({
|
|
89115
|
+
message: `snooze preset is not available at this time: ${presetId}`,
|
|
89116
|
+
preset: presetId
|
|
89117
|
+
}));
|
|
89118
|
+
return preset.snoozedUntil;
|
|
89119
|
+
});
|
|
89120
|
+
//#endregion
|
|
88303
89121
|
//#region src/cli/threads/unarchive.ts
|
|
88304
89122
|
const unarchiveThreadCommand = make("unarchive", {
|
|
88305
89123
|
thread: threadFlag,
|
|
@@ -88321,38 +89139,68 @@ const unarchiveThreadCommand = make("unarchive", {
|
|
|
88321
89139
|
return yield* output.printInfo(`thread unarchived: ${threadId} (sequence ${dispatch.sequence})`);
|
|
88322
89140
|
})).pipe(withDescription("unarchive thread"));
|
|
88323
89141
|
//#endregion
|
|
88324
|
-
//#region src/cli/
|
|
88325
|
-
|
|
88326
|
-
|
|
88327
|
-
|
|
88328
|
-
|
|
88329
|
-
|
|
88330
|
-
|
|
89142
|
+
//#region src/cli/threads/unpin.ts
|
|
89143
|
+
const unpinThreadCommand = make("unpin", {
|
|
89144
|
+
thread: threadFlag,
|
|
89145
|
+
format: formatFlag,
|
|
89146
|
+
...extraArgsConfig
|
|
89147
|
+
}, ({ thread, format }) => gen(function* () {
|
|
89148
|
+
const application = yield* T3Application;
|
|
89149
|
+
const cliRuntime = yield* CliRuntime;
|
|
89150
|
+
const t3CliEnv = yield* loadT3CliEnv;
|
|
89151
|
+
const output = yield* T3Output;
|
|
89152
|
+
const threadId = resolveThreadId({
|
|
89153
|
+
value: getOrUndefined(thread),
|
|
89154
|
+
scope: t3CliEnv.scope
|
|
88331
89155
|
});
|
|
88332
|
-
|
|
88333
|
-
|
|
88334
|
-
|
|
88335
|
-
|
|
88336
|
-
return
|
|
88337
|
-
}
|
|
88338
|
-
|
|
88339
|
-
|
|
88340
|
-
|
|
88341
|
-
|
|
88342
|
-
|
|
88343
|
-
|
|
88344
|
-
|
|
88345
|
-
|
|
88346
|
-
|
|
88347
|
-
|
|
89156
|
+
if (threadId === void 0) return yield* fail(new MissingThreadError({ message: "thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
|
|
89157
|
+
const resolvedFormat = resolveOutputFormat(format, cliRuntime, t3CliEnv, "json");
|
|
89158
|
+
const dispatch = yield* application.unpinThread(threadId);
|
|
89159
|
+
if (resolvedFormat === "json") return yield* output.printJson(dispatch);
|
|
89160
|
+
return yield* output.printInfo(`thread unpinned: ${threadId} (sequence ${dispatch.sequence})`);
|
|
89161
|
+
})).pipe(withDescription("unpin thread"));
|
|
89162
|
+
//#endregion
|
|
89163
|
+
//#region src/cli/threads/unsnooze.ts
|
|
89164
|
+
const unsnoozeThreadCommand = make("unsnooze", {
|
|
89165
|
+
thread: threadFlag,
|
|
89166
|
+
format: formatFlag,
|
|
89167
|
+
...extraArgsConfig
|
|
89168
|
+
}, ({ thread, format }) => gen(function* () {
|
|
89169
|
+
const application = yield* T3Application;
|
|
89170
|
+
const cliRuntime = yield* CliRuntime;
|
|
89171
|
+
const t3CliEnv = yield* loadT3CliEnv;
|
|
89172
|
+
const output = yield* T3Output;
|
|
89173
|
+
const threadId = resolveThreadId({
|
|
89174
|
+
value: getOrUndefined(thread),
|
|
89175
|
+
scope: t3CliEnv.scope
|
|
88348
89176
|
});
|
|
88349
|
-
}
|
|
88350
|
-
|
|
88351
|
-
|
|
88352
|
-
|
|
88353
|
-
|
|
89177
|
+
if (threadId === void 0) return yield* fail(new MissingThreadError({ message: "thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
|
|
89178
|
+
const resolvedFormat = resolveOutputFormat(format, cliRuntime, t3CliEnv, "json");
|
|
89179
|
+
const dispatch = yield* application.unsnoozeThread(threadId);
|
|
89180
|
+
if (resolvedFormat === "json") return yield* output.printJson(dispatch);
|
|
89181
|
+
return yield* output.printInfo(`thread unsnoozed: ${threadId} (sequence ${dispatch.sequence})`);
|
|
89182
|
+
})).pipe(withDescription("unsnooze thread"));
|
|
89183
|
+
//#endregion
|
|
89184
|
+
//#region src/cli/threads/unsettle.ts
|
|
89185
|
+
const unsettleThreadCommand = make("unsettle", {
|
|
89186
|
+
thread: threadFlag,
|
|
89187
|
+
format: formatFlag,
|
|
89188
|
+
...extraArgsConfig
|
|
89189
|
+
}, ({ thread, format }) => gen(function* () {
|
|
89190
|
+
const application = yield* T3Application;
|
|
89191
|
+
const cliRuntime = yield* CliRuntime;
|
|
89192
|
+
const t3CliEnv = yield* loadT3CliEnv;
|
|
89193
|
+
const output = yield* T3Output;
|
|
89194
|
+
const threadId = resolveThreadId({
|
|
89195
|
+
value: getOrUndefined(thread),
|
|
89196
|
+
scope: t3CliEnv.scope
|
|
88354
89197
|
});
|
|
88355
|
-
}
|
|
89198
|
+
if (threadId === void 0) return yield* fail(new MissingThreadError({ message: "thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
|
|
89199
|
+
const resolvedFormat = resolveOutputFormat(format, cliRuntime, t3CliEnv, "json");
|
|
89200
|
+
const dispatch = yield* application.unsettleThread(threadId);
|
|
89201
|
+
if (resolvedFormat === "json") return yield* output.printJson(dispatch);
|
|
89202
|
+
return yield* output.printInfo(`thread unsettled: ${threadId} (sequence ${dispatch.sequence})`);
|
|
89203
|
+
})).pipe(withDescription("unsettle thread"));
|
|
88356
89204
|
//#endregion
|
|
88357
89205
|
//#region src/cli/threads/update.ts
|
|
88358
89206
|
const updateThreadCommand = make("update", {
|
|
@@ -88427,6 +89275,12 @@ function createThreadCommand() {
|
|
|
88427
89275
|
respondThreadCommand,
|
|
88428
89276
|
archiveThreadCommand,
|
|
88429
89277
|
interruptThreadCommand,
|
|
89278
|
+
settleThreadCommand,
|
|
89279
|
+
unsettleThreadCommand,
|
|
89280
|
+
snoozeThreadCommand,
|
|
89281
|
+
unsnoozeThreadCommand,
|
|
89282
|
+
pinThreadCommand,
|
|
89283
|
+
unpinThreadCommand,
|
|
88430
89284
|
unarchiveThreadCommand,
|
|
88431
89285
|
updateThreadCommand,
|
|
88432
89286
|
deleteThreadCommand,
|
|
@@ -88582,7 +89436,11 @@ const sendThreadCommand = make("send", {
|
|
|
88582
89436
|
return yield* void_;
|
|
88583
89437
|
}
|
|
88584
89438
|
const result = yield* application.sendThread(input, { until: "visible" });
|
|
88585
|
-
if (resolvedFormat === "json") return yield* output.printJson(
|
|
89439
|
+
if (resolvedFormat === "json") return yield* output.printJson({
|
|
89440
|
+
dispatch: result.dispatch,
|
|
89441
|
+
threadId: result.threadId,
|
|
89442
|
+
thread: result.thread
|
|
89443
|
+
});
|
|
88586
89444
|
return yield* output.printInfo(`message sent: ${result.threadId}`);
|
|
88587
89445
|
})).pipe(withDescription("send message to existing thread"));
|
|
88588
89446
|
//#endregion
|
|
@@ -88687,7 +89545,12 @@ const startThreadCommand = make("start", {
|
|
|
88687
89545
|
return;
|
|
88688
89546
|
}
|
|
88689
89547
|
const result = yield* application.startThread(input, { until: "visible" });
|
|
88690
|
-
if (resolvedFormat === "json") yield* output.printJson(
|
|
89548
|
+
if (resolvedFormat === "json") yield* output.printJson({
|
|
89549
|
+
dispatch: result.dispatch,
|
|
89550
|
+
project: result.project,
|
|
89551
|
+
threadId: result.threadId,
|
|
89552
|
+
thread: result.thread
|
|
89553
|
+
});
|
|
88691
89554
|
else yield* output.printInfo(formatThreadStartedHuman({
|
|
88692
89555
|
thread: result.thread,
|
|
88693
89556
|
sequence: result.dispatch.sequence
|
|
@@ -88698,14 +89561,24 @@ const startThreadCommand = make("start", {
|
|
|
88698
89561
|
const getThreadTranscriptCommand = make("transcript", {
|
|
88699
89562
|
thread: threadFlag,
|
|
88700
89563
|
limit: integer$1("limit").pipe(withDefault(20)),
|
|
89564
|
+
turnLimit: integer$1("turn-limit").pipe(optional$2),
|
|
89565
|
+
beforeCursor: string$2("before-cursor").pipe(optional$2),
|
|
89566
|
+
all: boolean("all"),
|
|
88701
89567
|
full: boolean("full"),
|
|
88702
89568
|
format: formatFlag,
|
|
88703
89569
|
...extraArgsConfig
|
|
88704
|
-
}, ({ thread, limit, full, format }) => gen(function* () {
|
|
89570
|
+
}, ({ thread, limit, turnLimit, beforeCursor, all, full, format }) => gen(function* () {
|
|
88705
89571
|
if (limit < 0) return yield* fail(new InvalidLimitError({
|
|
88706
89572
|
message: `invalid limit: ${limit}`,
|
|
88707
89573
|
value: String(limit)
|
|
88708
89574
|
}));
|
|
89575
|
+
const turnLimitValue = getOrUndefined(turnLimit);
|
|
89576
|
+
const beforeCursorValue = getOrUndefined(beforeCursor);
|
|
89577
|
+
if (turnLimitValue !== void 0 && turnLimitValue <= 0) return yield* fail(new InvalidLimitError({
|
|
89578
|
+
message: `invalid turn limit: ${turnLimitValue}`,
|
|
89579
|
+
value: String(turnLimitValue)
|
|
89580
|
+
}));
|
|
89581
|
+
if (all && (turnLimitValue !== void 0 || beforeCursorValue !== void 0)) return yield* fail(new InvalidFlagCombinationError({ message: "--all cannot be combined with --turn-limit or --before-cursor" }));
|
|
88709
89582
|
const application = yield* T3Application;
|
|
88710
89583
|
const cliRuntime = yield* CliRuntime;
|
|
88711
89584
|
const t3CliEnv = yield* loadT3CliEnv;
|
|
@@ -88716,7 +89589,13 @@ const getThreadTranscriptCommand = make("transcript", {
|
|
|
88716
89589
|
});
|
|
88717
89590
|
if (threadId === void 0) return yield* fail(new MissingThreadError({ message: "thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
|
|
88718
89591
|
const resolvedFormat = resolveOutputFormat(format, cliRuntime, t3CliEnv, "json");
|
|
88719
|
-
const detail = yield* application.getThreadMessages(
|
|
89592
|
+
const detail = yield* application.getThreadMessages({
|
|
89593
|
+
threadId,
|
|
89594
|
+
...!all ? { window: {
|
|
89595
|
+
turnLimit: turnLimitValue ?? (beforeCursorValue === void 0 ? 10 : 20),
|
|
89596
|
+
...beforeCursorValue !== void 0 ? { beforeCursor: beforeCursorValue } : {}
|
|
89597
|
+
} } : {}
|
|
89598
|
+
});
|
|
88720
89599
|
if (resolvedFormat === "json") return yield* output.printJson(formatThreadMessagesJson(detail, full));
|
|
88721
89600
|
return yield* output.writeStdout(formatThreadMessagesHuman(detail, limit));
|
|
88722
89601
|
})).pipe(withDescription("get latest thread transcript"));
|
|
@@ -88747,11 +89626,13 @@ const waitForThreadCommand = make("wait", {
|
|
|
88747
89626
|
function createCliCommand() {
|
|
88748
89627
|
return make("t3cli").pipe(withDescription("non-interactive cli for running t3code server"), withGlobalFlags([cliEnvironmentSetting]), withSubcommands([
|
|
88749
89628
|
createActionCommand(),
|
|
89629
|
+
askCommand,
|
|
88750
89630
|
createAuthCommand(),
|
|
88751
89631
|
createEnvCommand(),
|
|
88752
89632
|
listThreadsCommand,
|
|
88753
89633
|
createModelCommand(),
|
|
88754
89634
|
createProjectCommand(),
|
|
89635
|
+
searchThreadsCommand,
|
|
88755
89636
|
createTerminalCommandGroup(),
|
|
88756
89637
|
startThreadCommand,
|
|
88757
89638
|
sendThreadCommand,
|
|
@@ -88893,7 +89774,7 @@ var T3Version = class extends Service()("t3cli/T3Version") {};
|
|
|
88893
89774
|
//#endregion
|
|
88894
89775
|
//#region src/version/layer.ts
|
|
88895
89776
|
const PackageJsonSchema = fromJsonString(Struct({ version: String$1 }));
|
|
88896
|
-
const T3VersionBundledLive = sync$1(T3Version, () => ({ version: "0.
|
|
89777
|
+
const T3VersionBundledLive = sync$1(T3Version, () => ({ version: "0.15.0" }));
|
|
88897
89778
|
effect(T3Version, gen(function* () {
|
|
88898
89779
|
const packageJson = yield* (yield* FileSystem).readFileString(fileURLToPath(new URL("../../package.json", import.meta.url)));
|
|
88899
89780
|
return { version: (yield* decodeUnknownEffect(PackageJsonSchema)(packageJson)).version };
|