codexuse-cli 3.6.5 → 3.6.6
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/dist/index.js +27 -5
- package/dist/index.js.map +1 -1
- package/dist/server/{NodeSqliteClient-BPzkJKIG.mjs → NodeSqliteClient-BPNNnMBz.mjs} +4 -4
- package/dist/server/{SqlClient-DSf3-WP1.mjs → SqlClient-B-Bb00hw.mjs} +479 -818
- package/dist/server/{SqlError-Cc34CGhm.mjs → SqlError-3S4KD3xN.mjs} +2 -2
- package/dist/server/{SqliteClient-BBxZHTRF.mjs → SqliteClient-9lnXlJby.mjs} +3 -3
- package/dist/server/index.mjs +774 -792
- package/dist/server/{open-Cm7F9p66.mjs → open-BM96ykXl.mjs} +1 -1
- package/package.json +1 -1
- package/dist/server/Cache-Ctxz7HFI.mjs +0 -567
package/dist/server/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
-
import { $ as
|
|
4
|
-
import { a as make$32, i as keys, n as getOption, o as makeWith$1, r as invalidate, s as set$3, t as get$3 } from "./Cache-Ctxz7HFI.mjs";
|
|
3
|
+
import { $ as is, $a as fromInputUnsafe, $i as succeed$1, $n as cached, $o as structure, $r as serviceOption, $t as splitLines, A as Record, Aa as scope, Ai as mergeAll, An as makeUnsafe$1, Ao as isNone, Ar as logError$1, At as make$21, B as Void, Ba as void_$2, Bi as provide$2, Bn as InvalidValue$1, Bo as PipeInspectableProto, Br as orElseSucceed, Bt as fromIterable$1, C as Literal, Ca as forkDetach, Ci as Class, Cn as shutdown, Co as isFailure$1, Cr as gen, Ct as Path$1, D as Null, Da as ignore$1, Di as effectDiscard, Dn as unbounded$1, Do as getOrElse, Dr as isEffect, Dt as FileTypeId, E as NonEmptyString, Ea as gen$1, Ei as effect, En as publish, Eo as fromNullishOr, Er as interrupt, Et as FileSystem, F as Trim, Fa as succeedNone, Fi as unwrap$1, Fn as nominal, Fo as some, Fr as matchCauseEffect, Ft as empty$4, G as decodeTo, Ga as Reference, Gi as isDone, Gn as acquireUseRelease, Go as BaseProto, Gr as result, Gt as make$30, H as declare, Ha as CurrentLogSpans, Hi as doneUnsafe, Hn as make$31, Ho as exitSucceed, Hr as provide, Ht as fromQueue, I as Tuple, Ia as suspend$1, Ii as Scope, In as transform$1, Io as Number$2, Ir as matchEffect, It as fail$5, J as decodeUnknownSync, Ja as empty$5, Ji as succeed$5, Jn as andThen, Jo as format$1, Jr as runPromiseWith, Jt as onExit$1, K as decodeUnknownEffect, Ka as Service, Ki as make$27, Kn as addFinalizer$1, Ko as Class$1, Kr as runFork, Kt as merge$1, L as URLFromString, La as sync$1, Li as addFinalizer, Ln as transformOrFail, Lo as make$26, Lr as never, Lt as flatMap$2, M as Struct, Ma as servicesWith, Mi as provideMerge, Mn as BadArgument, Mo as map$4, Mr as logWarning$1, Mt as concat, N as TaggedErrorClass, Na as sleep$1, Ni as succeed$2, Nn as badArgument, No as match, Nr as map$2, Nt as decodeText, O as NullOr, Oa as loggerMake, On as make$20, Oo as getOrNull, Or as log$1, Ot as Size, P as TemplateLiteral, Pa as succeed$3, Pi as sync$2, Pn as systemError, Po as none, Pr as mapError, Q as fromJsonString, Qa as merge$2, Qi as isSuccess, Qn as asVoid, Qo as array, Qr as service, Qt as runForEach, R as Union, Ra as uninterruptibleMask, Ri as close, Rn as parseJson, Ro as make$32, Rr as onInterrupt, Rt as fromChannel$1, S as Int, Sa as forever$1, Si as clamp, Sn as offerUnsafe, So as failVoid, Sr as forkScoped, St as omit, T as NonEmptyArray, Ta as formatLogSpan, Ti as TaggedError, Tn as unbounded, To as filter$1, Tr as ignoreCause, Tt as FileDescriptor, U as decodeEffect, Ua as MinimumLogLevel, Ui as fail$4, Un as encodeBase64Url, Uo as isEffect$1, Ur as provideService, Ut as fromReadableStream, V as brand, Va as CurrentLogAnnotations, Vi as _await, Vn as makeFormatterDefault, Vo as YieldableProto, Vr as promise, Vt as fromPubSub, W as decodeExit, Wa as DisablePropagation, Wi as failCause$1, Wn as acquireRelease, Wo as withFiber, Wr as provideServices, Wt as isStream, X as encodeEffect, Xi as hasInterrupts$1, Xn as as, Xo as symbolRedactable, Xt as runCollect, Y as encode, Ya as get$4, Yi as fail, Yn as annotateLogs, Yo as redact$1, Yr as runSync, Yt as run$2, Z as encodeUnknownEffect, Za as make$25, Zi as isFailure, Zn as asSome$1, Zo as symbol, Zr as scoped, Zt as runFold, _ as url, _a as causePretty, _i as withFiber$1, _n as endUnsafe, _o as makeEquivalence, _r as forEach, _t as toJsonSchemaDocument, aa as fail$2, ai as sync, an as make$22, ao as toMillis, ar as catchTags, as as isUndefined, at as isMaxProperties, b as Defect, ba as flatMap$1, bi as zipWith, bn as offer$1, bo as makeEquivalence$2, br as forkDetach$1, bt as withDecodingDefault, c as FalseValues, ca as pretty, ci as timeoutOption, cn as isSink, co as filter, cr as effectify, cs as constVoid, ct as isPattern, d as boolean$3, da as ConsoleRef, di as try_, dn as make$29, do as isArray, dr as fail$1, ds as pipe, dt as makeFilter, ea as void_$3, ei as services, en as suspend$3, eo as infinity, er as callback, es as symbol$1, et as isBetween, f as map$5, fa as CurrentLoggers$1, fi as uninterruptible, fn as get$3, fo as isReadonlyArrayNonEmpty, fr as failCause, fs as pipeArguments, ft as mutable, ga as asSome, gi as void_$1, gn as size, go as sort, gr as fnUntraced, gt as toCodecStringTree, h as string$3, ha as as$1, hi as useSpan, hn as set$3, ho as of, hr as fn, ht as tag, ia as done, ii as suspend, in as get$2, io as seconds, ir as catchTag, is as isNullish, it as isMaxLength, j as String$1, ja as scopeAddFinalizerExit, ji as provide$1, jo as isSome, jr as logInfo$1, jt as callback$1, k as Number$1, ka as onExit, ki as empty$6, kn as set$4, ko as getOrUndefined, kr as logDebug, kt as WatchBackend, l as TrueValues, la as squash, li as timeoutOrElse, ln as fromTransform, lo as flatMapNullishOr, lr as ensuring, ls as dual, lt as isSchemaError, m as port, ma as andThen$1, mi as updateServices$1, mn as remove$2, mo as map$3, mr as flatMap, mt as suspend$2, n as SqlClient, na as NoSuchElementError, ni as succeed, nn as transduce, no as isZero, nr as catchDefect, ns as isNotNull, nt as isGreaterThanOrEqualTo, oa as hasInterrupts, oi as tap, on as drain, oo as zero, or as catch_, os as constFalse, ot as isMinLength, p as option, pa as addFinalizer$2, pi as uninterruptibleMask$1, pn as make$24, po as makeEquivalence$1, pr as filterOrFail, pt as optional$2, q as decodeUnknownExit, qi as makeUnsafe$2, qn as all, qo as NodeInspectSymbol, qr as runPromise, qt as mkString, ra as UnknownError, ri as succeedNone$1, rn as unwrap, ro as minutes, rr as catchFilter, rs as isNotUndefined, rt as isLessThanOrEqualTo, s as Boolean$1, sa as hasInterruptsOnly, si as tapCause, sn as fromChannel, so as ensure, sr as die, ss as constTrue, st as isNonEmpty, ta as Done, ti as servicesWith$1, tn as toReadableStreamEffect, to as isFinite$1, tr as catchCause, ts as hasProperty, tt as isGreaterThan, u as all$1, ua as ClockRef, ui as tryPromise, un as mapDone, uo as fromIterable$2, ur as exit, us as identity, ut as link$1, v as Array$1, va as defaultLogger$1, vi as withParentSpan, vn as failCauseUnsafe, vo as map$6, vr as forever, vt as toType, w as Literals, wa as formatLabel, wi as Error$1, wn as take, wo as succeed$4, wr as ignore, wt as TypeId$17, x as ErrorClass, xa as fnUntraced$1, xi as catchDone, xn as offerAll, xo as fail$3, xr as forkIn, xt as assign, y as Boolean$2, ya as fiberInterrupt, yi as withSpan, yn as make$23, yo as filterMap, yr as forkChild, yt as withConstructorDefault, z as Unknown, za as updateServices, zi as make$28, zn as stringifyJson, zo as strictEqual, zr as orDie, zt as fromEffect } from "./SqlClient-B-Bb00hw.mjs";
|
|
5
4
|
import { createRequire } from "node:module";
|
|
6
5
|
import * as NodeChildProcess from "node:child_process";
|
|
7
6
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
@@ -34,7 +33,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
34
33
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
35
34
|
var __getProtoOf = Object.getPrototypeOf;
|
|
36
35
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
37
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
36
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
38
37
|
var __copyProps = (to, from, except, desc) => {
|
|
39
38
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
40
39
|
key = keys[i];
|
|
@@ -296,7 +295,7 @@ const makeHandle = (params) => Object.assign(Object.create(HandleProto), params)
|
|
|
296
295
|
* @category Models
|
|
297
296
|
*/
|
|
298
297
|
const make$19 = (spawn) => {
|
|
299
|
-
const streamString = (command, options) => spawn(command).pipe(map$
|
|
298
|
+
const streamString = (command, options) => spawn(command).pipe(map$2((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap);
|
|
300
299
|
const streamLines = (command, options) => splitLines(streamString(command, options));
|
|
301
300
|
return ChildProcessSpawner.of({
|
|
302
301
|
spawn,
|
|
@@ -316,16 +315,16 @@ const make$19 = (spawn) => {
|
|
|
316
315
|
var ChildProcessSpawner = class extends Service()("effect/process/ChildProcessSpawner") {};
|
|
317
316
|
//#endregion
|
|
318
317
|
//#region ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect-smol+effect@8881a9b/node_modules/effect/dist/unstable/process/ChildProcess.js
|
|
319
|
-
const TypeId$
|
|
320
|
-
const Proto$
|
|
318
|
+
const TypeId$16 = "~effect/unstable/process/ChildProcess";
|
|
319
|
+
const Proto$10 = {
|
|
321
320
|
...PipeInspectableProto,
|
|
322
321
|
...YieldableProto,
|
|
323
|
-
[TypeId$
|
|
322
|
+
[TypeId$16]: TypeId$16,
|
|
324
323
|
asEffect() {
|
|
325
324
|
return ChildProcessSpawner.use((_) => _.spawn(this));
|
|
326
325
|
}
|
|
327
326
|
};
|
|
328
|
-
const makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto$
|
|
327
|
+
const makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto$10), {
|
|
329
328
|
_tag: "StandardCommand",
|
|
330
329
|
command,
|
|
331
330
|
args,
|
|
@@ -874,7 +873,7 @@ const make$17 = /* @__PURE__ */ gen(function* () {
|
|
|
874
873
|
const stdin = yield* setupChildStdin(cmd, childProcess, stdinConfig);
|
|
875
874
|
const { all, stderr, stdout } = setupChildOutputStreams(cmd, childProcess, stdoutConfig, stderrConfig);
|
|
876
875
|
const { getInputFd, getOutputFd } = yield* setupAdditionalFds(cmd, childProcess, resolvedAdditionalFds);
|
|
877
|
-
const isRunning = map$
|
|
876
|
+
const isRunning = map$2(isDone(exitSignal), (done) => !done);
|
|
878
877
|
const exitCode = flatMap(_await(exitSignal), ([code, signal]) => {
|
|
879
878
|
if (isNotNull(code)) return succeed(ExitCode(code));
|
|
880
879
|
return fail$1(toPlatformError("exitCode", new globalThis.Error(`Process interrupted due to receipt of signal: '${signal}'`), cmd));
|
|
@@ -903,7 +902,7 @@ const make$17 = /* @__PURE__ */ gen(function* () {
|
|
|
903
902
|
const command = pipeline[i];
|
|
904
903
|
const options = pipeOptions[i] ?? {};
|
|
905
904
|
const stdinConfig = resolveStdinOption(command.options);
|
|
906
|
-
const sourceStream = unwrap(map$
|
|
905
|
+
const sourceStream = unwrap(map$2(handle, (h) => getSourceStream(h, options.from)));
|
|
907
906
|
const toOption = options.to ?? "stdin";
|
|
908
907
|
if (toOption === "stdin") handle = spawnCommand(make$18(command.command, command.args, {
|
|
909
908
|
...command.options,
|
|
@@ -1054,7 +1053,7 @@ const makeTempDirectoryScoped = /* @__PURE__ */ (() => {
|
|
|
1054
1053
|
const openFactory = (method) => {
|
|
1055
1054
|
const nodeOpen = effectify(NFS.open, handleErrnoException("FileSystem", method), handleBadArgument(method));
|
|
1056
1055
|
const nodeClose = effectify(NFS.close, handleErrnoException("FileSystem", method), handleBadArgument(method));
|
|
1057
|
-
return (path, options) => pipe(acquireRelease(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie(nodeClose(fd))), map$
|
|
1056
|
+
return (path, options) => pipe(acquireRelease(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie(nodeClose(fd))), map$2((fd) => makeFile(FileDescriptor(fd), options?.flag?.startsWith("a") ?? false)));
|
|
1058
1057
|
};
|
|
1059
1058
|
const open = /* @__PURE__ */ openFactory("open");
|
|
1060
1059
|
const makeFile = /* @__PURE__ */ (() => {
|
|
@@ -1078,7 +1077,7 @@ const makeFile = /* @__PURE__ */ (() => {
|
|
|
1078
1077
|
this.append = append;
|
|
1079
1078
|
}
|
|
1080
1079
|
get stat() {
|
|
1081
|
-
return map$
|
|
1080
|
+
return map$2(nodeStat(this.fd), makeFileInfo);
|
|
1082
1081
|
}
|
|
1083
1082
|
get sync() {
|
|
1084
1083
|
return nodeSync(this.fd);
|
|
@@ -1094,7 +1093,7 @@ const makeFile = /* @__PURE__ */ (() => {
|
|
|
1094
1093
|
read(buffer) {
|
|
1095
1094
|
return suspend(() => {
|
|
1096
1095
|
const position = this.position;
|
|
1097
|
-
return map$
|
|
1096
|
+
return map$2(nodeRead(this.fd, {
|
|
1098
1097
|
buffer,
|
|
1099
1098
|
position
|
|
1100
1099
|
}), (bytesRead) => {
|
|
@@ -1109,7 +1108,7 @@ const makeFile = /* @__PURE__ */ (() => {
|
|
|
1109
1108
|
return suspend(() => {
|
|
1110
1109
|
const buffer = Buffer.allocUnsafeSlow(sizeNumber);
|
|
1111
1110
|
const position = this.position;
|
|
1112
|
-
return map$
|
|
1111
|
+
return map$2(nodeReadAlloc(this.fd, {
|
|
1113
1112
|
buffer,
|
|
1114
1113
|
position
|
|
1115
1114
|
}), (bytesRead) => {
|
|
@@ -1123,7 +1122,7 @@ const makeFile = /* @__PURE__ */ (() => {
|
|
|
1123
1122
|
});
|
|
1124
1123
|
}
|
|
1125
1124
|
truncate(length) {
|
|
1126
|
-
return map$
|
|
1125
|
+
return map$2(nodeTruncate(this.fd, length ? Number(length) : void 0), () => {
|
|
1127
1126
|
if (!this.append) {
|
|
1128
1127
|
const len = BigInt(length ?? 0);
|
|
1129
1128
|
if (this.position > len) this.position = len;
|
|
@@ -1133,7 +1132,7 @@ const makeFile = /* @__PURE__ */ (() => {
|
|
|
1133
1132
|
write(buffer) {
|
|
1134
1133
|
return suspend(() => {
|
|
1135
1134
|
const position = this.position;
|
|
1136
|
-
return map$
|
|
1135
|
+
return map$2(nodeWrite(this.fd, buffer, void 0, void 0, this.append ? void 0 : Number(position)), (bytesWritten) => {
|
|
1137
1136
|
const sizeWritten = Size(bytesWritten);
|
|
1138
1137
|
if (!this.append) this.position = position + sizeWritten;
|
|
1139
1138
|
return sizeWritten;
|
|
@@ -1222,7 +1221,7 @@ const makeFileInfo = (stat) => ({
|
|
|
1222
1221
|
});
|
|
1223
1222
|
const stat$1 = /* @__PURE__ */ (() => {
|
|
1224
1223
|
const nodeStat = /* @__PURE__ */ effectify(NFS.stat, /* @__PURE__ */ handleErrnoException("FileSystem", "stat"), /* @__PURE__ */ handleBadArgument("stat"));
|
|
1225
|
-
return (path) => map$
|
|
1224
|
+
return (path) => map$2(nodeStat(path), makeFileInfo);
|
|
1226
1225
|
})();
|
|
1227
1226
|
const symlink = /* @__PURE__ */ (() => {
|
|
1228
1227
|
const nodeSymlink = /* @__PURE__ */ effectify(NFS.symlink, /* @__PURE__ */ handleErrnoException("FileSystem", "symlink"), /* @__PURE__ */ handleBadArgument("symlink"));
|
|
@@ -1274,7 +1273,7 @@ const watchNode = (path) => callback$1((queue) => acquireRelease(sync(() => {
|
|
|
1274
1273
|
});
|
|
1275
1274
|
return watcher;
|
|
1276
1275
|
}), (watcher) => sync(() => watcher.close())));
|
|
1277
|
-
const watch = (backend, path) => stat$1(path).pipe(map$
|
|
1276
|
+
const watch = (backend, path) => stat$1(path).pipe(map$2((stat) => {
|
|
1278
1277
|
if (backend) {
|
|
1279
1278
|
const stream = backend.register(path, stat);
|
|
1280
1279
|
if (stream) return stream;
|
|
@@ -1295,7 +1294,7 @@ const writeFile$1 = (path, data, options) => callback((resume, signal) => {
|
|
|
1295
1294
|
resume(fail$1(handleBadArgument("writeFile")(err)));
|
|
1296
1295
|
}
|
|
1297
1296
|
});
|
|
1298
|
-
const makeFileSystem = /* @__PURE__ */ map$
|
|
1297
|
+
const makeFileSystem = /* @__PURE__ */ map$2(/* @__PURE__ */ serviceOption(WatchBackend), (backend) => make$21({
|
|
1299
1298
|
access,
|
|
1300
1299
|
chmod,
|
|
1301
1300
|
chown,
|
|
@@ -1363,8 +1362,8 @@ const toFileUrl = (path) => try_({
|
|
|
1363
1362
|
* @since 1.0.0
|
|
1364
1363
|
* @category Layers
|
|
1365
1364
|
*/
|
|
1366
|
-
const layerPosix
|
|
1367
|
-
[TypeId$
|
|
1365
|
+
const layerPosix = /* @__PURE__ */ succeed$2(Path$1)({
|
|
1366
|
+
[TypeId$17]: TypeId$17,
|
|
1368
1367
|
...Path.posix,
|
|
1369
1368
|
fromFileUrl,
|
|
1370
1369
|
toFileUrl
|
|
@@ -1373,8 +1372,8 @@ const layerPosix$1 = /* @__PURE__ */ succeed$2(Path$1)({
|
|
|
1373
1372
|
* @since 1.0.0
|
|
1374
1373
|
* @category Layers
|
|
1375
1374
|
*/
|
|
1376
|
-
const layerWin32
|
|
1377
|
-
[TypeId$
|
|
1375
|
+
const layerWin32 = /* @__PURE__ */ succeed$2(Path$1)({
|
|
1376
|
+
[TypeId$17]: TypeId$17,
|
|
1378
1377
|
...Path.win32,
|
|
1379
1378
|
fromFileUrl,
|
|
1380
1379
|
toFileUrl
|
|
@@ -1384,7 +1383,7 @@ const layerWin32$1 = /* @__PURE__ */ succeed$2(Path$1)({
|
|
|
1384
1383
|
* @category Layers
|
|
1385
1384
|
*/
|
|
1386
1385
|
const layer$8 = /* @__PURE__ */ succeed$2(Path$1)({
|
|
1387
|
-
[TypeId$
|
|
1386
|
+
[TypeId$17]: TypeId$17,
|
|
1388
1387
|
...Path,
|
|
1389
1388
|
fromFileUrl,
|
|
1390
1389
|
toFileUrl
|
|
@@ -1399,34 +1398,24 @@ const layer$8 = /* @__PURE__ */ succeed$2(Path$1)({
|
|
|
1399
1398
|
* @category layer
|
|
1400
1399
|
*/
|
|
1401
1400
|
const layer$7 = layer$8;
|
|
1402
|
-
/**
|
|
1403
|
-
* @since 1.0.0
|
|
1404
|
-
* @category layer
|
|
1405
|
-
*/
|
|
1406
|
-
const layerPosix = layerPosix$1;
|
|
1407
|
-
/**
|
|
1408
|
-
* @since 1.0.0
|
|
1409
|
-
* @category layer
|
|
1410
|
-
*/
|
|
1411
|
-
const layerWin32 = layerWin32$1;
|
|
1412
1401
|
//#endregion
|
|
1413
1402
|
//#region ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect-smol+effect@8881a9b/node_modules/effect/dist/Stdio.js
|
|
1414
1403
|
/**
|
|
1415
1404
|
* @since 4.0.0
|
|
1416
1405
|
* @category Type IDs
|
|
1417
1406
|
*/
|
|
1418
|
-
const TypeId$
|
|
1407
|
+
const TypeId$15 = "~effect/Stdio";
|
|
1419
1408
|
/**
|
|
1420
1409
|
* @since 4.0.0
|
|
1421
1410
|
* @category Services
|
|
1422
1411
|
*/
|
|
1423
|
-
const Stdio = /* @__PURE__ */ Service(TypeId$
|
|
1412
|
+
const Stdio = /* @__PURE__ */ Service(TypeId$15);
|
|
1424
1413
|
/**
|
|
1425
1414
|
* @since 4.0.0
|
|
1426
1415
|
* @category Constructors
|
|
1427
1416
|
*/
|
|
1428
1417
|
const make$16 = (options) => ({
|
|
1429
|
-
[TypeId$
|
|
1418
|
+
[TypeId$15]: TypeId$15,
|
|
1430
1419
|
...options
|
|
1431
1420
|
});
|
|
1432
1421
|
//#endregion
|
|
@@ -1480,7 +1469,7 @@ const layer$6 = /* @__PURE__ */ succeed$2(Stdio, /* @__PURE__ */ make$16({
|
|
|
1480
1469
|
const layer$5 = layer$6;
|
|
1481
1470
|
//#endregion
|
|
1482
1471
|
//#region ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect-smol+effect@8881a9b/node_modules/effect/dist/Terminal.js
|
|
1483
|
-
const TypeId$
|
|
1472
|
+
const TypeId$14 = "~effect/platform/Terminal";
|
|
1484
1473
|
const QuitErrorTypeId = "effect/platform/Terminal/QuitError";
|
|
1485
1474
|
/**
|
|
1486
1475
|
* A `QuitError` represents an error that occurs when a user attempts to
|
|
@@ -1513,7 +1502,7 @@ const Terminal = /* @__PURE__ */ Service("effect/platform/Terminal");
|
|
|
1513
1502
|
*/
|
|
1514
1503
|
const make$15 = (impl) => Terminal.of({
|
|
1515
1504
|
...impl,
|
|
1516
|
-
[TypeId$
|
|
1505
|
+
[TypeId$14]: TypeId$14
|
|
1517
1506
|
});
|
|
1518
1507
|
//#endregion
|
|
1519
1508
|
//#region ../../node_modules/.bun/@effect+platform-node-shared@https+++pkg.pr.new+Effect-TS+effect-smol+@effect+platform-node-shared@8881a9b606d84a6f5eb6615279138322984f5368+eecd35a1726d7096/node_modules/@effect/platform-node-shared/dist/NodeTerminal.js
|
|
@@ -1538,7 +1527,7 @@ const make$14 = /* @__PURE__ */ fnUntraced(function* (shouldQuit = defaultShould
|
|
|
1538
1527
|
})) });
|
|
1539
1528
|
const columns = sync(() => stdout.columns ?? 0);
|
|
1540
1529
|
const readInput = gen(function* () {
|
|
1541
|
-
yield* get$
|
|
1530
|
+
yield* get$2(rlRef);
|
|
1542
1531
|
const queue = yield* make$23();
|
|
1543
1532
|
const handleKeypress = (s, k) => {
|
|
1544
1533
|
const userInput = {
|
|
@@ -1557,7 +1546,7 @@ const make$14 = /* @__PURE__ */ fnUntraced(function* (shouldQuit = defaultShould
|
|
|
1557
1546
|
stdin.on("keypress", handleKeypress);
|
|
1558
1547
|
return queue;
|
|
1559
1548
|
});
|
|
1560
|
-
const readLine = scoped(flatMap(get$
|
|
1549
|
+
const readLine = scoped(flatMap(get$2(rlRef), (readlineInterface) => callback((resume) => {
|
|
1561
1550
|
const onLine = (line) => resume(succeed(line));
|
|
1562
1551
|
readlineInterface.once("line", onLine);
|
|
1563
1552
|
return sync(() => readlineInterface.off("line", onLine));
|
|
@@ -1592,11 +1581,6 @@ function defaultShouldQuit(input) {
|
|
|
1592
1581
|
*/
|
|
1593
1582
|
/**
|
|
1594
1583
|
* @since 1.0.0
|
|
1595
|
-
* @category constructors
|
|
1596
|
-
*/
|
|
1597
|
-
const make$13 = make$14;
|
|
1598
|
-
/**
|
|
1599
|
-
* @since 1.0.0
|
|
1600
1584
|
* @category layers
|
|
1601
1585
|
*/
|
|
1602
1586
|
const layer$3 = layer$4;
|
|
@@ -1608,6 +1592,567 @@ const layer$3 = layer$4;
|
|
|
1608
1592
|
*/
|
|
1609
1593
|
const layer$2 = /* @__PURE__ */ provideMerge(layer$11, /* @__PURE__ */ mergeAll(layer$9, layer$7, layer$5, layer$3));
|
|
1610
1594
|
//#endregion
|
|
1595
|
+
//#region ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect-smol+effect@8881a9b/node_modules/effect/dist/Cache.js
|
|
1596
|
+
/**
|
|
1597
|
+
* @since 4.0.0
|
|
1598
|
+
*/
|
|
1599
|
+
const TypeId$13 = "~effect/Cache";
|
|
1600
|
+
/**
|
|
1601
|
+
* Creates a cache with dynamic time-to-live based on the result and key.
|
|
1602
|
+
*
|
|
1603
|
+
* The timeToLive function receives both the exit result and the key, allowing
|
|
1604
|
+
* for flexible TTL policies based on success/failure state and key characteristics.
|
|
1605
|
+
*
|
|
1606
|
+
* @example
|
|
1607
|
+
* ```ts
|
|
1608
|
+
* import { Cache, Effect, Exit } from "effect"
|
|
1609
|
+
*
|
|
1610
|
+
* // Cache with different TTL for success vs failure
|
|
1611
|
+
* const program = Effect.gen(function*() {
|
|
1612
|
+
* const cache = yield* Cache.makeWith<string, number, string>({
|
|
1613
|
+
* capacity: 100,
|
|
1614
|
+
* lookup: (key) =>
|
|
1615
|
+
* key === "fail"
|
|
1616
|
+
* ? Effect.fail("error")
|
|
1617
|
+
* : Effect.succeed(key.length),
|
|
1618
|
+
* timeToLive: (exit, key) => {
|
|
1619
|
+
* if (Exit.isFailure(exit)) return "1 minute" // Short TTL for errors
|
|
1620
|
+
* return key.startsWith("temp") ? "5 minutes" : "1 hour"
|
|
1621
|
+
* }
|
|
1622
|
+
* })
|
|
1623
|
+
*
|
|
1624
|
+
* // Get values with different TTL policies
|
|
1625
|
+
* const result1 = yield* Cache.get(cache, "hello")
|
|
1626
|
+
* const result2 = yield* Cache.get(cache, "temp_data")
|
|
1627
|
+
* console.log({ result1, result2 }) // { result1: 5, result2: 9 }
|
|
1628
|
+
* })
|
|
1629
|
+
* ```
|
|
1630
|
+
*
|
|
1631
|
+
* @example
|
|
1632
|
+
* ```ts
|
|
1633
|
+
* import { Cache, Effect, Exit } from "effect"
|
|
1634
|
+
*
|
|
1635
|
+
* // Cache with TTL based on computed value
|
|
1636
|
+
* const userCache = Effect.gen(function*() {
|
|
1637
|
+
* const cache = yield* Cache.makeWith<
|
|
1638
|
+
* number,
|
|
1639
|
+
* { id: number; active: boolean },
|
|
1640
|
+
* never
|
|
1641
|
+
* >({
|
|
1642
|
+
* capacity: 1000,
|
|
1643
|
+
* lookup: (id) => Effect.succeed({ id, active: id % 2 === 0 }),
|
|
1644
|
+
* timeToLive: (exit) => {
|
|
1645
|
+
* if (Exit.isSuccess(exit)) {
|
|
1646
|
+
* const user = exit.value
|
|
1647
|
+
* return user.active ? "1 hour" : "5 minutes"
|
|
1648
|
+
* }
|
|
1649
|
+
* return "30 seconds"
|
|
1650
|
+
* }
|
|
1651
|
+
* })
|
|
1652
|
+
*
|
|
1653
|
+
* return cache
|
|
1654
|
+
* })
|
|
1655
|
+
* ```
|
|
1656
|
+
*
|
|
1657
|
+
* @since 4.0.0
|
|
1658
|
+
* @category Constructors
|
|
1659
|
+
*/
|
|
1660
|
+
const makeWith$1 = (options) => servicesWith((services) => {
|
|
1661
|
+
const self = Object.create(Proto$9);
|
|
1662
|
+
self.lookup = (key) => updateServices(options.lookup(key), (input) => merge$2(services, input));
|
|
1663
|
+
self.map = make$24();
|
|
1664
|
+
self.capacity = options.capacity;
|
|
1665
|
+
self.timeToLive = options.timeToLive ? (exit, key) => fromInputUnsafe(options.timeToLive(exit, key)) : defaultTimeToLive;
|
|
1666
|
+
return succeed$3(self);
|
|
1667
|
+
});
|
|
1668
|
+
/**
|
|
1669
|
+
* Creates a cache with a fixed time-to-live for all entries.
|
|
1670
|
+
*
|
|
1671
|
+
* This is the basic cache constructor where all entries share the same TTL.
|
|
1672
|
+
* The lookup function will be called when a key is not found or has expired.
|
|
1673
|
+
*
|
|
1674
|
+
* @example
|
|
1675
|
+
* ```ts
|
|
1676
|
+
* import { Cache, Effect } from "effect"
|
|
1677
|
+
*
|
|
1678
|
+
* // Basic cache with string keys
|
|
1679
|
+
* const program = Effect.gen(function*() {
|
|
1680
|
+
* const cache = yield* Cache.make<string, number>({
|
|
1681
|
+
* capacity: 100,
|
|
1682
|
+
* lookup: (key) => Effect.succeed(key.length)
|
|
1683
|
+
* })
|
|
1684
|
+
*
|
|
1685
|
+
* const result1 = yield* Cache.get(cache, "hello")
|
|
1686
|
+
* const result2 = yield* Cache.get(cache, "world")
|
|
1687
|
+
* console.log({ result1, result2 }) // { result1: 5, result2: 5 }
|
|
1688
|
+
* })
|
|
1689
|
+
* ```
|
|
1690
|
+
*
|
|
1691
|
+
* @example
|
|
1692
|
+
* ```ts
|
|
1693
|
+
* import { Cache, Effect } from "effect"
|
|
1694
|
+
*
|
|
1695
|
+
* // Cache with TTL and async lookup
|
|
1696
|
+
* const fetchUserCache = Effect.gen(function*() {
|
|
1697
|
+
* const cache = yield* Cache.make<
|
|
1698
|
+
* number,
|
|
1699
|
+
* { name: string; email: string },
|
|
1700
|
+
* string
|
|
1701
|
+
* >({
|
|
1702
|
+
* capacity: 500,
|
|
1703
|
+
* lookup: (userId) =>
|
|
1704
|
+
* Effect.tryPromise({
|
|
1705
|
+
* try: () => fetch(`/api/users/${userId}`).then((r) => r.json()),
|
|
1706
|
+
* catch: () => "Failed to fetch user"
|
|
1707
|
+
* }),
|
|
1708
|
+
* timeToLive: "15 minutes"
|
|
1709
|
+
* })
|
|
1710
|
+
*
|
|
1711
|
+
* // First call fetches from API, second call returns cached result
|
|
1712
|
+
* const user1 = yield* Cache.get(cache, 123)
|
|
1713
|
+
* const user2 = yield* Cache.get(cache, 123) // From cache
|
|
1714
|
+
* return { user1, user2 }
|
|
1715
|
+
* })
|
|
1716
|
+
* ```
|
|
1717
|
+
*
|
|
1718
|
+
* @since 4.0.0
|
|
1719
|
+
* @category Constructors
|
|
1720
|
+
*/
|
|
1721
|
+
const make$13 = (options) => makeWith$1({
|
|
1722
|
+
...options,
|
|
1723
|
+
timeToLive: options.timeToLive ? () => options.timeToLive : defaultTimeToLive
|
|
1724
|
+
});
|
|
1725
|
+
const Proto$9 = {
|
|
1726
|
+
...PipeInspectableProto,
|
|
1727
|
+
[TypeId$13]: TypeId$13,
|
|
1728
|
+
toJSON() {
|
|
1729
|
+
return {
|
|
1730
|
+
_id: "Cache",
|
|
1731
|
+
capacity: this.capacity,
|
|
1732
|
+
map: this.map
|
|
1733
|
+
};
|
|
1734
|
+
}
|
|
1735
|
+
};
|
|
1736
|
+
const defaultTimeToLive = (_, _key) => infinity;
|
|
1737
|
+
/**
|
|
1738
|
+
* Retrieves the value associated with the specified key from the cache.
|
|
1739
|
+
*
|
|
1740
|
+
* If the key is not present or has expired, it will invoke the lookup function
|
|
1741
|
+
* to construct the value, store it in the cache, and return it.
|
|
1742
|
+
*
|
|
1743
|
+
* @example
|
|
1744
|
+
* ```ts
|
|
1745
|
+
* import { Cache, Effect } from "effect"
|
|
1746
|
+
*
|
|
1747
|
+
* const program = Effect.gen(function*() {
|
|
1748
|
+
* const cache = yield* Cache.make({
|
|
1749
|
+
* capacity: 10,
|
|
1750
|
+
* lookup: (key: string) => Effect.succeed(key.length)
|
|
1751
|
+
* })
|
|
1752
|
+
*
|
|
1753
|
+
* // Cache miss - triggers lookup function
|
|
1754
|
+
* const result1 = yield* Cache.get(cache, "hello")
|
|
1755
|
+
* console.log(result1) // 5
|
|
1756
|
+
*
|
|
1757
|
+
* // Cache hit - returns cached value without lookup
|
|
1758
|
+
* const result2 = yield* Cache.get(cache, "hello")
|
|
1759
|
+
* console.log(result2) // 5 (from cache)
|
|
1760
|
+
*
|
|
1761
|
+
* return { result1, result2 }
|
|
1762
|
+
* })
|
|
1763
|
+
* ```
|
|
1764
|
+
*
|
|
1765
|
+
* @example
|
|
1766
|
+
* ```ts
|
|
1767
|
+
* import { Cache, Effect } from "effect"
|
|
1768
|
+
*
|
|
1769
|
+
* // Error handling when lookup fails
|
|
1770
|
+
* const program = Effect.gen(function*() {
|
|
1771
|
+
* const cache = yield* Cache.make<string, number, string>({
|
|
1772
|
+
* capacity: 10,
|
|
1773
|
+
* lookup: (key: string) =>
|
|
1774
|
+
* key === "error"
|
|
1775
|
+
* ? Effect.fail("Lookup failed")
|
|
1776
|
+
* : Effect.succeed(key.length)
|
|
1777
|
+
* })
|
|
1778
|
+
*
|
|
1779
|
+
* // Successful lookup
|
|
1780
|
+
* const success = yield* Cache.get(cache, "hello")
|
|
1781
|
+
* console.log(success) // 5
|
|
1782
|
+
*
|
|
1783
|
+
* // Failed lookup - returns error
|
|
1784
|
+
* const failure = yield* Effect.exit(Cache.get(cache, "error"))
|
|
1785
|
+
* console.log(failure) // Exit.fail("Lookup failed")
|
|
1786
|
+
* })
|
|
1787
|
+
* ```
|
|
1788
|
+
*
|
|
1789
|
+
* @example
|
|
1790
|
+
* ```ts
|
|
1791
|
+
* import { Cache, Effect } from "effect"
|
|
1792
|
+
*
|
|
1793
|
+
* // Concurrent access - multiple gets of same key only invoke lookup once
|
|
1794
|
+
* const program = Effect.gen(function*() {
|
|
1795
|
+
* let lookupCount = 0
|
|
1796
|
+
* const cache = yield* Cache.make({
|
|
1797
|
+
* capacity: 10,
|
|
1798
|
+
* lookup: (key: string) =>
|
|
1799
|
+
* Effect.sync(() => {
|
|
1800
|
+
* lookupCount++
|
|
1801
|
+
* return key.length
|
|
1802
|
+
* })
|
|
1803
|
+
* })
|
|
1804
|
+
*
|
|
1805
|
+
* // Multiple concurrent gets
|
|
1806
|
+
* const results = yield* Effect.all([
|
|
1807
|
+
* Cache.get(cache, "hello"),
|
|
1808
|
+
* Cache.get(cache, "hello"),
|
|
1809
|
+
* Cache.get(cache, "hello")
|
|
1810
|
+
* ], { concurrency: "unbounded" })
|
|
1811
|
+
*
|
|
1812
|
+
* console.log(results) // [5, 5, 5]
|
|
1813
|
+
* console.log(lookupCount) // 1 (lookup called only once)
|
|
1814
|
+
* })
|
|
1815
|
+
* ```
|
|
1816
|
+
*
|
|
1817
|
+
* @since 4.0.0
|
|
1818
|
+
* @category Combinators
|
|
1819
|
+
*/
|
|
1820
|
+
const get$1 = /* @__PURE__ */ dual(2, (self, key) => withFiber((fiber) => {
|
|
1821
|
+
const oentry = get$3(self.map, key);
|
|
1822
|
+
if (isSome(oentry) && !hasExpired(oentry.value, fiber)) {
|
|
1823
|
+
remove$2(self.map, key);
|
|
1824
|
+
set$3(self.map, key, oentry.value);
|
|
1825
|
+
return _await(oentry.value.deferred);
|
|
1826
|
+
}
|
|
1827
|
+
const deferred = makeUnsafe$2();
|
|
1828
|
+
const entry = {
|
|
1829
|
+
expiresAt: void 0,
|
|
1830
|
+
deferred
|
|
1831
|
+
};
|
|
1832
|
+
set$3(self.map, key, entry);
|
|
1833
|
+
if (Number.isFinite(self.capacity)) checkCapacity(self);
|
|
1834
|
+
return onExit(self.lookup(key), (exit) => {
|
|
1835
|
+
doneUnsafe(deferred, exit);
|
|
1836
|
+
const ttl = self.timeToLive(exit, key);
|
|
1837
|
+
if (isFinite$1(ttl)) entry.expiresAt = fiber.getRef(ClockRef).currentTimeMillisUnsafe() + toMillis(ttl);
|
|
1838
|
+
else if (isZero(ttl)) remove$2(self.map, key);
|
|
1839
|
+
return void_$2;
|
|
1840
|
+
});
|
|
1841
|
+
}));
|
|
1842
|
+
const hasExpired = (entry, fiber) => {
|
|
1843
|
+
if (entry.expiresAt === void 0) return false;
|
|
1844
|
+
return fiber.getRef(ClockRef).currentTimeMillisUnsafe() >= entry.expiresAt;
|
|
1845
|
+
};
|
|
1846
|
+
const checkCapacity = (self) => {
|
|
1847
|
+
let diff = size(self.map) - self.capacity;
|
|
1848
|
+
if (diff <= 0) return;
|
|
1849
|
+
for (const [key] of self.map) {
|
|
1850
|
+
remove$2(self.map, key);
|
|
1851
|
+
diff--;
|
|
1852
|
+
if (diff === 0) return;
|
|
1853
|
+
}
|
|
1854
|
+
};
|
|
1855
|
+
/**
|
|
1856
|
+
* Retrieves the value associated with the specified key from the cache,
|
|
1857
|
+
* returning an `Option` that is `Some` if the key exists and has not expired,
|
|
1858
|
+
* or `None` if the key does not exist or has expired.
|
|
1859
|
+
*
|
|
1860
|
+
* Unlike `get`, this function will not invoke the lookup function if the key
|
|
1861
|
+
* is missing or expired.
|
|
1862
|
+
*
|
|
1863
|
+
* @example
|
|
1864
|
+
* ```ts
|
|
1865
|
+
* import { Cache, Effect } from "effect"
|
|
1866
|
+
*
|
|
1867
|
+
* const program = Effect.gen(function*() {
|
|
1868
|
+
* const cache = yield* Cache.make({
|
|
1869
|
+
* capacity: 10,
|
|
1870
|
+
* lookup: (key: string) => Effect.succeed(key.length)
|
|
1871
|
+
* })
|
|
1872
|
+
*
|
|
1873
|
+
* // No value in cache yet - returns None without lookup
|
|
1874
|
+
* const empty = yield* Cache.getOption(cache, "hello")
|
|
1875
|
+
* console.log(empty) // Option.none()
|
|
1876
|
+
*
|
|
1877
|
+
* // Populate cache using get
|
|
1878
|
+
* yield* Cache.get(cache, "hello")
|
|
1879
|
+
*
|
|
1880
|
+
* // Now getOption returns the cached value
|
|
1881
|
+
* const cached = yield* Cache.getOption(cache, "hello")
|
|
1882
|
+
* console.log(cached) // Option.some(5)
|
|
1883
|
+
*
|
|
1884
|
+
* return { empty, cached }
|
|
1885
|
+
* })
|
|
1886
|
+
* ```
|
|
1887
|
+
*
|
|
1888
|
+
* @example
|
|
1889
|
+
* ```ts
|
|
1890
|
+
* import { Cache, Effect } from "effect"
|
|
1891
|
+
* import { TestClock } from "effect/testing"
|
|
1892
|
+
*
|
|
1893
|
+
* // Expired entries return None
|
|
1894
|
+
* const program = Effect.gen(function*() {
|
|
1895
|
+
* const cache = yield* Cache.make({
|
|
1896
|
+
* capacity: 10,
|
|
1897
|
+
* lookup: (key: string) => Effect.succeed(key.length),
|
|
1898
|
+
* timeToLive: "1 hour"
|
|
1899
|
+
* })
|
|
1900
|
+
*
|
|
1901
|
+
* // Add value to cache
|
|
1902
|
+
* yield* Cache.get(cache, "hello")
|
|
1903
|
+
*
|
|
1904
|
+
* // Value exists before expiration
|
|
1905
|
+
* const beforeExpiry = yield* Cache.getOption(cache, "hello")
|
|
1906
|
+
* console.log(beforeExpiry) // Option.some(5)
|
|
1907
|
+
*
|
|
1908
|
+
* // Simulate time passing
|
|
1909
|
+
* yield* TestClock.adjust("2 hours")
|
|
1910
|
+
*
|
|
1911
|
+
* // Value expired - returns None
|
|
1912
|
+
* const afterExpiry = yield* Cache.getOption(cache, "hello")
|
|
1913
|
+
* console.log(afterExpiry) // Option.none()
|
|
1914
|
+
* })
|
|
1915
|
+
* ```
|
|
1916
|
+
*
|
|
1917
|
+
* @example
|
|
1918
|
+
* ```ts
|
|
1919
|
+
* import { Cache, Deferred, Effect, Fiber } from "effect"
|
|
1920
|
+
*
|
|
1921
|
+
* // Waits for ongoing computation to complete
|
|
1922
|
+
* const program = Effect.gen(function*() {
|
|
1923
|
+
* const deferred = yield* Deferred.make<void>()
|
|
1924
|
+
* const cache = yield* Cache.make({
|
|
1925
|
+
* capacity: 10,
|
|
1926
|
+
* lookup: (_key: string) => Deferred.await(deferred).pipe(Effect.as(42))
|
|
1927
|
+
* })
|
|
1928
|
+
*
|
|
1929
|
+
* // Start lookup in background
|
|
1930
|
+
* const getFiber = yield* Effect.forkChild(Cache.get(cache, "key"))
|
|
1931
|
+
*
|
|
1932
|
+
* // getOption waits for ongoing computation
|
|
1933
|
+
* const optionFiber = yield* Effect.forkChild(Cache.getOption(cache, "key"))
|
|
1934
|
+
*
|
|
1935
|
+
* // Complete the computation
|
|
1936
|
+
* yield* Deferred.succeed(deferred, void 0)
|
|
1937
|
+
*
|
|
1938
|
+
* const result = yield* Fiber.join(optionFiber)
|
|
1939
|
+
* console.log(result) // Option.some(42)
|
|
1940
|
+
* })
|
|
1941
|
+
* ```
|
|
1942
|
+
*
|
|
1943
|
+
* @since 4.0.0
|
|
1944
|
+
* @category Combinators
|
|
1945
|
+
*/
|
|
1946
|
+
const getOption = /* @__PURE__ */ dual(2, (self, key) => withFiber((fiber) => {
|
|
1947
|
+
const entry = getImpl(self, key, fiber);
|
|
1948
|
+
return entry ? asSome(_await(entry.deferred)) : succeedNone;
|
|
1949
|
+
}));
|
|
1950
|
+
const getImpl = (self, key, fiber, isRead = true) => {
|
|
1951
|
+
const oentry = get$3(self.map, key);
|
|
1952
|
+
if (isNone(oentry)) return;
|
|
1953
|
+
else if (hasExpired(oentry.value, fiber)) {
|
|
1954
|
+
remove$2(self.map, key);
|
|
1955
|
+
return;
|
|
1956
|
+
} else if (isRead) {
|
|
1957
|
+
remove$2(self.map, key);
|
|
1958
|
+
set$3(self.map, key, oentry.value);
|
|
1959
|
+
}
|
|
1960
|
+
return oentry.value;
|
|
1961
|
+
};
|
|
1962
|
+
/**
|
|
1963
|
+
* Sets the value associated with the specified key in the cache. This will
|
|
1964
|
+
* overwrite any existing value for that key, skipping the lookup function.
|
|
1965
|
+
*
|
|
1966
|
+
* @example
|
|
1967
|
+
* ```ts
|
|
1968
|
+
* import { Cache, Effect } from "effect"
|
|
1969
|
+
*
|
|
1970
|
+
* const program = Effect.gen(function*() {
|
|
1971
|
+
* const cache = yield* Cache.make({
|
|
1972
|
+
* capacity: 100,
|
|
1973
|
+
* lookup: (key: string) => Effect.succeed(key.length)
|
|
1974
|
+
* })
|
|
1975
|
+
*
|
|
1976
|
+
* // Set a value directly without invoking lookup
|
|
1977
|
+
* yield* Cache.set(cache, "hello", 42)
|
|
1978
|
+
* const result = yield* Cache.get(cache, "hello")
|
|
1979
|
+
* console.log(result) // 42 (not 5 from lookup)
|
|
1980
|
+
* })
|
|
1981
|
+
* ```
|
|
1982
|
+
*
|
|
1983
|
+
* @example
|
|
1984
|
+
* ```ts
|
|
1985
|
+
* import { Cache, Effect } from "effect"
|
|
1986
|
+
*
|
|
1987
|
+
* // Overwriting existing cached values
|
|
1988
|
+
* const program = Effect.gen(function*() {
|
|
1989
|
+
* const cache = yield* Cache.make({
|
|
1990
|
+
* capacity: 100,
|
|
1991
|
+
* lookup: (key: string) => Effect.succeed(key.length)
|
|
1992
|
+
* })
|
|
1993
|
+
*
|
|
1994
|
+
* // First get populates via lookup
|
|
1995
|
+
* const original = yield* Cache.get(cache, "test") // 4
|
|
1996
|
+
*
|
|
1997
|
+
* // Set overwrites the cached value
|
|
1998
|
+
* yield* Cache.set(cache, "test", 999)
|
|
1999
|
+
* const updated = yield* Cache.get(cache, "test") // 999
|
|
2000
|
+
*
|
|
2001
|
+
* console.log({ original, updated })
|
|
2002
|
+
* })
|
|
2003
|
+
* ```
|
|
2004
|
+
*
|
|
2005
|
+
* @example
|
|
2006
|
+
* ```ts
|
|
2007
|
+
* import { Cache, Effect } from "effect"
|
|
2008
|
+
* import { TestClock } from "effect/testing"
|
|
2009
|
+
*
|
|
2010
|
+
* // TTL behavior with set operations
|
|
2011
|
+
* const program = Effect.gen(function*() {
|
|
2012
|
+
* const cache = yield* Cache.make({
|
|
2013
|
+
* capacity: 100,
|
|
2014
|
+
* lookup: (key: string) => Effect.succeed(key.length),
|
|
2015
|
+
* timeToLive: "1 hour"
|
|
2016
|
+
* })
|
|
2017
|
+
*
|
|
2018
|
+
* // Set value with TTL applied
|
|
2019
|
+
* yield* Cache.set(cache, "temporary", 123)
|
|
2020
|
+
* console.log(yield* Cache.has(cache, "temporary")) // true
|
|
2021
|
+
*
|
|
2022
|
+
* // Advance time past TTL
|
|
2023
|
+
* yield* TestClock.adjust("2 hours")
|
|
2024
|
+
* console.log(yield* Cache.has(cache, "temporary")) // false
|
|
2025
|
+
* })
|
|
2026
|
+
* ```
|
|
2027
|
+
*
|
|
2028
|
+
* @example
|
|
2029
|
+
* ```ts
|
|
2030
|
+
* import { Cache, Effect } from "effect"
|
|
2031
|
+
*
|
|
2032
|
+
* // Capacity enforcement with set operations
|
|
2033
|
+
* const program = Effect.gen(function*() {
|
|
2034
|
+
* const cache = yield* Cache.make({
|
|
2035
|
+
* capacity: 2,
|
|
2036
|
+
* lookup: (key: string) => Effect.succeed(key.length)
|
|
2037
|
+
* })
|
|
2038
|
+
*
|
|
2039
|
+
* // Fill cache to capacity
|
|
2040
|
+
* yield* Cache.set(cache, "a", 1)
|
|
2041
|
+
* yield* Cache.set(cache, "b", 2)
|
|
2042
|
+
* console.log(yield* Cache.size(cache)) // 2
|
|
2043
|
+
*
|
|
2044
|
+
* // Adding another entry evicts oldest
|
|
2045
|
+
* yield* Cache.set(cache, "c", 3)
|
|
2046
|
+
* console.log(yield* Cache.size(cache)) // 2
|
|
2047
|
+
* console.log(yield* Cache.has(cache, "a")) // false (evicted)
|
|
2048
|
+
* console.log(yield* Cache.has(cache, "c")) // true
|
|
2049
|
+
* })
|
|
2050
|
+
* ```
|
|
2051
|
+
*
|
|
2052
|
+
* @since 4.0.0
|
|
2053
|
+
* @category Combinators
|
|
2054
|
+
*/
|
|
2055
|
+
const set$2 = /* @__PURE__ */ dual(3, (self, key, value) => withFiber((fiber) => {
|
|
2056
|
+
const exit = exitSucceed(value);
|
|
2057
|
+
const deferred = makeUnsafe$2();
|
|
2058
|
+
doneUnsafe(deferred, exit);
|
|
2059
|
+
const ttl = self.timeToLive(exit, key);
|
|
2060
|
+
if (isZero(ttl)) {
|
|
2061
|
+
remove$2(self.map, key);
|
|
2062
|
+
return void_$2;
|
|
2063
|
+
}
|
|
2064
|
+
set$3(self.map, key, {
|
|
2065
|
+
deferred,
|
|
2066
|
+
expiresAt: isFinite$1(ttl) ? fiber.getRef(ClockRef).currentTimeMillisUnsafe() + toMillis(ttl) : void 0
|
|
2067
|
+
});
|
|
2068
|
+
checkCapacity(self);
|
|
2069
|
+
return void_$2;
|
|
2070
|
+
}));
|
|
2071
|
+
/**
|
|
2072
|
+
* Invalidates the entry associated with the specified key in the cache.
|
|
2073
|
+
*
|
|
2074
|
+
* @example
|
|
2075
|
+
* ```ts
|
|
2076
|
+
* import { Cache, Effect } from "effect"
|
|
2077
|
+
*
|
|
2078
|
+
* const program = Effect.gen(function*() {
|
|
2079
|
+
* const cache = yield* Cache.make({
|
|
2080
|
+
* capacity: 10,
|
|
2081
|
+
* lookup: (key: string) => Effect.succeed(key.length)
|
|
2082
|
+
* })
|
|
2083
|
+
*
|
|
2084
|
+
* // Add a value to the cache
|
|
2085
|
+
* yield* Cache.get(cache, "hello")
|
|
2086
|
+
* console.log(yield* Cache.has(cache, "hello")) // true
|
|
2087
|
+
*
|
|
2088
|
+
* // Invalidate the entry
|
|
2089
|
+
* yield* Cache.invalidate(cache, "hello")
|
|
2090
|
+
* console.log(yield* Cache.has(cache, "hello")) // false
|
|
2091
|
+
*
|
|
2092
|
+
* // Invalidating non-existent keys doesn't error
|
|
2093
|
+
* yield* Cache.invalidate(cache, "nonexistent")
|
|
2094
|
+
*
|
|
2095
|
+
* // Get after invalidation will invoke lookup again
|
|
2096
|
+
* let lookupCount = 0
|
|
2097
|
+
* const cache2 = yield* Cache.make({
|
|
2098
|
+
* capacity: 10,
|
|
2099
|
+
* lookup: (key: string) =>
|
|
2100
|
+
* Effect.sync(() => {
|
|
2101
|
+
* lookupCount++
|
|
2102
|
+
* return key.length
|
|
2103
|
+
* })
|
|
2104
|
+
* })
|
|
2105
|
+
*
|
|
2106
|
+
* yield* Cache.get(cache2, "test") // lookupCount = 1
|
|
2107
|
+
* yield* Cache.invalidate(cache2, "test")
|
|
2108
|
+
* yield* Cache.get(cache2, "test") // lookupCount = 2 (lookup called again)
|
|
2109
|
+
* })
|
|
2110
|
+
* ```
|
|
2111
|
+
*
|
|
2112
|
+
* @since 4.0.0
|
|
2113
|
+
* @category Combinators
|
|
2114
|
+
*/
|
|
2115
|
+
const invalidate = /* @__PURE__ */ dual(2, (self, key) => sync$1(() => {
|
|
2116
|
+
remove$2(self.map, key);
|
|
2117
|
+
}));
|
|
2118
|
+
/**
|
|
2119
|
+
* Retrieves all active keys from the cache, automatically filtering out expired entries.
|
|
2120
|
+
*
|
|
2121
|
+
* @example
|
|
2122
|
+
* ```ts
|
|
2123
|
+
* import { Cache, Effect } from "effect"
|
|
2124
|
+
*
|
|
2125
|
+
* // Basic key enumeration
|
|
2126
|
+
* const program = Effect.gen(function*() {
|
|
2127
|
+
* const cache = yield* Cache.make({
|
|
2128
|
+
* capacity: 10,
|
|
2129
|
+
* lookup: (key: string) => Effect.succeed(key.length)
|
|
2130
|
+
* })
|
|
2131
|
+
*
|
|
2132
|
+
* // Add some entries to the cache
|
|
2133
|
+
* yield* Cache.get(cache, "hello")
|
|
2134
|
+
* yield* Cache.get(cache, "world")
|
|
2135
|
+
* yield* Cache.get(cache, "cache")
|
|
2136
|
+
*
|
|
2137
|
+
* // Retrieve all active keys
|
|
2138
|
+
* const keys = yield* Cache.keys(cache)
|
|
2139
|
+
*
|
|
2140
|
+
* console.log(Array.from(keys)) // ["hello", "world", "cache"]
|
|
2141
|
+
* })
|
|
2142
|
+
* ```
|
|
2143
|
+
*
|
|
2144
|
+
* @since 4.0.0
|
|
2145
|
+
* @category Combinators
|
|
2146
|
+
*/
|
|
2147
|
+
const keys = (self) => withFiber((fiber) => {
|
|
2148
|
+
const now = fiber.getRef(ClockRef).currentTimeMillisUnsafe();
|
|
2149
|
+
return succeed$3(filterMap(self.map, ([key, entry]) => {
|
|
2150
|
+
if (entry.expiresAt === void 0 || entry.expiresAt > now) return succeed$4(key);
|
|
2151
|
+
remove$2(self.map, key);
|
|
2152
|
+
return failVoid;
|
|
2153
|
+
}));
|
|
2154
|
+
});
|
|
2155
|
+
//#endregion
|
|
1611
2156
|
//#region ../../node_modules/.bun/effect@https+++pkg.pr.new+Effect-TS+effect-smol+effect@8881a9b/node_modules/effect/dist/Console.js
|
|
1612
2157
|
/**
|
|
1613
2158
|
* A reference to the current console service in the Effect system.
|
|
@@ -1848,45 +2393,6 @@ const isLogger = (u) => hasProperty(u, TypeId$12);
|
|
|
1848
2393
|
*/
|
|
1849
2394
|
const CurrentLoggers = CurrentLoggers$1;
|
|
1850
2395
|
/**
|
|
1851
|
-
* @since 4.0.0
|
|
1852
|
-
* @category references
|
|
1853
|
-
*/
|
|
1854
|
-
const LogToStderr = LogToStderr$1;
|
|
1855
|
-
/**
|
|
1856
|
-
* Transforms the output of a `Logger` using the provided function.
|
|
1857
|
-
*
|
|
1858
|
-
* This allows you to modify, enhance, or completely change the output format
|
|
1859
|
-
* of an existing logger without recreating the entire logging logic.
|
|
1860
|
-
*
|
|
1861
|
-
* @example
|
|
1862
|
-
* ```ts
|
|
1863
|
-
* import { Logger } from "effect"
|
|
1864
|
-
*
|
|
1865
|
-
* // Create a logger that outputs objects
|
|
1866
|
-
* const structuredLogger = Logger.make((options) => ({
|
|
1867
|
-
* level: options.logLevel,
|
|
1868
|
-
* message: options.message,
|
|
1869
|
-
* timestamp: options.date.toISOString()
|
|
1870
|
-
* }))
|
|
1871
|
-
*
|
|
1872
|
-
* // Transform the output to JSON strings
|
|
1873
|
-
* const jsonStringLogger = Logger.map(
|
|
1874
|
-
* structuredLogger,
|
|
1875
|
-
* (output) => JSON.stringify(output)
|
|
1876
|
-
* )
|
|
1877
|
-
*
|
|
1878
|
-
* // Transform to uppercase messages
|
|
1879
|
-
* const uppercaseLogger = Logger.map(
|
|
1880
|
-
* structuredLogger,
|
|
1881
|
-
* (output) => ({ ...output, message: String(output.message).toUpperCase() })
|
|
1882
|
-
* )
|
|
1883
|
-
* ```
|
|
1884
|
-
*
|
|
1885
|
-
* @since 2.0.0
|
|
1886
|
-
* @category utils
|
|
1887
|
-
*/
|
|
1888
|
-
const map$2 = /* @__PURE__ */ dual(2, (self, f) => loggerMake((options) => f(self.log(options))));
|
|
1889
|
-
/**
|
|
1890
2396
|
* Match strings that do not contain any whitespace characters, double quotes,
|
|
1891
2397
|
* or equal signs.
|
|
1892
2398
|
*/
|
|
@@ -2027,114 +2533,6 @@ const defaultLogger = defaultLogger$1;
|
|
|
2027
2533
|
*/
|
|
2028
2534
|
const formatSimple = /* @__PURE__ */ loggerMake(/* @__PURE__ */ format(escapeDoubleQuotes));
|
|
2029
2535
|
/**
|
|
2030
|
-
* A `Logger` which outputs logs using a structured format.
|
|
2031
|
-
*
|
|
2032
|
-
* For example:
|
|
2033
|
-
* ```
|
|
2034
|
-
* {
|
|
2035
|
-
* message: [ 'hello' ],
|
|
2036
|
-
* level: 'INFO',
|
|
2037
|
-
* timestamp: '2025-01-03T14:25:39.666Z',
|
|
2038
|
-
* annotations: { key: 'value' },
|
|
2039
|
-
* spans: { label: 0 },
|
|
2040
|
-
* fiberId: '#1'
|
|
2041
|
-
* }
|
|
2042
|
-
* ```
|
|
2043
|
-
*
|
|
2044
|
-
* @example
|
|
2045
|
-
* ```ts
|
|
2046
|
-
* import { Effect, Logger } from "effect"
|
|
2047
|
-
*
|
|
2048
|
-
* // Use the structured format logger
|
|
2049
|
-
* const structuredLoggerProgram = Effect.log("Hello Structured Format").pipe(
|
|
2050
|
-
* Effect.provide(Logger.layer([Logger.formatStructured]))
|
|
2051
|
-
* )
|
|
2052
|
-
*
|
|
2053
|
-
* // Perfect for JSON processing and analytics
|
|
2054
|
-
* const analyticsProgram = Effect.gen(function*() {
|
|
2055
|
-
* yield* Effect.log("User action", { action: "click", element: "button" })
|
|
2056
|
-
* yield* Effect.logInfo("API call", { endpoint: "/users", duration: 150 })
|
|
2057
|
-
* }).pipe(
|
|
2058
|
-
* Effect.annotateLogs("sessionId", "abc123"),
|
|
2059
|
-
* Effect.withLogSpan("request"),
|
|
2060
|
-
* Effect.provide(Logger.layer([Logger.formatStructured]))
|
|
2061
|
-
* )
|
|
2062
|
-
*
|
|
2063
|
-
* // Process structured output
|
|
2064
|
-
* const processingLogger = Logger.map(Logger.formatStructured, (output) => {
|
|
2065
|
-
* // Process the structured object
|
|
2066
|
-
* const enhanced = { ...output, processed: true }
|
|
2067
|
-
* return enhanced
|
|
2068
|
-
* })
|
|
2069
|
-
* ```
|
|
2070
|
-
*
|
|
2071
|
-
* @since 4.0.0
|
|
2072
|
-
* @category constructors
|
|
2073
|
-
*/
|
|
2074
|
-
const formatStructured = /* @__PURE__ */ loggerMake(({ cause, date, fiber, logLevel, message }) => {
|
|
2075
|
-
const annotationsObj = {};
|
|
2076
|
-
const spansObj = {};
|
|
2077
|
-
const annotations = fiber.getRef(CurrentLogAnnotations);
|
|
2078
|
-
for (const [key, value] of Object.entries(annotations)) annotationsObj[key] = structuredMessage(value);
|
|
2079
|
-
const now = date.getTime();
|
|
2080
|
-
const spans = fiber.getRef(CurrentLogSpans);
|
|
2081
|
-
for (const [label, timestamp] of spans) spansObj[label] = now - timestamp;
|
|
2082
|
-
const messageArr = ensure(message);
|
|
2083
|
-
return {
|
|
2084
|
-
message: messageArr.length === 1 ? structuredMessage(messageArr[0]) : messageArr.map(structuredMessage),
|
|
2085
|
-
level: logLevel.toUpperCase(),
|
|
2086
|
-
timestamp: date.toISOString(),
|
|
2087
|
-
cause: cause.reasons.length > 0 ? causePretty(cause) : void 0,
|
|
2088
|
-
annotations: annotationsObj,
|
|
2089
|
-
spans: spansObj,
|
|
2090
|
-
fiberId: formatFiberId(fiber.id)
|
|
2091
|
-
};
|
|
2092
|
-
});
|
|
2093
|
-
/**
|
|
2094
|
-
* A `Logger` which outputs logs using a structured format serialized as JSON
|
|
2095
|
-
* on a single line.
|
|
2096
|
-
*
|
|
2097
|
-
* For example:
|
|
2098
|
-
* ```
|
|
2099
|
-
* {"message":["hello"],"level":"INFO","timestamp":"2025-01-03T14:28:57.508Z","annotations":{"key":"value"},"spans":{"label":0},"fiberId":"#1"}
|
|
2100
|
-
* ```
|
|
2101
|
-
*
|
|
2102
|
-
* @example
|
|
2103
|
-
* ```ts
|
|
2104
|
-
* import { Effect, Logger } from "effect"
|
|
2105
|
-
*
|
|
2106
|
-
* // Use the JSON format logger
|
|
2107
|
-
* const jsonLoggerProgram = Effect.log("Hello JSON Format").pipe(
|
|
2108
|
-
* Effect.provide(Logger.layer([Logger.formatJson]))
|
|
2109
|
-
* )
|
|
2110
|
-
*
|
|
2111
|
-
* // Perfect for log aggregation and processing systems
|
|
2112
|
-
* const productionProgram = Effect.gen(function*() {
|
|
2113
|
-
* yield* Effect.log("Server started", { port: 3000, env: "production" })
|
|
2114
|
-
* yield* Effect.logInfo("Request received", {
|
|
2115
|
-
* method: "GET",
|
|
2116
|
-
* path: "/api/users"
|
|
2117
|
-
* })
|
|
2118
|
-
* yield* Effect.logError("Database error", { error: "Connection timeout" })
|
|
2119
|
-
* }).pipe(
|
|
2120
|
-
* Effect.annotateLogs("service", "api-server"),
|
|
2121
|
-
* Effect.withLogSpan("request-processing"),
|
|
2122
|
-
* Effect.provide(Logger.layer([Logger.formatJson]))
|
|
2123
|
-
* )
|
|
2124
|
-
*
|
|
2125
|
-
* // Send to external logging service
|
|
2126
|
-
* const externalLogger = Logger.map(Logger.formatJson, (jsonString) => {
|
|
2127
|
-
* // Send to Elasticsearch, CloudWatch, etc.
|
|
2128
|
-
* console.log("Sending to external service:", jsonString)
|
|
2129
|
-
* return jsonString
|
|
2130
|
-
* })
|
|
2131
|
-
* ```
|
|
2132
|
-
*
|
|
2133
|
-
* @since 4.0.0
|
|
2134
|
-
* @category constructors
|
|
2135
|
-
*/
|
|
2136
|
-
const formatJson = /* @__PURE__ */ map$2(formatStructured, formatJson$1);
|
|
2137
|
-
/**
|
|
2138
2536
|
* Returns a new `Logger` which will aggregate logs output by the specified
|
|
2139
2537
|
* `Logger` over the provided `window`. After the `window` has elapsed, the
|
|
2140
2538
|
* provided `flush` function will be called with the logs aggregated during
|
|
@@ -2199,104 +2597,6 @@ const batched = /* @__PURE__ */ dual(2, (self, options) => flatMap$1(scope, (sco
|
|
|
2199
2597
|
}))));
|
|
2200
2598
|
}));
|
|
2201
2599
|
/**
|
|
2202
|
-
* A `Logger` which outputs logs in a "pretty" format and writes them to the
|
|
2203
|
-
* console.
|
|
2204
|
-
*
|
|
2205
|
-
* For example:
|
|
2206
|
-
* ```
|
|
2207
|
-
* [09:37:17.579] INFO (#1) label=0ms: hello
|
|
2208
|
-
* key: value
|
|
2209
|
-
* ```
|
|
2210
|
-
*
|
|
2211
|
-
* @example
|
|
2212
|
-
* ```ts
|
|
2213
|
-
* import { Effect, Logger } from "effect"
|
|
2214
|
-
*
|
|
2215
|
-
* // Use the pretty console logger with default settings
|
|
2216
|
-
* const basicPretty = Effect.log("Hello Pretty Format").pipe(
|
|
2217
|
-
* Effect.provide(Logger.layer([Logger.consolePretty()]))
|
|
2218
|
-
* )
|
|
2219
|
-
*
|
|
2220
|
-
* // Configure pretty logger options
|
|
2221
|
-
* const customPretty = Logger.consolePretty({
|
|
2222
|
-
* colors: true,
|
|
2223
|
-
* stderr: false,
|
|
2224
|
-
* mode: "tty",
|
|
2225
|
-
* formatDate: (date) => date.toLocaleTimeString()
|
|
2226
|
-
* })
|
|
2227
|
-
*
|
|
2228
|
-
* // Perfect for development environment
|
|
2229
|
-
* const developmentProgram = Effect.gen(function*() {
|
|
2230
|
-
* yield* Effect.log("Application starting")
|
|
2231
|
-
* yield* Effect.logInfo("Database connected")
|
|
2232
|
-
* yield* Effect.logWarning("High memory usage detected")
|
|
2233
|
-
* }).pipe(
|
|
2234
|
-
* Effect.annotateLogs("environment", "development"),
|
|
2235
|
-
* Effect.withLogSpan("startup"),
|
|
2236
|
-
* Effect.provide(Logger.layer([customPretty]))
|
|
2237
|
-
* )
|
|
2238
|
-
*
|
|
2239
|
-
* // Disable colors for CI/CD environments
|
|
2240
|
-
* const ciLogger = Logger.consolePretty({ colors: false })
|
|
2241
|
-
* ```
|
|
2242
|
-
*
|
|
2243
|
-
* @since 4.0.0
|
|
2244
|
-
* @category constructors
|
|
2245
|
-
*/
|
|
2246
|
-
const consolePretty = consolePretty$1;
|
|
2247
|
-
/**
|
|
2248
|
-
* A `Logger` which includes log messages as tracer span events.
|
|
2249
|
-
*
|
|
2250
|
-
* This logger integrates logging with distributed tracing by recording
|
|
2251
|
-
* all log messages as events on the current trace span, making them visible
|
|
2252
|
-
* in tracing tools like OpenTelemetry, Jaeger, or Zipkin.
|
|
2253
|
-
*
|
|
2254
|
-
* **Note**: This logger is included in the default set of loggers for all
|
|
2255
|
-
* Effect programs, so log messages automatically appear as span events unless
|
|
2256
|
-
* you override the default loggers.
|
|
2257
|
-
*
|
|
2258
|
-
* @example
|
|
2259
|
-
* ```ts
|
|
2260
|
-
* import { Effect, Logger } from "effect"
|
|
2261
|
-
*
|
|
2262
|
-
* // Tracer logger is included by default - logs automatically become span events
|
|
2263
|
-
* const defaultProgram = Effect.gen(function*() {
|
|
2264
|
-
* yield* Effect.log("This automatically becomes a span event")
|
|
2265
|
-
* yield* Effect.logInfo("Processing data")
|
|
2266
|
-
* })
|
|
2267
|
-
*
|
|
2268
|
-
* // Explicitly combine tracer logger with other loggers
|
|
2269
|
-
* const observabilityProgram = Effect.gen(function*() {
|
|
2270
|
-
* yield* Effect.log("Operation started")
|
|
2271
|
-
* yield* Effect.logInfo("Processing data")
|
|
2272
|
-
* yield* Effect.logError("Error occurred")
|
|
2273
|
-
* }).pipe(
|
|
2274
|
-
* Effect.withLogSpan("data-processing"),
|
|
2275
|
-
* Effect.provide(Logger.layer([
|
|
2276
|
-
* Logger.tracerLogger,
|
|
2277
|
-
* Logger.consoleJson
|
|
2278
|
-
* ]))
|
|
2279
|
-
* )
|
|
2280
|
-
*
|
|
2281
|
-
* // Perfect for correlating logs with traces in distributed systems
|
|
2282
|
-
* const distributedProgram = Effect.gen(function*() {
|
|
2283
|
-
* yield* Effect.log("Step 1: Fetching user data")
|
|
2284
|
-
* yield* Effect.sleep("100 millis")
|
|
2285
|
-
* yield* Effect.log("Step 2: Processing payment")
|
|
2286
|
-
* yield* Effect.sleep("200 millis")
|
|
2287
|
-
* yield* Effect.log("Step 3: Sending confirmation")
|
|
2288
|
-
* }).pipe(
|
|
2289
|
-
* Effect.withLogSpan("payment-workflow"),
|
|
2290
|
-
* Effect.annotateLogs("userId", "user-123"),
|
|
2291
|
-
* Effect.provide(Logger.layer([Logger.tracerLogger]))
|
|
2292
|
-
* )
|
|
2293
|
-
* ```
|
|
2294
|
-
*
|
|
2295
|
-
* @since 4.0.0
|
|
2296
|
-
* @category constructors
|
|
2297
|
-
*/
|
|
2298
|
-
const tracerLogger = tracerLogger$1;
|
|
2299
|
-
/**
|
|
2300
2600
|
* Creates a `Layer` which will overwrite the current set of loggers with the
|
|
2301
2601
|
* specified array of `loggers`.
|
|
2302
2602
|
*
|
|
@@ -2573,7 +2873,7 @@ const get = (self) => sync(() => self.ref.current);
|
|
|
2573
2873
|
* @since 2.0.0
|
|
2574
2874
|
* @category setters
|
|
2575
2875
|
*/
|
|
2576
|
-
const set$1 = /* @__PURE__ */ dual(2, (self, value) => sync(() => set$
|
|
2876
|
+
const set$1 = /* @__PURE__ */ dual(2, (self, value) => sync(() => set$4(self.ref, value)));
|
|
2577
2877
|
/**
|
|
2578
2878
|
* Atomically modifies the value of the Ref using the given function.
|
|
2579
2879
|
*
|
|
@@ -13651,30 +13951,6 @@ const makeSchemaPrimitive = (tag, schema) => {
|
|
|
13651
13951
|
*/
|
|
13652
13952
|
const boolean$2 = /* @__PURE__ */ makeSchemaPrimitive("Boolean", Boolean$1);
|
|
13653
13953
|
/**
|
|
13654
|
-
* Creates a primitive that parses floating-point numbers from string input.
|
|
13655
|
-
*
|
|
13656
|
-
* @example
|
|
13657
|
-
* ```ts
|
|
13658
|
-
* import { Effect } from "effect"
|
|
13659
|
-
* import { Primitive } from "effect/unstable/cli"
|
|
13660
|
-
*
|
|
13661
|
-
* const parseFloat = Effect.gen(function*() {
|
|
13662
|
-
* const result1 = yield* Primitive.float.parse("3.14")
|
|
13663
|
-
* console.log(result1) // 3.14
|
|
13664
|
-
*
|
|
13665
|
-
* const result2 = yield* Primitive.float.parse("-42.5")
|
|
13666
|
-
* console.log(result2) // -42.5
|
|
13667
|
-
*
|
|
13668
|
-
* const result3 = yield* Primitive.float.parse("0")
|
|
13669
|
-
* console.log(result3) // 0
|
|
13670
|
-
* })
|
|
13671
|
-
* ```
|
|
13672
|
-
*
|
|
13673
|
-
* @since 4.0.0
|
|
13674
|
-
* @category constructors
|
|
13675
|
-
*/
|
|
13676
|
-
const float = /* @__PURE__ */ makeSchemaPrimitive("Float", Finite);
|
|
13677
|
-
/**
|
|
13678
13954
|
* Creates a primitive that parses integer numbers from string input.
|
|
13679
13955
|
*
|
|
13680
13956
|
* @example
|
|
@@ -13699,30 +13975,6 @@ const float = /* @__PURE__ */ makeSchemaPrimitive("Float", Finite);
|
|
|
13699
13975
|
*/
|
|
13700
13976
|
const integer$2 = /* @__PURE__ */ makeSchemaPrimitive("Integer", Int);
|
|
13701
13977
|
/**
|
|
13702
|
-
* Creates a primitive that parses Date objects from string input.
|
|
13703
|
-
*
|
|
13704
|
-
* @example
|
|
13705
|
-
* ```ts
|
|
13706
|
-
* import { Effect } from "effect"
|
|
13707
|
-
* import { Primitive } from "effect/unstable/cli"
|
|
13708
|
-
*
|
|
13709
|
-
* const parseDate = Effect.gen(function*() {
|
|
13710
|
-
* const result1 = yield* Primitive.date.parse("2023-12-25")
|
|
13711
|
-
* console.log(result1) // Date object for December 25, 2023
|
|
13712
|
-
*
|
|
13713
|
-
* const result2 = yield* Primitive.date.parse("2023-12-25T10:30:00Z")
|
|
13714
|
-
* console.log(result2) // Date object with time
|
|
13715
|
-
*
|
|
13716
|
-
* const result3 = yield* Primitive.date.parse("Dec 25, 2023")
|
|
13717
|
-
* console.log(result3) // Date object parsed from natural format
|
|
13718
|
-
* })
|
|
13719
|
-
* ```
|
|
13720
|
-
*
|
|
13721
|
-
* @since 4.0.0
|
|
13722
|
-
* @category constructors
|
|
13723
|
-
*/
|
|
13724
|
-
const date = /* @__PURE__ */ makeSchemaPrimitive("Date", DateValid);
|
|
13725
|
-
/**
|
|
13726
13978
|
* Creates a primitive that accepts any string value without validation.
|
|
13727
13979
|
*
|
|
13728
13980
|
* @example
|
|
@@ -13785,28 +14037,6 @@ const choice$2 = (choices) => {
|
|
|
13785
14037
|
return Object.assign(primitive, { choiceKeys: choices.map(([key]) => key) });
|
|
13786
14038
|
};
|
|
13787
14039
|
/**
|
|
13788
|
-
* A sentinel primitive that always fails to parse a value.
|
|
13789
|
-
*
|
|
13790
|
-
* Used for flags that don't accept values.
|
|
13791
|
-
*
|
|
13792
|
-
* @example
|
|
13793
|
-
* ```ts
|
|
13794
|
-
* import { Effect } from "effect"
|
|
13795
|
-
* import { Primitive } from "effect/unstable/cli"
|
|
13796
|
-
*
|
|
13797
|
-
* const program = Effect.gen(function*() {
|
|
13798
|
-
* // This will always fail - useful for boolean flags
|
|
13799
|
-
* const result = yield* Primitive.none.parse("any-value")
|
|
13800
|
-
* })
|
|
13801
|
-
*
|
|
13802
|
-
* // The above effect will fail with "This option does not accept values"
|
|
13803
|
-
* ```
|
|
13804
|
-
*
|
|
13805
|
-
* @since 4.0.0
|
|
13806
|
-
* @category constructors
|
|
13807
|
-
*/
|
|
13808
|
-
const none$2 = /* @__PURE__ */ makePrimitive("None", () => fail$1("This option does not accept values"));
|
|
13809
|
-
/**
|
|
13810
14040
|
* Gets a human-readable type name for a primitive.
|
|
13811
14041
|
*
|
|
13812
14042
|
* Used for generating help documentation.
|
|
@@ -14051,34 +14281,6 @@ const choiceWithValue$1 = (kind, name, choices) => makeSingle({
|
|
|
14051
14281
|
const choice$1 = (kind, name, choices) => {
|
|
14052
14282
|
return choiceWithValue$1(kind, name, choices.map((value) => [value, value]));
|
|
14053
14283
|
};
|
|
14054
|
-
/**
|
|
14055
|
-
* Creates an empty sentinel parameter that always fails to parse.
|
|
14056
|
-
*
|
|
14057
|
-
* This is useful for creating placeholder parameters or for combinators.
|
|
14058
|
-
*
|
|
14059
|
-
* @example
|
|
14060
|
-
* ```ts
|
|
14061
|
-
* import * as Param from "effect/unstable/cli/Param"
|
|
14062
|
-
*
|
|
14063
|
-
* // @internal - this module is not exported publicly
|
|
14064
|
-
*
|
|
14065
|
-
* // Create a none parameter for composition
|
|
14066
|
-
* const noneParam = Param.none(Param.flagKind)
|
|
14067
|
-
*
|
|
14068
|
-
* // Often used in conditional parameter creation
|
|
14069
|
-
* const conditionalParam = process.env.NODE_ENV === "production"
|
|
14070
|
-
* ? Param.string(Param.flagKind, "my-dev-flag")
|
|
14071
|
-
* : Param.none(Param.flagKind)
|
|
14072
|
-
* ```
|
|
14073
|
-
*
|
|
14074
|
-
* @since 4.0.0
|
|
14075
|
-
* @category constructors
|
|
14076
|
-
*/
|
|
14077
|
-
const none$1 = (kind) => makeSingle({
|
|
14078
|
-
name: "__none__",
|
|
14079
|
-
primitiveType: none$2,
|
|
14080
|
-
kind
|
|
14081
|
-
});
|
|
14082
14284
|
const FLAG_DASH_REGEXP = /^-+/;
|
|
14083
14285
|
/**
|
|
14084
14286
|
* Adds an alias to an option.
|
|
@@ -14161,7 +14363,7 @@ const withDescription$2 = /* @__PURE__ */ dual(2, (self, description) => {
|
|
|
14161
14363
|
* @category combinators
|
|
14162
14364
|
*/
|
|
14163
14365
|
const map$1 = /* @__PURE__ */ dual(2, (self, f) => {
|
|
14164
|
-
const parse = (args) => map$
|
|
14366
|
+
const parse = (args) => map$2(self.parse(args), ([operands, value]) => [operands, f(value)]);
|
|
14165
14367
|
return Object.assign(Object.create(Proto$7), {
|
|
14166
14368
|
_tag: "Map",
|
|
14167
14369
|
kind: self.kind,
|
|
@@ -14207,7 +14409,7 @@ const transform = (self, f) => Object.assign(Object.create(Proto$7), {
|
|
|
14207
14409
|
* @since 4.0.0
|
|
14208
14410
|
* @category combinators
|
|
14209
14411
|
*/
|
|
14210
|
-
const mapEffect = /* @__PURE__ */ dual(2, (self, f) => transform(self, (parse) => (args) => flatMap(parse(args), ([leftover, a]) => f(a).pipe(map$
|
|
14412
|
+
const mapEffect = /* @__PURE__ */ dual(2, (self, f) => transform(self, (parse) => (args) => flatMap(parse(args), ([leftover, a]) => f(a).pipe(map$2((b) => [leftover, b])))));
|
|
14211
14413
|
/**
|
|
14212
14414
|
* Creates an optional option that returns None when not provided.
|
|
14213
14415
|
*
|
|
@@ -14230,7 +14432,7 @@ const mapEffect = /* @__PURE__ */ dual(2, (self, f) => transform(self, (parse) =
|
|
|
14230
14432
|
* @category combinators
|
|
14231
14433
|
*/
|
|
14232
14434
|
const optional$1 = (param) => {
|
|
14233
|
-
const parse = (args) => param.parse(args).pipe(map$
|
|
14435
|
+
const parse = (args) => param.parse(args).pipe(map$2(([leftover, value]) => [leftover, some(value)]), catchTag("MissingOption", () => succeed([args.arguments, none()])), catchTag("MissingArgument", () => succeed([args.arguments, none()])));
|
|
14234
14436
|
return Object.assign(Object.create(Proto$7), {
|
|
14235
14437
|
_tag: "Optional",
|
|
14236
14438
|
kind: param.kind,
|
|
@@ -14239,42 +14441,6 @@ const optional$1 = (param) => {
|
|
|
14239
14441
|
});
|
|
14240
14442
|
};
|
|
14241
14443
|
/**
|
|
14242
|
-
* Makes an option optional by providing a default value.
|
|
14243
|
-
*
|
|
14244
|
-
* This combinator is useful when you want to make an existing option optional
|
|
14245
|
-
* by providing a fallback value that will be used when the option is not
|
|
14246
|
-
* provided on the command line.
|
|
14247
|
-
*
|
|
14248
|
-
* @example
|
|
14249
|
-
* ```ts
|
|
14250
|
-
* import * as Param from "effect/unstable/cli/Param"
|
|
14251
|
-
*
|
|
14252
|
-
* // @internal - this module is not exported publicly
|
|
14253
|
-
*
|
|
14254
|
-
* // Using the pipe operator to make an option optional
|
|
14255
|
-
* const port = Param.integer(Param.flagKind, "port").pipe(
|
|
14256
|
-
* Param.withDefault(8080)
|
|
14257
|
-
* )
|
|
14258
|
-
*
|
|
14259
|
-
* // Can also be used with other combinators
|
|
14260
|
-
* const verbose = Param.boolean(Param.flagKind, "verbose").pipe(
|
|
14261
|
-
* Param.withAlias("-v"),
|
|
14262
|
-
* Param.withDescription("Enable verbose output"),
|
|
14263
|
-
* Param.withDefault(false)
|
|
14264
|
-
* )
|
|
14265
|
-
* ```
|
|
14266
|
-
*
|
|
14267
|
-
* @since 4.0.0
|
|
14268
|
-
* @category combinators
|
|
14269
|
-
*/
|
|
14270
|
-
const withDefault$1 = /* @__PURE__ */ dual(2, (self, defaultValue) => {
|
|
14271
|
-
if (!isEffect(defaultValue)) return map$1(optional$1(self), getOrElse(() => defaultValue));
|
|
14272
|
-
return mapEffect(optional$1(self), match({
|
|
14273
|
-
onNone: () => defaultValue,
|
|
14274
|
-
onSome: succeed
|
|
14275
|
-
}));
|
|
14276
|
-
});
|
|
14277
|
-
/**
|
|
14278
14444
|
* Creates a variadic parameter that can be specified multiple times.
|
|
14279
14445
|
*
|
|
14280
14446
|
* This is the base combinator for creating parameters that accept multiple values.
|
|
@@ -14829,22 +14995,6 @@ const choiceWithValue = (name, choices) => choiceWithValue$1(flagKind, name, cho
|
|
|
14829
14995
|
*/
|
|
14830
14996
|
const choice = (name, choices) => choice$1(flagKind, name, choices);
|
|
14831
14997
|
/**
|
|
14832
|
-
* Creates an empty sentinel flag that always fails to parse.
|
|
14833
|
-
* This is useful for creating placeholder flags or for combinators.
|
|
14834
|
-
*
|
|
14835
|
-
* @example
|
|
14836
|
-
* ```ts
|
|
14837
|
-
* import { Flag } from "effect/unstable/cli"
|
|
14838
|
-
*
|
|
14839
|
-
* // Used as a placeholder in flag combinators
|
|
14840
|
-
* const conditionalFlag = true ? Flag.string("value") : Flag.none
|
|
14841
|
-
* ```
|
|
14842
|
-
*
|
|
14843
|
-
* @since 4.0.0
|
|
14844
|
-
* @category constructors
|
|
14845
|
-
*/
|
|
14846
|
-
const none = /* @__PURE__ */ none$1(flagKind);
|
|
14847
|
-
/**
|
|
14848
14998
|
* Adds an alias to a flag, allowing it to be referenced by multiple names.
|
|
14849
14999
|
*
|
|
14850
15000
|
* @example
|
|
@@ -14915,28 +15065,6 @@ const withDescription$1 = /* @__PURE__ */ dual(2, (self, description) => withDes
|
|
|
14915
15065
|
*/
|
|
14916
15066
|
const optional = (param) => optional$1(param);
|
|
14917
15067
|
/**
|
|
14918
|
-
* Provides a default value for a flag when it's not specified.
|
|
14919
|
-
*
|
|
14920
|
-
* @example
|
|
14921
|
-
* ```ts
|
|
14922
|
-
* import { Flag } from "effect/unstable/cli"
|
|
14923
|
-
*
|
|
14924
|
-
* const portFlag = Flag.integer("port").pipe(
|
|
14925
|
-
* Flag.withDefault(8080)
|
|
14926
|
-
* )
|
|
14927
|
-
* // If --port is not provided, defaults to 8080
|
|
14928
|
-
*
|
|
14929
|
-
* const hostFlag = Flag.string("host").pipe(
|
|
14930
|
-
* Flag.withDefault("localhost")
|
|
14931
|
-
* )
|
|
14932
|
-
* // If --host is not provided, defaults to "localhost"
|
|
14933
|
-
* ```
|
|
14934
|
-
*
|
|
14935
|
-
* @since 4.0.0
|
|
14936
|
-
* @category optionality
|
|
14937
|
-
*/
|
|
14938
|
-
const withDefault = withDefault$1;
|
|
14939
|
-
/**
|
|
14940
15068
|
* Transforms the parsed value of a flag using a mapping function.
|
|
14941
15069
|
*
|
|
14942
15070
|
* @example
|
|
@@ -15142,7 +15270,7 @@ const makeCommand = (options) => {
|
|
|
15142
15270
|
const subcommandDocs = [];
|
|
15143
15271
|
for (const group of subcommands) subcommandDocs.push({
|
|
15144
15272
|
group: group.group,
|
|
15145
|
-
commands: map$
|
|
15273
|
+
commands: map$3(group.commands, (subcommand) => ({
|
|
15146
15274
|
name: subcommand.name,
|
|
15147
15275
|
alias: subcommand.alias,
|
|
15148
15276
|
shortDescription: subcommand.shortDescription,
|
|
@@ -15883,7 +16011,7 @@ const Completions = /* @__PURE__ */ action({
|
|
|
15883
16011
|
"zsh",
|
|
15884
16012
|
"fish",
|
|
15885
16013
|
"sh"
|
|
15886
|
-
]).pipe(optional, /* @__PURE__ */ map((v) => map$
|
|
16014
|
+
]).pipe(optional, /* @__PURE__ */ map((v) => map$4(v, (s) => s === "sh" ? "bash" : s)), /* @__PURE__ */ withDescription$1("Print shell completion script")),
|
|
15887
16015
|
run: (shell, { command }) => gen(function* () {
|
|
15888
16016
|
if (isNone(shell)) return;
|
|
15889
16017
|
const descriptor = fromCommand(command);
|
|
@@ -16561,10 +16689,10 @@ const runWith = (command, config) => {
|
|
|
16561
16689
|
program = provideService(program, LogLevel, logLevel);
|
|
16562
16690
|
const services = match(logLevel, {
|
|
16563
16691
|
onNone: () => empty$5(),
|
|
16564
|
-
onSome: (level) => make$
|
|
16692
|
+
onSome: (level) => make$25(MinimumLogLevel, level)
|
|
16565
16693
|
});
|
|
16566
16694
|
yield* provideServices(program, services);
|
|
16567
|
-
}, catchFilter((error) => isCliError(error) && error._tag === "ShowHelp" ? succeed$
|
|
16695
|
+
}, catchFilter((error) => isCliError(error) && error._tag === "ShowHelp" ? succeed$4(error) : fail$3(error), (error) => showHelp(command, error.commandPath)), catchFilter((e) => isQuitError(e) ? succeed$4(e) : fail$3(e), (_) => interrupt));
|
|
16568
16696
|
};
|
|
16569
16697
|
//#endregion
|
|
16570
16698
|
//#region ../../packages/t3-shared/src/Net.ts
|
|
@@ -19541,7 +19669,7 @@ const launchDetached = (launch) => gen(function* () {
|
|
|
19541
19669
|
});
|
|
19542
19670
|
const make$9 = gen(function* () {
|
|
19543
19671
|
const open = yield* tryPromise({
|
|
19544
|
-
try: () => import("./open-
|
|
19672
|
+
try: () => import("./open-BM96ykXl.mjs"),
|
|
19545
19673
|
catch: (cause) => new OpenError({
|
|
19546
19674
|
message: "failed to load browser opener",
|
|
19547
19675
|
cause
|
|
@@ -19609,7 +19737,7 @@ const make$8 = ({ dumpSchema = () => void_$1 }) => ({ loader, schemaDirectory, t
|
|
|
19609
19737
|
migration_id,
|
|
19610
19738
|
name
|
|
19611
19739
|
})))}`.withoutTransform;
|
|
19612
|
-
const latestMigration = map$
|
|
19740
|
+
const latestMigration = map$2(sql`SELECT migration_id, name, created_at FROM ${sql(table)} ORDER BY migration_id DESC`.withoutTransform, (_) => map$4(fromNullishOr(_[0]), ({ created_at, migration_id, name }) => ({
|
|
19613
19741
|
id: migration_id,
|
|
19614
19742
|
name,
|
|
19615
19743
|
createdAt: created_at
|
|
@@ -19634,7 +19762,7 @@ const make$8 = ({ dumpSchema = () => void_$1 }) => ({ loader, schemaDirectory, t
|
|
|
19634
19762
|
pg: () => sql`LOCK TABLE ${sql(table)} IN ACCESS EXCLUSIVE MODE`,
|
|
19635
19763
|
orElse: () => void_$1
|
|
19636
19764
|
});
|
|
19637
|
-
const [latestMigrationId, current] = yield* all([map$
|
|
19765
|
+
const [latestMigrationId, current] = yield* all([map$2(latestMigration, match({
|
|
19638
19766
|
onNone: () => 0,
|
|
19639
19767
|
onSome: (_) => _.id
|
|
19640
19768
|
})), loader]);
|
|
@@ -19668,12 +19796,12 @@ const make$8 = ({ dumpSchema = () => void_$1 }) => ({ loader, schemaDirectory, t
|
|
|
19668
19796
|
if (schemaDirectory && completed.length > 0) yield* dumpSchema(`${schemaDirectory}/_schema.sql`, table).pipe(catchCause((cause) => logInfo$1("Could not dump schema", cause)));
|
|
19669
19797
|
return completed;
|
|
19670
19798
|
});
|
|
19671
|
-
const migrationOrder = /* @__PURE__ */ make$
|
|
19799
|
+
const migrationOrder = /* @__PURE__ */ make$26(([a], [b]) => Number$2(a, b));
|
|
19672
19800
|
/**
|
|
19673
19801
|
* @since 4.0.0
|
|
19674
19802
|
* @category loaders
|
|
19675
19803
|
*/
|
|
19676
|
-
const fromRecord = (migrations) => pipe(Object.keys(migrations), flatMapNullishOr((_) => _.match(/^(\d+)_(.+)$/)), map$
|
|
19804
|
+
const fromRecord = (migrations) => pipe(Object.keys(migrations), flatMapNullishOr((_) => _.match(/^(\d+)_(.+)$/)), map$3(([key, id, name]) => [
|
|
19677
19805
|
Number(id),
|
|
19678
19806
|
name,
|
|
19679
19807
|
succeed(migrations[key])
|
|
@@ -20370,8 +20498,8 @@ const runMigrations = gen(function* () {
|
|
|
20370
20498
|
//#endregion
|
|
20371
20499
|
//#region src/persistence/Layers/Sqlite.ts
|
|
20372
20500
|
const defaultSqliteClientLoaders = {
|
|
20373
|
-
bun: () => import("./SqliteClient-
|
|
20374
|
-
node: () => import("./NodeSqliteClient-
|
|
20501
|
+
bun: () => import("./SqliteClient-9lnXlJby.mjs"),
|
|
20502
|
+
node: () => import("./NodeSqliteClient-BPNNnMBz.mjs")
|
|
20375
20503
|
};
|
|
20376
20504
|
const makeRuntimeSqliteLayer = (config) => gen(function* () {
|
|
20377
20505
|
const loader = defaultSqliteClientLoaders[process.versions.bun !== void 0 ? "bun" : "node"];
|
|
@@ -20576,7 +20704,7 @@ const make$7 = gen(function* () {
|
|
|
20576
20704
|
threadId: input.threadId,
|
|
20577
20705
|
fromTurnCount: 0,
|
|
20578
20706
|
toTurnCount: input.toTurnCount
|
|
20579
|
-
}).pipe(map$
|
|
20707
|
+
}).pipe(map$2((result) => result));
|
|
20580
20708
|
return {
|
|
20581
20709
|
getTurnDiff,
|
|
20582
20710
|
getFullThreadDiff
|
|
@@ -20707,7 +20835,7 @@ const makeGitService = gen(function* () {
|
|
|
20707
20835
|
const [stdout, stderr, exitCode] = yield* all([
|
|
20708
20836
|
collectOutput(commandInput, child.stdout, maxOutputBytes),
|
|
20709
20837
|
collectOutput(commandInput, child.stderr, maxOutputBytes),
|
|
20710
|
-
child.exitCode.pipe(map$
|
|
20838
|
+
child.exitCode.pipe(map$2((value) => Number(value)), mapError(toGitCommandError(commandInput, "failed to report exit code.")))
|
|
20711
20839
|
], { concurrency: "unbounded" });
|
|
20712
20840
|
if (!input.allowNonZeroExit && exitCode !== 0) {
|
|
20713
20841
|
const trimmedStderr = stderr.trim();
|
|
@@ -20779,7 +20907,7 @@ const makeCheckpointStore = gen(function* () {
|
|
|
20779
20907
|
"HEAD^{commit}"
|
|
20780
20908
|
],
|
|
20781
20909
|
allowNonZeroExit: true
|
|
20782
|
-
}).pipe(map$
|
|
20910
|
+
}).pipe(map$2((result) => {
|
|
20783
20911
|
if (result.code !== 0) return null;
|
|
20784
20912
|
const commit = result.stdout.trim();
|
|
20785
20913
|
return commit.length > 0 ? commit : null;
|
|
@@ -20793,7 +20921,7 @@ const makeCheckpointStore = gen(function* () {
|
|
|
20793
20921
|
"HEAD"
|
|
20794
20922
|
],
|
|
20795
20923
|
allowNonZeroExit: true
|
|
20796
|
-
}).pipe(map$
|
|
20924
|
+
}).pipe(map$2((result) => result.code === 0));
|
|
20797
20925
|
const resolveCheckpointCommit = (cwd, checkpointRef) => git.execute({
|
|
20798
20926
|
operation: "CheckpointStore.resolveCheckpointCommit",
|
|
20799
20927
|
cwd,
|
|
@@ -20804,7 +20932,7 @@ const makeCheckpointStore = gen(function* () {
|
|
|
20804
20932
|
`${checkpointRef}^{commit}`
|
|
20805
20933
|
],
|
|
20806
20934
|
allowNonZeroExit: true
|
|
20807
|
-
}).pipe(map$
|
|
20935
|
+
}).pipe(map$2((result) => {
|
|
20808
20936
|
if (result.code !== 0) return null;
|
|
20809
20937
|
const commit = result.stdout.trim();
|
|
20810
20938
|
return commit.length > 0 ? commit : null;
|
|
@@ -20832,7 +20960,7 @@ const makeCheckpointStore = gen(function* () {
|
|
|
20832
20960
|
cwd,
|
|
20833
20961
|
args: ["rev-parse", "--is-inside-work-tree"],
|
|
20834
20962
|
allowNonZeroExit: true
|
|
20835
|
-
}).pipe(map$
|
|
20963
|
+
}).pipe(map$2((result) => result.code === 0 && result.stdout.trim() === "true"), catch_(() => succeed(false)));
|
|
20836
20964
|
const captureCheckpoint = (input) => gen(function* () {
|
|
20837
20965
|
const operation = "CheckpointStore.captureCheckpoint";
|
|
20838
20966
|
yield* acquireUseRelease(fs.makeTempDirectory({ prefix: "t3-fs-checkpoint-" }), (tempDir) => gen(function* () {
|
|
@@ -20907,7 +21035,7 @@ const makeCheckpointStore = gen(function* () {
|
|
|
20907
21035
|
cause: error
|
|
20908
21036
|
})) }));
|
|
20909
21037
|
});
|
|
20910
|
-
const hasCheckpointRef = (input) => resolveCheckpointCommit(input.cwd, input.checkpointRef).pipe(map$
|
|
21038
|
+
const hasCheckpointRef = (input) => resolveCheckpointCommit(input.cwd, input.checkpointRef).pipe(map$2((commit) => commit !== null));
|
|
20911
21039
|
const restoreCheckpoint = (input) => gen(function* () {
|
|
20912
21040
|
const operation = "CheckpointStore.restoreCheckpoint";
|
|
20913
21041
|
let commitOid = yield* resolveCheckpointCommit(input.cwd, input.checkpointRef);
|
|
@@ -21050,7 +21178,7 @@ const findOne = (options) => {
|
|
|
21050
21178
|
const findOneOption = (options) => {
|
|
21051
21179
|
const encodeRequest = encodeEffect(options.Request);
|
|
21052
21180
|
const decode = decodeUnknownEffect(options.Result);
|
|
21053
|
-
return (request) => flatMap(flatMap(encodeRequest(request), options.execute), (arr) => isReadonlyArrayNonEmpty(arr) ? asSome(decode(arr[0])) : succeedNone);
|
|
21181
|
+
return (request) => flatMap(flatMap(encodeRequest(request), options.execute), (arr) => isReadonlyArrayNonEmpty(arr) ? asSome$1(decode(arr[0])) : succeedNone$1);
|
|
21054
21182
|
};
|
|
21055
21183
|
//#endregion
|
|
21056
21184
|
//#region src/persistence/Errors.ts
|
|
@@ -21234,9 +21362,9 @@ const makeProjectionCheckpointRepository = gen(function* () {
|
|
|
21234
21362
|
checkpointTurnCount: row.checkpointTurnCount
|
|
21235
21363
|
}).pipe(flatMap(() => upsertProjectionCheckpointRow(row))));
|
|
21236
21364
|
const upsert = (row) => upsertCheckpointRow(row).pipe(mapError(toPersistenceSqlOrDecodeError$6("ProjectionCheckpointRepository.upsert:query", "ProjectionCheckpointRepository.upsert:encodeRequest")));
|
|
21237
|
-
const listByThreadId = (input) => listProjectionCheckpointRows(input).pipe(mapError(toPersistenceSqlOrDecodeError$6("ProjectionCheckpointRepository.listByThreadId:query", "ProjectionCheckpointRepository.listByThreadId:decodeRows")), map$
|
|
21365
|
+
const listByThreadId = (input) => listProjectionCheckpointRows(input).pipe(mapError(toPersistenceSqlOrDecodeError$6("ProjectionCheckpointRepository.listByThreadId:query", "ProjectionCheckpointRepository.listByThreadId:decodeRows")), map$2((rows) => rows));
|
|
21238
21366
|
const getByThreadAndTurnCount = (input) => getProjectionCheckpointRow(input).pipe(mapError(toPersistenceSqlOrDecodeError$6("ProjectionCheckpointRepository.getByThreadAndTurnCount:query", "ProjectionCheckpointRepository.getByThreadAndTurnCount:decodeRow")), flatMap((rowOption) => match(rowOption, {
|
|
21239
|
-
onNone: () => succeed(none
|
|
21367
|
+
onNone: () => succeed(none()),
|
|
21240
21368
|
onSome: (row) => succeed(some(row))
|
|
21241
21369
|
})));
|
|
21242
21370
|
const deleteByThreadId = (input) => deleteProjectionCheckpointRows(input).pipe(mapError(toPersistenceSqlError("ProjectionCheckpointRepository.deleteByThreadId:query")));
|
|
@@ -21621,10 +21749,10 @@ const makeProjectionProjectRepository = gen(function* () {
|
|
|
21621
21749
|
});
|
|
21622
21750
|
const upsert = (row) => upsertProjectionProjectRow(row).pipe(mapError(toPersistenceSqlOrDecodeError$4("ProjectionProjectRepository.upsert:query", "ProjectionProjectRepository.upsert:encodeRequest")));
|
|
21623
21751
|
const getById = (input) => getProjectionProjectRow(input).pipe(mapError(toPersistenceSqlOrDecodeError$4("ProjectionProjectRepository.getById:query", "ProjectionProjectRepository.getById:decodeRow")), flatMap((rowOption) => match(rowOption, {
|
|
21624
|
-
onNone: () => succeed(none
|
|
21752
|
+
onNone: () => succeed(none()),
|
|
21625
21753
|
onSome: (row) => succeed(some(row))
|
|
21626
21754
|
})));
|
|
21627
|
-
const listAll = () => listProjectionProjectRows().pipe(mapError(toPersistenceSqlOrDecodeError$4("ProjectionProjectRepository.listAll:query", "ProjectionProjectRepository.listAll:decodeRows")), map$
|
|
21755
|
+
const listAll = () => listProjectionProjectRows().pipe(mapError(toPersistenceSqlOrDecodeError$4("ProjectionProjectRepository.listAll:query", "ProjectionProjectRepository.listAll:decodeRows")), map$2((rows) => rows));
|
|
21628
21756
|
const deleteById = (input) => deleteProjectionProjectRow(input).pipe(mapError(toPersistenceSqlError("ProjectionProjectRepository.deleteById:query")));
|
|
21629
21757
|
return {
|
|
21630
21758
|
upsert,
|
|
@@ -21714,7 +21842,7 @@ const makeProjectionStateRepository = gen(function* () {
|
|
|
21714
21842
|
const upsert = (row) => upsertProjectionStateRow(row).pipe(mapError(toPersistenceSqlError("ProjectionStateRepository.upsert:query")));
|
|
21715
21843
|
const getByProjector = (input) => getProjectionStateRow(input).pipe(mapError(toPersistenceSqlError("ProjectionStateRepository.getByProjector:query")));
|
|
21716
21844
|
const listAll = () => listProjectionStateRows(void 0).pipe(mapError(toPersistenceSqlError("ProjectionStateRepository.listAll:query")));
|
|
21717
|
-
const minLastAppliedSequence = () => readMinLastAppliedSequence(void 0).pipe(mapError(toPersistenceSqlError("ProjectionStateRepository.minLastAppliedSequence:query")), map$
|
|
21845
|
+
const minLastAppliedSequence = () => readMinLastAppliedSequence(void 0).pipe(mapError(toPersistenceSqlError("ProjectionStateRepository.minLastAppliedSequence:query")), map$2((row) => row.minLastAppliedSequence));
|
|
21718
21846
|
return {
|
|
21719
21847
|
upsert,
|
|
21720
21848
|
getByProjector,
|
|
@@ -21829,7 +21957,7 @@ const makeProjectionThreadActivityRepository = gen(function* () {
|
|
|
21829
21957
|
`
|
|
21830
21958
|
});
|
|
21831
21959
|
const upsert = (row) => upsertProjectionThreadActivityRow(row).pipe(mapError(toPersistenceSqlOrDecodeError$3("ProjectionThreadActivityRepository.upsert:query", "ProjectionThreadActivityRepository.upsert:encodeRequest")));
|
|
21832
|
-
const listByThreadId = (input) => listProjectionThreadActivityRows(input).pipe(mapError(toPersistenceSqlOrDecodeError$3("ProjectionThreadActivityRepository.listByThreadId:query", "ProjectionThreadActivityRepository.listByThreadId:decodeRows")), map$
|
|
21960
|
+
const listByThreadId = (input) => listProjectionThreadActivityRows(input).pipe(mapError(toPersistenceSqlOrDecodeError$3("ProjectionThreadActivityRepository.listByThreadId:query", "ProjectionThreadActivityRepository.listByThreadId:decodeRows")), map$2((rows) => rows.map((row) => ({
|
|
21833
21961
|
activityId: row.activityId,
|
|
21834
21962
|
threadId: row.threadId,
|
|
21835
21963
|
turnId: row.turnId,
|
|
@@ -21960,7 +22088,7 @@ const makeProjectionThreadMessageRepository = gen(function* () {
|
|
|
21960
22088
|
`
|
|
21961
22089
|
});
|
|
21962
22090
|
const upsert = (row) => upsertProjectionThreadMessageRow(row).pipe(mapError(toPersistenceSqlError("ProjectionThreadMessageRepository.upsert:query")));
|
|
21963
|
-
const listByThreadId = (input) => listProjectionThreadMessageRows(input).pipe(mapError(toPersistenceSqlError("ProjectionThreadMessageRepository.listByThreadId:query")), map$
|
|
22091
|
+
const listByThreadId = (input) => listProjectionThreadMessageRows(input).pipe(mapError(toPersistenceSqlError("ProjectionThreadMessageRepository.listByThreadId:query")), map$2((rows) => rows.map((row) => ({
|
|
21964
22092
|
messageId: row.messageId,
|
|
21965
22093
|
threadId: row.threadId,
|
|
21966
22094
|
turnId: row.turnId,
|
|
@@ -22646,10 +22774,10 @@ const makeProjectionTurnRepository = gen(function* () {
|
|
|
22646
22774
|
const replacePendingTurnStart = (row) => sql.withTransaction(clearPendingProjectionTurnsByThread({ threadId: row.threadId }).pipe(flatMap(() => insertPendingProjectionTurn(row)))).pipe(mapError(toPersistenceSqlOrDecodeError$1("ProjectionTurnRepository.replacePendingTurnStart:query", "ProjectionTurnRepository.replacePendingTurnStart:encodeRequest")));
|
|
22647
22775
|
const getPendingTurnStartByThreadId = (input) => getPendingProjectionTurn(input).pipe(mapError(toPersistenceSqlError("ProjectionTurnRepository.getPendingTurnStartByThreadId:query")));
|
|
22648
22776
|
const deletePendingTurnStartByThreadId = (input) => clearPendingProjectionTurnsByThread(input).pipe(mapError(toPersistenceSqlError("ProjectionTurnRepository.deletePendingTurnStartByThreadId:query")));
|
|
22649
|
-
const listByThreadId = (input) => listProjectionTurnsByThread(input).pipe(mapError(toPersistenceSqlOrDecodeError$1("ProjectionTurnRepository.listByThreadId:query", "ProjectionTurnRepository.listByThreadId:decodeRows")), map$
|
|
22650
|
-
const listAll = () => listAllProjectionTurns(void 0).pipe(mapError(toPersistenceSqlOrDecodeError$1("ProjectionTurnRepository.listAll:query", "ProjectionTurnRepository.listAll:decodeRows")), map$
|
|
22777
|
+
const listByThreadId = (input) => listProjectionTurnsByThread(input).pipe(mapError(toPersistenceSqlOrDecodeError$1("ProjectionTurnRepository.listByThreadId:query", "ProjectionTurnRepository.listByThreadId:decodeRows")), map$2((rows) => rows));
|
|
22778
|
+
const listAll = () => listAllProjectionTurns(void 0).pipe(mapError(toPersistenceSqlOrDecodeError$1("ProjectionTurnRepository.listAll:query", "ProjectionTurnRepository.listAll:decodeRows")), map$2((rows) => rows));
|
|
22651
22779
|
const getByTurnId = (input) => getProjectionTurnByTurnId(input).pipe(mapError(toPersistenceSqlOrDecodeError$1("ProjectionTurnRepository.getByTurnId:query", "ProjectionTurnRepository.getByTurnId:decodeRow")), flatMap((rowOption) => match(rowOption, {
|
|
22652
|
-
onNone: () => succeed(none
|
|
22780
|
+
onNone: () => succeed(none()),
|
|
22653
22781
|
onSome: (row) => succeed(some(row))
|
|
22654
22782
|
})));
|
|
22655
22783
|
const clearCheckpointTurnConflict = (input) => clearCheckpointTurnConflictRow(input).pipe(mapError(toPersistenceSqlError("ProjectionTurnRepository.clearCheckpointTurnConflict:query")));
|
|
@@ -22783,8 +22911,8 @@ const makeProviderSessionRuntimeRepository = gen(function* () {
|
|
|
22783
22911
|
});
|
|
22784
22912
|
const upsert = (runtime) => upsertRuntimeRow(runtime).pipe(mapError(toPersistenceSqlOrDecodeError("ProviderSessionRuntimeRepository.upsert:query", "ProviderSessionRuntimeRepository.upsert:encodeRequest")));
|
|
22785
22913
|
const getByThreadId = (input) => getRuntimeRowByThreadId(input).pipe(mapError(toPersistenceSqlOrDecodeError("ProviderSessionRuntimeRepository.getByThreadId:query", "ProviderSessionRuntimeRepository.getByThreadId:decodeRow")), flatMap((runtimeRowOption) => match(runtimeRowOption, {
|
|
22786
|
-
onNone: () => succeed(none
|
|
22787
|
-
onSome: (row) => decodeRuntime(row).pipe(mapError(toPersistenceDecodeError("ProviderSessionRuntimeRepository.getByThreadId:rowToRuntime")), map$
|
|
22914
|
+
onNone: () => succeed(none()),
|
|
22915
|
+
onSome: (row) => decodeRuntime(row).pipe(mapError(toPersistenceDecodeError("ProviderSessionRuntimeRepository.getByThreadId:rowToRuntime")), map$2((runtime) => some(runtime)))
|
|
22788
22916
|
})));
|
|
22789
22917
|
const list = () => listRuntimeRows(void 0).pipe(mapError(toPersistenceSqlOrDecodeError("ProviderSessionRuntimeRepository.list:query", "ProviderSessionRuntimeRepository.list:decodeRows")), flatMap((rows) => forEach(rows, (row) => decodeRuntime(row).pipe(mapError(toPersistenceDecodeError("ProviderSessionRuntimeRepository.list:rowToRuntime"))), { concurrency: "unbounded" })));
|
|
22790
22918
|
const deleteByThreadId = (input) => deleteRuntimeByThreadId(input).pipe(mapError(toPersistenceSqlError("ProviderSessionRuntimeRepository.deleteByThreadId:query")));
|
|
@@ -23643,7 +23771,7 @@ function projectEvent(model, event) {
|
|
|
23643
23771
|
updatedAt: event.occurredAt
|
|
23644
23772
|
};
|
|
23645
23773
|
switch (event.type) {
|
|
23646
|
-
case "project.created": return decodeForEvent(ProjectCreatedPayload, event.payload, event.type, "payload").pipe(map$
|
|
23774
|
+
case "project.created": return decodeForEvent(ProjectCreatedPayload, event.payload, event.type, "payload").pipe(map$2((payload) => {
|
|
23647
23775
|
const existing = nextBase.projects.find((entry) => entry.id === payload.projectId);
|
|
23648
23776
|
const nextProject = {
|
|
23649
23777
|
id: payload.projectId,
|
|
@@ -23660,7 +23788,7 @@ function projectEvent(model, event) {
|
|
|
23660
23788
|
projects: existing ? nextBase.projects.map((entry) => entry.id === payload.projectId ? nextProject : entry) : [...nextBase.projects, nextProject]
|
|
23661
23789
|
};
|
|
23662
23790
|
}));
|
|
23663
|
-
case "project.meta-updated": return decodeForEvent(ProjectMetaUpdatedPayload, event.payload, event.type, "payload").pipe(map$
|
|
23791
|
+
case "project.meta-updated": return decodeForEvent(ProjectMetaUpdatedPayload, event.payload, event.type, "payload").pipe(map$2((payload) => ({
|
|
23664
23792
|
...nextBase,
|
|
23665
23793
|
projects: nextBase.projects.map((project) => project.id === payload.projectId ? {
|
|
23666
23794
|
...project,
|
|
@@ -23671,7 +23799,7 @@ function projectEvent(model, event) {
|
|
|
23671
23799
|
updatedAt: payload.updatedAt
|
|
23672
23800
|
} : project)
|
|
23673
23801
|
})));
|
|
23674
|
-
case "project.deleted": return decodeForEvent(ProjectDeletedPayload, event.payload, event.type, "payload").pipe(map$
|
|
23802
|
+
case "project.deleted": return decodeForEvent(ProjectDeletedPayload, event.payload, event.type, "payload").pipe(map$2((payload) => ({
|
|
23675
23803
|
...nextBase,
|
|
23676
23804
|
projects: nextBase.projects.map((project) => project.id === payload.projectId ? {
|
|
23677
23805
|
...project,
|
|
@@ -23708,28 +23836,28 @@ function projectEvent(model, event) {
|
|
|
23708
23836
|
threads: existing ? nextBase.threads.map((entry) => entry.id === thread.id ? thread : entry) : [...nextBase.threads, thread]
|
|
23709
23837
|
};
|
|
23710
23838
|
});
|
|
23711
|
-
case "thread.archived": return decodeForEvent(ThreadArchivedPayload, event.payload, event.type, "payload").pipe(map$
|
|
23839
|
+
case "thread.archived": return decodeForEvent(ThreadArchivedPayload, event.payload, event.type, "payload").pipe(map$2((payload) => ({
|
|
23712
23840
|
...nextBase,
|
|
23713
23841
|
threads: updateThread(nextBase.threads, payload.threadId, {
|
|
23714
23842
|
archivedAt: payload.archivedAt,
|
|
23715
23843
|
updatedAt: payload.updatedAt
|
|
23716
23844
|
})
|
|
23717
23845
|
})));
|
|
23718
|
-
case "thread.unarchived": return decodeForEvent(ThreadUnarchivedPayload, event.payload, event.type, "payload").pipe(map$
|
|
23846
|
+
case "thread.unarchived": return decodeForEvent(ThreadUnarchivedPayload, event.payload, event.type, "payload").pipe(map$2((payload) => ({
|
|
23719
23847
|
...nextBase,
|
|
23720
23848
|
threads: updateThread(nextBase.threads, payload.threadId, {
|
|
23721
23849
|
archivedAt: null,
|
|
23722
23850
|
updatedAt: payload.updatedAt
|
|
23723
23851
|
})
|
|
23724
23852
|
})));
|
|
23725
|
-
case "thread.deleted": return decodeForEvent(ThreadDeletedPayload, event.payload, event.type, "payload").pipe(map$
|
|
23853
|
+
case "thread.deleted": return decodeForEvent(ThreadDeletedPayload, event.payload, event.type, "payload").pipe(map$2((payload) => ({
|
|
23726
23854
|
...nextBase,
|
|
23727
23855
|
threads: updateThread(nextBase.threads, payload.threadId, {
|
|
23728
23856
|
deletedAt: payload.deletedAt,
|
|
23729
23857
|
updatedAt: payload.deletedAt
|
|
23730
23858
|
})
|
|
23731
23859
|
})));
|
|
23732
|
-
case "thread.meta-updated": return decodeForEvent(ThreadMetaUpdatedPayload, event.payload, event.type, "payload").pipe(map$
|
|
23860
|
+
case "thread.meta-updated": return decodeForEvent(ThreadMetaUpdatedPayload, event.payload, event.type, "payload").pipe(map$2((payload) => ({
|
|
23733
23861
|
...nextBase,
|
|
23734
23862
|
threads: updateThread(nextBase.threads, payload.threadId, {
|
|
23735
23863
|
...payload.projectId !== void 0 ? { projectId: payload.projectId } : {},
|
|
@@ -23744,14 +23872,14 @@ function projectEvent(model, event) {
|
|
|
23744
23872
|
updatedAt: payload.updatedAt
|
|
23745
23873
|
})
|
|
23746
23874
|
})));
|
|
23747
|
-
case "thread.runtime-mode-set": return decodeForEvent(ThreadRuntimeModeSetPayload, event.payload, event.type, "payload").pipe(map$
|
|
23875
|
+
case "thread.runtime-mode-set": return decodeForEvent(ThreadRuntimeModeSetPayload, event.payload, event.type, "payload").pipe(map$2((payload) => ({
|
|
23748
23876
|
...nextBase,
|
|
23749
23877
|
threads: updateThread(nextBase.threads, payload.threadId, {
|
|
23750
23878
|
runtimeMode: payload.runtimeMode,
|
|
23751
23879
|
updatedAt: payload.updatedAt
|
|
23752
23880
|
})
|
|
23753
23881
|
})));
|
|
23754
|
-
case "thread.interaction-mode-set": return decodeForEvent(ThreadInteractionModeSetPayload, event.payload, event.type, "payload").pipe(map$
|
|
23882
|
+
case "thread.interaction-mode-set": return decodeForEvent(ThreadInteractionModeSetPayload, event.payload, event.type, "payload").pipe(map$2((payload) => ({
|
|
23755
23883
|
...nextBase,
|
|
23756
23884
|
threads: updateThread(nextBase.threads, payload.threadId, {
|
|
23757
23885
|
interactionMode: payload.interactionMode,
|
|
@@ -23856,7 +23984,7 @@ function projectEvent(model, event) {
|
|
|
23856
23984
|
})
|
|
23857
23985
|
};
|
|
23858
23986
|
});
|
|
23859
|
-
case "thread.reverted": return decodeForEvent(ThreadRevertedPayload, event.payload, event.type, "payload").pipe(map$
|
|
23987
|
+
case "thread.reverted": return decodeForEvent(ThreadRevertedPayload, event.payload, event.type, "payload").pipe(map$2((payload) => {
|
|
23860
23988
|
const thread = nextBase.threads.find((entry) => entry.id === payload.threadId);
|
|
23861
23989
|
if (!thread) return nextBase;
|
|
23862
23990
|
const checkpoints = thread.checkpoints.filter((entry) => entry.checkpointTurnCount <= payload.turnCount).toSorted((left, right) => left.checkpointTurnCount - right.checkpointTurnCount).slice(-MAX_THREAD_CHECKPOINTS);
|
|
@@ -23885,7 +24013,7 @@ function projectEvent(model, event) {
|
|
|
23885
24013
|
})
|
|
23886
24014
|
};
|
|
23887
24015
|
}));
|
|
23888
|
-
case "thread.activity-appended": return decodeForEvent(ThreadActivityAppendedPayload, event.payload, event.type, "payload").pipe(map$
|
|
24016
|
+
case "thread.activity-appended": return decodeForEvent(ThreadActivityAppendedPayload, event.payload, event.type, "payload").pipe(map$2((payload) => {
|
|
23889
24017
|
const thread = nextBase.threads.find((entry) => entry.id === payload.threadId);
|
|
23890
24018
|
if (!thread) return nextBase;
|
|
23891
24019
|
const activities = [...thread.activities.filter((entry) => entry.id !== payload.activity.id), payload.activity].toSorted(compareThreadActivities).slice(-500);
|
|
@@ -24212,7 +24340,7 @@ const makeOrchestrationEngine = gen(function* () {
|
|
|
24212
24340
|
const processEnvelope = (envelope) => {
|
|
24213
24341
|
const dispatchStartSequence = readModel.snapshotSequence;
|
|
24214
24342
|
const reconcileReadModelAfterDispatchFailure = gen(function* () {
|
|
24215
|
-
const persistedEvents = yield* runCollect(eventStore.readFromSequence(dispatchStartSequence)).pipe(map$
|
|
24343
|
+
const persistedEvents = yield* runCollect(eventStore.readFromSequence(dispatchStartSequence)).pipe(map$2((chunk) => Array.from(chunk)));
|
|
24216
24344
|
if (persistedEvents.length === 0) return;
|
|
24217
24345
|
let nextReadModel = readModel;
|
|
24218
24346
|
for (const persistedEvent of persistedEvents) nextReadModel = yield* projectEvent(nextReadModel, persistedEvent);
|
|
@@ -24223,7 +24351,7 @@ const makeOrchestrationEngine = gen(function* () {
|
|
|
24223
24351
|
const existingReceipt = yield* commandReceiptRepository.getByCommandId({ commandId: envelope.command.commandId });
|
|
24224
24352
|
if (isSome(existingReceipt)) {
|
|
24225
24353
|
if (existingReceipt.value.status === "accepted") {
|
|
24226
|
-
yield* succeed$
|
|
24354
|
+
yield* succeed$5(envelope.result, { sequence: existingReceipt.value.resultSequence });
|
|
24227
24355
|
return;
|
|
24228
24356
|
}
|
|
24229
24357
|
yield* fail$4(envelope.result, new OrchestrationCommandPreviouslyRejectedError({
|
|
@@ -24268,7 +24396,7 @@ const makeOrchestrationEngine = gen(function* () {
|
|
|
24268
24396
|
})).pipe(catchTag("SqlError", (sqlError) => fail$1(toPersistenceSqlError("OrchestrationEngine.processEnvelope:transaction")(sqlError))));
|
|
24269
24397
|
readModel = committedCommand.nextReadModel;
|
|
24270
24398
|
for (const event of committedCommand.committedEvents) yield* publish(eventPubSub, event);
|
|
24271
|
-
yield* succeed$
|
|
24399
|
+
yield* succeed$5(envelope.result, { sequence: committedCommand.lastSequence });
|
|
24272
24400
|
}).pipe(catch_((error) => gen(function* () {
|
|
24273
24401
|
yield* reconcileReadModelAfterDispatchFailure.pipe(catch_(() => logWarning$1("failed to reconcile orchestration read model after dispatch failure").pipe(annotateLogs({
|
|
24274
24402
|
commandId: envelope.command.commandId,
|
|
@@ -24313,7 +24441,7 @@ const makeOrchestrationEngine = gen(function* () {
|
|
|
24313
24441
|
const getReadModel = () => sync(() => readModel);
|
|
24314
24442
|
const readEvents = (fromSequenceExclusive) => eventStore.readFromSequence(fromSequenceExclusive);
|
|
24315
24443
|
const dispatch = (command) => gen(function* () {
|
|
24316
|
-
const result = yield* make$
|
|
24444
|
+
const result = yield* make$27();
|
|
24317
24445
|
yield* offer$1(commandQueue, {
|
|
24318
24446
|
command,
|
|
24319
24447
|
result
|
|
@@ -24353,8 +24481,8 @@ const OrchestrationEngineLive = effect(OrchestrationEngineService, makeOrchestra
|
|
|
24353
24481
|
*/
|
|
24354
24482
|
const makeDrainableWorker = (process) => gen(function* () {
|
|
24355
24483
|
const queue = yield* unbounded();
|
|
24356
|
-
const initialIdle = yield* make$
|
|
24357
|
-
yield* succeed$
|
|
24484
|
+
const initialIdle = yield* make$27();
|
|
24485
|
+
yield* succeed$5(initialIdle, void 0).pipe(orDie);
|
|
24358
24486
|
const state = yield* make$11({
|
|
24359
24487
|
outstanding: 0,
|
|
24360
24488
|
idle: initialIdle
|
|
@@ -24366,10 +24494,10 @@ const makeDrainableWorker = (process) => gen(function* () {
|
|
|
24366
24494
|
outstanding: remaining,
|
|
24367
24495
|
idle: current.idle
|
|
24368
24496
|
}];
|
|
24369
|
-
}).pipe(flatMap((idle) => idle === null ? void_$1 : succeed$
|
|
24497
|
+
}).pipe(flatMap((idle) => idle === null ? void_$1 : succeed$5(idle, void 0).pipe(orDie)));
|
|
24370
24498
|
yield* forkScoped(forever(take(queue).pipe(flatMap((item) => process(item).pipe(ensuring(finishOne))))));
|
|
24371
24499
|
const enqueue = (item) => gen(function* () {
|
|
24372
|
-
const nextIdle = yield* make$
|
|
24500
|
+
const nextIdle = yield* make$27();
|
|
24373
24501
|
yield* update(state, (current) => current.outstanding === 0 ? {
|
|
24374
24502
|
outstanding: 1,
|
|
24375
24503
|
idle: nextIdle
|
|
@@ -25021,7 +25149,7 @@ const make$6 = gen(function* () {
|
|
|
25021
25149
|
const thread = (yield* orchestrationEngine.getReadModel()).threads.find((entry) => entry.id === threadId);
|
|
25022
25150
|
const sessions = yield* providerService.listSessions();
|
|
25023
25151
|
const findSessionWithCwd = (session) => {
|
|
25024
|
-
if (!session?.cwd) return none
|
|
25152
|
+
if (!session?.cwd) return none();
|
|
25025
25153
|
return some({
|
|
25026
25154
|
threadId: session.threadId,
|
|
25027
25155
|
cwd: session.cwd
|
|
@@ -25031,7 +25159,7 @@ const make$6 = gen(function* () {
|
|
|
25031
25159
|
const fromProjected = findSessionWithCwd(sessions.find((session) => session.threadId === thread.id));
|
|
25032
25160
|
if (isSome(fromProjected)) return fromProjected;
|
|
25033
25161
|
}
|
|
25034
|
-
return none
|
|
25162
|
+
return none();
|
|
25035
25163
|
});
|
|
25036
25164
|
const isGitWorkspace = (cwd) => isGitRepository(cwd);
|
|
25037
25165
|
const resolveCheckpointCwd = fnUntraced(function* (input) {
|
|
@@ -25073,7 +25201,7 @@ const make$6 = gen(function* () {
|
|
|
25073
25201
|
fromCheckpointRef,
|
|
25074
25202
|
toCheckpointRef: targetCheckpointRef,
|
|
25075
25203
|
fallbackFromToHead: false
|
|
25076
|
-
}).pipe(map$
|
|
25204
|
+
}).pipe(map$2((summary) => summary.map((file) => ({
|
|
25077
25205
|
path: file.path,
|
|
25078
25206
|
kind: "modified",
|
|
25079
25207
|
additions: file.additions,
|
|
@@ -25669,12 +25797,12 @@ const make$5 = gen(function* () {
|
|
|
25669
25797
|
const providerService = yield* ProviderService;
|
|
25670
25798
|
const git = yield* GitCore;
|
|
25671
25799
|
const textGeneration = yield* TextGeneration;
|
|
25672
|
-
const handledTurnStartKeys = yield* make$
|
|
25800
|
+
const handledTurnStartKeys = yield* make$13({
|
|
25673
25801
|
capacity: HANDLED_TURN_START_KEY_MAX,
|
|
25674
25802
|
timeToLive: HANDLED_TURN_START_KEY_TTL,
|
|
25675
25803
|
lookup: () => succeed(true)
|
|
25676
25804
|
});
|
|
25677
|
-
const hasHandledTurnStartRecently = (key) => getOption(handledTurnStartKeys, key).pipe(flatMap((cached) => set$
|
|
25805
|
+
const hasHandledTurnStartRecently = (key) => getOption(handledTurnStartKeys, key).pipe(flatMap((cached) => set$2(handledTurnStartKeys, key, true).pipe(as(isSome(cached)))));
|
|
25678
25806
|
const threadProviderOptions = /* @__PURE__ */ new Map();
|
|
25679
25807
|
const threadModelSelections = /* @__PURE__ */ new Map();
|
|
25680
25808
|
const appendProviderFailureActivity = (input) => orchestrationEngine.dispatch({
|
|
@@ -25725,7 +25853,7 @@ const make$5 = gen(function* () {
|
|
|
25725
25853
|
projects: readModel.projects
|
|
25726
25854
|
});
|
|
25727
25855
|
const importedThreadResumeCursor = thread.origin === "external-import" && hasImportedThreadLineage(thread) && preferredProvider === "codex" ? { threadId } : void 0;
|
|
25728
|
-
const resolveActiveSession = (threadId) => providerService.listSessions().pipe(map$
|
|
25856
|
+
const resolveActiveSession = (threadId) => providerService.listSessions().pipe(map$2((sessions) => sessions.find((session) => session.threadId === threadId)));
|
|
25729
25857
|
const startProviderSession = (input) => providerService.startSession(threadId, {
|
|
25730
25858
|
threadId,
|
|
25731
25859
|
...preferredProvider ? { provider: preferredProvider } : {},
|
|
@@ -25801,7 +25929,7 @@ const make$5 = gen(function* () {
|
|
|
25801
25929
|
});
|
|
25802
25930
|
const normalizedInput = toNonEmptyProviderInput(input.messageText);
|
|
25803
25931
|
const normalizedAttachments = input.attachments ?? [];
|
|
25804
|
-
const activeSession = yield* providerService.listSessions().pipe(map$
|
|
25932
|
+
const activeSession = yield* providerService.listSessions().pipe(map$2((sessions) => sessions.find((session) => session.threadId === input.threadId)));
|
|
25805
25933
|
const sessionModelSwitch = activeSession === void 0 ? "in-session" : (yield* providerService.getCapabilities(activeSession.provider)).sessionModelSwitch;
|
|
25806
25934
|
const requestedModelSelection = input.modelSelection ?? threadModelSelections.get(input.threadId) ?? thread.modelSelection;
|
|
25807
25935
|
const modelForTurn = sessionModelSwitch === "unsupported" ? activeSession?.model !== void 0 ? {
|
|
@@ -29663,6 +29791,24 @@ const ENV_HINTS = [
|
|
|
29663
29791
|
"CODEX_PATH"
|
|
29664
29792
|
];
|
|
29665
29793
|
let cachedStatus = null;
|
|
29794
|
+
function getPathHintEntries() {
|
|
29795
|
+
const homeDir = process.env.HOME ?? process.env.USERPROFILE ?? "";
|
|
29796
|
+
const homeEntries = homeDir ? [
|
|
29797
|
+
path.join(homeDir, ".local", "bin"),
|
|
29798
|
+
path.join(homeDir, ".fnm", "aliases", "default", "bin"),
|
|
29799
|
+
path.join(homeDir, ".fnm", "current", "bin"),
|
|
29800
|
+
path.join(homeDir, ".volta", "bin"),
|
|
29801
|
+
path.join(homeDir, ".asdf", "shims"),
|
|
29802
|
+
path.join(homeDir, ".bun", "bin")
|
|
29803
|
+
] : [];
|
|
29804
|
+
const configuredHints = (process.env.CODEX_PATH_HINTS ?? "").split(path.delimiter).map((entry) => entry.trim()).filter(Boolean);
|
|
29805
|
+
return [
|
|
29806
|
+
"/opt/homebrew/bin",
|
|
29807
|
+
"/usr/local/bin",
|
|
29808
|
+
...homeEntries,
|
|
29809
|
+
...configuredHints
|
|
29810
|
+
];
|
|
29811
|
+
}
|
|
29666
29812
|
function fileExists$1(candidate) {
|
|
29667
29813
|
if (!candidate) return null;
|
|
29668
29814
|
const normalized = path.resolve(candidate);
|
|
@@ -29682,8 +29828,7 @@ function resolveCodexFromEnv() {
|
|
|
29682
29828
|
}
|
|
29683
29829
|
function resolveCodexFromPath() {
|
|
29684
29830
|
const pathValue = process.env.PATH ?? "";
|
|
29685
|
-
|
|
29686
|
-
const entries = pathValue.split(path.delimiter).map((entry) => entry.trim()).filter(Boolean);
|
|
29831
|
+
const entries = Array.from(new Set([...getPathHintEntries(), ...pathValue.split(path.delimiter).map((entry) => entry.trim()).filter(Boolean)].filter(Boolean)));
|
|
29687
29832
|
const names = process.platform === "win32" ? [
|
|
29688
29833
|
"codex.exe",
|
|
29689
29834
|
"codex.cmd",
|
|
@@ -32862,7 +33007,7 @@ const makeThreadSnapshotPreparation = gen(function* () {
|
|
|
32862
33007
|
importStateRepositories.messageRepository.listByThreadId({ threadId }),
|
|
32863
33008
|
importStateRepositories.activityRepository.listByThreadId({ threadId }),
|
|
32864
33009
|
importStateRepositories.proposedPlanRepository.listByThreadId({ threadId })
|
|
32865
|
-
], { concurrency: "inherit" }).pipe(map$
|
|
33010
|
+
], { concurrency: "inherit" }).pipe(map$2(([messages, activities, proposedPlans]) => {
|
|
32866
33011
|
const importedIdPrefix = `${threadId}:`;
|
|
32867
33012
|
return {
|
|
32868
33013
|
hasArtifacts: messages.length > 0 || activities.length > 0 || proposedPlans.length > 0,
|
|
@@ -33289,17 +33434,17 @@ const make$4 = gen(function* () {
|
|
|
33289
33434
|
const assistantDeliveryModeRef = yield* make$11(DEFAULT_ASSISTANT_DELIVERY_MODE);
|
|
33290
33435
|
const passiveImportedThreadRecoveryLastStartedAtMs = /* @__PURE__ */ new Map();
|
|
33291
33436
|
const passiveImportedThreadRecoveryInFlight = /* @__PURE__ */ new Map();
|
|
33292
|
-
const turnMessageIdsByTurnKey = yield* make$
|
|
33437
|
+
const turnMessageIdsByTurnKey = yield* make$13({
|
|
33293
33438
|
capacity: TURN_MESSAGE_IDS_BY_TURN_CACHE_CAPACITY,
|
|
33294
33439
|
timeToLive: TURN_MESSAGE_IDS_BY_TURN_TTL,
|
|
33295
33440
|
lookup: () => succeed(/* @__PURE__ */ new Set())
|
|
33296
33441
|
});
|
|
33297
|
-
const bufferedAssistantTextByMessageId = yield* make$
|
|
33442
|
+
const bufferedAssistantTextByMessageId = yield* make$13({
|
|
33298
33443
|
capacity: BUFFERED_MESSAGE_TEXT_BY_MESSAGE_ID_CACHE_CAPACITY,
|
|
33299
33444
|
timeToLive: BUFFERED_MESSAGE_TEXT_BY_MESSAGE_ID_TTL,
|
|
33300
33445
|
lookup: () => succeed("")
|
|
33301
33446
|
});
|
|
33302
|
-
const bufferedProposedPlanById = yield* make$
|
|
33447
|
+
const bufferedProposedPlanById = yield* make$13({
|
|
33303
33448
|
capacity: BUFFERED_PROPOSED_PLAN_BY_ID_CACHE_CAPACITY,
|
|
33304
33449
|
timeToLive: BUFFERED_PROPOSED_PLAN_BY_ID_TTL,
|
|
33305
33450
|
lookup: () => succeed({
|
|
@@ -33318,7 +33463,7 @@ const make$4 = gen(function* () {
|
|
|
33318
33463
|
if (!workspaceCwd) return false;
|
|
33319
33464
|
return isGitRepository(workspaceCwd);
|
|
33320
33465
|
});
|
|
33321
|
-
const rememberAssistantMessageId = (threadId, turnId, messageId) => getOption(turnMessageIdsByTurnKey, providerTurnKey(threadId, turnId)).pipe(flatMap((existingIds) => set$
|
|
33466
|
+
const rememberAssistantMessageId = (threadId, turnId, messageId) => getOption(turnMessageIdsByTurnKey, providerTurnKey(threadId, turnId)).pipe(flatMap((existingIds) => set$2(turnMessageIdsByTurnKey, providerTurnKey(threadId, turnId), match(existingIds, {
|
|
33322
33467
|
onNone: () => new Set([messageId]),
|
|
33323
33468
|
onSome: (ids) => {
|
|
33324
33469
|
const nextIds = new Set(ids);
|
|
@@ -33332,10 +33477,10 @@ const make$4 = gen(function* () {
|
|
|
33332
33477
|
const nextIds = new Set(ids);
|
|
33333
33478
|
nextIds.delete(messageId);
|
|
33334
33479
|
if (nextIds.size === 0) return invalidate(turnMessageIdsByTurnKey, providerTurnKey(threadId, turnId));
|
|
33335
|
-
return set$
|
|
33480
|
+
return set$2(turnMessageIdsByTurnKey, providerTurnKey(threadId, turnId), nextIds);
|
|
33336
33481
|
}
|
|
33337
33482
|
})));
|
|
33338
|
-
const getAssistantMessageIdsForTurn = (threadId, turnId) => getOption(turnMessageIdsByTurnKey, providerTurnKey(threadId, turnId)).pipe(map$
|
|
33483
|
+
const getAssistantMessageIdsForTurn = (threadId, turnId) => getOption(turnMessageIdsByTurnKey, providerTurnKey(threadId, turnId)).pipe(map$2((existingIds) => getOrElse(existingIds, () => /* @__PURE__ */ new Set())));
|
|
33339
33484
|
const clearAssistantMessageIdsForTurn = (threadId, turnId) => invalidate(turnMessageIdsByTurnKey, providerTurnKey(threadId, turnId));
|
|
33340
33485
|
const appendBufferedAssistantText = (messageId, delta) => getOption(bufferedAssistantTextByMessageId, messageId).pipe(flatMap((existingText) => gen(function* () {
|
|
33341
33486
|
const nextText = match(existingText, {
|
|
@@ -33343,7 +33488,7 @@ const make$4 = gen(function* () {
|
|
|
33343
33488
|
onSome: (text) => `${text}${delta}`
|
|
33344
33489
|
});
|
|
33345
33490
|
if (nextText.length <= MAX_BUFFERED_ASSISTANT_CHARS) {
|
|
33346
|
-
yield* set$
|
|
33491
|
+
yield* set$2(bufferedAssistantTextByMessageId, messageId, nextText);
|
|
33347
33492
|
return "";
|
|
33348
33493
|
}
|
|
33349
33494
|
yield* invalidate(bufferedAssistantTextByMessageId, messageId);
|
|
@@ -33353,7 +33498,7 @@ const make$4 = gen(function* () {
|
|
|
33353
33498
|
const clearBufferedAssistantText = (messageId) => invalidate(bufferedAssistantTextByMessageId, messageId);
|
|
33354
33499
|
const appendBufferedProposedPlan = (planId, delta, createdAt) => getOption(bufferedProposedPlanById, planId).pipe(flatMap((existingEntry) => {
|
|
33355
33500
|
const existing = getOrUndefined(existingEntry);
|
|
33356
|
-
return set$
|
|
33501
|
+
return set$2(bufferedProposedPlanById, planId, {
|
|
33357
33502
|
text: `${existing?.text ?? ""}${delta}`,
|
|
33358
33503
|
createdAt: existing?.createdAt && existing.createdAt.length > 0 ? existing.createdAt : createdAt
|
|
33359
33504
|
});
|
|
@@ -35200,7 +35345,7 @@ function makeThreadWriter(input) {
|
|
|
35200
35345
|
return;
|
|
35201
35346
|
}
|
|
35202
35347
|
const sink = sinkResult.sink;
|
|
35203
|
-
const scope = yield* make$
|
|
35348
|
+
const scope = yield* make$28();
|
|
35204
35349
|
const loggerLayer = layer$1([yield* batched(makeLineLogger(input.streamLabel), {
|
|
35205
35350
|
window: input.batchWindowMs,
|
|
35206
35351
|
flush: (messages) => gen(function* () {
|
|
@@ -36077,7 +36222,7 @@ const makeCodexAdapter = (options) => gen(function* () {
|
|
|
36077
36222
|
detail: toMessage(cause, "Failed to start Codex adapter session."),
|
|
36078
36223
|
cause
|
|
36079
36224
|
})
|
|
36080
|
-
}).pipe(map$
|
|
36225
|
+
}).pipe(map$2((session) => session));
|
|
36081
36226
|
};
|
|
36082
36227
|
const sendTurn = (input) => gen(function* () {
|
|
36083
36228
|
const codexAttachments = yield* forEach(input.attachments ?? [], (attachment) => gen(function* () {
|
|
@@ -36111,7 +36256,7 @@ const makeCodexAdapter = (options) => gen(function* () {
|
|
|
36111
36256
|
return manager.sendTurn(managerInput);
|
|
36112
36257
|
},
|
|
36113
36258
|
catch: (cause) => toRequestError(input.threadId, "turn/start", cause)
|
|
36114
|
-
}).pipe(map$
|
|
36259
|
+
}).pipe(map$2((result) => ({
|
|
36115
36260
|
...result,
|
|
36116
36261
|
threadId: input.threadId
|
|
36117
36262
|
})));
|
|
@@ -36123,7 +36268,7 @@ const makeCodexAdapter = (options) => gen(function* () {
|
|
|
36123
36268
|
const readThread = (threadId) => tryPromise({
|
|
36124
36269
|
try: () => manager.readThread(threadId),
|
|
36125
36270
|
catch: (cause) => toRequestError(threadId, "thread/read", cause)
|
|
36126
|
-
}).pipe(map$
|
|
36271
|
+
}).pipe(map$2((snapshot) => ({
|
|
36127
36272
|
threadId,
|
|
36128
36273
|
turns: snapshot.turns
|
|
36129
36274
|
})));
|
|
@@ -36136,7 +36281,7 @@ const makeCodexAdapter = (options) => gen(function* () {
|
|
|
36136
36281
|
return tryPromise({
|
|
36137
36282
|
try: () => manager.rollbackThread(threadId, numTurns),
|
|
36138
36283
|
catch: (cause) => toRequestError(threadId, "thread/rollback", cause)
|
|
36139
|
-
}).pipe(map$
|
|
36284
|
+
}).pipe(map$2((snapshot) => ({
|
|
36140
36285
|
threadId,
|
|
36141
36286
|
turns: snapshot.turns
|
|
36142
36287
|
})));
|
|
@@ -36510,7 +36655,7 @@ const makeProviderService = (options) => gen(function* () {
|
|
|
36510
36655
|
});
|
|
36511
36656
|
const listSessions = () => gen(function* () {
|
|
36512
36657
|
const activeSessions = (yield* forEach(adapters, (adapter) => adapter.listSessions())).flatMap((sessions) => sessions);
|
|
36513
|
-
const persistedBindings = yield* directory.listThreadIds().pipe(flatMap((threadIds) => forEach(threadIds, (threadId) => directory.getBinding(threadId).pipe(orElseSucceed(() => none
|
|
36658
|
+
const persistedBindings = yield* directory.listThreadIds().pipe(flatMap((threadIds) => forEach(threadIds, (threadId) => directory.getBinding(threadId).pipe(orElseSucceed(() => none())), { concurrency: "unbounded" })), orElseSucceed(() => []));
|
|
36514
36659
|
const bindingsByThreadId = /* @__PURE__ */ new Map();
|
|
36515
36660
|
for (const bindingOption of persistedBindings) {
|
|
36516
36661
|
const binding = getOrUndefined(bindingOption);
|
|
@@ -36525,7 +36670,7 @@ const makeProviderService = (options) => gen(function* () {
|
|
|
36525
36670
|
return Object.assign({}, session, overrides);
|
|
36526
36671
|
});
|
|
36527
36672
|
});
|
|
36528
|
-
const getCapabilities = (provider) => registry.getByProvider(provider).pipe(map$
|
|
36673
|
+
const getCapabilities = (provider) => registry.getByProvider(provider).pipe(map$2((adapter) => adapter.capabilities));
|
|
36529
36674
|
const rollbackConversation = (rawInput) => gen(function* () {
|
|
36530
36675
|
const input = yield* decodeInputOrValidationError({
|
|
36531
36676
|
operation: "ProviderService.rollbackConversation",
|
|
@@ -36603,8 +36748,8 @@ function mergeRuntimePayload(existing, next) {
|
|
|
36603
36748
|
const makeProviderSessionDirectory = gen(function* () {
|
|
36604
36749
|
const repository = yield* ProviderSessionRuntimeRepository;
|
|
36605
36750
|
const getBinding = (threadId) => repository.getByThreadId({ threadId }).pipe(mapError(toPersistenceError("ProviderSessionDirectory.getBinding:getByThreadId")), flatMap((runtime) => match(runtime, {
|
|
36606
|
-
onNone: () => succeed(none
|
|
36607
|
-
onSome: (value) => decodeProviderKind(value.providerName, "ProviderSessionDirectory.getBinding").pipe(map$
|
|
36751
|
+
onNone: () => succeed(none()),
|
|
36752
|
+
onSome: (value) => decodeProviderKind(value.providerName, "ProviderSessionDirectory.getBinding").pipe(map$2((provider) => some({
|
|
36608
36753
|
threadId: value.threadId,
|
|
36609
36754
|
provider,
|
|
36610
36755
|
adapterKey: value.adapterKey,
|
|
@@ -36642,7 +36787,7 @@ const makeProviderSessionDirectory = gen(function* () {
|
|
|
36642
36787
|
}))
|
|
36643
36788
|
})));
|
|
36644
36789
|
const remove = (threadId) => repository.deleteByThreadId({ threadId }).pipe(mapError(toPersistenceError("ProviderSessionDirectory.remove:deleteByThreadId")));
|
|
36645
|
-
const listThreadIds = () => repository.list().pipe(mapError(toPersistenceError("ProviderSessionDirectory.listThreadIds:list")), map$
|
|
36790
|
+
const listThreadIds = () => repository.list().pipe(mapError(toPersistenceError("ProviderSessionDirectory.listThreadIds:list")), map$2((rows) => rows.map((row) => row.threadId)));
|
|
36646
36791
|
return {
|
|
36647
36792
|
upsert,
|
|
36648
36793
|
getProvider,
|
|
@@ -37946,7 +38091,7 @@ function compileResolvedKeybindingsConfig(config) {
|
|
|
37946
38091
|
return compiled;
|
|
37947
38092
|
}
|
|
37948
38093
|
const ResolvedKeybindingFromConfig = KeybindingRule.pipe(decodeTo(toType(ResolvedKeybindingRule), transformOrFail({
|
|
37949
|
-
decode: (rule) => succeed(compileResolvedKeybindingRule(rule)).pipe(filterOrFail(isNotNull, () => new InvalidValue$1(some(rule), { title: "Invalid keybinding rule" })), map$
|
|
38094
|
+
decode: (rule) => succeed(compileResolvedKeybindingRule(rule)).pipe(filterOrFail(isNotNull, () => new InvalidValue$1(some(rule), { title: "Invalid keybinding rule" })), map$2((resolved) => resolved)),
|
|
37950
38095
|
encode: (resolved) => gen(function* () {
|
|
37951
38096
|
const key = encodeShortcut(resolved.shortcut);
|
|
37952
38097
|
if (!key) return yield* fail$1(new InvalidValue$1(some(resolved), { title: "Resolved shortcut cannot be encoded to key string" }));
|
|
@@ -38034,11 +38179,11 @@ const makeKeybindings = gen(function* () {
|
|
|
38034
38179
|
const { keybindingsConfigPath, stateDir } = yield* ServerConfig$1;
|
|
38035
38180
|
const fs = yield* FileSystem;
|
|
38036
38181
|
const path = yield* Path$1;
|
|
38037
|
-
const upsertSemaphore = yield* make$
|
|
38182
|
+
const upsertSemaphore = yield* make$29(1);
|
|
38038
38183
|
const resolvedConfigCacheKey = "resolved";
|
|
38039
38184
|
const changesPubSub = yield* unbounded$1();
|
|
38040
38185
|
const startedRef = yield* make$11(false);
|
|
38041
|
-
const startedDeferred = yield* make$
|
|
38186
|
+
const startedDeferred = yield* make$27();
|
|
38042
38187
|
const keybindingsDbPath = path.join(stateDir, SQLITE_DB_FILE);
|
|
38043
38188
|
const emitChange = (configState) => publish(changesPubSub, configState).pipe(asVoid);
|
|
38044
38189
|
const readStoredRawConfig = tryPromise({
|
|
@@ -38074,7 +38219,7 @@ const makeKeybindings = gen(function* () {
|
|
|
38074
38219
|
yield* fs.remove(keybindingsConfigPath).pipe(orElseSucceed(() => void 0));
|
|
38075
38220
|
return rawConfig;
|
|
38076
38221
|
});
|
|
38077
|
-
const readRawConfig = importLegacyRawConfigOnce().pipe(map$
|
|
38222
|
+
const readRawConfig = importLegacyRawConfigOnce().pipe(map$2((rawConfig) => rawConfig ?? "[]"), mapError((cause) => new KeybindingsConfigError({
|
|
38078
38223
|
configPath: keybindingsConfigPath,
|
|
38079
38224
|
detail: "failed to read keybindings config",
|
|
38080
38225
|
cause
|
|
@@ -38104,7 +38249,7 @@ const makeKeybindings = gen(function* () {
|
|
|
38104
38249
|
return null;
|
|
38105
38250
|
}
|
|
38106
38251
|
return decodedRule.value;
|
|
38107
|
-
})).pipe(map$
|
|
38252
|
+
})).pipe(map$2(filter(isNotNull)));
|
|
38108
38253
|
});
|
|
38109
38254
|
const loadRuntimeCustomKeybindingsConfig = fn(function* () {
|
|
38110
38255
|
const rawConfig = yield* readRawConfig;
|
|
@@ -38148,21 +38293,21 @@ const makeKeybindings = gen(function* () {
|
|
|
38148
38293
|
};
|
|
38149
38294
|
});
|
|
38150
38295
|
const writeConfigAtomically = (rules) => {
|
|
38151
|
-
return encodeEffect(KeybindingsConfigPrettyJson)(rules).pipe(map$
|
|
38296
|
+
return encodeEffect(KeybindingsConfigPrettyJson)(rules).pipe(map$2((encoded) => `${encoded}\n`), flatMap((encoded) => writeStoredRawConfig(encoded)), mapError((cause) => new KeybindingsConfigError({
|
|
38152
38297
|
configPath: keybindingsConfigPath,
|
|
38153
38298
|
detail: "failed to write keybindings config",
|
|
38154
38299
|
cause
|
|
38155
38300
|
})));
|
|
38156
38301
|
};
|
|
38157
|
-
const loadConfigStateFromDisk = loadRuntimeCustomKeybindingsConfig().pipe(map$
|
|
38302
|
+
const loadConfigStateFromDisk = loadRuntimeCustomKeybindingsConfig().pipe(map$2(({ keybindings, issues }) => ({
|
|
38158
38303
|
keybindings: mergeWithDefaultKeybindings(compileResolvedKeybindingsConfig(keybindings)),
|
|
38159
38304
|
issues
|
|
38160
38305
|
})));
|
|
38161
|
-
const resolvedConfigCache = yield* make$
|
|
38306
|
+
const resolvedConfigCache = yield* make$13({
|
|
38162
38307
|
capacity: 1,
|
|
38163
38308
|
lookup: () => loadConfigStateFromDisk
|
|
38164
38309
|
});
|
|
38165
|
-
const loadConfigStateFromCacheOrDisk = get$
|
|
38310
|
+
const loadConfigStateFromCacheOrDisk = get$1(resolvedConfigCache, resolvedConfigCacheKey);
|
|
38166
38311
|
upsertSemaphore.withPermits(1)(gen(function* () {
|
|
38167
38312
|
yield* invalidate(resolvedConfigCache, resolvedConfigCacheKey);
|
|
38168
38313
|
yield* emitChange(yield* loadConfigStateFromCacheOrDisk);
|
|
@@ -38223,7 +38368,7 @@ const makeKeybindings = gen(function* () {
|
|
|
38223
38368
|
yield* failCause$1(startedDeferred, startupExit.cause).pipe(orDie);
|
|
38224
38369
|
return yield* failCause(startupExit.cause);
|
|
38225
38370
|
}
|
|
38226
|
-
yield* succeed$
|
|
38371
|
+
yield* succeed$5(startedDeferred, void 0).pipe(orDie);
|
|
38227
38372
|
}),
|
|
38228
38373
|
ready: _await(startedDeferred),
|
|
38229
38374
|
syncDefaultKeybindingsOnStartup,
|
|
@@ -38241,7 +38386,7 @@ const makeKeybindings = gen(function* () {
|
|
|
38241
38386
|
});
|
|
38242
38387
|
yield* writeConfigAtomically(cappedConfig);
|
|
38243
38388
|
const nextResolved = mergeWithDefaultKeybindings(compileResolvedKeybindingsConfig(cappedConfig));
|
|
38244
|
-
yield* set$
|
|
38389
|
+
yield* set$2(resolvedConfigCache, resolvedConfigCacheKey, {
|
|
38245
38390
|
keybindings: nextResolved,
|
|
38246
38391
|
issues: []
|
|
38247
38392
|
});
|
|
@@ -38672,7 +38817,7 @@ const makeGitManager = gen(function* () {
|
|
|
38672
38817
|
"--json",
|
|
38673
38818
|
"number,title,url,baseRefName,headRefName,state,mergedAt,updatedAt"
|
|
38674
38819
|
]
|
|
38675
|
-
}).pipe(map$
|
|
38820
|
+
}).pipe(map$2((result) => result.stdout))).trim();
|
|
38676
38821
|
if (raw.length === 0) continue;
|
|
38677
38822
|
const parsedJson = yield* try_({
|
|
38678
38823
|
try: () => JSON.parse(raw),
|
|
@@ -38720,7 +38865,7 @@ const makeGitManager = gen(function* () {
|
|
|
38720
38865
|
stagedPatch: limitContext(context.stagedPatch, 5e4),
|
|
38721
38866
|
...input.includeBranch ? { includeBranch: true } : {},
|
|
38722
38867
|
...input.model ? { model: input.model } : {}
|
|
38723
|
-
}).pipe(map$
|
|
38868
|
+
}).pipe(map$2((result) => sanitizeCommitMessage(result)), catch_((error) => logWarning$1(`GitManager.resolveCommitAndBranchSuggestion: falling back to a generic commit message for ${input.cwd}: ${error instanceof Error ? error.message : String(error)}`).pipe(as(buildFallbackCommitAndBranchSuggestion({
|
|
38724
38869
|
stagedSummary: context.stagedSummary,
|
|
38725
38870
|
includeBranch: input.includeBranch
|
|
38726
38871
|
})))));
|
|
@@ -38827,7 +38972,7 @@ const makeGitManager = gen(function* () {
|
|
|
38827
38972
|
const pr = details.branch !== null ? yield* findLatestPr(input.cwd, {
|
|
38828
38973
|
branch: details.branch,
|
|
38829
38974
|
upstreamRef: details.upstreamRef
|
|
38830
|
-
}).pipe(map$
|
|
38975
|
+
}).pipe(map$2((latest) => latest ? toStatusPr(latest) : null), catch_(() => succeed(null))) : null;
|
|
38831
38976
|
return {
|
|
38832
38977
|
branch: details.branch,
|
|
38833
38978
|
hasWorkingTreeChanges: details.hasWorkingTreeChanges,
|
|
@@ -38842,7 +38987,7 @@ const makeGitManager = gen(function* () {
|
|
|
38842
38987
|
return { pullRequest: yield* gitHubCli.getPullRequest({
|
|
38843
38988
|
cwd: input.cwd,
|
|
38844
38989
|
reference: normalizePullRequestReference(input.reference)
|
|
38845
|
-
}).pipe(map$
|
|
38990
|
+
}).pipe(map$2((resolved) => toResolvedPullRequest(resolved))) };
|
|
38846
38991
|
});
|
|
38847
38992
|
const preparePullRequestThread = fnUntraced(function* (input) {
|
|
38848
38993
|
const normalizedReference = normalizePullRequestReference(input.reference);
|
|
@@ -38881,7 +39026,7 @@ const makeGitManager = gen(function* () {
|
|
|
38881
39026
|
...toPullRequestHeadRemoteInfo(pullRequestSummary)
|
|
38882
39027
|
};
|
|
38883
39028
|
const localPullRequestBranch = resolvePullRequestWorktreeLocalBranchName(pullRequestWithRemoteInfo);
|
|
38884
|
-
const findLocalHeadBranch = (cwd) => gitCore.listBranches({ cwd }).pipe(map$
|
|
39029
|
+
const findLocalHeadBranch = (cwd) => gitCore.listBranches({ cwd }).pipe(map$2((result) => {
|
|
38885
39030
|
const localBranch = result.branches.find((branch) => !branch.isRemote && branch.name === localPullRequestBranch);
|
|
38886
39031
|
if (localBranch) return localBranch;
|
|
38887
39032
|
if (localPullRequestBranch === pullRequest.headBranch) return null;
|
|
@@ -39188,7 +39333,7 @@ const makeGitCore = gen(function* () {
|
|
|
39188
39333
|
return fail$1(createGitCommandError(operation, cwd, args, `${commandLabel(args)} failed: code=${result.code ?? "null"}`));
|
|
39189
39334
|
}));
|
|
39190
39335
|
const runGit = (operation, cwd, args, allowNonZeroExit = false) => executeGit(operation, cwd, args, { allowNonZeroExit }).pipe(asVoid);
|
|
39191
|
-
const runGitStdout = (operation, cwd, args, allowNonZeroExit = false) => executeGit(operation, cwd, args, { allowNonZeroExit }).pipe(map$
|
|
39336
|
+
const runGitStdout = (operation, cwd, args, allowNonZeroExit = false) => executeGit(operation, cwd, args, { allowNonZeroExit }).pipe(map$2((result) => result.stdout));
|
|
39192
39337
|
const branchExists = (cwd, branch) => executeGit("GitCore.branchExists", cwd, [
|
|
39193
39338
|
"show-ref",
|
|
39194
39339
|
"--verify",
|
|
@@ -39197,7 +39342,7 @@ const makeGitCore = gen(function* () {
|
|
|
39197
39342
|
], {
|
|
39198
39343
|
allowNonZeroExit: true,
|
|
39199
39344
|
timeoutMs: 5e3
|
|
39200
|
-
}).pipe(map$
|
|
39345
|
+
}).pipe(map$2((result) => result.code === 0));
|
|
39201
39346
|
const resolveAvailableBranchName = (cwd, desiredBranch) => gen(function* () {
|
|
39202
39347
|
if (!(yield* branchExists(cwd, desiredBranch))) return desiredBranch;
|
|
39203
39348
|
for (let suffix = 1; suffix <= 100; suffix += 1) {
|
|
@@ -39217,7 +39362,7 @@ const makeGitCore = gen(function* () {
|
|
|
39217
39362
|
"--abbrev-ref",
|
|
39218
39363
|
"--symbolic-full-name",
|
|
39219
39364
|
"@{upstream}"
|
|
39220
|
-
], true).pipe(map$
|
|
39365
|
+
], true).pipe(map$2((stdout) => stdout.trim()));
|
|
39221
39366
|
if (upstreamRef.length === 0 || upstreamRef === "@{upstream}") return null;
|
|
39222
39367
|
const separatorIndex = upstreamRef.indexOf("/");
|
|
39223
39368
|
if (separatorIndex <= 0) return null;
|
|
@@ -39268,7 +39413,7 @@ const makeGitCore = gen(function* () {
|
|
|
39268
39413
|
const refreshStatusUpstreamIfStale = (cwd) => gen(function* () {
|
|
39269
39414
|
const upstream = yield* resolveCurrentUpstream(cwd);
|
|
39270
39415
|
if (!upstream) return;
|
|
39271
|
-
yield* get$
|
|
39416
|
+
yield* get$1(statusUpstreamRefreshCache, new StatusUpstreamRefreshCacheKey({
|
|
39272
39417
|
cwd,
|
|
39273
39418
|
upstreamRef: upstream.upstreamRef,
|
|
39274
39419
|
remoteName: upstream.remoteName,
|
|
@@ -39280,7 +39425,7 @@ const makeGitCore = gen(function* () {
|
|
|
39280
39425
|
if (!upstream) return;
|
|
39281
39426
|
yield* fetchUpstreamRef(cwd, upstream);
|
|
39282
39427
|
});
|
|
39283
|
-
const resolveDefaultBranchName = (cwd, remoteName) => executeGit("GitCore.resolveDefaultBranchName", cwd, ["symbolic-ref", `refs/remotes/${remoteName}/HEAD`], { allowNonZeroExit: true }).pipe(map$
|
|
39428
|
+
const resolveDefaultBranchName = (cwd, remoteName) => executeGit("GitCore.resolveDefaultBranchName", cwd, ["symbolic-ref", `refs/remotes/${remoteName}/HEAD`], { allowNonZeroExit: true }).pipe(map$2((result) => {
|
|
39284
39429
|
if (result.code !== 0) return null;
|
|
39285
39430
|
return parseDefaultBranchFromRemoteHeadRef(result.stdout, remoteName);
|
|
39286
39431
|
}));
|
|
@@ -39289,13 +39434,13 @@ const makeGitCore = gen(function* () {
|
|
|
39289
39434
|
"--verify",
|
|
39290
39435
|
"--quiet",
|
|
39291
39436
|
`refs/remotes/${remoteName}/${branch}`
|
|
39292
|
-
], { allowNonZeroExit: true }).pipe(map$
|
|
39437
|
+
], { allowNonZeroExit: true }).pipe(map$2((result) => result.code === 0));
|
|
39293
39438
|
const originRemoteExists = (cwd) => executeGit("GitCore.originRemoteExists", cwd, [
|
|
39294
39439
|
"remote",
|
|
39295
39440
|
"get-url",
|
|
39296
39441
|
"origin"
|
|
39297
|
-
], { allowNonZeroExit: true }).pipe(map$
|
|
39298
|
-
const listRemoteNames = (cwd) => runGitStdout("GitCore.listRemoteNames", cwd, ["remote"]).pipe(map$
|
|
39442
|
+
], { allowNonZeroExit: true }).pipe(map$2((result) => result.code === 0));
|
|
39443
|
+
const listRemoteNames = (cwd) => runGitStdout("GitCore.listRemoteNames", cwd, ["remote"]).pipe(map$2((stdout) => parseRemoteNames(stdout).toReversed()));
|
|
39299
39444
|
const resolvePrimaryRemoteName = (cwd) => gen(function* () {
|
|
39300
39445
|
if (yield* originRemoteExists(cwd)) return "origin";
|
|
39301
39446
|
const [firstRemote] = yield* listRemoteNames(cwd);
|
|
@@ -39307,20 +39452,20 @@ const makeGitCore = gen(function* () {
|
|
|
39307
39452
|
"config",
|
|
39308
39453
|
"--get",
|
|
39309
39454
|
`branch.${branch}.pushRemote`
|
|
39310
|
-
], true).pipe(map$
|
|
39455
|
+
], true).pipe(map$2((stdout) => stdout.trim()));
|
|
39311
39456
|
if (branchPushRemote.length > 0) return branchPushRemote;
|
|
39312
39457
|
const pushDefaultRemote = yield* runGitStdout("GitCore.resolvePushRemoteName.remotePushDefault", cwd, [
|
|
39313
39458
|
"config",
|
|
39314
39459
|
"--get",
|
|
39315
39460
|
"remote.pushDefault"
|
|
39316
|
-
], true).pipe(map$
|
|
39461
|
+
], true).pipe(map$2((stdout) => stdout.trim()));
|
|
39317
39462
|
if (pushDefaultRemote.length > 0) return pushDefaultRemote;
|
|
39318
39463
|
return yield* resolvePrimaryRemoteName(cwd).pipe(catch_(() => succeed(null)));
|
|
39319
39464
|
});
|
|
39320
39465
|
const ensureRemote = (input) => gen(function* () {
|
|
39321
39466
|
const preferredName = sanitizeRemoteName(input.preferredName);
|
|
39322
39467
|
const normalizedTargetUrl = normalizeRemoteUrl(input.url);
|
|
39323
|
-
const remoteFetchUrls = yield* runGitStdout("GitCore.ensureRemote.listRemoteUrls", input.cwd, ["remote", "-v"]).pipe(map$
|
|
39468
|
+
const remoteFetchUrls = yield* runGitStdout("GitCore.ensureRemote.listRemoteUrls", input.cwd, ["remote", "-v"]).pipe(map$2((stdout) => parseRemoteFetchUrls(stdout)));
|
|
39324
39469
|
for (const [remoteName, remoteUrl] of remoteFetchUrls.entries()) if (normalizeRemoteUrl(remoteUrl) === normalizedTargetUrl) return remoteName;
|
|
39325
39470
|
let remoteName = preferredName;
|
|
39326
39471
|
let suffix = 1;
|
|
@@ -39341,7 +39486,7 @@ const makeGitCore = gen(function* () {
|
|
|
39341
39486
|
"config",
|
|
39342
39487
|
"--get",
|
|
39343
39488
|
`branch.${branch}.gh-merge-base`
|
|
39344
|
-
], true).pipe(map$
|
|
39489
|
+
], true).pipe(map$2((stdout) => stdout.trim()));
|
|
39345
39490
|
const primaryRemoteName = yield* resolvePrimaryRemoteName(cwd).pipe(catch_(() => succeed(null)));
|
|
39346
39491
|
const defaultBranch = primaryRemoteName === null ? null : yield* resolveDefaultBranchName(cwd, primaryRemoteName);
|
|
39347
39492
|
const candidates = [
|
|
@@ -39486,7 +39631,7 @@ const makeGitCore = gen(function* () {
|
|
|
39486
39631
|
behindCount
|
|
39487
39632
|
};
|
|
39488
39633
|
});
|
|
39489
|
-
const status = (input) => statusDetails(input.cwd).pipe(map$
|
|
39634
|
+
const status = (input) => statusDetails(input.cwd).pipe(map$2((details) => ({
|
|
39490
39635
|
branch: details.branch,
|
|
39491
39636
|
hasWorkingTreeChanges: details.hasWorkingTreeChanges,
|
|
39492
39637
|
workingTree: details.workingTree,
|
|
@@ -39509,7 +39654,7 @@ const makeGitCore = gen(function* () {
|
|
|
39509
39654
|
"diff",
|
|
39510
39655
|
"--cached",
|
|
39511
39656
|
"--name-status"
|
|
39512
|
-
]).pipe(map$
|
|
39657
|
+
]).pipe(map$2((stdout) => stdout.trim()));
|
|
39513
39658
|
if (stagedSummary.length === 0) return null;
|
|
39514
39659
|
const changedFileCount = stagedSummary.split(/\r?\n/g).filter((line) => line.trim().length > 0).length;
|
|
39515
39660
|
if (changedFileCount > LARGE_COMMIT_PATCH_MAX_FILES) return {
|
|
@@ -39537,7 +39682,7 @@ const makeGitCore = gen(function* () {
|
|
|
39537
39682
|
const trimmedBody = body.trim();
|
|
39538
39683
|
if (trimmedBody.length > 0) args.push("-m", trimmedBody);
|
|
39539
39684
|
yield* runGit("GitCore.commit.commit", cwd, args);
|
|
39540
|
-
return { commitSha: yield* runGitStdout("GitCore.commit.revParseHead", cwd, ["rev-parse", "HEAD"]).pipe(map$
|
|
39685
|
+
return { commitSha: yield* runGitStdout("GitCore.commit.revParseHead", cwd, ["rev-parse", "HEAD"]).pipe(map$2((stdout) => stdout.trim())) };
|
|
39541
39686
|
});
|
|
39542
39687
|
const pushCurrentBranch = (cwd, fallbackBranch) => gen(function* () {
|
|
39543
39688
|
const details = yield* statusDetails(cwd);
|
|
@@ -39604,12 +39749,12 @@ const makeGitCore = gen(function* () {
|
|
|
39604
39749
|
const branch = details.branch;
|
|
39605
39750
|
if (!branch) return yield* createGitCommandError("GitCore.pullCurrentBranch", cwd, ["pull", "--ff-only"], "Cannot pull from detached HEAD.");
|
|
39606
39751
|
if (!details.hasUpstream) return yield* createGitCommandError("GitCore.pullCurrentBranch", cwd, ["pull", "--ff-only"], "Current branch has no upstream configured. Push with upstream first.");
|
|
39607
|
-
const beforeSha = yield* runGitStdout("GitCore.pullCurrentBranch.beforeSha", cwd, ["rev-parse", "HEAD"], true).pipe(map$
|
|
39752
|
+
const beforeSha = yield* runGitStdout("GitCore.pullCurrentBranch.beforeSha", cwd, ["rev-parse", "HEAD"], true).pipe(map$2((stdout) => stdout.trim()));
|
|
39608
39753
|
yield* executeGit("GitCore.pullCurrentBranch.pull", cwd, ["pull", "--ff-only"], {
|
|
39609
39754
|
timeoutMs: 3e4,
|
|
39610
39755
|
fallbackErrorMessage: "git pull failed"
|
|
39611
39756
|
});
|
|
39612
|
-
const afterSha = yield* runGitStdout("GitCore.pullCurrentBranch.afterSha", cwd, ["rev-parse", "HEAD"], true).pipe(map$
|
|
39757
|
+
const afterSha = yield* runGitStdout("GitCore.pullCurrentBranch.afterSha", cwd, ["rev-parse", "HEAD"], true).pipe(map$2((stdout) => stdout.trim()));
|
|
39613
39758
|
const refreshed = yield* statusDetails(cwd);
|
|
39614
39759
|
return {
|
|
39615
39760
|
status: beforeSha.length > 0 && beforeSha === afterSha ? "skipped_up_to_date" : "pulled",
|
|
@@ -39647,7 +39792,7 @@ const makeGitCore = gen(function* () {
|
|
|
39647
39792
|
"config",
|
|
39648
39793
|
"--get",
|
|
39649
39794
|
key
|
|
39650
|
-
], true).pipe(map$
|
|
39795
|
+
], true).pipe(map$2((stdout) => stdout.trim()), map$2((trimmed) => trimmed.length > 0 ? trimmed : null));
|
|
39651
39796
|
const listBranches = (input) => gen(function* () {
|
|
39652
39797
|
const branchRecencyPromise = readBranchRecency(input.cwd).pipe(catch_(() => succeed(/* @__PURE__ */ new Map())));
|
|
39653
39798
|
const localBranchResult = yield* executeGit("GitCore.listBranches.branchNoColor", input.cwd, ["branch", "--no-color"], {
|
|
@@ -39709,7 +39854,7 @@ const makeGitCore = gen(function* () {
|
|
|
39709
39854
|
let currentPath = null;
|
|
39710
39855
|
for (const line of worktreeList.stdout.split("\n")) if (line.startsWith("worktree ")) {
|
|
39711
39856
|
const candidatePath = line.slice(9);
|
|
39712
|
-
currentPath = (yield* fileSystem.stat(candidatePath).pipe(map$
|
|
39857
|
+
currentPath = (yield* fileSystem.stat(candidatePath).pipe(map$2(() => true), catch_(() => succeed(false)))) ? candidatePath : null;
|
|
39713
39858
|
} else if (line.startsWith("branch refs/heads/") && currentPath) worktreeMap.set(line.slice(18), currentPath);
|
|
39714
39859
|
else if (line === "") currentPath = null;
|
|
39715
39860
|
}
|
|
@@ -39850,7 +39995,7 @@ const makeGitCore = gen(function* () {
|
|
|
39850
39995
|
], {
|
|
39851
39996
|
timeoutMs: 5e3,
|
|
39852
39997
|
allowNonZeroExit: true
|
|
39853
|
-
}).pipe(map$
|
|
39998
|
+
}).pipe(map$2((result) => result.code === 0)), executeGit("GitCore.checkoutBranch.remoteExists", input.cwd, [
|
|
39854
39999
|
"show-ref",
|
|
39855
40000
|
"--verify",
|
|
39856
40001
|
"--quiet",
|
|
@@ -39858,7 +40003,7 @@ const makeGitCore = gen(function* () {
|
|
|
39858
40003
|
], {
|
|
39859
40004
|
timeoutMs: 5e3,
|
|
39860
40005
|
allowNonZeroExit: true
|
|
39861
|
-
}).pipe(map$
|
|
40006
|
+
}).pipe(map$2((result) => result.code === 0))], { concurrency: "unbounded" });
|
|
39862
40007
|
const localTrackingBranch = remoteExists ? yield* executeGit("GitCore.checkoutBranch.localTrackingBranch", input.cwd, [
|
|
39863
40008
|
"for-each-ref",
|
|
39864
40009
|
"--format=%(refname:short) %(upstream:short)",
|
|
@@ -39866,7 +40011,7 @@ const makeGitCore = gen(function* () {
|
|
|
39866
40011
|
], {
|
|
39867
40012
|
timeoutMs: 5e3,
|
|
39868
40013
|
allowNonZeroExit: true
|
|
39869
|
-
}).pipe(map$
|
|
40014
|
+
}).pipe(map$2((result) => result.code === 0 ? parseTrackingBranchByUpstreamRef(result.stdout, input.branch) : null)) : null;
|
|
39870
40015
|
const localTrackedBranchCandidate = deriveLocalBranchNameFromRemoteRef(input.branch);
|
|
39871
40016
|
const localTrackedBranchTargetExists = remoteExists && localTrackedBranchCandidate ? yield* executeGit("GitCore.checkoutBranch.localTrackedBranchTargetExists", input.cwd, [
|
|
39872
40017
|
"show-ref",
|
|
@@ -39876,7 +40021,7 @@ const makeGitCore = gen(function* () {
|
|
|
39876
40021
|
], {
|
|
39877
40022
|
timeoutMs: 5e3,
|
|
39878
40023
|
allowNonZeroExit: true
|
|
39879
|
-
}).pipe(map$
|
|
40024
|
+
}).pipe(map$2((result) => result.code === 0)) : false;
|
|
39880
40025
|
const checkoutArgs = localInputExists ? ["checkout", input.branch] : remoteExists && !localTrackingBranch && localTrackedBranchTargetExists ? ["checkout", input.branch] : remoteExists && !localTrackingBranch ? [
|
|
39881
40026
|
"checkout",
|
|
39882
40027
|
"--track",
|
|
@@ -39896,7 +40041,7 @@ const makeGitCore = gen(function* () {
|
|
|
39896
40041
|
"branch",
|
|
39897
40042
|
"--list",
|
|
39898
40043
|
"--format=%(refname:short)"
|
|
39899
|
-
]).pipe(map$
|
|
40044
|
+
]).pipe(map$2((stdout) => stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0)));
|
|
39900
40045
|
return {
|
|
39901
40046
|
status,
|
|
39902
40047
|
statusDetails,
|
|
@@ -40031,7 +40176,7 @@ const makeGitHubCli = sync(() => {
|
|
|
40031
40176
|
"--json",
|
|
40032
40177
|
"number,title,url,baseRefName,headRefName"
|
|
40033
40178
|
]
|
|
40034
|
-
}).pipe(map$
|
|
40179
|
+
}).pipe(map$2((result) => result.stdout.trim()), flatMap((raw) => raw.length === 0 ? succeed([]) : decodeGitHubJson(raw, Array$1(RawGitHubPullRequestSchema), "listOpenPullRequests", "GitHub CLI returned invalid PR list JSON.")), map$2((pullRequests) => pullRequests.map(normalizePullRequestSummary))),
|
|
40035
40180
|
getPullRequest: (input) => execute({
|
|
40036
40181
|
cwd: input.cwd,
|
|
40037
40182
|
args: [
|
|
@@ -40041,7 +40186,7 @@ const makeGitHubCli = sync(() => {
|
|
|
40041
40186
|
"--json",
|
|
40042
40187
|
"number,title,url,baseRefName,headRefName,state,mergedAt,isCrossRepository,headRepository,headRepositoryOwner"
|
|
40043
40188
|
]
|
|
40044
|
-
}).pipe(map$
|
|
40189
|
+
}).pipe(map$2((result) => result.stdout.trim()), flatMap((raw) => decodeGitHubJson(raw, RawGitHubPullRequestSchema, "getPullRequest", "GitHub CLI returned invalid pull request JSON.")), map$2(normalizePullRequestSummary)),
|
|
40045
40190
|
getRepositoryCloneUrls: (input) => execute({
|
|
40046
40191
|
cwd: input.cwd,
|
|
40047
40192
|
args: [
|
|
@@ -40051,7 +40196,7 @@ const makeGitHubCli = sync(() => {
|
|
|
40051
40196
|
"--json",
|
|
40052
40197
|
"nameWithOwner,url,sshUrl"
|
|
40053
40198
|
]
|
|
40054
|
-
}).pipe(map$
|
|
40199
|
+
}).pipe(map$2((result) => result.stdout.trim()), flatMap((raw) => decodeGitHubJson(raw, RawGitHubRepositoryCloneUrlsSchema, "getRepositoryCloneUrls", "GitHub CLI returned invalid repository JSON.")), map$2(normalizeRepositoryCloneUrls)),
|
|
40055
40200
|
createPullRequest: (input) => execute({
|
|
40056
40201
|
cwd: input.cwd,
|
|
40057
40202
|
args: [
|
|
@@ -40077,7 +40222,7 @@ const makeGitHubCli = sync(() => {
|
|
|
40077
40222
|
"--jq",
|
|
40078
40223
|
".defaultBranchRef.name"
|
|
40079
40224
|
]
|
|
40080
|
-
}).pipe(map$
|
|
40225
|
+
}).pipe(map$2((value) => {
|
|
40081
40226
|
const trimmed = value.stdout.trim();
|
|
40082
40227
|
return trimmed.length > 0 ? trimmed : null;
|
|
40083
40228
|
})),
|
|
@@ -40207,13 +40352,13 @@ const makeCodexTextGeneration = gen(function* () {
|
|
|
40207
40352
|
], {
|
|
40208
40353
|
cwd,
|
|
40209
40354
|
shell: process.platform === "win32",
|
|
40210
|
-
stdin: { stream: make$
|
|
40355
|
+
stdin: { stream: make$30(new TextEncoder().encode(prompt)) }
|
|
40211
40356
|
});
|
|
40212
40357
|
const child = yield* commandSpawner.spawn(command).pipe(mapError((cause) => normalizeCodexError(operation, cause, "Failed to spawn Codex CLI process")));
|
|
40213
40358
|
const [stdout, stderr, exitCode] = yield* all([
|
|
40214
40359
|
readStreamAsString(operation, child.stdout),
|
|
40215
40360
|
readStreamAsString(operation, child.stderr),
|
|
40216
|
-
child.exitCode.pipe(map$
|
|
40361
|
+
child.exitCode.pipe(map$2((value) => Number(value)), mapError((cause) => normalizeCodexError(operation, cause, "Failed to read Codex CLI exit code")))
|
|
40217
40362
|
], { concurrency: "unbounded" });
|
|
40218
40363
|
if (exitCode !== 0) {
|
|
40219
40364
|
const stderrDetail = stderr.trim();
|
|
@@ -40282,7 +40427,7 @@ const makeCodexTextGeneration = gen(function* () {
|
|
|
40282
40427
|
prompt,
|
|
40283
40428
|
outputSchemaJson,
|
|
40284
40429
|
...input.model ? { model: input.model } : {}
|
|
40285
|
-
}).pipe(map$
|
|
40430
|
+
}).pipe(map$2((generated) => ({
|
|
40286
40431
|
subject: sanitizeCommitSubject(generated.subject),
|
|
40287
40432
|
body: generated.body.trim(),
|
|
40288
40433
|
..."branch" in generated && typeof generated.branch === "string" ? { branch: sanitizeFeatureBranchName(generated.branch) } : {}
|
|
@@ -40319,7 +40464,7 @@ const makeCodexTextGeneration = gen(function* () {
|
|
|
40319
40464
|
body: String$1
|
|
40320
40465
|
}),
|
|
40321
40466
|
...input.model ? { model: input.model } : {}
|
|
40322
|
-
}).pipe(map$
|
|
40467
|
+
}).pipe(map$2((generated) => ({
|
|
40323
40468
|
title: sanitizePrTitle(generated.title),
|
|
40324
40469
|
body: generated.body.trim()
|
|
40325
40470
|
})));
|
|
@@ -40733,7 +40878,7 @@ const readCodexConfigModelProvider = gen(function* () {
|
|
|
40733
40878
|
* required because authentication is handled through provider-specific
|
|
40734
40879
|
* environment variables.
|
|
40735
40880
|
*/
|
|
40736
|
-
const hasCustomModelProvider = map$
|
|
40881
|
+
const hasCustomModelProvider = map$2(readCodexConfigModelProvider, (provider) => provider !== void 0 && !OPENAI_AUTH_PROVIDERS.has(provider));
|
|
40737
40882
|
const collectStreamAsString = (stream) => runFold(stream, () => "", (acc, chunk) => acc + new TextDecoder().decode(chunk));
|
|
40738
40883
|
const runCodexCommand$1 = (args, env) => gen(function* () {
|
|
40739
40884
|
const spawner = yield* ChildProcessSpawner;
|
|
@@ -40745,7 +40890,7 @@ const runCodexCommand$1 = (args, env) => gen(function* () {
|
|
|
40745
40890
|
const [stdout, stderr, exitCode] = yield* all([
|
|
40746
40891
|
collectStreamAsString(child.stdout),
|
|
40747
40892
|
collectStreamAsString(child.stderr),
|
|
40748
|
-
child.exitCode.pipe(map$
|
|
40893
|
+
child.exitCode.pipe(map$2(Number))
|
|
40749
40894
|
], { concurrency: "unbounded" });
|
|
40750
40895
|
return {
|
|
40751
40896
|
stdout,
|
|
@@ -40847,7 +40992,7 @@ const ProviderHealthLive = effect(ProviderHealth, gen(function* () {
|
|
|
40847
40992
|
const fileSystem = yield* FileSystem;
|
|
40848
40993
|
const path = yield* Path$1;
|
|
40849
40994
|
const childProcessSpawner = yield* ChildProcessSpawner;
|
|
40850
|
-
const loadStatuses = checkCodexProviderStatus.pipe(map$
|
|
40995
|
+
const loadStatuses = checkCodexProviderStatus.pipe(map$2(of), provideService(FileSystem, fileSystem), provideService(Path$1, path), provideService(ChildProcessSpawner, childProcessSpawner));
|
|
40851
40996
|
const statusesRef = yield* make$11(yield* loadStatuses);
|
|
40852
40997
|
return {
|
|
40853
40998
|
getStatuses: get(statusesRef),
|
|
@@ -43690,7 +43835,8 @@ function resolveFallbackAccountKey(profileName) {
|
|
|
43690
43835
|
}
|
|
43691
43836
|
var ProfileManager = class {
|
|
43692
43837
|
constructor() {
|
|
43693
|
-
|
|
43838
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
43839
|
+
this.codexDir = join$1(homeDir, ".codex");
|
|
43694
43840
|
this.profileHomesRoot = join$1(getUserDataDir(), "profile-homes");
|
|
43695
43841
|
this.activeAuth = join$1(this.codexDir, "auth.json");
|
|
43696
43842
|
this.activeAuthBackup = `${this.activeAuth}.swap`;
|
|
@@ -47884,7 +48030,7 @@ const makeServerPushBus = (input) => gen(function* () {
|
|
|
47884
48030
|
const nextSequence = yield* make$11(0);
|
|
47885
48031
|
const queue = yield* unbounded();
|
|
47886
48032
|
const encodePush = encodeUnknownEffect(fromJsonString(WsPush));
|
|
47887
|
-
const settleDelivery = (job, delivered) => job.delivered === null ? void_$1 : succeed$
|
|
48033
|
+
const settleDelivery = (job, delivered) => job.delivered === null ? void_$1 : succeed$5(job.delivered, delivered).pipe(orDie);
|
|
47888
48034
|
const send = fnUntraced(function* (job) {
|
|
47889
48035
|
const push = {
|
|
47890
48036
|
type: "push",
|
|
@@ -47893,7 +48039,7 @@ const makeServerPushBus = (input) => gen(function* () {
|
|
|
47893
48039
|
data: job.data
|
|
47894
48040
|
};
|
|
47895
48041
|
const recipients = job.target.kind === "all" ? yield* get(input.clients) : new Set([job.target.client]);
|
|
47896
|
-
return yield* encodePush(push).pipe(map$
|
|
48042
|
+
return yield* encodePush(push).pipe(map$2((message) => {
|
|
47897
48043
|
let recipientCount = 0;
|
|
47898
48044
|
for (const client of recipients) {
|
|
47899
48045
|
if (client.readyState !== client.OPEN) continue;
|
|
@@ -47914,7 +48060,7 @@ const makeServerPushBus = (input) => gen(function* () {
|
|
|
47914
48060
|
return {
|
|
47915
48061
|
publishAll: publish({ kind: "all" }),
|
|
47916
48062
|
publishClient: (client, channel, data) => gen(function* () {
|
|
47917
|
-
const delivered = yield* make$
|
|
48063
|
+
const delivered = yield* make$27();
|
|
47918
48064
|
yield* offer$1(queue, {
|
|
47919
48065
|
channel,
|
|
47920
48066
|
data,
|
|
@@ -47931,12 +48077,12 @@ const makeServerPushBus = (input) => gen(function* () {
|
|
|
47931
48077
|
//#endregion
|
|
47932
48078
|
//#region src/wsServer/readiness.ts
|
|
47933
48079
|
const makeServerReadiness = gen(function* () {
|
|
47934
|
-
const httpListening = yield* make$
|
|
47935
|
-
const pushBusReady = yield* make$
|
|
47936
|
-
const keybindingsReady = yield* make$
|
|
47937
|
-
const terminalSubscriptionsReady = yield* make$
|
|
47938
|
-
const orchestrationSubscriptionsReady = yield* make$
|
|
47939
|
-
const complete = (deferred) => succeed$
|
|
48080
|
+
const httpListening = yield* make$27();
|
|
48081
|
+
const pushBusReady = yield* make$27();
|
|
48082
|
+
const keybindingsReady = yield* make$27();
|
|
48083
|
+
const terminalSubscriptionsReady = yield* make$27();
|
|
48084
|
+
const orchestrationSubscriptionsReady = yield* make$27();
|
|
48085
|
+
const complete = (deferred) => succeed$5(deferred, void 0).pipe(orDie);
|
|
47940
48086
|
return {
|
|
47941
48087
|
awaitServerReady: all([
|
|
47942
48088
|
_await(httpListening),
|
|
@@ -47982,7 +48128,7 @@ const handleOrchestrationRequest = fnUntraced(function* (body, context) {
|
|
|
47982
48128
|
case ORCHESTRATION_WS_METHODS.replayEvents: return yield* runCollect(context.orchestrationEngine.readEvents(clamp(body.fromSequenceExclusive, {
|
|
47983
48129
|
maximum: Number.MAX_SAFE_INTEGER,
|
|
47984
48130
|
minimum: 0
|
|
47985
|
-
}))).pipe(map$
|
|
48131
|
+
}))).pipe(map$2((events) => Array.from(events)));
|
|
47986
48132
|
default: return unhandledRequest;
|
|
47987
48133
|
}
|
|
47988
48134
|
});
|
|
@@ -47993,7 +48139,7 @@ const decodeJsonResult = (schema) => {
|
|
|
47993
48139
|
return (input) => {
|
|
47994
48140
|
const result = decode(input);
|
|
47995
48141
|
if (isFailure(result)) return fail$3(result.cause);
|
|
47996
|
-
return succeed$
|
|
48142
|
+
return succeed$4(result.value);
|
|
47997
48143
|
};
|
|
47998
48144
|
};
|
|
47999
48145
|
const formatSchemaError = (cause) => {
|
|
@@ -52812,7 +52958,7 @@ const createServer = fn(function* () {
|
|
|
52812
52958
|
const checkpointDiffQuery = yield* CheckpointDiffQuery;
|
|
52813
52959
|
const orchestrationReactor = yield* OrchestrationReactor;
|
|
52814
52960
|
const { openInEditor } = yield* Open;
|
|
52815
|
-
const subscriptionsScope = yield* make$
|
|
52961
|
+
const subscriptionsScope = yield* make$28("sequential");
|
|
52816
52962
|
yield* addFinalizer$1(() => close(subscriptionsScope, void_$3));
|
|
52817
52963
|
yield* runForEach(orchestrationEngine.streamDomainEvents, (event) => gen(function* () {
|
|
52818
52964
|
yield* pushBus.publishAll(ORCHESTRATION_WS_CHANNELS.domainEvent, event);
|
|
@@ -53798,18 +53944,18 @@ var CliConfig = class CliConfig extends Service()("t3/main/CliConfig") {
|
|
|
53798
53944
|
}
|
|
53799
53945
|
};
|
|
53800
53946
|
const CliEnvConfig = all$1({
|
|
53801
|
-
mode: string$3("T3CODE_MODE").pipe(option, map$
|
|
53947
|
+
mode: string$3("T3CODE_MODE").pipe(option, map$5(match({
|
|
53802
53948
|
onNone: () => "web",
|
|
53803
53949
|
onSome: (value) => value === "desktop" ? "desktop" : "web"
|
|
53804
53950
|
}))),
|
|
53805
|
-
port: port("T3CODE_PORT").pipe(option, map$
|
|
53806
|
-
host: string$3("T3CODE_HOST").pipe(option, map$
|
|
53807
|
-
stateDir: string$3("T3CODE_STATE_DIR").pipe(option, map$
|
|
53808
|
-
devUrl: url("VITE_DEV_SERVER_URL").pipe(option, map$
|
|
53809
|
-
noBrowser: boolean$3("T3CODE_NO_BROWSER").pipe(option, map$
|
|
53810
|
-
authToken: string$3("T3CODE_AUTH_TOKEN").pipe(option, map$
|
|
53811
|
-
autoBootstrapProjectFromCwd: boolean$3("T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD").pipe(option, map$
|
|
53812
|
-
logWebSocketEvents: boolean$3("T3CODE_LOG_WS_EVENTS").pipe(option, map$
|
|
53951
|
+
port: port("T3CODE_PORT").pipe(option, map$5(getOrUndefined)),
|
|
53952
|
+
host: string$3("T3CODE_HOST").pipe(option, map$5(getOrUndefined)),
|
|
53953
|
+
stateDir: string$3("T3CODE_STATE_DIR").pipe(option, map$5(getOrUndefined)),
|
|
53954
|
+
devUrl: url("VITE_DEV_SERVER_URL").pipe(option, map$5(getOrUndefined)),
|
|
53955
|
+
noBrowser: boolean$3("T3CODE_NO_BROWSER").pipe(option, map$5(getOrUndefined)),
|
|
53956
|
+
authToken: string$3("T3CODE_AUTH_TOKEN").pipe(option, map$5(getOrUndefined)),
|
|
53957
|
+
autoBootstrapProjectFromCwd: boolean$3("T3CODE_AUTO_BOOTSTRAP_PROJECT_FROM_CWD").pipe(option, map$5(getOrUndefined)),
|
|
53958
|
+
logWebSocketEvents: boolean$3("T3CODE_LOG_WS_EVENTS").pipe(option, map$5(getOrUndefined))
|
|
53813
53959
|
});
|
|
53814
53960
|
const resolveBooleanFlag = (flag, envValue) => getOrElse(filter$1(flag, Boolean), () => envValue);
|
|
53815
53961
|
const ServerConfigLive = (input) => effect(ServerConfig$1, gen(function* () {
|
|
@@ -53979,52 +54125,7 @@ var version = "0.0.10";
|
|
|
53979
54125
|
* @since 4.0.0
|
|
53980
54126
|
*/
|
|
53981
54127
|
const TypeId$8 = "~effect/http/Cookies";
|
|
53982
|
-
/**
|
|
53983
|
-
* @since 4.0.0
|
|
53984
|
-
* @category refinements
|
|
53985
|
-
*/
|
|
53986
|
-
const isCookies = (u) => hasProperty(u, TypeId$8);
|
|
53987
|
-
/**
|
|
53988
|
-
* @since 4.0.0
|
|
53989
|
-
* @category Schemas
|
|
53990
|
-
*/
|
|
53991
|
-
const CookiesSchema = /* @__PURE__ */ declare(isCookies, {
|
|
53992
|
-
typeConstructor: { _tag: "effect/http/Cookies" },
|
|
53993
|
-
generation: {
|
|
53994
|
-
runtime: `Cookies.CookiesSchema`,
|
|
53995
|
-
Type: `Cookies.Cookies`,
|
|
53996
|
-
Encoded: `typeof Cookies.CookiesSchema["Encoded"]`,
|
|
53997
|
-
importDeclaration: `import * as Cookies from "effect/unstable/http/Cookies"`
|
|
53998
|
-
},
|
|
53999
|
-
expected: "Cookies",
|
|
54000
|
-
toCodecJson: () => link$1()(Array$1(String$1), transform$1({
|
|
54001
|
-
decode: (input) => fromSetCookie(input),
|
|
54002
|
-
encode: (cookies) => toSetCookieHeaders(cookies)
|
|
54003
|
-
})),
|
|
54004
|
-
toCodecIso: () => link$1()(Record(String$1, CookieSchema), transform$1({
|
|
54005
|
-
decode: (input) => fromReadonlyRecord(input),
|
|
54006
|
-
encode: (cookies) => cookies.cookies
|
|
54007
|
-
}))
|
|
54008
|
-
});
|
|
54009
54128
|
const CookieTypeId = "~effect/http/Cookies/Cookie";
|
|
54010
|
-
/**
|
|
54011
|
-
* @since 4.0.0
|
|
54012
|
-
* @category Guards
|
|
54013
|
-
*/
|
|
54014
|
-
const isCookie = (u) => hasProperty(u, CookieTypeId);
|
|
54015
|
-
/**
|
|
54016
|
-
* @since 4.0.0
|
|
54017
|
-
* @category Schemas
|
|
54018
|
-
*/
|
|
54019
|
-
const CookieSchema = /* @__PURE__ */ declare(isCookie, {
|
|
54020
|
-
typeConstructor: { _tag: "effect/http/Cookie" },
|
|
54021
|
-
generation: {
|
|
54022
|
-
runtime: `Cookies.CookieSchema`,
|
|
54023
|
-
Type: `Cookies.Cookie`,
|
|
54024
|
-
importDeclaration: `import * as Cookie from "effect/unstable/http/Cookies"`
|
|
54025
|
-
},
|
|
54026
|
-
expected: "Cookie"
|
|
54027
|
-
});
|
|
54028
54129
|
const CookieErrorTypeId = "~effect/http/Cookies/CookieError";
|
|
54029
54130
|
/**
|
|
54030
54131
|
* @since 4.0.0
|
|
@@ -54062,7 +54163,7 @@ const Proto$5 = {
|
|
|
54062
54163
|
toJSON() {
|
|
54063
54164
|
return {
|
|
54064
54165
|
_id: "effect/Cookies",
|
|
54065
|
-
cookies: map$
|
|
54166
|
+
cookies: map$6(this.cookies, (cookie) => cookie.toJSON())
|
|
54066
54167
|
};
|
|
54067
54168
|
},
|
|
54068
54169
|
pipe() {
|
|
@@ -54208,109 +54309,6 @@ const CookieProto = {
|
|
|
54208
54309
|
};
|
|
54209
54310
|
}
|
|
54210
54311
|
};
|
|
54211
|
-
/**
|
|
54212
|
-
* Create a new cookie
|
|
54213
|
-
*
|
|
54214
|
-
* @since 4.0.0
|
|
54215
|
-
* @category constructors
|
|
54216
|
-
*/
|
|
54217
|
-
function makeCookie(name, value, options) {
|
|
54218
|
-
if (!fieldContentRegExp.test(name)) return fail$3(CookiesError.fromReason("InvalidCookieName"));
|
|
54219
|
-
const encodedValue = encodeURIComponent(value);
|
|
54220
|
-
if (encodedValue && !fieldContentRegExp.test(encodedValue)) return fail$3(CookiesError.fromReason("InvalidCookieValue"));
|
|
54221
|
-
if (options !== void 0) {
|
|
54222
|
-
if (options.domain !== void 0 && !fieldContentRegExp.test(options.domain)) return fail$3(CookiesError.fromReason("InvalidCookieDomain"));
|
|
54223
|
-
if (options.path !== void 0 && !fieldContentRegExp.test(options.path)) return fail$3(CookiesError.fromReason("InvalidCookiePath"));
|
|
54224
|
-
if (options.maxAge !== void 0 && !isFinite$1(fromInputUnsafe(options.maxAge))) return fail$3(CookiesError.fromReason("CookieInfinityMaxAge"));
|
|
54225
|
-
}
|
|
54226
|
-
return succeed$3(Object.assign(Object.create(CookieProto), {
|
|
54227
|
-
name,
|
|
54228
|
-
value,
|
|
54229
|
-
valueEncoded: encodedValue,
|
|
54230
|
-
options
|
|
54231
|
-
}));
|
|
54232
|
-
}
|
|
54233
|
-
/**
|
|
54234
|
-
* Create a new cookie, throwing an error if invalid
|
|
54235
|
-
*
|
|
54236
|
-
* @since 4.0.0
|
|
54237
|
-
* @category constructors
|
|
54238
|
-
*/
|
|
54239
|
-
const makeCookieUnsafe = (name, value, options) => getOrThrow(makeCookie(name, value, options));
|
|
54240
|
-
/**
|
|
54241
|
-
* Serialize a cookie into a string
|
|
54242
|
-
*
|
|
54243
|
-
* Adapted from https://github.com/fastify/fastify-cookie under MIT License
|
|
54244
|
-
*
|
|
54245
|
-
* @since 4.0.0
|
|
54246
|
-
* @category encoding
|
|
54247
|
-
*/
|
|
54248
|
-
function serializeCookie(self) {
|
|
54249
|
-
let str = self.name + "=" + self.valueEncoded;
|
|
54250
|
-
if (self.options === void 0) return str;
|
|
54251
|
-
const options = self.options;
|
|
54252
|
-
if (options.maxAge !== void 0) {
|
|
54253
|
-
const maxAge = toSeconds(fromInputUnsafe(options.maxAge));
|
|
54254
|
-
str += "; Max-Age=" + Math.trunc(maxAge);
|
|
54255
|
-
}
|
|
54256
|
-
if (options.domain !== void 0) str += "; Domain=" + options.domain;
|
|
54257
|
-
if (options.path !== void 0) str += "; Path=" + options.path;
|
|
54258
|
-
if (options.priority !== void 0) switch (options.priority) {
|
|
54259
|
-
case "low":
|
|
54260
|
-
str += "; Priority=Low";
|
|
54261
|
-
break;
|
|
54262
|
-
case "medium":
|
|
54263
|
-
str += "; Priority=Medium";
|
|
54264
|
-
break;
|
|
54265
|
-
case "high":
|
|
54266
|
-
str += "; Priority=High";
|
|
54267
|
-
break;
|
|
54268
|
-
}
|
|
54269
|
-
if (options.expires !== void 0) str += "; Expires=" + options.expires.toUTCString();
|
|
54270
|
-
if (options.httpOnly) str += "; HttpOnly";
|
|
54271
|
-
if (options.secure) str += "; Secure";
|
|
54272
|
-
if (options.partitioned) str += "; Partitioned";
|
|
54273
|
-
if (options.sameSite !== void 0) switch (options.sameSite) {
|
|
54274
|
-
case "lax":
|
|
54275
|
-
str += "; SameSite=Lax";
|
|
54276
|
-
break;
|
|
54277
|
-
case "strict":
|
|
54278
|
-
str += "; SameSite=Strict";
|
|
54279
|
-
break;
|
|
54280
|
-
case "none":
|
|
54281
|
-
str += "; SameSite=None";
|
|
54282
|
-
break;
|
|
54283
|
-
}
|
|
54284
|
-
return str;
|
|
54285
|
-
}
|
|
54286
|
-
/**
|
|
54287
|
-
* @since 4.0.0
|
|
54288
|
-
* @category encoding
|
|
54289
|
-
*/
|
|
54290
|
-
const toRecord$1 = (self) => {
|
|
54291
|
-
const record = {};
|
|
54292
|
-
const cookies = Object.values(self.cookies);
|
|
54293
|
-
for (let index = 0; index < cookies.length; index++) {
|
|
54294
|
-
const cookie = cookies[index];
|
|
54295
|
-
record[cookie.name] = cookie.value;
|
|
54296
|
-
}
|
|
54297
|
-
return record;
|
|
54298
|
-
};
|
|
54299
|
-
/**
|
|
54300
|
-
* @since 4.0.0
|
|
54301
|
-
* @category Schemas
|
|
54302
|
-
*/
|
|
54303
|
-
const schemaRecord$1 = /* @__PURE__ */ CookiesSchema.pipe(/* @__PURE__ */ decodeTo(/* @__PURE__ */ Record(String$1, String$1), /* @__PURE__ */ transform$1({
|
|
54304
|
-
decode: toRecord$1,
|
|
54305
|
-
encode: (self) => fromIterable(Object.entries(self).map(([name, value]) => makeCookieUnsafe(name, value)))
|
|
54306
|
-
})));
|
|
54307
|
-
/**
|
|
54308
|
-
* Serialize a Cookies object into Headers object containing one or more Set-Cookie headers
|
|
54309
|
-
*
|
|
54310
|
-
* @since 4.0.0
|
|
54311
|
-
* @category encoding
|
|
54312
|
-
*/
|
|
54313
|
-
const toSetCookieHeaders = (self) => Object.values(self.cookies).map(serializeCookie);
|
|
54314
54312
|
const tryDecodeURIComponent = (str) => {
|
|
54315
54313
|
try {
|
|
54316
54314
|
return decodeURIComponent(str);
|
|
@@ -54334,7 +54332,7 @@ const Proto$4 = /* @__PURE__ */ Object.create(null);
|
|
|
54334
54332
|
Object.defineProperties(Proto$4, {
|
|
54335
54333
|
[TypeId$7]: { value: TypeId$7 },
|
|
54336
54334
|
[symbolRedactable]: { value(context) {
|
|
54337
|
-
return redact(this, get$
|
|
54335
|
+
return redact(this, get$4(context, CurrentRedactedNames));
|
|
54338
54336
|
} },
|
|
54339
54337
|
toJSON: { value() {
|
|
54340
54338
|
return redact$1(this);
|
|
@@ -54424,8 +54422,8 @@ const redact = /* @__PURE__ */ dual(2, (self, key) => {
|
|
|
54424
54422
|
const modify = (key) => {
|
|
54425
54423
|
if (typeof key === "string") {
|
|
54426
54424
|
const k = key.toLowerCase();
|
|
54427
|
-
if (k in self) out[k] = make$
|
|
54428
|
-
} else for (const name in self) if (key.test(name)) out[name] = make$
|
|
54425
|
+
if (k in self) out[k] = make$31(self[k]);
|
|
54426
|
+
} else for (const name in self) if (key.test(name)) out[name] = make$31(self[name]);
|
|
54429
54427
|
};
|
|
54430
54428
|
if (Array.isArray(key)) for (let i = 0; i < key.length; i++) modify(key[i]);
|
|
54431
54429
|
else modify(key);
|
|
@@ -54686,7 +54684,7 @@ const fromInputNested = (input) => {
|
|
|
54686
54684
|
* @since 4.0.0
|
|
54687
54685
|
* @category Equivalence
|
|
54688
54686
|
*/
|
|
54689
|
-
const Equivalence = /* @__PURE__ */ make$
|
|
54687
|
+
const Equivalence = /* @__PURE__ */ make$32((a, b) => arrayEquivalence(a.params, b.params));
|
|
54690
54688
|
const arrayEquivalence = /* @__PURE__ */ makeEquivalence$1(/* @__PURE__ */ makeEquivalence$2([/* @__PURE__ */ strictEqual(), /* @__PURE__ */ strictEqual()]));
|
|
54691
54689
|
/**
|
|
54692
54690
|
* @since 4.0.0
|
|
@@ -54744,7 +54742,7 @@ const makeUrl = (url, params, hash) => {
|
|
|
54744
54742
|
if (value !== void 0) urlInstance.searchParams.append(key, value);
|
|
54745
54743
|
}
|
|
54746
54744
|
if (hash !== void 0) urlInstance.hash = hash;
|
|
54747
|
-
return succeed$
|
|
54745
|
+
return succeed$4(urlInstance);
|
|
54748
54746
|
} catch (e) {
|
|
54749
54747
|
return fail$3(new UrlParamsError({ cause: e }));
|
|
54750
54748
|
}
|
|
@@ -55040,15 +55038,6 @@ const TypeId$1 = "~effect/http/HttpClientResponse";
|
|
|
55040
55038
|
* @category constructors
|
|
55041
55039
|
*/
|
|
55042
55040
|
const fromWeb = (request, source) => new WebHttpClientResponse(request, source);
|
|
55043
|
-
/**
|
|
55044
|
-
* @since 4.0.0
|
|
55045
|
-
* @category filters
|
|
55046
|
-
*/
|
|
55047
|
-
const filterStatusOk$1 = (self) => self.status >= 200 && self.status < 300 ? succeed(self) : fail$1(new HttpClientError({ reason: new StatusCodeError({
|
|
55048
|
-
response: self,
|
|
55049
|
-
request: self.request,
|
|
55050
|
-
description: "non 2xx status code"
|
|
55051
|
-
}) }));
|
|
55052
55041
|
var WebHttpClientResponse = class extends Class$1 {
|
|
55053
55042
|
[TypeId$2];
|
|
55054
55043
|
[TypeId$1];
|
|
@@ -55187,13 +55176,6 @@ const HttpClient = /* @__PURE__ */ Service("effect/HttpClient");
|
|
|
55187
55176
|
*/
|
|
55188
55177
|
const transformResponse = /* @__PURE__ */ dual(2, (self, f) => makeWith((request) => f(self.postprocess(request)), self.preprocess));
|
|
55189
55178
|
/**
|
|
55190
|
-
* Filters responses that return a 2xx status code.
|
|
55191
|
-
*
|
|
55192
|
-
* @since 4.0.0
|
|
55193
|
-
* @category filters
|
|
55194
|
-
*/
|
|
55195
|
-
const filterStatusOk = /* @__PURE__ */ transformResponse(/* @__PURE__ */ flatMap(filterStatusOk$1));
|
|
55196
|
-
/**
|
|
55197
55179
|
* @since 4.0.0
|
|
55198
55180
|
* @category constructors
|
|
55199
55181
|
*/
|
|
@@ -55293,7 +55275,7 @@ const SpanNameGenerator = /* @__PURE__ */ Reference("effect/http/HttpClient/Span
|
|
|
55293
55275
|
/**
|
|
55294
55276
|
* @since 4.0.0
|
|
55295
55277
|
*/
|
|
55296
|
-
const layerMergedServices = (effect$1) => effect(HttpClient)(servicesWith((services) => map$
|
|
55278
|
+
const layerMergedServices = (effect$1) => effect(HttpClient)(servicesWith$1((services) => map$2(effect$1, (client) => transformResponse(client, updateServices$1((input) => merge$2(services, input))))));
|
|
55297
55279
|
const responseRegistry = /* @__PURE__ */ (() => {
|
|
55298
55280
|
if ("FinalizationRegistry" in globalThis && globalThis.FinalizationRegistry) {
|
|
55299
55281
|
const registry = /* @__PURE__ */ new FinalizationRegistry((controller) => {
|
|
@@ -55372,7 +55354,7 @@ var InterruptibleResponse = class {
|
|
|
55372
55354
|
get stream() {
|
|
55373
55355
|
return suspend$3(() => {
|
|
55374
55356
|
responseRegistry.unregister(this.original);
|
|
55375
|
-
return onExit(this.original.stream, (exit) => {
|
|
55357
|
+
return onExit$1(this.original.stream, (exit) => {
|
|
55376
55358
|
if (hasInterrupts$1(exit)) this.controller.abort();
|
|
55377
55359
|
return void_$1;
|
|
55378
55360
|
});
|
|
@@ -55404,7 +55386,7 @@ const fetch$1 = /* @__PURE__ */ make((request, url, signal, fiber) => {
|
|
|
55404
55386
|
const fetch = fiber.getRef(Fetch);
|
|
55405
55387
|
const options = fiber.services.mapUnsafe.get(RequestInit.key) ?? {};
|
|
55406
55388
|
const headers = options.headers ? merge(fromInput$1(options.headers), request.headers) : request.headers;
|
|
55407
|
-
const send = (body) => map$
|
|
55389
|
+
const send = (body) => map$2(tryPromise({
|
|
55408
55390
|
try: () => fetch(url, {
|
|
55409
55391
|
...options,
|
|
55410
55392
|
method: request.method,
|
|
@@ -55436,6 +55418,6 @@ const layer = /* @__PURE__ */ layerMergedServices(/* @__PURE__ */ succeed(fetch$
|
|
|
55436
55418
|
const RuntimeLayer = empty$6.pipe(provideMerge(CliConfig.layer), provideMerge(ServerLive), provideMerge(OpenLive), provideMerge(NetService.layer), provideMerge(layer$2), provideMerge(layer));
|
|
55437
55419
|
run$1(t3Cli, { version }).pipe(provide(RuntimeLayer), runMain);
|
|
55438
55420
|
//#endregion
|
|
55439
|
-
export {};
|
|
55421
|
+
export { make$13 as n, get$1 as t };
|
|
55440
55422
|
|
|
55441
55423
|
//# sourceMappingURL=index.mjs.map
|