@pmelab/gtd 24.3.0 → 24.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +15 -4
- package/dist/chunks/{reserved-DJwU5C4z.mjs → reserved-B9pG93Fc.mjs} +52 -12
- package/dist/chunks/{steering-D-PvRC5W.mjs → steering-DVILanVf.mjs} +16 -5
- package/dist/flows.mjs +9 -1
- package/dist/gtd.bundle.mjs +779 -812
- package/dist/steering.mjs +2 -2
- package/dist/testkit.mjs +663 -158
- package/dist/workflow-kit.mjs +9 -7
- package/dist/workflows/feature.mjs +152 -35
- package/dist/workflows/fix.mjs +2 -2
- package/dist/workflows/review.mjs +1 -1
- package/dist/workflows.mjs +223 -54
- package/package.json +1 -1
- package/src/cli/Program.test.ts +3 -8
- package/src/cli/Program.ts +1 -8
- package/src/edge/Edge.test.ts +5 -2
- package/src/edge/Edge.ts +3 -4
- package/src/emit/index.ts +1 -0
- package/src/flows/scripts.ts +6 -0
- package/src/platform/Git.test.ts +6 -9
- package/src/steering/FORMATS.md +1 -1
- package/src/steering/SteeringFormat.test.ts +9 -1
- package/src/steering/SteeringFormat.ts +7 -0
- package/src/steering/contract.test.ts +3 -0
- package/src/steering/index.ts +1 -0
- package/src/steering/review.test.ts +30 -0
- package/src/steering/review.ts +8 -2
- package/src/testkit/EmittedScriptRecognizer.test.ts +29 -30
- package/src/testkit/EmittedScriptRecognizer.ts +148 -51
- package/src/testkit/EmittedScripts.test.ts +166 -0
- package/src/testkit/FlowScripts.test.ts +242 -0
- package/src/testkit/FlowScripts.ts +326 -0
- package/src/testkit/GitTiers.ts +140 -49
- package/src/testkit/InMemRepo.ts +35 -2
- package/src/testkit/Layers.ts +10 -2
- package/src/testkit/TestRepo.ts +4 -1
- package/src/testkit/index.ts +1 -1
- package/src/workflow/discovery.test.ts +147 -0
- package/src/workflow/discovery.ts +5 -0
- package/src/workflow/fingerprint.test.ts +20 -4
- package/src/workflow/fingerprint.ts +8 -9
- package/src/workflow/index.ts +1 -6
- package/src/workflow/load.test.ts +5 -19
- package/src/workflow/load.ts +94 -10
- package/src/workflow-kit/review.test.ts +84 -0
- package/src/workflow-kit/review.ts +9 -6
- package/src/workflows/feature/review.test.ts +238 -12
- package/src/workflows/feature/review.ts +172 -31
- package/src/workflows/feature/steps.test.ts +12 -0
- package/src/workflows/feature/steps.ts +8 -1
- package/src/workflows/shared/access.test.ts +4 -2
- package/src/workflows/shared/access.ts +1 -0
- package/src/workflows/shared/options.test.ts +8 -0
- package/src/workflows/shared/options.ts +1 -0
- package/src/workflows/shared/steps.ts +2 -0
- package/src/workflows/shared/tail.ts +3 -11
- package/src/workflows/shared/text.test.ts +106 -0
- package/src/workflows/shared/text.ts +57 -1
- package/src/workflows/shared/vars.ts +1 -0
package/dist/gtd.bundle.mjs
CHANGED
|
@@ -3,17 +3,17 @@ import { createRequire as __createRequire } from 'module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import * as http from "node:http";
|
|
6
|
-
import { IncomingMessage } from "node:http";
|
|
7
6
|
import { isIP } from "node:net";
|
|
8
7
|
import * as Crypto from "node:crypto";
|
|
9
8
|
import { createHash, randomUUID } from "node:crypto";
|
|
10
9
|
import * as NFS from "node:fs";
|
|
11
10
|
import { appendFileSync, closeSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
12
11
|
import * as OS from "node:os";
|
|
13
|
-
import { constants, homedir, tmpdir } from "node:os";
|
|
12
|
+
import { constants, homedir, networkInterfaces, tmpdir } from "node:os";
|
|
14
13
|
import * as Path from "node:path";
|
|
15
14
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
16
15
|
import * as https from "node:https";
|
|
16
|
+
import { Readable } from "node:stream";
|
|
17
17
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
18
18
|
import * as ChildProcess from "node:child_process";
|
|
19
19
|
import { execFile, execFileSync, spawn } from "node:child_process";
|
|
@@ -10186,7 +10186,7 @@ var init_Fiber = __esmMin((() => {
|
|
|
10186
10186
|
}));
|
|
10187
10187
|
//#endregion
|
|
10188
10188
|
//#region node_modules/effect/dist/esm/internal/runtime.js
|
|
10189
|
-
var makeDual, unsafeFork, unsafeRunSync, AsyncFiberExceptionImpl, asyncFiberException, FiberFailureId, FiberFailureCauseId, FiberFailureImpl, fiberFailure, fastPath, unsafeRunSyncExit, unsafeRunPromiseExit, RuntimeImpl, make$16, runtime$1, defaultRuntimeFlags, defaultRuntime, updateContext$1, unsafeForkEffect, unsafeRunSyncEffect;
|
|
10189
|
+
var makeDual, unsafeFork, unsafeRunSync, AsyncFiberExceptionImpl, asyncFiberException, FiberFailureId, FiberFailureCauseId, FiberFailureImpl, fiberFailure, fastPath, unsafeRunSyncExit, unsafeRunPromise, unsafeRunPromiseExit, RuntimeImpl, make$16, runtime$1, defaultRuntimeFlags, defaultRuntime, updateContext$1, unsafeForkEffect, unsafeRunPromiseEffect, unsafeRunSyncEffect;
|
|
10190
10190
|
var init_runtime = __esmMin((() => {
|
|
10191
10191
|
init_Context();
|
|
10192
10192
|
init_Equal();
|
|
@@ -10203,6 +10203,7 @@ var init_runtime = __esmMin((() => {
|
|
|
10203
10203
|
init_executionStrategy();
|
|
10204
10204
|
init_fiberRuntime();
|
|
10205
10205
|
init_fiberScope();
|
|
10206
|
+
init_effect();
|
|
10206
10207
|
init_runtimeFlags();
|
|
10207
10208
|
init_supervisor();
|
|
10208
10209
|
makeDual = (f) => function() {
|
|
@@ -10310,6 +10311,12 @@ var init_runtime = __esmMin((() => {
|
|
|
10310
10311
|
if (result) return result;
|
|
10311
10312
|
return exitDie$1(capture(asyncFiberException(fiberRuntime), currentSpanFromFiber(fiberRuntime)));
|
|
10312
10313
|
});
|
|
10314
|
+
unsafeRunPromise = /*#__PURE__*/ makeDual((runtime, effect, options) => unsafeRunPromiseExit(runtime, effect, options).then((result) => {
|
|
10315
|
+
switch (result._tag) {
|
|
10316
|
+
case OP_SUCCESS: return result.effect_instruction_i0;
|
|
10317
|
+
case OP_FAILURE: throw fiberFailure(result.effect_instruction_i0);
|
|
10318
|
+
}
|
|
10319
|
+
}));
|
|
10313
10320
|
unsafeRunPromiseExit = /*#__PURE__*/ makeDual((runtime, effect, options) => new Promise((resolve) => {
|
|
10314
10321
|
const op = fastPath(effect);
|
|
10315
10322
|
if (op) resolve(op);
|
|
@@ -10349,6 +10356,7 @@ var init_runtime = __esmMin((() => {
|
|
|
10349
10356
|
fiberRefs: self.fiberRefs
|
|
10350
10357
|
}));
|
|
10351
10358
|
unsafeForkEffect = /*#__PURE__*/ unsafeFork(defaultRuntime);
|
|
10359
|
+
unsafeRunPromiseEffect = /*#__PURE__*/ unsafeRunPromise(defaultRuntime);
|
|
10352
10360
|
unsafeRunSyncEffect = /*#__PURE__*/ unsafeRunSync(defaultRuntime);
|
|
10353
10361
|
}));
|
|
10354
10362
|
//#endregion
|
|
@@ -11427,7 +11435,7 @@ var init_MutableQueue = __esmMin((() => {
|
|
|
11427
11435
|
}));
|
|
11428
11436
|
//#endregion
|
|
11429
11437
|
//#region node_modules/effect/dist/esm/Effect.js
|
|
11430
|
-
var isEffect, all$1, forEach$2, async, withFiberRuntime, fail$7, failCause$2, die, dieMessage, gen, promise, succeed$3, suspend$5, sync$1, _void, catchAll, catchAllCause, catchTag, ignore, sandbox, retry, try_, tryMap, tryPromise, interrupt, interruptible, uninterruptible, uninterruptibleMask, as, asVoid, map$4, mapBoth$1, mapError$1, negate, acquireRelease, acquireUseRelease$2, addFinalizer, ensuring$2, onError, scope$1, scopeWith, scopedWith$1, scoped$3, fiberIdWith, forkDaemon, forkIn, forkScoped, timeout, provide$1, provideService, serviceOption, either, exit$1, intoDeferred, when, flatMap$4, andThen, flatten$5, race, raceWith, tap, tapErrorCause, repeat, match$2, matchCause, matchCauseEffect, matchEffect, logWarning, logError, annotateLogs, orDie, orElse$1, orElseSucceed, runtime, unsafeMakeSemaphore, makeSemaphore, unsafeMakeLatch, runFork$1, runSync, zip$1, zipLeft, zipRight$1, zipWith, fnUntraced;
|
|
11438
|
+
var isEffect, all$1, forEach$2, async, withFiberRuntime, fail$7, failCause$2, die, dieMessage, gen, promise, succeed$3, suspend$5, sync$1, _void, catchAll, catchAllCause, catchTag, ignore, sandbox, retry, try_, tryMap, tryPromise, interrupt, interruptible, uninterruptible, uninterruptibleMask, as, asVoid, map$4, mapBoth$1, mapError$1, negate, acquireRelease, acquireUseRelease$2, addFinalizer, ensuring$2, onError, scope$1, scopeWith, scopedWith$1, scoped$3, fiberIdWith, forkDaemon, forkIn, forkScoped, timeout, provide$1, provideService, serviceOption, either, exit$1, intoDeferred, when, flatMap$4, andThen, flatten$5, race, raceWith, tap, tapErrorCause, repeat, match$2, matchCause, matchCauseEffect, matchEffect, logWarning, logError, annotateLogs, orDie, orElse$1, orElseSucceed, runtime, unsafeMakeSemaphore, makeSemaphore, unsafeMakeLatch, runFork$1, runPromise, runSync, zip$1, zipLeft, zipRight$1, zipWith, fnUntraced;
|
|
11431
11439
|
var init_Effect = __esmMin((() => {
|
|
11432
11440
|
init_core_effect();
|
|
11433
11441
|
init_core();
|
|
@@ -11514,6 +11522,7 @@ var init_Effect = __esmMin((() => {
|
|
|
11514
11522
|
makeSemaphore = makeSemaphore$1;
|
|
11515
11523
|
unsafeMakeLatch = unsafeMakeLatch$1;
|
|
11516
11524
|
runFork$1 = unsafeForkEffect;
|
|
11525
|
+
runPromise = unsafeRunPromiseEffect;
|
|
11517
11526
|
runSync = unsafeRunSyncEffect;
|
|
11518
11527
|
zip$1 = zipOptions;
|
|
11519
11528
|
zipLeft = zipLeftOptions;
|
|
@@ -21814,6 +21823,13 @@ const moveScript = (from, to) => [
|
|
|
21814
21823
|
`mv -- ${quote(from)} ${quote(to)}`,
|
|
21815
21824
|
""
|
|
21816
21825
|
].join("\n");
|
|
21826
|
+
/** Write `path` as committed at `ref` to `to`. */
|
|
21827
|
+
const showScript = (ref, path, to) => [
|
|
21828
|
+
"#!/usr/bin/env sh",
|
|
21829
|
+
"set -e",
|
|
21830
|
+
`git show ${quote(`${ref}:${path}`)} > ${quote(to)}`,
|
|
21831
|
+
""
|
|
21832
|
+
].join("\n");
|
|
21817
21833
|
//#endregion
|
|
21818
21834
|
//#region src/flows/helpers.ts
|
|
21819
21835
|
/** Whether a judge answered `expected` at a probability of at least `minP`. */
|
|
@@ -22092,6 +22108,7 @@ var flows_exports = /* @__PURE__ */ __exportAll({
|
|
|
22092
22108
|
scope: () => scope,
|
|
22093
22109
|
sectionBodies: () => sectionBodies,
|
|
22094
22110
|
sections: () => sections,
|
|
22111
|
+
showScript: () => showScript,
|
|
22095
22112
|
skillsFor: () => skillsFor,
|
|
22096
22113
|
start: () => start,
|
|
22097
22114
|
threads: () => threads,
|
|
@@ -22099,6 +22116,16 @@ var flows_exports = /* @__PURE__ */ __exportAll({
|
|
|
22099
22116
|
wrote: () => wrote
|
|
22100
22117
|
});
|
|
22101
22118
|
//#endregion
|
|
22119
|
+
//#region src/steering/SteeringFormat.ts
|
|
22120
|
+
var formatFinding;
|
|
22121
|
+
var init_SteeringFormat = __esmMin((() => {
|
|
22122
|
+
formatFinding = (file, finding) => {
|
|
22123
|
+
if (finding.line === void 0) return finding.message;
|
|
22124
|
+
const col = finding.range !== void 0 ? `:${finding.range.start.character + 1}` : "";
|
|
22125
|
+
return `${file}:${finding.line + 1}${col}: ${finding.message}`;
|
|
22126
|
+
};
|
|
22127
|
+
}));
|
|
22128
|
+
//#endregion
|
|
22102
22129
|
//#region node_modules/mdast-util-to-string/lib/index.js
|
|
22103
22130
|
/**
|
|
22104
22131
|
* Get the text content of a node or list of nodes.
|
|
@@ -37039,6 +37066,7 @@ var init_CodeThreads = __esmMin((() => {
|
|
|
37039
37066
|
//#region src/steering/index.ts
|
|
37040
37067
|
var REGISTRY, BUILT_IN_MODE_NAMES, steeringFormatFor, steeringFormatOrFreeForm, unansweredQuestions, viewOf, openThreads;
|
|
37041
37068
|
var init_steering = __esmMin((() => {
|
|
37069
|
+
init_SteeringFormat();
|
|
37042
37070
|
init_qa();
|
|
37043
37071
|
init_review();
|
|
37044
37072
|
init_Edits();
|
|
@@ -38199,6 +38227,30 @@ var ConfigDiscovery = class ConfigDiscovery extends Tag("ConfigDiscovery")() {
|
|
|
38199
38227
|
});
|
|
38200
38228
|
};
|
|
38201
38229
|
//#endregion
|
|
38230
|
+
//#region src/workflow/fingerprint.ts
|
|
38231
|
+
const HASH_LENGTH = 16;
|
|
38232
|
+
const CONTROL_CHARACTER = /[\x00-\x1f\x7f-\x9f]/;
|
|
38233
|
+
const contentHash = (content) => createHash("sha256").update(content).digest("hex").slice(0, HASH_LENGTH);
|
|
38234
|
+
const realOr = (path) => {
|
|
38235
|
+
try {
|
|
38236
|
+
return realpathSync(path);
|
|
38237
|
+
} catch {
|
|
38238
|
+
return path;
|
|
38239
|
+
}
|
|
38240
|
+
};
|
|
38241
|
+
const configFingerprint = (files, root, read) => {
|
|
38242
|
+
const fingerprint = {};
|
|
38243
|
+
const realRoot = realOr(root);
|
|
38244
|
+
for (const file of files) {
|
|
38245
|
+
const path = relative(realRoot, realOr(file)).split(sep).join("/");
|
|
38246
|
+
if (CONTROL_CHARACTER.test(path)) continue;
|
|
38247
|
+
const content = read(file);
|
|
38248
|
+
if (content !== void 0) fingerprint[path] = contentHash(content);
|
|
38249
|
+
}
|
|
38250
|
+
return fingerprint;
|
|
38251
|
+
};
|
|
38252
|
+
const changedConfigFiles = (recorded, current) => [.../* @__PURE__ */ new Set([...Object.keys(recorded), ...Object.keys(current)])].filter((path) => recorded[path] !== current[path]).sort();
|
|
38253
|
+
//#endregion
|
|
38202
38254
|
//#region src/workflow/Diagnostic.ts
|
|
38203
38255
|
const compareSegment = (a, b) => {
|
|
38204
38256
|
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
@@ -38334,9 +38386,16 @@ const load = gen(function* () {
|
|
|
38334
38386
|
},
|
|
38335
38387
|
...compiled.ui !== void 0 ? { ui: compiled.ui } : {},
|
|
38336
38388
|
warnings: diagnostics.filter((d) => d.severity === "warning"),
|
|
38337
|
-
|
|
38389
|
+
fingerprint: configFingerprint(loaded.file.dependencyFiles, host.root, module.read ?? readFromDisk)
|
|
38338
38390
|
};
|
|
38339
38391
|
});
|
|
38392
|
+
const readFromDisk = (path) => {
|
|
38393
|
+
try {
|
|
38394
|
+
return readFileSync(path, "utf8");
|
|
38395
|
+
} catch {
|
|
38396
|
+
return;
|
|
38397
|
+
}
|
|
38398
|
+
};
|
|
38340
38399
|
const TRANSFORM_MEMO_SIZE = 512;
|
|
38341
38400
|
const memoized = (transform) => {
|
|
38342
38401
|
const memo = /* @__PURE__ */ new Map();
|
|
@@ -38353,12 +38412,18 @@ const memoized = (transform) => {
|
|
|
38353
38412
|
};
|
|
38354
38413
|
let jitiModule;
|
|
38355
38414
|
let transform;
|
|
38356
|
-
const jiti = (shipped) => {
|
|
38415
|
+
const jiti = (shipped, local) => {
|
|
38357
38416
|
const require = createRequire(import.meta.url);
|
|
38358
38417
|
jitiModule ??= require("jiti");
|
|
38359
38418
|
transform ??= memoized(require(join(dirname(require.resolve("jiti/package.json")), "dist", "babel.cjs")));
|
|
38360
38419
|
return jitiModule.createJiti(import.meta.url, {
|
|
38361
|
-
virtualModules: shipped.modules,
|
|
38420
|
+
virtualModules: new Proxy(shipped.modules, {
|
|
38421
|
+
has: (modules, id) => id in modules || typeof id === "string" && local?.resolve(id) !== void 0,
|
|
38422
|
+
get: (modules, id) => {
|
|
38423
|
+
const path = typeof id === "string" ? local?.resolve(id) : void 0;
|
|
38424
|
+
return path === void 0 ? modules[id] : local.load(path);
|
|
38425
|
+
}
|
|
38426
|
+
}),
|
|
38362
38427
|
alias: shipped.missing,
|
|
38363
38428
|
fsCache: false,
|
|
38364
38429
|
moduleCache: false,
|
|
@@ -38555,12 +38620,9 @@ const namespaceOf = (exported) => typeof exported === "object" && exported !== n
|
|
|
38555
38620
|
* pulled in, transitively.
|
|
38556
38621
|
*/
|
|
38557
38622
|
const loadWorkflows = (module, shipped) => {
|
|
38558
|
-
const
|
|
38559
|
-
const exports = namespaceOf(
|
|
38560
|
-
|
|
38561
|
-
cache
|
|
38562
|
-
}));
|
|
38563
|
-
const file = fileFrom(exports, module.filepath, Object.keys(cache));
|
|
38623
|
+
const { exports: evaluated, files } = module.read === void 0 ? evaluateFromDisk(module, shipped) : evaluateRead(module, module.read, shipped);
|
|
38624
|
+
const exports = namespaceOf(evaluated);
|
|
38625
|
+
const file = fileFrom(exports, module.filepath, files);
|
|
38564
38626
|
const exported = Object.entries(exports).filter(([name, value]) => !RESERVED_EXPORTS.has(name) && isWorkflow(value));
|
|
38565
38627
|
const value = defaultExport(exports);
|
|
38566
38628
|
const defaultName = exported.find(([, other]) => other === value)?.[0] ?? "default";
|
|
@@ -38584,6 +38646,49 @@ const loadWorkflows = (module, shipped) => {
|
|
|
38584
38646
|
diagnostics: nameRejections(rejections)
|
|
38585
38647
|
};
|
|
38586
38648
|
};
|
|
38649
|
+
const evaluateFromDisk = (module, shipped) => {
|
|
38650
|
+
const cache = {};
|
|
38651
|
+
return {
|
|
38652
|
+
exports: jiti(shipped).evalModule(module.source, {
|
|
38653
|
+
filename: module.filepath,
|
|
38654
|
+
cache
|
|
38655
|
+
}),
|
|
38656
|
+
files: Object.keys(cache)
|
|
38657
|
+
};
|
|
38658
|
+
};
|
|
38659
|
+
const moduleCandidates = (path) => [
|
|
38660
|
+
path,
|
|
38661
|
+
path.replace(/\.js$/, ".ts"),
|
|
38662
|
+
path.replace(/\.mjs$/, ".mts"),
|
|
38663
|
+
`${path}.ts`,
|
|
38664
|
+
join(path, "index.ts")
|
|
38665
|
+
];
|
|
38666
|
+
/**
|
|
38667
|
+
* Evaluates the config with every local module it imports taken from `read`
|
|
38668
|
+
* instead of the disk. jiti matches a virtual module on the specifier as
|
|
38669
|
+
* written, so each module gets its own instance resolving against its own
|
|
38670
|
+
* directory. A specifier `read` cannot serve falls through to the disk, and
|
|
38671
|
+
* fails the way a missing file does.
|
|
38672
|
+
*/
|
|
38673
|
+
const evaluateRead = (module, read, shipped) => {
|
|
38674
|
+
const files = [module.filepath];
|
|
38675
|
+
const evaluated = /* @__PURE__ */ new Map();
|
|
38676
|
+
const evaluate = (filepath, source) => jiti(shipped, {
|
|
38677
|
+
resolve: (specifier) => /^\.\.?\//.test(specifier) ? moduleCandidates(join(dirname(filepath), specifier)).find((candidate) => read(candidate) !== void 0) : void 0,
|
|
38678
|
+
load: (path) => {
|
|
38679
|
+
if (!evaluated.has(path)) {
|
|
38680
|
+
evaluated.set(path, {});
|
|
38681
|
+
files.push(path);
|
|
38682
|
+
evaluated.set(path, evaluate(path, read(path)));
|
|
38683
|
+
}
|
|
38684
|
+
return evaluated.get(path);
|
|
38685
|
+
}
|
|
38686
|
+
}).evalModule(source, { filename: filepath });
|
|
38687
|
+
return {
|
|
38688
|
+
exports: evaluate(module.filepath, module.source),
|
|
38689
|
+
files
|
|
38690
|
+
};
|
|
38691
|
+
};
|
|
38587
38692
|
const isWorkflow = (value) => typeof value === "function" || isFactoryWorkflow(value);
|
|
38588
38693
|
const defaultExport = (exports) => {
|
|
38589
38694
|
const value = exports.default;
|
|
@@ -38812,35 +38917,6 @@ const resolveScopeAccess = (def, skills, vars) => gen(function* () {
|
|
|
38812
38917
|
//#region src/workflow/Workflow.ts
|
|
38813
38918
|
const knownModes = (def) => Object.keys(def.modes);
|
|
38814
38919
|
//#endregion
|
|
38815
|
-
//#region src/workflow/fingerprint.ts
|
|
38816
|
-
const HASH_LENGTH = 16;
|
|
38817
|
-
const CONTROL_CHARACTER = /[\x00-\x1f\x7f-\x9f]/;
|
|
38818
|
-
const contentHash = (content) => createHash("sha256").update(content).digest("hex").slice(0, HASH_LENGTH);
|
|
38819
|
-
const realOr = (path) => {
|
|
38820
|
-
try {
|
|
38821
|
-
return realpathSync(path);
|
|
38822
|
-
} catch {
|
|
38823
|
-
return path;
|
|
38824
|
-
}
|
|
38825
|
-
};
|
|
38826
|
-
const configFingerprint = (files, root) => {
|
|
38827
|
-
const fingerprint = {};
|
|
38828
|
-
const realRoot = realOr(root);
|
|
38829
|
-
for (const file of files) {
|
|
38830
|
-
const path = relative(realRoot, realOr(file)).split(sep).join("/");
|
|
38831
|
-
if (CONTROL_CHARACTER.test(path)) continue;
|
|
38832
|
-
let content;
|
|
38833
|
-
try {
|
|
38834
|
-
content = readFileSync(file);
|
|
38835
|
-
} catch {
|
|
38836
|
-
continue;
|
|
38837
|
-
}
|
|
38838
|
-
fingerprint[path] = contentHash(content);
|
|
38839
|
-
}
|
|
38840
|
-
return fingerprint;
|
|
38841
|
-
};
|
|
38842
|
-
const changedConfigFiles = (recorded, current) => [.../* @__PURE__ */ new Set([...Object.keys(recorded), ...Object.keys(current)])].filter((path) => recorded[path] !== current[path]).sort();
|
|
38843
|
-
//#endregion
|
|
38844
38920
|
//#region src/step/planStep.ts
|
|
38845
38921
|
/**
|
|
38846
38922
|
* At the human review gate an unconditional `gtd uncheck '<file>'` runs
|
|
@@ -39561,7 +39637,7 @@ const restAt = (ref, startOverrides = {}) => gen(function* () {
|
|
|
39561
39637
|
path: e.path
|
|
39562
39638
|
})) : [];
|
|
39563
39639
|
const memory = memoryOf(outcome.trace, run);
|
|
39564
|
-
const configNow =
|
|
39640
|
+
const configNow = config.fingerprint;
|
|
39565
39641
|
if (ref === void 0) yield* warnConfigChanges(run, configNow, workspace);
|
|
39566
39642
|
return {
|
|
39567
39643
|
def,
|
|
@@ -39790,7 +39866,7 @@ const inRepoConfigPaths = (root, files, recorded) => {
|
|
|
39790
39866
|
const configRefusal = (tip, paths) => /* @__PURE__ */ new Error(`gtd history: refused — config differs at ${tip.slice(0, 7)}: ${paths.join(", ")}. A history ref replays under today's config, so it is unreadable after the config changes`);
|
|
39791
39867
|
const differingConfigPaths = (git, workspace, root, config, run, hash) => gen(function* () {
|
|
39792
39868
|
const differing = [];
|
|
39793
|
-
for (const path of inRepoConfigPaths(root, config.
|
|
39869
|
+
for (const path of inRepoConfigPaths(root, Object.keys(config.fingerprint), run.pinnedConfig?.files ?? {})) if ((yield* orElseSucceed(git.readFileAtRef(hash, path), () => void 0)) !== workspace.readSync(path)) differing.push(path);
|
|
39794
39870
|
return differing;
|
|
39795
39871
|
});
|
|
39796
39872
|
const notClosedError = (hash, outcome) => outcome.kind === "rest" ? /* @__PURE__ */ new Error(`gtd history: ${hash.slice(0, 7)} does not close a process under today's config`) : replayError(outcome) ?? /* @__PURE__ */ new Error("gtd history: replay failed");
|
|
@@ -40784,12 +40860,6 @@ const runValidateCommand = (out) => gen(function* () {
|
|
|
40784
40860
|
const resolved = yield* resolveValidateScript(rest);
|
|
40785
40861
|
out.write(resolved !== void 0 && resolved.script.length > 0 ? `${resolved.script}\n` : `nothing to validate at "${rest.state}"\n`);
|
|
40786
40862
|
});
|
|
40787
|
-
/** `file:line:col: message` — the shape editors and grep already jump on. Stored 0-based, printed 1-based. A finding with a `line` but no `range`, or none at all, degrades to the shorter forms. */
|
|
40788
|
-
const formatFinding = (file, finding) => {
|
|
40789
|
-
if (finding.line === void 0) return finding.message;
|
|
40790
|
-
const col = finding.range !== void 0 ? `:${finding.range.start.character + 1}` : "";
|
|
40791
|
-
return `${file}:${finding.line + 1}${col}: ${finding.message}`;
|
|
40792
|
-
};
|
|
40793
40863
|
/**
|
|
40794
40864
|
* Runs `<mode>`'s parser over `<file>`, exiting non-zero on any finding.
|
|
40795
40865
|
* Resolves no workflow state and reads no config — this is what a seeded
|
|
@@ -42159,9 +42229,9 @@ function getErrorShape(opts) {
|
|
|
42159
42229
|
};
|
|
42160
42230
|
if (config.isDev && typeof opts.error.stack === "string") shape.data.stack = opts.error.stack;
|
|
42161
42231
|
if (typeof path === "string") shape.data.path = path;
|
|
42162
|
-
return config.errorFormatter((0, import_objectSpread2$
|
|
42232
|
+
return config.errorFormatter((0, import_objectSpread2$7.default)((0, import_objectSpread2$7.default)({}, opts), {}, { shape }));
|
|
42163
42233
|
}
|
|
42164
|
-
var __create, __defProp, __getOwnPropDesc, __getOwnPropNames, __getProtoOf, __hasOwnProp, __commonJS, __copyProps, __toESM, noop, freezeIfAvailable, createRecursiveProxy, JSONRPC2_TO_HTTP_CODE, require_typeof, require_toPrimitive, require_toPropertyKey, require_defineProperty, require_objectSpread2, import_objectSpread2$
|
|
42234
|
+
var __create, __defProp, __getOwnPropDesc, __getOwnPropNames, __getProtoOf, __hasOwnProp, __commonJS, __copyProps, __toESM, noop, freezeIfAvailable, createRecursiveProxy, JSONRPC2_TO_HTTP_CODE, require_typeof, require_toPrimitive, require_toPropertyKey, require_defineProperty, require_objectSpread2, import_objectSpread2$7;
|
|
42165
42235
|
var init_getErrorShape_BPSzUA7W = __esmMin((() => {
|
|
42166
42236
|
init_codes_DagpWZLc();
|
|
42167
42237
|
__create = Object.create;
|
|
@@ -42286,7 +42356,7 @@ var init_getErrorShape_BPSzUA7W = __esmMin((() => {
|
|
|
42286
42356
|
}
|
|
42287
42357
|
module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
42288
42358
|
} });
|
|
42289
|
-
import_objectSpread2$
|
|
42359
|
+
import_objectSpread2$7 = __toESM(require_objectSpread2(), 1);
|
|
42290
42360
|
}));
|
|
42291
42361
|
//#endregion
|
|
42292
42362
|
//#region node_modules/@trpc/server/dist/tracked-DWInO6EQ.mjs
|
|
@@ -42321,8 +42391,8 @@ function getDataTransformer(transformer) {
|
|
|
42321
42391
|
};
|
|
42322
42392
|
}
|
|
42323
42393
|
function transformTRPCResponseItem(config, item) {
|
|
42324
|
-
if ("error" in item) return (0, import_objectSpread2$1$
|
|
42325
|
-
if ("data" in item.result) return (0, import_objectSpread2$1$
|
|
42394
|
+
if ("error" in item) return (0, import_objectSpread2$1$6.default)((0, import_objectSpread2$1$6.default)({}, item), {}, { error: config.transformer.output.serialize(item.error) });
|
|
42395
|
+
if ("data" in item.result) return (0, import_objectSpread2$1$6.default)((0, import_objectSpread2$1$6.default)({}, item), {}, { result: (0, import_objectSpread2$1$6.default)((0, import_objectSpread2$1$6.default)({}, item.result), {}, { data: config.transformer.output.serialize(item.result.data) }) });
|
|
42326
42396
|
return item;
|
|
42327
42397
|
}
|
|
42328
42398
|
/**
|
|
@@ -42403,13 +42473,13 @@ function createRouterFactory(config) {
|
|
|
42403
42473
|
return aggregate;
|
|
42404
42474
|
}
|
|
42405
42475
|
const record = step(input);
|
|
42406
|
-
const _def = (0, import_objectSpread2$
|
|
42476
|
+
const _def = (0, import_objectSpread2$4.default)((0, import_objectSpread2$4.default)({
|
|
42407
42477
|
_config: config,
|
|
42408
42478
|
router: true,
|
|
42409
42479
|
procedures,
|
|
42410
42480
|
lazy: lazy$1
|
|
42411
42481
|
}, emptyRouter), {}, { record });
|
|
42412
|
-
return (0, import_objectSpread2$
|
|
42482
|
+
return (0, import_objectSpread2$4.default)((0, import_objectSpread2$4.default)({}, record), {}, {
|
|
42413
42483
|
_def,
|
|
42414
42484
|
createCaller: createCallerFactory()({ _def })
|
|
42415
42485
|
});
|
|
@@ -42500,7 +42570,7 @@ function mergeRouters(...routerList) {
|
|
|
42500
42570
|
function isTrackedEnvelope(value) {
|
|
42501
42571
|
return Array.isArray(value) && value[2] === trackedSymbol;
|
|
42502
42572
|
}
|
|
42503
|
-
var defaultFormatter, import_defineProperty$2, UnknownCauseError, TRPCError, import_objectSpread2$1$
|
|
42573
|
+
var defaultFormatter, import_defineProperty$2, UnknownCauseError, TRPCError, import_objectSpread2$1$6, defaultTransformer, import_objectSpread2$4, lazyMarker, emptyRouter, reservedWords, trackedSymbol;
|
|
42504
42574
|
var init_tracked_DWInO6EQ = __esmMin((() => {
|
|
42505
42575
|
init_getErrorShape_BPSzUA7W();
|
|
42506
42576
|
init_codes_DagpWZLc();
|
|
@@ -42527,7 +42597,7 @@ var init_tracked_DWInO6EQ = __esmMin((() => {
|
|
|
42527
42597
|
(_this$cause = this.cause) !== null && _this$cause !== void 0 || (this.cause = cause);
|
|
42528
42598
|
}
|
|
42529
42599
|
};
|
|
42530
|
-
import_objectSpread2$1$
|
|
42600
|
+
import_objectSpread2$1$6 = __toESM(require_objectSpread2(), 1);
|
|
42531
42601
|
defaultTransformer = {
|
|
42532
42602
|
input: {
|
|
42533
42603
|
serialize: (obj) => obj,
|
|
@@ -42538,7 +42608,7 @@ var init_tracked_DWInO6EQ = __esmMin((() => {
|
|
|
42538
42608
|
deserialize: (obj) => obj
|
|
42539
42609
|
}
|
|
42540
42610
|
};
|
|
42541
|
-
import_objectSpread2$
|
|
42611
|
+
import_objectSpread2$4 = __toESM(require_objectSpread2(), 1);
|
|
42542
42612
|
lazyMarker = "lazyMarker";
|
|
42543
42613
|
emptyRouter = {
|
|
42544
42614
|
_ctx: null,
|
|
@@ -43589,7 +43659,7 @@ async function resolveResponse(opts) {
|
|
|
43589
43659
|
}));
|
|
43590
43660
|
return isObservable(result.data) ? observableToAsyncIterable(result.data, opts.req.signal) : result.data;
|
|
43591
43661
|
});
|
|
43592
|
-
const stream = sseStreamProducer((0, import_objectSpread2$
|
|
43662
|
+
const stream = sseStreamProducer((0, import_objectSpread2$5.default)((0, import_objectSpread2$5.default)({}, config.sse), {}, {
|
|
43593
43663
|
data: iterable,
|
|
43594
43664
|
serialize: (v) => config.transformer.output.serialize(v),
|
|
43595
43665
|
formatError(errorOpts) {
|
|
@@ -43664,7 +43734,7 @@ async function resolveResponse(opts) {
|
|
|
43664
43734
|
headers,
|
|
43665
43735
|
untransformedJSON: null
|
|
43666
43736
|
});
|
|
43667
|
-
const stream = jsonlStreamProducer((0, import_objectSpread2$
|
|
43737
|
+
const stream = jsonlStreamProducer((0, import_objectSpread2$5.default)((0, import_objectSpread2$5.default)({}, config.jsonl), {}, {
|
|
43668
43738
|
maxDepth: Infinity,
|
|
43669
43739
|
data: rpcCalls.map(async (res, index) => {
|
|
43670
43740
|
const [error, result] = await res;
|
|
@@ -43788,13 +43858,13 @@ async function resolveResponse(opts) {
|
|
|
43788
43858
|
});
|
|
43789
43859
|
}
|
|
43790
43860
|
}
|
|
43791
|
-
var import_objectSpread2$1$
|
|
43861
|
+
var import_objectSpread2$1$4, jsonContentTypeHandler, handlers, import_defineProperty$1, _Symbol$toStringTag, subscribableCache, NOOP, Unpromise, _Symbol, _Symbol$dispose, _Symbol2, _Symbol2$asyncDispose, disposablePromiseTimerResult, require_usingCtx, require_OverloadYield, require_awaitAsyncGenerator, require_wrapAsyncGenerator, import_usingCtx$4, import_awaitAsyncGenerator$4, import_wrapAsyncGenerator$5, import_usingCtx$3, import_awaitAsyncGenerator$3, import_wrapAsyncGenerator$4, import_usingCtx$2, import_awaitAsyncGenerator$2, import_wrapAsyncGenerator$3, PING_SYM, require_asyncIterator, import_awaitAsyncGenerator$1, import_wrapAsyncGenerator$2, import_usingCtx$1, import_asyncIterator$1, CHUNK_VALUE_TYPE_PROMISE, CHUNK_VALUE_TYPE_ASYNC_ITERABLE, PROMISE_STATUS_FULFILLED, PROMISE_STATUS_REJECTED, ASYNC_ITERABLE_STATUS_RETURN, ASYNC_ITERABLE_STATUS_YIELD, ASYNC_ITERABLE_STATUS_ERROR, MaxDepthError, require_asyncGeneratorDelegate, import_asyncIterator, import_awaitAsyncGenerator, import_wrapAsyncGenerator$1, import_asyncGeneratorDelegate, PING_EVENT, SERIALIZED_ERROR_EVENT, CONNECTED_EVENT, RETURN_EVENT, sseHeaders, import_wrapAsyncGenerator, import_objectSpread2$5, TYPE_ACCEPTED_METHOD_MAP, TYPE_ACCEPTED_METHOD_MAP_WITH_METHOD_OVERRIDE;
|
|
43792
43862
|
var init_resolveResponse_CdASWfAV = __esmMin((() => {
|
|
43793
43863
|
init_getErrorShape_BPSzUA7W();
|
|
43794
43864
|
init_codes_DagpWZLc();
|
|
43795
43865
|
init_tracked_DWInO6EQ();
|
|
43796
43866
|
init_observable_UMO3vUa_();
|
|
43797
|
-
import_objectSpread2$1$
|
|
43867
|
+
import_objectSpread2$1$4 = __toESM(require_objectSpread2(), 1);
|
|
43798
43868
|
jsonContentTypeHandler = {
|
|
43799
43869
|
isMatch(req) {
|
|
43800
43870
|
var _req$headers$get;
|
|
@@ -43844,7 +43914,7 @@ var init_resolveResponse_CdASWfAV = __esmMin((() => {
|
|
|
43844
43914
|
if ((procedure === null || procedure === void 0 ? void 0 : procedure._def.type) === "subscription") {
|
|
43845
43915
|
var _ref2, _opts$headers$get;
|
|
43846
43916
|
const lastEventId = (_ref2 = (_opts$headers$get = opts.headers.get("last-event-id")) !== null && _opts$headers$get !== void 0 ? _opts$headers$get : opts.searchParams.get("lastEventId")) !== null && _ref2 !== void 0 ? _ref2 : opts.searchParams.get("Last-Event-Id");
|
|
43847
|
-
if (lastEventId) if (isObject$2(input)) input = (0, import_objectSpread2$1$
|
|
43917
|
+
if (lastEventId) if (isObject$2(input)) input = (0, import_objectSpread2$1$4.default)((0, import_objectSpread2$1$4.default)({}, input), {}, { lastEventId });
|
|
43848
43918
|
else {
|
|
43849
43919
|
var _input;
|
|
43850
43920
|
(_input = input) !== null && _input !== void 0 || (input = { lastEventId });
|
|
@@ -44354,7 +44424,7 @@ var init_resolveResponse_CdASWfAV = __esmMin((() => {
|
|
|
44354
44424
|
Connection: "keep-alive"
|
|
44355
44425
|
};
|
|
44356
44426
|
import_wrapAsyncGenerator = __toESM(require_wrapAsyncGenerator(), 1);
|
|
44357
|
-
import_objectSpread2$
|
|
44427
|
+
import_objectSpread2$5 = __toESM(require_objectSpread2(), 1);
|
|
44358
44428
|
TYPE_ACCEPTED_METHOD_MAP = {
|
|
44359
44429
|
mutation: ["POST"],
|
|
44360
44430
|
query: ["GET"],
|
|
@@ -44367,570 +44437,58 @@ var init_resolveResponse_CdASWfAV = __esmMin((() => {
|
|
|
44367
44437
|
};
|
|
44368
44438
|
}));
|
|
44369
44439
|
//#endregion
|
|
44370
|
-
//#region node_modules/@trpc/server/dist/
|
|
44371
|
-
|
|
44372
|
-
|
|
44373
|
-
|
|
44374
|
-
|
|
44375
|
-
|
|
44376
|
-
|
|
44377
|
-
|
|
44378
|
-
|
|
44379
|
-
|
|
44380
|
-
|
|
44381
|
-
|
|
44382
|
-
|
|
44383
|
-
|
|
44384
|
-
|
|
44385
|
-
|
|
44386
|
-
|
|
44387
|
-
|
|
44388
|
-
|
|
44389
|
-
|
|
44390
|
-
|
|
44391
|
-
|
|
44392
|
-
*/
|
|
44393
|
-
function createInputMiddleware(parse) {
|
|
44394
|
-
const inputMiddleware = async function inputValidatorMiddleware(opts) {
|
|
44395
|
-
let parsedInput;
|
|
44396
|
-
const rawInput = await opts.getRawInput();
|
|
44397
|
-
try {
|
|
44398
|
-
parsedInput = await parse(rawInput);
|
|
44399
|
-
} catch (cause) {
|
|
44400
|
-
throw new TRPCError({
|
|
44401
|
-
code: "BAD_REQUEST",
|
|
44402
|
-
cause
|
|
44403
|
-
});
|
|
44404
|
-
}
|
|
44405
|
-
const combinedInput = isObject$2(opts.input) && isObject$2(parsedInput) ? (0, import_objectSpread2$2.default)((0, import_objectSpread2$2.default)({}, opts.input), parsedInput) : parsedInput;
|
|
44406
|
-
return opts.next({ input: combinedInput });
|
|
44407
|
-
};
|
|
44408
|
-
inputMiddleware._type = "input";
|
|
44409
|
-
return inputMiddleware;
|
|
44410
|
-
}
|
|
44411
|
-
/**
|
|
44412
|
-
* @internal
|
|
44413
|
-
*/
|
|
44414
|
-
function createOutputMiddleware(parse) {
|
|
44415
|
-
const outputMiddleware = async function outputValidatorMiddleware({ next }) {
|
|
44416
|
-
const result = await next();
|
|
44417
|
-
if (!result.ok) return result;
|
|
44418
|
-
try {
|
|
44419
|
-
const data = await parse(result.data);
|
|
44420
|
-
return (0, import_objectSpread2$2.default)((0, import_objectSpread2$2.default)({}, result), {}, { data });
|
|
44421
|
-
} catch (cause) {
|
|
44422
|
-
throw new TRPCError({
|
|
44423
|
-
message: "Output validation failed",
|
|
44424
|
-
code: "INTERNAL_SERVER_ERROR",
|
|
44425
|
-
cause
|
|
44426
|
-
});
|
|
44427
|
-
}
|
|
44428
|
-
};
|
|
44429
|
-
outputMiddleware._type = "output";
|
|
44430
|
-
return outputMiddleware;
|
|
44431
|
-
}
|
|
44432
|
-
function getParseFn(procedureParser) {
|
|
44433
|
-
const parser = procedureParser;
|
|
44434
|
-
const isStandardSchema = "~standard" in parser;
|
|
44435
|
-
if (typeof parser === "function" && typeof parser.assert === "function") return parser.assert.bind(parser);
|
|
44436
|
-
if (typeof parser === "function" && !isStandardSchema) return parser;
|
|
44437
|
-
if (typeof parser.parseAsync === "function") return parser.parseAsync.bind(parser);
|
|
44438
|
-
if (typeof parser.parse === "function") return parser.parse.bind(parser);
|
|
44439
|
-
if (typeof parser.validateSync === "function") return parser.validateSync.bind(parser);
|
|
44440
|
-
if (typeof parser.create === "function") return parser.create.bind(parser);
|
|
44441
|
-
if (typeof parser.assert === "function") return (value) => {
|
|
44442
|
-
parser.assert(value);
|
|
44443
|
-
return value;
|
|
44444
|
-
};
|
|
44445
|
-
if (isStandardSchema) return async (value) => {
|
|
44446
|
-
const result = await parser["~standard"].validate(value);
|
|
44447
|
-
if (result.issues) throw new StandardSchemaV1Error(result.issues);
|
|
44448
|
-
return result.value;
|
|
44449
|
-
};
|
|
44450
|
-
throw new Error("Could not find a validator fn");
|
|
44451
|
-
}
|
|
44452
|
-
function createNewBuilder(def1, def2) {
|
|
44453
|
-
const { middlewares = [], inputs, meta } = def2, rest = (0, import_objectWithoutProperties.default)(def2, _excluded);
|
|
44454
|
-
return createBuilder((0, import_objectSpread2$1$1.default)((0, import_objectSpread2$1$1.default)({}, mergeWithoutOverrides(def1, rest)), {}, {
|
|
44455
|
-
inputs: [...def1.inputs, ...inputs !== null && inputs !== void 0 ? inputs : []],
|
|
44456
|
-
middlewares: [...def1.middlewares, ...middlewares],
|
|
44457
|
-
meta: def1.meta && meta ? (0, import_objectSpread2$1$1.default)((0, import_objectSpread2$1$1.default)({}, def1.meta), meta) : meta !== null && meta !== void 0 ? meta : def1.meta
|
|
44458
|
-
}));
|
|
44459
|
-
}
|
|
44460
|
-
function createBuilder(initDef = {}) {
|
|
44461
|
-
const _def = (0, import_objectSpread2$1$1.default)({
|
|
44462
|
-
procedure: true,
|
|
44463
|
-
inputs: [],
|
|
44464
|
-
middlewares: []
|
|
44465
|
-
}, initDef);
|
|
44466
|
-
return {
|
|
44467
|
-
_def,
|
|
44468
|
-
input(input) {
|
|
44469
|
-
const parser = getParseFn(input);
|
|
44470
|
-
return createNewBuilder(_def, {
|
|
44471
|
-
inputs: [input],
|
|
44472
|
-
middlewares: [createInputMiddleware(parser)]
|
|
44473
|
-
});
|
|
44474
|
-
},
|
|
44475
|
-
output(output) {
|
|
44476
|
-
const parser = getParseFn(output);
|
|
44477
|
-
return createNewBuilder(_def, {
|
|
44478
|
-
output,
|
|
44479
|
-
middlewares: [createOutputMiddleware(parser)]
|
|
44480
|
-
});
|
|
44481
|
-
},
|
|
44482
|
-
meta(meta) {
|
|
44483
|
-
return createNewBuilder(_def, { meta });
|
|
44484
|
-
},
|
|
44485
|
-
use(middlewareBuilderOrFn) {
|
|
44486
|
-
const middlewares = "_middlewares" in middlewareBuilderOrFn ? middlewareBuilderOrFn._middlewares : [middlewareBuilderOrFn];
|
|
44487
|
-
return createNewBuilder(_def, { middlewares });
|
|
44488
|
-
},
|
|
44489
|
-
unstable_concat(builder$1) {
|
|
44490
|
-
return createNewBuilder(_def, builder$1._def);
|
|
44491
|
-
},
|
|
44492
|
-
concat(builder$1) {
|
|
44493
|
-
return createNewBuilder(_def, builder$1._def);
|
|
44494
|
-
},
|
|
44495
|
-
query(resolver) {
|
|
44496
|
-
return createResolver((0, import_objectSpread2$1$1.default)((0, import_objectSpread2$1$1.default)({}, _def), {}, { type: "query" }), resolver);
|
|
44497
|
-
},
|
|
44498
|
-
mutation(resolver) {
|
|
44499
|
-
return createResolver((0, import_objectSpread2$1$1.default)((0, import_objectSpread2$1$1.default)({}, _def), {}, { type: "mutation" }), resolver);
|
|
44500
|
-
},
|
|
44501
|
-
subscription(resolver) {
|
|
44502
|
-
return createResolver((0, import_objectSpread2$1$1.default)((0, import_objectSpread2$1$1.default)({}, _def), {}, { type: "subscription" }), resolver);
|
|
44440
|
+
//#region node_modules/@trpc/server/dist/adapters/fetch/index.mjs
|
|
44441
|
+
async function fetchRequestHandler(opts) {
|
|
44442
|
+
const resHeaders = new Headers();
|
|
44443
|
+
const createContext = async (innerOpts) => {
|
|
44444
|
+
var _opts$createContext;
|
|
44445
|
+
return (_opts$createContext = opts.createContext) === null || _opts$createContext === void 0 ? void 0 : _opts$createContext.call(opts, (0, import_objectSpread2$3.default)({
|
|
44446
|
+
req: opts.req,
|
|
44447
|
+
resHeaders
|
|
44448
|
+
}, innerOpts));
|
|
44449
|
+
};
|
|
44450
|
+
const url = new URL(opts.req.url);
|
|
44451
|
+
const pathname = trimSlashes(url.pathname);
|
|
44452
|
+
const endpoint = trimSlashes(opts.endpoint);
|
|
44453
|
+
const path = trimSlashes(pathname.slice(endpoint.length));
|
|
44454
|
+
return await resolveResponse((0, import_objectSpread2$3.default)((0, import_objectSpread2$3.default)({}, opts), {}, {
|
|
44455
|
+
req: opts.req,
|
|
44456
|
+
createContext,
|
|
44457
|
+
path,
|
|
44458
|
+
error: null,
|
|
44459
|
+
onError(o) {
|
|
44460
|
+
var _opts$onError;
|
|
44461
|
+
opts === null || opts === void 0 || (_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, (0, import_objectSpread2$3.default)((0, import_objectSpread2$3.default)({}, o), {}, { req: opts.req }));
|
|
44503
44462
|
},
|
|
44504
|
-
|
|
44505
|
-
|
|
44506
|
-
|
|
44507
|
-
|
|
44508
|
-
|
|
44509
|
-
|
|
44510
|
-
|
|
44511
|
-
|
|
44512
|
-
|
|
44513
|
-
|
|
44514
|
-
|
|
44515
|
-
marker: middlewareMarker,
|
|
44516
|
-
ok: true,
|
|
44517
|
-
data,
|
|
44518
|
-
ctx: opts.ctx
|
|
44519
|
-
};
|
|
44520
|
-
}]
|
|
44521
|
-
});
|
|
44522
|
-
const _def = (0, import_objectSpread2$1$1.default)((0, import_objectSpread2$1$1.default)({}, finalBuilder._def), {}, {
|
|
44523
|
-
type: _defIn.type,
|
|
44524
|
-
experimental_caller: Boolean(finalBuilder._def.caller),
|
|
44525
|
-
meta: finalBuilder._def.meta,
|
|
44526
|
-
$types: null
|
|
44527
|
-
});
|
|
44528
|
-
const invoke = createProcedureCaller(finalBuilder._def);
|
|
44529
|
-
const callerOverride = finalBuilder._def.caller;
|
|
44530
|
-
if (!callerOverride) return invoke;
|
|
44531
|
-
const callerWrapper = async (...args) => {
|
|
44532
|
-
return await callerOverride({
|
|
44533
|
-
args,
|
|
44534
|
-
invoke,
|
|
44535
|
-
_def
|
|
44536
|
-
});
|
|
44537
|
-
};
|
|
44538
|
-
callerWrapper._def = _def;
|
|
44539
|
-
return callerWrapper;
|
|
44540
|
-
}
|
|
44541
|
-
async function callRecursive(index, _def, opts) {
|
|
44542
|
-
try {
|
|
44543
|
-
const middleware = _def.middlewares[index];
|
|
44544
|
-
return await middleware((0, import_objectSpread2$1$1.default)((0, import_objectSpread2$1$1.default)({}, opts), {}, {
|
|
44545
|
-
meta: _def.meta,
|
|
44546
|
-
input: opts.input,
|
|
44547
|
-
next(_nextOpts) {
|
|
44548
|
-
var _nextOpts$getRawInput;
|
|
44549
|
-
const nextOpts = _nextOpts;
|
|
44550
|
-
return callRecursive(index + 1, _def, (0, import_objectSpread2$1$1.default)((0, import_objectSpread2$1$1.default)({}, opts), {}, {
|
|
44551
|
-
ctx: (nextOpts === null || nextOpts === void 0 ? void 0 : nextOpts.ctx) ? (0, import_objectSpread2$1$1.default)((0, import_objectSpread2$1$1.default)({}, opts.ctx), nextOpts.ctx) : opts.ctx,
|
|
44552
|
-
input: nextOpts && "input" in nextOpts ? nextOpts.input : opts.input,
|
|
44553
|
-
getRawInput: (_nextOpts$getRawInput = nextOpts === null || nextOpts === void 0 ? void 0 : nextOpts.getRawInput) !== null && _nextOpts$getRawInput !== void 0 ? _nextOpts$getRawInput : opts.getRawInput
|
|
44554
|
-
}));
|
|
44555
|
-
}
|
|
44556
|
-
}));
|
|
44557
|
-
} catch (cause) {
|
|
44558
|
-
return {
|
|
44559
|
-
ok: false,
|
|
44560
|
-
error: getTRPCErrorFromUnknown(cause),
|
|
44561
|
-
marker: middlewareMarker
|
|
44562
|
-
};
|
|
44563
|
-
}
|
|
44564
|
-
}
|
|
44565
|
-
function createProcedureCaller(_def) {
|
|
44566
|
-
async function procedure(opts) {
|
|
44567
|
-
if (!opts || !("getRawInput" in opts)) throw new Error(codeblock);
|
|
44568
|
-
const result = await callRecursive(0, _def, opts);
|
|
44569
|
-
if (!result) throw new TRPCError({
|
|
44570
|
-
code: "INTERNAL_SERVER_ERROR",
|
|
44571
|
-
message: "No result from middlewares - did you forget to `return next()`?"
|
|
44572
|
-
});
|
|
44573
|
-
if (!result.ok) throw result.error;
|
|
44574
|
-
return result.data;
|
|
44575
|
-
}
|
|
44576
|
-
procedure._def = _def;
|
|
44577
|
-
procedure.procedure = true;
|
|
44578
|
-
procedure.meta = _def.meta;
|
|
44579
|
-
return procedure;
|
|
44580
|
-
}
|
|
44581
|
-
var import_objectSpread2$2, middlewareMarker, import_defineProperty, StandardSchemaV1Error, require_objectWithoutPropertiesLoose, import_objectWithoutProperties, import_objectSpread2$1$1, _excluded, codeblock, _globalThis$process, _globalThis$process2, _globalThis$process3, isServerDefault, import_objectSpread2$3, initTRPC;
|
|
44582
|
-
var init_initTRPC_BRf4imah = __esmMin((() => {
|
|
44583
|
-
init_getErrorShape_BPSzUA7W();
|
|
44584
|
-
init_codes_DagpWZLc();
|
|
44585
|
-
init_tracked_DWInO6EQ();
|
|
44586
|
-
import_objectSpread2$2 = __toESM(require_objectSpread2(), 1);
|
|
44587
|
-
middlewareMarker = "middlewareMarker";
|
|
44588
|
-
import_defineProperty = __toESM(require_defineProperty(), 1);
|
|
44589
|
-
StandardSchemaV1Error = class extends Error {
|
|
44590
|
-
/**
|
|
44591
|
-
* Creates a schema error with useful information.
|
|
44592
|
-
*
|
|
44593
|
-
* @param issues The schema issues.
|
|
44594
|
-
*/
|
|
44595
|
-
constructor(issues) {
|
|
44596
|
-
var _issues$;
|
|
44597
|
-
super((_issues$ = issues[0]) === null || _issues$ === void 0 ? void 0 : _issues$.message);
|
|
44598
|
-
(0, import_defineProperty.default)(this, "issues", void 0);
|
|
44599
|
-
this.name = "SchemaError";
|
|
44600
|
-
this.issues = issues;
|
|
44601
|
-
}
|
|
44602
|
-
};
|
|
44603
|
-
require_objectWithoutPropertiesLoose = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js"(exports, module) {
|
|
44604
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
44605
|
-
if (null == r) return {};
|
|
44606
|
-
var t = {};
|
|
44607
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
44608
|
-
if (e.includes(n)) continue;
|
|
44609
|
-
t[n] = r[n];
|
|
44610
|
-
}
|
|
44611
|
-
return t;
|
|
44612
|
-
}
|
|
44613
|
-
module.exports = _objectWithoutPropertiesLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
44614
|
-
} });
|
|
44615
|
-
import_objectWithoutProperties = __toESM(__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js"(exports, module) {
|
|
44616
|
-
var objectWithoutPropertiesLoose = require_objectWithoutPropertiesLoose();
|
|
44617
|
-
function _objectWithoutProperties$1(e, t) {
|
|
44618
|
-
if (null == e) return {};
|
|
44619
|
-
var o, r, i = objectWithoutPropertiesLoose(e, t);
|
|
44620
|
-
if (Object.getOwnPropertySymbols) {
|
|
44621
|
-
var s = Object.getOwnPropertySymbols(e);
|
|
44622
|
-
for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
44463
|
+
responseMeta(data) {
|
|
44464
|
+
var _opts$responseMeta;
|
|
44465
|
+
const meta = (_opts$responseMeta = opts.responseMeta) === null || _opts$responseMeta === void 0 ? void 0 : _opts$responseMeta.call(opts, data);
|
|
44466
|
+
if (meta === null || meta === void 0 ? void 0 : meta.headers) {
|
|
44467
|
+
if (meta.headers instanceof Headers) for (const [key, value] of meta.headers.entries()) resHeaders.append(key, value);
|
|
44468
|
+
else
|
|
44469
|
+
/**
|
|
44470
|
+
* @deprecated, delete in v12
|
|
44471
|
+
*/
|
|
44472
|
+
for (const [key, value] of Object.entries(meta.headers)) if (Array.isArray(value)) for (const v of value) resHeaders.append(key, v);
|
|
44473
|
+
else if (typeof value === "string") resHeaders.set(key, value);
|
|
44623
44474
|
}
|
|
44624
|
-
return i;
|
|
44625
|
-
}
|
|
44626
|
-
module.exports = _objectWithoutProperties$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
44627
|
-
} })(), 1);
|
|
44628
|
-
import_objectSpread2$1$1 = __toESM(require_objectSpread2(), 1);
|
|
44629
|
-
_excluded = [
|
|
44630
|
-
"middlewares",
|
|
44631
|
-
"inputs",
|
|
44632
|
-
"meta"
|
|
44633
|
-
];
|
|
44634
|
-
codeblock = `
|
|
44635
|
-
This is a client-only function.
|
|
44636
|
-
If you want to call this function on the server, see https://trpc.io/docs/v11/server/server-side-calls
|
|
44637
|
-
`.trim();
|
|
44638
|
-
isServerDefault = typeof window === "undefined" || "Deno" in window || ((_globalThis$process = globalThis.process) === null || _globalThis$process === void 0 || (_globalThis$process = _globalThis$process.env) === null || _globalThis$process === void 0 ? void 0 : _globalThis$process["NODE_ENV"]) === "test" || !!((_globalThis$process2 = globalThis.process) === null || _globalThis$process2 === void 0 || (_globalThis$process2 = _globalThis$process2.env) === null || _globalThis$process2 === void 0 ? void 0 : _globalThis$process2["JEST_WORKER_ID"]) || !!((_globalThis$process3 = globalThis.process) === null || _globalThis$process3 === void 0 || (_globalThis$process3 = _globalThis$process3.env) === null || _globalThis$process3 === void 0 ? void 0 : _globalThis$process3["VITEST_WORKER_ID"]);
|
|
44639
|
-
import_objectSpread2$3 = __toESM(require_objectSpread2(), 1);
|
|
44640
|
-
initTRPC = new class TRPCBuilder {
|
|
44641
|
-
/**
|
|
44642
|
-
* Add a context shape as a generic to the root object
|
|
44643
|
-
* @see https://trpc.io/docs/v11/server/context
|
|
44644
|
-
*/
|
|
44645
|
-
context() {
|
|
44646
|
-
return new TRPCBuilder();
|
|
44647
|
-
}
|
|
44648
|
-
/**
|
|
44649
|
-
* Add a meta shape as a generic to the root object
|
|
44650
|
-
* @see https://trpc.io/docs/v11/quickstart
|
|
44651
|
-
*/
|
|
44652
|
-
meta() {
|
|
44653
|
-
return new TRPCBuilder();
|
|
44654
|
-
}
|
|
44655
|
-
/**
|
|
44656
|
-
* Create the root object
|
|
44657
|
-
* @see https://trpc.io/docs/v11/server/routers#initialize-trpc
|
|
44658
|
-
*/
|
|
44659
|
-
create(opts) {
|
|
44660
|
-
var _opts$transformer, _opts$isDev, _globalThis$process$1, _opts$allowOutsideOfS, _opts$errorFormatter, _opts$isServer;
|
|
44661
|
-
const config = (0, import_objectSpread2$3.default)((0, import_objectSpread2$3.default)({}, opts), {}, {
|
|
44662
|
-
transformer: getDataTransformer((_opts$transformer = opts === null || opts === void 0 ? void 0 : opts.transformer) !== null && _opts$transformer !== void 0 ? _opts$transformer : defaultTransformer),
|
|
44663
|
-
isDev: (_opts$isDev = opts === null || opts === void 0 ? void 0 : opts.isDev) !== null && _opts$isDev !== void 0 ? _opts$isDev : ((_globalThis$process$1 = globalThis.process) === null || _globalThis$process$1 === void 0 ? void 0 : _globalThis$process$1.env["NODE_ENV"]) !== "production",
|
|
44664
|
-
allowOutsideOfServer: (_opts$allowOutsideOfS = opts === null || opts === void 0 ? void 0 : opts.allowOutsideOfServer) !== null && _opts$allowOutsideOfS !== void 0 ? _opts$allowOutsideOfS : false,
|
|
44665
|
-
errorFormatter: (_opts$errorFormatter = opts === null || opts === void 0 ? void 0 : opts.errorFormatter) !== null && _opts$errorFormatter !== void 0 ? _opts$errorFormatter : defaultFormatter,
|
|
44666
|
-
isServer: (_opts$isServer = opts === null || opts === void 0 ? void 0 : opts.isServer) !== null && _opts$isServer !== void 0 ? _opts$isServer : isServerDefault,
|
|
44667
|
-
$types: null
|
|
44668
|
-
});
|
|
44669
|
-
var _opts$isServer2;
|
|
44670
|
-
if (!((_opts$isServer2 = opts === null || opts === void 0 ? void 0 : opts.isServer) !== null && _opts$isServer2 !== void 0 ? _opts$isServer2 : isServerDefault) && (opts === null || opts === void 0 ? void 0 : opts.allowOutsideOfServer) !== true) throw new Error(`You're trying to use @trpc/server in a non-server environment. This is not supported by default.`);
|
|
44671
44475
|
return {
|
|
44672
|
-
|
|
44673
|
-
|
|
44674
|
-
middleware: createMiddlewareFactory(),
|
|
44675
|
-
router: createRouterFactory(config),
|
|
44676
|
-
mergeRouters,
|
|
44677
|
-
createCallerFactory: createCallerFactory()
|
|
44476
|
+
headers: resHeaders,
|
|
44477
|
+
status: meta === null || meta === void 0 ? void 0 : meta.status
|
|
44678
44478
|
};
|
|
44679
44479
|
}
|
|
44680
|
-
}
|
|
44681
|
-
}));
|
|
44682
|
-
//#endregion
|
|
44683
|
-
//#region node_modules/@trpc/server/dist/node-http-gyWQuCv2.mjs
|
|
44684
|
-
function createBody(req, opts) {
|
|
44685
|
-
if ("body" in req) {
|
|
44686
|
-
if (req.body === void 0) return void 0;
|
|
44687
|
-
if (typeof req.body === "string") return req.body;
|
|
44688
|
-
if (req.body instanceof IncomingMessage) return req.body;
|
|
44689
|
-
return JSON.stringify(req.body);
|
|
44690
|
-
}
|
|
44691
|
-
let size = 0;
|
|
44692
|
-
let hasClosed = false;
|
|
44693
|
-
return new ReadableStream({
|
|
44694
|
-
start(controller) {
|
|
44695
|
-
const onData = (chunk) => {
|
|
44696
|
-
size += chunk.length;
|
|
44697
|
-
if (!opts.maxBodySize || size <= opts.maxBodySize) {
|
|
44698
|
-
controller.enqueue(new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength));
|
|
44699
|
-
return;
|
|
44700
|
-
}
|
|
44701
|
-
controller.error(new TRPCError({ code: "PAYLOAD_TOO_LARGE" }));
|
|
44702
|
-
hasClosed = true;
|
|
44703
|
-
req.off("data", onData);
|
|
44704
|
-
req.off("end", onEnd);
|
|
44705
|
-
};
|
|
44706
|
-
const onEnd = () => {
|
|
44707
|
-
if (hasClosed) return;
|
|
44708
|
-
hasClosed = true;
|
|
44709
|
-
req.off("data", onData);
|
|
44710
|
-
req.off("end", onEnd);
|
|
44711
|
-
controller.close();
|
|
44712
|
-
};
|
|
44713
|
-
req.on("data", onData);
|
|
44714
|
-
req.on("end", onEnd);
|
|
44715
|
-
},
|
|
44716
|
-
cancel() {
|
|
44717
|
-
req.destroy();
|
|
44718
|
-
}
|
|
44719
|
-
});
|
|
44720
|
-
}
|
|
44721
|
-
function createURL(req) {
|
|
44722
|
-
try {
|
|
44723
|
-
var _ref, _req$headers$host;
|
|
44724
|
-
const protocol = req.headers[":scheme"] && req.headers[":scheme"] === "https" || req.socket && "encrypted" in req.socket && req.socket.encrypted ? "https:" : "http:";
|
|
44725
|
-
const host = (_ref = (_req$headers$host = req.headers.host) !== null && _req$headers$host !== void 0 ? _req$headers$host : req.headers[":authority"]) !== null && _ref !== void 0 ? _ref : "localhost";
|
|
44726
|
-
return new URL(req.url, `${protocol}//${host}`);
|
|
44727
|
-
} catch (cause) {
|
|
44728
|
-
throw new TRPCError({
|
|
44729
|
-
code: "BAD_REQUEST",
|
|
44730
|
-
message: "Invalid URL",
|
|
44731
|
-
cause
|
|
44732
|
-
});
|
|
44733
|
-
}
|
|
44734
|
-
}
|
|
44735
|
-
function createHeaders(incoming) {
|
|
44736
|
-
const headers = new Headers();
|
|
44737
|
-
for (const key in incoming) {
|
|
44738
|
-
const value = incoming[key];
|
|
44739
|
-
if (typeof key === "string" && key.startsWith(":")) continue;
|
|
44740
|
-
if (Array.isArray(value)) for (const item of value) headers.append(key, item);
|
|
44741
|
-
else if (value != null) headers.append(key, value);
|
|
44742
|
-
}
|
|
44743
|
-
return headers;
|
|
44744
|
-
}
|
|
44745
|
-
/**
|
|
44746
|
-
* Convert an [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
|
|
44747
|
-
*/
|
|
44748
|
-
function incomingMessageToRequest(req, res, opts) {
|
|
44749
|
-
const ac = new AbortController();
|
|
44750
|
-
const onAbort = () => {
|
|
44751
|
-
res.off("close", onAbort);
|
|
44752
|
-
req.off("aborted", onAbort);
|
|
44753
|
-
ac.abort();
|
|
44754
|
-
};
|
|
44755
|
-
res.once("close", onAbort);
|
|
44756
|
-
req.once("aborted", onAbort);
|
|
44757
|
-
const url = createURL(req);
|
|
44758
|
-
const init = {
|
|
44759
|
-
headers: createHeaders(req.headers),
|
|
44760
|
-
method: req.method,
|
|
44761
|
-
signal: ac.signal
|
|
44762
|
-
};
|
|
44763
|
-
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
44764
|
-
init.body = createBody(req, opts);
|
|
44765
|
-
init.duplex = "half";
|
|
44766
|
-
}
|
|
44767
|
-
return new Request(url, init);
|
|
44768
|
-
}
|
|
44769
|
-
async function writeResponseBodyChunk(res, chunk) {
|
|
44770
|
-
if (res.write(chunk) === false) await new Promise((resolve, reject) => {
|
|
44771
|
-
const onError = (err) => {
|
|
44772
|
-
reject(err);
|
|
44773
|
-
cleanup();
|
|
44774
|
-
};
|
|
44775
|
-
const onDrain = () => {
|
|
44776
|
-
resolve();
|
|
44777
|
-
cleanup();
|
|
44778
|
-
};
|
|
44779
|
-
const cleanup = () => {
|
|
44780
|
-
res.off("error", onError);
|
|
44781
|
-
res.off("drain", onDrain);
|
|
44782
|
-
};
|
|
44783
|
-
res.once("error", onError);
|
|
44784
|
-
res.once("drain", onDrain);
|
|
44785
|
-
});
|
|
44786
|
-
}
|
|
44787
|
-
/**
|
|
44788
|
-
* @internal
|
|
44789
|
-
*/
|
|
44790
|
-
async function writeResponseBody(opts) {
|
|
44791
|
-
const { res } = opts;
|
|
44792
|
-
try {
|
|
44793
|
-
const writableStream = new WritableStream({ async write(chunk) {
|
|
44794
|
-
var _res$flush;
|
|
44795
|
-
await writeResponseBodyChunk(res, chunk);
|
|
44796
|
-
(_res$flush = res.flush) === null || _res$flush === void 0 || _res$flush.call(res);
|
|
44797
|
-
} });
|
|
44798
|
-
await opts.body.pipeTo(writableStream, { signal: opts.signal });
|
|
44799
|
-
} catch (err) {
|
|
44800
|
-
if (isAbortError(err)) return;
|
|
44801
|
-
throw err;
|
|
44802
|
-
}
|
|
44803
|
-
}
|
|
44804
|
-
/**
|
|
44805
|
-
* @internal
|
|
44806
|
-
*/
|
|
44807
|
-
async function writeResponse(opts) {
|
|
44808
|
-
const { response, rawResponse } = opts;
|
|
44809
|
-
if (rawResponse.statusCode === 200) rawResponse.statusCode = response.status;
|
|
44810
|
-
for (const [key, value] of response.headers) {
|
|
44811
|
-
if (key.toLowerCase() === "set-cookie") continue;
|
|
44812
|
-
rawResponse.setHeader(key, value);
|
|
44813
|
-
}
|
|
44814
|
-
const cookies = response.headers.getSetCookie();
|
|
44815
|
-
if (cookies.length > 0) rawResponse.setHeader("set-cookie", cookies);
|
|
44816
|
-
try {
|
|
44817
|
-
if (response.body) await writeResponseBody({
|
|
44818
|
-
res: rawResponse,
|
|
44819
|
-
signal: opts.request.signal,
|
|
44820
|
-
body: response.body
|
|
44821
|
-
});
|
|
44822
|
-
} catch (err) {
|
|
44823
|
-
if (!rawResponse.headersSent) rawResponse.statusCode = 500;
|
|
44824
|
-
throw err;
|
|
44825
|
-
} finally {
|
|
44826
|
-
rawResponse.end();
|
|
44827
|
-
}
|
|
44828
|
-
}
|
|
44829
|
-
/**
|
|
44830
|
-
* @internal
|
|
44831
|
-
*/
|
|
44832
|
-
function internal_exceptionHandler(opts) {
|
|
44833
|
-
return (cause) => {
|
|
44834
|
-
var _opts$onError;
|
|
44835
|
-
const { res, req } = opts;
|
|
44836
|
-
const error = getTRPCErrorFromUnknown(cause);
|
|
44837
|
-
const shape = getErrorShape({
|
|
44838
|
-
config: opts.router._def._config,
|
|
44839
|
-
error,
|
|
44840
|
-
type: "unknown",
|
|
44841
|
-
path: void 0,
|
|
44842
|
-
input: void 0,
|
|
44843
|
-
ctx: void 0
|
|
44844
|
-
});
|
|
44845
|
-
(_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, {
|
|
44846
|
-
req,
|
|
44847
|
-
error,
|
|
44848
|
-
type: "unknown",
|
|
44849
|
-
path: void 0,
|
|
44850
|
-
input: void 0,
|
|
44851
|
-
ctx: void 0
|
|
44852
|
-
});
|
|
44853
|
-
const transformed = transformTRPCResponse(opts.router._def._config, { error: shape });
|
|
44854
|
-
res.statusCode = shape.data.httpStatus;
|
|
44855
|
-
res.end(JSON.stringify(transformed));
|
|
44856
|
-
};
|
|
44857
|
-
}
|
|
44858
|
-
/**
|
|
44859
|
-
* @remark the promise never rejects
|
|
44860
|
-
*/
|
|
44861
|
-
async function nodeHTTPRequestHandler(opts) {
|
|
44862
|
-
return new Promise((resolve) => {
|
|
44863
|
-
var _opts$middleware;
|
|
44864
|
-
const handleViaMiddleware = (_opts$middleware = opts.middleware) !== null && _opts$middleware !== void 0 ? _opts$middleware : (_req, _res, next) => next();
|
|
44865
|
-
opts.res.once("finish", () => {
|
|
44866
|
-
resolve();
|
|
44867
|
-
});
|
|
44868
|
-
return handleViaMiddleware(opts.req, opts.res, (err) => {
|
|
44869
|
-
run$2(async () => {
|
|
44870
|
-
var _opts$maxBodySize;
|
|
44871
|
-
const request = incomingMessageToRequest(opts.req, opts.res, { maxBodySize: (_opts$maxBodySize = opts.maxBodySize) !== null && _opts$maxBodySize !== void 0 ? _opts$maxBodySize : null });
|
|
44872
|
-
const createContext = async (innerOpts) => {
|
|
44873
|
-
var _opts$createContext;
|
|
44874
|
-
return await ((_opts$createContext = opts.createContext) === null || _opts$createContext === void 0 ? void 0 : _opts$createContext.call(opts, (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, opts), innerOpts)));
|
|
44875
|
-
};
|
|
44876
|
-
await writeResponse({
|
|
44877
|
-
request,
|
|
44878
|
-
response: await resolveResponse((0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, opts), {}, {
|
|
44879
|
-
req: request,
|
|
44880
|
-
error: err ? getTRPCErrorFromUnknown(err) : null,
|
|
44881
|
-
createContext,
|
|
44882
|
-
onError(o) {
|
|
44883
|
-
var _opts$onError2;
|
|
44884
|
-
opts === null || opts === void 0 || (_opts$onError2 = opts.onError) === null || _opts$onError2 === void 0 || _opts$onError2.call(opts, (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, o), {}, { req: opts.req }));
|
|
44885
|
-
}
|
|
44886
|
-
})),
|
|
44887
|
-
rawResponse: opts.res
|
|
44888
|
-
});
|
|
44889
|
-
}).catch(internal_exceptionHandler(opts));
|
|
44890
|
-
});
|
|
44891
|
-
});
|
|
44480
|
+
}));
|
|
44892
44481
|
}
|
|
44893
|
-
var import_objectSpread2$
|
|
44894
|
-
var
|
|
44482
|
+
var import_objectSpread2$3, trimSlashes;
|
|
44483
|
+
var init_fetch = __esmMin((() => {
|
|
44895
44484
|
init_getErrorShape_BPSzUA7W();
|
|
44896
|
-
init_codes_DagpWZLc();
|
|
44897
|
-
init_tracked_DWInO6EQ();
|
|
44898
44485
|
init_resolveResponse_CdASWfAV();
|
|
44899
|
-
import_objectSpread2$
|
|
44900
|
-
|
|
44901
|
-
|
|
44902
|
-
|
|
44903
|
-
|
|
44904
|
-
var _opts$basePath;
|
|
44905
|
-
const sliceLength = ((_opts$basePath = opts.basePath) !== null && _opts$basePath !== void 0 ? _opts$basePath : "/").length;
|
|
44906
|
-
return (req, res) => {
|
|
44907
|
-
let path = "";
|
|
44908
|
-
run$2(async () => {
|
|
44909
|
-
path = createURL(req).pathname.slice(sliceLength);
|
|
44910
|
-
await nodeHTTPRequestHandler((0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
|
44911
|
-
req,
|
|
44912
|
-
res,
|
|
44913
|
-
path
|
|
44914
|
-
}));
|
|
44915
|
-
}).catch(internal_exceptionHandler((0, import_objectSpread2.default)({
|
|
44916
|
-
req,
|
|
44917
|
-
res,
|
|
44918
|
-
path
|
|
44919
|
-
}, opts)));
|
|
44486
|
+
import_objectSpread2$3 = __toESM(require_objectSpread2(), 1);
|
|
44487
|
+
trimSlashes = (path) => {
|
|
44488
|
+
path = path.startsWith("/") ? path.slice(1) : path;
|
|
44489
|
+
path = path.endsWith("/") ? path.slice(0, -1) : path;
|
|
44490
|
+
return path;
|
|
44920
44491
|
};
|
|
44921
|
-
}
|
|
44922
|
-
/**
|
|
44923
|
-
* @internal
|
|
44924
|
-
*/
|
|
44925
|
-
function createHTTPHandler(opts) {
|
|
44926
|
-
return createHandler(opts);
|
|
44927
|
-
}
|
|
44928
|
-
var import_objectSpread2;
|
|
44929
|
-
var init_standalone = __esmMin((() => {
|
|
44930
|
-
init_getErrorShape_BPSzUA7W();
|
|
44931
|
-
init_codes_DagpWZLc();
|
|
44932
|
-
init_node_http_gyWQuCv2();
|
|
44933
|
-
import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
|
44934
44492
|
}));
|
|
44935
44493
|
//#endregion
|
|
44936
44494
|
//#region src/ui/client.generated.html
|
|
@@ -45130,7 +44688,7 @@ var init_Bind = __esmMin((() => {
|
|
|
45130
44688
|
}));
|
|
45131
44689
|
//#endregion
|
|
45132
44690
|
//#region src/ui/Ports.ts
|
|
45133
|
-
var UiError, UiUsageError, UiShell;
|
|
44691
|
+
var UiError, UiUsageError, UiShell, UiHost;
|
|
45134
44692
|
var init_Ports = __esmMin((() => {
|
|
45135
44693
|
init_esm();
|
|
45136
44694
|
UiError = class extends Error {
|
|
@@ -45150,6 +44708,7 @@ var init_Ports = __esmMin((() => {
|
|
|
45150
44708
|
UiShell = class UiShell extends Tag("UiShell")() {
|
|
45151
44709
|
static layer = (bash) => succeed$2(UiShell, { bash });
|
|
45152
44710
|
};
|
|
44711
|
+
UiHost = class extends Tag("UiHost")() {};
|
|
45153
44712
|
}));
|
|
45154
44713
|
//#endregion
|
|
45155
44714
|
//#region src/ui/Quote.ts
|
|
@@ -45308,10 +44867,9 @@ var init_View = __esmMin((() => {
|
|
|
45308
44867
|
}));
|
|
45309
44868
|
//#endregion
|
|
45310
44869
|
//#region src/ui/Write.ts
|
|
45311
|
-
var contentHashOf, writeQueues, enqueue, verifyForWrite, finishWrite, annotateRefusal, writeNote, writeValue,
|
|
44870
|
+
var contentHashOf, writeQueues, enqueue, verifyForWrite, finishWrite, annotateRefusal, writeNote, writeValue, actorVia, liveReadFile, liveWriteFile;
|
|
45312
44871
|
var init_Write = __esmMin((() => {
|
|
45313
44872
|
init_steering();
|
|
45314
|
-
init_Beat();
|
|
45315
44873
|
init_SafePath();
|
|
45316
44874
|
contentHashOf = (content) => createHash("sha256").update(content, "utf8").digest("hex");
|
|
45317
44875
|
writeQueues = /* @__PURE__ */ new Map();
|
|
@@ -45408,8 +44966,8 @@ var init_Write = __esmMin((() => {
|
|
|
45408
44966
|
return finishWrite(absPath, nextContent, deps);
|
|
45409
44967
|
});
|
|
45410
44968
|
};
|
|
45411
|
-
|
|
45412
|
-
const outcome = await
|
|
44969
|
+
actorVia = (run) => async (worktreePath) => {
|
|
44970
|
+
const outcome = await run(worktreePath, "gtd next --json");
|
|
45413
44971
|
if (outcome.status !== 0) return void 0;
|
|
45414
44972
|
try {
|
|
45415
44973
|
const parsed = JSON.parse(outcome.stdout);
|
|
@@ -45470,6 +45028,319 @@ var init_ReadSteeringFile = __esmMin((() => {
|
|
|
45470
45028
|
};
|
|
45471
45029
|
}));
|
|
45472
45030
|
//#endregion
|
|
45031
|
+
//#region node_modules/@trpc/server/dist/initTRPC-BRf4imah.mjs
|
|
45032
|
+
/**
|
|
45033
|
+
* @internal
|
|
45034
|
+
*/
|
|
45035
|
+
function createMiddlewareFactory() {
|
|
45036
|
+
function createMiddlewareInner(middlewares) {
|
|
45037
|
+
return {
|
|
45038
|
+
_middlewares: middlewares,
|
|
45039
|
+
unstable_pipe(middlewareBuilderOrFn) {
|
|
45040
|
+
const pipedMiddleware = "_middlewares" in middlewareBuilderOrFn ? middlewareBuilderOrFn._middlewares : [middlewareBuilderOrFn];
|
|
45041
|
+
return createMiddlewareInner([...middlewares, ...pipedMiddleware]);
|
|
45042
|
+
}
|
|
45043
|
+
};
|
|
45044
|
+
}
|
|
45045
|
+
function createMiddleware(fn) {
|
|
45046
|
+
return createMiddlewareInner([fn]);
|
|
45047
|
+
}
|
|
45048
|
+
return createMiddleware;
|
|
45049
|
+
}
|
|
45050
|
+
/**
|
|
45051
|
+
* @internal
|
|
45052
|
+
* Please note, `trpc-openapi` uses this function.
|
|
45053
|
+
*/
|
|
45054
|
+
function createInputMiddleware(parse) {
|
|
45055
|
+
const inputMiddleware = async function inputValidatorMiddleware(opts) {
|
|
45056
|
+
let parsedInput;
|
|
45057
|
+
const rawInput = await opts.getRawInput();
|
|
45058
|
+
try {
|
|
45059
|
+
parsedInput = await parse(rawInput);
|
|
45060
|
+
} catch (cause) {
|
|
45061
|
+
throw new TRPCError({
|
|
45062
|
+
code: "BAD_REQUEST",
|
|
45063
|
+
cause
|
|
45064
|
+
});
|
|
45065
|
+
}
|
|
45066
|
+
const combinedInput = isObject$2(opts.input) && isObject$2(parsedInput) ? (0, import_objectSpread2$2.default)((0, import_objectSpread2$2.default)({}, opts.input), parsedInput) : parsedInput;
|
|
45067
|
+
return opts.next({ input: combinedInput });
|
|
45068
|
+
};
|
|
45069
|
+
inputMiddleware._type = "input";
|
|
45070
|
+
return inputMiddleware;
|
|
45071
|
+
}
|
|
45072
|
+
/**
|
|
45073
|
+
* @internal
|
|
45074
|
+
*/
|
|
45075
|
+
function createOutputMiddleware(parse) {
|
|
45076
|
+
const outputMiddleware = async function outputValidatorMiddleware({ next }) {
|
|
45077
|
+
const result = await next();
|
|
45078
|
+
if (!result.ok) return result;
|
|
45079
|
+
try {
|
|
45080
|
+
const data = await parse(result.data);
|
|
45081
|
+
return (0, import_objectSpread2$2.default)((0, import_objectSpread2$2.default)({}, result), {}, { data });
|
|
45082
|
+
} catch (cause) {
|
|
45083
|
+
throw new TRPCError({
|
|
45084
|
+
message: "Output validation failed",
|
|
45085
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
45086
|
+
cause
|
|
45087
|
+
});
|
|
45088
|
+
}
|
|
45089
|
+
};
|
|
45090
|
+
outputMiddleware._type = "output";
|
|
45091
|
+
return outputMiddleware;
|
|
45092
|
+
}
|
|
45093
|
+
function getParseFn(procedureParser) {
|
|
45094
|
+
const parser = procedureParser;
|
|
45095
|
+
const isStandardSchema = "~standard" in parser;
|
|
45096
|
+
if (typeof parser === "function" && typeof parser.assert === "function") return parser.assert.bind(parser);
|
|
45097
|
+
if (typeof parser === "function" && !isStandardSchema) return parser;
|
|
45098
|
+
if (typeof parser.parseAsync === "function") return parser.parseAsync.bind(parser);
|
|
45099
|
+
if (typeof parser.parse === "function") return parser.parse.bind(parser);
|
|
45100
|
+
if (typeof parser.validateSync === "function") return parser.validateSync.bind(parser);
|
|
45101
|
+
if (typeof parser.create === "function") return parser.create.bind(parser);
|
|
45102
|
+
if (typeof parser.assert === "function") return (value) => {
|
|
45103
|
+
parser.assert(value);
|
|
45104
|
+
return value;
|
|
45105
|
+
};
|
|
45106
|
+
if (isStandardSchema) return async (value) => {
|
|
45107
|
+
const result = await parser["~standard"].validate(value);
|
|
45108
|
+
if (result.issues) throw new StandardSchemaV1Error(result.issues);
|
|
45109
|
+
return result.value;
|
|
45110
|
+
};
|
|
45111
|
+
throw new Error("Could not find a validator fn");
|
|
45112
|
+
}
|
|
45113
|
+
function createNewBuilder(def1, def2) {
|
|
45114
|
+
const { middlewares = [], inputs, meta } = def2, rest = (0, import_objectWithoutProperties.default)(def2, _excluded);
|
|
45115
|
+
return createBuilder((0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, mergeWithoutOverrides(def1, rest)), {}, {
|
|
45116
|
+
inputs: [...def1.inputs, ...inputs !== null && inputs !== void 0 ? inputs : []],
|
|
45117
|
+
middlewares: [...def1.middlewares, ...middlewares],
|
|
45118
|
+
meta: def1.meta && meta ? (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, def1.meta), meta) : meta !== null && meta !== void 0 ? meta : def1.meta
|
|
45119
|
+
}));
|
|
45120
|
+
}
|
|
45121
|
+
function createBuilder(initDef = {}) {
|
|
45122
|
+
const _def = (0, import_objectSpread2$1.default)({
|
|
45123
|
+
procedure: true,
|
|
45124
|
+
inputs: [],
|
|
45125
|
+
middlewares: []
|
|
45126
|
+
}, initDef);
|
|
45127
|
+
return {
|
|
45128
|
+
_def,
|
|
45129
|
+
input(input) {
|
|
45130
|
+
const parser = getParseFn(input);
|
|
45131
|
+
return createNewBuilder(_def, {
|
|
45132
|
+
inputs: [input],
|
|
45133
|
+
middlewares: [createInputMiddleware(parser)]
|
|
45134
|
+
});
|
|
45135
|
+
},
|
|
45136
|
+
output(output) {
|
|
45137
|
+
const parser = getParseFn(output);
|
|
45138
|
+
return createNewBuilder(_def, {
|
|
45139
|
+
output,
|
|
45140
|
+
middlewares: [createOutputMiddleware(parser)]
|
|
45141
|
+
});
|
|
45142
|
+
},
|
|
45143
|
+
meta(meta) {
|
|
45144
|
+
return createNewBuilder(_def, { meta });
|
|
45145
|
+
},
|
|
45146
|
+
use(middlewareBuilderOrFn) {
|
|
45147
|
+
const middlewares = "_middlewares" in middlewareBuilderOrFn ? middlewareBuilderOrFn._middlewares : [middlewareBuilderOrFn];
|
|
45148
|
+
return createNewBuilder(_def, { middlewares });
|
|
45149
|
+
},
|
|
45150
|
+
unstable_concat(builder$1) {
|
|
45151
|
+
return createNewBuilder(_def, builder$1._def);
|
|
45152
|
+
},
|
|
45153
|
+
concat(builder$1) {
|
|
45154
|
+
return createNewBuilder(_def, builder$1._def);
|
|
45155
|
+
},
|
|
45156
|
+
query(resolver) {
|
|
45157
|
+
return createResolver((0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, _def), {}, { type: "query" }), resolver);
|
|
45158
|
+
},
|
|
45159
|
+
mutation(resolver) {
|
|
45160
|
+
return createResolver((0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, _def), {}, { type: "mutation" }), resolver);
|
|
45161
|
+
},
|
|
45162
|
+
subscription(resolver) {
|
|
45163
|
+
return createResolver((0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, _def), {}, { type: "subscription" }), resolver);
|
|
45164
|
+
},
|
|
45165
|
+
experimental_caller(caller) {
|
|
45166
|
+
return createNewBuilder(_def, { caller });
|
|
45167
|
+
}
|
|
45168
|
+
};
|
|
45169
|
+
}
|
|
45170
|
+
function createResolver(_defIn, resolver) {
|
|
45171
|
+
const finalBuilder = createNewBuilder(_defIn, {
|
|
45172
|
+
resolver,
|
|
45173
|
+
middlewares: [async function resolveMiddleware(opts) {
|
|
45174
|
+
const data = await resolver(opts);
|
|
45175
|
+
return {
|
|
45176
|
+
marker: middlewareMarker,
|
|
45177
|
+
ok: true,
|
|
45178
|
+
data,
|
|
45179
|
+
ctx: opts.ctx
|
|
45180
|
+
};
|
|
45181
|
+
}]
|
|
45182
|
+
});
|
|
45183
|
+
const _def = (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, finalBuilder._def), {}, {
|
|
45184
|
+
type: _defIn.type,
|
|
45185
|
+
experimental_caller: Boolean(finalBuilder._def.caller),
|
|
45186
|
+
meta: finalBuilder._def.meta,
|
|
45187
|
+
$types: null
|
|
45188
|
+
});
|
|
45189
|
+
const invoke = createProcedureCaller(finalBuilder._def);
|
|
45190
|
+
const callerOverride = finalBuilder._def.caller;
|
|
45191
|
+
if (!callerOverride) return invoke;
|
|
45192
|
+
const callerWrapper = async (...args) => {
|
|
45193
|
+
return await callerOverride({
|
|
45194
|
+
args,
|
|
45195
|
+
invoke,
|
|
45196
|
+
_def
|
|
45197
|
+
});
|
|
45198
|
+
};
|
|
45199
|
+
callerWrapper._def = _def;
|
|
45200
|
+
return callerWrapper;
|
|
45201
|
+
}
|
|
45202
|
+
async function callRecursive(index, _def, opts) {
|
|
45203
|
+
try {
|
|
45204
|
+
const middleware = _def.middlewares[index];
|
|
45205
|
+
return await middleware((0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, opts), {}, {
|
|
45206
|
+
meta: _def.meta,
|
|
45207
|
+
input: opts.input,
|
|
45208
|
+
next(_nextOpts) {
|
|
45209
|
+
var _nextOpts$getRawInput;
|
|
45210
|
+
const nextOpts = _nextOpts;
|
|
45211
|
+
return callRecursive(index + 1, _def, (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, opts), {}, {
|
|
45212
|
+
ctx: (nextOpts === null || nextOpts === void 0 ? void 0 : nextOpts.ctx) ? (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, opts.ctx), nextOpts.ctx) : opts.ctx,
|
|
45213
|
+
input: nextOpts && "input" in nextOpts ? nextOpts.input : opts.input,
|
|
45214
|
+
getRawInput: (_nextOpts$getRawInput = nextOpts === null || nextOpts === void 0 ? void 0 : nextOpts.getRawInput) !== null && _nextOpts$getRawInput !== void 0 ? _nextOpts$getRawInput : opts.getRawInput
|
|
45215
|
+
}));
|
|
45216
|
+
}
|
|
45217
|
+
}));
|
|
45218
|
+
} catch (cause) {
|
|
45219
|
+
return {
|
|
45220
|
+
ok: false,
|
|
45221
|
+
error: getTRPCErrorFromUnknown(cause),
|
|
45222
|
+
marker: middlewareMarker
|
|
45223
|
+
};
|
|
45224
|
+
}
|
|
45225
|
+
}
|
|
45226
|
+
function createProcedureCaller(_def) {
|
|
45227
|
+
async function procedure(opts) {
|
|
45228
|
+
if (!opts || !("getRawInput" in opts)) throw new Error(codeblock);
|
|
45229
|
+
const result = await callRecursive(0, _def, opts);
|
|
45230
|
+
if (!result) throw new TRPCError({
|
|
45231
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
45232
|
+
message: "No result from middlewares - did you forget to `return next()`?"
|
|
45233
|
+
});
|
|
45234
|
+
if (!result.ok) throw result.error;
|
|
45235
|
+
return result.data;
|
|
45236
|
+
}
|
|
45237
|
+
procedure._def = _def;
|
|
45238
|
+
procedure.procedure = true;
|
|
45239
|
+
procedure.meta = _def.meta;
|
|
45240
|
+
return procedure;
|
|
45241
|
+
}
|
|
45242
|
+
var import_objectSpread2$2, middlewareMarker, import_defineProperty, StandardSchemaV1Error, require_objectWithoutPropertiesLoose, import_objectWithoutProperties, import_objectSpread2$1, _excluded, codeblock, _globalThis$process, _globalThis$process2, _globalThis$process3, isServerDefault, import_objectSpread2, initTRPC;
|
|
45243
|
+
var init_initTRPC_BRf4imah = __esmMin((() => {
|
|
45244
|
+
init_getErrorShape_BPSzUA7W();
|
|
45245
|
+
init_codes_DagpWZLc();
|
|
45246
|
+
init_tracked_DWInO6EQ();
|
|
45247
|
+
import_objectSpread2$2 = __toESM(require_objectSpread2(), 1);
|
|
45248
|
+
middlewareMarker = "middlewareMarker";
|
|
45249
|
+
import_defineProperty = __toESM(require_defineProperty(), 1);
|
|
45250
|
+
StandardSchemaV1Error = class extends Error {
|
|
45251
|
+
/**
|
|
45252
|
+
* Creates a schema error with useful information.
|
|
45253
|
+
*
|
|
45254
|
+
* @param issues The schema issues.
|
|
45255
|
+
*/
|
|
45256
|
+
constructor(issues) {
|
|
45257
|
+
var _issues$;
|
|
45258
|
+
super((_issues$ = issues[0]) === null || _issues$ === void 0 ? void 0 : _issues$.message);
|
|
45259
|
+
(0, import_defineProperty.default)(this, "issues", void 0);
|
|
45260
|
+
this.name = "SchemaError";
|
|
45261
|
+
this.issues = issues;
|
|
45262
|
+
}
|
|
45263
|
+
};
|
|
45264
|
+
require_objectWithoutPropertiesLoose = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js"(exports, module) {
|
|
45265
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
45266
|
+
if (null == r) return {};
|
|
45267
|
+
var t = {};
|
|
45268
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
45269
|
+
if (e.includes(n)) continue;
|
|
45270
|
+
t[n] = r[n];
|
|
45271
|
+
}
|
|
45272
|
+
return t;
|
|
45273
|
+
}
|
|
45274
|
+
module.exports = _objectWithoutPropertiesLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
45275
|
+
} });
|
|
45276
|
+
import_objectWithoutProperties = __toESM(__commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js"(exports, module) {
|
|
45277
|
+
var objectWithoutPropertiesLoose = require_objectWithoutPropertiesLoose();
|
|
45278
|
+
function _objectWithoutProperties$1(e, t) {
|
|
45279
|
+
if (null == e) return {};
|
|
45280
|
+
var o, r, i = objectWithoutPropertiesLoose(e, t);
|
|
45281
|
+
if (Object.getOwnPropertySymbols) {
|
|
45282
|
+
var s = Object.getOwnPropertySymbols(e);
|
|
45283
|
+
for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
45284
|
+
}
|
|
45285
|
+
return i;
|
|
45286
|
+
}
|
|
45287
|
+
module.exports = _objectWithoutProperties$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
45288
|
+
} })(), 1);
|
|
45289
|
+
import_objectSpread2$1 = __toESM(require_objectSpread2(), 1);
|
|
45290
|
+
_excluded = [
|
|
45291
|
+
"middlewares",
|
|
45292
|
+
"inputs",
|
|
45293
|
+
"meta"
|
|
45294
|
+
];
|
|
45295
|
+
codeblock = `
|
|
45296
|
+
This is a client-only function.
|
|
45297
|
+
If you want to call this function on the server, see https://trpc.io/docs/v11/server/server-side-calls
|
|
45298
|
+
`.trim();
|
|
45299
|
+
isServerDefault = typeof window === "undefined" || "Deno" in window || ((_globalThis$process = globalThis.process) === null || _globalThis$process === void 0 || (_globalThis$process = _globalThis$process.env) === null || _globalThis$process === void 0 ? void 0 : _globalThis$process["NODE_ENV"]) === "test" || !!((_globalThis$process2 = globalThis.process) === null || _globalThis$process2 === void 0 || (_globalThis$process2 = _globalThis$process2.env) === null || _globalThis$process2 === void 0 ? void 0 : _globalThis$process2["JEST_WORKER_ID"]) || !!((_globalThis$process3 = globalThis.process) === null || _globalThis$process3 === void 0 || (_globalThis$process3 = _globalThis$process3.env) === null || _globalThis$process3 === void 0 ? void 0 : _globalThis$process3["VITEST_WORKER_ID"]);
|
|
45300
|
+
import_objectSpread2 = __toESM(require_objectSpread2(), 1);
|
|
45301
|
+
initTRPC = new class TRPCBuilder {
|
|
45302
|
+
/**
|
|
45303
|
+
* Add a context shape as a generic to the root object
|
|
45304
|
+
* @see https://trpc.io/docs/v11/server/context
|
|
45305
|
+
*/
|
|
45306
|
+
context() {
|
|
45307
|
+
return new TRPCBuilder();
|
|
45308
|
+
}
|
|
45309
|
+
/**
|
|
45310
|
+
* Add a meta shape as a generic to the root object
|
|
45311
|
+
* @see https://trpc.io/docs/v11/quickstart
|
|
45312
|
+
*/
|
|
45313
|
+
meta() {
|
|
45314
|
+
return new TRPCBuilder();
|
|
45315
|
+
}
|
|
45316
|
+
/**
|
|
45317
|
+
* Create the root object
|
|
45318
|
+
* @see https://trpc.io/docs/v11/server/routers#initialize-trpc
|
|
45319
|
+
*/
|
|
45320
|
+
create(opts) {
|
|
45321
|
+
var _opts$transformer, _opts$isDev, _globalThis$process$1, _opts$allowOutsideOfS, _opts$errorFormatter, _opts$isServer;
|
|
45322
|
+
const config = (0, import_objectSpread2.default)((0, import_objectSpread2.default)({}, opts), {}, {
|
|
45323
|
+
transformer: getDataTransformer((_opts$transformer = opts === null || opts === void 0 ? void 0 : opts.transformer) !== null && _opts$transformer !== void 0 ? _opts$transformer : defaultTransformer),
|
|
45324
|
+
isDev: (_opts$isDev = opts === null || opts === void 0 ? void 0 : opts.isDev) !== null && _opts$isDev !== void 0 ? _opts$isDev : ((_globalThis$process$1 = globalThis.process) === null || _globalThis$process$1 === void 0 ? void 0 : _globalThis$process$1.env["NODE_ENV"]) !== "production",
|
|
45325
|
+
allowOutsideOfServer: (_opts$allowOutsideOfS = opts === null || opts === void 0 ? void 0 : opts.allowOutsideOfServer) !== null && _opts$allowOutsideOfS !== void 0 ? _opts$allowOutsideOfS : false,
|
|
45326
|
+
errorFormatter: (_opts$errorFormatter = opts === null || opts === void 0 ? void 0 : opts.errorFormatter) !== null && _opts$errorFormatter !== void 0 ? _opts$errorFormatter : defaultFormatter,
|
|
45327
|
+
isServer: (_opts$isServer = opts === null || opts === void 0 ? void 0 : opts.isServer) !== null && _opts$isServer !== void 0 ? _opts$isServer : isServerDefault,
|
|
45328
|
+
$types: null
|
|
45329
|
+
});
|
|
45330
|
+
var _opts$isServer2;
|
|
45331
|
+
if (!((_opts$isServer2 = opts === null || opts === void 0 ? void 0 : opts.isServer) !== null && _opts$isServer2 !== void 0 ? _opts$isServer2 : isServerDefault) && (opts === null || opts === void 0 ? void 0 : opts.allowOutsideOfServer) !== true) throw new Error(`You're trying to use @trpc/server in a non-server environment. This is not supported by default.`);
|
|
45332
|
+
return {
|
|
45333
|
+
_config: config,
|
|
45334
|
+
procedure: createBuilder({ meta: opts === null || opts === void 0 ? void 0 : opts.defaultMeta }),
|
|
45335
|
+
middleware: createMiddlewareFactory(),
|
|
45336
|
+
router: createRouterFactory(config),
|
|
45337
|
+
mergeRouters,
|
|
45338
|
+
createCallerFactory: createCallerFactory()
|
|
45339
|
+
};
|
|
45340
|
+
}
|
|
45341
|
+
}();
|
|
45342
|
+
}));
|
|
45343
|
+
//#endregion
|
|
45473
45344
|
//#region node_modules/@trpc/server/dist/index.mjs
|
|
45474
45345
|
var init_dist = __esmMin((() => {
|
|
45475
45346
|
init_tracked_DWInO6EQ();
|
|
@@ -45851,19 +45722,25 @@ var init_Tailscale = __esmMin((() => {
|
|
|
45851
45722
|
}));
|
|
45852
45723
|
//#endregion
|
|
45853
45724
|
//#region src/ui/Tls.ts
|
|
45854
|
-
var generateSelfSignedCert, obtainTailscaleCert, loadCertPair;
|
|
45725
|
+
var issueInScratch, generateSelfSignedCert, obtainTailscaleCert, loadCertPair;
|
|
45855
45726
|
var init_Tls = __esmMin((() => {
|
|
45856
45727
|
init_esm$1();
|
|
45857
45728
|
init_esm();
|
|
45858
45729
|
init_Ports();
|
|
45859
45730
|
init_Quote();
|
|
45860
|
-
|
|
45731
|
+
issueInScratch = (tool, command) => gen(function* () {
|
|
45861
45732
|
const runner = yield* UiShell;
|
|
45862
|
-
|
|
45863
|
-
|
|
45864
|
-
|
|
45733
|
+
return yield* (yield* UiHost).scratch((dir, read) => runner.bash(command(join(dir, "cert.pem"), join(dir, "key.pem"))).pipe(mapError$1((e) => new UiError(`gtd ui: could not run ${tool} to issue a certificate: ${e.message}`)), flatMap$4((outcome) => outcome.status !== 0 ? fail$7(new UiError(`gtd ui: ${tool} exited without issuing a certificate`, [`exit status: ${outcome.status ?? "signal"}`, ...outcome.output.trim().split("\n").filter(Boolean)])) : try_({
|
|
45734
|
+
try: () => ({
|
|
45735
|
+
cert: read("cert.pem"),
|
|
45736
|
+
key: read("key.pem")
|
|
45737
|
+
}),
|
|
45738
|
+
catch: (e) => new UiError(`gtd ui: ${tool} reported success but its output could not be read: ${e instanceof Error ? e.message : String(e)}`)
|
|
45739
|
+
}))));
|
|
45740
|
+
});
|
|
45741
|
+
generateSelfSignedCert = (request) => {
|
|
45865
45742
|
const subjectAltName = request.ip !== void 0 ? `IP:${request.ip},DNS:${request.host}` : `DNS:${request.host}`;
|
|
45866
|
-
|
|
45743
|
+
return issueInScratch("openssl", (certPath, keyPath) => [
|
|
45867
45744
|
"openssl req -x509 -newkey rsa:2048 -nodes -days 825",
|
|
45868
45745
|
`-keyout ${shellQuote(keyPath)}`,
|
|
45869
45746
|
`-out ${shellQuote(certPath)}`,
|
|
@@ -45871,40 +45748,14 @@ var init_Tls = __esmMin((() => {
|
|
|
45871
45748
|
`-addext ${shellQuote(`subjectAltName=${subjectAltName}`)}`,
|
|
45872
45749
|
`-addext "extendedKeyUsage=serverAuth"`,
|
|
45873
45750
|
`-addext "basicConstraints=critical,CA:FALSE"`
|
|
45874
|
-
].join(" ");
|
|
45875
|
-
|
|
45876
|
-
|
|
45877
|
-
|
|
45878
|
-
|
|
45879
|
-
|
|
45880
|
-
|
|
45881
|
-
|
|
45882
|
-
recursive: true,
|
|
45883
|
-
force: true
|
|
45884
|
-
}))));
|
|
45885
|
-
});
|
|
45886
|
-
obtainTailscaleCert = (domain) => gen(function* () {
|
|
45887
|
-
const runner = yield* UiShell;
|
|
45888
|
-
const dir = mkdtempSync(join(tmpdir(), "gtd-tls-"));
|
|
45889
|
-
const keyPath = join(dir, "key.pem");
|
|
45890
|
-
const certPath = join(dir, "cert.pem");
|
|
45891
|
-
const command = [
|
|
45892
|
-
"tailscale cert",
|
|
45893
|
-
`--cert-file ${shellQuote(certPath)}`,
|
|
45894
|
-
`--key-file ${shellQuote(keyPath)}`,
|
|
45895
|
-
shellQuote(domain)
|
|
45896
|
-
].join(" ");
|
|
45897
|
-
return yield* runner.bash(command).pipe(mapError$1((e) => new UiError(`gtd ui: could not run tailscale cert to issue a certificate: ${e.message}`)), flatMap$4((outcome) => outcome.status !== 0 ? fail$7(new UiError("gtd ui: tailscale cert exited without issuing a certificate", [`exit status: ${outcome.status ?? "signal"}`, ...outcome.output.trim().split("\n").filter(Boolean)])) : try_({
|
|
45898
|
-
try: () => ({
|
|
45899
|
-
cert: readFileSync(certPath, "utf8"),
|
|
45900
|
-
key: readFileSync(keyPath, "utf8")
|
|
45901
|
-
}),
|
|
45902
|
-
catch: (e) => new UiError(`gtd ui: tailscale cert reported success but its output could not be read: ${e instanceof Error ? e.message : String(e)}`)
|
|
45903
|
-
})), ensuring$2(sync$1(() => rmSync(dir, {
|
|
45904
|
-
recursive: true,
|
|
45905
|
-
force: true
|
|
45906
|
-
}))));
|
|
45907
|
-
});
|
|
45751
|
+
].join(" "));
|
|
45752
|
+
};
|
|
45753
|
+
obtainTailscaleCert = (domain) => issueInScratch("tailscale cert", (certPath, keyPath) => [
|
|
45754
|
+
"tailscale cert",
|
|
45755
|
+
`--cert-file ${shellQuote(certPath)}`,
|
|
45756
|
+
`--key-file ${shellQuote(keyPath)}`,
|
|
45757
|
+
shellQuote(domain)
|
|
45758
|
+
].join(" "));
|
|
45908
45759
|
loadCertPair = (certPath, keyPath) => gen(function* () {
|
|
45909
45760
|
const fs = yield* FileSystem;
|
|
45910
45761
|
const read = (path) => fs.readFileString(path).pipe(mapError$1((e) => new UiError(`gtd ui: could not read ${path}: ${e.message}`)));
|
|
@@ -45916,9 +45767,9 @@ var init_Tls = __esmMin((() => {
|
|
|
45916
45767
|
}));
|
|
45917
45768
|
//#endregion
|
|
45918
45769
|
//#region src/ui/Server.ts
|
|
45919
|
-
var TRPC_PATH_PREFIX, resolveBindHost, resolveCertPair, UiListener, SERVE_PORT_CANDIDATES, normalizePort, findPackageRoot, readDevTemplate, rebuildDevClientScript, rebuildDevClientCss, resolveClientHtml,
|
|
45770
|
+
var TRPC_PATH_PREFIX, resolveBindHost, resolveCertPair, UiListener, viaNode, SERVE_PORT_CANDIDATES, normalizePort, findPackageRoot, readDevTemplate, rebuildDevClientScript, rebuildDevClientCss, resolveClientHtml, buildFormatCommand, isRenderable, refusalFor, resolveHostsAndCert, probeLiveServeMapping, clearOrphanForPublish, attemptServe, teardownServe, resolveListener, runUiCommand;
|
|
45920
45771
|
var init_Server = __esmMin((() => {
|
|
45921
|
-
|
|
45772
|
+
init_fetch();
|
|
45922
45773
|
init_esm$1();
|
|
45923
45774
|
init_esm();
|
|
45924
45775
|
init_client_generated();
|
|
@@ -45935,7 +45786,7 @@ var init_Server = __esmMin((() => {
|
|
|
45935
45786
|
init_Tls();
|
|
45936
45787
|
init_Write();
|
|
45937
45788
|
TRPC_PATH_PREFIX = "/trpc";
|
|
45938
|
-
resolveBindHost = (host, config, pickHost
|
|
45789
|
+
resolveBindHost = (host, config, pickHost) => {
|
|
45939
45790
|
const resolved = host ?? config?.host ?? pickHost();
|
|
45940
45791
|
return resolved === void 0 ? fail$7(new UiError("gtd ui: no Tailscale interface found to bind to, and no --host given", ["join a tailnet, so a CGNAT (100.64.0.0/10) address is available", "or pass --host <address> to bind explicitly"])) : succeed$3(resolved);
|
|
45941
45792
|
};
|
|
@@ -45959,10 +45810,11 @@ var init_Server = __esmMin((() => {
|
|
|
45959
45810
|
};
|
|
45960
45811
|
UiListener = class UiListener extends Tag("UiListener")() {
|
|
45961
45812
|
static Live = succeed$2(UiListener, { listen: ({ tls, host, port, handler }) => async((resume) => {
|
|
45813
|
+
const serve = viaNode(handler);
|
|
45962
45814
|
const server = tls !== void 0 ? https.createServer({
|
|
45963
45815
|
cert: tls.cert,
|
|
45964
45816
|
key: tls.key
|
|
45965
|
-
},
|
|
45817
|
+
}, serve) : http.createServer(serve);
|
|
45966
45818
|
server.once("error", (err) => {
|
|
45967
45819
|
resume(fail$7(err.code === "EADDRINUSE" ? new UiError(`gtd ui: port ${port} is already in use`) : new UiError(`gtd ui: could not start the server: ${err.message}`)));
|
|
45968
45820
|
});
|
|
@@ -45976,6 +45828,33 @@ var init_Server = __esmMin((() => {
|
|
|
45976
45828
|
});
|
|
45977
45829
|
}) });
|
|
45978
45830
|
};
|
|
45831
|
+
viaNode = (handler) => (req, res) => {
|
|
45832
|
+
const headers = new Headers();
|
|
45833
|
+
for (const [name, value] of Object.entries(req.headers)) for (const one of [value ?? []].flat()) headers.append(name, one);
|
|
45834
|
+
const hasBody = req.method !== "GET" && req.method !== "HEAD";
|
|
45835
|
+
let request;
|
|
45836
|
+
try {
|
|
45837
|
+
request = new Request(new URL(req.url ?? "/", "http://localhost"), {
|
|
45838
|
+
method: req.method ?? "GET",
|
|
45839
|
+
headers,
|
|
45840
|
+
...hasBody ? {
|
|
45841
|
+
body: Readable.toWeb(req),
|
|
45842
|
+
duplex: "half"
|
|
45843
|
+
} : {}
|
|
45844
|
+
});
|
|
45845
|
+
} catch {
|
|
45846
|
+
res.writeHead(400);
|
|
45847
|
+
res.end();
|
|
45848
|
+
return;
|
|
45849
|
+
}
|
|
45850
|
+
handler(request, (callback) => res.once("finish", callback)).then(async (response) => {
|
|
45851
|
+
res.writeHead(response.status, Object.fromEntries(response.headers));
|
|
45852
|
+
res.end(Buffer.from(await response.arrayBuffer()));
|
|
45853
|
+
}, () => {
|
|
45854
|
+
res.writeHead(500);
|
|
45855
|
+
res.end();
|
|
45856
|
+
});
|
|
45857
|
+
};
|
|
45979
45858
|
SERVE_PORT_CANDIDATES = [
|
|
45980
45859
|
8443,
|
|
45981
45860
|
1e4,
|
|
@@ -46014,12 +45893,7 @@ var init_Server = __esmMin((() => {
|
|
|
46014
45893
|
rebuildDevClientScript(runner, fs, root),
|
|
46015
45894
|
rebuildDevClientCss(runner, fs, root)
|
|
46016
45895
|
])), map$4(([template, script, css]) => inlineStyles(inlineScript(template, script), css))) : succeed$3(client_generated_default);
|
|
46017
|
-
|
|
46018
|
-
run: liveRunInWorktree,
|
|
46019
|
-
readLocalGtdVersion: readLocalGtdVersionAt,
|
|
46020
|
-
headSha: liveHeadSha
|
|
46021
|
-
};
|
|
46022
|
-
buildFormatCommand = (format, worktreeRoot, run = liveRunInWorktree) => {
|
|
45896
|
+
buildFormatCommand = (format, worktreeRoot, run) => {
|
|
46023
45897
|
if (format === void 0) return void 0;
|
|
46024
45898
|
return async (absPath) => {
|
|
46025
45899
|
const outcome = await run(worktreeRoot, withFileVar(format, absPath));
|
|
@@ -46037,7 +45911,8 @@ var init_Server = __esmMin((() => {
|
|
|
46037
45911
|
return new UiUsageError(`gtd ui: refuses to start — "${step.label}" rests with you, but names no steering file to show on the phone`, ["gtd next --json reported no steering file for this rest"]);
|
|
46038
45912
|
};
|
|
46039
45913
|
resolveHostsAndCert = (options, config) => gen(function* () {
|
|
46040
|
-
const
|
|
45914
|
+
const host = yield* UiHost;
|
|
45915
|
+
const bindHost = yield* resolveBindHost(options.host, config, () => pickBindHost(host.networkInterfaces()));
|
|
46041
45916
|
const tailscaleStatus = (options.host ?? config?.host) !== void 0 ? void 0 : yield* probeTailscaleStatus();
|
|
46042
45917
|
const displayHost = tailscaleStatus?.hostname ?? bindHost;
|
|
46043
45918
|
return {
|
|
@@ -46046,14 +45921,6 @@ var init_Server = __esmMin((() => {
|
|
|
46046
45921
|
certPair: yield* resolveCertPair(options, config, bindHost, displayHost, tailscaleStatus)
|
|
46047
45922
|
};
|
|
46048
45923
|
});
|
|
46049
|
-
isPidAlive = (pid) => {
|
|
46050
|
-
try {
|
|
46051
|
-
process.kill(pid, 0);
|
|
46052
|
-
return true;
|
|
46053
|
-
} catch {
|
|
46054
|
-
return false;
|
|
46055
|
-
}
|
|
46056
|
-
};
|
|
46057
45924
|
probeLiveServeMapping = (servePort) => gen(function* () {
|
|
46058
45925
|
const outcome = yield* (yield* UiShell).bash("tailscale serve status --json").pipe(catchAll(() => succeed$3(void 0)));
|
|
46059
45926
|
if (outcome === void 0 || outcome.status !== 0) return { ok: false };
|
|
@@ -46063,15 +45930,16 @@ var init_Server = __esmMin((() => {
|
|
|
46063
45930
|
};
|
|
46064
45931
|
});
|
|
46065
45932
|
clearOrphanForPublish = (servePort) => gen(function* () {
|
|
46066
|
-
const
|
|
45933
|
+
const host = yield* UiHost;
|
|
45934
|
+
const record = host.serveRecords.read(servePort);
|
|
46067
45935
|
if (record === void 0) {
|
|
46068
45936
|
const probe = yield* probeLiveServeMapping(servePort);
|
|
46069
45937
|
if (!probe.ok) return "unknowable";
|
|
46070
45938
|
return probe.mapping === void 0 ? "clear" : "occupied";
|
|
46071
45939
|
}
|
|
46072
|
-
if (isPidAlive(record.pid) && record.pid !== process.pid) return "occupied";
|
|
45940
|
+
if (host.isPidAlive(record.pid) && record.pid !== process.pid) return "occupied";
|
|
46073
45941
|
yield* unpublishServe(servePort).pipe(catchAll(() => succeed$3(void 0)));
|
|
46074
|
-
|
|
45942
|
+
host.serveRecords.delete(servePort);
|
|
46075
45943
|
return "clear";
|
|
46076
45944
|
});
|
|
46077
45945
|
attemptServe = (servePort, worktree, uiListener, handler) => gen(function* () {
|
|
@@ -46125,7 +45993,7 @@ var init_Server = __esmMin((() => {
|
|
|
46125
45993
|
reason: `tailscale serve failed: ${publishResult.reason}`
|
|
46126
45994
|
};
|
|
46127
45995
|
}
|
|
46128
|
-
|
|
45996
|
+
(yield* UiHost).serveRecords.write(servePort, {
|
|
46129
45997
|
pid: process.pid,
|
|
46130
45998
|
servePort,
|
|
46131
45999
|
targetPort: bound.port,
|
|
@@ -46140,12 +46008,13 @@ var init_Server = __esmMin((() => {
|
|
|
46140
46008
|
};
|
|
46141
46009
|
});
|
|
46142
46010
|
teardownServe = (servePort) => gen(function* () {
|
|
46143
|
-
const
|
|
46011
|
+
const host = yield* UiHost;
|
|
46012
|
+
const record = host.serveRecords.read(servePort);
|
|
46144
46013
|
if (record === void 0) return;
|
|
46145
46014
|
const probe = yield* probeLiveServeMapping(servePort);
|
|
46146
46015
|
if (!probe.ok) return;
|
|
46147
46016
|
if (probe.mapping !== void 0 && probe.mapping.targetUrl === record.target) yield* unpublishServe(servePort).pipe(catchAll(() => succeed$3(void 0)));
|
|
46148
|
-
|
|
46017
|
+
host.serveRecords.delete(servePort);
|
|
46149
46018
|
});
|
|
46150
46019
|
resolveListener = (args) => gen(function* () {
|
|
46151
46020
|
const { options, config, explicitPort, explicitHost, worktree, uiListener, handler, out } = args;
|
|
@@ -46196,7 +46065,13 @@ var init_Server = __esmMin((() => {
|
|
|
46196
46065
|
};
|
|
46197
46066
|
});
|
|
46198
46067
|
runUiCommand = (options, config, out, root) => gen(function* () {
|
|
46199
|
-
const
|
|
46068
|
+
const host = yield* UiHost;
|
|
46069
|
+
const beatDeps = {
|
|
46070
|
+
run: host.run,
|
|
46071
|
+
readLocalGtdVersion: host.readLocalGtdVersion,
|
|
46072
|
+
headSha: host.headSha
|
|
46073
|
+
};
|
|
46074
|
+
const step = yield* promise(() => readStep({ path: root }, beatDeps));
|
|
46200
46075
|
if (step.status === "broken" || !isRenderable(step)) return yield* fail$7(refusalFor(step));
|
|
46201
46076
|
const servedState = step.state;
|
|
46202
46077
|
const servedLabel = step.label;
|
|
@@ -46207,25 +46082,25 @@ var init_Server = __esmMin((() => {
|
|
|
46207
46082
|
const explicitPort = normalizePort(options.port ?? config?.port);
|
|
46208
46083
|
const explicitHost = options.host ?? config?.host;
|
|
46209
46084
|
const clientHtml = yield* resolveClientHtml(options.dev, runner, fs);
|
|
46210
|
-
const formatCommand = buildFormatCommand(config?.format, root);
|
|
46085
|
+
const formatCommand = buildFormatCommand(config?.format, root, host.run);
|
|
46211
46086
|
const writeDeps = {
|
|
46212
|
-
headSha:
|
|
46213
|
-
actorAt:
|
|
46214
|
-
readFile:
|
|
46215
|
-
writeFile:
|
|
46087
|
+
headSha: host.headSha,
|
|
46088
|
+
actorAt: actorVia(host.run),
|
|
46089
|
+
readFile: host.readFile,
|
|
46090
|
+
writeFile: host.writeFile,
|
|
46216
46091
|
...formatCommand !== void 0 ? { formatCommand } : {}
|
|
46217
46092
|
};
|
|
46218
|
-
const diffDeps = { run:
|
|
46093
|
+
const diffDeps = { run: host.run };
|
|
46219
46094
|
const readDeps = {
|
|
46220
|
-
headSha:
|
|
46221
|
-
readFile:
|
|
46095
|
+
headSha: host.headSha,
|
|
46096
|
+
readFile: host.readFile
|
|
46222
46097
|
};
|
|
46223
46098
|
const handoffDeferred = yield* make$33();
|
|
46224
46099
|
const endServer = () => {
|
|
46225
46100
|
runFork(runtime$4)(succeed$7(handoffDeferred, void 0));
|
|
46226
46101
|
};
|
|
46227
46102
|
const readServedStep = async () => {
|
|
46228
|
-
const read = await readStep({ path: root },
|
|
46103
|
+
const read = await readStep({ path: root }, beatDeps);
|
|
46229
46104
|
if (!(read.status === "broken" || read.state !== servedState || !isRenderable(read))) return read;
|
|
46230
46105
|
endServer();
|
|
46231
46106
|
return {
|
|
@@ -46234,53 +46109,50 @@ var init_Server = __esmMin((() => {
|
|
|
46234
46109
|
};
|
|
46235
46110
|
};
|
|
46236
46111
|
const isServedFile = (filePath) => filePath === step.file;
|
|
46237
|
-
const
|
|
46238
|
-
|
|
46239
|
-
|
|
46240
|
-
|
|
46241
|
-
|
|
46242
|
-
|
|
46243
|
-
|
|
46244
|
-
|
|
46245
|
-
|
|
46246
|
-
|
|
46247
|
-
|
|
46248
|
-
|
|
46249
|
-
|
|
46250
|
-
|
|
46251
|
-
|
|
46252
|
-
|
|
46253
|
-
|
|
46254
|
-
|
|
46255
|
-
|
|
46256
|
-
|
|
46257
|
-
|
|
46258
|
-
|
|
46259
|
-
|
|
46260
|
-
|
|
46261
|
-
|
|
46262
|
-
|
|
46263
|
-
|
|
46264
|
-
|
|
46265
|
-
|
|
46266
|
-
|
|
46267
|
-
|
|
46268
|
-
|
|
46269
|
-
|
|
46270
|
-
|
|
46271
|
-
|
|
46272
|
-
|
|
46273
|
-
|
|
46274
|
-
|
|
46275
|
-
|
|
46276
|
-
|
|
46277
|
-
|
|
46278
|
-
|
|
46279
|
-
|
|
46280
|
-
|
|
46281
|
-
}
|
|
46282
|
-
res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
|
|
46283
|
-
res.end(clientHtml);
|
|
46112
|
+
const handler = (request, afterResponse) => {
|
|
46113
|
+
const path = new URL(request.url).pathname;
|
|
46114
|
+
if (path !== TRPC_PATH_PREFIX && !path.startsWith(`${TRPC_PATH_PREFIX}/`)) return Promise.resolve(new Response(clientHtml, { headers: { "content-type": "text/html; charset=utf-8" } }));
|
|
46115
|
+
return fetchRequestHandler({
|
|
46116
|
+
endpoint: TRPC_PATH_PREFIX,
|
|
46117
|
+
req: request,
|
|
46118
|
+
router: appRouter,
|
|
46119
|
+
createContext: () => ({
|
|
46120
|
+
readStep: readServedStep,
|
|
46121
|
+
writeNote: (request) => isServedFile(request.filePath) ? writeNote({
|
|
46122
|
+
...request,
|
|
46123
|
+
worktreePath: root
|
|
46124
|
+
}, writeDeps) : Promise.resolve({
|
|
46125
|
+
ok: false,
|
|
46126
|
+
reason: "file-vanished"
|
|
46127
|
+
}),
|
|
46128
|
+
writeValue: (request) => isServedFile(request.filePath) ? writeValue({
|
|
46129
|
+
...request,
|
|
46130
|
+
worktreePath: root
|
|
46131
|
+
}, writeDeps) : Promise.resolve({
|
|
46132
|
+
ok: false,
|
|
46133
|
+
reason: "file-vanished"
|
|
46134
|
+
}),
|
|
46135
|
+
resolveDiff: (path, line, endLine) => resolveDiff(root, path, line, endLine, diffDeps),
|
|
46136
|
+
readSteeringFile: (request) => isServedFile(request.filePath) ? readSteeringFile({
|
|
46137
|
+
...request,
|
|
46138
|
+
worktreePath: root
|
|
46139
|
+
}, readDeps) : Promise.resolve({
|
|
46140
|
+
ok: false,
|
|
46141
|
+
reason: "file-vanished"
|
|
46142
|
+
}),
|
|
46143
|
+
handOff: () => {
|
|
46144
|
+
let settled = false;
|
|
46145
|
+
const settle = () => {
|
|
46146
|
+
if (settled) return;
|
|
46147
|
+
settled = true;
|
|
46148
|
+
clearTimeout(fallback);
|
|
46149
|
+
endServer();
|
|
46150
|
+
};
|
|
46151
|
+
afterResponse(settle);
|
|
46152
|
+
const fallback = setTimeout(settle, 2e3);
|
|
46153
|
+
}
|
|
46154
|
+
})
|
|
46155
|
+
});
|
|
46284
46156
|
};
|
|
46285
46157
|
const { bound, url, teardown } = yield* resolveListener({
|
|
46286
46158
|
options,
|
|
@@ -46298,9 +46170,45 @@ var init_Server = __esmMin((() => {
|
|
|
46298
46170
|
});
|
|
46299
46171
|
}));
|
|
46300
46172
|
//#endregion
|
|
46173
|
+
//#region src/ui/Host.ts
|
|
46174
|
+
var liveUiHost;
|
|
46175
|
+
var init_Host$1 = __esmMin((() => {
|
|
46176
|
+
init_esm();
|
|
46177
|
+
init_Beat();
|
|
46178
|
+
init_Ports();
|
|
46179
|
+
init_Serve();
|
|
46180
|
+
init_Write();
|
|
46181
|
+
liveUiHost = succeed$2(UiHost, {
|
|
46182
|
+
run: liveRunInWorktree,
|
|
46183
|
+
headSha: liveHeadSha,
|
|
46184
|
+
readLocalGtdVersion: readLocalGtdVersionAt,
|
|
46185
|
+
readFile: liveReadFile,
|
|
46186
|
+
writeFile: liveWriteFile,
|
|
46187
|
+
networkInterfaces: () => networkInterfaces(),
|
|
46188
|
+
serveRecords: {
|
|
46189
|
+
read: (servePort) => readServeRecord(servePort),
|
|
46190
|
+
write: (servePort, record) => writeServeRecord(servePort, record),
|
|
46191
|
+
delete: (servePort) => deleteServeRecord(servePort)
|
|
46192
|
+
},
|
|
46193
|
+
isPidAlive: (pid) => {
|
|
46194
|
+
try {
|
|
46195
|
+
process.kill(pid, 0);
|
|
46196
|
+
return true;
|
|
46197
|
+
} catch {
|
|
46198
|
+
return false;
|
|
46199
|
+
}
|
|
46200
|
+
},
|
|
46201
|
+
scratch: (body) => acquireUseRelease$2(sync$1(() => mkdtempSync(join(tmpdir(), "gtd-tls-"))), (dir) => body(dir, (name) => readFileSync(join(dir, name), "utf8")), (dir) => sync$1(() => rmSync(dir, {
|
|
46202
|
+
recursive: true,
|
|
46203
|
+
force: true
|
|
46204
|
+
})))
|
|
46205
|
+
});
|
|
46206
|
+
}));
|
|
46207
|
+
//#endregion
|
|
46301
46208
|
//#region src/ui/index.ts
|
|
46302
46209
|
var ui_exports = /* @__PURE__ */ __exportAll({
|
|
46303
46210
|
UiError: () => UiError,
|
|
46211
|
+
UiHost: () => UiHost,
|
|
46304
46212
|
UiListener: () => UiListener,
|
|
46305
46213
|
UiShell: () => UiShell,
|
|
46306
46214
|
UiUsageError: () => UiUsageError,
|
|
@@ -46309,6 +46217,7 @@ var ui_exports = /* @__PURE__ */ __exportAll({
|
|
|
46309
46217
|
generateSelfSignedCert: () => generateSelfSignedCert,
|
|
46310
46218
|
liveHeadSha: () => liveHeadSha,
|
|
46311
46219
|
liveReadFile: () => liveReadFile,
|
|
46220
|
+
liveUiHost: () => liveUiHost,
|
|
46312
46221
|
parseTailscaleStatus: () => parseTailscaleStatus,
|
|
46313
46222
|
pickBindHost: () => pickBindHost,
|
|
46314
46223
|
readServeRecord: () => readServeRecord,
|
|
@@ -46318,6 +46227,7 @@ var ui_exports = /* @__PURE__ */ __exportAll({
|
|
|
46318
46227
|
var init_ui = __esmMin((() => {
|
|
46319
46228
|
init_Server();
|
|
46320
46229
|
init_Ports();
|
|
46230
|
+
init_Host$1();
|
|
46321
46231
|
init_Write();
|
|
46322
46232
|
init_Serve();
|
|
46323
46233
|
init_Bind();
|
|
@@ -57331,7 +57241,7 @@ var init_main = __esmMin((() => {
|
|
|
57331
57241
|
}));
|
|
57332
57242
|
//#endregion
|
|
57333
57243
|
//#region src/lsp/Lsp.ts
|
|
57334
|
-
var import_main, toDocumentSymbol, FOOTNOTE_DEFINITION_RE, THREAD_REPLY_RE, revealPositionFor, toCodeAction, toLocation, lineSpan, toDiagnostic, diagnosticsFor, toDocumentLink, documentLinksFor, basenameFallbackFormat, formatForDocument, resolveWorkspaceRoot, OPEN_STEERING_FILE_COMMAND, REVEAL_POSITION_COMMAND, steeringFileOutcome, errorText, revealPositionArgs, makeSteeringLanguageService, bindSteeringServer, run$1, optionalString, parseCurrentRest,
|
|
57244
|
+
var import_main, toDocumentSymbol, FOOTNOTE_DEFINITION_RE, THREAD_REPLY_RE, revealPositionFor, toCodeAction, toLocation, lineSpan, toDiagnostic, diagnosticsFor, toDocumentLink, documentLinksFor, basenameFallbackFormat, formatForDocument, resolveWorkspaceRoot, OPEN_STEERING_FILE_COMMAND, REVEAL_POSITION_COMMAND, steeringFileOutcome, errorText, revealPositionArgs, makeSteeringLanguageService, bindSteeringServer, run$1, optionalString, parseCurrentRest, nodeLspIo, makeLspEnv, serve, serveLspOver, startLspServer;
|
|
57335
57245
|
var init_Lsp = __esmMin((() => {
|
|
57336
57246
|
init_esm();
|
|
57337
57247
|
import_main = require_main();
|
|
@@ -57627,22 +57537,28 @@ var init_Lsp = __esmMin((() => {
|
|
|
57627
57537
|
mode: optionalString(parsed?.["mode"])
|
|
57628
57538
|
};
|
|
57629
57539
|
};
|
|
57630
|
-
|
|
57540
|
+
nodeLspIo = (gtd) => ({
|
|
57541
|
+
cwd: process.cwd(),
|
|
57542
|
+
topLevel: async (dir) => resolve(dir, (await run$1("git", ["rev-parse", "--show-cdup"], dir)).trim()),
|
|
57543
|
+
head: async (root) => (await run$1("git", ["rev-parse", "HEAD"], root)).trim(),
|
|
57544
|
+
next: (root) => run$1(gtd[0], [
|
|
57545
|
+
...gtd.slice(1),
|
|
57546
|
+
"next",
|
|
57547
|
+
"--json"
|
|
57548
|
+
], root)
|
|
57549
|
+
});
|
|
57550
|
+
makeLspEnv = (io, retryAfterMs = 5e3) => {
|
|
57631
57551
|
const memo = /* @__PURE__ */ new Map();
|
|
57632
57552
|
return {
|
|
57633
|
-
cwd:
|
|
57634
|
-
gitTopLevel:
|
|
57553
|
+
cwd: io.cwd,
|
|
57554
|
+
gitTopLevel: (dir) => io.topLevel(dir),
|
|
57635
57555
|
currentRest: async (root) => {
|
|
57636
|
-
const head = await
|
|
57556
|
+
const head = await io.head(root).catch(() => "no-head");
|
|
57637
57557
|
const cached = memo.get(root);
|
|
57638
57558
|
if (cached?.head === head && (cached.failedAt === void 0 || Date.now() - cached.failedAt < retryAfterMs)) return cached.rest;
|
|
57639
57559
|
const entry = {
|
|
57640
57560
|
head,
|
|
57641
|
-
rest:
|
|
57642
|
-
...gtd.slice(1),
|
|
57643
|
-
"next",
|
|
57644
|
-
"--json"
|
|
57645
|
-
], root).then(parseCurrentRest)
|
|
57561
|
+
rest: io.next(root).then(parseCurrentRest)
|
|
57646
57562
|
};
|
|
57647
57563
|
memo.set(root, entry);
|
|
57648
57564
|
entry.rest.catch(() => {
|
|
@@ -57652,20 +57568,28 @@ var init_Lsp = __esmMin((() => {
|
|
|
57652
57568
|
}
|
|
57653
57569
|
};
|
|
57654
57570
|
};
|
|
57655
|
-
|
|
57656
|
-
const connection = (0, import_main.createConnection)(import_main.ProposedFeatures.all, process.stdin, process.stdout);
|
|
57571
|
+
serve = (io, connection) => gen(function* () {
|
|
57657
57572
|
const documents = new import_main.TextDocuments(TextDocument);
|
|
57658
57573
|
const warn = (message) => connection.console.warn(`gtd lsp: ${message}`);
|
|
57659
|
-
|
|
57660
|
-
bindSteeringServer(connection, documents, service);
|
|
57574
|
+
bindSteeringServer(connection, documents, makeSteeringLanguageService(makeLspEnv(io), warn));
|
|
57661
57575
|
yield* async((resume) => {
|
|
57662
57576
|
connection.onExit(() => resume(_void));
|
|
57663
57577
|
});
|
|
57664
57578
|
});
|
|
57579
|
+
serveLspOver = (io, input, output) => {
|
|
57580
|
+
const connection = (0, import_main.createConnection)(import_main.ProposedFeatures.all, new import_main.StreamMessageReader(input), new import_main.StreamMessageWriter(output));
|
|
57581
|
+
runPromise(serve(io, connection));
|
|
57582
|
+
return { close: () => connection.dispose() };
|
|
57583
|
+
};
|
|
57584
|
+
startLspServer = (options) => suspend$5(() => serve(nodeLspIo(options.gtd), (0, import_main.createConnection)(import_main.ProposedFeatures.all, process.stdin, process.stdout)));
|
|
57665
57585
|
}));
|
|
57666
57586
|
//#endregion
|
|
57667
57587
|
//#region src/lsp/index.ts
|
|
57668
|
-
var lsp_exports = /* @__PURE__ */ __exportAll({
|
|
57588
|
+
var lsp_exports = /* @__PURE__ */ __exportAll({
|
|
57589
|
+
nodeLspIo: () => nodeLspIo,
|
|
57590
|
+
serveLspOver: () => serveLspOver,
|
|
57591
|
+
startLspServer: () => startLspServer
|
|
57592
|
+
});
|
|
57669
57593
|
var init_lsp = __esmMin((() => {
|
|
57670
57594
|
init_Lsp();
|
|
57671
57595
|
}));
|
|
@@ -58136,9 +58060,47 @@ var init_loop = __esmMin((() => {
|
|
|
58136
58060
|
init_Host();
|
|
58137
58061
|
}));
|
|
58138
58062
|
//#endregion
|
|
58063
|
+
//#region src/judges/providers/io.ts
|
|
58064
|
+
var liveJudgeIo;
|
|
58065
|
+
var init_io = __esmMin((() => {
|
|
58066
|
+
liveJudgeIo = {
|
|
58067
|
+
readFile: (path) => readFile(path, "utf8"),
|
|
58068
|
+
fetch: (input, init) => fetch(input, init),
|
|
58069
|
+
claude: ({ argv, stdin, env, cwd, timeoutMs }) => new Promise((resolve) => {
|
|
58070
|
+
const child = execFile("claude", argv, {
|
|
58071
|
+
cwd,
|
|
58072
|
+
env,
|
|
58073
|
+
timeout: timeoutMs,
|
|
58074
|
+
killSignal: "SIGKILL",
|
|
58075
|
+
maxBuffer: 64 * 1024 * 1024
|
|
58076
|
+
}, (e, stdout, stderr) => {
|
|
58077
|
+
if (!e) return resolve({
|
|
58078
|
+
kind: "exited",
|
|
58079
|
+
code: 0,
|
|
58080
|
+
stdout,
|
|
58081
|
+
stderr
|
|
58082
|
+
});
|
|
58083
|
+
const { code, killed, message } = e;
|
|
58084
|
+
resolve(code === "ENOENT" ? { kind: "missing" } : killed ? { kind: "timeout" } : typeof code === "number" ? {
|
|
58085
|
+
kind: "exited",
|
|
58086
|
+
code,
|
|
58087
|
+
stdout,
|
|
58088
|
+
stderr
|
|
58089
|
+
} : {
|
|
58090
|
+
kind: "unstartable",
|
|
58091
|
+
message
|
|
58092
|
+
});
|
|
58093
|
+
});
|
|
58094
|
+
child.stdin?.on("error", () => {});
|
|
58095
|
+
child.stdin?.end(stdin);
|
|
58096
|
+
})
|
|
58097
|
+
};
|
|
58098
|
+
}));
|
|
58099
|
+
//#endregion
|
|
58139
58100
|
//#region src/judges/providers/fixed.ts
|
|
58140
58101
|
var fail$3, isAnswer, isProbability, validate, fixed;
|
|
58141
58102
|
var init_fixed = __esmMin((() => {
|
|
58103
|
+
init_io();
|
|
58142
58104
|
fail$3 = (message) => {
|
|
58143
58105
|
throw new Error(`gtd judge run: ${message}`);
|
|
58144
58106
|
};
|
|
@@ -58159,10 +58121,10 @@ var init_fixed = __esmMin((() => {
|
|
|
58159
58121
|
p
|
|
58160
58122
|
};
|
|
58161
58123
|
};
|
|
58162
|
-
fixed = ({ answersPath, env }) => async (questions) => {
|
|
58124
|
+
fixed = ({ answersPath, env, io = liveJudgeIo }) => async (questions) => {
|
|
58163
58125
|
const inline = env["GTD_JUDGE_ANSWERS"];
|
|
58164
58126
|
let raw;
|
|
58165
|
-
if (answersPath !== void 0) raw = await readFile(answersPath
|
|
58127
|
+
if (answersPath !== void 0) raw = await io.readFile(answersPath).catch((e) => fail$3(`cannot read --answers ${answersPath}: ${e instanceof Error ? e.message : String(e)}`));
|
|
58166
58128
|
else if (inline !== void 0 && inline !== "") raw = inline;
|
|
58167
58129
|
else return fail$3("provider \"fixed\" needs --answers <path> or GTD_JUDGE_ANSWERS");
|
|
58168
58130
|
let parsed;
|
|
@@ -58199,6 +58161,7 @@ var init_criteria = __esmMin((() => {
|
|
|
58199
58161
|
var DEFAULT_URL, MODEL, RETRIES, fail$2, translate, toRequest, clamp, unreadable$1, num, probs, toVerdict$1, toVerdicts, sleep, post, parse, jev;
|
|
58200
58162
|
var init_jev = __esmMin((() => {
|
|
58201
58163
|
init_criteria();
|
|
58164
|
+
init_io();
|
|
58202
58165
|
DEFAULT_URL = "https://api.typesafe.ai/v1/systemone";
|
|
58203
58166
|
MODEL = "jev-latest";
|
|
58204
58167
|
RETRIES = 3;
|
|
@@ -58284,9 +58247,9 @@ var init_jev = __esmMin((() => {
|
|
|
58284
58247
|
return questions.map((q) => toVerdict$1(q, map[q.id]));
|
|
58285
58248
|
};
|
|
58286
58249
|
sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
58287
|
-
post = async (url, key, body, delayMs) => {
|
|
58250
|
+
post = async (io, url, key, body, delayMs) => {
|
|
58288
58251
|
for (let attempt = 0;; attempt++) {
|
|
58289
|
-
const res = await fetch(url, {
|
|
58252
|
+
const res = await io.fetch(url, {
|
|
58290
58253
|
method: "POST",
|
|
58291
58254
|
headers: {
|
|
58292
58255
|
Authorization: `Bearer ${key}`,
|
|
@@ -58311,11 +58274,11 @@ var init_jev = __esmMin((() => {
|
|
|
58311
58274
|
return unreadable$1("not JSON");
|
|
58312
58275
|
}
|
|
58313
58276
|
};
|
|
58314
|
-
jev = ({ env, retryDelayMs = 2e3 }) => async (questions, state) => {
|
|
58277
|
+
jev = ({ env, retryDelayMs = 2e3, io = liveJudgeIo }) => async (questions, state) => {
|
|
58315
58278
|
const key = env["TYPESAFE_API_KEY"];
|
|
58316
58279
|
if (key === void 0 || key === "") return fail$2("--provider jev needs TYPESAFE_API_KEY");
|
|
58317
58280
|
const url = env["JEV_BASE_URL"] || DEFAULT_URL;
|
|
58318
|
-
const text = await post(url, key, JSON.stringify(toRequest(questions, state)), retryDelayMs);
|
|
58281
|
+
const text = await post(io, url, key, JSON.stringify(toRequest(questions, state)), retryDelayMs);
|
|
58319
58282
|
return toVerdicts(questions, parse(text));
|
|
58320
58283
|
};
|
|
58321
58284
|
}));
|
|
@@ -58324,6 +58287,7 @@ var init_jev = __esmMin((() => {
|
|
|
58324
58287
|
var DEFAULT_MODEL, TIMEOUT_MS, SYSTEM_PROMPT, fail$1, unreadable, levelsOf, optionsOf, describe, toPrompt, answerSchema, toSchema, isObject, toVerdict, toLlmVerdicts, run, llm;
|
|
58325
58288
|
var init_llm = __esmMin((() => {
|
|
58326
58289
|
init_criteria();
|
|
58290
|
+
init_io();
|
|
58327
58291
|
DEFAULT_MODEL = "haiku";
|
|
58328
58292
|
TIMEOUT_MS = 18e4;
|
|
58329
58293
|
SYSTEM_PROMPT = "You are a strict, impartial judge. Answer each question from the supplied evidence alone.\nReply only with the structured answer; never use tools or ask questions.";
|
|
@@ -58398,40 +58362,35 @@ var init_llm = __esmMin((() => {
|
|
|
58398
58362
|
if (missing.length > 0) return fail$1(`claude answered ${questions.length - missing.length} of ${questions.length} questions; missing ${missing.map((q) => q.id).join(", ")}`);
|
|
58399
58363
|
return questions.map((q) => toVerdict(q, out[q.id]));
|
|
58400
58364
|
};
|
|
58401
|
-
run =
|
|
58402
|
-
const
|
|
58403
|
-
|
|
58404
|
-
|
|
58405
|
-
|
|
58406
|
-
|
|
58407
|
-
|
|
58408
|
-
|
|
58409
|
-
|
|
58410
|
-
const { code, killed, message } = e;
|
|
58411
|
-
reject(/* @__PURE__ */ new Error(code === "ENOENT" ? "gtd judge run: --provider llm needs `claude` on PATH" : killed ? `gtd judge run: claude timed out after ${timeoutMs} ms` : typeof code === "number" ? `gtd judge run: claude exited ${code}: ${stderr.slice(0, 2048)}` : `gtd judge run: claude failed to start: ${message}`));
|
|
58412
|
-
});
|
|
58413
|
-
child.stdin?.on("error", () => {});
|
|
58414
|
-
child.stdin?.end(stdin);
|
|
58415
|
-
});
|
|
58416
|
-
llm = ({ env, cwd, model = DEFAULT_MODEL, timeoutMs = TIMEOUT_MS }) => async (questions, state) => {
|
|
58365
|
+
run = async (io, call) => {
|
|
58366
|
+
const outcome = await io.claude(call);
|
|
58367
|
+
if (outcome.kind === "missing") return fail$1("--provider llm needs `claude` on PATH");
|
|
58368
|
+
if (outcome.kind === "timeout") return fail$1(`claude timed out after ${call.timeoutMs} ms`);
|
|
58369
|
+
if (outcome.kind === "unstartable") return fail$1(`claude failed to start: ${outcome.message}`);
|
|
58370
|
+
if (outcome.code !== 0) return fail$1(`claude exited ${outcome.code}: ${outcome.stderr.slice(0, 2048)}`);
|
|
58371
|
+
return outcome.stdout;
|
|
58372
|
+
};
|
|
58373
|
+
llm = ({ env, cwd, model = DEFAULT_MODEL, timeoutMs = TIMEOUT_MS, io = liveJudgeIo }) => async (questions, state) => {
|
|
58417
58374
|
const schema = JSON.stringify(toSchema(questions));
|
|
58418
58375
|
const prompt = toPrompt(questions, state);
|
|
58419
|
-
const stdout = await run(
|
|
58420
|
-
|
|
58421
|
-
|
|
58422
|
-
|
|
58423
|
-
|
|
58424
|
-
|
|
58425
|
-
|
|
58426
|
-
|
|
58427
|
-
|
|
58428
|
-
|
|
58429
|
-
|
|
58430
|
-
|
|
58431
|
-
|
|
58432
|
-
|
|
58433
|
-
|
|
58434
|
-
|
|
58376
|
+
const stdout = await run(io, {
|
|
58377
|
+
argv: [
|
|
58378
|
+
"-p",
|
|
58379
|
+
"--model",
|
|
58380
|
+
model,
|
|
58381
|
+
"--output-format",
|
|
58382
|
+
"json",
|
|
58383
|
+
"--json-schema",
|
|
58384
|
+
schema,
|
|
58385
|
+
"--system-prompt",
|
|
58386
|
+
SYSTEM_PROMPT,
|
|
58387
|
+
"--tools",
|
|
58388
|
+
"",
|
|
58389
|
+
"--no-session-persistence",
|
|
58390
|
+
"--settings",
|
|
58391
|
+
"{\"disableAllHooks\":true}"
|
|
58392
|
+
],
|
|
58393
|
+
stdin: prompt,
|
|
58435
58394
|
env,
|
|
58436
58395
|
cwd,
|
|
58437
58396
|
timeoutMs
|
|
@@ -58443,6 +58402,7 @@ var init_llm = __esmMin((() => {
|
|
|
58443
58402
|
//#region src/judges/run.ts
|
|
58444
58403
|
var PROVIDERS, fail, envProvider, checkPairing, userConfigPath, readText, parseObject, decodeUserConfig, readUserConfig, selectJudge, answererFor, runJudge;
|
|
58445
58404
|
var init_run = __esmMin((() => {
|
|
58405
|
+
init_io();
|
|
58446
58406
|
init_fixed();
|
|
58447
58407
|
init_jev();
|
|
58448
58408
|
init_llm();
|
|
@@ -58466,9 +58426,9 @@ var init_run = __esmMin((() => {
|
|
|
58466
58426
|
const home = env["HOME"];
|
|
58467
58427
|
return home ? `${home}/.config/gtd/judge.json` : void 0;
|
|
58468
58428
|
};
|
|
58469
|
-
readText = async (path) => {
|
|
58429
|
+
readText = async (io, path) => {
|
|
58470
58430
|
try {
|
|
58471
|
-
return await readFile(path
|
|
58431
|
+
return await io.readFile(path);
|
|
58472
58432
|
} catch (e) {
|
|
58473
58433
|
if (e.code === "ENOENT") return void 0;
|
|
58474
58434
|
return fail(`cannot read ${path}: ${e instanceof Error ? e.message : String(e)}`);
|
|
@@ -58494,9 +58454,9 @@ var init_run = __esmMin((() => {
|
|
|
58494
58454
|
model
|
|
58495
58455
|
};
|
|
58496
58456
|
};
|
|
58497
|
-
readUserConfig = async (env) => {
|
|
58457
|
+
readUserConfig = async (io, env) => {
|
|
58498
58458
|
const path = userConfigPath(env);
|
|
58499
|
-
const text = path === void 0 ? void 0 : await readText(path);
|
|
58459
|
+
const text = path === void 0 ? void 0 : await readText(io, path);
|
|
58500
58460
|
return path === void 0 || text === void 0 ? void 0 : decodeUserConfig(path, text);
|
|
58501
58461
|
};
|
|
58502
58462
|
selectJudge = ({ provider, model, env }, user) => {
|
|
@@ -58517,17 +58477,22 @@ var init_run = __esmMin((() => {
|
|
|
58517
58477
|
});
|
|
58518
58478
|
};
|
|
58519
58479
|
answererFor = async (opts) => {
|
|
58520
|
-
const { answers, env, cwd } = opts;
|
|
58521
|
-
const { provider, model } = selectJudge(opts, await readUserConfig(env));
|
|
58480
|
+
const { answers, env, cwd, io = liveJudgeIo } = opts;
|
|
58481
|
+
const { provider, model } = selectJudge(opts, await readUserConfig(io, env));
|
|
58522
58482
|
if (provider === "fixed") return fixed({
|
|
58523
58483
|
answersPath: answers,
|
|
58524
|
-
env
|
|
58484
|
+
env,
|
|
58485
|
+
io
|
|
58486
|
+
});
|
|
58487
|
+
if (provider === "jev" || provider === void 0 && model === void 0 && env["TYPESAFE_API_KEY"]) return jev({
|
|
58488
|
+
env,
|
|
58489
|
+
io
|
|
58525
58490
|
});
|
|
58526
|
-
if (provider === "jev" || provider === void 0 && model === void 0 && env["TYPESAFE_API_KEY"]) return jev({ env });
|
|
58527
58491
|
return llm({
|
|
58528
58492
|
env,
|
|
58529
58493
|
cwd,
|
|
58530
|
-
model
|
|
58494
|
+
model,
|
|
58495
|
+
io
|
|
58531
58496
|
});
|
|
58532
58497
|
};
|
|
58533
58498
|
runJudge = async (opts) => {
|
|
@@ -58546,11 +58511,13 @@ var init_run = __esmMin((() => {
|
|
|
58546
58511
|
//#endregion
|
|
58547
58512
|
//#region src/judges/index.ts
|
|
58548
58513
|
var judges_exports = /* @__PURE__ */ __exportAll({
|
|
58514
|
+
liveJudgeIo: () => liveJudgeIo,
|
|
58549
58515
|
runJudge: () => runJudge,
|
|
58550
58516
|
toRequest: () => toRequest
|
|
58551
58517
|
});
|
|
58552
58518
|
var init_judges = __esmMin((() => {
|
|
58553
58519
|
init_run();
|
|
58520
|
+
init_io();
|
|
58554
58521
|
init_jev();
|
|
58555
58522
|
}));
|
|
58556
58523
|
//#endregion
|
|
@@ -58568,8 +58535,8 @@ const liveToolCommands = effect$1(ToolCommands, gen(function* () {
|
|
|
58568
58535
|
const fs = yield* FileSystem;
|
|
58569
58536
|
return {
|
|
58570
58537
|
ui: (request, out) => lazy("ui", async () => {
|
|
58571
|
-
const { runUiCommand, UiListener, UiShell, UiUsageError } = await Promise.resolve().then(() => (init_ui(), ui_exports));
|
|
58572
|
-
return () => runUiCommand(request.flags, uiConfigOf(request.config), out, request.root).pipe(provideService(UiShell, shell), provideService(FileSystem, fs), provide$1(UiListener.Live), mapError$1((error) => error instanceof UiUsageError ? new GtdUsageError(error.message, error.detail) : new GtdError(error.message, error.detail)));
|
|
58538
|
+
const { runUiCommand, UiListener, UiShell, UiUsageError, liveUiHost } = await Promise.resolve().then(() => (init_ui(), ui_exports));
|
|
58539
|
+
return () => runUiCommand(request.flags, uiConfigOf(request.config), out, request.root).pipe(provideService(UiShell, shell), provideService(FileSystem, fs), provide$1(UiListener.Live), provide$1(liveUiHost), mapError$1((error) => error instanceof UiUsageError ? new GtdUsageError(error.message, error.detail) : new GtdError(error.message, error.detail)));
|
|
58573
58540
|
}),
|
|
58574
58541
|
lsp: (gtd) => lazy("lsp", async () => {
|
|
58575
58542
|
const { startLspServer } = await Promise.resolve().then(() => (init_lsp(), lsp_exports));
|