@slayzone/computer 0.36.1 → 0.36.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.cjs +2846 -443
- package/dist/bin.cjs.map +4 -4
- package/package.json +1 -1
package/dist/bin.cjs
CHANGED
|
@@ -21,9 +21,9 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
21
21
|
throw mod = 0, e;
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
var __export = (
|
|
24
|
+
var __export = (target2, all) => {
|
|
25
25
|
for (var name in all)
|
|
26
|
-
__defProp(
|
|
26
|
+
__defProp(target2, name, { get: all[name], enumerable: true });
|
|
27
27
|
};
|
|
28
28
|
var __copyProps = (to, from, except, desc) => {
|
|
29
29
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -33,12 +33,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
33
33
|
}
|
|
34
34
|
return to;
|
|
35
35
|
};
|
|
36
|
-
var __toESM = (mod, isNodeMode,
|
|
36
|
+
var __toESM = (mod, isNodeMode, target2) => (target2 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
37
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
38
|
// file that has been converted to a CommonJS file using a Babel-
|
|
39
39
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
40
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
41
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(
|
|
41
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target2, "default", { value: mod, enumerable: true }) : target2,
|
|
42
42
|
mod
|
|
43
43
|
));
|
|
44
44
|
|
|
@@ -126,17 +126,17 @@ var require_buffer_util = __commonJS({
|
|
|
126
126
|
function concat(list, totalLength) {
|
|
127
127
|
if (list.length === 0) return EMPTY_BUFFER;
|
|
128
128
|
if (list.length === 1) return list[0];
|
|
129
|
-
const
|
|
129
|
+
const target2 = Buffer.allocUnsafe(totalLength);
|
|
130
130
|
let offset = 0;
|
|
131
131
|
for (let i = 0; i < list.length; i++) {
|
|
132
132
|
const buf = list[i];
|
|
133
|
-
|
|
133
|
+
target2.set(buf, offset);
|
|
134
134
|
offset += buf.length;
|
|
135
135
|
}
|
|
136
136
|
if (offset < totalLength) {
|
|
137
|
-
return new FastBuffer(
|
|
137
|
+
return new FastBuffer(target2.buffer, target2.byteOffset, offset);
|
|
138
138
|
}
|
|
139
|
-
return
|
|
139
|
+
return target2;
|
|
140
140
|
}
|
|
141
141
|
function _mask(source, mask, output2, offset, length) {
|
|
142
142
|
for (let i = 0; i < length; i++) {
|
|
@@ -1560,29 +1560,29 @@ var require_sender = __commonJS({
|
|
|
1560
1560
|
offset += 2;
|
|
1561
1561
|
payloadLength = 126;
|
|
1562
1562
|
}
|
|
1563
|
-
const
|
|
1564
|
-
|
|
1565
|
-
if (options.rsv1)
|
|
1566
|
-
|
|
1563
|
+
const target2 = Buffer.allocUnsafe(merge2 ? dataLength + offset : offset);
|
|
1564
|
+
target2[0] = options.fin ? options.opcode | 128 : options.opcode;
|
|
1565
|
+
if (options.rsv1) target2[0] |= 64;
|
|
1566
|
+
target2[1] = payloadLength;
|
|
1567
1567
|
if (payloadLength === 126) {
|
|
1568
|
-
|
|
1568
|
+
target2.writeUInt16BE(dataLength, 2);
|
|
1569
1569
|
} else if (payloadLength === 127) {
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
}
|
|
1573
|
-
if (!options.mask) return [
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
if (skipMasking) return [
|
|
1570
|
+
target2[2] = target2[3] = 0;
|
|
1571
|
+
target2.writeUIntBE(dataLength, 4, 6);
|
|
1572
|
+
}
|
|
1573
|
+
if (!options.mask) return [target2, data];
|
|
1574
|
+
target2[1] |= 128;
|
|
1575
|
+
target2[offset - 4] = mask[0];
|
|
1576
|
+
target2[offset - 3] = mask[1];
|
|
1577
|
+
target2[offset - 2] = mask[2];
|
|
1578
|
+
target2[offset - 1] = mask[3];
|
|
1579
|
+
if (skipMasking) return [target2, data];
|
|
1580
1580
|
if (merge2) {
|
|
1581
|
-
applyMask(data, mask,
|
|
1582
|
-
return [
|
|
1581
|
+
applyMask(data, mask, target2, offset, dataLength);
|
|
1582
|
+
return [target2];
|
|
1583
1583
|
}
|
|
1584
1584
|
applyMask(data, mask, data, 0, dataLength);
|
|
1585
|
-
return [
|
|
1585
|
+
return [target2, data];
|
|
1586
1586
|
}
|
|
1587
1587
|
/**
|
|
1588
1588
|
* Sends a close message to the other peer.
|
|
@@ -2180,7 +2180,7 @@ var require_extension = __commonJS({
|
|
|
2180
2180
|
if (dest[name] === void 0) dest[name] = [elem];
|
|
2181
2181
|
else dest[name].push(elem);
|
|
2182
2182
|
}
|
|
2183
|
-
function
|
|
2183
|
+
function parse5(header) {
|
|
2184
2184
|
const offers = /* @__PURE__ */ Object.create(null);
|
|
2185
2185
|
let params = /* @__PURE__ */ Object.create(null);
|
|
2186
2186
|
let mustUnescape = false;
|
|
@@ -2320,7 +2320,7 @@ var require_extension = __commonJS({
|
|
|
2320
2320
|
}).join(", ");
|
|
2321
2321
|
}).join(", ");
|
|
2322
2322
|
}
|
|
2323
|
-
module2.exports = { format, parse:
|
|
2323
|
+
module2.exports = { format, parse: parse5 };
|
|
2324
2324
|
}
|
|
2325
2325
|
});
|
|
2326
2326
|
|
|
@@ -2354,7 +2354,7 @@ var require_websocket = __commonJS({
|
|
|
2354
2354
|
var {
|
|
2355
2355
|
EventTarget: { addEventListener, removeEventListener }
|
|
2356
2356
|
} = require_event_target();
|
|
2357
|
-
var { format, parse:
|
|
2357
|
+
var { format, parse: parse5 } = require_extension();
|
|
2358
2358
|
var { toBuffer } = require_buffer_util();
|
|
2359
2359
|
var kAborted = /* @__PURE__ */ Symbol("kAborted");
|
|
2360
2360
|
var protocolVersions = [8, 13];
|
|
@@ -3044,7 +3044,7 @@ var require_websocket = __commonJS({
|
|
|
3044
3044
|
}
|
|
3045
3045
|
let extensions;
|
|
3046
3046
|
try {
|
|
3047
|
-
extensions =
|
|
3047
|
+
extensions = parse5(secWebSocketExtensions);
|
|
3048
3048
|
} catch (err) {
|
|
3049
3049
|
const message = "Invalid Sec-WebSocket-Extensions header";
|
|
3050
3050
|
abortHandshake(websocket, socket, message);
|
|
@@ -3336,7 +3336,7 @@ var require_subprotocol = __commonJS({
|
|
|
3336
3336
|
"../../../node_modules/ws/lib/subprotocol.js"(exports2, module2) {
|
|
3337
3337
|
"use strict";
|
|
3338
3338
|
var { tokenChars } = require_validation();
|
|
3339
|
-
function
|
|
3339
|
+
function parse5(header) {
|
|
3340
3340
|
const protocols = /* @__PURE__ */ new Set();
|
|
3341
3341
|
let start = -1;
|
|
3342
3342
|
let end = -1;
|
|
@@ -3372,7 +3372,7 @@ var require_subprotocol = __commonJS({
|
|
|
3372
3372
|
protocols.add(protocol);
|
|
3373
3373
|
return protocols;
|
|
3374
3374
|
}
|
|
3375
|
-
module2.exports = { parse:
|
|
3375
|
+
module2.exports = { parse: parse5 };
|
|
3376
3376
|
}
|
|
3377
3377
|
});
|
|
3378
3378
|
|
|
@@ -3779,44 +3779,44 @@ var require_websocket_server = __commonJS({
|
|
|
3779
3779
|
|
|
3780
3780
|
// ../../shared/platform/src/fs-utils.ts
|
|
3781
3781
|
async function writeFileIfChanged(filePath, content, mode) {
|
|
3782
|
-
const
|
|
3782
|
+
const target2 = await resolveTarget(filePath);
|
|
3783
3783
|
const buf = Buffer.isBuffer(content) ? content : Buffer.from(content, "utf8");
|
|
3784
|
-
const existing = await safeReadFile(
|
|
3784
|
+
const existing = await safeReadFile(target2);
|
|
3785
3785
|
if (existing && existing.equals(buf)) return false;
|
|
3786
|
-
await import_promises3.default.mkdir(import_path2.default.dirname(
|
|
3787
|
-
const tmp = `${
|
|
3786
|
+
await import_promises3.default.mkdir(import_path2.default.dirname(target2), { recursive: true });
|
|
3787
|
+
const tmp = `${target2}.tmp.${import_crypto.default.randomBytes(6).toString("hex")}`;
|
|
3788
3788
|
await import_promises3.default.writeFile(tmp, buf);
|
|
3789
3789
|
if (mode != null && process.platform !== "win32") {
|
|
3790
3790
|
await import_promises3.default.chmod(tmp, mode);
|
|
3791
3791
|
}
|
|
3792
|
-
await import_promises3.default.rename(tmp,
|
|
3792
|
+
await import_promises3.default.rename(tmp, target2);
|
|
3793
3793
|
return true;
|
|
3794
3794
|
}
|
|
3795
3795
|
async function updateFileAtomically(filePath, merge2, opts = {}) {
|
|
3796
3796
|
const { mode, retries = 5 } = opts;
|
|
3797
|
-
const
|
|
3798
|
-
await import_promises3.default.mkdir(import_path2.default.dirname(
|
|
3799
|
-
const release = await acquireLock(`${
|
|
3797
|
+
const target2 = await resolveTarget(filePath);
|
|
3798
|
+
await import_promises3.default.mkdir(import_path2.default.dirname(target2), { recursive: true });
|
|
3799
|
+
const release = await acquireLock(`${target2}.lock`);
|
|
3800
3800
|
try {
|
|
3801
3801
|
for (let attempt = 0; ; attempt++) {
|
|
3802
|
-
const baseline = await safeReadFile(
|
|
3802
|
+
const baseline = await safeReadFile(target2);
|
|
3803
3803
|
const merged = await merge2(baseline);
|
|
3804
3804
|
if (merged == null) return false;
|
|
3805
3805
|
const buf = Buffer.isBuffer(merged) ? merged : Buffer.from(merged, "utf8");
|
|
3806
3806
|
if (baseline && baseline.equals(buf)) return false;
|
|
3807
|
-
const tmp = `${
|
|
3807
|
+
const tmp = `${target2}.tmp.${import_crypto.default.randomBytes(6).toString("hex")}`;
|
|
3808
3808
|
await import_promises3.default.writeFile(tmp, buf);
|
|
3809
3809
|
if (mode != null && process.platform !== "win32") {
|
|
3810
3810
|
await import_promises3.default.chmod(tmp, mode);
|
|
3811
3811
|
}
|
|
3812
|
-
if (sameBytes(baseline, await safeReadFile(
|
|
3813
|
-
await import_promises3.default.rename(tmp,
|
|
3812
|
+
if (sameBytes(baseline, await safeReadFile(target2))) {
|
|
3813
|
+
await import_promises3.default.rename(tmp, target2);
|
|
3814
3814
|
return true;
|
|
3815
3815
|
}
|
|
3816
3816
|
await import_promises3.default.rm(tmp, { force: true });
|
|
3817
3817
|
if (attempt >= retries) {
|
|
3818
3818
|
throw new Error(
|
|
3819
|
-
`[fs-utils] updateFileAtomically: ${
|
|
3819
|
+
`[fs-utils] updateFileAtomically: ${target2} kept changing underneath ${retries + 1} merge attempts \u2014 giving up rather than writing a stale merge`
|
|
3820
3820
|
);
|
|
3821
3821
|
}
|
|
3822
3822
|
await sleep(2 ** attempt + Math.floor(Math.random() * 5));
|
|
@@ -3864,7 +3864,7 @@ function sameBytes(a, b) {
|
|
|
3864
3864
|
return a.equals(b);
|
|
3865
3865
|
}
|
|
3866
3866
|
function sleep(ms) {
|
|
3867
|
-
return new Promise((
|
|
3867
|
+
return new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
3868
3868
|
}
|
|
3869
3869
|
async function safeReadFile(p) {
|
|
3870
3870
|
try {
|
|
@@ -3876,8 +3876,8 @@ async function safeReadFile(p) {
|
|
|
3876
3876
|
}
|
|
3877
3877
|
async function resolveTarget(p) {
|
|
3878
3878
|
try {
|
|
3879
|
-
const
|
|
3880
|
-
if (
|
|
3879
|
+
const stat3 = await import_promises3.default.lstat(p);
|
|
3880
|
+
if (stat3.isSymbolicLink()) return await import_promises3.default.realpath(p);
|
|
3881
3881
|
} catch (err) {
|
|
3882
3882
|
if (!isENOENT(err)) throw err;
|
|
3883
3883
|
}
|
|
@@ -4197,7 +4197,7 @@ var require_ignore = __commonJS({
|
|
|
4197
4197
|
// Zero, one or several directories
|
|
4198
4198
|
// should not use '*', or it will be replaced by the next replacer
|
|
4199
4199
|
// Check if it is not the last `'/**'`
|
|
4200
|
-
(_, index,
|
|
4200
|
+
(_, index, str2) => index + 6 < str2.length ? str2.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : "\\/.+",
|
|
4201
4201
|
"*"
|
|
4202
4202
|
],
|
|
4203
4203
|
// normal intermediate wildcards
|
|
@@ -4436,8 +4436,8 @@ var require_ignore = __commonJS({
|
|
|
4436
4436
|
);
|
|
4437
4437
|
return cut < 0 ? EMPTY : path9.slice(0, cut + 1);
|
|
4438
4438
|
};
|
|
4439
|
-
var
|
|
4440
|
-
var checkPattern = (pattern) => pattern &&
|
|
4439
|
+
var isString2 = (subject) => typeof subject === "string";
|
|
4440
|
+
var checkPattern = (pattern) => pattern && isString2(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
|
|
4441
4441
|
var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
|
|
4442
4442
|
var IgnoreRule = class {
|
|
4443
4443
|
constructor(pattern, mark, body, ignoreCase, negative, prefix) {
|
|
@@ -4471,12 +4471,12 @@ var require_ignore = __commonJS({
|
|
|
4471
4471
|
return this._make(MODE_CHECK_IGNORE, key);
|
|
4472
4472
|
}
|
|
4473
4473
|
_make(mode, key) {
|
|
4474
|
-
const
|
|
4474
|
+
const str2 = pinWildcards(this.regexPrefix.replace(
|
|
4475
4475
|
REGEX_REPLACE_TRAILING_WILDCARD,
|
|
4476
4476
|
// It does not need to bind pattern
|
|
4477
4477
|
TRAILING_WILD_CARD_REPLACERS[mode]
|
|
4478
4478
|
));
|
|
4479
|
-
const regex = this.ignoreCase ? new RegExp(
|
|
4479
|
+
const regex = this.ignoreCase ? new RegExp(str2, "i") : new RegExp(str2);
|
|
4480
4480
|
return define(this, key, regex);
|
|
4481
4481
|
}
|
|
4482
4482
|
};
|
|
@@ -4514,7 +4514,7 @@ var require_ignore = __commonJS({
|
|
|
4514
4514
|
this._added = true;
|
|
4515
4515
|
return;
|
|
4516
4516
|
}
|
|
4517
|
-
if (
|
|
4517
|
+
if (isString2(pattern)) {
|
|
4518
4518
|
pattern = {
|
|
4519
4519
|
pattern
|
|
4520
4520
|
};
|
|
@@ -4532,7 +4532,7 @@ var require_ignore = __commonJS({
|
|
|
4532
4532
|
add(pattern) {
|
|
4533
4533
|
this._added = false;
|
|
4534
4534
|
makeArray(
|
|
4535
|
-
|
|
4535
|
+
isString2(pattern) ? splitPattern(pattern) : pattern
|
|
4536
4536
|
).forEach(this._add, this);
|
|
4537
4537
|
return this._added;
|
|
4538
4538
|
}
|
|
@@ -4577,7 +4577,7 @@ var require_ignore = __commonJS({
|
|
|
4577
4577
|
throw new Ctor(message);
|
|
4578
4578
|
};
|
|
4579
4579
|
var checkPath = (path9, originalPath, doThrow) => {
|
|
4580
|
-
if (!
|
|
4580
|
+
if (!isString2(path9)) {
|
|
4581
4581
|
return doThrow(
|
|
4582
4582
|
`path must be a string, but got \`${originalPath}\``,
|
|
4583
4583
|
TypeError
|
|
@@ -4690,7 +4690,7 @@ var require_ignore = __commonJS({
|
|
|
4690
4690
|
var factory = (options) => new Ignore(options);
|
|
4691
4691
|
var isPathValid = (path9) => checkPath(path9 && checkPath.convert(path9), path9, RETURN_FALSE);
|
|
4692
4692
|
var setupWindows = () => {
|
|
4693
|
-
const makePosix = (
|
|
4693
|
+
const makePosix = (str2) => /^\\\\\?\\/.test(str2) || /["<>|\u0000-\u001F]+/u.test(str2) ? str2 : str2.replace(/\\/g, "/");
|
|
4694
4694
|
checkPath.convert = makePosix;
|
|
4695
4695
|
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
4696
4696
|
checkPath.isNotRelative = (path9) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path9) || isNotRelative(path9);
|
|
@@ -4716,11 +4716,11 @@ function parseNotifyVersion(script) {
|
|
|
4716
4716
|
return Number.isFinite(n) ? n : 0;
|
|
4717
4717
|
}
|
|
4718
4718
|
async function installNotifyScript(opts) {
|
|
4719
|
-
const
|
|
4719
|
+
const target2 = opts.targetPath ?? import_path3.default.join(getHooksDir(), "notify.sh");
|
|
4720
4720
|
const source = opts.source;
|
|
4721
4721
|
const incomingV = parseNotifyVersion(source);
|
|
4722
4722
|
const changed = await updateFileAtomically(
|
|
4723
|
-
|
|
4723
|
+
target2,
|
|
4724
4724
|
(current) => {
|
|
4725
4725
|
if (current === null) return source;
|
|
4726
4726
|
if (incomingV < parseNotifyVersion(current.toString("utf8"))) return null;
|
|
@@ -4728,7 +4728,7 @@ async function installNotifyScript(opts) {
|
|
|
4728
4728
|
},
|
|
4729
4729
|
{ mode: 493 }
|
|
4730
4730
|
);
|
|
4731
|
-
return { path:
|
|
4731
|
+
return { path: target2, changed };
|
|
4732
4732
|
}
|
|
4733
4733
|
var import_path3;
|
|
4734
4734
|
var init_notify_script_installer = __esm({
|
|
@@ -4757,10 +4757,10 @@ var init_hook_paths = __esm({
|
|
|
4757
4757
|
|
|
4758
4758
|
// ../../shared/platform/src/agent-hooks/claude-hook-installer.ts
|
|
4759
4759
|
async function installClaudeHooks(opts) {
|
|
4760
|
-
const
|
|
4760
|
+
const target2 = opts.settingsPath ?? getClaudeSettingsPath();
|
|
4761
4761
|
const events = opts.events ?? CLAUDE_HOOK_EVENTS;
|
|
4762
4762
|
let result = { installed: false, eventsAdded: [], reason: "unwritten" };
|
|
4763
|
-
await updateFileAtomically(
|
|
4763
|
+
await updateFileAtomically(target2, (current) => {
|
|
4764
4764
|
let settings;
|
|
4765
4765
|
if (current === null) {
|
|
4766
4766
|
settings = {};
|
|
@@ -4868,10 +4868,10 @@ async function installGeminiHooks(opts) {
|
|
|
4868
4868
|
return { installed: false, eventsAdded: [], reason: "gemini binary not on PATH" };
|
|
4869
4869
|
}
|
|
4870
4870
|
}
|
|
4871
|
-
const
|
|
4871
|
+
const target2 = opts.settingsPath ?? getGeminiSettingsPath();
|
|
4872
4872
|
const events = opts.events ?? GEMINI_HOOK_EVENTS;
|
|
4873
4873
|
let result = { installed: false, eventsAdded: [], reason: "unwritten" };
|
|
4874
|
-
await updateFileAtomically(
|
|
4874
|
+
await updateFileAtomically(target2, (current) => {
|
|
4875
4875
|
let settings;
|
|
4876
4876
|
if (current === null) {
|
|
4877
4877
|
settings = {};
|
|
@@ -4971,10 +4971,10 @@ async function installCodexHooks(opts) {
|
|
|
4971
4971
|
);
|
|
4972
4972
|
}
|
|
4973
4973
|
}
|
|
4974
|
-
const
|
|
4974
|
+
const target2 = opts.hooksPath ?? getCodexHooksPath();
|
|
4975
4975
|
const events = opts.events ?? CODEX_HOOK_EVENTS;
|
|
4976
4976
|
let result = { installed: false, eventsAdded: [], reason: "unwritten" };
|
|
4977
|
-
await updateFileAtomically(
|
|
4977
|
+
await updateFileAtomically(target2, (current) => {
|
|
4978
4978
|
let config2;
|
|
4979
4979
|
if (current === null) {
|
|
4980
4980
|
config2 = {};
|
|
@@ -5041,11 +5041,11 @@ function isManagedSlayzoneHook3(hook) {
|
|
|
5041
5041
|
return cmd.includes(".slayzone/hooks/notify.sh") || cmd.includes("/slayzone/hooks/notify.sh");
|
|
5042
5042
|
}
|
|
5043
5043
|
async function uninstallCodexWrapper(opts = {}) {
|
|
5044
|
-
const
|
|
5044
|
+
const target2 = opts.wrapperPath ?? import_path4.default.join(getSlayzoneBinDir(), "codex");
|
|
5045
5045
|
try {
|
|
5046
|
-
const content = await
|
|
5046
|
+
const content = await import_promises11.default.readFile(target2, "utf8");
|
|
5047
5047
|
if (!content.includes("slayzone codex wrapper")) return false;
|
|
5048
|
-
await
|
|
5048
|
+
await import_promises11.default.unlink(target2);
|
|
5049
5049
|
return true;
|
|
5050
5050
|
} catch (err) {
|
|
5051
5051
|
if (isENOENT2(err)) return false;
|
|
@@ -5064,9 +5064,9 @@ async function probeCodexVersion() {
|
|
|
5064
5064
|
}
|
|
5065
5065
|
}
|
|
5066
5066
|
function stripSlayzoneBin(pathVar) {
|
|
5067
|
-
const
|
|
5067
|
+
const sep6 = process.platform === "win32" ? ";" : ":";
|
|
5068
5068
|
const ours = getSlayzoneBinDir();
|
|
5069
|
-
return pathVar.split(
|
|
5069
|
+
return pathVar.split(sep6).filter((p) => p !== ours).join(sep6);
|
|
5070
5070
|
}
|
|
5071
5071
|
function parseCodexVersion(raw) {
|
|
5072
5072
|
const match = raw.match(/(\d+)\.(\d+)(?:\.(\d+))?/);
|
|
@@ -5080,18 +5080,18 @@ function isAtLeast(v, min) {
|
|
|
5080
5080
|
function isENOENT2(err) {
|
|
5081
5081
|
return typeof err === "object" && err != null && err.code === "ENOENT";
|
|
5082
5082
|
}
|
|
5083
|
-
var
|
|
5083
|
+
var import_promises11, import_path4, import_child_process2, import_util14, execP, MARKER_KEY3, CODEX_HOOK_EVENTS, TOOL_MATCHED_EVENTS3, MIN_CODEX_VERSION;
|
|
5084
5084
|
var init_codex_hook_installer = __esm({
|
|
5085
5085
|
"../../shared/platform/src/agent-hooks/codex-hook-installer.ts"() {
|
|
5086
5086
|
"use strict";
|
|
5087
|
-
|
|
5087
|
+
import_promises11 = __toESM(require("fs/promises"), 1);
|
|
5088
5088
|
import_path4 = __toESM(require("path"), 1);
|
|
5089
5089
|
import_child_process2 = require("child_process");
|
|
5090
|
-
|
|
5090
|
+
import_util14 = require("util");
|
|
5091
5091
|
init_dirs();
|
|
5092
5092
|
init_fs_utils();
|
|
5093
5093
|
init_hook_paths();
|
|
5094
|
-
execP = (0,
|
|
5094
|
+
execP = (0, import_util14.promisify)(import_child_process2.exec);
|
|
5095
5095
|
MARKER_KEY3 = "_slayzoneManaged";
|
|
5096
5096
|
CODEX_HOOK_EVENTS = [
|
|
5097
5097
|
"SessionStart",
|
|
@@ -5123,14 +5123,14 @@ async function installAntigravityHooks(opts) {
|
|
|
5123
5123
|
return { installed: false, eventsAdded: [], reason: "agy binary not on PATH" };
|
|
5124
5124
|
}
|
|
5125
5125
|
}
|
|
5126
|
-
const
|
|
5126
|
+
const target2 = opts.hooksPath ?? getAntigravityHooksPath();
|
|
5127
5127
|
const events = opts.events ?? ANTIGRAVITY_HOOK_EVENTS;
|
|
5128
5128
|
let result = {
|
|
5129
5129
|
installed: false,
|
|
5130
5130
|
eventsAdded: [],
|
|
5131
5131
|
reason: "unwritten"
|
|
5132
5132
|
};
|
|
5133
|
-
await updateFileAtomically(
|
|
5133
|
+
await updateFileAtomically(target2, (current) => {
|
|
5134
5134
|
let hooksFile;
|
|
5135
5135
|
if (current === null) {
|
|
5136
5136
|
hooksFile = {};
|
|
@@ -5189,11 +5189,11 @@ var init_antigravity_hook_installer = __esm({
|
|
|
5189
5189
|
|
|
5190
5190
|
// ../../shared/platform/src/agent-hooks/opencode-plugin-installer.ts
|
|
5191
5191
|
async function installOpencodePlugin(opts) {
|
|
5192
|
-
const
|
|
5192
|
+
const target2 = opts.targetPath ?? getOpencodePluginPath();
|
|
5193
5193
|
const rawSource = opts.source;
|
|
5194
5194
|
const content = rawSource.split(NOTIFY_PATH_PLACEHOLDER).join(toPosixPath(opts.notifyPath));
|
|
5195
|
-
const changed = await writeFileIfChanged(
|
|
5196
|
-
return { path:
|
|
5195
|
+
const changed = await writeFileIfChanged(target2, content, 420);
|
|
5196
|
+
return { path: target2, changed };
|
|
5197
5197
|
}
|
|
5198
5198
|
var NOTIFY_PATH_PLACEHOLDER;
|
|
5199
5199
|
var init_opencode_plugin_installer = __esm({
|
|
@@ -5220,10 +5220,10 @@ var init_agent_hooks = __esm({
|
|
|
5220
5220
|
}
|
|
5221
5221
|
});
|
|
5222
5222
|
|
|
5223
|
-
// raw-import:/tmp/slz-publish-wt.
|
|
5223
|
+
// raw-import:/tmp/slz-publish-wt.AbcjgE/packages/shared/hooks/src/notify.sh
|
|
5224
5224
|
var notify_default;
|
|
5225
5225
|
var init_notify = __esm({
|
|
5226
|
-
"raw-import:/tmp/slz-publish-wt.
|
|
5226
|
+
"raw-import:/tmp/slz-publish-wt.AbcjgE/packages/shared/hooks/src/notify.sh"() {
|
|
5227
5227
|
notify_default = `#!/bin/sh
|
|
5228
5228
|
# SlayZone agent lifecycle hook \u2014 BENIGN DUMB FORWARDER.
|
|
5229
5229
|
#
|
|
@@ -5385,10 +5385,10 @@ exit 0
|
|
|
5385
5385
|
}
|
|
5386
5386
|
});
|
|
5387
5387
|
|
|
5388
|
-
// raw-import:/tmp/slz-publish-wt.
|
|
5388
|
+
// raw-import:/tmp/slz-publish-wt.AbcjgE/packages/shared/hooks/src/opencode-plugin.js
|
|
5389
5389
|
var opencode_plugin_default;
|
|
5390
5390
|
var init_opencode_plugin = __esm({
|
|
5391
|
-
"raw-import:/tmp/slz-publish-wt.
|
|
5391
|
+
"raw-import:/tmp/slz-publish-wt.AbcjgE/packages/shared/hooks/src/opencode-plugin.js"() {
|
|
5392
5392
|
opencode_plugin_default = "// SlayZone opencode plugin v1\n//\n// Forwards OpenCode SDK session lifecycle events to the SlayZone agent-hook\n// notify script over a local shell exec. Plugin is loaded by OpenCode from\n// ${XDG_CONFIG_HOME:-~/.config}/opencode/plugin/slayzone-notify.js\n//\n// The {{NOTIFY_PATH}} placeholder is substituted by the SlayZone installer\n// (packages/apps/app/src/main/agent-hooks/opencode-plugin-installer.ts) at\n// install time with the absolute path to `~/.slayzone/hooks/notify.sh`.\n//\n// Behavior:\n// - No-op when SLAYZONE_TASK_ID is unset (plugin only fires inside SlayZone PTYs).\n// - Subagent (child session) events are suppressed \u2014 oh-my-opencode + similar\n// tools spawn many child sessions and would otherwise flap Start/Stop.\n// - On client.session.list() error, sessions are assumed CHILD (safer to\n// suppress than emit a false-positive Start/Stop).\n// - Handles both modern (session.status w/ nested type) and legacy\n// (session.busy / session.idle) event shapes for forward compat.\n// - Singleton guard prevents double-load if OpenCode re-imports the plugin.\n\nexport const SlayzoneNotifyPlugin = async ({ $, client }) => {\n if (globalThis.__slayzoneOpencodePluginV1) return {}\n globalThis.__slayzoneOpencodePluginV1 = true\n if (!process?.env?.SLAYZONE_TASK_ID) return {}\n\n const notifyPath = '{{NOTIFY_PATH}}'\n let currentState = 'idle' // 'idle' | 'busy'\n let rootSessionID = null // first non-child session we see\n let stopSent = false // dedup Stop emits\n const childSessionCache = new Map() // sessionID -> isChild bool\n\n const notify = async (eventName) => {\n const payload = JSON.stringify({ hook_event_name: eventName })\n try {\n await $`bash ${notifyPath} ${payload}`\n } catch {\n // Hook failures must never bubble into the OpenCode TUI.\n }\n }\n\n const isChildSession = async (sessionID) => {\n if (!sessionID) return true\n if (!client?.session?.list) return true\n if (childSessionCache.has(sessionID)) return childSessionCache.get(sessionID)\n try {\n const sessions = await client.session.list()\n const session = sessions.data?.find((s) => s.id === sessionID)\n const isChild = !!session?.parentID\n childSessionCache.set(sessionID, isChild)\n return isChild\n } catch {\n // On error, assume CHILD \u2014 safer than emitting a false-positive Start/Stop.\n return true\n }\n }\n\n const handleBusy = async (sessionID) => {\n if (!rootSessionID) rootSessionID = sessionID\n if (sessionID !== rootSessionID) return\n if (currentState === 'idle') {\n currentState = 'busy'\n stopSent = false\n await notify('Start')\n }\n }\n\n const handleStop = async (sessionID) => {\n if (rootSessionID && sessionID !== rootSessionID) return\n if (currentState === 'busy' && !stopSent) {\n currentState = 'idle'\n stopSent = true\n await notify('Stop')\n rootSessionID = null // reset for next session\n }\n }\n\n return {\n event: async ({ event }) => {\n const sessionID = event.properties?.sessionID ?? event.properties?.info?.id ?? null\n\n if (event.type === 'session.created') {\n const isChild = Boolean(event.properties?.info?.parentID)\n if (sessionID) childSessionCache.set(sessionID, isChild)\n if (!isChild) await notify('SessionStart')\n return\n }\n\n if (event.type === 'session.deleted') {\n const cached = sessionID ? childSessionCache.get(sessionID) : undefined\n const isChild = cached !== undefined ? cached : await isChildSession(sessionID)\n if (!isChild) await notify('SessionEnd')\n if (sessionID) childSessionCache.delete(sessionID)\n return\n }\n\n if (await isChildSession(sessionID)) return\n\n if (event.type === 'session.status') {\n const status = event.properties?.status\n if (status?.type === 'busy') await handleBusy(sessionID)\n else if (status?.type === 'idle') await handleStop(sessionID)\n }\n // Backwards-compat: some OpenCode versions emit busy/idle as top-level events.\n if (event.type === 'session.busy') await handleBusy(sessionID)\n if (event.type === 'session.idle') await handleStop(sessionID)\n if (event.type === 'session.error') await handleStop(sessionID)\n },\n 'permission.ask': async (_permission, output) => {\n if (output.status === 'ask') await notify('PermissionRequest')\n }\n }\n}\n";
|
|
5393
5393
|
}
|
|
5394
5394
|
});
|
|
@@ -5431,8 +5431,8 @@ var init_agent_hooks2 = __esm({
|
|
|
5431
5431
|
});
|
|
5432
5432
|
|
|
5433
5433
|
// src/bin.ts
|
|
5434
|
-
var
|
|
5435
|
-
var
|
|
5434
|
+
var import_node_os9 = require("node:os");
|
|
5435
|
+
var import_node_path15 = require("node:path");
|
|
5436
5436
|
|
|
5437
5437
|
// ../../shared/platform/src/config-prompt.ts
|
|
5438
5438
|
var import_promises = require("node:readline/promises");
|
|
@@ -5615,6 +5615,27 @@ function hubUrlFromAddr(addr, kind, path9 = "") {
|
|
|
5615
5615
|
const scheme = kind === "ws" ? secure ? "wss" : "ws" : secure ? "https" : "http";
|
|
5616
5616
|
return `${scheme}://${addr}${path9}`;
|
|
5617
5617
|
}
|
|
5618
|
+
function hubAddrFromUrl(url2) {
|
|
5619
|
+
let u;
|
|
5620
|
+
try {
|
|
5621
|
+
u = new URL(url2);
|
|
5622
|
+
} catch {
|
|
5623
|
+
return null;
|
|
5624
|
+
}
|
|
5625
|
+
if (!["ws:", "wss:", "http:", "https:"].includes(u.protocol)) return null;
|
|
5626
|
+
const kind = u.protocol === "ws:" || u.protocol === "wss:" ? "ws" : "http";
|
|
5627
|
+
if (u.username !== "" || u.password !== "" || !isBareAuthority(u.host)) return null;
|
|
5628
|
+
return new URL(hubUrlFromAddr(u.host, kind)).protocol === u.protocol ? u.host : null;
|
|
5629
|
+
}
|
|
5630
|
+
function isBareAuthority(addr) {
|
|
5631
|
+
if (addr === "" || /[/\s]/.test(addr) || addr.includes("://")) return false;
|
|
5632
|
+
try {
|
|
5633
|
+
const u = new URL(`http://${addr}`);
|
|
5634
|
+
return u.host === addr && u.pathname === "/" && u.search === "" && u.hash === "" && u.username === "" && u.password === "";
|
|
5635
|
+
} catch {
|
|
5636
|
+
return false;
|
|
5637
|
+
}
|
|
5638
|
+
}
|
|
5618
5639
|
function isLoopbackComputerUrl(url2) {
|
|
5619
5640
|
let host;
|
|
5620
5641
|
try {
|
|
@@ -5758,13 +5779,13 @@ var DuplexRpc = class {
|
|
|
5758
5779
|
...params === void 0 ? {} : { params },
|
|
5759
5780
|
...actor === void 0 ? {} : { actor }
|
|
5760
5781
|
});
|
|
5761
|
-
return new Promise((
|
|
5782
|
+
return new Promise((resolve9, reject) => {
|
|
5762
5783
|
const timer = effectiveTimeout > 0 ? setTimeout(() => {
|
|
5763
5784
|
this.pending.delete(id);
|
|
5764
5785
|
reject(new RpcTimeoutError(method, effectiveTimeout, this.label));
|
|
5765
5786
|
}, effectiveTimeout) : null;
|
|
5766
5787
|
this.pending.set(id, {
|
|
5767
|
-
resolve:
|
|
5788
|
+
resolve: resolve9,
|
|
5768
5789
|
reject,
|
|
5769
5790
|
timer
|
|
5770
5791
|
});
|
|
@@ -6625,8 +6646,8 @@ function defineLazy(object2, key, getter) {
|
|
|
6625
6646
|
function objectClone(obj) {
|
|
6626
6647
|
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
|
6627
6648
|
}
|
|
6628
|
-
function assignProp(
|
|
6629
|
-
Object.defineProperty(
|
|
6649
|
+
function assignProp(target2, prop, value) {
|
|
6650
|
+
Object.defineProperty(target2, prop, {
|
|
6630
6651
|
value,
|
|
6631
6652
|
writable: true,
|
|
6632
6653
|
enumerable: true,
|
|
@@ -6640,8 +6661,8 @@ function rawShape(def) {
|
|
|
6640
6661
|
function sourceShape(schema) {
|
|
6641
6662
|
return rawShape(schema._zod.def) ?? schema._zod.def.shape;
|
|
6642
6663
|
}
|
|
6643
|
-
function deferProp(
|
|
6644
|
-
Object.defineProperty(
|
|
6664
|
+
function deferProp(target2, key, getter) {
|
|
6665
|
+
Object.defineProperty(target2, key, {
|
|
6645
6666
|
get() {
|
|
6646
6667
|
const value = getter();
|
|
6647
6668
|
assignProp(this, key, value);
|
|
@@ -6651,36 +6672,36 @@ function deferProp(target, key, getter) {
|
|
|
6651
6672
|
configurable: true
|
|
6652
6673
|
});
|
|
6653
6674
|
}
|
|
6654
|
-
function putProp(
|
|
6655
|
-
if (key in
|
|
6656
|
-
assignProp(
|
|
6675
|
+
function putProp(target2, key, value) {
|
|
6676
|
+
if (key in target2)
|
|
6677
|
+
assignProp(target2, key, value);
|
|
6657
6678
|
else
|
|
6658
|
-
|
|
6679
|
+
target2[key] = value;
|
|
6659
6680
|
}
|
|
6660
|
-
function mirrorShape(
|
|
6681
|
+
function mirrorShape(target2, source, keys, wrap) {
|
|
6661
6682
|
const raw = sourceShape(source);
|
|
6662
6683
|
for (const key of keys) {
|
|
6663
6684
|
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
6664
6685
|
if (!desc.enumerable)
|
|
6665
6686
|
continue;
|
|
6666
6687
|
if (desc.get) {
|
|
6667
|
-
deferProp(
|
|
6688
|
+
deferProp(target2, key, () => {
|
|
6668
6689
|
const value = source._zod.def.shape[key];
|
|
6669
6690
|
return wrap ? wrap(value, key) : value;
|
|
6670
6691
|
});
|
|
6671
6692
|
} else
|
|
6672
|
-
putProp(
|
|
6693
|
+
putProp(target2, key, wrap ? wrap(desc.value, key) : desc.value);
|
|
6673
6694
|
}
|
|
6674
6695
|
}
|
|
6675
|
-
function mirrorProps(
|
|
6696
|
+
function mirrorProps(target2, source) {
|
|
6676
6697
|
for (const key of Reflect.ownKeys(source)) {
|
|
6677
6698
|
const desc = Object.getOwnPropertyDescriptor(source, key);
|
|
6678
6699
|
if (!desc.enumerable)
|
|
6679
6700
|
continue;
|
|
6680
6701
|
if (desc.get)
|
|
6681
|
-
deferProp(
|
|
6702
|
+
deferProp(target2, key, () => source[key]);
|
|
6682
6703
|
else
|
|
6683
|
-
putProp(
|
|
6704
|
+
putProp(target2, key, desc.value);
|
|
6684
6705
|
}
|
|
6685
6706
|
}
|
|
6686
6707
|
function mergeDefs(...defs) {
|
|
@@ -6712,14 +6733,14 @@ function promiseAllObject(promisesObj) {
|
|
|
6712
6733
|
}
|
|
6713
6734
|
function randomString(length = 10) {
|
|
6714
6735
|
const chars = "abcdefghijklmnopqrstuvwxyz";
|
|
6715
|
-
let
|
|
6736
|
+
let str2 = "";
|
|
6716
6737
|
for (let i = 0; i < length; i++) {
|
|
6717
|
-
|
|
6738
|
+
str2 += chars[Math.floor(Math.random() * chars.length)];
|
|
6718
6739
|
}
|
|
6719
|
-
return
|
|
6740
|
+
return str2;
|
|
6720
6741
|
}
|
|
6721
|
-
function esc(
|
|
6722
|
-
return JSON.stringify(
|
|
6742
|
+
function esc(str2) {
|
|
6743
|
+
return JSON.stringify(str2);
|
|
6723
6744
|
}
|
|
6724
6745
|
function slugify(input2) {
|
|
6725
6746
|
return input2.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -6781,8 +6802,8 @@ function numKeys(data) {
|
|
|
6781
6802
|
return keyCount;
|
|
6782
6803
|
}
|
|
6783
6804
|
var getParsedType = (data) => {
|
|
6784
|
-
const
|
|
6785
|
-
switch (
|
|
6805
|
+
const t2 = typeof data;
|
|
6806
|
+
switch (t2) {
|
|
6786
6807
|
case "undefined":
|
|
6787
6808
|
return "undefined";
|
|
6788
6809
|
case "string":
|
|
@@ -6821,7 +6842,7 @@ var getParsedType = (data) => {
|
|
|
6821
6842
|
}
|
|
6822
6843
|
return "object";
|
|
6823
6844
|
default:
|
|
6824
|
-
throw new Error(`Unknown data type: ${
|
|
6845
|
+
throw new Error(`Unknown data type: ${t2}`);
|
|
6825
6846
|
}
|
|
6826
6847
|
};
|
|
6827
6848
|
var propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
|
|
@@ -6833,8 +6854,8 @@ var primitiveTypes = /* @__PURE__ */ new Set([
|
|
|
6833
6854
|
"symbol",
|
|
6834
6855
|
"undefined"
|
|
6835
6856
|
]);
|
|
6836
|
-
function escapeRegex(
|
|
6837
|
-
return
|
|
6857
|
+
function escapeRegex(str2) {
|
|
6858
|
+
return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6838
6859
|
}
|
|
6839
6860
|
function clone(inst, def, params) {
|
|
6840
6861
|
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
@@ -6859,35 +6880,35 @@ function normalizeParams(_params) {
|
|
|
6859
6880
|
return params;
|
|
6860
6881
|
}
|
|
6861
6882
|
function createTransparentProxy(getter) {
|
|
6862
|
-
let
|
|
6883
|
+
let target2;
|
|
6863
6884
|
return new Proxy({}, {
|
|
6864
6885
|
get(_, prop, receiver) {
|
|
6865
|
-
|
|
6866
|
-
return Reflect.get(
|
|
6886
|
+
target2 ?? (target2 = getter());
|
|
6887
|
+
return Reflect.get(target2, prop, receiver);
|
|
6867
6888
|
},
|
|
6868
6889
|
set(_, prop, value, receiver) {
|
|
6869
|
-
|
|
6870
|
-
return Reflect.set(
|
|
6890
|
+
target2 ?? (target2 = getter());
|
|
6891
|
+
return Reflect.set(target2, prop, value, receiver);
|
|
6871
6892
|
},
|
|
6872
6893
|
has(_, prop) {
|
|
6873
|
-
|
|
6874
|
-
return Reflect.has(
|
|
6894
|
+
target2 ?? (target2 = getter());
|
|
6895
|
+
return Reflect.has(target2, prop);
|
|
6875
6896
|
},
|
|
6876
6897
|
deleteProperty(_, prop) {
|
|
6877
|
-
|
|
6878
|
-
return Reflect.deleteProperty(
|
|
6898
|
+
target2 ?? (target2 = getter());
|
|
6899
|
+
return Reflect.deleteProperty(target2, prop);
|
|
6879
6900
|
},
|
|
6880
6901
|
ownKeys(_) {
|
|
6881
|
-
|
|
6882
|
-
return Reflect.ownKeys(
|
|
6902
|
+
target2 ?? (target2 = getter());
|
|
6903
|
+
return Reflect.ownKeys(target2);
|
|
6883
6904
|
},
|
|
6884
6905
|
getOwnPropertyDescriptor(_, prop) {
|
|
6885
|
-
|
|
6886
|
-
return Reflect.getOwnPropertyDescriptor(
|
|
6906
|
+
target2 ?? (target2 = getter());
|
|
6907
|
+
return Reflect.getOwnPropertyDescriptor(target2, prop);
|
|
6887
6908
|
},
|
|
6888
6909
|
defineProperty(_, prop, descriptor) {
|
|
6889
|
-
|
|
6890
|
-
return Reflect.defineProperty(
|
|
6910
|
+
target2 ?? (target2 = getter());
|
|
6911
|
+
return Reflect.defineProperty(target2, prop, descriptor);
|
|
6891
6912
|
}
|
|
6892
6913
|
});
|
|
6893
6914
|
}
|
|
@@ -7088,13 +7109,13 @@ function getSizableOrigin(input2) {
|
|
|
7088
7109
|
return "unknown";
|
|
7089
7110
|
}
|
|
7090
7111
|
var highSurrogate = /[\uD800-\uDBFF]/;
|
|
7091
|
-
function codePointLength(
|
|
7092
|
-
const units =
|
|
7093
|
-
if (!highSurrogate.test(
|
|
7112
|
+
function codePointLength(str2) {
|
|
7113
|
+
const units = str2.length;
|
|
7114
|
+
if (!highSurrogate.test(str2))
|
|
7094
7115
|
return units;
|
|
7095
7116
|
let count = units;
|
|
7096
7117
|
for (let i = 0; i < units - 1; i++) {
|
|
7097
|
-
if ((
|
|
7118
|
+
if ((str2.charCodeAt(i) & 64512) === 55296 && (str2.charCodeAt(i + 1) & 64512) === 56320) {
|
|
7098
7119
|
count--;
|
|
7099
7120
|
i++;
|
|
7100
7121
|
}
|
|
@@ -7109,8 +7130,8 @@ function getLengthableOrigin(input2) {
|
|
|
7109
7130
|
return "unknown";
|
|
7110
7131
|
}
|
|
7111
7132
|
function parsedType(data) {
|
|
7112
|
-
const
|
|
7113
|
-
switch (
|
|
7133
|
+
const t2 = typeof data;
|
|
7134
|
+
switch (t2) {
|
|
7114
7135
|
case "number": {
|
|
7115
7136
|
return Number.isNaN(data) ? "nan" : "number";
|
|
7116
7137
|
}
|
|
@@ -7127,7 +7148,7 @@ function parsedType(data) {
|
|
|
7127
7148
|
}
|
|
7128
7149
|
}
|
|
7129
7150
|
}
|
|
7130
|
-
return
|
|
7151
|
+
return t2;
|
|
7131
7152
|
}
|
|
7132
7153
|
function issue(...args) {
|
|
7133
7154
|
const [iss, input2, inst] = args;
|
|
@@ -7358,10 +7379,10 @@ function $constructor(name, initializer3, proto, params) {
|
|
|
7358
7379
|
let up = own2;
|
|
7359
7380
|
while (up && up !== ctorProto)
|
|
7360
7381
|
up = Object.getPrototypeOf(up);
|
|
7361
|
-
const
|
|
7362
|
-
if (!initialized.has(
|
|
7363
|
-
initialized.add(
|
|
7364
|
-
members(
|
|
7382
|
+
const target2 = up ?? own2;
|
|
7383
|
+
if (!initialized.has(target2)) {
|
|
7384
|
+
initialized.add(target2);
|
|
7385
|
+
members(target2, protoMembers);
|
|
7365
7386
|
}
|
|
7366
7387
|
}
|
|
7367
7388
|
const proto2 = _.prototype;
|
|
@@ -7723,18 +7744,18 @@ var validateAsync = async (schema, value, _ctx) => {
|
|
|
7723
7744
|
return result.issues.length === 0;
|
|
7724
7745
|
};
|
|
7725
7746
|
var _encode = (_Err) => {
|
|
7726
|
-
const
|
|
7747
|
+
const parse5 = _parse(_Err);
|
|
7727
7748
|
const fn = (schema, value, _ctx, _params) => {
|
|
7728
7749
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
7729
|
-
return
|
|
7750
|
+
return parse5(schema, value, ctx, finalizeParams(fn, _params));
|
|
7730
7751
|
};
|
|
7731
7752
|
return fn;
|
|
7732
7753
|
};
|
|
7733
7754
|
var encode = /* @__PURE__ */ _encode($ZodRealError);
|
|
7734
7755
|
var _decode = (_Err) => {
|
|
7735
|
-
const
|
|
7756
|
+
const parse5 = _parse(_Err);
|
|
7736
7757
|
const fn = (schema, value, _ctx, _params) => {
|
|
7737
|
-
return
|
|
7758
|
+
return parse5(schema, value, _ctx, finalizeParams(fn, _params));
|
|
7738
7759
|
};
|
|
7739
7760
|
return fn;
|
|
7740
7761
|
};
|
|
@@ -9210,15 +9231,15 @@ var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
|
|
|
9210
9231
|
}
|
|
9211
9232
|
}
|
|
9212
9233
|
const input2 = payload.value;
|
|
9213
|
-
const
|
|
9214
|
-
const isValidDate =
|
|
9234
|
+
const isDate2 = input2 instanceof Date;
|
|
9235
|
+
const isValidDate = isDate2 && !Number.isNaN(input2.getTime());
|
|
9215
9236
|
if (isValidDate)
|
|
9216
9237
|
return payload;
|
|
9217
9238
|
payload.issues.push({
|
|
9218
9239
|
expected: "date",
|
|
9219
9240
|
code: "invalid_type",
|
|
9220
9241
|
input: input2,
|
|
9221
|
-
...
|
|
9242
|
+
...isDate2 ? { received: "Invalid Date" } : {},
|
|
9222
9243
|
inst
|
|
9223
9244
|
});
|
|
9224
9245
|
return payload;
|
|
@@ -9325,7 +9346,7 @@ function handleCatchall(proms, input2, payload, ctx, def, inst, abortEarly) {
|
|
|
9325
9346
|
const unrecognized = [];
|
|
9326
9347
|
const keySet = def.keySet;
|
|
9327
9348
|
const _catchall = def.catchall._zod;
|
|
9328
|
-
const
|
|
9349
|
+
const t2 = _catchall.def.type;
|
|
9329
9350
|
const optin = _catchall.optin;
|
|
9330
9351
|
const optout = _catchall.optout;
|
|
9331
9352
|
let seen = 0;
|
|
@@ -9338,11 +9359,11 @@ function handleCatchall(proms, input2, payload, ctx, def, inst, abortEarly) {
|
|
|
9338
9359
|
if (keySet.has(key))
|
|
9339
9360
|
continue;
|
|
9340
9361
|
if (key === "__proto__") {
|
|
9341
|
-
if (
|
|
9362
|
+
if (t2 === "never")
|
|
9342
9363
|
unrecognized.push(key);
|
|
9343
9364
|
continue;
|
|
9344
9365
|
}
|
|
9345
|
-
if (
|
|
9366
|
+
if (t2 === "never") {
|
|
9346
9367
|
unrecognized.push(key);
|
|
9347
9368
|
continue;
|
|
9348
9369
|
}
|
|
@@ -9401,7 +9422,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
9401
9422
|
}
|
|
9402
9423
|
return propValues;
|
|
9403
9424
|
});
|
|
9404
|
-
const
|
|
9425
|
+
const isObject3 = isObject;
|
|
9405
9426
|
const catchall = def.catchall;
|
|
9406
9427
|
let value;
|
|
9407
9428
|
const memo2 = globalConfig.memoizer;
|
|
@@ -9409,7 +9430,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
9409
9430
|
inst._zod.parse = (payload, ctx) => {
|
|
9410
9431
|
value ?? (value = _normalized.value);
|
|
9411
9432
|
const input2 = payload.value;
|
|
9412
|
-
if (!
|
|
9433
|
+
if (!isObject3(input2)) {
|
|
9413
9434
|
payload.issues.push({
|
|
9414
9435
|
expected: "object",
|
|
9415
9436
|
code: "invalid_type",
|
|
@@ -9545,7 +9566,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
9545
9566
|
return doc.compile();
|
|
9546
9567
|
};
|
|
9547
9568
|
let fastpass;
|
|
9548
|
-
const
|
|
9569
|
+
const isObject3 = isObject;
|
|
9549
9570
|
const jit = !globalConfig.jitless;
|
|
9550
9571
|
const allowsEval2 = allowsEval;
|
|
9551
9572
|
const fastEnabled = jit && allowsEval2.value;
|
|
@@ -9554,7 +9575,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
9554
9575
|
inst._zod.parse = (payload, ctx) => {
|
|
9555
9576
|
value ?? (value = _normalized.value);
|
|
9556
9577
|
const input2 = payload.value;
|
|
9557
|
-
if (!
|
|
9578
|
+
if (!isObject3(input2)) {
|
|
9558
9579
|
payload.issues.push({
|
|
9559
9580
|
expected: "object",
|
|
9560
9581
|
code: "invalid_type",
|
|
@@ -10904,7 +10925,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
10904
10925
|
var NONE = 0;
|
|
10905
10926
|
var ASSUMED = 1;
|
|
10906
10927
|
var PROVEN = 2;
|
|
10907
|
-
function isRecursive(inst, stack,
|
|
10928
|
+
function isRecursive(inst, stack, resolve9) {
|
|
10908
10929
|
const cached2 = recursive.get(inst);
|
|
10909
10930
|
if (cached2 !== void 0)
|
|
10910
10931
|
return cached2 ? PROVEN : NONE;
|
|
@@ -10914,7 +10935,7 @@ function isRecursive(inst, stack, resolve7) {
|
|
|
10914
10935
|
let result = NONE;
|
|
10915
10936
|
const check2 = (child) => {
|
|
10916
10937
|
if (result !== PROVEN && child?._zod) {
|
|
10917
|
-
const answer = isRecursive(child, stack,
|
|
10938
|
+
const answer = isRecursive(child, stack, resolve9);
|
|
10918
10939
|
if (answer > result)
|
|
10919
10940
|
result = answer;
|
|
10920
10941
|
}
|
|
@@ -10925,7 +10946,7 @@ function isRecursive(inst, stack, resolve7) {
|
|
|
10925
10946
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
10926
10947
|
if (spread && !desc.enumerable)
|
|
10927
10948
|
continue;
|
|
10928
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
10949
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve9) : NONE;
|
|
10929
10950
|
if (child > answer)
|
|
10930
10951
|
answer = child;
|
|
10931
10952
|
}
|
|
@@ -10989,7 +11010,7 @@ function isRecursive(inst, stack, resolve7) {
|
|
|
10989
11010
|
break;
|
|
10990
11011
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
10991
11012
|
case "lazy": {
|
|
10992
|
-
const inner = def._cachedInner ?? (
|
|
11013
|
+
const inner = def._cachedInner ?? (resolve9 ? inst._zod.innerType : void 0);
|
|
10993
11014
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
10994
11015
|
break;
|
|
10995
11016
|
}
|
|
@@ -13576,16 +13597,16 @@ var error20 = () => {
|
|
|
13576
13597
|
number: { unit: "", shortLabel: "\u05E7\u05D8\u05DF", longLabel: "\u05D2\u05D3\u05D5\u05DC" }
|
|
13577
13598
|
// no unit
|
|
13578
13599
|
};
|
|
13579
|
-
const typeEntry = (
|
|
13580
|
-
const typeLabel = (
|
|
13581
|
-
const e = typeEntry(
|
|
13600
|
+
const typeEntry = (t2) => t2 ? TypeNames[t2] : void 0;
|
|
13601
|
+
const typeLabel = (t2) => {
|
|
13602
|
+
const e = typeEntry(t2);
|
|
13582
13603
|
if (e)
|
|
13583
13604
|
return e.label;
|
|
13584
|
-
return
|
|
13605
|
+
return t2 ?? TypeNames.unknown.label;
|
|
13585
13606
|
};
|
|
13586
|
-
const withDefinite = (
|
|
13587
|
-
const verbFor = (
|
|
13588
|
-
const e = typeEntry(
|
|
13607
|
+
const withDefinite = (t2) => `\u05D4${typeLabel(t2)}`;
|
|
13608
|
+
const verbFor = (t2) => {
|
|
13609
|
+
const e = typeEntry(t2);
|
|
13589
13610
|
const gender = e?.gender ?? "m";
|
|
13590
13611
|
return gender === "f" ? "\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA" : "\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA";
|
|
13591
13612
|
};
|
|
@@ -18845,8 +18866,8 @@ function withParser(schema, parser) {
|
|
|
18845
18866
|
installCompiledUserMethods(clone2, schema, parser);
|
|
18846
18867
|
return clone2;
|
|
18847
18868
|
}
|
|
18848
|
-
function installCompiledUserMethods(
|
|
18849
|
-
const targetAny =
|
|
18869
|
+
function installCompiledUserMethods(target2, source, parser) {
|
|
18870
|
+
const targetAny = target2;
|
|
18850
18871
|
const sourceAny = source;
|
|
18851
18872
|
if (typeof sourceAny.safeParse === "function") {
|
|
18852
18873
|
const originalSafeParse = sourceAny.safeParse;
|
|
@@ -21007,12 +21028,12 @@ function _uppercase(params) {
|
|
|
21007
21028
|
});
|
|
21008
21029
|
}
|
|
21009
21030
|
// @__NO_SIDE_EFFECTS__
|
|
21010
|
-
function _includes(
|
|
21031
|
+
function _includes(includes2, params) {
|
|
21011
21032
|
return new $ZodCheckIncludes({
|
|
21012
21033
|
check: "string_format",
|
|
21013
21034
|
format: "includes",
|
|
21014
21035
|
...normalizeParams(params),
|
|
21015
|
-
includes
|
|
21036
|
+
includes: includes2
|
|
21016
21037
|
});
|
|
21017
21038
|
}
|
|
21018
21039
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -21441,26 +21462,26 @@ function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
|
|
|
21441
21462
|
}
|
|
21442
21463
|
|
|
21443
21464
|
// ../../../node_modules/zod/v4/core/to-json-schema.js
|
|
21444
|
-
function assignProps(
|
|
21465
|
+
function assignProps(target2, ...sources) {
|
|
21445
21466
|
for (const source of sources) {
|
|
21446
21467
|
for (const key of Reflect.ownKeys(source)) {
|
|
21447
21468
|
if (Object.prototype.propertyIsEnumerable.call(source, key)) {
|
|
21448
|
-
assignProp(
|
|
21469
|
+
assignProp(target2, key, source[key]);
|
|
21449
21470
|
}
|
|
21450
21471
|
}
|
|
21451
21472
|
}
|
|
21452
|
-
return
|
|
21473
|
+
return target2;
|
|
21453
21474
|
}
|
|
21454
21475
|
function initializeContext(params) {
|
|
21455
|
-
let
|
|
21456
|
-
if (
|
|
21457
|
-
|
|
21458
|
-
if (
|
|
21459
|
-
|
|
21476
|
+
let target2 = params?.target ?? "draft-2020-12";
|
|
21477
|
+
if (target2 === "draft-4")
|
|
21478
|
+
target2 = "draft-04";
|
|
21479
|
+
if (target2 === "draft-7")
|
|
21480
|
+
target2 = "draft-07";
|
|
21460
21481
|
return {
|
|
21461
21482
|
processors: params.processors ?? {},
|
|
21462
21483
|
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
21463
|
-
target,
|
|
21484
|
+
target: target2,
|
|
21464
21485
|
unrepresentable: params?.unrepresentable ?? "throw",
|
|
21465
21486
|
override: params?.override ?? (() => {
|
|
21466
21487
|
}),
|
|
@@ -21963,8 +21984,8 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
|
21963
21984
|
return finalize(ctx, schema);
|
|
21964
21985
|
};
|
|
21965
21986
|
var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
21966
|
-
const { libraryOptions, target } = params ?? {};
|
|
21967
|
-
const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
|
|
21987
|
+
const { libraryOptions, target: target2 } = params ?? {};
|
|
21988
|
+
const ctx = initializeContext({ ...libraryOptions ?? {}, target: target2, io, processors });
|
|
21968
21989
|
processSchema(schema, ctx);
|
|
21969
21990
|
extractDefs(ctx, schema);
|
|
21970
21991
|
return finalize(ctx, schema);
|
|
@@ -22458,7 +22479,7 @@ function stringifyKeyNames(bySchema, json2, visited) {
|
|
|
22458
22479
|
json2 = { ...json2, [keyword]: mapped };
|
|
22459
22480
|
}
|
|
22460
22481
|
const types = Array.isArray(json2.type) ? json2.type : [json2.type];
|
|
22461
|
-
const numericType = !types.includes("string") && types.some((
|
|
22482
|
+
const numericType = !types.includes("string") && types.some((t2) => t2 === "number" || t2 === "integer");
|
|
22462
22483
|
const values = json2.enum ?? (json2.const !== void 0 ? [json2.const] : void 0);
|
|
22463
22484
|
if (!numericType && !values?.some((v) => typeof v === "number"))
|
|
22464
22485
|
return json2;
|
|
@@ -23158,8 +23179,8 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
23158
23179
|
catch(params) {
|
|
23159
23180
|
return _catch2(this, params);
|
|
23160
23181
|
},
|
|
23161
|
-
pipe(
|
|
23162
|
-
return pipe(this,
|
|
23182
|
+
pipe(target2) {
|
|
23183
|
+
return pipe(this, target2);
|
|
23163
23184
|
},
|
|
23164
23185
|
readonly() {
|
|
23165
23186
|
return readonly(this);
|
|
@@ -24961,8 +24982,8 @@ function convertBaseSchema(schema, ctx) {
|
|
|
24961
24982
|
}
|
|
24962
24983
|
const type = schema.type;
|
|
24963
24984
|
if (Array.isArray(type)) {
|
|
24964
|
-
const typeSchemas = type.map((
|
|
24965
|
-
const typeSchema = { ...schema, type:
|
|
24985
|
+
const typeSchemas = type.map((t2) => {
|
|
24986
|
+
const typeSchema = { ...schema, type: t2 };
|
|
24966
24987
|
return convertBaseSchema(typeSchema, ctx);
|
|
24967
24988
|
});
|
|
24968
24989
|
if (typeSchemas.length === 0) {
|
|
@@ -26295,10 +26316,10 @@ var TypedEventEmitter = class {
|
|
|
26295
26316
|
}
|
|
26296
26317
|
/** Promise for the next occurrence of `event`. */
|
|
26297
26318
|
once(event) {
|
|
26298
|
-
return new Promise((
|
|
26319
|
+
return new Promise((resolve9) => {
|
|
26299
26320
|
const unsubscribe2 = this.on(event, (payload) => {
|
|
26300
26321
|
unsubscribe2();
|
|
26301
|
-
|
|
26322
|
+
resolve9(payload);
|
|
26302
26323
|
});
|
|
26303
26324
|
});
|
|
26304
26325
|
}
|
|
@@ -26504,7 +26525,7 @@ var HubDialer = class {
|
|
|
26504
26525
|
}
|
|
26505
26526
|
const conn = this.current;
|
|
26506
26527
|
if (conn) {
|
|
26507
|
-
const closed = new Promise((
|
|
26528
|
+
const closed = new Promise((resolve9) => conn.ws.once("close", () => resolve9()));
|
|
26508
26529
|
if (conn.ws.readyState === wrapper_default.OPEN) {
|
|
26509
26530
|
conn.ws.close(1e3, "computer-stop");
|
|
26510
26531
|
} else {
|
|
@@ -26931,8 +26952,8 @@ var ENV_VARS = {
|
|
|
26931
26952
|
// the normal way (see ignoredCertPinNotices).
|
|
26932
26953
|
};
|
|
26933
26954
|
var DEFAULT_CAPABILITIES = ["pty", "git", "fs", "proc"];
|
|
26934
|
-
function realpathBoundary(
|
|
26935
|
-
let current = (0, import_node_path3.resolve)(
|
|
26955
|
+
function realpathBoundary(target2) {
|
|
26956
|
+
let current = (0, import_node_path3.resolve)(target2);
|
|
26936
26957
|
const tail = [];
|
|
26937
26958
|
for (; ; ) {
|
|
26938
26959
|
try {
|
|
@@ -26941,7 +26962,7 @@ function realpathBoundary(target) {
|
|
|
26941
26962
|
} catch {
|
|
26942
26963
|
const parent = (0, import_node_path3.dirname)(current);
|
|
26943
26964
|
if (parent === current) {
|
|
26944
|
-
return (0, import_node_path3.resolve)(
|
|
26965
|
+
return (0, import_node_path3.resolve)(target2);
|
|
26945
26966
|
}
|
|
26946
26967
|
tail.push((0, import_node_path3.basename)(current));
|
|
26947
26968
|
current = parent;
|
|
@@ -27097,7 +27118,16 @@ var HUB_SWITCH_ENV = {
|
|
|
27097
27118
|
enablePassword: "SLAYZONE_HUB_ENABLE_PASSWORD",
|
|
27098
27119
|
enableSso: "SLAYZONE_HUB_ENABLE_SSO",
|
|
27099
27120
|
enableProcesses: "SLAYZONE_HUB_ENABLE_PROCESSES",
|
|
27100
|
-
enableIntegrations: "SLAYZONE_HUB_ENABLE_INTEGRATIONS"
|
|
27121
|
+
enableIntegrations: "SLAYZONE_HUB_ENABLE_INTEGRATIONS",
|
|
27122
|
+
enableTelemetry: "SLAYZONE_HUB_ENABLE_TELEMETRY"
|
|
27123
|
+
};
|
|
27124
|
+
var HUB_SWITCH_DEFAULTS = {
|
|
27125
|
+
requireLogin: false,
|
|
27126
|
+
enablePassword: true,
|
|
27127
|
+
enableSso: false,
|
|
27128
|
+
enableProcesses: true,
|
|
27129
|
+
enableIntegrations: true,
|
|
27130
|
+
enableTelemetry: true
|
|
27101
27131
|
};
|
|
27102
27132
|
var HUB_SSO_ENV = {
|
|
27103
27133
|
tenantId: "SLAYZONE_HUB_SSO_TENANT_ID",
|
|
@@ -27135,12 +27165,136 @@ var HUB_PROCESS_ENV = [
|
|
|
27135
27165
|
HUB_SESSION_RETENTION_DAYS_ENV,
|
|
27136
27166
|
HUB_CONVEX_ADDRESS_ENV
|
|
27137
27167
|
];
|
|
27168
|
+
var HubSwitchValueError = class extends Error {
|
|
27169
|
+
constructor(variable, value) {
|
|
27170
|
+
super(
|
|
27171
|
+
`[slayzone] ${variable} must be 0 or 1, got '${value}'. Switches take exactly 0 (off) or 1 (on) \u2014 not true/false/yes/no.`
|
|
27172
|
+
);
|
|
27173
|
+
this.variable = variable;
|
|
27174
|
+
this.value = value;
|
|
27175
|
+
this.name = "HubSwitchValueError";
|
|
27176
|
+
}
|
|
27177
|
+
variable;
|
|
27178
|
+
value;
|
|
27179
|
+
};
|
|
27180
|
+
function parseSwitchValue(variable, raw) {
|
|
27181
|
+
if (raw === void 0) return void 0;
|
|
27182
|
+
if (raw === "1") return true;
|
|
27183
|
+
if (raw === "0") return false;
|
|
27184
|
+
throw new HubSwitchValueError(variable, raw);
|
|
27185
|
+
}
|
|
27186
|
+
function resolveHubSwitches(env = process.env) {
|
|
27187
|
+
const out = { ...HUB_SWITCH_DEFAULTS };
|
|
27188
|
+
for (const key of Object.keys(HUB_SWITCH_ENV)) {
|
|
27189
|
+
const parsed = parseSwitchValue(HUB_SWITCH_ENV[key], env[HUB_SWITCH_ENV[key]]);
|
|
27190
|
+
if (parsed !== void 0) out[key] = parsed;
|
|
27191
|
+
}
|
|
27192
|
+
return out;
|
|
27193
|
+
}
|
|
27138
27194
|
|
|
27139
27195
|
// ../../shared/platform/src/security-log.ts
|
|
27140
27196
|
var import_node_async_hooks = require("node:async_hooks");
|
|
27197
|
+
|
|
27198
|
+
// ../../shared/platform/src/client-address.ts
|
|
27199
|
+
var adopted = /* @__PURE__ */ new WeakMap();
|
|
27200
|
+
function clientAddress(req) {
|
|
27201
|
+
if (!req) return null;
|
|
27202
|
+
const resolved = adopted.get(req);
|
|
27203
|
+
if (resolved) return resolved;
|
|
27204
|
+
const addr = req.socket?.remoteAddress;
|
|
27205
|
+
return typeof addr === "string" && addr ? addr : null;
|
|
27206
|
+
}
|
|
27207
|
+
|
|
27208
|
+
// ../../shared/platform/src/security-log.ts
|
|
27209
|
+
var SENSITIVE_KEY = /pass(word|wd|phrase)|token|secret|cookie|authori[sz]ation|api[-_]?key|private[-_]?key|credential|bearer|signature|prompt|content|body|payload|stdin|stdout|stderr|bytes|email|message|^(key|data|env|args|text|input|output)$/i;
|
|
27210
|
+
var MAX_STRING = 200;
|
|
27211
|
+
var MAX_DEPTH = 4;
|
|
27212
|
+
var MAX_ITEMS = 20;
|
|
27213
|
+
var MAX_KEYS = 30;
|
|
27141
27214
|
var LINE_SEPARATOR = String.fromCharCode(8232);
|
|
27142
27215
|
var PARAGRAPH_SEPARATOR = String.fromCharCode(8233);
|
|
27216
|
+
var clip = (s) => s.length > MAX_STRING ? `${s.slice(0, MAX_STRING)}\u2026` : s;
|
|
27217
|
+
var str = (v) => typeof v === "string" && v ? clip(v) : null;
|
|
27218
|
+
function clean(value, depth, seen) {
|
|
27219
|
+
if (value === null) return null;
|
|
27220
|
+
switch (typeof value) {
|
|
27221
|
+
case "string":
|
|
27222
|
+
return clip(value);
|
|
27223
|
+
case "number":
|
|
27224
|
+
return Number.isFinite(value) ? value : String(value);
|
|
27225
|
+
case "boolean":
|
|
27226
|
+
return value;
|
|
27227
|
+
case "bigint":
|
|
27228
|
+
return value.toString();
|
|
27229
|
+
case "object":
|
|
27230
|
+
break;
|
|
27231
|
+
default:
|
|
27232
|
+
return void 0;
|
|
27233
|
+
}
|
|
27234
|
+
const obj = value;
|
|
27235
|
+
if (seen.has(obj)) return "[circular]";
|
|
27236
|
+
if (depth >= MAX_DEPTH) return "[depth]";
|
|
27237
|
+
if (obj instanceof Date) return Number.isNaN(obj.getTime()) ? null : obj.toISOString();
|
|
27238
|
+
if (ArrayBuffer.isView(obj) || obj instanceof ArrayBuffer) return "[bytes]";
|
|
27239
|
+
seen.add(obj);
|
|
27240
|
+
if (Array.isArray(obj)) {
|
|
27241
|
+
const out2 = obj.slice(0, MAX_ITEMS).map((v) => clean(v, depth + 1, seen) ?? null);
|
|
27242
|
+
if (obj.length > MAX_ITEMS) out2.push(`\u2026${obj.length - MAX_ITEMS} more`);
|
|
27243
|
+
return out2;
|
|
27244
|
+
}
|
|
27245
|
+
const proto = Object.getPrototypeOf(obj);
|
|
27246
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
27247
|
+
return `[${obj.constructor?.name || "object"}]`;
|
|
27248
|
+
}
|
|
27249
|
+
const out = {};
|
|
27250
|
+
let kept = 0;
|
|
27251
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
27252
|
+
if (SENSITIVE_KEY.test(k)) continue;
|
|
27253
|
+
const c = clean(v, depth + 1, seen);
|
|
27254
|
+
if (c === void 0) continue;
|
|
27255
|
+
if (kept++ >= MAX_KEYS) break;
|
|
27256
|
+
out[k] = c;
|
|
27257
|
+
}
|
|
27258
|
+
return out;
|
|
27259
|
+
}
|
|
27260
|
+
var stdoutGuarded = false;
|
|
27261
|
+
var stdoutSink = (line) => {
|
|
27262
|
+
if (!stdoutGuarded) {
|
|
27263
|
+
stdoutGuarded = true;
|
|
27264
|
+
process.stdout.on("error", () => {
|
|
27265
|
+
});
|
|
27266
|
+
}
|
|
27267
|
+
process.stdout.write(`${line}
|
|
27268
|
+
`);
|
|
27269
|
+
};
|
|
27270
|
+
var sink = stdoutSink;
|
|
27143
27271
|
var contextStore = new import_node_async_hooks.AsyncLocalStorage();
|
|
27272
|
+
function runWithSecurityContext(ctx, fn) {
|
|
27273
|
+
return contextStore.run(ctx, fn);
|
|
27274
|
+
}
|
|
27275
|
+
var peerAddress = clientAddress;
|
|
27276
|
+
function securityEvent(input2) {
|
|
27277
|
+
try {
|
|
27278
|
+
const ctx = contextStore.getStore();
|
|
27279
|
+
const route = input2.route === void 0 ? ctx?.route ?? null : input2.route;
|
|
27280
|
+
const detail = input2.detail ? clean(input2.detail, 0, /* @__PURE__ */ new WeakSet()) : {};
|
|
27281
|
+
const line = JSON.stringify({
|
|
27282
|
+
type: "security",
|
|
27283
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
27284
|
+
level: input2.level ?? (input2.outcome === "success" ? "info" : "warn"),
|
|
27285
|
+
event: input2.event,
|
|
27286
|
+
outcome: input2.outcome,
|
|
27287
|
+
actor: str(input2.actor === void 0 ? ctx?.actor : input2.actor),
|
|
27288
|
+
ip: str(input2.ip === void 0 ? ctx?.ip : input2.ip),
|
|
27289
|
+
targetKind: str(input2.targetKind),
|
|
27290
|
+
targetId: str(input2.targetId),
|
|
27291
|
+
route: typeof route === "string" ? str(route.split("?")[0]) : null,
|
|
27292
|
+
detail: detail && typeof detail === "object" && !Array.isArray(detail) ? detail : {}
|
|
27293
|
+
}).replaceAll(LINE_SEPARATOR, "\\u2028").replaceAll(PARAGRAPH_SEPARATOR, "\\u2029");
|
|
27294
|
+
sink(line);
|
|
27295
|
+
} catch {
|
|
27296
|
+
}
|
|
27297
|
+
}
|
|
27144
27298
|
|
|
27145
27299
|
// ../../shared/platform/src/hub-switch-refusal.ts
|
|
27146
27300
|
var MESSAGES = {
|
|
@@ -27149,7 +27303,8 @@ var MESSAGES = {
|
|
|
27149
27303
|
NO_COMPUTER_CONNECTED: `Connect a computer: this hub does not read project files or run git, gh or other commands itself (${HUB_SWITCH_ENV.enableProcesses}=0).`,
|
|
27150
27304
|
HUB_PASSWORD_DISABLED: `Password sign-in is switched off on this hub (${HUB_SWITCH_ENV.enablePassword}=0).`,
|
|
27151
27305
|
HUB_CONVEX_NOT_CONFIGURED: `GitHub sign-in is off on this hub: no Convex deployment is configured (${HUB_CONVEX_ADDRESS_ENV}).`,
|
|
27152
|
-
HUB_CONVEX_MISMATCH: `This hub starts GitHub sign-in only against its own Convex deployment (${HUB_CONVEX_ADDRESS_ENV}); the request named another
|
|
27306
|
+
HUB_CONVEX_MISMATCH: `This hub starts GitHub sign-in only against its own Convex deployment (${HUB_CONVEX_ADDRESS_ENV}); the request named another.`,
|
|
27307
|
+
HUB_TELEMETRY_DISABLED: `GitHub sign-in (leaderboard, feedback) is off on this hub: third-party telemetry is switched off (${HUB_SWITCH_ENV.enableTelemetry}=0).`
|
|
27153
27308
|
};
|
|
27154
27309
|
var VARIABLES = {
|
|
27155
27310
|
HUB_PROCESSES_DISABLED: HUB_SWITCH_ENV.enableProcesses,
|
|
@@ -27157,8 +27312,41 @@ var VARIABLES = {
|
|
|
27157
27312
|
NO_COMPUTER_CONNECTED: HUB_SWITCH_ENV.enableProcesses,
|
|
27158
27313
|
HUB_PASSWORD_DISABLED: HUB_SWITCH_ENV.enablePassword,
|
|
27159
27314
|
HUB_CONVEX_NOT_CONFIGURED: HUB_CONVEX_ADDRESS_ENV,
|
|
27160
|
-
HUB_CONVEX_MISMATCH: HUB_CONVEX_ADDRESS_ENV
|
|
27315
|
+
HUB_CONVEX_MISMATCH: HUB_CONVEX_ADDRESS_ENV,
|
|
27316
|
+
HUB_TELEMETRY_DISABLED: HUB_SWITCH_ENV.enableTelemetry
|
|
27317
|
+
};
|
|
27318
|
+
var HubSwitchedOffError = class extends Error {
|
|
27319
|
+
constructor(code) {
|
|
27320
|
+
super(MESSAGES[code]);
|
|
27321
|
+
this.code = code;
|
|
27322
|
+
this.name = "HubSwitchedOffError";
|
|
27323
|
+
this.variable = VARIABLES[code];
|
|
27324
|
+
}
|
|
27325
|
+
code;
|
|
27326
|
+
/** The env var of the switch that is off. */
|
|
27327
|
+
variable;
|
|
27161
27328
|
};
|
|
27329
|
+
function isHubSwitchedOffError(err) {
|
|
27330
|
+
if (err instanceof HubSwitchedOffError) return true;
|
|
27331
|
+
if (!(err instanceof Error) || err.name !== "HubSwitchedOffError") return false;
|
|
27332
|
+
const code = err.code;
|
|
27333
|
+
return typeof code === "string" && code in MESSAGES;
|
|
27334
|
+
}
|
|
27335
|
+
function hubProcessesEnabled(env = process.env) {
|
|
27336
|
+
return resolveHubSwitches(env).enableProcesses;
|
|
27337
|
+
}
|
|
27338
|
+
function refuse(event, code, refusal) {
|
|
27339
|
+
securityEvent({
|
|
27340
|
+
event,
|
|
27341
|
+
outcome: "denied",
|
|
27342
|
+
targetKind: "hub",
|
|
27343
|
+
detail: { ...refusal.detail, op: refusal.op, code, variable: VARIABLES[code] }
|
|
27344
|
+
});
|
|
27345
|
+
throw new HubSwitchedOffError(code);
|
|
27346
|
+
}
|
|
27347
|
+
function assertHubLocalExecEnabled(refusal) {
|
|
27348
|
+
if (!hubProcessesEnabled()) refuse("hub.local_exec", "NO_COMPUTER_CONNECTED", refusal);
|
|
27349
|
+
}
|
|
27162
27350
|
|
|
27163
27351
|
// ../../shared/platform/src/env-manifest.ts
|
|
27164
27352
|
var ENV_MANIFEST = {
|
|
@@ -27213,6 +27401,7 @@ var ENV_MANIFEST = {
|
|
|
27213
27401
|
SLAYZONE_HUB_ENABLE_SSO: "infra",
|
|
27214
27402
|
SLAYZONE_HUB_ENABLE_PROCESSES: "infra",
|
|
27215
27403
|
SLAYZONE_HUB_ENABLE_INTEGRATIONS: "infra",
|
|
27404
|
+
SLAYZONE_HUB_ENABLE_TELEMETRY: "infra",
|
|
27216
27405
|
SLAYZONE_HUB_SSO_TENANT_ID: "infra",
|
|
27217
27406
|
SLAYZONE_HUB_SSO_CLIENT_ID: "infra",
|
|
27218
27407
|
// Paths to the Entra client certificate and its private key, and the MFA switch.
|
|
@@ -27253,6 +27442,10 @@ var ENV_MANIFEST = {
|
|
|
27253
27442
|
// computers with none spawned" contract test).
|
|
27254
27443
|
SLAYZONE_E2E_NO_COMPUTER: "infra",
|
|
27255
27444
|
SLAYZONE_E2E_INSTALL_HOOKS: "infra",
|
|
27445
|
+
// PLAYWRIGHT-only: the Convex deployment (host[:port], '' = off) the desktop app's
|
|
27446
|
+
// renderer + hub use instead of the build's (app main convex-deployment.ts). Infra:
|
|
27447
|
+
// a hub started from a task terminal must not inherit a spec's deployment.
|
|
27448
|
+
SLAYZONE_E2E_CONVEX_ADDRESS: "infra",
|
|
27256
27449
|
// Redirects the MACHINE-WIDE ~/.slayzone (hooks/, bin/) — the files shared by
|
|
27257
27450
|
// every SlayZone process on the box, which deliberately do NOT follow
|
|
27258
27451
|
// SLAYZONE_ROOT. Sandbox redirect for tests, same role as the per-provider
|
|
@@ -27435,12 +27628,12 @@ function mergePathLists(primary, secondary) {
|
|
|
27435
27628
|
return [...entries].join(import_node_path4.default.delimiter);
|
|
27436
27629
|
}
|
|
27437
27630
|
function runProbe(probe, env) {
|
|
27438
|
-
return new Promise((
|
|
27631
|
+
return new Promise((resolve9) => {
|
|
27439
27632
|
const child = (0, import_node_child_process2.execFile)(
|
|
27440
27633
|
probe.file,
|
|
27441
27634
|
probe.args,
|
|
27442
27635
|
{ encoding: "utf-8", timeout: LOGIN_SHELL_PATH_PROBE_TIMEOUT_MS, env },
|
|
27443
|
-
(err, stdout2) =>
|
|
27636
|
+
(err, stdout2) => resolve9(err ? null : parseLoginShellPathOutput(stdout2))
|
|
27444
27637
|
);
|
|
27445
27638
|
child.stdin?.end();
|
|
27446
27639
|
});
|
|
@@ -27471,8 +27664,8 @@ async function adoptLoginShellPath(opts = {}) {
|
|
|
27471
27664
|
}
|
|
27472
27665
|
|
|
27473
27666
|
// src/main.ts
|
|
27474
|
-
var
|
|
27475
|
-
var
|
|
27667
|
+
var import_node_fs11 = require("node:fs");
|
|
27668
|
+
var import_node_path14 = require("node:path");
|
|
27476
27669
|
|
|
27477
27670
|
// src/request-log.ts
|
|
27478
27671
|
var import_node_fs4 = require("node:fs");
|
|
@@ -27481,10 +27674,10 @@ var REQUEST_LOG_DIR_NAME = "request-log";
|
|
|
27481
27674
|
var REQUEST_LOG_FILE_NAME = "requests.log";
|
|
27482
27675
|
var DEFAULT_MAX_BYTES = 10 * 1024 * 1024;
|
|
27483
27676
|
var DEFAULT_KEEP = 9;
|
|
27484
|
-
var
|
|
27485
|
-
function
|
|
27677
|
+
var MAX_STRING2 = 300;
|
|
27678
|
+
function clip2(value) {
|
|
27486
27679
|
if (typeof value !== "string") return void 0;
|
|
27487
|
-
return value.length >
|
|
27680
|
+
return value.length > MAX_STRING2 ? `${value.slice(0, MAX_STRING2)}\u2026` : value;
|
|
27488
27681
|
}
|
|
27489
27682
|
function programName(command) {
|
|
27490
27683
|
if (typeof command !== "string") return void 0;
|
|
@@ -27529,7 +27722,7 @@ function summarizeTarget(method, params) {
|
|
|
27529
27722
|
const p = params;
|
|
27530
27723
|
const out = {};
|
|
27531
27724
|
for (const key of TARGET_KEYS) {
|
|
27532
|
-
const v =
|
|
27725
|
+
const v = clip2(p[key]);
|
|
27533
27726
|
if (v !== void 0) out[key] = v;
|
|
27534
27727
|
}
|
|
27535
27728
|
const program = programName(p.command);
|
|
@@ -27540,7 +27733,7 @@ function summarizeTarget(method, params) {
|
|
|
27540
27733
|
if (sub) out.subcommand = sub;
|
|
27541
27734
|
}
|
|
27542
27735
|
if (Array.isArray(p.roots)) {
|
|
27543
|
-
out.roots = p.roots.slice(0, 20).map(
|
|
27736
|
+
out.roots = p.roots.slice(0, 20).map(clip2).filter((r) => r !== void 0);
|
|
27544
27737
|
}
|
|
27545
27738
|
return out;
|
|
27546
27739
|
}
|
|
@@ -27586,7 +27779,7 @@ function createRequestLog(opts) {
|
|
|
27586
27779
|
target: summarizeTarget(entry.method, entry.params),
|
|
27587
27780
|
result: entry.result,
|
|
27588
27781
|
...entry.code !== void 0 ? { code: entry.code } : {},
|
|
27589
|
-
...entry.reason !== void 0 ? { reason:
|
|
27782
|
+
...entry.reason !== void 0 ? { reason: clip2(entry.reason) } : {}
|
|
27590
27783
|
})}
|
|
27591
27784
|
`;
|
|
27592
27785
|
if (size > 0 && size + Buffer.byteLength(line) > maxBytes) rotate();
|
|
@@ -27760,13 +27953,13 @@ function createAgentHookServer(ctx) {
|
|
|
27760
27953
|
if (!res.headersSent) res.writeHead(200, { "content-type": "application/json" }).end("{}");
|
|
27761
27954
|
});
|
|
27762
27955
|
});
|
|
27763
|
-
return new Promise((
|
|
27956
|
+
return new Promise((resolve9, reject) => {
|
|
27764
27957
|
server.on("error", reject);
|
|
27765
27958
|
server.listen(0, "127.0.0.1", () => {
|
|
27766
27959
|
const addr = server.address();
|
|
27767
27960
|
const port = typeof addr === "object" && addr ? addr.port : 0;
|
|
27768
27961
|
ctx.log("agent-hook loopback relay listening", { port });
|
|
27769
|
-
|
|
27962
|
+
resolve9({
|
|
27770
27963
|
url: `http://127.0.0.1:${port}${AGENT_HOOK_PATH}`,
|
|
27771
27964
|
close: () => new Promise((r) => {
|
|
27772
27965
|
server.close(() => r());
|
|
@@ -27777,10 +27970,10 @@ function createAgentHookServer(ctx) {
|
|
|
27777
27970
|
}
|
|
27778
27971
|
|
|
27779
27972
|
// src/handlers/fs.ts
|
|
27780
|
-
var
|
|
27781
|
-
var
|
|
27782
|
-
var
|
|
27783
|
-
var
|
|
27973
|
+
var import_node_fs7 = require("node:fs");
|
|
27974
|
+
var import_promises7 = require("node:fs/promises");
|
|
27975
|
+
var import_node_os6 = require("node:os");
|
|
27976
|
+
var import_node_path10 = require("node:path");
|
|
27784
27977
|
|
|
27785
27978
|
// ../../domains/file-editor/src/server/file-ops.ts
|
|
27786
27979
|
var fs3 = __toESM(require("node:fs"), 1);
|
|
@@ -27790,8 +27983,8 @@ var import_ignore = __toESM(require_ignore(), 1);
|
|
|
27790
27983
|
var ALWAYS_IGNORED = /* @__PURE__ */ new Set([".git", ".DS_Store"]);
|
|
27791
27984
|
var MAX_FILE_SIZE = 1 * 1024 * 1024;
|
|
27792
27985
|
var FORCE_MAX_FILE_SIZE = 10 * 1024 * 1024;
|
|
27793
|
-
function assertWithinRoot(root,
|
|
27794
|
-
const resolved = path4.resolve(root,
|
|
27986
|
+
function assertWithinRoot(root, target2) {
|
|
27987
|
+
const resolved = path4.resolve(root, target2);
|
|
27795
27988
|
if (!resolved.startsWith(path4.resolve(root) + path4.sep) && resolved !== path4.resolve(root)) {
|
|
27796
27989
|
throw new Error("Path traversal denied");
|
|
27797
27990
|
}
|
|
@@ -27862,12 +28055,12 @@ function readDir(rootPath, dirPath) {
|
|
|
27862
28055
|
}
|
|
27863
28056
|
function readFile3(rootPath, filePath, force) {
|
|
27864
28057
|
const abs = assertWithinRoot(rootPath, filePath);
|
|
27865
|
-
const
|
|
27866
|
-
if (
|
|
27867
|
-
return { content: null, tooLarge: true, sizeBytes:
|
|
28058
|
+
const stat3 = fs3.statSync(abs);
|
|
28059
|
+
if (stat3.size > FORCE_MAX_FILE_SIZE) {
|
|
28060
|
+
return { content: null, tooLarge: true, sizeBytes: stat3.size };
|
|
27868
28061
|
}
|
|
27869
|
-
if (!force &&
|
|
27870
|
-
return { content: null, tooLarge: true, sizeBytes:
|
|
28062
|
+
if (!force && stat3.size > MAX_FILE_SIZE) {
|
|
28063
|
+
return { content: null, tooLarge: true, sizeBytes: stat3.size };
|
|
27871
28064
|
}
|
|
27872
28065
|
return { content: fs3.readFileSync(abs, "utf-8") };
|
|
27873
28066
|
}
|
|
@@ -27954,14 +28147,14 @@ function gitStatus(rootPath) {
|
|
|
27954
28147
|
if (!fs3.existsSync(path4.join(root, ".git"))) {
|
|
27955
28148
|
return Promise.resolve({ files: {}, isGitRepo: false });
|
|
27956
28149
|
}
|
|
27957
|
-
return new Promise((
|
|
28150
|
+
return new Promise((resolve9) => {
|
|
27958
28151
|
const chunks = [];
|
|
27959
28152
|
const proc = (0, import_node_child_process3.spawn)("git", ["status", "--porcelain"], { cwd: root });
|
|
27960
28153
|
proc.stdout.on("data", (chunk) => chunks.push(chunk));
|
|
27961
|
-
proc.on("error", () =>
|
|
28154
|
+
proc.on("error", () => resolve9({ files: {}, isGitRepo: false }));
|
|
27962
28155
|
proc.on("close", (code) => {
|
|
27963
28156
|
if (code !== 0) {
|
|
27964
|
-
|
|
28157
|
+
resolve9({ files: {}, isGitRepo: true });
|
|
27965
28158
|
return;
|
|
27966
28159
|
}
|
|
27967
28160
|
const output2 = Buffer.concat(chunks).toString("utf-8");
|
|
@@ -27988,7 +28181,7 @@ function gitStatus(rootPath) {
|
|
|
27988
28181
|
}
|
|
27989
28182
|
files[filePath] = status;
|
|
27990
28183
|
}
|
|
27991
|
-
|
|
28184
|
+
resolve9({ files, isGitRepo: true });
|
|
27992
28185
|
});
|
|
27993
28186
|
});
|
|
27994
28187
|
}
|
|
@@ -28031,13 +28224,13 @@ function searchFiles(rootPath, query, options) {
|
|
|
28031
28224
|
function searchFile(rootDir, relPath, re, out) {
|
|
28032
28225
|
if (totalMatches >= maxResults) return;
|
|
28033
28226
|
const abs = path4.join(rootDir, relPath);
|
|
28034
|
-
let
|
|
28227
|
+
let stat3;
|
|
28035
28228
|
try {
|
|
28036
|
-
|
|
28229
|
+
stat3 = fs3.statSync(abs);
|
|
28037
28230
|
} catch {
|
|
28038
28231
|
return;
|
|
28039
28232
|
}
|
|
28040
|
-
if (
|
|
28233
|
+
if (stat3.size > MAX_FILE_SIZE) return;
|
|
28041
28234
|
let content;
|
|
28042
28235
|
try {
|
|
28043
28236
|
content = fs3.readFileSync(abs, "utf-8");
|
|
@@ -28125,7 +28318,7 @@ function unsubscribe(root, listener) {
|
|
|
28125
28318
|
entry.listeners.delete(listener);
|
|
28126
28319
|
if (entry.listeners.size === 0) {
|
|
28127
28320
|
entry.watcher.close();
|
|
28128
|
-
for (const
|
|
28321
|
+
for (const t2 of entry.debounceMap.values()) clearTimeout(t2);
|
|
28129
28322
|
watchers.delete(root);
|
|
28130
28323
|
}
|
|
28131
28324
|
}
|
|
@@ -28158,10 +28351,10 @@ var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
|
28158
28351
|
".vscode"
|
|
28159
28352
|
]);
|
|
28160
28353
|
function git(args, cwd) {
|
|
28161
|
-
return new Promise((
|
|
28354
|
+
return new Promise((resolve9, reject) => {
|
|
28162
28355
|
(0, import_node_child_process4.execFile)("git", args, { cwd, maxBuffer: 8 * 1024 * 1024 }, (err, stdout2) => {
|
|
28163
28356
|
if (err) reject(err);
|
|
28164
|
-
else
|
|
28357
|
+
else resolve9(stdout2);
|
|
28165
28358
|
});
|
|
28166
28359
|
});
|
|
28167
28360
|
}
|
|
@@ -28261,124 +28454,2335 @@ async function discoverRepos(rootPath, maxDepth = DEFAULT_REPO_SCAN_DEPTH) {
|
|
|
28261
28454
|
return entries;
|
|
28262
28455
|
}
|
|
28263
28456
|
|
|
28264
|
-
// src/
|
|
28457
|
+
// ../../domains/file-editor/src/server/workspace-fs.ts
|
|
28458
|
+
var import_node_fs6 = require("node:fs");
|
|
28459
|
+
var import_promises6 = require("node:fs/promises");
|
|
28460
|
+
var import_node_os5 = require("node:os");
|
|
28461
|
+
var import_node_path9 = require("node:path");
|
|
28265
28462
|
var BROWSE_ALWAYS_HIDDEN = /* @__PURE__ */ new Set([".git", ".DS_Store", "node_modules"]);
|
|
28266
|
-
|
|
28267
|
-
|
|
28268
|
-
|
|
28269
|
-
|
|
28270
|
-
|
|
28271
|
-
|
|
28272
|
-
};
|
|
28273
|
-
const
|
|
28274
|
-
|
|
28275
|
-
|
|
28276
|
-
|
|
28277
|
-
|
|
28278
|
-
}
|
|
28279
|
-
async function removeDir(rawParams) {
|
|
28280
|
-
const { path: path9 } = fsRemoveDirParamsSchema.parse(rawParams);
|
|
28281
|
-
const resolved = allow(path9, true);
|
|
28282
|
-
await (0, import_promises6.rm)(resolved, { recursive: true, force: true });
|
|
28283
|
-
ctx.log("fs removeDir", { path: resolved });
|
|
28284
|
-
return { ok: true };
|
|
28463
|
+
var WORKSPACE_MAX_LIST_ALL_FILES = 5e4;
|
|
28464
|
+
var WORKSPACE_MAX_SEARCH_RESULTS = 2e3;
|
|
28465
|
+
function createLocalWorkspaceFs() {
|
|
28466
|
+
return refuseOnSwitchedOffHub(createUnguardedLocalWorkspaceFs());
|
|
28467
|
+
}
|
|
28468
|
+
function refuseOnSwitchedOffHub(fs7) {
|
|
28469
|
+
const guarded = {};
|
|
28470
|
+
for (const [op, fn] of Object.entries(fs7)) {
|
|
28471
|
+
guarded[op] = (...args) => {
|
|
28472
|
+
assertHubLocalExecEnabled({ op: `fs.${op}` });
|
|
28473
|
+
return fn(...args);
|
|
28474
|
+
};
|
|
28285
28475
|
}
|
|
28286
|
-
|
|
28287
|
-
|
|
28288
|
-
|
|
28289
|
-
|
|
28476
|
+
return guarded;
|
|
28477
|
+
}
|
|
28478
|
+
function createUnguardedLocalWorkspaceFs() {
|
|
28479
|
+
const localProjectPaths = /* @__PURE__ */ new Map();
|
|
28480
|
+
return {
|
|
28481
|
+
listRoots() {
|
|
28482
|
+
let home = null;
|
|
28290
28483
|
try {
|
|
28291
|
-
|
|
28484
|
+
home = import_node_fs6.realpathSync.native((0, import_node_os5.homedir)());
|
|
28292
28485
|
} catch {
|
|
28486
|
+
home = null;
|
|
28293
28487
|
}
|
|
28294
|
-
|
|
28295
|
-
|
|
28296
|
-
|
|
28297
|
-
|
|
28298
|
-
|
|
28299
|
-
|
|
28300
|
-
}
|
|
28301
|
-
|
|
28302
|
-
|
|
28303
|
-
|
|
28304
|
-
|
|
28305
|
-
|
|
28306
|
-
|
|
28307
|
-
|
|
28308
|
-
|
|
28309
|
-
|
|
28310
|
-
|
|
28311
|
-
|
|
28312
|
-
|
|
28313
|
-
|
|
28314
|
-
|
|
28315
|
-
|
|
28316
|
-
|
|
28317
|
-
} catch {
|
|
28318
|
-
continue;
|
|
28488
|
+
return {
|
|
28489
|
+
roots: home ? [home] : [(0, import_node_path9.parse)(process.cwd()).root],
|
|
28490
|
+
home,
|
|
28491
|
+
platform: process.platform,
|
|
28492
|
+
sep: import_node_path9.sep
|
|
28493
|
+
};
|
|
28494
|
+
},
|
|
28495
|
+
async listDir(path9, options) {
|
|
28496
|
+
const abs = import_node_fs6.realpathSync.native((0, import_node_path9.resolve)(path9));
|
|
28497
|
+
const dirents = await (0, import_promises6.readdir)(abs, { withFileTypes: true });
|
|
28498
|
+
const entries = [];
|
|
28499
|
+
for (const e of dirents) {
|
|
28500
|
+
if (BROWSE_ALWAYS_HIDDEN.has(e.name)) continue;
|
|
28501
|
+
if (!options?.includeHidden && e.name.startsWith(".")) continue;
|
|
28502
|
+
const full = (0, import_node_path9.join)(abs, e.name);
|
|
28503
|
+
const symlink = e.isSymbolicLink();
|
|
28504
|
+
let isDir = e.isDirectory();
|
|
28505
|
+
if (symlink) {
|
|
28506
|
+
try {
|
|
28507
|
+
isDir = (await (0, import_promises6.stat)(full)).isDirectory();
|
|
28508
|
+
} catch {
|
|
28509
|
+
continue;
|
|
28510
|
+
}
|
|
28319
28511
|
}
|
|
28512
|
+
if (options?.dirsOnly && !isDir) continue;
|
|
28513
|
+
entries.push({
|
|
28514
|
+
name: e.name,
|
|
28515
|
+
path: full,
|
|
28516
|
+
type: isDir ? "directory" : "file",
|
|
28517
|
+
...symlink && { isSymlink: true },
|
|
28518
|
+
...isDir && (0, import_node_fs6.existsSync)((0, import_node_path9.join)(full, ".git")) && { isGitRepo: true }
|
|
28519
|
+
});
|
|
28320
28520
|
}
|
|
28321
|
-
|
|
28322
|
-
|
|
28323
|
-
|
|
28324
|
-
path: full,
|
|
28325
|
-
type: isDir ? "directory" : "file",
|
|
28326
|
-
...symlink && { isSymlink: true },
|
|
28327
|
-
...isDir && (0, import_node_fs6.existsSync)((0, import_node_path9.join)(full, ".git")) && { isGitRepo: true }
|
|
28521
|
+
entries.sort((a, b) => {
|
|
28522
|
+
if (a.type !== b.type) return a.type === "directory" ? -1 : 1;
|
|
28523
|
+
return a.name.localeCompare(b.name);
|
|
28328
28524
|
});
|
|
28525
|
+
const parent = (0, import_node_path9.dirname)(abs);
|
|
28526
|
+
return { path: abs, parent: parent === abs ? null : parent, entries };
|
|
28527
|
+
},
|
|
28528
|
+
async mkdir(path9) {
|
|
28529
|
+
const abs = (0, import_node_path9.resolve)(path9);
|
|
28530
|
+
await (0, import_promises6.mkdir)(abs, { recursive: true });
|
|
28531
|
+
return { path: import_node_fs6.realpathSync.native(abs) };
|
|
28532
|
+
},
|
|
28533
|
+
pathExists(path9) {
|
|
28534
|
+
return (0, import_node_fs6.existsSync)((0, import_node_path9.resolve)(path9));
|
|
28535
|
+
},
|
|
28536
|
+
// A hub has no path-jail — `allowedRoots` is a computer concept. Saying so is
|
|
28537
|
+
// better than accepting the edit and discarding it, which would leave the
|
|
28538
|
+
// user believing they had restricted (or widened) something.
|
|
28539
|
+
setAllowedRoots() {
|
|
28540
|
+
return Promise.reject(
|
|
28541
|
+
new Error("this host has no path jail to configure \u2014 allowedRoots is a computer setting")
|
|
28542
|
+
);
|
|
28543
|
+
},
|
|
28544
|
+
// With no computer there is exactly one machine, so this process keeps the map
|
|
28545
|
+
// itself. In-memory rather than on disk: the only hosts that reach here are
|
|
28546
|
+
// the fork sidecar and tests, neither of which should be minting a new
|
|
28547
|
+
// persistent state file for a mapping a real computer owns.
|
|
28548
|
+
resolveProjectPath(projectId) {
|
|
28549
|
+
const path9 = localProjectPaths.get(projectId);
|
|
28550
|
+
if (!path9) return { path: null };
|
|
28551
|
+
return { path: path9, exists: (0, import_node_fs6.existsSync)(path9) };
|
|
28552
|
+
},
|
|
28553
|
+
setProjectPath(projectId, path9) {
|
|
28554
|
+
const abs = import_node_fs6.realpathSync.native((0, import_node_path9.resolve)(path9));
|
|
28555
|
+
localProjectPaths.set(projectId, abs);
|
|
28556
|
+
return { path: abs };
|
|
28557
|
+
},
|
|
28558
|
+
forgetProjectPath(projectId) {
|
|
28559
|
+
localProjectPaths.delete(projectId);
|
|
28560
|
+
},
|
|
28561
|
+
readDir,
|
|
28562
|
+
readFile: readFile3,
|
|
28563
|
+
writeFile: writeFile3,
|
|
28564
|
+
createFile,
|
|
28565
|
+
createDir,
|
|
28566
|
+
rename: renamePath,
|
|
28567
|
+
delete: deletePath,
|
|
28568
|
+
copyIn,
|
|
28569
|
+
copy,
|
|
28570
|
+
gitStatus,
|
|
28571
|
+
searchFiles(rootPath, query, options) {
|
|
28572
|
+
const maxResults = Math.min(
|
|
28573
|
+
options?.maxResults ?? WORKSPACE_MAX_SEARCH_RESULTS,
|
|
28574
|
+
WORKSPACE_MAX_SEARCH_RESULTS
|
|
28575
|
+
);
|
|
28576
|
+
const results = searchFiles(rootPath, query, { ...options, maxResults });
|
|
28577
|
+
const total = results.reduce((n, r) => n + r.matches.length, 0);
|
|
28578
|
+
return { results, truncated: total >= maxResults };
|
|
28579
|
+
},
|
|
28580
|
+
listAllFiles(rootPath) {
|
|
28581
|
+
const all = listAllFiles(rootPath);
|
|
28582
|
+
return {
|
|
28583
|
+
files: all.slice(0, WORKSPACE_MAX_LIST_ALL_FILES),
|
|
28584
|
+
truncated: all.length > WORKSPACE_MAX_LIST_ALL_FILES
|
|
28585
|
+
};
|
|
28586
|
+
},
|
|
28587
|
+
watch: subscribeFileWatcher,
|
|
28588
|
+
discoverRepos
|
|
28589
|
+
};
|
|
28590
|
+
}
|
|
28591
|
+
function createLocalWorkspaceFsAdapters(local = createLocalWorkspaceFs()) {
|
|
28592
|
+
return {
|
|
28593
|
+
listRoots: async () => local.listRoots(),
|
|
28594
|
+
listDir: async (_r, path9, options) => local.listDir(path9, options),
|
|
28595
|
+
mkdir: async (_r, path9) => local.mkdir(path9),
|
|
28596
|
+
pathExists: async (_r, path9) => local.pathExists(path9),
|
|
28597
|
+
setAllowedRoots: async (_r, roots) => local.setAllowedRoots(roots),
|
|
28598
|
+
resolveProjectPath: async (_r, projectId) => local.resolveProjectPath(projectId),
|
|
28599
|
+
setProjectPath: async (_r, projectId, path9) => local.setProjectPath(projectId, path9),
|
|
28600
|
+
forgetProjectPath: async (_r, projectId) => local.forgetProjectPath(projectId),
|
|
28601
|
+
readDir: async (_r, rootPath, dirPath) => local.readDir(rootPath, dirPath),
|
|
28602
|
+
readFile: async (_r, rootPath, filePath, force) => local.readFile(rootPath, filePath, force),
|
|
28603
|
+
writeFile: async (_r, rootPath, filePath, content) => local.writeFile(rootPath, filePath, content),
|
|
28604
|
+
createFile: async (_r, rootPath, filePath) => local.createFile(rootPath, filePath),
|
|
28605
|
+
createDir: async (_r, rootPath, dirPath) => local.createDir(rootPath, dirPath),
|
|
28606
|
+
rename: async (_r, rootPath, oldPath, newPath) => local.rename(rootPath, oldPath, newPath),
|
|
28607
|
+
delete: async (_r, rootPath, targetPath) => local.delete(rootPath, targetPath),
|
|
28608
|
+
copyIn: async (_r, rootPath, absoluteSrc, targetDir) => local.copyIn(rootPath, absoluteSrc, targetDir),
|
|
28609
|
+
copy: async (_r, rootPath, srcPath, destPath) => local.copy(rootPath, srcPath, destPath),
|
|
28610
|
+
gitStatus: async (_r, rootPath) => local.gitStatus(rootPath),
|
|
28611
|
+
searchFiles: async (_r, rootPath, query, options) => local.searchFiles(rootPath, query, options),
|
|
28612
|
+
listAllFiles: async (_r, rootPath) => local.listAllFiles(rootPath),
|
|
28613
|
+
watch: (_r, rootPath, listener) => local.watch(rootPath, listener),
|
|
28614
|
+
discoverRepos: async (_r, rootPath, maxDepth) => local.discoverRepos(rootPath, maxDepth)
|
|
28615
|
+
};
|
|
28616
|
+
}
|
|
28617
|
+
|
|
28618
|
+
// ../../domains/file-editor/src/server/workspace-deps.ts
|
|
28619
|
+
var workspaceDeps = {
|
|
28620
|
+
fs: createLocalWorkspaceFsAdapters(),
|
|
28621
|
+
resolveComputer: async () => null,
|
|
28622
|
+
isLocalComputer: () => true
|
|
28623
|
+
};
|
|
28624
|
+
function getWorkspaceDeps() {
|
|
28625
|
+
return workspaceDeps;
|
|
28626
|
+
}
|
|
28627
|
+
|
|
28628
|
+
// ../../../node_modules/@trpc/server/dist/codes-D5Ya6_Bi.mjs
|
|
28629
|
+
function mergeWithoutOverrides(obj1, ...objs) {
|
|
28630
|
+
const newObj = Object.assign(emptyObject(), obj1);
|
|
28631
|
+
for (const overrides of objs) for (const key in overrides) {
|
|
28632
|
+
if (key in newObj && newObj[key] !== overrides[key]) throw new Error(`Duplicate key ${key}`);
|
|
28633
|
+
newObj[key] = overrides[key];
|
|
28634
|
+
}
|
|
28635
|
+
return newObj;
|
|
28636
|
+
}
|
|
28637
|
+
function isObject2(value) {
|
|
28638
|
+
return !!value && !Array.isArray(value) && typeof value === "object";
|
|
28639
|
+
}
|
|
28640
|
+
function isFunction(fn) {
|
|
28641
|
+
return typeof fn === "function";
|
|
28642
|
+
}
|
|
28643
|
+
function emptyObject() {
|
|
28644
|
+
return /* @__PURE__ */ Object.create(null);
|
|
28645
|
+
}
|
|
28646
|
+
var TRPC_ERROR_CODES_BY_KEY = {
|
|
28647
|
+
/**
|
|
28648
|
+
* Invalid JSON was received by the server.
|
|
28649
|
+
* An error occurred on the server while parsing the JSON text.
|
|
28650
|
+
*/
|
|
28651
|
+
PARSE_ERROR: -32700,
|
|
28652
|
+
/**
|
|
28653
|
+
* The JSON sent is not a valid Request object.
|
|
28654
|
+
*/
|
|
28655
|
+
BAD_REQUEST: -32600,
|
|
28656
|
+
INTERNAL_SERVER_ERROR: -32603,
|
|
28657
|
+
NOT_IMPLEMENTED: -32603,
|
|
28658
|
+
BAD_GATEWAY: -32603,
|
|
28659
|
+
SERVICE_UNAVAILABLE: -32603,
|
|
28660
|
+
GATEWAY_TIMEOUT: -32603,
|
|
28661
|
+
UNAUTHORIZED: -32001,
|
|
28662
|
+
PAYMENT_REQUIRED: -32002,
|
|
28663
|
+
FORBIDDEN: -32003,
|
|
28664
|
+
NOT_FOUND: -32004,
|
|
28665
|
+
METHOD_NOT_SUPPORTED: -32005,
|
|
28666
|
+
TIMEOUT: -32008,
|
|
28667
|
+
CONFLICT: -32009,
|
|
28668
|
+
PRECONDITION_FAILED: -32012,
|
|
28669
|
+
PAYLOAD_TOO_LARGE: -32013,
|
|
28670
|
+
UNSUPPORTED_MEDIA_TYPE: -32015,
|
|
28671
|
+
UNPROCESSABLE_CONTENT: -32022,
|
|
28672
|
+
PRECONDITION_REQUIRED: -32028,
|
|
28673
|
+
TOO_MANY_REQUESTS: -32029,
|
|
28674
|
+
CLIENT_CLOSED_REQUEST: -32099
|
|
28675
|
+
};
|
|
28676
|
+
var retryableRpcCodes = [
|
|
28677
|
+
TRPC_ERROR_CODES_BY_KEY.BAD_GATEWAY,
|
|
28678
|
+
TRPC_ERROR_CODES_BY_KEY.SERVICE_UNAVAILABLE,
|
|
28679
|
+
TRPC_ERROR_CODES_BY_KEY.GATEWAY_TIMEOUT,
|
|
28680
|
+
TRPC_ERROR_CODES_BY_KEY.INTERNAL_SERVER_ERROR
|
|
28681
|
+
];
|
|
28682
|
+
|
|
28683
|
+
// ../../../node_modules/@trpc/server/dist/getErrorShape-B0JBUs-i.mjs
|
|
28684
|
+
var noop = () => {
|
|
28685
|
+
};
|
|
28686
|
+
var freezeIfAvailable = (obj) => {
|
|
28687
|
+
if (Object.freeze) Object.freeze(obj);
|
|
28688
|
+
};
|
|
28689
|
+
function createInnerProxy(callback, path9, memo2) {
|
|
28690
|
+
var _memo$cacheKey;
|
|
28691
|
+
const cacheKey = path9.join(".");
|
|
28692
|
+
(_memo$cacheKey = memo2[cacheKey]) !== null && _memo$cacheKey !== void 0 || (memo2[cacheKey] = new Proxy(noop, {
|
|
28693
|
+
get(_obj, key) {
|
|
28694
|
+
if (typeof key !== "string" || key === "then") return;
|
|
28695
|
+
return createInnerProxy(callback, [...path9, key], memo2);
|
|
28696
|
+
},
|
|
28697
|
+
apply(_1, _2, args) {
|
|
28698
|
+
const lastOfPath = path9[path9.length - 1];
|
|
28699
|
+
if (lastOfPath === "valueOf" || lastOfPath === "toString" || lastOfPath === "toJSON") return `tRPC.proxy(${path9.slice(0, -1).join(".")})`;
|
|
28700
|
+
let opts = {
|
|
28701
|
+
args,
|
|
28702
|
+
path: path9
|
|
28703
|
+
};
|
|
28704
|
+
if (lastOfPath === "call") opts = {
|
|
28705
|
+
args: args.length >= 2 ? [args[1]] : [],
|
|
28706
|
+
path: path9.slice(0, -1)
|
|
28707
|
+
};
|
|
28708
|
+
else if (lastOfPath === "apply") opts = {
|
|
28709
|
+
args: args.length >= 2 ? args[1] : [],
|
|
28710
|
+
path: path9.slice(0, -1)
|
|
28711
|
+
};
|
|
28712
|
+
freezeIfAvailable(opts.args);
|
|
28713
|
+
freezeIfAvailable(opts.path);
|
|
28714
|
+
return callback(opts);
|
|
28329
28715
|
}
|
|
28330
|
-
|
|
28331
|
-
|
|
28332
|
-
|
|
28333
|
-
|
|
28334
|
-
|
|
28335
|
-
|
|
28336
|
-
|
|
28337
|
-
|
|
28338
|
-
|
|
28339
|
-
|
|
28716
|
+
}));
|
|
28717
|
+
return memo2[cacheKey];
|
|
28718
|
+
}
|
|
28719
|
+
var createRecursiveProxy = (callback) => createInnerProxy(callback, [], emptyObject());
|
|
28720
|
+
function _typeof(o) {
|
|
28721
|
+
"@babel/helpers - typeof";
|
|
28722
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
28723
|
+
return typeof o2;
|
|
28724
|
+
} : function(o2) {
|
|
28725
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
28726
|
+
}, _typeof(o);
|
|
28727
|
+
}
|
|
28728
|
+
function toPrimitive(t2, r) {
|
|
28729
|
+
if ("object" != _typeof(t2) || !t2) return t2;
|
|
28730
|
+
var e = t2[Symbol.toPrimitive];
|
|
28731
|
+
if (void 0 !== e) {
|
|
28732
|
+
var i = e.call(t2, r || "default");
|
|
28733
|
+
if ("object" != _typeof(i)) return i;
|
|
28734
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
28735
|
+
}
|
|
28736
|
+
return ("string" === r ? String : Number)(t2);
|
|
28737
|
+
}
|
|
28738
|
+
function toPropertyKey(t2) {
|
|
28739
|
+
var i = toPrimitive(t2, "string");
|
|
28740
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
28741
|
+
}
|
|
28742
|
+
function _defineProperty(e, r, t2) {
|
|
28743
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
28744
|
+
value: t2,
|
|
28745
|
+
enumerable: true,
|
|
28746
|
+
configurable: true,
|
|
28747
|
+
writable: true
|
|
28748
|
+
}) : e[r] = t2, e;
|
|
28749
|
+
}
|
|
28750
|
+
function ownKeys(e, r) {
|
|
28751
|
+
var t2 = Object.keys(e);
|
|
28752
|
+
if (Object.getOwnPropertySymbols) {
|
|
28753
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
28754
|
+
r && (o = o.filter(function(r2) {
|
|
28755
|
+
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
|
|
28756
|
+
})), t2.push.apply(t2, o);
|
|
28757
|
+
}
|
|
28758
|
+
return t2;
|
|
28759
|
+
}
|
|
28760
|
+
function _objectSpread2(e) {
|
|
28761
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
28762
|
+
var t2 = null != arguments[r] ? arguments[r] : {};
|
|
28763
|
+
r % 2 ? ownKeys(Object(t2), true).forEach(function(r2) {
|
|
28764
|
+
_defineProperty(e, r2, t2[r2]);
|
|
28765
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t2)) : ownKeys(Object(t2)).forEach(function(r2) {
|
|
28766
|
+
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t2, r2));
|
|
28340
28767
|
});
|
|
28341
|
-
return { path: abs, parent: isRoot ? null : (0, import_node_path9.dirname)(abs), entries };
|
|
28342
28768
|
}
|
|
28343
|
-
|
|
28344
|
-
|
|
28345
|
-
|
|
28346
|
-
|
|
28347
|
-
|
|
28348
|
-
|
|
28349
|
-
|
|
28350
|
-
|
|
28351
|
-
|
|
28352
|
-
|
|
28769
|
+
return e;
|
|
28770
|
+
}
|
|
28771
|
+
|
|
28772
|
+
// ../../../node_modules/@trpc/server/dist/tracked-D4jU_Hb3.mjs
|
|
28773
|
+
var defaultFormatter = ({ shape }) => {
|
|
28774
|
+
return shape;
|
|
28775
|
+
};
|
|
28776
|
+
var UnknownCauseError = class extends Error {
|
|
28777
|
+
constructor(cause) {
|
|
28778
|
+
super(getMessage(cause));
|
|
28779
|
+
Object.assign(this, cause);
|
|
28353
28780
|
}
|
|
28354
|
-
|
|
28355
|
-
|
|
28356
|
-
|
|
28781
|
+
};
|
|
28782
|
+
function getMessage(cause) {
|
|
28783
|
+
if ("message" in cause) return String(cause.message);
|
|
28784
|
+
}
|
|
28785
|
+
function getCauseFromUnknown(cause) {
|
|
28786
|
+
if (cause instanceof Error) return cause;
|
|
28787
|
+
const type = typeof cause;
|
|
28788
|
+
if (type === "undefined" || type === "function" || cause === null) return;
|
|
28789
|
+
if (type !== "object") return new Error(String(cause));
|
|
28790
|
+
if (isObject2(cause)) return new UnknownCauseError(cause);
|
|
28791
|
+
}
|
|
28792
|
+
function getTRPCErrorFromUnknown(cause) {
|
|
28793
|
+
if (cause instanceof TRPCError) return cause;
|
|
28794
|
+
if (cause instanceof Error && cause.name === "TRPCError") return cause;
|
|
28795
|
+
const trpcError = new TRPCError({
|
|
28796
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
28797
|
+
cause
|
|
28798
|
+
});
|
|
28799
|
+
if (cause instanceof Error && cause.stack) trpcError.stack = cause.stack;
|
|
28800
|
+
return trpcError;
|
|
28801
|
+
}
|
|
28802
|
+
var TRPCError = class extends Error {
|
|
28803
|
+
constructor(opts) {
|
|
28804
|
+
var _ref, _opts$message, _this$cause;
|
|
28805
|
+
const cause = getCauseFromUnknown(opts.cause);
|
|
28806
|
+
const message = (_ref = (_opts$message = opts.message) !== null && _opts$message !== void 0 ? _opts$message : cause === null || cause === void 0 ? void 0 : cause.message) !== null && _ref !== void 0 ? _ref : opts.code;
|
|
28807
|
+
super(message, { cause });
|
|
28808
|
+
_defineProperty(this, "cause", void 0);
|
|
28809
|
+
_defineProperty(this, "code", void 0);
|
|
28810
|
+
this.code = opts.code;
|
|
28811
|
+
this.name = "TRPCError";
|
|
28812
|
+
(_this$cause = this.cause) !== null && _this$cause !== void 0 || (this.cause = cause);
|
|
28357
28813
|
}
|
|
28358
|
-
|
|
28359
|
-
|
|
28360
|
-
|
|
28361
|
-
|
|
28814
|
+
};
|
|
28815
|
+
function getDataTransformer(transformer) {
|
|
28816
|
+
if ("input" in transformer) return transformer;
|
|
28817
|
+
return {
|
|
28818
|
+
input: transformer,
|
|
28819
|
+
output: transformer
|
|
28820
|
+
};
|
|
28821
|
+
}
|
|
28822
|
+
var defaultTransformer = {
|
|
28823
|
+
input: {
|
|
28824
|
+
serialize: (obj) => obj,
|
|
28825
|
+
deserialize: (obj) => obj
|
|
28826
|
+
},
|
|
28827
|
+
output: {
|
|
28828
|
+
serialize: (obj) => obj,
|
|
28829
|
+
deserialize: (obj) => obj
|
|
28362
28830
|
}
|
|
28363
|
-
|
|
28364
|
-
|
|
28365
|
-
|
|
28366
|
-
|
|
28831
|
+
};
|
|
28832
|
+
var lazyMarker = "lazyMarker";
|
|
28833
|
+
function once(fn) {
|
|
28834
|
+
const uncalled = /* @__PURE__ */ Symbol();
|
|
28835
|
+
let result = uncalled;
|
|
28836
|
+
return () => {
|
|
28837
|
+
if (result === uncalled) result = fn();
|
|
28838
|
+
return result;
|
|
28839
|
+
};
|
|
28840
|
+
}
|
|
28841
|
+
function isLazy(input2) {
|
|
28842
|
+
return typeof input2 === "function" && lazyMarker in input2;
|
|
28843
|
+
}
|
|
28844
|
+
function isRouter(value) {
|
|
28845
|
+
return isObject2(value) && isObject2(value["_def"]) && "router" in value["_def"];
|
|
28846
|
+
}
|
|
28847
|
+
var emptyRouter = {
|
|
28848
|
+
_ctx: null,
|
|
28849
|
+
_errorShape: null,
|
|
28850
|
+
_meta: null,
|
|
28851
|
+
queries: {},
|
|
28852
|
+
mutations: {},
|
|
28853
|
+
subscriptions: {},
|
|
28854
|
+
errorFormatter: defaultFormatter,
|
|
28855
|
+
transformer: defaultTransformer
|
|
28856
|
+
};
|
|
28857
|
+
var reservedWords = [
|
|
28858
|
+
"then",
|
|
28859
|
+
"call",
|
|
28860
|
+
"apply"
|
|
28861
|
+
];
|
|
28862
|
+
function createRouterFactory(config2) {
|
|
28863
|
+
function createRouterInner(input2) {
|
|
28864
|
+
const reservedWordsUsed = new Set(Object.keys(input2).filter((v) => reservedWords.includes(v)));
|
|
28865
|
+
if (reservedWordsUsed.size > 0) throw new Error("Reserved words used in `router({})` call: " + Array.from(reservedWordsUsed).join(", "));
|
|
28866
|
+
const procedures = emptyObject();
|
|
28867
|
+
const lazy3 = emptyObject();
|
|
28868
|
+
function createLazyLoader(opts) {
|
|
28869
|
+
return {
|
|
28870
|
+
ref: opts.ref,
|
|
28871
|
+
load: once(async () => {
|
|
28872
|
+
const router2 = await opts.ref();
|
|
28873
|
+
const lazyPath = [...opts.path, opts.key];
|
|
28874
|
+
const lazyKey = lazyPath.join(".");
|
|
28875
|
+
opts.aggregate[opts.key] = step(router2._def.record, lazyPath);
|
|
28876
|
+
delete lazy3[lazyKey];
|
|
28877
|
+
for (const [nestedKey, nestedItem] of Object.entries(router2._def.lazy)) {
|
|
28878
|
+
const nestedRouterKey = [...lazyPath, nestedKey].join(".");
|
|
28879
|
+
lazy3[nestedRouterKey] = createLazyLoader({
|
|
28880
|
+
ref: nestedItem.ref,
|
|
28881
|
+
path: lazyPath,
|
|
28882
|
+
key: nestedKey,
|
|
28883
|
+
aggregate: opts.aggregate[opts.key]
|
|
28884
|
+
});
|
|
28885
|
+
}
|
|
28886
|
+
})
|
|
28887
|
+
};
|
|
28888
|
+
}
|
|
28889
|
+
function step(from, path9 = []) {
|
|
28890
|
+
const aggregate = emptyObject();
|
|
28891
|
+
for (const [key, item] of Object.entries(from !== null && from !== void 0 ? from : {})) {
|
|
28892
|
+
if (isLazy(item)) {
|
|
28893
|
+
lazy3[[...path9, key].join(".")] = createLazyLoader({
|
|
28894
|
+
path: path9,
|
|
28895
|
+
ref: item,
|
|
28896
|
+
key,
|
|
28897
|
+
aggregate
|
|
28898
|
+
});
|
|
28899
|
+
continue;
|
|
28900
|
+
}
|
|
28901
|
+
if (isRouter(item)) {
|
|
28902
|
+
aggregate[key] = step(item._def.record, [...path9, key]);
|
|
28903
|
+
continue;
|
|
28904
|
+
}
|
|
28905
|
+
if (!isProcedure(item)) {
|
|
28906
|
+
aggregate[key] = step(item, [...path9, key]);
|
|
28907
|
+
continue;
|
|
28908
|
+
}
|
|
28909
|
+
const newPath = [...path9, key].join(".");
|
|
28910
|
+
if (procedures[newPath]) throw new Error(`Duplicate key: ${newPath}`);
|
|
28911
|
+
procedures[newPath] = item;
|
|
28912
|
+
aggregate[key] = item;
|
|
28913
|
+
}
|
|
28914
|
+
return aggregate;
|
|
28915
|
+
}
|
|
28916
|
+
const record2 = step(input2);
|
|
28917
|
+
const _def = _objectSpread2(_objectSpread2({
|
|
28918
|
+
_config: config2,
|
|
28919
|
+
router: true,
|
|
28920
|
+
procedures,
|
|
28921
|
+
lazy: lazy3
|
|
28922
|
+
}, emptyRouter), {}, { record: record2 });
|
|
28923
|
+
return _objectSpread2(_objectSpread2({}, record2), {}, {
|
|
28924
|
+
_def,
|
|
28925
|
+
createCaller: createCallerFactory()({ _def })
|
|
28926
|
+
});
|
|
28367
28927
|
}
|
|
28368
|
-
|
|
28369
|
-
|
|
28370
|
-
|
|
28371
|
-
|
|
28928
|
+
return createRouterInner;
|
|
28929
|
+
}
|
|
28930
|
+
function isProcedure(procedureOrRouter) {
|
|
28931
|
+
return typeof procedureOrRouter === "function";
|
|
28932
|
+
}
|
|
28933
|
+
async function getProcedureAtPath(router2, path9) {
|
|
28934
|
+
const { _def } = router2;
|
|
28935
|
+
let procedure = _def.procedures[path9];
|
|
28936
|
+
while (!procedure) {
|
|
28937
|
+
const key = Object.keys(_def.lazy).find((key2) => path9 === key2 || path9.startsWith(key2 + "."));
|
|
28938
|
+
if (!key) return null;
|
|
28939
|
+
await _def.lazy[key].load();
|
|
28940
|
+
procedure = _def.procedures[path9];
|
|
28941
|
+
}
|
|
28942
|
+
return procedure;
|
|
28943
|
+
}
|
|
28944
|
+
function createCallerFactory() {
|
|
28945
|
+
return function createCallerInner(router2) {
|
|
28946
|
+
const { _def } = router2;
|
|
28947
|
+
return function createCaller(ctxOrCallback, opts) {
|
|
28948
|
+
return createRecursiveProxy(async (innerOpts) => {
|
|
28949
|
+
const { path: path9, args } = innerOpts;
|
|
28950
|
+
const fullPath = path9.join(".");
|
|
28951
|
+
if (path9.length === 1 && path9[0] === "_def") return _def;
|
|
28952
|
+
const procedure = await getProcedureAtPath(router2, fullPath);
|
|
28953
|
+
let ctx = void 0;
|
|
28954
|
+
try {
|
|
28955
|
+
if (!procedure) throw new TRPCError({
|
|
28956
|
+
code: "NOT_FOUND",
|
|
28957
|
+
message: `No procedure found on path "${path9}"`
|
|
28958
|
+
});
|
|
28959
|
+
ctx = isFunction(ctxOrCallback) ? await Promise.resolve(ctxOrCallback()) : ctxOrCallback;
|
|
28960
|
+
return await procedure({
|
|
28961
|
+
path: fullPath,
|
|
28962
|
+
getRawInput: async () => args[0],
|
|
28963
|
+
ctx,
|
|
28964
|
+
type: procedure._def.type,
|
|
28965
|
+
signal: opts === null || opts === void 0 ? void 0 : opts.signal,
|
|
28966
|
+
batchIndex: 0
|
|
28967
|
+
});
|
|
28968
|
+
} catch (cause) {
|
|
28969
|
+
var _opts$onError, _procedure$_def$type;
|
|
28970
|
+
opts === null || opts === void 0 || (_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, {
|
|
28971
|
+
ctx,
|
|
28972
|
+
error: getTRPCErrorFromUnknown(cause),
|
|
28973
|
+
input: args[0],
|
|
28974
|
+
path: fullPath,
|
|
28975
|
+
type: (_procedure$_def$type = procedure === null || procedure === void 0 ? void 0 : procedure._def.type) !== null && _procedure$_def$type !== void 0 ? _procedure$_def$type : "unknown"
|
|
28976
|
+
});
|
|
28977
|
+
throw cause;
|
|
28978
|
+
}
|
|
28979
|
+
});
|
|
28980
|
+
};
|
|
28981
|
+
};
|
|
28982
|
+
}
|
|
28983
|
+
function mergeRouters(...routerList) {
|
|
28984
|
+
var _routerList$, _routerList$2;
|
|
28985
|
+
const record2 = mergeWithoutOverrides({}, ...routerList.map((r) => r._def.record));
|
|
28986
|
+
return createRouterFactory({
|
|
28987
|
+
errorFormatter: routerList.reduce((currentErrorFormatter, nextRouter) => {
|
|
28988
|
+
if (nextRouter._def._config.errorFormatter && nextRouter._def._config.errorFormatter !== defaultFormatter) {
|
|
28989
|
+
if (currentErrorFormatter !== defaultFormatter && currentErrorFormatter !== nextRouter._def._config.errorFormatter) throw new Error("You seem to have several error formatters");
|
|
28990
|
+
return nextRouter._def._config.errorFormatter;
|
|
28991
|
+
}
|
|
28992
|
+
return currentErrorFormatter;
|
|
28993
|
+
}, defaultFormatter),
|
|
28994
|
+
transformer: routerList.reduce((prev, current) => {
|
|
28995
|
+
if (current._def._config.transformer && current._def._config.transformer !== defaultTransformer) {
|
|
28996
|
+
if (prev !== defaultTransformer && prev !== current._def._config.transformer) throw new Error("You seem to have several transformers");
|
|
28997
|
+
return current._def._config.transformer;
|
|
28998
|
+
}
|
|
28999
|
+
return prev;
|
|
29000
|
+
}, defaultTransformer),
|
|
29001
|
+
isDev: routerList.every((r) => r._def._config.isDev),
|
|
29002
|
+
allowOutsideOfServer: routerList.every((r) => r._def._config.allowOutsideOfServer),
|
|
29003
|
+
isServer: routerList.every((r) => r._def._config.isServer),
|
|
29004
|
+
$types: (_routerList$ = routerList[0]) === null || _routerList$ === void 0 ? void 0 : _routerList$._def._config.$types,
|
|
29005
|
+
sse: (_routerList$2 = routerList[0]) === null || _routerList$2 === void 0 ? void 0 : _routerList$2._def._config.sse
|
|
29006
|
+
})(record2);
|
|
29007
|
+
}
|
|
29008
|
+
|
|
29009
|
+
// ../../../node_modules/@trpc/server/dist/initTRPC-B259os3T.mjs
|
|
29010
|
+
var middlewareMarker = "middlewareMarker";
|
|
29011
|
+
function createMiddlewareFactory() {
|
|
29012
|
+
function createMiddlewareInner(middlewares) {
|
|
29013
|
+
return {
|
|
29014
|
+
_middlewares: middlewares,
|
|
29015
|
+
unstable_pipe(middlewareBuilderOrFn) {
|
|
29016
|
+
const pipedMiddleware = "_middlewares" in middlewareBuilderOrFn ? middlewareBuilderOrFn._middlewares : [middlewareBuilderOrFn];
|
|
29017
|
+
return createMiddlewareInner([...middlewares, ...pipedMiddleware]);
|
|
29018
|
+
}
|
|
29019
|
+
};
|
|
28372
29020
|
}
|
|
28373
|
-
function
|
|
28374
|
-
|
|
28375
|
-
allowIn(rootPath, newPath, true);
|
|
28376
|
-
renamePath(allowIn(rootPath, oldPath, true), oldPath, newPath);
|
|
28377
|
-
return { ok: true };
|
|
29021
|
+
function createMiddleware(fn) {
|
|
29022
|
+
return createMiddlewareInner([fn]);
|
|
28378
29023
|
}
|
|
28379
|
-
|
|
28380
|
-
|
|
28381
|
-
|
|
29024
|
+
return createMiddleware;
|
|
29025
|
+
}
|
|
29026
|
+
function createInputMiddleware(parse5) {
|
|
29027
|
+
const inputMiddleware = async function inputValidatorMiddleware(opts) {
|
|
29028
|
+
let parsedInput;
|
|
29029
|
+
const rawInput = await opts.getRawInput();
|
|
29030
|
+
try {
|
|
29031
|
+
parsedInput = await parse5(rawInput);
|
|
29032
|
+
} catch (cause) {
|
|
29033
|
+
throw new TRPCError({
|
|
29034
|
+
code: "BAD_REQUEST",
|
|
29035
|
+
cause
|
|
29036
|
+
});
|
|
29037
|
+
}
|
|
29038
|
+
const combinedInput = isObject2(opts.input) && isObject2(parsedInput) ? _objectSpread2(_objectSpread2({}, opts.input), parsedInput) : parsedInput;
|
|
29039
|
+
return opts.next({ input: combinedInput });
|
|
29040
|
+
};
|
|
29041
|
+
inputMiddleware._type = "input";
|
|
29042
|
+
return inputMiddleware;
|
|
29043
|
+
}
|
|
29044
|
+
function createOutputMiddleware(parse5) {
|
|
29045
|
+
const outputMiddleware = async function outputValidatorMiddleware({ next }) {
|
|
29046
|
+
const result = await next();
|
|
29047
|
+
if (!result.ok) return result;
|
|
29048
|
+
try {
|
|
29049
|
+
const data = await parse5(result.data);
|
|
29050
|
+
return _objectSpread2(_objectSpread2({}, result), {}, { data });
|
|
29051
|
+
} catch (cause) {
|
|
29052
|
+
throw new TRPCError({
|
|
29053
|
+
message: "Output validation failed",
|
|
29054
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
29055
|
+
cause
|
|
29056
|
+
});
|
|
29057
|
+
}
|
|
29058
|
+
};
|
|
29059
|
+
outputMiddleware._type = "output";
|
|
29060
|
+
return outputMiddleware;
|
|
29061
|
+
}
|
|
29062
|
+
var StandardSchemaV1Error = class extends Error {
|
|
29063
|
+
/**
|
|
29064
|
+
* Creates a schema error with useful information.
|
|
29065
|
+
*
|
|
29066
|
+
* @param issues The schema issues.
|
|
29067
|
+
*/
|
|
29068
|
+
constructor(issues) {
|
|
29069
|
+
var _issues$;
|
|
29070
|
+
super((_issues$ = issues[0]) === null || _issues$ === void 0 ? void 0 : _issues$.message);
|
|
29071
|
+
_defineProperty(this, "issues", void 0);
|
|
29072
|
+
this.name = "SchemaError";
|
|
29073
|
+
this.issues = issues;
|
|
29074
|
+
}
|
|
29075
|
+
};
|
|
29076
|
+
function getParseFn(procedureParser) {
|
|
29077
|
+
const parser = procedureParser;
|
|
29078
|
+
const isStandardSchema = "~standard" in parser;
|
|
29079
|
+
if (typeof parser === "function" && typeof parser.assert === "function") return parser.assert.bind(parser);
|
|
29080
|
+
if (typeof parser === "function" && !isStandardSchema) return parser;
|
|
29081
|
+
if (typeof parser.parseAsync === "function") return parser.parseAsync.bind(parser);
|
|
29082
|
+
if (typeof parser.parse === "function") return parser.parse.bind(parser);
|
|
29083
|
+
if (typeof parser.validateSync === "function") return parser.validateSync.bind(parser);
|
|
29084
|
+
if (typeof parser.create === "function") return parser.create.bind(parser);
|
|
29085
|
+
if (typeof parser.assert === "function") return (value) => {
|
|
29086
|
+
parser.assert(value);
|
|
29087
|
+
return value;
|
|
29088
|
+
};
|
|
29089
|
+
if (isStandardSchema) return async (value) => {
|
|
29090
|
+
const result = await parser["~standard"].validate(value);
|
|
29091
|
+
if (result.issues) throw new StandardSchemaV1Error(result.issues);
|
|
29092
|
+
return result.value;
|
|
29093
|
+
};
|
|
29094
|
+
throw new Error("Could not find a validator fn");
|
|
29095
|
+
}
|
|
29096
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
29097
|
+
if (null == r) return {};
|
|
29098
|
+
var t2 = {};
|
|
29099
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
29100
|
+
if (e.includes(n)) continue;
|
|
29101
|
+
t2[n] = r[n];
|
|
29102
|
+
}
|
|
29103
|
+
return t2;
|
|
29104
|
+
}
|
|
29105
|
+
function _objectWithoutProperties(e, t2) {
|
|
29106
|
+
if (null == e) return {};
|
|
29107
|
+
var o, r, i = _objectWithoutPropertiesLoose(e, t2);
|
|
29108
|
+
if (Object.getOwnPropertySymbols) {
|
|
29109
|
+
var s = Object.getOwnPropertySymbols(e);
|
|
29110
|
+
for (r = 0; r < s.length; r++) o = s[r], t2.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
29111
|
+
}
|
|
29112
|
+
return i;
|
|
29113
|
+
}
|
|
29114
|
+
var _excluded = [
|
|
29115
|
+
"middlewares",
|
|
29116
|
+
"inputs",
|
|
29117
|
+
"meta"
|
|
29118
|
+
];
|
|
29119
|
+
function createNewBuilder(def1, def2) {
|
|
29120
|
+
const { middlewares = [], inputs, meta: meta3 } = def2, rest = _objectWithoutProperties(def2, _excluded);
|
|
29121
|
+
return createBuilder(_objectSpread2(_objectSpread2({}, mergeWithoutOverrides(def1, rest)), {}, {
|
|
29122
|
+
inputs: [...def1.inputs, ...inputs !== null && inputs !== void 0 ? inputs : []],
|
|
29123
|
+
middlewares: [...def1.middlewares, ...middlewares],
|
|
29124
|
+
meta: def1.meta && meta3 ? _objectSpread2(_objectSpread2({}, def1.meta), meta3) : meta3 !== null && meta3 !== void 0 ? meta3 : def1.meta
|
|
29125
|
+
}));
|
|
29126
|
+
}
|
|
29127
|
+
function createBuilder(initDef = {}) {
|
|
29128
|
+
const _def = _objectSpread2({
|
|
29129
|
+
procedure: true,
|
|
29130
|
+
inputs: [],
|
|
29131
|
+
middlewares: []
|
|
29132
|
+
}, initDef);
|
|
29133
|
+
return {
|
|
29134
|
+
_def,
|
|
29135
|
+
input(input2) {
|
|
29136
|
+
const parser = getParseFn(input2);
|
|
29137
|
+
return createNewBuilder(_def, {
|
|
29138
|
+
inputs: [input2],
|
|
29139
|
+
middlewares: [createInputMiddleware(parser)]
|
|
29140
|
+
});
|
|
29141
|
+
},
|
|
29142
|
+
output(output2) {
|
|
29143
|
+
const parser = getParseFn(output2);
|
|
29144
|
+
return createNewBuilder(_def, {
|
|
29145
|
+
output: output2,
|
|
29146
|
+
middlewares: [createOutputMiddleware(parser)]
|
|
29147
|
+
});
|
|
29148
|
+
},
|
|
29149
|
+
meta(meta3) {
|
|
29150
|
+
return createNewBuilder(_def, { meta: meta3 });
|
|
29151
|
+
},
|
|
29152
|
+
use(middlewareBuilderOrFn) {
|
|
29153
|
+
const middlewares = "_middlewares" in middlewareBuilderOrFn ? middlewareBuilderOrFn._middlewares : [middlewareBuilderOrFn];
|
|
29154
|
+
return createNewBuilder(_def, { middlewares });
|
|
29155
|
+
},
|
|
29156
|
+
unstable_concat(builder) {
|
|
29157
|
+
return createNewBuilder(_def, builder._def);
|
|
29158
|
+
},
|
|
29159
|
+
concat(builder) {
|
|
29160
|
+
return createNewBuilder(_def, builder._def);
|
|
29161
|
+
},
|
|
29162
|
+
query(resolver) {
|
|
29163
|
+
return createResolver(_objectSpread2(_objectSpread2({}, _def), {}, { type: "query" }), resolver);
|
|
29164
|
+
},
|
|
29165
|
+
mutation(resolver) {
|
|
29166
|
+
return createResolver(_objectSpread2(_objectSpread2({}, _def), {}, { type: "mutation" }), resolver);
|
|
29167
|
+
},
|
|
29168
|
+
subscription(resolver) {
|
|
29169
|
+
return createResolver(_objectSpread2(_objectSpread2({}, _def), {}, { type: "subscription" }), resolver);
|
|
29170
|
+
},
|
|
29171
|
+
experimental_caller(caller) {
|
|
29172
|
+
return createNewBuilder(_def, { caller });
|
|
29173
|
+
}
|
|
29174
|
+
};
|
|
29175
|
+
}
|
|
29176
|
+
function createResolver(_defIn, resolver) {
|
|
29177
|
+
const finalBuilder = createNewBuilder(_defIn, {
|
|
29178
|
+
resolver,
|
|
29179
|
+
middlewares: [async function resolveMiddleware(opts) {
|
|
29180
|
+
const data = await resolver(opts);
|
|
29181
|
+
return {
|
|
29182
|
+
marker: middlewareMarker,
|
|
29183
|
+
ok: true,
|
|
29184
|
+
data,
|
|
29185
|
+
ctx: opts.ctx
|
|
29186
|
+
};
|
|
29187
|
+
}]
|
|
29188
|
+
});
|
|
29189
|
+
const _def = _objectSpread2(_objectSpread2({}, finalBuilder._def), {}, {
|
|
29190
|
+
type: _defIn.type,
|
|
29191
|
+
experimental_caller: Boolean(finalBuilder._def.caller),
|
|
29192
|
+
meta: finalBuilder._def.meta,
|
|
29193
|
+
$types: null
|
|
29194
|
+
});
|
|
29195
|
+
const invoke = createProcedureCaller(finalBuilder._def);
|
|
29196
|
+
const callerOverride = finalBuilder._def.caller;
|
|
29197
|
+
if (!callerOverride) return invoke;
|
|
29198
|
+
const callerWrapper = async (...args) => {
|
|
29199
|
+
return await callerOverride({
|
|
29200
|
+
args,
|
|
29201
|
+
invoke,
|
|
29202
|
+
_def
|
|
29203
|
+
});
|
|
29204
|
+
};
|
|
29205
|
+
callerWrapper._def = _def;
|
|
29206
|
+
return callerWrapper;
|
|
29207
|
+
}
|
|
29208
|
+
var codeblock = `
|
|
29209
|
+
This is a client-only function.
|
|
29210
|
+
If you want to call this function on the server, see https://trpc.io/docs/v11/server/server-side-calls
|
|
29211
|
+
`.trim();
|
|
29212
|
+
async function callRecursive(index, _def, opts) {
|
|
29213
|
+
try {
|
|
29214
|
+
const middleware2 = _def.middlewares[index];
|
|
29215
|
+
return await middleware2(_objectSpread2(_objectSpread2({}, opts), {}, {
|
|
29216
|
+
meta: _def.meta,
|
|
29217
|
+
input: opts.input,
|
|
29218
|
+
next(_nextOpts) {
|
|
29219
|
+
var _nextOpts$getRawInput;
|
|
29220
|
+
const nextOpts = _nextOpts;
|
|
29221
|
+
return callRecursive(index + 1, _def, _objectSpread2(_objectSpread2({}, opts), {}, {
|
|
29222
|
+
ctx: (nextOpts === null || nextOpts === void 0 ? void 0 : nextOpts.ctx) ? _objectSpread2(_objectSpread2({}, opts.ctx), nextOpts.ctx) : opts.ctx,
|
|
29223
|
+
input: nextOpts && "input" in nextOpts ? nextOpts.input : opts.input,
|
|
29224
|
+
getRawInput: (_nextOpts$getRawInput = nextOpts === null || nextOpts === void 0 ? void 0 : nextOpts.getRawInput) !== null && _nextOpts$getRawInput !== void 0 ? _nextOpts$getRawInput : opts.getRawInput
|
|
29225
|
+
}));
|
|
29226
|
+
}
|
|
29227
|
+
}));
|
|
29228
|
+
} catch (cause) {
|
|
29229
|
+
return {
|
|
29230
|
+
ok: false,
|
|
29231
|
+
error: getTRPCErrorFromUnknown(cause),
|
|
29232
|
+
marker: middlewareMarker
|
|
29233
|
+
};
|
|
29234
|
+
}
|
|
29235
|
+
}
|
|
29236
|
+
function createProcedureCaller(_def) {
|
|
29237
|
+
async function procedure(opts) {
|
|
29238
|
+
if (!opts || !("getRawInput" in opts)) throw new Error(codeblock);
|
|
29239
|
+
const result = await callRecursive(0, _def, opts);
|
|
29240
|
+
if (!result) throw new TRPCError({
|
|
29241
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
29242
|
+
message: "No result from middlewares - did you forget to `return next()`?"
|
|
29243
|
+
});
|
|
29244
|
+
if (!result.ok) throw result.error;
|
|
29245
|
+
return result.data;
|
|
29246
|
+
}
|
|
29247
|
+
procedure._def = _def;
|
|
29248
|
+
procedure.procedure = true;
|
|
29249
|
+
procedure.meta = _def.meta;
|
|
29250
|
+
return procedure;
|
|
29251
|
+
}
|
|
29252
|
+
var _globalThis$process;
|
|
29253
|
+
var _globalThis$process2;
|
|
29254
|
+
var _globalThis$process3;
|
|
29255
|
+
var 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"]);
|
|
29256
|
+
var initTRPC = new class TRPCBuilder {
|
|
29257
|
+
/**
|
|
29258
|
+
* Add a context shape as a generic to the root object
|
|
29259
|
+
* @see https://trpc.io/docs/v11/server/context
|
|
29260
|
+
*/
|
|
29261
|
+
context() {
|
|
29262
|
+
return new TRPCBuilder();
|
|
29263
|
+
}
|
|
29264
|
+
/**
|
|
29265
|
+
* Add a meta shape as a generic to the root object
|
|
29266
|
+
* @see https://trpc.io/docs/v11/quickstart
|
|
29267
|
+
*/
|
|
29268
|
+
meta() {
|
|
29269
|
+
return new TRPCBuilder();
|
|
29270
|
+
}
|
|
29271
|
+
/**
|
|
29272
|
+
* Create the root object
|
|
29273
|
+
* @see https://trpc.io/docs/v11/server/routers#initialize-trpc
|
|
29274
|
+
*/
|
|
29275
|
+
create(opts) {
|
|
29276
|
+
var _opts$transformer, _opts$isDev, _globalThis$process4, _opts$allowOutsideOfS, _opts$errorFormatter, _opts$isServer;
|
|
29277
|
+
const config2 = _objectSpread2(_objectSpread2({}, opts), {}, {
|
|
29278
|
+
transformer: getDataTransformer((_opts$transformer = opts === null || opts === void 0 ? void 0 : opts.transformer) !== null && _opts$transformer !== void 0 ? _opts$transformer : defaultTransformer),
|
|
29279
|
+
isDev: (_opts$isDev = opts === null || opts === void 0 ? void 0 : opts.isDev) !== null && _opts$isDev !== void 0 ? _opts$isDev : ((_globalThis$process4 = globalThis.process) === null || _globalThis$process4 === void 0 ? void 0 : _globalThis$process4.env["NODE_ENV"]) !== "production",
|
|
29280
|
+
allowOutsideOfServer: (_opts$allowOutsideOfS = opts === null || opts === void 0 ? void 0 : opts.allowOutsideOfServer) !== null && _opts$allowOutsideOfS !== void 0 ? _opts$allowOutsideOfS : false,
|
|
29281
|
+
errorFormatter: (_opts$errorFormatter = opts === null || opts === void 0 ? void 0 : opts.errorFormatter) !== null && _opts$errorFormatter !== void 0 ? _opts$errorFormatter : defaultFormatter,
|
|
29282
|
+
isServer: (_opts$isServer = opts === null || opts === void 0 ? void 0 : opts.isServer) !== null && _opts$isServer !== void 0 ? _opts$isServer : isServerDefault,
|
|
29283
|
+
/**
|
|
29284
|
+
* These are just types, they can't be used at runtime
|
|
29285
|
+
* @internal
|
|
29286
|
+
*/
|
|
29287
|
+
$types: null
|
|
29288
|
+
});
|
|
29289
|
+
var _opts$isServer2;
|
|
29290
|
+
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.`);
|
|
29291
|
+
return {
|
|
29292
|
+
/**
|
|
29293
|
+
* Your router config
|
|
29294
|
+
* @internal
|
|
29295
|
+
*/
|
|
29296
|
+
_config: config2,
|
|
29297
|
+
/**
|
|
29298
|
+
* Builder object for creating procedures
|
|
29299
|
+
* @see https://trpc.io/docs/v11/server/procedures
|
|
29300
|
+
*/
|
|
29301
|
+
procedure: createBuilder({ meta: opts === null || opts === void 0 ? void 0 : opts.defaultMeta }),
|
|
29302
|
+
/**
|
|
29303
|
+
* Create reusable middlewares
|
|
29304
|
+
* @see https://trpc.io/docs/v11/server/middlewares
|
|
29305
|
+
*/
|
|
29306
|
+
middleware: createMiddlewareFactory(),
|
|
29307
|
+
/**
|
|
29308
|
+
* Create a router
|
|
29309
|
+
* @see https://trpc.io/docs/v11/server/routers
|
|
29310
|
+
*/
|
|
29311
|
+
router: createRouterFactory(config2),
|
|
29312
|
+
/**
|
|
29313
|
+
* Merge Routers
|
|
29314
|
+
* @see https://trpc.io/docs/v11/server/merging-routers
|
|
29315
|
+
*/
|
|
29316
|
+
mergeRouters,
|
|
29317
|
+
/**
|
|
29318
|
+
* Create a server-side caller for a router
|
|
29319
|
+
* @see https://trpc.io/docs/v11/server/server-side-calls
|
|
29320
|
+
*/
|
|
29321
|
+
createCallerFactory: createCallerFactory()
|
|
29322
|
+
};
|
|
29323
|
+
}
|
|
29324
|
+
}();
|
|
29325
|
+
|
|
29326
|
+
// ../../../node_modules/@trpc/server/dist/observable-DwUFSuKv.mjs
|
|
29327
|
+
function observable(subscribe) {
|
|
29328
|
+
const self = {
|
|
29329
|
+
subscribe(observer) {
|
|
29330
|
+
let teardownRef = null;
|
|
29331
|
+
let isDone = false;
|
|
29332
|
+
let unsubscribed = false;
|
|
29333
|
+
let teardownImmediately = false;
|
|
29334
|
+
function unsubscribe2() {
|
|
29335
|
+
if (teardownRef === null) {
|
|
29336
|
+
teardownImmediately = true;
|
|
29337
|
+
return;
|
|
29338
|
+
}
|
|
29339
|
+
if (unsubscribed) return;
|
|
29340
|
+
unsubscribed = true;
|
|
29341
|
+
if (typeof teardownRef === "function") teardownRef();
|
|
29342
|
+
else if (teardownRef) teardownRef.unsubscribe();
|
|
29343
|
+
}
|
|
29344
|
+
teardownRef = subscribe({
|
|
29345
|
+
next(value) {
|
|
29346
|
+
var _observer$next;
|
|
29347
|
+
if (isDone) return;
|
|
29348
|
+
(_observer$next = observer.next) === null || _observer$next === void 0 || _observer$next.call(observer, value);
|
|
29349
|
+
},
|
|
29350
|
+
error(err) {
|
|
29351
|
+
var _observer$error;
|
|
29352
|
+
if (isDone) return;
|
|
29353
|
+
isDone = true;
|
|
29354
|
+
(_observer$error = observer.error) === null || _observer$error === void 0 || _observer$error.call(observer, err);
|
|
29355
|
+
unsubscribe2();
|
|
29356
|
+
},
|
|
29357
|
+
complete() {
|
|
29358
|
+
var _observer$complete;
|
|
29359
|
+
if (isDone) return;
|
|
29360
|
+
isDone = true;
|
|
29361
|
+
(_observer$complete = observer.complete) === null || _observer$complete === void 0 || _observer$complete.call(observer);
|
|
29362
|
+
unsubscribe2();
|
|
29363
|
+
}
|
|
29364
|
+
});
|
|
29365
|
+
if (teardownImmediately) unsubscribe2();
|
|
29366
|
+
return { unsubscribe: unsubscribe2 };
|
|
29367
|
+
},
|
|
29368
|
+
pipe(...operations) {
|
|
29369
|
+
return operations.reduce(pipeReducer, self);
|
|
29370
|
+
}
|
|
29371
|
+
};
|
|
29372
|
+
return self;
|
|
29373
|
+
}
|
|
29374
|
+
function pipeReducer(prev, fn) {
|
|
29375
|
+
return fn(prev);
|
|
29376
|
+
}
|
|
29377
|
+
|
|
29378
|
+
// ../../shared/platform/src/safe-path.ts
|
|
29379
|
+
var UnsafePathError = class extends Error {
|
|
29380
|
+
constructor(code, message) {
|
|
29381
|
+
super(message);
|
|
29382
|
+
this.code = code;
|
|
29383
|
+
this.name = "UnsafePathError";
|
|
29384
|
+
}
|
|
29385
|
+
code;
|
|
29386
|
+
};
|
|
29387
|
+
function isUnsafePathError(err) {
|
|
29388
|
+
if (err instanceof UnsafePathError) return true;
|
|
29389
|
+
if (!(err instanceof Error) || err.name !== "UnsafePathError") return false;
|
|
29390
|
+
const code = err.code;
|
|
29391
|
+
return code === "INVALID_ID" || code === "PATH_OUTSIDE_BASE";
|
|
29392
|
+
}
|
|
29393
|
+
|
|
29394
|
+
// ../../shared/trpc-server/src/auth-gate.ts
|
|
29395
|
+
var authGate = () => false;
|
|
29396
|
+
function getAuthGate() {
|
|
29397
|
+
return authGate();
|
|
29398
|
+
}
|
|
29399
|
+
|
|
29400
|
+
// ../../../node_modules/superjson/dist/double-indexed-kv.js
|
|
29401
|
+
var DoubleIndexedKV = class {
|
|
29402
|
+
constructor() {
|
|
29403
|
+
this.keyToValue = /* @__PURE__ */ new Map();
|
|
29404
|
+
this.valueToKey = /* @__PURE__ */ new Map();
|
|
29405
|
+
}
|
|
29406
|
+
set(key, value) {
|
|
29407
|
+
this.keyToValue.set(key, value);
|
|
29408
|
+
this.valueToKey.set(value, key);
|
|
29409
|
+
}
|
|
29410
|
+
getByKey(key) {
|
|
29411
|
+
return this.keyToValue.get(key);
|
|
29412
|
+
}
|
|
29413
|
+
getByValue(value) {
|
|
29414
|
+
return this.valueToKey.get(value);
|
|
29415
|
+
}
|
|
29416
|
+
clear() {
|
|
29417
|
+
this.keyToValue.clear();
|
|
29418
|
+
this.valueToKey.clear();
|
|
29419
|
+
}
|
|
29420
|
+
};
|
|
29421
|
+
|
|
29422
|
+
// ../../../node_modules/superjson/dist/registry.js
|
|
29423
|
+
var Registry = class {
|
|
29424
|
+
constructor(generateIdentifier) {
|
|
29425
|
+
this.generateIdentifier = generateIdentifier;
|
|
29426
|
+
this.kv = new DoubleIndexedKV();
|
|
29427
|
+
}
|
|
29428
|
+
register(value, identifier) {
|
|
29429
|
+
if (this.kv.getByValue(value)) {
|
|
29430
|
+
return;
|
|
29431
|
+
}
|
|
29432
|
+
if (!identifier) {
|
|
29433
|
+
identifier = this.generateIdentifier(value);
|
|
29434
|
+
}
|
|
29435
|
+
this.kv.set(identifier, value);
|
|
29436
|
+
}
|
|
29437
|
+
clear() {
|
|
29438
|
+
this.kv.clear();
|
|
29439
|
+
}
|
|
29440
|
+
getIdentifier(value) {
|
|
29441
|
+
return this.kv.getByValue(value);
|
|
29442
|
+
}
|
|
29443
|
+
getValue(identifier) {
|
|
29444
|
+
return this.kv.getByKey(identifier);
|
|
29445
|
+
}
|
|
29446
|
+
};
|
|
29447
|
+
|
|
29448
|
+
// ../../../node_modules/superjson/dist/class-registry.js
|
|
29449
|
+
var ClassRegistry = class extends Registry {
|
|
29450
|
+
constructor() {
|
|
29451
|
+
super((c) => c.name);
|
|
29452
|
+
this.classToAllowedProps = /* @__PURE__ */ new Map();
|
|
29453
|
+
}
|
|
29454
|
+
register(value, options) {
|
|
29455
|
+
if (typeof options === "object") {
|
|
29456
|
+
if (options.allowProps) {
|
|
29457
|
+
this.classToAllowedProps.set(value, options.allowProps);
|
|
29458
|
+
}
|
|
29459
|
+
super.register(value, options.identifier);
|
|
29460
|
+
} else {
|
|
29461
|
+
super.register(value, options);
|
|
29462
|
+
}
|
|
29463
|
+
}
|
|
29464
|
+
getAllowedProps(value) {
|
|
29465
|
+
return this.classToAllowedProps.get(value);
|
|
29466
|
+
}
|
|
29467
|
+
};
|
|
29468
|
+
|
|
29469
|
+
// ../../../node_modules/superjson/dist/util.js
|
|
29470
|
+
function valuesOfObj(record2) {
|
|
29471
|
+
if ("values" in Object) {
|
|
29472
|
+
return Object.values(record2);
|
|
29473
|
+
}
|
|
29474
|
+
const values = [];
|
|
29475
|
+
for (const key in record2) {
|
|
29476
|
+
if (record2.hasOwnProperty(key)) {
|
|
29477
|
+
values.push(record2[key]);
|
|
29478
|
+
}
|
|
29479
|
+
}
|
|
29480
|
+
return values;
|
|
29481
|
+
}
|
|
29482
|
+
function find(record2, predicate) {
|
|
29483
|
+
const values = valuesOfObj(record2);
|
|
29484
|
+
if ("find" in values) {
|
|
29485
|
+
return values.find(predicate);
|
|
29486
|
+
}
|
|
29487
|
+
const valuesNotNever = values;
|
|
29488
|
+
for (let i = 0; i < valuesNotNever.length; i++) {
|
|
29489
|
+
const value = valuesNotNever[i];
|
|
29490
|
+
if (predicate(value)) {
|
|
29491
|
+
return value;
|
|
29492
|
+
}
|
|
29493
|
+
}
|
|
29494
|
+
return void 0;
|
|
29495
|
+
}
|
|
29496
|
+
function forEach(record2, run) {
|
|
29497
|
+
Object.entries(record2).forEach(([key, value]) => run(value, key));
|
|
29498
|
+
}
|
|
29499
|
+
function includes(arr, value) {
|
|
29500
|
+
return arr.indexOf(value) !== -1;
|
|
29501
|
+
}
|
|
29502
|
+
function findArr(record2, predicate) {
|
|
29503
|
+
for (let i = 0; i < record2.length; i++) {
|
|
29504
|
+
const value = record2[i];
|
|
29505
|
+
if (predicate(value)) {
|
|
29506
|
+
return value;
|
|
29507
|
+
}
|
|
29508
|
+
}
|
|
29509
|
+
return void 0;
|
|
29510
|
+
}
|
|
29511
|
+
|
|
29512
|
+
// ../../../node_modules/superjson/dist/custom-transformer-registry.js
|
|
29513
|
+
var CustomTransformerRegistry = class {
|
|
29514
|
+
constructor() {
|
|
29515
|
+
this.transfomers = {};
|
|
29516
|
+
}
|
|
29517
|
+
register(transformer) {
|
|
29518
|
+
this.transfomers[transformer.name] = transformer;
|
|
29519
|
+
}
|
|
29520
|
+
findApplicable(v) {
|
|
29521
|
+
return find(this.transfomers, (transformer) => transformer.isApplicable(v));
|
|
29522
|
+
}
|
|
29523
|
+
findByName(name) {
|
|
29524
|
+
return this.transfomers[name];
|
|
29525
|
+
}
|
|
29526
|
+
};
|
|
29527
|
+
|
|
29528
|
+
// ../../../node_modules/superjson/dist/is.js
|
|
29529
|
+
var getType = (payload) => Object.prototype.toString.call(payload).slice(8, -1);
|
|
29530
|
+
var isUndefined = (payload) => typeof payload === "undefined";
|
|
29531
|
+
var isNull = (payload) => payload === null;
|
|
29532
|
+
var isPlainObject2 = (payload) => {
|
|
29533
|
+
if (typeof payload !== "object" || payload === null)
|
|
29534
|
+
return false;
|
|
29535
|
+
if (payload === Object.prototype)
|
|
29536
|
+
return false;
|
|
29537
|
+
if (Object.getPrototypeOf(payload) === null)
|
|
29538
|
+
return true;
|
|
29539
|
+
return Object.getPrototypeOf(payload) === Object.prototype;
|
|
29540
|
+
};
|
|
29541
|
+
var isEmptyObject = (payload) => isPlainObject2(payload) && Object.keys(payload).length === 0;
|
|
29542
|
+
var isArray = (payload) => Array.isArray(payload);
|
|
29543
|
+
var isString = (payload) => typeof payload === "string";
|
|
29544
|
+
var isNumber = (payload) => typeof payload === "number" && !isNaN(payload);
|
|
29545
|
+
var isBoolean = (payload) => typeof payload === "boolean";
|
|
29546
|
+
var isRegExp = (payload) => payload instanceof RegExp;
|
|
29547
|
+
var isMap = (payload) => payload instanceof Map;
|
|
29548
|
+
var isSet = (payload) => payload instanceof Set;
|
|
29549
|
+
var isSymbol = (payload) => getType(payload) === "Symbol";
|
|
29550
|
+
var isDate = (payload) => payload instanceof Date && !isNaN(payload.valueOf());
|
|
29551
|
+
var isError = (payload) => payload instanceof Error;
|
|
29552
|
+
var isNaNValue = (payload) => typeof payload === "number" && isNaN(payload);
|
|
29553
|
+
var isPrimitive = (payload) => isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
|
|
29554
|
+
var isBigint = (payload) => typeof payload === "bigint";
|
|
29555
|
+
var isInfinite = (payload) => payload === Infinity || payload === -Infinity;
|
|
29556
|
+
var isTypedArray = (payload) => ArrayBuffer.isView(payload) && !(payload instanceof DataView);
|
|
29557
|
+
var isURL = (payload) => payload instanceof URL;
|
|
29558
|
+
|
|
29559
|
+
// ../../../node_modules/superjson/dist/pathstringifier.js
|
|
29560
|
+
var escapeKey = (key) => key.replace(/\\/g, "\\\\").replace(/\./g, "\\.");
|
|
29561
|
+
var stringifyPath = (path9) => path9.map(String).map(escapeKey).join(".");
|
|
29562
|
+
var parsePath = (string4, legacyPaths) => {
|
|
29563
|
+
const result = [];
|
|
29564
|
+
let segment = "";
|
|
29565
|
+
for (let i = 0; i < string4.length; i++) {
|
|
29566
|
+
let char = string4.charAt(i);
|
|
29567
|
+
if (!legacyPaths && char === "\\") {
|
|
29568
|
+
const escaped = string4.charAt(i + 1);
|
|
29569
|
+
if (escaped === "\\") {
|
|
29570
|
+
segment += "\\";
|
|
29571
|
+
i++;
|
|
29572
|
+
continue;
|
|
29573
|
+
} else if (escaped !== ".") {
|
|
29574
|
+
throw Error("invalid path");
|
|
29575
|
+
}
|
|
29576
|
+
}
|
|
29577
|
+
const isEscapedDot = char === "\\" && string4.charAt(i + 1) === ".";
|
|
29578
|
+
if (isEscapedDot) {
|
|
29579
|
+
segment += ".";
|
|
29580
|
+
i++;
|
|
29581
|
+
continue;
|
|
29582
|
+
}
|
|
29583
|
+
const isEndOfSegment = char === ".";
|
|
29584
|
+
if (isEndOfSegment) {
|
|
29585
|
+
result.push(segment);
|
|
29586
|
+
segment = "";
|
|
29587
|
+
continue;
|
|
29588
|
+
}
|
|
29589
|
+
segment += char;
|
|
29590
|
+
}
|
|
29591
|
+
const lastSegment = segment;
|
|
29592
|
+
result.push(lastSegment);
|
|
29593
|
+
return result;
|
|
29594
|
+
};
|
|
29595
|
+
|
|
29596
|
+
// ../../../node_modules/superjson/dist/transformer.js
|
|
29597
|
+
function simpleTransformation(isApplicable, annotation, transform2, untransform) {
|
|
29598
|
+
return {
|
|
29599
|
+
isApplicable,
|
|
29600
|
+
annotation,
|
|
29601
|
+
transform: transform2,
|
|
29602
|
+
untransform
|
|
29603
|
+
};
|
|
29604
|
+
}
|
|
29605
|
+
var simpleRules = [
|
|
29606
|
+
simpleTransformation(isUndefined, "undefined", () => null, () => void 0),
|
|
29607
|
+
simpleTransformation(isBigint, "bigint", (v) => v.toString(), (v) => {
|
|
29608
|
+
if (typeof BigInt !== "undefined") {
|
|
29609
|
+
return BigInt(v);
|
|
29610
|
+
}
|
|
29611
|
+
console.error("Please add a BigInt polyfill.");
|
|
29612
|
+
return v;
|
|
29613
|
+
}),
|
|
29614
|
+
simpleTransformation(isDate, "Date", (v) => v.toISOString(), (v) => new Date(v)),
|
|
29615
|
+
simpleTransformation(isError, "Error", (v, superJson) => {
|
|
29616
|
+
const baseError = {
|
|
29617
|
+
name: v.name,
|
|
29618
|
+
message: v.message
|
|
29619
|
+
};
|
|
29620
|
+
if ("cause" in v) {
|
|
29621
|
+
baseError.cause = v.cause;
|
|
29622
|
+
}
|
|
29623
|
+
superJson.allowedErrorProps.forEach((prop) => {
|
|
29624
|
+
baseError[prop] = v[prop];
|
|
29625
|
+
});
|
|
29626
|
+
return baseError;
|
|
29627
|
+
}, (v, superJson) => {
|
|
29628
|
+
const e = new Error(v.message, { cause: v.cause });
|
|
29629
|
+
e.name = v.name;
|
|
29630
|
+
e.stack = v.stack;
|
|
29631
|
+
superJson.allowedErrorProps.forEach((prop) => {
|
|
29632
|
+
e[prop] = v[prop];
|
|
29633
|
+
});
|
|
29634
|
+
return e;
|
|
29635
|
+
}),
|
|
29636
|
+
simpleTransformation(isRegExp, "regexp", (v) => "" + v, (regex) => {
|
|
29637
|
+
const body = regex.slice(1, regex.lastIndexOf("/"));
|
|
29638
|
+
const flags = regex.slice(regex.lastIndexOf("/") + 1);
|
|
29639
|
+
return new RegExp(body, flags);
|
|
29640
|
+
}),
|
|
29641
|
+
simpleTransformation(
|
|
29642
|
+
isSet,
|
|
29643
|
+
"set",
|
|
29644
|
+
// (sets only exist in es6+)
|
|
29645
|
+
// eslint-disable-next-line es5/no-es6-methods
|
|
29646
|
+
(v) => [...v.values()],
|
|
29647
|
+
(v) => new Set(v)
|
|
29648
|
+
),
|
|
29649
|
+
simpleTransformation(isMap, "map", (v) => [...v.entries()], (v) => new Map(v)),
|
|
29650
|
+
simpleTransformation((v) => isNaNValue(v) || isInfinite(v), "number", (v) => {
|
|
29651
|
+
if (isNaNValue(v)) {
|
|
29652
|
+
return "NaN";
|
|
29653
|
+
}
|
|
29654
|
+
if (v > 0) {
|
|
29655
|
+
return "Infinity";
|
|
29656
|
+
} else {
|
|
29657
|
+
return "-Infinity";
|
|
29658
|
+
}
|
|
29659
|
+
}, Number),
|
|
29660
|
+
simpleTransformation((v) => v === 0 && 1 / v === -Infinity, "number", () => {
|
|
29661
|
+
return "-0";
|
|
29662
|
+
}, Number),
|
|
29663
|
+
simpleTransformation(isURL, "URL", (v) => v.toString(), (v) => new URL(v))
|
|
29664
|
+
];
|
|
29665
|
+
function compositeTransformation(isApplicable, annotation, transform2, untransform) {
|
|
29666
|
+
return {
|
|
29667
|
+
isApplicable,
|
|
29668
|
+
annotation,
|
|
29669
|
+
transform: transform2,
|
|
29670
|
+
untransform
|
|
29671
|
+
};
|
|
29672
|
+
}
|
|
29673
|
+
var symbolRule = compositeTransformation((s, superJson) => {
|
|
29674
|
+
if (isSymbol(s)) {
|
|
29675
|
+
const isRegistered = !!superJson.symbolRegistry.getIdentifier(s);
|
|
29676
|
+
return isRegistered;
|
|
29677
|
+
}
|
|
29678
|
+
return false;
|
|
29679
|
+
}, (s, superJson) => {
|
|
29680
|
+
const identifier = superJson.symbolRegistry.getIdentifier(s);
|
|
29681
|
+
return ["symbol", identifier];
|
|
29682
|
+
}, (v) => v.description, (_, a, superJson) => {
|
|
29683
|
+
const value = superJson.symbolRegistry.getValue(a[1]);
|
|
29684
|
+
if (!value) {
|
|
29685
|
+
throw new Error("Trying to deserialize unknown symbol");
|
|
29686
|
+
}
|
|
29687
|
+
return value;
|
|
29688
|
+
});
|
|
29689
|
+
var constructorToName = [
|
|
29690
|
+
Int8Array,
|
|
29691
|
+
Uint8Array,
|
|
29692
|
+
Int16Array,
|
|
29693
|
+
Uint16Array,
|
|
29694
|
+
Int32Array,
|
|
29695
|
+
Uint32Array,
|
|
29696
|
+
Float32Array,
|
|
29697
|
+
Float64Array,
|
|
29698
|
+
Uint8ClampedArray
|
|
29699
|
+
].reduce((obj, ctor) => {
|
|
29700
|
+
obj[ctor.name] = ctor;
|
|
29701
|
+
return obj;
|
|
29702
|
+
}, {});
|
|
29703
|
+
var typedArrayRule = compositeTransformation(isTypedArray, (v) => ["typed-array", v.constructor.name], (v) => [...v], (v, a) => {
|
|
29704
|
+
const ctor = constructorToName[a[1]];
|
|
29705
|
+
if (!ctor) {
|
|
29706
|
+
throw new Error("Trying to deserialize unknown typed array");
|
|
29707
|
+
}
|
|
29708
|
+
return new ctor(v);
|
|
29709
|
+
});
|
|
29710
|
+
function isInstanceOfRegisteredClass(potentialClass, superJson) {
|
|
29711
|
+
if (potentialClass?.constructor) {
|
|
29712
|
+
const isRegistered = !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
|
|
29713
|
+
return isRegistered;
|
|
29714
|
+
}
|
|
29715
|
+
return false;
|
|
29716
|
+
}
|
|
29717
|
+
var classRule = compositeTransformation(isInstanceOfRegisteredClass, (clazz, superJson) => {
|
|
29718
|
+
const identifier = superJson.classRegistry.getIdentifier(clazz.constructor);
|
|
29719
|
+
return ["class", identifier];
|
|
29720
|
+
}, (clazz, superJson) => {
|
|
29721
|
+
const allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor);
|
|
29722
|
+
if (!allowedProps) {
|
|
29723
|
+
return { ...clazz };
|
|
29724
|
+
}
|
|
29725
|
+
const result = {};
|
|
29726
|
+
allowedProps.forEach((prop) => {
|
|
29727
|
+
result[prop] = clazz[prop];
|
|
29728
|
+
});
|
|
29729
|
+
return result;
|
|
29730
|
+
}, (v, a, superJson) => {
|
|
29731
|
+
const clazz = superJson.classRegistry.getValue(a[1]);
|
|
29732
|
+
if (!clazz) {
|
|
29733
|
+
throw new Error(`Trying to deserialize unknown class '${a[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
|
|
29734
|
+
}
|
|
29735
|
+
return Object.assign(Object.create(clazz.prototype), v);
|
|
29736
|
+
});
|
|
29737
|
+
var customRule = compositeTransformation((value, superJson) => {
|
|
29738
|
+
return !!superJson.customTransformerRegistry.findApplicable(value);
|
|
29739
|
+
}, (value, superJson) => {
|
|
29740
|
+
const transformer = superJson.customTransformerRegistry.findApplicable(value);
|
|
29741
|
+
return ["custom", transformer.name];
|
|
29742
|
+
}, (value, superJson) => {
|
|
29743
|
+
const transformer = superJson.customTransformerRegistry.findApplicable(value);
|
|
29744
|
+
return transformer.serialize(value);
|
|
29745
|
+
}, (v, a, superJson) => {
|
|
29746
|
+
const transformer = superJson.customTransformerRegistry.findByName(a[1]);
|
|
29747
|
+
if (!transformer) {
|
|
29748
|
+
throw new Error("Trying to deserialize unknown custom value");
|
|
29749
|
+
}
|
|
29750
|
+
return transformer.deserialize(v);
|
|
29751
|
+
});
|
|
29752
|
+
var compositeRules = [classRule, symbolRule, customRule, typedArrayRule];
|
|
29753
|
+
var transformValue = (value, superJson) => {
|
|
29754
|
+
const applicableCompositeRule = findArr(compositeRules, (rule) => rule.isApplicable(value, superJson));
|
|
29755
|
+
if (applicableCompositeRule) {
|
|
29756
|
+
return {
|
|
29757
|
+
value: applicableCompositeRule.transform(value, superJson),
|
|
29758
|
+
type: applicableCompositeRule.annotation(value, superJson)
|
|
29759
|
+
};
|
|
29760
|
+
}
|
|
29761
|
+
const applicableSimpleRule = findArr(simpleRules, (rule) => rule.isApplicable(value, superJson));
|
|
29762
|
+
if (applicableSimpleRule) {
|
|
29763
|
+
return {
|
|
29764
|
+
value: applicableSimpleRule.transform(value, superJson),
|
|
29765
|
+
type: applicableSimpleRule.annotation
|
|
29766
|
+
};
|
|
29767
|
+
}
|
|
29768
|
+
return void 0;
|
|
29769
|
+
};
|
|
29770
|
+
var simpleRulesByAnnotation = {};
|
|
29771
|
+
simpleRules.forEach((rule) => {
|
|
29772
|
+
simpleRulesByAnnotation[rule.annotation] = rule;
|
|
29773
|
+
});
|
|
29774
|
+
var untransformValue = (json2, type, superJson) => {
|
|
29775
|
+
if (isArray(type)) {
|
|
29776
|
+
switch (type[0]) {
|
|
29777
|
+
case "symbol":
|
|
29778
|
+
return symbolRule.untransform(json2, type, superJson);
|
|
29779
|
+
case "class":
|
|
29780
|
+
return classRule.untransform(json2, type, superJson);
|
|
29781
|
+
case "custom":
|
|
29782
|
+
return customRule.untransform(json2, type, superJson);
|
|
29783
|
+
case "typed-array":
|
|
29784
|
+
return typedArrayRule.untransform(json2, type, superJson);
|
|
29785
|
+
default:
|
|
29786
|
+
throw new Error("Unknown transformation: " + type);
|
|
29787
|
+
}
|
|
29788
|
+
} else {
|
|
29789
|
+
const transformation = simpleRulesByAnnotation[type];
|
|
29790
|
+
if (!transformation) {
|
|
29791
|
+
throw new Error("Unknown transformation: " + type);
|
|
29792
|
+
}
|
|
29793
|
+
return transformation.untransform(json2, superJson);
|
|
29794
|
+
}
|
|
29795
|
+
};
|
|
29796
|
+
|
|
29797
|
+
// ../../../node_modules/superjson/dist/accessDeep.js
|
|
29798
|
+
var getNthKey = (value, n) => {
|
|
29799
|
+
if (n > value.size)
|
|
29800
|
+
throw new Error("index out of bounds");
|
|
29801
|
+
const keys = value.keys();
|
|
29802
|
+
while (n > 0) {
|
|
29803
|
+
keys.next();
|
|
29804
|
+
n--;
|
|
29805
|
+
}
|
|
29806
|
+
return keys.next().value;
|
|
29807
|
+
};
|
|
29808
|
+
function validatePath(path9) {
|
|
29809
|
+
if (includes(path9, "__proto__")) {
|
|
29810
|
+
throw new Error("__proto__ is not allowed as a property");
|
|
29811
|
+
}
|
|
29812
|
+
if (includes(path9, "prototype")) {
|
|
29813
|
+
throw new Error("prototype is not allowed as a property");
|
|
29814
|
+
}
|
|
29815
|
+
if (includes(path9, "constructor")) {
|
|
29816
|
+
throw new Error("constructor is not allowed as a property");
|
|
29817
|
+
}
|
|
29818
|
+
}
|
|
29819
|
+
var getDeep = (object2, path9) => {
|
|
29820
|
+
validatePath(path9);
|
|
29821
|
+
for (let i = 0; i < path9.length; i++) {
|
|
29822
|
+
const key = path9[i];
|
|
29823
|
+
if (isSet(object2)) {
|
|
29824
|
+
object2 = getNthKey(object2, +key);
|
|
29825
|
+
} else if (isMap(object2)) {
|
|
29826
|
+
const row = +key;
|
|
29827
|
+
const type = +path9[++i] === 0 ? "key" : "value";
|
|
29828
|
+
const keyOfRow = getNthKey(object2, row);
|
|
29829
|
+
switch (type) {
|
|
29830
|
+
case "key":
|
|
29831
|
+
object2 = keyOfRow;
|
|
29832
|
+
break;
|
|
29833
|
+
case "value":
|
|
29834
|
+
object2 = object2.get(keyOfRow);
|
|
29835
|
+
break;
|
|
29836
|
+
}
|
|
29837
|
+
} else {
|
|
29838
|
+
object2 = object2[key];
|
|
29839
|
+
}
|
|
29840
|
+
}
|
|
29841
|
+
return object2;
|
|
29842
|
+
};
|
|
29843
|
+
var setDeep = (object2, path9, mapper) => {
|
|
29844
|
+
validatePath(path9);
|
|
29845
|
+
if (path9.length === 0) {
|
|
29846
|
+
return mapper(object2);
|
|
29847
|
+
}
|
|
29848
|
+
let parent = object2;
|
|
29849
|
+
for (let i = 0; i < path9.length - 1; i++) {
|
|
29850
|
+
const key = path9[i];
|
|
29851
|
+
if (isArray(parent)) {
|
|
29852
|
+
const index = +key;
|
|
29853
|
+
parent = parent[index];
|
|
29854
|
+
} else if (isPlainObject2(parent)) {
|
|
29855
|
+
parent = parent[key];
|
|
29856
|
+
} else if (isSet(parent)) {
|
|
29857
|
+
const row = +key;
|
|
29858
|
+
parent = getNthKey(parent, row);
|
|
29859
|
+
} else if (isMap(parent)) {
|
|
29860
|
+
const isEnd = i === path9.length - 2;
|
|
29861
|
+
if (isEnd) {
|
|
29862
|
+
break;
|
|
29863
|
+
}
|
|
29864
|
+
const row = +key;
|
|
29865
|
+
const type = +path9[++i] === 0 ? "key" : "value";
|
|
29866
|
+
const keyOfRow = getNthKey(parent, row);
|
|
29867
|
+
switch (type) {
|
|
29868
|
+
case "key":
|
|
29869
|
+
parent = keyOfRow;
|
|
29870
|
+
break;
|
|
29871
|
+
case "value":
|
|
29872
|
+
parent = parent.get(keyOfRow);
|
|
29873
|
+
break;
|
|
29874
|
+
}
|
|
29875
|
+
}
|
|
29876
|
+
}
|
|
29877
|
+
const lastKey = path9[path9.length - 1];
|
|
29878
|
+
if (isArray(parent)) {
|
|
29879
|
+
parent[+lastKey] = mapper(parent[+lastKey]);
|
|
29880
|
+
} else if (isPlainObject2(parent)) {
|
|
29881
|
+
parent[lastKey] = mapper(parent[lastKey]);
|
|
29882
|
+
}
|
|
29883
|
+
if (isSet(parent)) {
|
|
29884
|
+
const oldValue = getNthKey(parent, +lastKey);
|
|
29885
|
+
const newValue = mapper(oldValue);
|
|
29886
|
+
if (oldValue !== newValue) {
|
|
29887
|
+
parent.delete(oldValue);
|
|
29888
|
+
parent.add(newValue);
|
|
29889
|
+
}
|
|
29890
|
+
}
|
|
29891
|
+
if (isMap(parent)) {
|
|
29892
|
+
const row = +path9[path9.length - 2];
|
|
29893
|
+
const keyToRow = getNthKey(parent, row);
|
|
29894
|
+
const type = +lastKey === 0 ? "key" : "value";
|
|
29895
|
+
switch (type) {
|
|
29896
|
+
case "key": {
|
|
29897
|
+
const newKey = mapper(keyToRow);
|
|
29898
|
+
parent.set(newKey, parent.get(keyToRow));
|
|
29899
|
+
if (newKey !== keyToRow) {
|
|
29900
|
+
parent.delete(keyToRow);
|
|
29901
|
+
}
|
|
29902
|
+
break;
|
|
29903
|
+
}
|
|
29904
|
+
case "value": {
|
|
29905
|
+
parent.set(keyToRow, mapper(parent.get(keyToRow)));
|
|
29906
|
+
break;
|
|
29907
|
+
}
|
|
29908
|
+
}
|
|
29909
|
+
}
|
|
29910
|
+
return object2;
|
|
29911
|
+
};
|
|
29912
|
+
|
|
29913
|
+
// ../../../node_modules/superjson/dist/plainer.js
|
|
29914
|
+
var enableLegacyPaths = (version2) => version2 < 1;
|
|
29915
|
+
function traverse(tree, walker2, version2, origin = []) {
|
|
29916
|
+
if (!tree) {
|
|
29917
|
+
return;
|
|
29918
|
+
}
|
|
29919
|
+
const legacyPaths = enableLegacyPaths(version2);
|
|
29920
|
+
if (!isArray(tree)) {
|
|
29921
|
+
forEach(tree, (subtree, key) => traverse(subtree, walker2, version2, [
|
|
29922
|
+
...origin,
|
|
29923
|
+
...parsePath(key, legacyPaths)
|
|
29924
|
+
]));
|
|
29925
|
+
return;
|
|
29926
|
+
}
|
|
29927
|
+
const [nodeValue, children] = tree;
|
|
29928
|
+
if (children) {
|
|
29929
|
+
forEach(children, (child, key) => {
|
|
29930
|
+
traverse(child, walker2, version2, [
|
|
29931
|
+
...origin,
|
|
29932
|
+
...parsePath(key, legacyPaths)
|
|
29933
|
+
]);
|
|
29934
|
+
});
|
|
29935
|
+
}
|
|
29936
|
+
walker2(nodeValue, origin);
|
|
29937
|
+
}
|
|
29938
|
+
function applyValueAnnotations(plain, annotations, version2, superJson) {
|
|
29939
|
+
traverse(annotations, (type, path9) => {
|
|
29940
|
+
plain = setDeep(plain, path9, (v) => untransformValue(v, type, superJson));
|
|
29941
|
+
}, version2);
|
|
29942
|
+
return plain;
|
|
29943
|
+
}
|
|
29944
|
+
function applyReferentialEqualityAnnotations(plain, annotations, version2) {
|
|
29945
|
+
const legacyPaths = enableLegacyPaths(version2);
|
|
29946
|
+
function apply(identicalPaths, path9) {
|
|
29947
|
+
const object2 = getDeep(plain, parsePath(path9, legacyPaths));
|
|
29948
|
+
identicalPaths.map((path10) => parsePath(path10, legacyPaths)).forEach((identicalObjectPath) => {
|
|
29949
|
+
plain = setDeep(plain, identicalObjectPath, () => object2);
|
|
29950
|
+
});
|
|
29951
|
+
}
|
|
29952
|
+
if (isArray(annotations)) {
|
|
29953
|
+
const [root, other] = annotations;
|
|
29954
|
+
root.forEach((identicalPath) => {
|
|
29955
|
+
plain = setDeep(plain, parsePath(identicalPath, legacyPaths), () => plain);
|
|
29956
|
+
});
|
|
29957
|
+
if (other) {
|
|
29958
|
+
forEach(other, apply);
|
|
29959
|
+
}
|
|
29960
|
+
} else {
|
|
29961
|
+
forEach(annotations, apply);
|
|
29962
|
+
}
|
|
29963
|
+
return plain;
|
|
29964
|
+
}
|
|
29965
|
+
var isDeep = (object2, superJson) => isPlainObject2(object2) || isArray(object2) || isMap(object2) || isSet(object2) || isError(object2) || isInstanceOfRegisteredClass(object2, superJson);
|
|
29966
|
+
function addIdentity(object2, path9, identities) {
|
|
29967
|
+
const existingSet = identities.get(object2);
|
|
29968
|
+
if (existingSet) {
|
|
29969
|
+
existingSet.push(path9);
|
|
29970
|
+
} else {
|
|
29971
|
+
identities.set(object2, [path9]);
|
|
29972
|
+
}
|
|
29973
|
+
}
|
|
29974
|
+
function generateReferentialEqualityAnnotations(identitites, dedupe) {
|
|
29975
|
+
const result = {};
|
|
29976
|
+
let rootEqualityPaths = void 0;
|
|
29977
|
+
identitites.forEach((paths) => {
|
|
29978
|
+
if (paths.length <= 1) {
|
|
29979
|
+
return;
|
|
29980
|
+
}
|
|
29981
|
+
if (!dedupe) {
|
|
29982
|
+
paths = paths.map((path9) => path9.map(String)).sort((a, b) => a.length - b.length);
|
|
29983
|
+
}
|
|
29984
|
+
const [representativePath, ...identicalPaths] = paths;
|
|
29985
|
+
if (representativePath.length === 0) {
|
|
29986
|
+
rootEqualityPaths = identicalPaths.map(stringifyPath);
|
|
29987
|
+
} else {
|
|
29988
|
+
result[stringifyPath(representativePath)] = identicalPaths.map(stringifyPath);
|
|
29989
|
+
}
|
|
29990
|
+
});
|
|
29991
|
+
if (rootEqualityPaths) {
|
|
29992
|
+
if (isEmptyObject(result)) {
|
|
29993
|
+
return [rootEqualityPaths];
|
|
29994
|
+
} else {
|
|
29995
|
+
return [rootEqualityPaths, result];
|
|
29996
|
+
}
|
|
29997
|
+
} else {
|
|
29998
|
+
return isEmptyObject(result) ? void 0 : result;
|
|
29999
|
+
}
|
|
30000
|
+
}
|
|
30001
|
+
var walker = (object2, identities, superJson, dedupe, path9 = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
|
|
30002
|
+
const primitive = isPrimitive(object2);
|
|
30003
|
+
if (!primitive) {
|
|
30004
|
+
addIdentity(object2, path9, identities);
|
|
30005
|
+
const seen = seenObjects.get(object2);
|
|
30006
|
+
if (seen) {
|
|
30007
|
+
return dedupe ? {
|
|
30008
|
+
transformedValue: null
|
|
30009
|
+
} : seen;
|
|
30010
|
+
}
|
|
30011
|
+
}
|
|
30012
|
+
if (!isDeep(object2, superJson)) {
|
|
30013
|
+
const transformed2 = transformValue(object2, superJson);
|
|
30014
|
+
const result2 = transformed2 ? {
|
|
30015
|
+
transformedValue: transformed2.value,
|
|
30016
|
+
annotations: [transformed2.type]
|
|
30017
|
+
} : {
|
|
30018
|
+
transformedValue: object2
|
|
30019
|
+
};
|
|
30020
|
+
if (!primitive) {
|
|
30021
|
+
seenObjects.set(object2, result2);
|
|
30022
|
+
}
|
|
30023
|
+
return result2;
|
|
30024
|
+
}
|
|
30025
|
+
if (includes(objectsInThisPath, object2)) {
|
|
30026
|
+
return {
|
|
30027
|
+
transformedValue: null
|
|
30028
|
+
};
|
|
30029
|
+
}
|
|
30030
|
+
const transformationResult = transformValue(object2, superJson);
|
|
30031
|
+
const transformed = transformationResult?.value ?? object2;
|
|
30032
|
+
const transformedValue = isArray(transformed) ? [] : {};
|
|
30033
|
+
const innerAnnotations = {};
|
|
30034
|
+
forEach(transformed, (value, index) => {
|
|
30035
|
+
if (index === "__proto__" || index === "constructor" || index === "prototype") {
|
|
30036
|
+
throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
|
|
30037
|
+
}
|
|
30038
|
+
const recursiveResult = walker(value, identities, superJson, dedupe, [...path9, index], [...objectsInThisPath, object2], seenObjects);
|
|
30039
|
+
transformedValue[index] = recursiveResult.transformedValue;
|
|
30040
|
+
if (isArray(recursiveResult.annotations)) {
|
|
30041
|
+
innerAnnotations[escapeKey(index)] = recursiveResult.annotations;
|
|
30042
|
+
} else if (isPlainObject2(recursiveResult.annotations)) {
|
|
30043
|
+
forEach(recursiveResult.annotations, (tree, key) => {
|
|
30044
|
+
innerAnnotations[escapeKey(index) + "." + key] = tree;
|
|
30045
|
+
});
|
|
30046
|
+
}
|
|
30047
|
+
});
|
|
30048
|
+
const result = isEmptyObject(innerAnnotations) ? {
|
|
30049
|
+
transformedValue,
|
|
30050
|
+
annotations: !!transformationResult ? [transformationResult.type] : void 0
|
|
30051
|
+
} : {
|
|
30052
|
+
transformedValue,
|
|
30053
|
+
annotations: !!transformationResult ? [transformationResult.type, innerAnnotations] : innerAnnotations
|
|
30054
|
+
};
|
|
30055
|
+
if (!primitive) {
|
|
30056
|
+
seenObjects.set(object2, result);
|
|
30057
|
+
}
|
|
30058
|
+
return result;
|
|
30059
|
+
};
|
|
30060
|
+
|
|
30061
|
+
// ../../../node_modules/is-what/dist/getType.js
|
|
30062
|
+
function getType2(payload) {
|
|
30063
|
+
return Object.prototype.toString.call(payload).slice(8, -1);
|
|
30064
|
+
}
|
|
30065
|
+
|
|
30066
|
+
// ../../../node_modules/is-what/dist/isArray.js
|
|
30067
|
+
function isArray2(payload) {
|
|
30068
|
+
return getType2(payload) === "Array";
|
|
30069
|
+
}
|
|
30070
|
+
|
|
30071
|
+
// ../../../node_modules/is-what/dist/isPlainObject.js
|
|
30072
|
+
function isPlainObject3(payload) {
|
|
30073
|
+
if (getType2(payload) !== "Object")
|
|
30074
|
+
return false;
|
|
30075
|
+
const prototype = Object.getPrototypeOf(payload);
|
|
30076
|
+
return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
|
|
30077
|
+
}
|
|
30078
|
+
|
|
30079
|
+
// ../../../node_modules/copy-anything/dist/index.js
|
|
30080
|
+
function assignProp2(carry, key, newVal, originalObject, includeNonenumerable) {
|
|
30081
|
+
const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
|
|
30082
|
+
if (propType === "enumerable")
|
|
30083
|
+
carry[key] = newVal;
|
|
30084
|
+
if (includeNonenumerable && propType === "nonenumerable") {
|
|
30085
|
+
Object.defineProperty(carry, key, {
|
|
30086
|
+
value: newVal,
|
|
30087
|
+
enumerable: false,
|
|
30088
|
+
writable: true,
|
|
30089
|
+
configurable: true
|
|
30090
|
+
});
|
|
30091
|
+
}
|
|
30092
|
+
}
|
|
30093
|
+
function copy2(target2, options = {}) {
|
|
30094
|
+
if (isArray2(target2)) {
|
|
30095
|
+
return target2.map((item) => copy2(item, options));
|
|
30096
|
+
}
|
|
30097
|
+
if (!isPlainObject3(target2)) {
|
|
30098
|
+
return target2;
|
|
30099
|
+
}
|
|
30100
|
+
const props = Object.getOwnPropertyNames(target2);
|
|
30101
|
+
const symbols = Object.getOwnPropertySymbols(target2);
|
|
30102
|
+
return [...props, ...symbols].reduce((carry, key) => {
|
|
30103
|
+
if (key === "__proto__")
|
|
30104
|
+
return carry;
|
|
30105
|
+
if (isArray2(options.props) && !options.props.includes(key)) {
|
|
30106
|
+
return carry;
|
|
30107
|
+
}
|
|
30108
|
+
const val = target2[key];
|
|
30109
|
+
const newVal = copy2(val, options);
|
|
30110
|
+
assignProp2(carry, key, newVal, target2, options.nonenumerable);
|
|
30111
|
+
return carry;
|
|
30112
|
+
}, {});
|
|
30113
|
+
}
|
|
30114
|
+
|
|
30115
|
+
// ../../../node_modules/superjson/dist/index.js
|
|
30116
|
+
var SuperJSON = class {
|
|
30117
|
+
/**
|
|
30118
|
+
* @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
|
|
30119
|
+
*/
|
|
30120
|
+
constructor({ dedupe = false } = {}) {
|
|
30121
|
+
this.classRegistry = new ClassRegistry();
|
|
30122
|
+
this.symbolRegistry = new Registry((s) => s.description ?? "");
|
|
30123
|
+
this.customTransformerRegistry = new CustomTransformerRegistry();
|
|
30124
|
+
this.allowedErrorProps = [];
|
|
30125
|
+
this.dedupe = dedupe;
|
|
30126
|
+
}
|
|
30127
|
+
serialize(object2) {
|
|
30128
|
+
const identities = /* @__PURE__ */ new Map();
|
|
30129
|
+
const output2 = walker(object2, identities, this, this.dedupe);
|
|
30130
|
+
const res = {
|
|
30131
|
+
json: output2.transformedValue
|
|
30132
|
+
};
|
|
30133
|
+
if (output2.annotations) {
|
|
30134
|
+
res.meta = {
|
|
30135
|
+
...res.meta,
|
|
30136
|
+
values: output2.annotations
|
|
30137
|
+
};
|
|
30138
|
+
}
|
|
30139
|
+
const equalityAnnotations = generateReferentialEqualityAnnotations(identities, this.dedupe);
|
|
30140
|
+
if (equalityAnnotations) {
|
|
30141
|
+
res.meta = {
|
|
30142
|
+
...res.meta,
|
|
30143
|
+
referentialEqualities: equalityAnnotations
|
|
30144
|
+
};
|
|
30145
|
+
}
|
|
30146
|
+
if (res.meta)
|
|
30147
|
+
res.meta.v = 1;
|
|
30148
|
+
return res;
|
|
30149
|
+
}
|
|
30150
|
+
deserialize(payload, options) {
|
|
30151
|
+
const { json: json2, meta: meta3 } = payload;
|
|
30152
|
+
let result = options?.inPlace ? json2 : copy2(json2);
|
|
30153
|
+
if (meta3?.values) {
|
|
30154
|
+
result = applyValueAnnotations(result, meta3.values, meta3.v ?? 0, this);
|
|
30155
|
+
}
|
|
30156
|
+
if (meta3?.referentialEqualities) {
|
|
30157
|
+
result = applyReferentialEqualityAnnotations(result, meta3.referentialEqualities, meta3.v ?? 0);
|
|
30158
|
+
}
|
|
30159
|
+
return result;
|
|
30160
|
+
}
|
|
30161
|
+
stringify(object2) {
|
|
30162
|
+
return JSON.stringify(this.serialize(object2));
|
|
30163
|
+
}
|
|
30164
|
+
parse(string4) {
|
|
30165
|
+
return this.deserialize(JSON.parse(string4), { inPlace: true });
|
|
30166
|
+
}
|
|
30167
|
+
registerClass(v, options) {
|
|
30168
|
+
this.classRegistry.register(v, options);
|
|
30169
|
+
}
|
|
30170
|
+
registerSymbol(v, identifier) {
|
|
30171
|
+
this.symbolRegistry.register(v, identifier);
|
|
30172
|
+
}
|
|
30173
|
+
registerCustom(transformer, name) {
|
|
30174
|
+
this.customTransformerRegistry.register({
|
|
30175
|
+
name,
|
|
30176
|
+
...transformer
|
|
30177
|
+
});
|
|
30178
|
+
}
|
|
30179
|
+
allowErrorProps(...props) {
|
|
30180
|
+
this.allowedErrorProps.push(...props);
|
|
30181
|
+
}
|
|
30182
|
+
};
|
|
30183
|
+
SuperJSON.defaultInstance = new SuperJSON();
|
|
30184
|
+
SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance);
|
|
30185
|
+
SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance);
|
|
30186
|
+
SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance);
|
|
30187
|
+
SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance);
|
|
30188
|
+
SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance);
|
|
30189
|
+
SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance);
|
|
30190
|
+
SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
|
|
30191
|
+
SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
|
|
30192
|
+
var dist_default = SuperJSON;
|
|
30193
|
+
var serialize = SuperJSON.serialize;
|
|
30194
|
+
var deserialize = SuperJSON.deserialize;
|
|
30195
|
+
var stringify = SuperJSON.stringify;
|
|
30196
|
+
var parse4 = SuperJSON.parse;
|
|
30197
|
+
var registerClass = SuperJSON.registerClass;
|
|
30198
|
+
var registerCustom = SuperJSON.registerCustom;
|
|
30199
|
+
var registerSymbol = SuperJSON.registerSymbol;
|
|
30200
|
+
var allowErrorProps = SuperJSON.allowErrorProps;
|
|
30201
|
+
|
|
30202
|
+
// ../../shared/trpc-server/src/trpc-transformer.ts
|
|
30203
|
+
var OBJECT_PROTO = Object.prototype;
|
|
30204
|
+
var ARRAY_PROTO = Array.prototype;
|
|
30205
|
+
function isPlainJsonData(value, seen) {
|
|
30206
|
+
switch (typeof value) {
|
|
30207
|
+
case "string":
|
|
30208
|
+
case "boolean":
|
|
30209
|
+
return true;
|
|
30210
|
+
case "number":
|
|
30211
|
+
return Number.isFinite(value) && !(value === 0 && 1 / value < 0);
|
|
30212
|
+
case "object":
|
|
30213
|
+
break;
|
|
30214
|
+
default:
|
|
30215
|
+
return false;
|
|
30216
|
+
}
|
|
30217
|
+
if (value === null) return true;
|
|
30218
|
+
if (seen.has(value)) return false;
|
|
30219
|
+
seen.add(value);
|
|
30220
|
+
const proto = Object.getPrototypeOf(value);
|
|
30221
|
+
if (Array.isArray(value)) {
|
|
30222
|
+
if (proto !== ARRAY_PROTO) return false;
|
|
30223
|
+
const arr = value;
|
|
30224
|
+
if (Object.keys(arr).length !== arr.length) return false;
|
|
30225
|
+
for (let i = 0; i < arr.length; i++) {
|
|
30226
|
+
if (!isPlainJsonData(arr[i], seen)) return false;
|
|
30227
|
+
}
|
|
30228
|
+
return true;
|
|
30229
|
+
}
|
|
30230
|
+
if (proto !== OBJECT_PROTO && proto !== null) return false;
|
|
30231
|
+
if (value === OBJECT_PROTO) return false;
|
|
30232
|
+
const obj = value;
|
|
30233
|
+
for (const key of Object.keys(obj)) {
|
|
30234
|
+
if (key === "__proto__" || key === "constructor" || key === "prototype") return false;
|
|
30235
|
+
if (!isPlainJsonData(obj[key], seen)) return false;
|
|
30236
|
+
}
|
|
30237
|
+
return true;
|
|
30238
|
+
}
|
|
30239
|
+
function serializeOutput(value) {
|
|
30240
|
+
if (isPlainJsonData(value, /* @__PURE__ */ new Set())) return { json: value };
|
|
30241
|
+
return dist_default.serialize(value);
|
|
30242
|
+
}
|
|
30243
|
+
var trpcTransformer = {
|
|
30244
|
+
input: dist_default,
|
|
30245
|
+
output: {
|
|
30246
|
+
serialize: serializeOutput,
|
|
30247
|
+
deserialize: dist_default.deserialize
|
|
30248
|
+
}
|
|
30249
|
+
};
|
|
30250
|
+
|
|
30251
|
+
// ../../shared/trpc-server/src/access-class.ts
|
|
30252
|
+
var ADMIN_ONLY = "ADMIN_ONLY";
|
|
30253
|
+
function roleAllows(cls, role) {
|
|
30254
|
+
if (role === "admin") return true;
|
|
30255
|
+
return cls === "user" || cls === "open";
|
|
30256
|
+
}
|
|
30257
|
+
|
|
30258
|
+
// ../../shared/trpc-server/src/admin-gate.ts
|
|
30259
|
+
var AdminOnlyError = class extends Error {
|
|
30260
|
+
constructor(target2) {
|
|
30261
|
+
super(`${target2} needs a hub admin account`);
|
|
30262
|
+
this.target = target2;
|
|
30263
|
+
this.name = "AdminOnlyError";
|
|
30264
|
+
}
|
|
30265
|
+
target;
|
|
30266
|
+
code = ADMIN_ONLY;
|
|
30267
|
+
};
|
|
30268
|
+
function isAdminOnlyError(err) {
|
|
30269
|
+
if (err instanceof AdminOnlyError) return true;
|
|
30270
|
+
return err instanceof Error && err.name === "AdminOnlyError" && err.code === ADMIN_ONLY;
|
|
30271
|
+
}
|
|
30272
|
+
function auditAdminDenied(opts) {
|
|
30273
|
+
securityEvent({
|
|
30274
|
+
event: "authz.denied",
|
|
30275
|
+
outcome: "denied",
|
|
30276
|
+
targetKind: opts.targetKind ?? null,
|
|
30277
|
+
targetId: opts.targetId ?? null,
|
|
30278
|
+
actor: opts.actor,
|
|
30279
|
+
ip: opts.ip,
|
|
30280
|
+
route: opts.route,
|
|
30281
|
+
detail: { reason: "not_admin", code: ADMIN_ONLY, ...opts.detail }
|
|
30282
|
+
});
|
|
30283
|
+
}
|
|
30284
|
+
function adminOnlyTrpcError(path9) {
|
|
30285
|
+
auditAdminDenied({ targetKind: "procedure", targetId: path9 });
|
|
30286
|
+
return new TRPCError({
|
|
30287
|
+
code: "FORBIDDEN",
|
|
30288
|
+
message: `${path9} needs a hub admin account`,
|
|
30289
|
+
cause: new AdminOnlyError(path9)
|
|
30290
|
+
});
|
|
30291
|
+
}
|
|
30292
|
+
|
|
30293
|
+
// ../../shared/trpc-server/src/app-codes.ts
|
|
30294
|
+
var extractors = [];
|
|
30295
|
+
function registeredAppCodes(cause) {
|
|
30296
|
+
let out = {};
|
|
30297
|
+
for (const extract of extractors) {
|
|
30298
|
+
const code = extract(cause);
|
|
30299
|
+
if (code !== void 0) out = { appCode: code };
|
|
30300
|
+
}
|
|
30301
|
+
return out;
|
|
30302
|
+
}
|
|
30303
|
+
|
|
30304
|
+
// ../../shared/trpc-server/src/procedure-policy.ts
|
|
30305
|
+
var registered = null;
|
|
30306
|
+
function procedurePolicy() {
|
|
30307
|
+
if (!registered) {
|
|
30308
|
+
throw new Error(
|
|
30309
|
+
"tRPC procedure policy not registered: import the composition (@slayzone/api router.ts) before serving"
|
|
30310
|
+
);
|
|
30311
|
+
}
|
|
30312
|
+
return registered;
|
|
30313
|
+
}
|
|
30314
|
+
|
|
30315
|
+
// ../../shared/trpc-server/src/trpc.ts
|
|
30316
|
+
var t = initTRPC.context().create({
|
|
30317
|
+
// superjson on the wire; responses skip superjson's walk when they are plain
|
|
30318
|
+
// JSON data (byte-identical output) — see trpc-transformer.ts.
|
|
30319
|
+
transformer: trpcTransformer,
|
|
30320
|
+
// A hub-switch refusal carries its stable code (`HUB_PROCESSES_DISABLED`, …) to the
|
|
30321
|
+
// client as `data.appCode`; every other error keeps its shape exactly.
|
|
30322
|
+
errorFormatter: ({ shape, error: error62 }) => ({
|
|
30323
|
+
...shape,
|
|
30324
|
+
data: {
|
|
30325
|
+
...shape.data,
|
|
30326
|
+
...isHubSwitchedOffError(error62.cause) ? { appCode: error62.cause.code } : {},
|
|
30327
|
+
// A role refusal (T-15) carries `ADMIN_ONLY` the same way.
|
|
30328
|
+
...isAdminOnlyError(error62.cause) ? { appCode: ADMIN_ONLY } : {},
|
|
30329
|
+
// An id refused as a path segment (T-104): `INVALID_ID` / `PATH_OUTSIDE_BASE`.
|
|
30330
|
+
...isUnsafePathError(error62.cause) ? { appCode: error62.cause.code } : {},
|
|
30331
|
+
// A domain's own refusal, registered by the module defining its error (see
|
|
30332
|
+
// app-codes.ts) — e.g. a refused join-token mint (T-20, `@slayzone/api`'s
|
|
30333
|
+
// join-token-policy.ts): `JOIN_TOKEN_OWNER_REQUIRED`, `…_TTL_TOO_LONG`, ….
|
|
30334
|
+
...registeredAppCodes(error62.cause)
|
|
30335
|
+
}
|
|
30336
|
+
})
|
|
30337
|
+
});
|
|
30338
|
+
var router = t.router;
|
|
30339
|
+
var middleware = t.middleware;
|
|
30340
|
+
var mergeRouters2 = t.mergeRouters;
|
|
30341
|
+
var securityContext = t.middleware(
|
|
30342
|
+
({ ctx, next, path: path9 }) => runWithSecurityContext(
|
|
30343
|
+
{ actor: ctx.principal?.userId ?? null, ip: peerAddress(ctx.req), route: `trpc ${path9}` },
|
|
30344
|
+
() => next()
|
|
30345
|
+
)
|
|
30346
|
+
);
|
|
30347
|
+
function auditDenied(path9, detail) {
|
|
30348
|
+
securityEvent({
|
|
30349
|
+
event: "authz.denied",
|
|
30350
|
+
outcome: "denied",
|
|
30351
|
+
targetKind: "procedure",
|
|
30352
|
+
targetId: path9,
|
|
30353
|
+
detail
|
|
30354
|
+
});
|
|
30355
|
+
}
|
|
30356
|
+
var authGate2 = t.middleware(({ ctx, next, path: path9 }) => {
|
|
30357
|
+
if (getAuthGate() && !ctx.principal) {
|
|
30358
|
+
auditDenied(path9, { reason: "unauthenticated" });
|
|
30359
|
+
throw new TRPCError({ code: "UNAUTHORIZED", message: "hub requires authentication" });
|
|
30360
|
+
}
|
|
30361
|
+
return next();
|
|
30362
|
+
});
|
|
30363
|
+
var scopeGate = t.middleware(({ ctx, next, path: path9 }) => {
|
|
30364
|
+
if (!getAuthGate()) return next();
|
|
30365
|
+
const scopes = ctx.principal?.scopes ?? [];
|
|
30366
|
+
if (!procedurePolicy().scopeAllows(scopes, path9)) {
|
|
30367
|
+
auditDenied(path9, { reason: "scope", scopes });
|
|
30368
|
+
throw new TRPCError({ code: "FORBIDDEN", message: `insufficient scope for ${path9}` });
|
|
30369
|
+
}
|
|
30370
|
+
return next();
|
|
30371
|
+
});
|
|
30372
|
+
var adminGate = t.middleware(({ ctx, next, path: path9 }) => {
|
|
30373
|
+
if (!getAuthGate()) return next();
|
|
30374
|
+
if (!roleAllows(procedurePolicy().adminClassOf(path9), ctx.principal?.role ?? "user")) {
|
|
30375
|
+
throw adminOnlyTrpcError(path9);
|
|
30376
|
+
}
|
|
30377
|
+
return next();
|
|
30378
|
+
});
|
|
30379
|
+
var ownerGate = t.middleware(async ({ ctx, next, path: path9, type, getRawInput }) => {
|
|
30380
|
+
const filter = getAuthGate() ? await procedurePolicy().ownerCheck({ ctx, path: path9, type, getRawInput }) : null;
|
|
30381
|
+
const result = await next();
|
|
30382
|
+
if (!filter || !result.ok) return result;
|
|
30383
|
+
return { ...result, data: await filter(result.data) };
|
|
30384
|
+
});
|
|
30385
|
+
var switchRefusal = t.middleware(async ({ next }) => {
|
|
30386
|
+
const result = await next();
|
|
30387
|
+
if (!result.ok && isHubSwitchedOffError(result.error.cause)) {
|
|
30388
|
+
throw new TRPCError({
|
|
30389
|
+
code: "FORBIDDEN",
|
|
30390
|
+
message: result.error.cause.message,
|
|
30391
|
+
cause: result.error.cause
|
|
30392
|
+
});
|
|
30393
|
+
}
|
|
30394
|
+
return result;
|
|
30395
|
+
});
|
|
30396
|
+
var unsafePathRefusal = t.middleware(async ({ next }) => {
|
|
30397
|
+
const result = await next();
|
|
30398
|
+
if (!result.ok && isUnsafePathError(result.error.cause)) {
|
|
30399
|
+
throw new TRPCError({
|
|
30400
|
+
code: "BAD_REQUEST",
|
|
30401
|
+
message: result.error.cause.message,
|
|
30402
|
+
cause: result.error.cause
|
|
30403
|
+
});
|
|
30404
|
+
}
|
|
30405
|
+
return result;
|
|
30406
|
+
});
|
|
30407
|
+
var publicProcedure = t.procedure.use(securityContext).use(authGate2).use(adminGate).use(scopeGate).use(ownerGate).use(switchRefusal).use(unsafePathRefusal);
|
|
30408
|
+
var hubLocalProcedure = publicProcedure.use(({ next, path: path9 }) => {
|
|
30409
|
+
assertHubLocalExecEnabled({ op: path9 });
|
|
30410
|
+
return next();
|
|
30411
|
+
});
|
|
30412
|
+
var openProcedure = t.procedure.use(securityContext);
|
|
30413
|
+
|
|
30414
|
+
// ../../domains/file-editor/src/server/file-editor-router-deps.ts
|
|
30415
|
+
var deps = null;
|
|
30416
|
+
function getFileEditorRouterDeps() {
|
|
30417
|
+
if (!deps)
|
|
30418
|
+
throw new Error(
|
|
30419
|
+
"fileEditor router deps not initialized \u2014 @slayzone/api wires them when it composes the router"
|
|
30420
|
+
);
|
|
30421
|
+
return deps;
|
|
30422
|
+
}
|
|
30423
|
+
|
|
30424
|
+
// ../../domains/file-editor/src/server/file-editor-router.ts
|
|
30425
|
+
var searchOptions = external_exports.unknown();
|
|
30426
|
+
var target = {
|
|
30427
|
+
computerId: external_exports.string().nullable().optional(),
|
|
30428
|
+
taskId: external_exports.string().optional(),
|
|
30429
|
+
projectId: external_exports.string().optional()
|
|
30430
|
+
};
|
|
30431
|
+
var resolve5 = (input2) => getWorkspaceDeps().resolveComputer(input2);
|
|
30432
|
+
var fs5 = () => getWorkspaceDeps().fs;
|
|
30433
|
+
var fileEditorRouter = router({
|
|
30434
|
+
readDir: publicProcedure.input(external_exports.object({ ...target, rootPath: external_exports.string(), dirPath: external_exports.string() })).query(async ({ input: input2 }) => fs5().readDir(await resolve5(input2), input2.rootPath, input2.dirPath)),
|
|
30435
|
+
readFile: publicProcedure.input(
|
|
30436
|
+
external_exports.object({
|
|
30437
|
+
...target,
|
|
30438
|
+
rootPath: external_exports.string(),
|
|
30439
|
+
filePath: external_exports.string(),
|
|
30440
|
+
force: external_exports.boolean().optional()
|
|
30441
|
+
})
|
|
30442
|
+
).query(
|
|
30443
|
+
async ({ input: input2 }) => fs5().readFile(await resolve5(input2), input2.rootPath, input2.filePath, input2.force)
|
|
30444
|
+
),
|
|
30445
|
+
/**
|
|
30446
|
+
* Whole-tree read, capped at the transport layer. `truncated` is preserved
|
|
30447
|
+
* rather than dropped: a partial tree presented as complete is how a
|
|
30448
|
+
* quick-open silently stops finding files.
|
|
30449
|
+
*/
|
|
30450
|
+
listAllFiles: publicProcedure.input(external_exports.object({ ...target, rootPath: external_exports.string() })).query(async ({ input: input2 }) => fs5().listAllFiles(await resolve5(input2), input2.rootPath)),
|
|
30451
|
+
writeFile: publicProcedure.input(external_exports.object({ ...target, rootPath: external_exports.string(), filePath: external_exports.string(), content: external_exports.string() })).mutation(async ({ input: input2 }) => {
|
|
30452
|
+
await fs5().writeFile(await resolve5(input2), input2.rootPath, input2.filePath, input2.content);
|
|
30453
|
+
}),
|
|
30454
|
+
createFile: publicProcedure.input(external_exports.object({ ...target, rootPath: external_exports.string(), filePath: external_exports.string() })).mutation(async ({ input: input2 }) => {
|
|
30455
|
+
await fs5().createFile(await resolve5(input2), input2.rootPath, input2.filePath);
|
|
30456
|
+
}),
|
|
30457
|
+
createDir: publicProcedure.input(external_exports.object({ ...target, rootPath: external_exports.string(), dirPath: external_exports.string() })).mutation(async ({ input: input2 }) => {
|
|
30458
|
+
await fs5().createDir(await resolve5(input2), input2.rootPath, input2.dirPath);
|
|
30459
|
+
}),
|
|
30460
|
+
rename: publicProcedure.input(external_exports.object({ ...target, rootPath: external_exports.string(), oldPath: external_exports.string(), newPath: external_exports.string() })).mutation(async ({ input: input2 }) => {
|
|
30461
|
+
await fs5().rename(await resolve5(input2), input2.rootPath, input2.oldPath, input2.newPath);
|
|
30462
|
+
}),
|
|
30463
|
+
delete: publicProcedure.input(external_exports.object({ ...target, rootPath: external_exports.string(), targetPath: external_exports.string() })).mutation(async ({ input: input2 }) => {
|
|
30464
|
+
await fs5().delete(await resolve5(input2), input2.rootPath, input2.targetPath);
|
|
30465
|
+
}),
|
|
30466
|
+
copyIn: publicProcedure.input(
|
|
30467
|
+
external_exports.object({
|
|
30468
|
+
...target,
|
|
30469
|
+
rootPath: external_exports.string(),
|
|
30470
|
+
absoluteSrc: external_exports.string(),
|
|
30471
|
+
targetDir: external_exports.string().optional()
|
|
30472
|
+
})
|
|
30473
|
+
).mutation(
|
|
30474
|
+
async ({ input: input2 }) => fs5().copyIn(await resolve5(input2), input2.rootPath, input2.absoluteSrc, input2.targetDir)
|
|
30475
|
+
),
|
|
30476
|
+
copy: publicProcedure.input(external_exports.object({ ...target, rootPath: external_exports.string(), srcPath: external_exports.string(), destPath: external_exports.string() })).mutation(async ({ input: input2 }) => {
|
|
30477
|
+
await fs5().copy(await resolve5(input2), input2.rootPath, input2.srcPath, input2.destPath);
|
|
30478
|
+
}),
|
|
30479
|
+
gitStatus: publicProcedure.input(external_exports.object({ ...target, rootPath: external_exports.string() })).query(async ({ input: input2 }) => fs5().gitStatus(await resolve5(input2), input2.rootPath)),
|
|
30480
|
+
searchFiles: publicProcedure.input(
|
|
30481
|
+
external_exports.object({
|
|
30482
|
+
...target,
|
|
30483
|
+
rootPath: external_exports.string(),
|
|
30484
|
+
query: external_exports.string(),
|
|
30485
|
+
options: searchOptions.optional()
|
|
30486
|
+
})
|
|
30487
|
+
).query(
|
|
30488
|
+
async ({ input: input2 }) => fs5().searchFiles(await resolve5(input2), input2.rootPath, input2.query, input2.options)
|
|
30489
|
+
),
|
|
30490
|
+
/**
|
|
30491
|
+
* Reveal in the OS file manager.
|
|
30492
|
+
*
|
|
30493
|
+
* Deliberately NOT routed. There is no Finder on a headless computer, and even if
|
|
30494
|
+
* there were, revealing a folder on a machine the user is not sitting at is not
|
|
30495
|
+
* the action they asked for. The path resolves against the DESKTOP, so the UI
|
|
30496
|
+
* should only offer this when the workspace is co-resident — the caller decides.
|
|
30497
|
+
*/
|
|
30498
|
+
showInFinder: publicProcedure.input(external_exports.object({ rootPath: external_exports.string(), targetPath: external_exports.string() })).mutation(async ({ input: input2 }) => {
|
|
30499
|
+
const path9 = await import("node:path");
|
|
30500
|
+
const abs = input2.targetPath ? path9.resolve(input2.rootPath, input2.targetPath) : path9.resolve(input2.rootPath);
|
|
30501
|
+
getFileEditorRouterDeps().shellShowItemInFolder(abs);
|
|
30502
|
+
}),
|
|
30503
|
+
/**
|
|
30504
|
+
* Subscribe to changes under rootPath.
|
|
30505
|
+
*
|
|
30506
|
+
* The source is the computer's watcher, streamed back as `fs.change` frames and
|
|
30507
|
+
* demuxed by a hub-minted watchId. A lost computer COMPLETES the stream rather
|
|
30508
|
+
* than going quiet, because a watcher that simply stops emitting is
|
|
30509
|
+
* indistinguishable from a directory that stopped changing — and the client
|
|
30510
|
+
* would keep showing a stale tree believing it was live.
|
|
30511
|
+
*/
|
|
30512
|
+
watch: publicProcedure.input(external_exports.object({ ...target, rootPath: external_exports.string() })).subscription(
|
|
30513
|
+
({ input: input2 }) => observable((emit) => {
|
|
30514
|
+
let dispose = null;
|
|
30515
|
+
let cancelled = false;
|
|
30516
|
+
resolve5(input2).then((computerId) => {
|
|
30517
|
+
if (cancelled) return;
|
|
30518
|
+
dispose = fs5().watch(computerId, input2.rootPath, (e) => emit.next(e));
|
|
30519
|
+
}).catch((err) => {
|
|
30520
|
+
if (cancelled) return;
|
|
30521
|
+
emit.error(
|
|
30522
|
+
isHubSwitchedOffError(err) ? new TRPCError({ code: "FORBIDDEN", message: err.message, cause: err }) : err
|
|
30523
|
+
);
|
|
30524
|
+
});
|
|
30525
|
+
return () => {
|
|
30526
|
+
cancelled = true;
|
|
30527
|
+
dispose?.();
|
|
30528
|
+
};
|
|
30529
|
+
})
|
|
30530
|
+
)
|
|
30531
|
+
});
|
|
30532
|
+
|
|
30533
|
+
// ../../domains/file-editor/src/server/workspace-router.ts
|
|
30534
|
+
var targetInput = external_exports.object({
|
|
30535
|
+
computerId: external_exports.string().nullable().optional(),
|
|
30536
|
+
taskId: external_exports.string().optional(),
|
|
30537
|
+
projectId: external_exports.string().optional()
|
|
30538
|
+
});
|
|
30539
|
+
function refusalCode(err) {
|
|
30540
|
+
return isHubSwitchedOffError(err) ? { code: err.code } : {};
|
|
30541
|
+
}
|
|
30542
|
+
var workspaceRouter = router({
|
|
30543
|
+
/**
|
|
30544
|
+
* Where browsing may start on the target machine, in that machine's idiom
|
|
30545
|
+
* (platform + separator), so the client never assumes POSIX or the desktop's OS.
|
|
30546
|
+
*
|
|
30547
|
+
* An empty `roots` array is a real, actionable state — a computer whose
|
|
30548
|
+
* `allowedRoots` is unconfigured refuses all filesystem access — and must be
|
|
30549
|
+
* surfaced as such rather than rendered as an empty directory.
|
|
30550
|
+
*/
|
|
30551
|
+
listRoots: publicProcedure.input(targetInput).query(async ({ input: input2 }) => {
|
|
30552
|
+
const { fs: fs7, resolveComputer, isLocalComputer } = getWorkspaceDeps();
|
|
30553
|
+
const computerId = await resolveComputer(input2);
|
|
30554
|
+
return { computerId, isLocal: isLocalComputer(computerId), ...await fs7.listRoots(computerId) };
|
|
30555
|
+
}),
|
|
30556
|
+
listDir: publicProcedure.input(
|
|
30557
|
+
targetInput.extend({
|
|
30558
|
+
/** Absolute path ON THE TARGET machine. */
|
|
30559
|
+
path: external_exports.string().min(1),
|
|
30560
|
+
dirsOnly: external_exports.boolean().optional(),
|
|
30561
|
+
includeHidden: external_exports.boolean().optional()
|
|
30562
|
+
})
|
|
30563
|
+
).query(async ({ input: input2 }) => {
|
|
30564
|
+
const { fs: fs7, resolveComputer } = getWorkspaceDeps();
|
|
30565
|
+
const computerId = await resolveComputer(input2);
|
|
30566
|
+
const res = await fs7.listDir(computerId, input2.path, {
|
|
30567
|
+
dirsOnly: input2.dirsOnly,
|
|
30568
|
+
includeHidden: input2.includeHidden
|
|
30569
|
+
});
|
|
30570
|
+
return { computerId, ...res };
|
|
30571
|
+
}),
|
|
30572
|
+
mkdir: publicProcedure.input(targetInput.extend({ path: external_exports.string().min(1) })).mutation(async ({ input: input2 }) => {
|
|
30573
|
+
const { fs: fs7, resolveComputer } = getWorkspaceDeps();
|
|
30574
|
+
const computerId = await resolveComputer(input2);
|
|
30575
|
+
const res = await fs7.mkdir(computerId, input2.path);
|
|
30576
|
+
return { computerId, ...res };
|
|
30577
|
+
}),
|
|
30578
|
+
/**
|
|
30579
|
+
* Replace a computer's path-jail (Settings → Computers).
|
|
30580
|
+
*
|
|
30581
|
+
* Routing the filesystem through computers gave the co-resident local computer's
|
|
30582
|
+
* `[homedir()]` default authority over ops the desktop previously ran unjailed
|
|
30583
|
+
* — so a project on `/Volumes` or `/opt` would have stopped working. This is
|
|
30584
|
+
* the escape hatch that keeps that from being a cap.
|
|
30585
|
+
*
|
|
30586
|
+
* Returns what was actually applied plus what was rejected, so the UI can name
|
|
30587
|
+
* the entry that did not take rather than showing a list that silently differs
|
|
30588
|
+
* from the enforced one.
|
|
30589
|
+
*/
|
|
30590
|
+
setAllowedRoots: publicProcedure.input(targetInput.extend({ roots: external_exports.array(external_exports.string().min(1)) })).mutation(async ({ input: input2 }) => {
|
|
30591
|
+
const { fs: fs7, resolveComputer } = getWorkspaceDeps();
|
|
30592
|
+
const computerId = await resolveComputer(input2);
|
|
30593
|
+
return { computerId, ...await fs7.setAllowedRoots(computerId, input2.roots) };
|
|
30594
|
+
}),
|
|
30595
|
+
/**
|
|
30596
|
+
* Where does the target machine keep this project?
|
|
30597
|
+
*
|
|
30598
|
+
* `path: null` means that machine has no checkout — the honest answer the
|
|
30599
|
+
* hub's single `projects.path` column could never give, since it always had
|
|
30600
|
+
* *a* path even for a computer that had never seen the project. `exists: false`
|
|
30601
|
+
* is different again: recorded, but the folder is gone.
|
|
30602
|
+
*/
|
|
30603
|
+
resolveProjectPath: publicProcedure.input(targetInput.extend({ projectId: external_exports.string().min(1) })).query(async ({ input: input2 }) => {
|
|
30604
|
+
const { fs: fs7, resolveComputer } = getWorkspaceDeps();
|
|
30605
|
+
const computerId = await resolveComputer(input2);
|
|
30606
|
+
try {
|
|
30607
|
+
return {
|
|
30608
|
+
computerId,
|
|
30609
|
+
reachable: true,
|
|
30610
|
+
...await fs7.resolveProjectPath(computerId, input2.projectId)
|
|
30611
|
+
};
|
|
30612
|
+
} catch (err) {
|
|
30613
|
+
return {
|
|
30614
|
+
computerId,
|
|
30615
|
+
reachable: false,
|
|
30616
|
+
path: null,
|
|
30617
|
+
error: err instanceof Error ? err.message : String(err),
|
|
30618
|
+
...refusalCode(err)
|
|
30619
|
+
};
|
|
30620
|
+
}
|
|
30621
|
+
}),
|
|
30622
|
+
/** Adopt an existing folder on the target machine as this project's checkout. */
|
|
30623
|
+
setProjectPath: publicProcedure.input(
|
|
30624
|
+
targetInput.extend({
|
|
30625
|
+
projectId: external_exports.string().min(1),
|
|
30626
|
+
path: external_exports.string().min(1)
|
|
30627
|
+
})
|
|
30628
|
+
).mutation(async ({ input: input2 }) => {
|
|
30629
|
+
const { fs: fs7, resolveComputer } = getWorkspaceDeps();
|
|
30630
|
+
const computerId = await resolveComputer(input2);
|
|
30631
|
+
return {
|
|
30632
|
+
computerId,
|
|
30633
|
+
...await fs7.setProjectPath(computerId, input2.projectId, input2.path)
|
|
30634
|
+
};
|
|
30635
|
+
}),
|
|
30636
|
+
/** Drop the mapping on that machine. The checkout itself is left alone. */
|
|
30637
|
+
forgetProjectPath: publicProcedure.input(targetInput.extend({ projectId: external_exports.string().min(1) })).mutation(async ({ input: input2 }) => {
|
|
30638
|
+
const { fs: fs7, resolveComputer } = getWorkspaceDeps();
|
|
30639
|
+
const computerId = await resolveComputer(input2);
|
|
30640
|
+
await fs7.forgetProjectPath(computerId, input2.projectId);
|
|
30641
|
+
return { computerId, ok: true };
|
|
30642
|
+
}),
|
|
30643
|
+
/**
|
|
30644
|
+
* Does a path exist on the target machine?
|
|
30645
|
+
*
|
|
30646
|
+
* This is the honest replacement for `app.files.pathExists`, which always
|
|
30647
|
+
* probed the hub. `reachable: false` distinguishes "the computer said no" from
|
|
30648
|
+
* "we could not ask" — collapsing those is what produced a permanent
|
|
30649
|
+
* "No repository path configured" for a path that was fine.
|
|
30650
|
+
*/
|
|
30651
|
+
pathExists: publicProcedure.input(targetInput.extend({ path: external_exports.string().min(1) })).query(async ({ input: input2 }) => {
|
|
30652
|
+
const { fs: fs7, resolveComputer } = getWorkspaceDeps();
|
|
30653
|
+
const computerId = await resolveComputer(input2);
|
|
30654
|
+
try {
|
|
30655
|
+
return { computerId, exists: await fs7.pathExists(computerId, input2.path), reachable: true };
|
|
30656
|
+
} catch (err) {
|
|
30657
|
+
return {
|
|
30658
|
+
computerId,
|
|
30659
|
+
exists: false,
|
|
30660
|
+
reachable: false,
|
|
30661
|
+
error: err instanceof Error ? err.message : String(err),
|
|
30662
|
+
...refusalCode(err)
|
|
30663
|
+
};
|
|
30664
|
+
}
|
|
30665
|
+
})
|
|
30666
|
+
});
|
|
30667
|
+
|
|
30668
|
+
// src/handlers/fs.ts
|
|
30669
|
+
var BROWSE_ALWAYS_HIDDEN2 = /* @__PURE__ */ new Set([".git", ".DS_Store", "node_modules"]);
|
|
30670
|
+
function createFsHandlers(ctx) {
|
|
30671
|
+
const allow = (candidate, subtree = false) => assertPathAllowed(candidate, ctx.config.allowedRoots, { subtree });
|
|
30672
|
+
const allowIn = (rootPath, rel, subtree = false) => {
|
|
30673
|
+
const root = allow(rootPath);
|
|
30674
|
+
allow((0, import_node_path10.join)(root, rel), subtree);
|
|
30675
|
+
return root;
|
|
30676
|
+
};
|
|
30677
|
+
const watches = /* @__PURE__ */ new Map();
|
|
30678
|
+
function pathExists(rawParams) {
|
|
30679
|
+
const { path: path9 } = fsPathExistsParamsSchema.parse(rawParams);
|
|
30680
|
+
const resolved = allow(path9);
|
|
30681
|
+
return { exists: (0, import_node_fs7.existsSync)(resolved) };
|
|
30682
|
+
}
|
|
30683
|
+
async function removeDir(rawParams) {
|
|
30684
|
+
const { path: path9 } = fsRemoveDirParamsSchema.parse(rawParams);
|
|
30685
|
+
const resolved = allow(path9, true);
|
|
30686
|
+
await (0, import_promises7.rm)(resolved, { recursive: true, force: true });
|
|
30687
|
+
ctx.log("fs removeDir", { path: resolved });
|
|
30688
|
+
return { ok: true };
|
|
30689
|
+
}
|
|
30690
|
+
function listRoots(rawParams) {
|
|
30691
|
+
fsListRootsParamsSchema.parse(rawParams ?? {});
|
|
30692
|
+
const resolvedRoots = [];
|
|
30693
|
+
for (const root of ctx.config.allowedRoots) {
|
|
30694
|
+
try {
|
|
30695
|
+
resolvedRoots.push(import_node_fs7.realpathSync.native((0, import_node_path10.resolve)(root)));
|
|
30696
|
+
} catch {
|
|
30697
|
+
}
|
|
30698
|
+
}
|
|
30699
|
+
let home = null;
|
|
30700
|
+
try {
|
|
30701
|
+
home = import_node_fs7.realpathSync.native((0, import_node_os6.homedir)());
|
|
30702
|
+
} catch {
|
|
30703
|
+
home = null;
|
|
30704
|
+
}
|
|
30705
|
+
return { roots: resolvedRoots, home, platform: process.platform, sep: import_node_path10.sep };
|
|
30706
|
+
}
|
|
30707
|
+
async function listDir(rawParams) {
|
|
30708
|
+
const params = fsListDirParamsSchema.parse(rawParams);
|
|
30709
|
+
const abs = allow(params.path);
|
|
30710
|
+
const dirents = await (0, import_promises7.readdir)(abs, { withFileTypes: true });
|
|
30711
|
+
const entries = [];
|
|
30712
|
+
for (const e of dirents) {
|
|
30713
|
+
if (BROWSE_ALWAYS_HIDDEN2.has(e.name)) continue;
|
|
30714
|
+
if (!params.includeHidden && e.name.startsWith(".")) continue;
|
|
30715
|
+
const full = (0, import_node_path10.join)(abs, e.name);
|
|
30716
|
+
const symlink = e.isSymbolicLink();
|
|
30717
|
+
let isDir = e.isDirectory();
|
|
30718
|
+
if (symlink) {
|
|
30719
|
+
try {
|
|
30720
|
+
isDir = (await (0, import_promises7.stat)(full)).isDirectory();
|
|
30721
|
+
} catch {
|
|
30722
|
+
continue;
|
|
30723
|
+
}
|
|
30724
|
+
}
|
|
30725
|
+
if (params.dirsOnly && !isDir) continue;
|
|
30726
|
+
entries.push({
|
|
30727
|
+
name: e.name,
|
|
30728
|
+
path: full,
|
|
30729
|
+
type: isDir ? "directory" : "file",
|
|
30730
|
+
...symlink && { isSymlink: true },
|
|
30731
|
+
...isDir && (0, import_node_fs7.existsSync)((0, import_node_path10.join)(full, ".git")) && { isGitRepo: true }
|
|
30732
|
+
});
|
|
30733
|
+
}
|
|
30734
|
+
entries.sort((a, b) => {
|
|
30735
|
+
if (a.type !== b.type) return a.type === "directory" ? -1 : 1;
|
|
30736
|
+
return a.name.localeCompare(b.name);
|
|
30737
|
+
});
|
|
30738
|
+
const isRoot = ctx.config.allowedRoots.some((r) => {
|
|
30739
|
+
try {
|
|
30740
|
+
return import_node_fs7.realpathSync.native((0, import_node_path10.resolve)(r)) === abs;
|
|
30741
|
+
} catch {
|
|
30742
|
+
return false;
|
|
30743
|
+
}
|
|
30744
|
+
});
|
|
30745
|
+
return { path: abs, parent: isRoot ? null : (0, import_node_path10.dirname)(abs), entries };
|
|
30746
|
+
}
|
|
30747
|
+
async function mkdirHandler(rawParams) {
|
|
30748
|
+
const { path: path9 } = fsMkdirParamsSchema.parse(rawParams);
|
|
30749
|
+
const abs = allow(path9);
|
|
30750
|
+
await (0, import_promises7.mkdir)(abs, { recursive: true });
|
|
30751
|
+
ctx.log("fs mkdir", { path: abs });
|
|
30752
|
+
return { path: import_node_fs7.realpathSync.native(abs) };
|
|
30753
|
+
}
|
|
30754
|
+
function readDirHandler(rawParams) {
|
|
30755
|
+
const { rootPath, dirPath } = fsReadDirParamsSchema.parse(rawParams);
|
|
30756
|
+
return { entries: readDir(allow(rootPath), dirPath) };
|
|
30757
|
+
}
|
|
30758
|
+
function readFileHandler(rawParams) {
|
|
30759
|
+
const { rootPath, filePath, force } = fsReadFileParamsSchema.parse(rawParams);
|
|
30760
|
+
return readFile3(allowIn(rootPath, filePath), filePath, force);
|
|
30761
|
+
}
|
|
30762
|
+
function writeFileHandler(rawParams) {
|
|
30763
|
+
const { rootPath, filePath, content } = fsWriteFileParamsSchema.parse(rawParams);
|
|
30764
|
+
writeFile3(allowIn(rootPath, filePath), filePath, content);
|
|
30765
|
+
return { ok: true };
|
|
30766
|
+
}
|
|
30767
|
+
function createFileHandler(rawParams) {
|
|
30768
|
+
const { rootPath, filePath } = fsCreateFileParamsSchema.parse(rawParams);
|
|
30769
|
+
createFile(allowIn(rootPath, filePath), filePath);
|
|
30770
|
+
return { ok: true };
|
|
30771
|
+
}
|
|
30772
|
+
function createDirHandler(rawParams) {
|
|
30773
|
+
const { rootPath, dirPath } = fsCreateDirParamsSchema.parse(rawParams);
|
|
30774
|
+
createDir(allowIn(rootPath, dirPath), dirPath);
|
|
30775
|
+
return { ok: true };
|
|
30776
|
+
}
|
|
30777
|
+
function renameHandler(rawParams) {
|
|
30778
|
+
const { rootPath, oldPath, newPath } = fsRenameParamsSchema.parse(rawParams);
|
|
30779
|
+
allowIn(rootPath, newPath, true);
|
|
30780
|
+
renamePath(allowIn(rootPath, oldPath, true), oldPath, newPath);
|
|
30781
|
+
return { ok: true };
|
|
30782
|
+
}
|
|
30783
|
+
function deleteHandler(rawParams) {
|
|
30784
|
+
const { rootPath, targetPath } = fsDeleteParamsSchema.parse(rawParams);
|
|
30785
|
+
deletePath(allowIn(rootPath, targetPath, true), targetPath);
|
|
28382
30786
|
return { ok: true };
|
|
28383
30787
|
}
|
|
28384
30788
|
function copyInHandler(rawParams) {
|
|
@@ -28403,7 +30807,7 @@ function createFsHandlers(ctx) {
|
|
|
28403
30807
|
const results = searchFiles(root, query, {
|
|
28404
30808
|
...options,
|
|
28405
30809
|
maxResults
|
|
28406
|
-
}).filter((r) => !isProtectedPath((0,
|
|
30810
|
+
}).filter((r) => !isProtectedPath((0, import_node_path10.join)(root, r.path)));
|
|
28407
30811
|
const total = results.reduce((n, r) => n + r.matches.length, 0);
|
|
28408
30812
|
return { results, truncated: total >= maxResults };
|
|
28409
30813
|
}
|
|
@@ -28476,7 +30880,7 @@ function createGhHandlers(ctx) {
|
|
|
28476
30880
|
async function ghExec(rawParams) {
|
|
28477
30881
|
const params = ghExecParamsSchema.parse(rawParams);
|
|
28478
30882
|
const cwd = assertPathAllowed(params.cwd, ctx.config.allowedRoots);
|
|
28479
|
-
return new Promise((
|
|
30883
|
+
return new Promise((resolve9) => {
|
|
28480
30884
|
const child = (0, import_node_child_process5.execFile)(
|
|
28481
30885
|
"gh",
|
|
28482
30886
|
params.args,
|
|
@@ -28491,7 +30895,7 @@ function createGhHandlers(ctx) {
|
|
|
28491
30895
|
},
|
|
28492
30896
|
(err, stdout2, stderr) => {
|
|
28493
30897
|
const status = err && typeof err.code === "number" ? err.code : err ? null : 0;
|
|
28494
|
-
|
|
30898
|
+
resolve9({ status, stdout: stdout2 ?? "", stderr: stderr ?? "" });
|
|
28495
30899
|
}
|
|
28496
30900
|
);
|
|
28497
30901
|
if (params.stdin !== void 0) {
|
|
@@ -28504,14 +30908,14 @@ function createGhHandlers(ctx) {
|
|
|
28504
30908
|
|
|
28505
30909
|
// src/handlers/git.ts
|
|
28506
30910
|
var import_node_child_process7 = require("node:child_process");
|
|
28507
|
-
var
|
|
28508
|
-
var
|
|
28509
|
-
var
|
|
30911
|
+
var import_node_fs8 = require("node:fs");
|
|
30912
|
+
var import_promises8 = require("node:fs/promises");
|
|
30913
|
+
var import_node_path11 = require("node:path");
|
|
28510
30914
|
|
|
28511
30915
|
// src/handlers/exec.ts
|
|
28512
30916
|
var import_node_child_process6 = require("node:child_process");
|
|
28513
30917
|
function execCapture(command, args, opts = {}) {
|
|
28514
|
-
return new Promise((
|
|
30918
|
+
return new Promise((resolve9) => {
|
|
28515
30919
|
const child = (0, import_node_child_process6.spawn)(command, args, {
|
|
28516
30920
|
...opts.cwd ? { cwd: opts.cwd } : {},
|
|
28517
30921
|
...opts.env ? { env: opts.env } : {},
|
|
@@ -28527,11 +30931,11 @@ function execCapture(command, args, opts = {}) {
|
|
|
28527
30931
|
}
|
|
28528
30932
|
child.on("close", (code) => {
|
|
28529
30933
|
if (timer) clearTimeout(timer);
|
|
28530
|
-
|
|
30934
|
+
resolve9({ stdout: stdout2.join(""), stderr: stderr.join(""), status: code });
|
|
28531
30935
|
});
|
|
28532
30936
|
child.on("error", (err) => {
|
|
28533
30937
|
if (timer) clearTimeout(timer);
|
|
28534
|
-
|
|
30938
|
+
resolve9({ stdout: "", stderr: err.message, status: 1, spawnError: err.message });
|
|
28535
30939
|
});
|
|
28536
30940
|
});
|
|
28537
30941
|
}
|
|
@@ -28566,7 +30970,7 @@ function createGitHandlers(ctx) {
|
|
|
28566
30970
|
async function isGitRepo(rawParams) {
|
|
28567
30971
|
const { path: path9 } = isGitRepoParams.parse(rawParams);
|
|
28568
30972
|
const repoPath = allow(path9);
|
|
28569
|
-
if (!(0,
|
|
30973
|
+
if (!(0, import_node_fs8.existsSync)(repoPath)) return { isGitRepo: false };
|
|
28570
30974
|
const result = await execCapture("git", ["rev-parse", "--git-dir"], { cwd: repoPath });
|
|
28571
30975
|
if (result.spawnError) throw new Error(`Could not start git: ${result.spawnError}`);
|
|
28572
30976
|
return { isGitRepo: result.status === 0 };
|
|
@@ -28599,7 +31003,7 @@ function createGitHandlers(ctx) {
|
|
|
28599
31003
|
try {
|
|
28600
31004
|
await execGit(["worktree", "remove", worktreePath, "--force"], repoPath);
|
|
28601
31005
|
} catch (err) {
|
|
28602
|
-
if (!(0,
|
|
31006
|
+
if (!(0, import_node_fs8.existsSync)(worktreePath)) {
|
|
28603
31007
|
await execGit(["worktree", "prune"], repoPath);
|
|
28604
31008
|
} else {
|
|
28605
31009
|
throw err;
|
|
@@ -28627,13 +31031,13 @@ function createGitHandlers(ctx) {
|
|
|
28627
31031
|
const params = runWorktreeSetupScriptParams.parse(rawParams);
|
|
28628
31032
|
const worktreePath = allow(params.worktreePath);
|
|
28629
31033
|
const repoPath = allow(params.repoPath);
|
|
28630
|
-
const scriptPath = (0,
|
|
28631
|
-
if (!(0,
|
|
31034
|
+
const scriptPath = (0, import_node_path11.resolve)(worktreePath, SETUP_SCRIPT);
|
|
31035
|
+
if (!(0, import_node_fs8.existsSync)(scriptPath)) return Promise.resolve({ ran: false });
|
|
28632
31036
|
try {
|
|
28633
|
-
(0,
|
|
31037
|
+
(0, import_node_fs8.accessSync)(scriptPath, import_node_fs8.constants.X_OK);
|
|
28634
31038
|
} catch {
|
|
28635
31039
|
try {
|
|
28636
|
-
(0,
|
|
31040
|
+
(0, import_node_fs8.chmodSync)(scriptPath, 493);
|
|
28637
31041
|
} catch {
|
|
28638
31042
|
return Promise.resolve({ ran: false });
|
|
28639
31043
|
}
|
|
@@ -28684,20 +31088,20 @@ function createGitHandlers(ctx) {
|
|
|
28684
31088
|
} else {
|
|
28685
31089
|
relPaths = params.customPaths ?? [];
|
|
28686
31090
|
}
|
|
28687
|
-
const repoRoot = (0,
|
|
28688
|
-
const wtRoot = (0,
|
|
31091
|
+
const repoRoot = (0, import_node_path11.resolve)(repoPath);
|
|
31092
|
+
const wtRoot = (0, import_node_path11.resolve)(worktreePath);
|
|
28689
31093
|
let copied = 0;
|
|
28690
31094
|
for (const rel of relPaths) {
|
|
28691
|
-
const src = (0,
|
|
28692
|
-
const dest = (0,
|
|
31095
|
+
const src = (0, import_node_path11.resolve)(repoPath, rel);
|
|
31096
|
+
const dest = (0, import_node_path11.resolve)(worktreePath, rel);
|
|
28693
31097
|
if (!isInside2(src, repoRoot) || !isInside2(dest, wtRoot)) {
|
|
28694
31098
|
ctx.log("copyIgnoredFiles skipped traversal", { rel });
|
|
28695
31099
|
continue;
|
|
28696
31100
|
}
|
|
28697
|
-
if (!(0,
|
|
31101
|
+
if (!(0, import_node_fs8.existsSync)(src)) continue;
|
|
28698
31102
|
try {
|
|
28699
|
-
await (0,
|
|
28700
|
-
await (0,
|
|
31103
|
+
await (0, import_promises8.mkdir)((0, import_node_path11.dirname)(dest), { recursive: true });
|
|
31104
|
+
await (0, import_promises8.cp)(src, dest, { recursive: true, verbatimSymlinks: true });
|
|
28701
31105
|
copied += 1;
|
|
28702
31106
|
} catch (err) {
|
|
28703
31107
|
ctx.log("copyIgnoredFiles copy failed", { rel, error: String(err) });
|
|
@@ -28715,8 +31119,8 @@ function createGitHandlers(ctx) {
|
|
|
28715
31119
|
};
|
|
28716
31120
|
}
|
|
28717
31121
|
function isInside2(child, root) {
|
|
28718
|
-
const c = (0,
|
|
28719
|
-
return c === root || c.startsWith(root +
|
|
31122
|
+
const c = (0, import_node_path11.resolve)(child);
|
|
31123
|
+
return c === root || c.startsWith(root + import_node_path11.sep);
|
|
28720
31124
|
}
|
|
28721
31125
|
|
|
28722
31126
|
// src/handlers/proc.ts
|
|
@@ -28748,19 +31152,19 @@ var ExitTombstones = class {
|
|
|
28748
31152
|
/** Wire form for `pty.list` / `proc.list`. */
|
|
28749
31153
|
list() {
|
|
28750
31154
|
this.prune();
|
|
28751
|
-
return [...this.bySession].map(([sessionId,
|
|
31155
|
+
return [...this.bySession].map(([sessionId, t2]) => ({
|
|
28752
31156
|
sessionId,
|
|
28753
|
-
...
|
|
28754
|
-
...
|
|
28755
|
-
exitCode:
|
|
28756
|
-
signal:
|
|
28757
|
-
...
|
|
31157
|
+
...t2.spawnId !== void 0 ? { spawnId: t2.spawnId } : {},
|
|
31158
|
+
...t2.pid !== void 0 ? { pid: t2.pid } : {},
|
|
31159
|
+
exitCode: t2.exitCode,
|
|
31160
|
+
signal: t2.signal,
|
|
31161
|
+
...t2.reason !== void 0 ? { reason: t2.reason } : {}
|
|
28758
31162
|
}));
|
|
28759
31163
|
}
|
|
28760
31164
|
prune() {
|
|
28761
31165
|
const cutoff = Date.now() - TOMBSTONE_TTL_MS;
|
|
28762
|
-
for (const [sessionId,
|
|
28763
|
-
if (
|
|
31166
|
+
for (const [sessionId, t2] of this.bySession) {
|
|
31167
|
+
if (t2.at > cutoff) break;
|
|
28764
31168
|
this.bySession.delete(sessionId);
|
|
28765
31169
|
}
|
|
28766
31170
|
}
|
|
@@ -28819,6 +31223,17 @@ var RingBuffer = class {
|
|
|
28819
31223
|
}
|
|
28820
31224
|
};
|
|
28821
31225
|
|
|
31226
|
+
// src/handlers/spawn-env.ts
|
|
31227
|
+
function buildSpawnEnv(ctx, overrides) {
|
|
31228
|
+
const merged = overrides ? { ...sanitizeSpawnEnv(process.env), ...overrides } : sanitizeSpawnEnv(process.env);
|
|
31229
|
+
if (ctx.agentHookUrl) {
|
|
31230
|
+
merged.SLAYZONE_AGENT_HOOK_URL = ctx.agentHookUrl;
|
|
31231
|
+
delete merged.SLAYZONE_HUB_TOKEN;
|
|
31232
|
+
}
|
|
31233
|
+
if (ctx.hubAddress) merged.SLAYZONE_HUB_ADDRESS = ctx.hubAddress;
|
|
31234
|
+
return merged;
|
|
31235
|
+
}
|
|
31236
|
+
|
|
28822
31237
|
// src/handlers/proc.ts
|
|
28823
31238
|
var MAX_BUFFER_SIZE = 750 * 1024;
|
|
28824
31239
|
var ProcMethods = {
|
|
@@ -28835,14 +31250,6 @@ var ProcNotifications = {
|
|
|
28835
31250
|
function createProcHandlers(ctx, getProjectPaths) {
|
|
28836
31251
|
const procs = /* @__PURE__ */ new Map();
|
|
28837
31252
|
const tombstones = new ExitTombstones();
|
|
28838
|
-
function buildEnv(overrides) {
|
|
28839
|
-
const merged = overrides ? { ...sanitizeSpawnEnv(process.env), ...overrides } : sanitizeSpawnEnv(process.env);
|
|
28840
|
-
if (ctx.agentHookUrl) {
|
|
28841
|
-
merged.SLAYZONE_AGENT_HOOK_URL = ctx.agentHookUrl;
|
|
28842
|
-
delete merged.SLAYZONE_HUB_TOKEN;
|
|
28843
|
-
}
|
|
28844
|
-
return merged;
|
|
28845
|
-
}
|
|
28846
31253
|
function killTree(child, signal = "SIGTERM") {
|
|
28847
31254
|
if (typeof child.pid === "number") killPidTree(child.pid, signal);
|
|
28848
31255
|
}
|
|
@@ -28867,7 +31274,7 @@ function createProcHandlers(ctx, getProjectPaths) {
|
|
|
28867
31274
|
const invocation = params.shell ? buildShellInvocation(params.command) : { file: params.command, args: params.args ?? [] };
|
|
28868
31275
|
const child = (0, import_node_child_process8.spawn)(invocation.file, invocation.args, {
|
|
28869
31276
|
...cwd ? { cwd } : {},
|
|
28870
|
-
env:
|
|
31277
|
+
env: buildSpawnEnv(ctx, params.env),
|
|
28871
31278
|
// stdin PIPED (was 'ignore') so `proc.write` can reach the child.
|
|
28872
31279
|
stdio: ["pipe", "pipe", "pipe"],
|
|
28873
31280
|
// Its own process group, so a kill reaches everything it started (`pnpm dev`
|
|
@@ -28993,7 +31400,7 @@ function createProcHandlers(ctx, getProjectPaths) {
|
|
|
28993
31400
|
}
|
|
28994
31401
|
|
|
28995
31402
|
// src/handlers/project.ts
|
|
28996
|
-
var
|
|
31403
|
+
var import_node_fs9 = require("node:fs");
|
|
28997
31404
|
function createProjectHandlers(ctx, getStore) {
|
|
28998
31405
|
const allow = (candidate) => assertPathAllowed(candidate, ctx.config.allowedRoots);
|
|
28999
31406
|
const store = () => {
|
|
@@ -29005,7 +31412,7 @@ function createProjectHandlers(ctx, getStore) {
|
|
|
29005
31412
|
const { projectId } = projectResolvePathParamsSchema.parse(rawParams);
|
|
29006
31413
|
const entry = store().get(projectId);
|
|
29007
31414
|
if (!entry) return { path: null };
|
|
29008
|
-
return { path: entry.path, exists: (0,
|
|
31415
|
+
return { path: entry.path, exists: (0, import_node_fs9.existsSync)(entry.path) };
|
|
29009
31416
|
}
|
|
29010
31417
|
async function setPath(rawParams) {
|
|
29011
31418
|
const { projectId, path: path9 } = projectSetPathParamsSchema.parse(rawParams);
|
|
@@ -29026,7 +31433,7 @@ function createProjectHandlers(ctx, getStore) {
|
|
|
29026
31433
|
projects: store().list().map((e) => ({
|
|
29027
31434
|
projectId: e.projectId,
|
|
29028
31435
|
path: e.path,
|
|
29029
|
-
exists: (0,
|
|
31436
|
+
exists: (0, import_node_fs9.existsSync)(e.path)
|
|
29030
31437
|
}))
|
|
29031
31438
|
};
|
|
29032
31439
|
}
|
|
@@ -29068,7 +31475,7 @@ function armStartupDeadline({
|
|
|
29068
31475
|
|
|
29069
31476
|
// src/background-jobs.ts
|
|
29070
31477
|
var import_node_child_process9 = require("node:child_process");
|
|
29071
|
-
var
|
|
31478
|
+
var import_promises9 = require("node:fs/promises");
|
|
29072
31479
|
var import_node_util = require("node:util");
|
|
29073
31480
|
var execFileAsync2 = (0, import_node_util.promisify)(import_node_child_process9.execFile);
|
|
29074
31481
|
var EXEC_TIMEOUT_MS = 5e3;
|
|
@@ -29121,7 +31528,7 @@ async function readStdoutPaths(pids) {
|
|
|
29121
31528
|
if (process.platform === "linux") {
|
|
29122
31529
|
await Promise.all(
|
|
29123
31530
|
pids.map(
|
|
29124
|
-
(pid2) => (0,
|
|
31531
|
+
(pid2) => (0, import_promises9.readlink)(`/proc/${pid2}/fd/1`).then(
|
|
29125
31532
|
(path9) => void out.set(pid2, path9),
|
|
29126
31533
|
() => void 0
|
|
29127
31534
|
)
|
|
@@ -29158,10 +31565,10 @@ async function probeBackgroundJobs(rootPid, jobs) {
|
|
|
29158
31565
|
}
|
|
29159
31566
|
|
|
29160
31567
|
// src/spawn-admission.ts
|
|
29161
|
-
var
|
|
31568
|
+
var import_node_os7 = require("node:os");
|
|
29162
31569
|
var DEFAULT_START_CAP_MS = 5e3;
|
|
29163
31570
|
var DEFAULT_WARM_QUIET_MS = 3e3;
|
|
29164
|
-
function defaultAdmissionConcurrency(cores = (0,
|
|
31571
|
+
function defaultAdmissionConcurrency(cores = (0, import_node_os7.availableParallelism)()) {
|
|
29165
31572
|
return Math.max(2, Math.min(4, Math.floor(cores / 2)));
|
|
29166
31573
|
}
|
|
29167
31574
|
var LANE_RANK = { foreground: 0, background: 1, warm: 2 };
|
|
@@ -29171,9 +31578,9 @@ function createSpawnAdmission(opts = {}) {
|
|
|
29171
31578
|
const warmQuietMs = opts.warmQuietMs ?? DEFAULT_WARM_QUIET_MS;
|
|
29172
31579
|
const now = opts.now ?? Date.now;
|
|
29173
31580
|
const setTimer = opts.setTimer ?? ((fn, ms) => {
|
|
29174
|
-
const
|
|
29175
|
-
|
|
29176
|
-
return
|
|
31581
|
+
const t2 = setTimeout(fn, ms);
|
|
31582
|
+
t2.unref?.();
|
|
31583
|
+
return t2;
|
|
29177
31584
|
});
|
|
29178
31585
|
const clearTimer = opts.clearTimer ?? ((h) => clearTimeout(h));
|
|
29179
31586
|
const queue = [];
|
|
@@ -29189,9 +31596,9 @@ function createSpawnAdmission(opts = {}) {
|
|
|
29189
31596
|
function next() {
|
|
29190
31597
|
if (active.size >= concurrency || queue.length === 0) return null;
|
|
29191
31598
|
let best = null;
|
|
29192
|
-
for (const
|
|
29193
|
-
if (!best || LANE_RANK[
|
|
29194
|
-
best =
|
|
31599
|
+
for (const t2 of queue) {
|
|
31600
|
+
if (!best || LANE_RANK[t2.lane] < LANE_RANK[best.lane] || t2.lane === best.lane && t2.order < best.order) {
|
|
31601
|
+
best = t2;
|
|
29195
31602
|
}
|
|
29196
31603
|
}
|
|
29197
31604
|
if (!best || best.lane !== "warm") return best;
|
|
@@ -29237,7 +31644,7 @@ function createSpawnAdmission(opts = {}) {
|
|
|
29237
31644
|
try {
|
|
29238
31645
|
do {
|
|
29239
31646
|
pumpAgain = false;
|
|
29240
|
-
for (let
|
|
31647
|
+
for (let t2 = next(); t2; t2 = next()) admit(t2);
|
|
29241
31648
|
} while (pumpAgain);
|
|
29242
31649
|
} finally {
|
|
29243
31650
|
pumping = false;
|
|
@@ -29259,10 +31666,10 @@ function createSpawnAdmission(opts = {}) {
|
|
|
29259
31666
|
return true;
|
|
29260
31667
|
},
|
|
29261
31668
|
prioritize(ticket) {
|
|
29262
|
-
const
|
|
29263
|
-
if (!queue.includes(
|
|
29264
|
-
|
|
29265
|
-
|
|
31669
|
+
const t2 = ticket;
|
|
31670
|
+
if (!queue.includes(t2)) return false;
|
|
31671
|
+
t2.lane = "foreground";
|
|
31672
|
+
t2.order = -++promotions;
|
|
29266
31673
|
pump();
|
|
29267
31674
|
return true;
|
|
29268
31675
|
},
|
|
@@ -29294,14 +31701,6 @@ function createPtyHandlers(ctx, getProjectPaths, options = {}) {
|
|
|
29294
31701
|
}
|
|
29295
31702
|
return spawnCwd(entry.path, ctx.config.allowedRoots);
|
|
29296
31703
|
}
|
|
29297
|
-
function buildEnv(overrides) {
|
|
29298
|
-
const merged = overrides ? { ...sanitizeSpawnEnv(process.env), ...overrides } : sanitizeSpawnEnv(process.env);
|
|
29299
|
-
if (ctx.agentHookUrl) {
|
|
29300
|
-
merged.SLAYZONE_AGENT_HOOK_URL = ctx.agentHookUrl;
|
|
29301
|
-
delete merged.SLAYZONE_HUB_TOKEN;
|
|
29302
|
-
}
|
|
29303
|
-
return merged;
|
|
29304
|
-
}
|
|
29305
31704
|
function spawnSession(id, opts) {
|
|
29306
31705
|
const cwd = resolveCwd(opts);
|
|
29307
31706
|
const existing = sessions.get(id);
|
|
@@ -29317,7 +31716,7 @@ function createPtyHandlers(ctx, getProjectPaths, options = {}) {
|
|
|
29317
31716
|
const proc = pty.spawn(opts.command, opts.args ?? [], {
|
|
29318
31717
|
name: "xterm-color",
|
|
29319
31718
|
cwd,
|
|
29320
|
-
env:
|
|
31719
|
+
env: buildSpawnEnv(ctx, opts.env),
|
|
29321
31720
|
cols: opts.cols ?? 80,
|
|
29322
31721
|
rows: opts.rows ?? 24
|
|
29323
31722
|
});
|
|
@@ -29420,10 +31819,10 @@ function createPtyHandlers(ctx, getProjectPaths, options = {}) {
|
|
|
29420
31819
|
if (prior && spec.spawnId !== void 0 && prior.spawnId === spec.spawnId) {
|
|
29421
31820
|
return prior.promise;
|
|
29422
31821
|
}
|
|
29423
|
-
let
|
|
31822
|
+
let resolve9;
|
|
29424
31823
|
let reject;
|
|
29425
31824
|
const promise2 = new Promise((res, rej) => {
|
|
29426
|
-
|
|
31825
|
+
resolve9 = res;
|
|
29427
31826
|
reject = rej;
|
|
29428
31827
|
});
|
|
29429
31828
|
const item = {
|
|
@@ -29435,7 +31834,7 @@ function createPtyHandlers(ctx, getProjectPaths, options = {}) {
|
|
|
29435
31834
|
ticket: void 0,
|
|
29436
31835
|
run: (slot) => run(slot, item),
|
|
29437
31836
|
promise: promise2,
|
|
29438
|
-
resolve:
|
|
31837
|
+
resolve: resolve9,
|
|
29439
31838
|
reject
|
|
29440
31839
|
};
|
|
29441
31840
|
if (prior) {
|
|
@@ -29727,19 +32126,19 @@ function createPtyHandlers(ctx, getProjectPaths, options = {}) {
|
|
|
29727
32126
|
}
|
|
29728
32127
|
|
|
29729
32128
|
// src/handlers/computer-config.ts
|
|
29730
|
-
var
|
|
29731
|
-
var
|
|
32129
|
+
var import_node_fs10 = require("node:fs");
|
|
32130
|
+
var import_node_path12 = require("node:path");
|
|
29732
32131
|
function canonicalRoots(roots) {
|
|
29733
32132
|
const applied = [];
|
|
29734
32133
|
const rejected = [];
|
|
29735
32134
|
for (const root of roots) {
|
|
29736
|
-
if (!(0,
|
|
32135
|
+
if (!(0, import_node_path12.isAbsolute)(root)) {
|
|
29737
32136
|
rejected.push({ path: root, reason: "not an absolute path" });
|
|
29738
32137
|
continue;
|
|
29739
32138
|
}
|
|
29740
32139
|
let real;
|
|
29741
32140
|
try {
|
|
29742
|
-
real =
|
|
32141
|
+
real = import_node_fs10.realpathSync.native((0, import_node_path12.resolve)(root));
|
|
29743
32142
|
} catch {
|
|
29744
32143
|
rejected.push({ path: root, reason: "does not exist on this computer" });
|
|
29745
32144
|
continue;
|
|
@@ -29783,13 +32182,13 @@ function createComputerConfigHandlers(ctx) {
|
|
|
29783
32182
|
}
|
|
29784
32183
|
|
|
29785
32184
|
// src/project-paths.ts
|
|
29786
|
-
var
|
|
29787
|
-
var
|
|
29788
|
-
var
|
|
32185
|
+
var import_promises10 = require("node:fs/promises");
|
|
32186
|
+
var import_node_os8 = require("node:os");
|
|
32187
|
+
var import_node_path13 = require("node:path");
|
|
29789
32188
|
function slayzoneRootDir3() {
|
|
29790
32189
|
if (process.env.SLAYZONE_ROOT) return process.env.SLAYZONE_ROOT;
|
|
29791
|
-
const home = process.env.HOME ?? process.env.USERPROFILE ?? (0,
|
|
29792
|
-
return (0,
|
|
32190
|
+
const home = process.env.HOME ?? process.env.USERPROFILE ?? (0, import_node_os8.homedir)();
|
|
32191
|
+
return (0, import_node_path13.join)(home, ".slayzone");
|
|
29793
32192
|
}
|
|
29794
32193
|
var projectPathEntrySchema = external_exports.object({
|
|
29795
32194
|
/** Absolute, realpath-resolved at write time. */
|
|
@@ -29798,13 +32197,13 @@ var projectPathEntrySchema = external_exports.object({
|
|
|
29798
32197
|
});
|
|
29799
32198
|
var projectMapSchema = external_exports.record(external_exports.string(), projectPathEntrySchema);
|
|
29800
32199
|
function projectsFilePath(baseDir) {
|
|
29801
|
-
return (0,
|
|
32200
|
+
return (0, import_node_path13.join)(baseDir ?? slayzoneRootDir3(), "computer.projects.json");
|
|
29802
32201
|
}
|
|
29803
32202
|
var fileSchema = external_exports.record(external_exports.string(), projectMapSchema);
|
|
29804
32203
|
async function readFileMap(filePath) {
|
|
29805
32204
|
let raw;
|
|
29806
32205
|
try {
|
|
29807
|
-
raw = await (0,
|
|
32206
|
+
raw = await (0, import_promises10.readFile)(filePath, "utf8");
|
|
29808
32207
|
} catch (err) {
|
|
29809
32208
|
if (err.code === "ENOENT") return {};
|
|
29810
32209
|
throw err;
|
|
@@ -29829,14 +32228,14 @@ async function readFileMap(filePath) {
|
|
|
29829
32228
|
return fileSchema.parse(out);
|
|
29830
32229
|
}
|
|
29831
32230
|
async function writeFileMap(filePath, map2) {
|
|
29832
|
-
await (0,
|
|
32231
|
+
await (0, import_promises10.mkdir)((0, import_node_path13.dirname)(filePath), { recursive: true, mode: 448 });
|
|
29833
32232
|
const tmpPath = `${filePath}.tmp-${process.pid}-${Date.now()}`;
|
|
29834
|
-
await (0,
|
|
32233
|
+
await (0, import_promises10.writeFile)(tmpPath, `${JSON.stringify(map2, null, 2)}
|
|
29835
32234
|
`, { mode: 384 });
|
|
29836
32235
|
try {
|
|
29837
|
-
await (0,
|
|
32236
|
+
await (0, import_promises10.rename)(tmpPath, filePath);
|
|
29838
32237
|
} catch (err) {
|
|
29839
|
-
await (0,
|
|
32238
|
+
await (0, import_promises10.rm)(tmpPath, { force: true });
|
|
29840
32239
|
throw err;
|
|
29841
32240
|
}
|
|
29842
32241
|
}
|
|
@@ -29873,26 +32272,27 @@ async function createProjectPathStore(hubHost, options = {}) {
|
|
|
29873
32272
|
|
|
29874
32273
|
// src/main.ts
|
|
29875
32274
|
var COMPUTER_VERSION = "0.0.0";
|
|
29876
|
-
function createHubRequestHandler(
|
|
29877
|
-
const log =
|
|
32275
|
+
function createHubRequestHandler(deps2) {
|
|
32276
|
+
const log = deps2.log ?? (() => {
|
|
29878
32277
|
});
|
|
29879
32278
|
const ctx = {
|
|
29880
|
-
dialer:
|
|
29881
|
-
config:
|
|
32279
|
+
dialer: deps2.dialer,
|
|
32280
|
+
config: deps2.config,
|
|
29882
32281
|
log,
|
|
29883
|
-
...
|
|
32282
|
+
...deps2.agentHookUrl ? { agentHookUrl: deps2.agentHookUrl } : {},
|
|
32283
|
+
...deps2.hubAddress ? { hubAddress: deps2.hubAddress } : {}
|
|
29884
32284
|
};
|
|
29885
32285
|
const pty2 = createPtyHandlers(
|
|
29886
32286
|
ctx,
|
|
29887
|
-
|
|
29888
|
-
|
|
32287
|
+
deps2.getProjectPaths,
|
|
32288
|
+
deps2.admission ? { admission: deps2.admission } : {}
|
|
29889
32289
|
);
|
|
29890
|
-
const proc = createProcHandlers(ctx,
|
|
29891
|
-
const
|
|
32290
|
+
const proc = createProcHandlers(ctx, deps2.getProjectPaths);
|
|
32291
|
+
const fs7 = createFsHandlers(ctx);
|
|
29892
32292
|
const shutdownHandler = async (params) => {
|
|
29893
32293
|
const parsed = computerShutdownParamsSchema.safeParse(params ?? {});
|
|
29894
32294
|
const reason = parsed.success ? parsed.data.reason ?? "hub-requested" : "hub-requested";
|
|
29895
|
-
queueMicrotask(() =>
|
|
32295
|
+
queueMicrotask(() => deps2.shutdown(reason));
|
|
29896
32296
|
return { ok: true };
|
|
29897
32297
|
};
|
|
29898
32298
|
const table = {
|
|
@@ -29900,17 +32300,17 @@ function createHubRequestHandler(deps) {
|
|
|
29900
32300
|
...pty2.handlers,
|
|
29901
32301
|
...proc.handlers,
|
|
29902
32302
|
...createGitHandlers(ctx),
|
|
29903
|
-
...
|
|
32303
|
+
...fs7.handlers,
|
|
29904
32304
|
...createComputerConfigHandlers(ctx),
|
|
29905
32305
|
...createGhHandlers(ctx),
|
|
29906
|
-
...createProjectHandlers(ctx,
|
|
32306
|
+
...createProjectHandlers(ctx, deps2.getProjectPaths ?? (() => null))
|
|
29907
32307
|
};
|
|
29908
|
-
const hub =
|
|
32308
|
+
const hub = deps2.hubHost ?? "unknown";
|
|
29909
32309
|
const ptyMethods = new Set(Object.keys(pty2.handlers));
|
|
29910
32310
|
const handle = async (method, params, rawActor) => {
|
|
29911
32311
|
const parsedActor = requestActorSchema.safeParse(rawActor);
|
|
29912
32312
|
const actor = parsedActor.success ? parsedActor.data : null;
|
|
29913
|
-
const record2 = (result, code, reason) =>
|
|
32313
|
+
const record2 = (result, code, reason) => deps2.requestLog?.record({
|
|
29914
32314
|
hub,
|
|
29915
32315
|
method,
|
|
29916
32316
|
actor,
|
|
@@ -29937,7 +32337,7 @@ function createHubRequestHandler(deps) {
|
|
|
29937
32337
|
throw err;
|
|
29938
32338
|
}
|
|
29939
32339
|
try {
|
|
29940
|
-
if (
|
|
32340
|
+
if (deps2.pathReady && !ptyMethods.has(method)) await deps2.pathReady;
|
|
29941
32341
|
const result = await entry(params);
|
|
29942
32342
|
record2("ok");
|
|
29943
32343
|
return result;
|
|
@@ -29960,7 +32360,7 @@ function createHubRequestHandler(deps) {
|
|
|
29960
32360
|
const dispose = () => {
|
|
29961
32361
|
pty2.disposeAll();
|
|
29962
32362
|
proc.disposeAll();
|
|
29963
|
-
|
|
32363
|
+
fs7.disposeAll();
|
|
29964
32364
|
};
|
|
29965
32365
|
const setAgentHookUrl = (url2) => {
|
|
29966
32366
|
ctx.agentHookUrl = url2;
|
|
@@ -29970,8 +32370,8 @@ function createHubRequestHandler(deps) {
|
|
|
29970
32370
|
};
|
|
29971
32371
|
return { handle, dispose, setAgentHookUrl, hubDisconnected };
|
|
29972
32372
|
}
|
|
29973
|
-
function startComputer(config2,
|
|
29974
|
-
const log =
|
|
32373
|
+
function startComputer(config2, deps2 = {}) {
|
|
32374
|
+
const log = deps2.log ?? (() => {
|
|
29975
32375
|
});
|
|
29976
32376
|
const identity = {
|
|
29977
32377
|
name: config2.name,
|
|
@@ -29989,14 +32389,14 @@ function startComputer(config2, deps = {}) {
|
|
|
29989
32389
|
});
|
|
29990
32390
|
});
|
|
29991
32391
|
let handle;
|
|
29992
|
-
const stateDir =
|
|
29993
|
-
const configFile = (0,
|
|
32392
|
+
const stateDir = deps2.stateDir ?? (0, import_node_path14.dirname)(getComputerConfigFilePath());
|
|
32393
|
+
const configFile = (0, import_node_path14.join)(stateDir, "computer.config.json");
|
|
29994
32394
|
setProtectedPaths([
|
|
29995
32395
|
configFile,
|
|
29996
32396
|
// The legacy file computer.config.json falls back to when absent.
|
|
29997
|
-
(0,
|
|
32397
|
+
(0, import_node_path14.join)(stateDir, "config.json"),
|
|
29998
32398
|
credentialsFilePath(stateDir),
|
|
29999
|
-
(0,
|
|
32399
|
+
(0, import_node_path14.join)(stateDir, REQUEST_LOG_DIR_NAME)
|
|
30000
32400
|
]);
|
|
30001
32401
|
const requestLog = createRequestLog({
|
|
30002
32402
|
stateDir,
|
|
@@ -30005,7 +32405,7 @@ function startComputer(config2, deps = {}) {
|
|
|
30005
32405
|
log("local request log", { file: requestLog.filePath });
|
|
30006
32406
|
const watchLocalRoots = !config2.hubMayEditRoots;
|
|
30007
32407
|
if (watchLocalRoots) {
|
|
30008
|
-
(0,
|
|
32408
|
+
(0, import_node_fs11.watchFile)(configFile, { interval: 2e3, persistent: false }, () => {
|
|
30009
32409
|
const declared = loadComputerConfigFile(configFile).allowedRoots;
|
|
30010
32410
|
const applied = reloadLocalRoots(config2, declared);
|
|
30011
32411
|
if (!applied) return;
|
|
@@ -30021,7 +32421,8 @@ function startComputer(config2, deps = {}) {
|
|
|
30021
32421
|
}
|
|
30022
32422
|
const admission = createSpawnAdmission();
|
|
30023
32423
|
const connectHub = (hubUrl, isPrimary) => {
|
|
30024
|
-
const credentialStore = (isPrimary ?
|
|
32424
|
+
const credentialStore = (isPrimary ? deps2.credentialStore : void 0) ?? createFileCredentialStore(hubHostFromUrl(hubUrl));
|
|
32425
|
+
const hubAddress = hubAddrFromUrl(hubUrl);
|
|
30025
32426
|
let dispatch;
|
|
30026
32427
|
const dialer = new HubDialer({
|
|
30027
32428
|
url: hubUrl,
|
|
@@ -30043,7 +32444,7 @@ function startComputer(config2, deps = {}) {
|
|
|
30043
32444
|
dispatch = createHubRequestHandler({
|
|
30044
32445
|
shutdown: (reason) => {
|
|
30045
32446
|
log("computer shutdown requested by hub", { hubUrl, reason });
|
|
30046
|
-
void handle.stop().then(() =>
|
|
32447
|
+
void handle.stop().then(() => deps2.onShutdown?.(reason));
|
|
30047
32448
|
},
|
|
30048
32449
|
dialer,
|
|
30049
32450
|
config: config2,
|
|
@@ -30052,7 +32453,9 @@ function startComputer(config2, deps = {}) {
|
|
|
30052
32453
|
admission,
|
|
30053
32454
|
requestLog,
|
|
30054
32455
|
hubHost: hubHostFromUrl(hubUrl),
|
|
30055
|
-
|
|
32456
|
+
// Per hub, like the hook relay: a pty THIS hub asked for belongs to it.
|
|
32457
|
+
...hubAddress ? { hubAddress } : {},
|
|
32458
|
+
...deps2.pathReady ? { pathReady: deps2.pathReady } : {}
|
|
30056
32459
|
});
|
|
30057
32460
|
dialer.events.on(
|
|
30058
32461
|
"connected",
|
|
@@ -30102,7 +32505,7 @@ function startComputer(config2, deps = {}) {
|
|
|
30102
32505
|
dialers: connections.map((c) => c.dialer),
|
|
30103
32506
|
stop: async () => {
|
|
30104
32507
|
hostIdStop?.();
|
|
30105
|
-
if (watchLocalRoots) (0,
|
|
32508
|
+
if (watchLocalRoots) (0, import_node_fs11.unwatchFile)(configFile);
|
|
30106
32509
|
await Promise.all(connections.map((c) => c.dispose()));
|
|
30107
32510
|
}
|
|
30108
32511
|
};
|
|
@@ -30144,7 +32547,7 @@ async function maybeInteractiveSetup() {
|
|
|
30144
32547
|
default: defaultRoot,
|
|
30145
32548
|
transform: (raw) => {
|
|
30146
32549
|
const roots = raw.split(",").map((r) => r.trim()).filter((r) => r.length > 0);
|
|
30147
|
-
return roots.length > 0 ? { config: roots, env: roots.join(
|
|
32550
|
+
return roots.length > 0 ? { config: roots, env: roots.join(import_node_path15.delimiter) } : null;
|
|
30148
32551
|
}
|
|
30149
32552
|
},
|
|
30150
32553
|
{
|
|
@@ -30156,7 +32559,7 @@ async function maybeInteractiveSetup() {
|
|
|
30156
32559
|
configKey: "computerName",
|
|
30157
32560
|
envKey: "SLAYZONE_COMPUTER_NAME",
|
|
30158
32561
|
label: "Computer display name",
|
|
30159
|
-
hint: `default: ${(0,
|
|
32562
|
+
hint: `default: ${(0, import_node_os9.hostname)()}`
|
|
30160
32563
|
}
|
|
30161
32564
|
]
|
|
30162
32565
|
});
|
|
@@ -30204,8 +32607,8 @@ async function main() {
|
|
|
30204
32607
|
await installAgentHooks2(log);
|
|
30205
32608
|
}
|
|
30206
32609
|
const pathReady = adoptLoginShellPath().then(
|
|
30207
|
-
(
|
|
30208
|
-
|
|
32610
|
+
(adopted2) => log(
|
|
32611
|
+
adopted2 ? `PATH: adopted login-shell PATH (+${adopted2.added.length} entries)` : "PATH: no login-shell PATH probed \u2014 keeping the inherited one"
|
|
30209
32612
|
)
|
|
30210
32613
|
);
|
|
30211
32614
|
const handle = startComputer(config2, {
|