@kb-labs/core-state-daemon 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.cjs +523 -253
- package/dist/bin.cjs.map +1 -1
- package/dist/index.d.ts +26 -0
- package/dist/manifest.d.ts +5 -0
- package/package.json +7 -6
package/dist/bin.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var crypto = require('crypto');
|
|
5
|
-
var
|
|
5
|
+
var path5 = require('path');
|
|
6
6
|
var net = require('net');
|
|
7
7
|
var fs4 = require('fs');
|
|
8
8
|
var os = require('os');
|
|
@@ -32,7 +32,7 @@ function _interopNamespace(e) {
|
|
|
32
32
|
return Object.freeze(n);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
var
|
|
35
|
+
var path5__namespace = /*#__PURE__*/_interopNamespace(path5);
|
|
36
36
|
var net__namespace = /*#__PURE__*/_interopNamespace(net);
|
|
37
37
|
var fs4__namespace = /*#__PURE__*/_interopNamespace(fs4);
|
|
38
38
|
var os__namespace = /*#__PURE__*/_interopNamespace(os);
|
|
@@ -1490,16 +1490,16 @@ var init_dist2 = __esm({
|
|
|
1490
1490
|
this.realStorage = realStorage;
|
|
1491
1491
|
this.analytics = analytics;
|
|
1492
1492
|
}
|
|
1493
|
-
async read(
|
|
1493
|
+
async read(path33) {
|
|
1494
1494
|
const startTime = Date.now();
|
|
1495
1495
|
const requestId = generateRequestId5();
|
|
1496
1496
|
try {
|
|
1497
|
-
const result = await this.realStorage.read(
|
|
1497
|
+
const result = await this.realStorage.read(path33);
|
|
1498
1498
|
const durationMs = Date.now() - startTime;
|
|
1499
1499
|
const bytesRead = result?.length ?? 0;
|
|
1500
1500
|
await this.analytics.track("storage.read.completed", {
|
|
1501
1501
|
requestId,
|
|
1502
|
-
path:
|
|
1502
|
+
path: path33,
|
|
1503
1503
|
bytesRead,
|
|
1504
1504
|
durationMs,
|
|
1505
1505
|
found: result !== null
|
|
@@ -1508,50 +1508,50 @@ var init_dist2 = __esm({
|
|
|
1508
1508
|
} catch (error48) {
|
|
1509
1509
|
await this.analytics.track("storage.read.error", {
|
|
1510
1510
|
requestId,
|
|
1511
|
-
path:
|
|
1511
|
+
path: path33,
|
|
1512
1512
|
error: error48 instanceof Error ? error48.message : String(error48),
|
|
1513
1513
|
durationMs: Date.now() - startTime
|
|
1514
1514
|
});
|
|
1515
1515
|
throw error48;
|
|
1516
1516
|
}
|
|
1517
1517
|
}
|
|
1518
|
-
async write(
|
|
1518
|
+
async write(path33, data) {
|
|
1519
1519
|
const startTime = Date.now();
|
|
1520
1520
|
const requestId = generateRequestId5();
|
|
1521
1521
|
try {
|
|
1522
|
-
await this.realStorage.write(
|
|
1522
|
+
await this.realStorage.write(path33, data);
|
|
1523
1523
|
const durationMs = Date.now() - startTime;
|
|
1524
1524
|
await this.analytics.track("storage.write.completed", {
|
|
1525
1525
|
requestId,
|
|
1526
|
-
path:
|
|
1526
|
+
path: path33,
|
|
1527
1527
|
bytesWritten: data.length,
|
|
1528
1528
|
durationMs
|
|
1529
1529
|
});
|
|
1530
1530
|
} catch (error48) {
|
|
1531
1531
|
await this.analytics.track("storage.write.error", {
|
|
1532
1532
|
requestId,
|
|
1533
|
-
path:
|
|
1533
|
+
path: path33,
|
|
1534
1534
|
error: error48 instanceof Error ? error48.message : String(error48),
|
|
1535
1535
|
durationMs: Date.now() - startTime
|
|
1536
1536
|
});
|
|
1537
1537
|
throw error48;
|
|
1538
1538
|
}
|
|
1539
1539
|
}
|
|
1540
|
-
async delete(
|
|
1540
|
+
async delete(path33) {
|
|
1541
1541
|
const startTime = Date.now();
|
|
1542
1542
|
const requestId = generateRequestId5();
|
|
1543
1543
|
try {
|
|
1544
|
-
await this.realStorage.delete(
|
|
1544
|
+
await this.realStorage.delete(path33);
|
|
1545
1545
|
const durationMs = Date.now() - startTime;
|
|
1546
1546
|
await this.analytics.track("storage.delete.completed", {
|
|
1547
1547
|
requestId,
|
|
1548
|
-
path:
|
|
1548
|
+
path: path33,
|
|
1549
1549
|
durationMs
|
|
1550
1550
|
});
|
|
1551
1551
|
} catch (error48) {
|
|
1552
1552
|
await this.analytics.track("storage.delete.error", {
|
|
1553
1553
|
requestId,
|
|
1554
|
-
path:
|
|
1554
|
+
path: path33,
|
|
1555
1555
|
error: error48 instanceof Error ? error48.message : String(error48),
|
|
1556
1556
|
durationMs: Date.now() - startTime
|
|
1557
1557
|
});
|
|
@@ -1581,15 +1581,15 @@ var init_dist2 = __esm({
|
|
|
1581
1581
|
throw error48;
|
|
1582
1582
|
}
|
|
1583
1583
|
}
|
|
1584
|
-
async exists(
|
|
1584
|
+
async exists(path33) {
|
|
1585
1585
|
const startTime = Date.now();
|
|
1586
1586
|
const requestId = generateRequestId5();
|
|
1587
1587
|
try {
|
|
1588
|
-
const result = await this.realStorage.exists(
|
|
1588
|
+
const result = await this.realStorage.exists(path33);
|
|
1589
1589
|
const durationMs = Date.now() - startTime;
|
|
1590
1590
|
await this.analytics.track("storage.exists.completed", {
|
|
1591
1591
|
requestId,
|
|
1592
|
-
path:
|
|
1592
|
+
path: path33,
|
|
1593
1593
|
exists: result,
|
|
1594
1594
|
durationMs
|
|
1595
1595
|
});
|
|
@@ -1597,7 +1597,7 @@ var init_dist2 = __esm({
|
|
|
1597
1597
|
} catch (error48) {
|
|
1598
1598
|
await this.analytics.track("storage.exists.error", {
|
|
1599
1599
|
requestId,
|
|
1600
|
-
path:
|
|
1600
|
+
path: path33,
|
|
1601
1601
|
error: error48 instanceof Error ? error48.message : String(error48),
|
|
1602
1602
|
durationMs: Date.now() - startTime
|
|
1603
1603
|
});
|
|
@@ -1910,7 +1910,7 @@ var init_dist2 = __esm({
|
|
|
1910
1910
|
const month = String(date5.getMonth() + 1).padStart(2, "0");
|
|
1911
1911
|
const year = date5.getFullYear();
|
|
1912
1912
|
const filename = `${this.filePrefix}${year}${month}${day}-${ts}.jsonl`;
|
|
1913
|
-
return
|
|
1913
|
+
return path5__namespace.default.posix.join(this.basePath, filename);
|
|
1914
1914
|
}
|
|
1915
1915
|
async enforceRotation() {
|
|
1916
1916
|
const files = await this.getFilesSorted();
|
|
@@ -2023,7 +2023,7 @@ var init_dist2 = __esm({
|
|
|
2023
2023
|
const month = String(date5.getMonth() + 1).padStart(2, "0");
|
|
2024
2024
|
const year = date5.getFullYear();
|
|
2025
2025
|
const filename = `${this.filePrefix}${year}${month}${day}-${ts}.jsonl`;
|
|
2026
|
-
return
|
|
2026
|
+
return path5__namespace.default.posix.join(this.basePath, filename);
|
|
2027
2027
|
}
|
|
2028
2028
|
async enforceRotation() {
|
|
2029
2029
|
const files = await this.getFilesSorted();
|
|
@@ -16083,7 +16083,7 @@ var init_dist3 = __esm({
|
|
|
16083
16083
|
return { type: "inline", payload: json2 };
|
|
16084
16084
|
}
|
|
16085
16085
|
const tempId = `bulk-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
16086
|
-
const tempPath =
|
|
16086
|
+
const tempPath = path5.join(opts.tempDir, `${tempId}.json`);
|
|
16087
16087
|
await fs3.writeFile(tempPath, json2, "utf8");
|
|
16088
16088
|
this.tempFiles.set(tempPath, tempPath);
|
|
16089
16089
|
return { type: "file", payload: tempPath };
|
|
@@ -16968,10 +16968,10 @@ function matchesGlobPattern(filePath, pattern, cwd) {
|
|
|
16968
16968
|
return true;
|
|
16969
16969
|
}
|
|
16970
16970
|
if (!pattern.includes("*") && !pattern.includes("?")) {
|
|
16971
|
-
const resolvedPattern2 =
|
|
16971
|
+
const resolvedPattern2 = path5__namespace.resolve(cwd, pattern);
|
|
16972
16972
|
return filePath.startsWith(resolvedPattern2);
|
|
16973
16973
|
}
|
|
16974
|
-
const resolvedPattern =
|
|
16974
|
+
const resolvedPattern = path5__namespace.resolve(cwd, pattern);
|
|
16975
16975
|
const regex = globToRegex(resolvedPattern);
|
|
16976
16976
|
return regex.test(filePath);
|
|
16977
16977
|
}
|
|
@@ -16988,7 +16988,7 @@ function createFSShim(options) {
|
|
|
16988
16988
|
...permissions.fs?.write ?? []
|
|
16989
16989
|
];
|
|
16990
16990
|
function normalizePath(filePath) {
|
|
16991
|
-
return
|
|
16991
|
+
return path5__namespace.normalize(path5__namespace.resolve(cwd, filePath));
|
|
16992
16992
|
}
|
|
16993
16993
|
function checkDeniedPatterns(normalizedPath) {
|
|
16994
16994
|
for (const pattern of HARDCODED_DENIED_PATTERNS) {
|
|
@@ -17034,7 +17034,7 @@ function createFSShim(options) {
|
|
|
17034
17034
|
},
|
|
17035
17035
|
async writeFile(filePath, content, options2) {
|
|
17036
17036
|
const resolved = checkWritePermission(filePath);
|
|
17037
|
-
await fs3__namespace.mkdir(
|
|
17037
|
+
await fs3__namespace.mkdir(path5__namespace.dirname(resolved), { recursive: true });
|
|
17038
17038
|
const writeOptions = {
|
|
17039
17039
|
encoding: options2?.encoding ?? "utf-8"
|
|
17040
17040
|
};
|
|
@@ -17090,17 +17090,17 @@ function createFSShim(options) {
|
|
|
17090
17090
|
async copy(src, dest) {
|
|
17091
17091
|
const resolvedSrc = checkReadPermission(src);
|
|
17092
17092
|
const resolvedDest = checkWritePermission(dest);
|
|
17093
|
-
await fs3__namespace.mkdir(
|
|
17093
|
+
await fs3__namespace.mkdir(path5__namespace.dirname(resolvedDest), { recursive: true });
|
|
17094
17094
|
await fs3__namespace.cp(resolvedSrc, resolvedDest, { recursive: true });
|
|
17095
17095
|
},
|
|
17096
17096
|
async move(src, dest) {
|
|
17097
17097
|
const resolvedSrc = checkWritePermission(src);
|
|
17098
17098
|
const resolvedDest = checkWritePermission(dest);
|
|
17099
|
-
await fs3__namespace.mkdir(
|
|
17099
|
+
await fs3__namespace.mkdir(path5__namespace.dirname(resolvedDest), { recursive: true });
|
|
17100
17100
|
await fs3__namespace.rename(resolvedSrc, resolvedDest);
|
|
17101
17101
|
},
|
|
17102
17102
|
async glob(pattern, options2) {
|
|
17103
|
-
const searchCwd = options2?.cwd ?
|
|
17103
|
+
const searchCwd = options2?.cwd ? path5__namespace.resolve(cwd, options2.cwd) : cwd;
|
|
17104
17104
|
const ignorePatterns = options2?.ignore ?? [];
|
|
17105
17105
|
const matches = [];
|
|
17106
17106
|
async function walk(dir) {
|
|
@@ -17111,8 +17111,8 @@ function createFSShim(options) {
|
|
|
17111
17111
|
}
|
|
17112
17112
|
const entries = await fs3__namespace.readdir(dir, { withFileTypes: true });
|
|
17113
17113
|
for (const entry of entries) {
|
|
17114
|
-
const fullPath =
|
|
17115
|
-
const relativePath =
|
|
17114
|
+
const fullPath = path5__namespace.join(dir, entry.name);
|
|
17115
|
+
const relativePath = path5__namespace.relative(searchCwd, fullPath);
|
|
17116
17116
|
if (ignorePatterns.some((ignore) => matchesGlobPattern(fullPath, ignore, searchCwd))) {
|
|
17117
17117
|
continue;
|
|
17118
17118
|
}
|
|
@@ -17127,22 +17127,22 @@ function createFSShim(options) {
|
|
|
17127
17127
|
return matches;
|
|
17128
17128
|
},
|
|
17129
17129
|
resolve(filePath) {
|
|
17130
|
-
return
|
|
17130
|
+
return path5__namespace.resolve(cwd, filePath);
|
|
17131
17131
|
},
|
|
17132
17132
|
relative(filePath) {
|
|
17133
|
-
return
|
|
17133
|
+
return path5__namespace.relative(cwd, filePath);
|
|
17134
17134
|
},
|
|
17135
17135
|
join(...segments) {
|
|
17136
|
-
return
|
|
17136
|
+
return path5__namespace.join(...segments);
|
|
17137
17137
|
},
|
|
17138
17138
|
dirname(filePath) {
|
|
17139
|
-
return
|
|
17139
|
+
return path5__namespace.dirname(filePath);
|
|
17140
17140
|
},
|
|
17141
17141
|
basename(filePath, ext) {
|
|
17142
|
-
return
|
|
17142
|
+
return path5__namespace.basename(filePath, ext);
|
|
17143
17143
|
},
|
|
17144
17144
|
extname(filePath) {
|
|
17145
|
-
return
|
|
17145
|
+
return path5__namespace.extname(filePath);
|
|
17146
17146
|
}
|
|
17147
17147
|
};
|
|
17148
17148
|
}
|
|
@@ -17276,13 +17276,13 @@ function createArtifactsAPI(options) {
|
|
|
17276
17276
|
await fs3__namespace.mkdir(outdir, { recursive: true });
|
|
17277
17277
|
}
|
|
17278
17278
|
function artifactPath(name) {
|
|
17279
|
-
return
|
|
17279
|
+
return path5__namespace.join(outdir, name);
|
|
17280
17280
|
}
|
|
17281
17281
|
return {
|
|
17282
17282
|
async write(name, content) {
|
|
17283
17283
|
await ensureOutdir();
|
|
17284
17284
|
const filePath = artifactPath(name);
|
|
17285
|
-
await fs3__namespace.mkdir(
|
|
17285
|
+
await fs3__namespace.mkdir(path5__namespace.dirname(filePath), { recursive: true });
|
|
17286
17286
|
await fs3__namespace.writeFile(filePath, content);
|
|
17287
17287
|
return filePath;
|
|
17288
17288
|
},
|
|
@@ -17293,7 +17293,7 @@ function createArtifactsAPI(options) {
|
|
|
17293
17293
|
const artifacts = [];
|
|
17294
17294
|
for (const entry of entries) {
|
|
17295
17295
|
if (entry.isFile()) {
|
|
17296
|
-
const filePath =
|
|
17296
|
+
const filePath = path5__namespace.join(outdir, entry.name);
|
|
17297
17297
|
const stats = await fs3__namespace.stat(filePath);
|
|
17298
17298
|
artifacts.push({
|
|
17299
17299
|
name: entry.name,
|
|
@@ -18706,17 +18706,17 @@ async function runInSubprocess(options) {
|
|
|
18706
18706
|
const startTime = Date.now();
|
|
18707
18707
|
return new Promise((resolve22, reject) => {
|
|
18708
18708
|
const BOOTSTRAP = "bootstrap.js";
|
|
18709
|
-
const currentDir =
|
|
18709
|
+
const currentDir = path5__namespace.dirname(new URL((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bin.cjs', document.baseURI).href))).pathname);
|
|
18710
18710
|
const possiblePaths = [
|
|
18711
|
-
|
|
18711
|
+
path5__namespace.join(currentDir, BOOTSTRAP),
|
|
18712
18712
|
// Production (same dir)
|
|
18713
|
-
|
|
18713
|
+
path5__namespace.join(currentDir, "sandbox", BOOTSTRAP),
|
|
18714
18714
|
// Nested sandbox dir
|
|
18715
|
-
|
|
18715
|
+
path5__namespace.join(process.cwd(), "dist", "sandbox", BOOTSTRAP),
|
|
18716
18716
|
// Test/dev mode
|
|
18717
|
-
|
|
18717
|
+
path5__namespace.join(process.cwd(), "dist", BOOTSTRAP),
|
|
18718
18718
|
// Fallback
|
|
18719
|
-
|
|
18719
|
+
path5__namespace.join(process.cwd(), "packages", "plugin-runtime", "dist", "sandbox", BOOTSTRAP)
|
|
18720
18720
|
// Monorepo test mode
|
|
18721
18721
|
];
|
|
18722
18722
|
let bootstrapPath;
|
|
@@ -19044,7 +19044,7 @@ function getWorkspaceManager(platform2) {
|
|
|
19044
19044
|
return platform2.workspaceManager;
|
|
19045
19045
|
}
|
|
19046
19046
|
async function tryResolveWorkspaceRootPath(workspaceId) {
|
|
19047
|
-
const registryFile =
|
|
19047
|
+
const registryFile = path5__namespace.default.resolve(process.cwd(), ".kb/runtime/workspace-registry", `${workspaceId}.json`);
|
|
19048
19048
|
try {
|
|
19049
19049
|
const raw = await fs3.readFile(registryFile, "utf8");
|
|
19050
19050
|
const parsed = JSON.parse(raw);
|
|
@@ -19518,9 +19518,9 @@ var init_dist5 = __esm({
|
|
|
19518
19518
|
});
|
|
19519
19519
|
const hashIndex = requestToExecute.handlerRef.indexOf("#");
|
|
19520
19520
|
const relPath = hashIndex > 0 ? requestToExecute.handlerRef.slice(0, hashIndex) : requestToExecute.handlerRef;
|
|
19521
|
-
let handlerPath =
|
|
19521
|
+
let handlerPath = path5__namespace.resolve(lease.pluginRoot, relPath);
|
|
19522
19522
|
if (!fs4__namespace.existsSync(handlerPath)) {
|
|
19523
|
-
const distPath =
|
|
19523
|
+
const distPath = path5__namespace.resolve(lease.pluginRoot, "dist", relPath.replace(/^\.\//, ""));
|
|
19524
19524
|
if (fs4__namespace.existsSync(distPath)) {
|
|
19525
19525
|
handlerPath = distPath;
|
|
19526
19526
|
}
|
|
@@ -19702,9 +19702,9 @@ var init_dist5 = __esm({
|
|
|
19702
19702
|
});
|
|
19703
19703
|
const hashIndex = requestToExecute.handlerRef.indexOf("#");
|
|
19704
19704
|
const relPath = hashIndex > 0 ? requestToExecute.handlerRef.slice(0, hashIndex) : requestToExecute.handlerRef;
|
|
19705
|
-
let handlerPath =
|
|
19705
|
+
let handlerPath = path5__namespace.resolve(lease.pluginRoot, relPath);
|
|
19706
19706
|
if (!fs4__namespace.existsSync(handlerPath)) {
|
|
19707
|
-
const distPath =
|
|
19707
|
+
const distPath = path5__namespace.resolve(lease.pluginRoot, "dist", relPath.replace(/^\.\//, ""));
|
|
19708
19708
|
if (fs4__namespace.existsSync(distPath)) {
|
|
19709
19709
|
handlerPath = distPath;
|
|
19710
19710
|
}
|
|
@@ -20763,7 +20763,7 @@ var init_dist5 = __esm({
|
|
|
20763
20763
|
await this.lifecycleManager.shutdown(timeoutMs);
|
|
20764
20764
|
}
|
|
20765
20765
|
};
|
|
20766
|
-
__dirname$1 =
|
|
20766
|
+
__dirname$1 = path5__namespace.dirname(url$1.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bin.cjs', document.baseURI).href))));
|
|
20767
20767
|
WorkerPoolBackend = class {
|
|
20768
20768
|
pool = null;
|
|
20769
20769
|
startTime = Date.now();
|
|
@@ -20779,7 +20779,7 @@ var init_dist5 = __esm({
|
|
|
20779
20779
|
constructor(options) {
|
|
20780
20780
|
this.platform = options.platform;
|
|
20781
20781
|
this.uiProvider = options.uiProvider ?? (() => noopUI);
|
|
20782
|
-
this.workerScript = options.workerScript ??
|
|
20782
|
+
this.workerScript = options.workerScript ?? path5__namespace.join(__dirname$1, "backends", "worker-pool", "worker-script.js");
|
|
20783
20783
|
this.config = {
|
|
20784
20784
|
min: options.min ?? 2,
|
|
20785
20785
|
max: options.max ?? 10,
|
|
@@ -27615,7 +27615,7 @@ var require_transport = __commonJS({
|
|
|
27615
27615
|
var { existsSync: existsSync6 } = __require("fs");
|
|
27616
27616
|
var getCallers = require_caller();
|
|
27617
27617
|
var { join: join6, isAbsolute, sep: sep2 } = __require("path");
|
|
27618
|
-
var { fileURLToPath:
|
|
27618
|
+
var { fileURLToPath: fileURLToPath3 } = __require("url");
|
|
27619
27619
|
var sleep3 = require_atomic_sleep();
|
|
27620
27620
|
var onExit = require_on_exit_leak_free();
|
|
27621
27621
|
var ThreadStream = require_thread_stream();
|
|
@@ -27681,7 +27681,7 @@ var require_transport = __commonJS({
|
|
|
27681
27681
|
let path6 = unquoted;
|
|
27682
27682
|
if (path6.startsWith("file://")) {
|
|
27683
27683
|
try {
|
|
27684
|
-
path6 =
|
|
27684
|
+
path6 = fileURLToPath3(path6);
|
|
27685
27685
|
} catch {
|
|
27686
27686
|
return false;
|
|
27687
27687
|
}
|
|
@@ -48661,7 +48661,7 @@ var require_util3 = __commonJS({
|
|
|
48661
48661
|
exports$1.esc = esc2;
|
|
48662
48662
|
exports$1.slugify = slugify2;
|
|
48663
48663
|
exports$1.isObject = isObject3;
|
|
48664
|
-
exports$1.isPlainObject =
|
|
48664
|
+
exports$1.isPlainObject = isPlainObject3;
|
|
48665
48665
|
exports$1.shallowClone = shallowClone2;
|
|
48666
48666
|
exports$1.numKeys = numKeys2;
|
|
48667
48667
|
exports$1.escapeRegex = escapeRegex2;
|
|
@@ -48804,8 +48804,8 @@ var require_util3 = __commonJS({
|
|
|
48804
48804
|
}
|
|
48805
48805
|
function promiseAllObject2(promisesObj) {
|
|
48806
48806
|
const keys = Object.keys(promisesObj);
|
|
48807
|
-
const
|
|
48808
|
-
return Promise.all(
|
|
48807
|
+
const promises5 = keys.map((key) => promisesObj[key]);
|
|
48808
|
+
return Promise.all(promises5).then((results) => {
|
|
48809
48809
|
const resolvedObj = {};
|
|
48810
48810
|
for (let i = 0; i < keys.length; i++) {
|
|
48811
48811
|
resolvedObj[keys[i]] = results[i];
|
|
@@ -48844,7 +48844,7 @@ var require_util3 = __commonJS({
|
|
|
48844
48844
|
return false;
|
|
48845
48845
|
}
|
|
48846
48846
|
});
|
|
48847
|
-
function
|
|
48847
|
+
function isPlainObject3(o) {
|
|
48848
48848
|
if (isObject3(o) === false)
|
|
48849
48849
|
return false;
|
|
48850
48850
|
const ctor = o.constructor;
|
|
@@ -48861,7 +48861,7 @@ var require_util3 = __commonJS({
|
|
|
48861
48861
|
return true;
|
|
48862
48862
|
}
|
|
48863
48863
|
function shallowClone2(o) {
|
|
48864
|
-
if (
|
|
48864
|
+
if (isPlainObject3(o))
|
|
48865
48865
|
return { ...o };
|
|
48866
48866
|
if (Array.isArray(o))
|
|
48867
48867
|
return [...o];
|
|
@@ -49055,7 +49055,7 @@ var require_util3 = __commonJS({
|
|
|
49055
49055
|
return clone2(schema, def);
|
|
49056
49056
|
}
|
|
49057
49057
|
function extend2(schema, shape) {
|
|
49058
|
-
if (!
|
|
49058
|
+
if (!isPlainObject3(shape)) {
|
|
49059
49059
|
throw new Error("Invalid input to extend: expected a plain object");
|
|
49060
49060
|
}
|
|
49061
49061
|
const checks = schema._zod.def.checks;
|
|
@@ -49078,7 +49078,7 @@ var require_util3 = __commonJS({
|
|
|
49078
49078
|
return clone2(schema, def);
|
|
49079
49079
|
}
|
|
49080
49080
|
function safeExtend2(schema, shape) {
|
|
49081
|
-
if (!
|
|
49081
|
+
if (!isPlainObject3(shape)) {
|
|
49082
49082
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
49083
49083
|
}
|
|
49084
49084
|
const def = mergeDefs2(schema._zod.def, {
|
|
@@ -65354,12 +65354,12 @@ var MemoryEventBus = class {
|
|
|
65354
65354
|
if (!topicHandlers) {
|
|
65355
65355
|
return;
|
|
65356
65356
|
}
|
|
65357
|
-
const
|
|
65357
|
+
const promises5 = Array.from(topicHandlers).map(
|
|
65358
65358
|
(handler) => handler(event).catch((err) => {
|
|
65359
65359
|
console.error(`[EventBus] Handler error for topic "${topic}":`, err);
|
|
65360
65360
|
})
|
|
65361
65361
|
);
|
|
65362
|
-
await Promise.all(
|
|
65362
|
+
await Promise.all(promises5);
|
|
65363
65363
|
}
|
|
65364
65364
|
subscribe(topic, handler) {
|
|
65365
65365
|
let topicHandlers = this.handlers.get(topic);
|
|
@@ -65704,7 +65704,7 @@ var DiagnosticCollector = class {
|
|
|
65704
65704
|
var LOCK_FILE = ".kb/marketplace.lock";
|
|
65705
65705
|
var SCHEMA_VERSION = "kb.marketplace/2";
|
|
65706
65706
|
async function readMarketplaceLock(root, diag) {
|
|
65707
|
-
const lockPath =
|
|
65707
|
+
const lockPath = path5__namespace.join(root, LOCK_FILE);
|
|
65708
65708
|
let raw;
|
|
65709
65709
|
try {
|
|
65710
65710
|
raw = await fs3__namespace.readFile(lockPath, "utf-8");
|
|
@@ -66935,6 +66935,98 @@ function createQueuedVectorStore(broker, vectorStore) {
|
|
|
66935
66935
|
return new QueuedVectorStore(broker, vectorStore);
|
|
66936
66936
|
}
|
|
66937
66937
|
|
|
66938
|
+
// ../../../../node_modules/.pnpm/ulid@2.4.0/node_modules/ulid/dist/index.esm.js
|
|
66939
|
+
function createError(message) {
|
|
66940
|
+
const err = new Error(message);
|
|
66941
|
+
err.source = "ulid";
|
|
66942
|
+
return err;
|
|
66943
|
+
}
|
|
66944
|
+
var ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
66945
|
+
var ENCODING_LEN = ENCODING.length;
|
|
66946
|
+
var TIME_MAX = Math.pow(2, 48) - 1;
|
|
66947
|
+
var TIME_LEN = 10;
|
|
66948
|
+
var RANDOM_LEN = 16;
|
|
66949
|
+
function randomChar(prng) {
|
|
66950
|
+
let rand = Math.floor(prng() * ENCODING_LEN);
|
|
66951
|
+
if (rand === ENCODING_LEN) {
|
|
66952
|
+
rand = ENCODING_LEN - 1;
|
|
66953
|
+
}
|
|
66954
|
+
return ENCODING.charAt(rand);
|
|
66955
|
+
}
|
|
66956
|
+
function encodeTime(now, len) {
|
|
66957
|
+
if (isNaN(now)) {
|
|
66958
|
+
throw new Error(now + " must be a number");
|
|
66959
|
+
}
|
|
66960
|
+
if (now > TIME_MAX) {
|
|
66961
|
+
throw createError("cannot encode time greater than " + TIME_MAX);
|
|
66962
|
+
}
|
|
66963
|
+
if (now < 0) {
|
|
66964
|
+
throw createError("time must be positive");
|
|
66965
|
+
}
|
|
66966
|
+
if (Number.isInteger(Number(now)) === false) {
|
|
66967
|
+
throw createError("time must be an integer");
|
|
66968
|
+
}
|
|
66969
|
+
let mod;
|
|
66970
|
+
let str = "";
|
|
66971
|
+
for (; len > 0; len--) {
|
|
66972
|
+
mod = now % ENCODING_LEN;
|
|
66973
|
+
str = ENCODING.charAt(mod) + str;
|
|
66974
|
+
now = (now - mod) / ENCODING_LEN;
|
|
66975
|
+
}
|
|
66976
|
+
return str;
|
|
66977
|
+
}
|
|
66978
|
+
function encodeRandom(len, prng) {
|
|
66979
|
+
let str = "";
|
|
66980
|
+
for (; len > 0; len--) {
|
|
66981
|
+
str = randomChar(prng) + str;
|
|
66982
|
+
}
|
|
66983
|
+
return str;
|
|
66984
|
+
}
|
|
66985
|
+
function detectPrng(allowInsecure = false, root) {
|
|
66986
|
+
if (!root) {
|
|
66987
|
+
root = typeof window !== "undefined" ? window : null;
|
|
66988
|
+
}
|
|
66989
|
+
const browserCrypto = root && (root.crypto || root.msCrypto);
|
|
66990
|
+
if (browserCrypto) {
|
|
66991
|
+
return () => {
|
|
66992
|
+
const buffer = new Uint8Array(1);
|
|
66993
|
+
browserCrypto.getRandomValues(buffer);
|
|
66994
|
+
return buffer[0] / 255;
|
|
66995
|
+
};
|
|
66996
|
+
} else {
|
|
66997
|
+
try {
|
|
66998
|
+
const nodeCrypto = __require("crypto");
|
|
66999
|
+
return () => nodeCrypto.randomBytes(1).readUInt8() / 255;
|
|
67000
|
+
} catch (e) {
|
|
67001
|
+
}
|
|
67002
|
+
}
|
|
67003
|
+
if (allowInsecure) {
|
|
67004
|
+
try {
|
|
67005
|
+
console.error("secure crypto unusable, falling back to insecure Math.random()!");
|
|
67006
|
+
} catch (e) {
|
|
67007
|
+
}
|
|
67008
|
+
return () => Math.random();
|
|
67009
|
+
}
|
|
67010
|
+
throw createError("secure crypto unusable, insecure Math.random not allowed");
|
|
67011
|
+
}
|
|
67012
|
+
function factory(currPrng) {
|
|
67013
|
+
if (!currPrng) {
|
|
67014
|
+
currPrng = detectPrng();
|
|
67015
|
+
}
|
|
67016
|
+
return function ulid4(seedTime) {
|
|
67017
|
+
if (isNaN(seedTime)) {
|
|
67018
|
+
seedTime = Date.now();
|
|
67019
|
+
}
|
|
67020
|
+
return encodeTime(seedTime, TIME_LEN) + encodeRandom(RANDOM_LEN, currPrng);
|
|
67021
|
+
};
|
|
67022
|
+
}
|
|
67023
|
+
factory();
|
|
67024
|
+
|
|
67025
|
+
// ../core-platform/dist/adapters/index.js
|
|
67026
|
+
function isDisposable2(value) {
|
|
67027
|
+
return typeof value === "object" && value !== null && "dispose" in value && typeof value.dispose === "function";
|
|
67028
|
+
}
|
|
67029
|
+
|
|
66938
67030
|
// ../core-config/dist/index.js
|
|
66939
67031
|
__toESM(require_dist());
|
|
66940
67032
|
|
|
@@ -70981,32 +71073,6 @@ var NEVER = INVALID;
|
|
|
70981
71073
|
// ../core-config/dist/index.js
|
|
70982
71074
|
var import_ajv = __toESM(require_ajv());
|
|
70983
71075
|
var import_ajv_formats = __toESM(require_dist2());
|
|
70984
|
-
async function findNearestConfig(opts) {
|
|
70985
|
-
const start = path4__namespace.default.resolve(opts.startDir ?? process.cwd());
|
|
70986
|
-
const stop = opts.stopDir ? path4__namespace.default.resolve(opts.stopDir) : null;
|
|
70987
|
-
const tried = [];
|
|
70988
|
-
let dir = start;
|
|
70989
|
-
while (true) {
|
|
70990
|
-
for (const name of opts.filenames) {
|
|
70991
|
-
const candidate = path4__namespace.default.join(dir, name);
|
|
70992
|
-
tried.push(candidate);
|
|
70993
|
-
try {
|
|
70994
|
-
await fs4.promises.access(candidate);
|
|
70995
|
-
return { path: candidate, tried };
|
|
70996
|
-
} catch {
|
|
70997
|
-
}
|
|
70998
|
-
}
|
|
70999
|
-
const parent = path4__namespace.default.dirname(dir);
|
|
71000
|
-
if (parent === dir) {
|
|
71001
|
-
break;
|
|
71002
|
-
}
|
|
71003
|
-
if (stop && (dir === stop || parent === stop)) {
|
|
71004
|
-
break;
|
|
71005
|
-
}
|
|
71006
|
-
dir = parent;
|
|
71007
|
-
}
|
|
71008
|
-
return { path: null, tried };
|
|
71009
|
-
}
|
|
71010
71076
|
async function readJsonWithDiagnostics(p) {
|
|
71011
71077
|
const diagnostics = [];
|
|
71012
71078
|
try {
|
|
@@ -71023,6 +71089,34 @@ async function readJsonWithDiagnostics(p) {
|
|
|
71023
71089
|
return { ok: false, diagnostics };
|
|
71024
71090
|
}
|
|
71025
71091
|
}
|
|
71092
|
+
function mergeDefined(base, over) {
|
|
71093
|
+
if (!over) {
|
|
71094
|
+
return base;
|
|
71095
|
+
}
|
|
71096
|
+
if (Array.isArray(base) && Array.isArray(over)) {
|
|
71097
|
+
return [...base, ...over.filter((v) => v !== void 0)];
|
|
71098
|
+
}
|
|
71099
|
+
if (isPlainObject(base) && isPlainObject(over)) {
|
|
71100
|
+
const out = { ...base };
|
|
71101
|
+
for (const [k, v] of Object.entries(over)) {
|
|
71102
|
+
if (v === void 0) {
|
|
71103
|
+
continue;
|
|
71104
|
+
}
|
|
71105
|
+
if (isPlainObject(base[k]) && isPlainObject(v)) {
|
|
71106
|
+
out[k] = mergeDefined(base[k], v);
|
|
71107
|
+
} else if (Array.isArray(base[k]) && Array.isArray(v)) {
|
|
71108
|
+
out[k] = mergeDefined(base[k], v);
|
|
71109
|
+
} else {
|
|
71110
|
+
out[k] = v;
|
|
71111
|
+
}
|
|
71112
|
+
}
|
|
71113
|
+
return out;
|
|
71114
|
+
}
|
|
71115
|
+
return over ?? base;
|
|
71116
|
+
}
|
|
71117
|
+
function isPlainObject(v) {
|
|
71118
|
+
return typeof v === "object" && v !== null && Object.getPrototypeOf(v) === Object.prototype;
|
|
71119
|
+
}
|
|
71026
71120
|
var GlobSchema = external_exports.string().min(1, "Glob pattern must be a non-empty string");
|
|
71027
71121
|
var ProductOverridesSchema = external_exports.record(external_exports.string(), external_exports.unknown());
|
|
71028
71122
|
var ProductsMapSchema = external_exports.record(external_exports.string(), ProductOverridesSchema);
|
|
@@ -71088,97 +71182,223 @@ external_exports.object({
|
|
|
71088
71182
|
module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bin.cjs', document.baseURI).href)));
|
|
71089
71183
|
var ajv = new import_ajv.default({ allErrors: true, strict: false });
|
|
71090
71184
|
(0, import_ajv_formats.default)(ajv);
|
|
71185
|
+
async function findRepoRoot(startDir = process.cwd()) {
|
|
71186
|
+
const markersPriority = ["pnpm-workspace.yaml", ".git", "package.json"];
|
|
71187
|
+
for (const marker of markersPriority) {
|
|
71188
|
+
let dir = path5__namespace.default.resolve(startDir);
|
|
71189
|
+
while (true) {
|
|
71190
|
+
try {
|
|
71191
|
+
await fs4.promises.access(path5__namespace.default.join(dir, marker));
|
|
71192
|
+
return dir;
|
|
71193
|
+
} catch {
|
|
71194
|
+
}
|
|
71195
|
+
const parent = path5__namespace.default.dirname(dir);
|
|
71196
|
+
if (parent === dir) {
|
|
71197
|
+
break;
|
|
71198
|
+
}
|
|
71199
|
+
dir = parent;
|
|
71200
|
+
}
|
|
71201
|
+
}
|
|
71202
|
+
return path5__namespace.default.resolve(startDir);
|
|
71203
|
+
}
|
|
71091
71204
|
|
|
71092
|
-
//
|
|
71093
|
-
|
|
71094
|
-
|
|
71095
|
-
|
|
71096
|
-
|
|
71205
|
+
// ../core-workspace/dist/index.js
|
|
71206
|
+
var WORKSPACE_CONFIG_RELATIVE = path5__namespace.default.join(".kb", "kb.config.json");
|
|
71207
|
+
var PLATFORM_PACKAGE_MARKERS = [
|
|
71208
|
+
"@kb-labs/cli-bin",
|
|
71209
|
+
"@kb-labs/core-runtime"
|
|
71210
|
+
];
|
|
71211
|
+
var defaultFs = {
|
|
71212
|
+
async exists(target) {
|
|
71213
|
+
try {
|
|
71214
|
+
await fs4.promises.access(target);
|
|
71215
|
+
return true;
|
|
71216
|
+
} catch {
|
|
71217
|
+
return false;
|
|
71218
|
+
}
|
|
71219
|
+
}
|
|
71220
|
+
};
|
|
71221
|
+
function resolveProjectEnvRoot(env) {
|
|
71222
|
+
if (!env) {
|
|
71223
|
+
return void 0;
|
|
71224
|
+
}
|
|
71225
|
+
return env.KB_PROJECT_ROOT ?? env.KB_LABS_WORKSPACE_ROOT ?? env.KB_LABS_REPO_ROOT;
|
|
71097
71226
|
}
|
|
71098
|
-
|
|
71099
|
-
|
|
71100
|
-
|
|
71101
|
-
|
|
71102
|
-
|
|
71103
|
-
|
|
71104
|
-
|
|
71105
|
-
|
|
71106
|
-
|
|
71227
|
+
async function findConfigRoot(startDir, fs5) {
|
|
71228
|
+
let current = path5__namespace.default.resolve(startDir);
|
|
71229
|
+
while (true) {
|
|
71230
|
+
const configPath = path5__namespace.default.join(current, WORKSPACE_CONFIG_RELATIVE);
|
|
71231
|
+
if (await fs5.exists(configPath)) {
|
|
71232
|
+
return current;
|
|
71233
|
+
}
|
|
71234
|
+
const parent = path5__namespace.default.dirname(current);
|
|
71235
|
+
if (parent === current) {
|
|
71236
|
+
return void 0;
|
|
71237
|
+
}
|
|
71238
|
+
current = parent;
|
|
71107
71239
|
}
|
|
71108
|
-
return ENCODING.charAt(rand);
|
|
71109
71240
|
}
|
|
71110
|
-
function
|
|
71111
|
-
|
|
71112
|
-
|
|
71241
|
+
async function resolveProjectRoot(options = {}) {
|
|
71242
|
+
const {
|
|
71243
|
+
cwd,
|
|
71244
|
+
env = process.env,
|
|
71245
|
+
fs: fs5 = defaultFs,
|
|
71246
|
+
startDir = process.cwd()
|
|
71247
|
+
} = options;
|
|
71248
|
+
if (cwd) {
|
|
71249
|
+
return {
|
|
71250
|
+
rootDir: path5__namespace.default.resolve(cwd),
|
|
71251
|
+
source: "explicit"
|
|
71252
|
+
};
|
|
71113
71253
|
}
|
|
71114
|
-
|
|
71115
|
-
|
|
71254
|
+
const envRoot = resolveProjectEnvRoot(env);
|
|
71255
|
+
if (envRoot) {
|
|
71256
|
+
return {
|
|
71257
|
+
rootDir: path5__namespace.default.resolve(envRoot),
|
|
71258
|
+
source: "env"
|
|
71259
|
+
};
|
|
71116
71260
|
}
|
|
71117
|
-
|
|
71118
|
-
|
|
71261
|
+
const configRoot = await findConfigRoot(startDir, fs5);
|
|
71262
|
+
if (configRoot) {
|
|
71263
|
+
return {
|
|
71264
|
+
rootDir: configRoot,
|
|
71265
|
+
source: "config"
|
|
71266
|
+
};
|
|
71119
71267
|
}
|
|
71120
|
-
|
|
71121
|
-
|
|
71268
|
+
try {
|
|
71269
|
+
const repoRoot = await findRepoRoot(startDir);
|
|
71270
|
+
const resolvedRepo = path5__namespace.default.resolve(repoRoot);
|
|
71271
|
+
const fsRoot = path5__namespace.default.parse(resolvedRepo).root;
|
|
71272
|
+
if (resolvedRepo !== fsRoot) {
|
|
71273
|
+
return {
|
|
71274
|
+
rootDir: resolvedRepo,
|
|
71275
|
+
source: "repo"
|
|
71276
|
+
};
|
|
71277
|
+
}
|
|
71278
|
+
} catch {
|
|
71122
71279
|
}
|
|
71123
|
-
|
|
71124
|
-
|
|
71125
|
-
|
|
71126
|
-
|
|
71127
|
-
|
|
71128
|
-
|
|
71280
|
+
return {
|
|
71281
|
+
rootDir: path5__namespace.default.resolve(startDir),
|
|
71282
|
+
source: "fallback"
|
|
71283
|
+
};
|
|
71284
|
+
}
|
|
71285
|
+
async function hasPlatformMarker(candidate, fs5) {
|
|
71286
|
+
for (const marker of PLATFORM_PACKAGE_MARKERS) {
|
|
71287
|
+
const markerPath = path5__namespace.default.join(candidate, "node_modules", marker);
|
|
71288
|
+
if (await fs5.exists(markerPath)) {
|
|
71289
|
+
return true;
|
|
71290
|
+
}
|
|
71129
71291
|
}
|
|
71130
|
-
return
|
|
71292
|
+
return false;
|
|
71131
71293
|
}
|
|
71132
|
-
function
|
|
71133
|
-
let
|
|
71134
|
-
|
|
71135
|
-
|
|
71294
|
+
async function walkUpForPlatformMarker(startDir, fs5) {
|
|
71295
|
+
let current = path5__namespace.default.resolve(startDir);
|
|
71296
|
+
while (true) {
|
|
71297
|
+
if (await hasPlatformMarker(current, fs5)) {
|
|
71298
|
+
return current;
|
|
71299
|
+
}
|
|
71300
|
+
if (await fs5.exists(path5__namespace.default.join(current, "pnpm-workspace.yaml"))) {
|
|
71301
|
+
return current;
|
|
71302
|
+
}
|
|
71303
|
+
const parent = path5__namespace.default.dirname(current);
|
|
71304
|
+
if (parent === current) {
|
|
71305
|
+
return void 0;
|
|
71306
|
+
}
|
|
71307
|
+
current = parent;
|
|
71136
71308
|
}
|
|
71137
|
-
return str;
|
|
71138
71309
|
}
|
|
71139
|
-
function
|
|
71140
|
-
|
|
71141
|
-
|
|
71310
|
+
async function resolvePlatformRootFromModuleUrl(moduleUrl, fs5) {
|
|
71311
|
+
let modulePath;
|
|
71312
|
+
try {
|
|
71313
|
+
modulePath = url$1.fileURLToPath(moduleUrl);
|
|
71314
|
+
} catch {
|
|
71315
|
+
return void 0;
|
|
71142
71316
|
}
|
|
71143
|
-
|
|
71144
|
-
|
|
71145
|
-
|
|
71146
|
-
|
|
71147
|
-
|
|
71148
|
-
|
|
71149
|
-
};
|
|
71150
|
-
} else {
|
|
71151
|
-
try {
|
|
71152
|
-
const nodeCrypto = __require("crypto");
|
|
71153
|
-
return () => nodeCrypto.randomBytes(1).readUInt8() / 255;
|
|
71154
|
-
} catch (e) {
|
|
71317
|
+
let current = path5__namespace.default.dirname(modulePath);
|
|
71318
|
+
let firstMarkerHit;
|
|
71319
|
+
let topMostWorkspace;
|
|
71320
|
+
while (true) {
|
|
71321
|
+
if (!firstMarkerHit && await hasPlatformMarker(current, fs5)) {
|
|
71322
|
+
firstMarkerHit = current;
|
|
71155
71323
|
}
|
|
71156
|
-
|
|
71157
|
-
|
|
71158
|
-
try {
|
|
71159
|
-
console.error("secure crypto unusable, falling back to insecure Math.random()!");
|
|
71160
|
-
} catch (e) {
|
|
71324
|
+
if (await fs5.exists(path5__namespace.default.join(current, "pnpm-workspace.yaml"))) {
|
|
71325
|
+
topMostWorkspace = current;
|
|
71161
71326
|
}
|
|
71162
|
-
|
|
71327
|
+
const parent = path5__namespace.default.dirname(current);
|
|
71328
|
+
if (parent === current) {
|
|
71329
|
+
return topMostWorkspace ?? firstMarkerHit;
|
|
71330
|
+
}
|
|
71331
|
+
current = parent;
|
|
71163
71332
|
}
|
|
71164
|
-
throw createError("secure crypto unusable, insecure Math.random not allowed");
|
|
71165
71333
|
}
|
|
71166
|
-
function
|
|
71167
|
-
|
|
71168
|
-
|
|
71334
|
+
async function resolvePlatformRoot(options = {}) {
|
|
71335
|
+
const {
|
|
71336
|
+
cwd,
|
|
71337
|
+
moduleUrl,
|
|
71338
|
+
env = process.env,
|
|
71339
|
+
fs: fs5 = defaultFs,
|
|
71340
|
+
startDir = process.cwd()
|
|
71341
|
+
} = options;
|
|
71342
|
+
if (cwd) {
|
|
71343
|
+
return {
|
|
71344
|
+
rootDir: path5__namespace.default.resolve(cwd),
|
|
71345
|
+
source: "explicit"
|
|
71346
|
+
};
|
|
71169
71347
|
}
|
|
71170
|
-
|
|
71171
|
-
|
|
71172
|
-
|
|
71348
|
+
const envRoot = env?.KB_PLATFORM_ROOT;
|
|
71349
|
+
if (envRoot) {
|
|
71350
|
+
return {
|
|
71351
|
+
rootDir: path5__namespace.default.resolve(envRoot),
|
|
71352
|
+
source: "env"
|
|
71353
|
+
};
|
|
71354
|
+
}
|
|
71355
|
+
if (moduleUrl) {
|
|
71356
|
+
const fromModule = await resolvePlatformRootFromModuleUrl(moduleUrl, fs5);
|
|
71357
|
+
if (fromModule) {
|
|
71358
|
+
return {
|
|
71359
|
+
rootDir: fromModule,
|
|
71360
|
+
source: "module"
|
|
71361
|
+
};
|
|
71173
71362
|
}
|
|
71174
|
-
|
|
71363
|
+
}
|
|
71364
|
+
const fromMarker = await walkUpForPlatformMarker(startDir, fs5);
|
|
71365
|
+
if (fromMarker) {
|
|
71366
|
+
return {
|
|
71367
|
+
rootDir: fromMarker,
|
|
71368
|
+
source: "marker"
|
|
71369
|
+
};
|
|
71370
|
+
}
|
|
71371
|
+
try {
|
|
71372
|
+
const repoRoot = await findRepoRoot(startDir);
|
|
71373
|
+
const resolvedRepo = path5__namespace.default.resolve(repoRoot);
|
|
71374
|
+
const fsRoot = path5__namespace.default.parse(resolvedRepo).root;
|
|
71375
|
+
if (resolvedRepo !== fsRoot) {
|
|
71376
|
+
return {
|
|
71377
|
+
rootDir: resolvedRepo,
|
|
71378
|
+
source: "repo"
|
|
71379
|
+
};
|
|
71380
|
+
}
|
|
71381
|
+
} catch {
|
|
71382
|
+
}
|
|
71383
|
+
return {
|
|
71384
|
+
rootDir: path5__namespace.default.resolve(startDir),
|
|
71385
|
+
source: "fallback"
|
|
71175
71386
|
};
|
|
71176
71387
|
}
|
|
71177
|
-
|
|
71178
|
-
|
|
71179
|
-
|
|
71180
|
-
|
|
71181
|
-
|
|
71388
|
+
async function resolveRoots(options = {}) {
|
|
71389
|
+
const [platform2, project] = await Promise.all([
|
|
71390
|
+
resolvePlatformRoot(options),
|
|
71391
|
+
resolveProjectRoot(options)
|
|
71392
|
+
]);
|
|
71393
|
+
return {
|
|
71394
|
+
platformRoot: platform2.rootDir,
|
|
71395
|
+
projectRoot: project.rootDir,
|
|
71396
|
+
sameLocation: path5__namespace.default.resolve(platform2.rootDir) === path5__namespace.default.resolve(project.rootDir),
|
|
71397
|
+
sources: {
|
|
71398
|
+
platform: platform2.source,
|
|
71399
|
+
project: project.source
|
|
71400
|
+
}
|
|
71401
|
+
};
|
|
71182
71402
|
}
|
|
71183
71403
|
|
|
71184
71404
|
// ../core-runtime/dist/index.js
|
|
@@ -71957,15 +72177,15 @@ async function discoverAdapters(cwd) {
|
|
|
71957
72177
|
if (entry.enabled === false) {
|
|
71958
72178
|
continue;
|
|
71959
72179
|
}
|
|
71960
|
-
const pkgRoot =
|
|
72180
|
+
const pkgRoot = path5__namespace.default.resolve(cwd, entry.resolvedPath);
|
|
71961
72181
|
let mainPath = "dist/index.js";
|
|
71962
72182
|
try {
|
|
71963
|
-
const pkgContent = await fs4.promises.readFile(
|
|
72183
|
+
const pkgContent = await fs4.promises.readFile(path5__namespace.default.join(pkgRoot, "package.json"), "utf-8");
|
|
71964
72184
|
const pkg = JSON.parse(pkgContent);
|
|
71965
72185
|
mainPath = pkg.main || mainPath;
|
|
71966
72186
|
} catch {
|
|
71967
72187
|
}
|
|
71968
|
-
const distPath =
|
|
72188
|
+
const distPath = path5__namespace.default.join(pkgRoot, mainPath);
|
|
71969
72189
|
try {
|
|
71970
72190
|
await fs4.promises.access(distPath);
|
|
71971
72191
|
const module = await loadAdapterModule(distPath);
|
|
@@ -71989,7 +72209,7 @@ async function resolveAdapter(adapterPath, cwd) {
|
|
|
71989
72209
|
const subpath = adapterPath.includes("/") ? adapterPath.split("/").slice(2).join("/") : null;
|
|
71990
72210
|
const adapter = discovered.get(basePkgName);
|
|
71991
72211
|
if (adapter && subpath) {
|
|
71992
|
-
const subpathFile =
|
|
72212
|
+
const subpathFile = path5__namespace.default.join(adapter.pkgRoot, "dist", `${subpath}.js`);
|
|
71993
72213
|
try {
|
|
71994
72214
|
await fs4.promises.access(subpathFile);
|
|
71995
72215
|
const module = await loadAdapterModule(subpathFile);
|
|
@@ -72415,7 +72635,7 @@ var init_bulk_transfer = __esm2({
|
|
|
72415
72635
|
return { type: "inline", payload: json2 };
|
|
72416
72636
|
}
|
|
72417
72637
|
const tempId = `bulk-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
72418
|
-
const tempPath =
|
|
72638
|
+
const tempPath = path5.join(opts.tempDir, `${tempId}.json`);
|
|
72419
72639
|
await fs3.writeFile(tempPath, json2, "utf8");
|
|
72420
72640
|
this.tempFiles.set(tempPath, tempPath);
|
|
72421
72641
|
return { type: "file", payload: tempPath };
|
|
@@ -72454,7 +72674,7 @@ var init_bulk_transfer = __esm2({
|
|
|
72454
72674
|
*/
|
|
72455
72675
|
static async cleanup() {
|
|
72456
72676
|
const cleanupPromises = Array.from(this.tempFiles.values()).map(
|
|
72457
|
-
(
|
|
72677
|
+
(path52) => fs3.unlink(path52).catch(() => {
|
|
72458
72678
|
})
|
|
72459
72679
|
);
|
|
72460
72680
|
await Promise.all(cleanupPromises);
|
|
@@ -72471,9 +72691,9 @@ var init_bulk_transfer = __esm2({
|
|
|
72471
72691
|
}
|
|
72472
72692
|
};
|
|
72473
72693
|
process.on("exit", () => {
|
|
72474
|
-
for (const
|
|
72694
|
+
for (const path52 of BulkTransferHelper2.getStats().tempFilePaths) {
|
|
72475
72695
|
try {
|
|
72476
|
-
fs4.unlinkSync(
|
|
72696
|
+
fs4.unlinkSync(path52);
|
|
72477
72697
|
} catch {
|
|
72478
72698
|
}
|
|
72479
72699
|
}
|
|
@@ -72961,8 +73181,8 @@ var init_storage_proxy = __esm2({
|
|
|
72961
73181
|
* @param path - File path
|
|
72962
73182
|
* @returns File contents or null if not found
|
|
72963
73183
|
*/
|
|
72964
|
-
async read(
|
|
72965
|
-
return await this.callRemote("read", [
|
|
73184
|
+
async read(path52) {
|
|
73185
|
+
return await this.callRemote("read", [path52]);
|
|
72966
73186
|
}
|
|
72967
73187
|
/**
|
|
72968
73188
|
* Write file contents.
|
|
@@ -72970,16 +73190,16 @@ var init_storage_proxy = __esm2({
|
|
|
72970
73190
|
* @param path - File path
|
|
72971
73191
|
* @param data - File contents
|
|
72972
73192
|
*/
|
|
72973
|
-
async write(
|
|
72974
|
-
await this.callRemote("write", [
|
|
73193
|
+
async write(path52, data) {
|
|
73194
|
+
await this.callRemote("write", [path52, data]);
|
|
72975
73195
|
}
|
|
72976
73196
|
/**
|
|
72977
73197
|
* Delete a file.
|
|
72978
73198
|
*
|
|
72979
73199
|
* @param path - File path
|
|
72980
73200
|
*/
|
|
72981
|
-
async delete(
|
|
72982
|
-
await this.callRemote("delete", [
|
|
73201
|
+
async delete(path52) {
|
|
73202
|
+
await this.callRemote("delete", [path52]);
|
|
72983
73203
|
}
|
|
72984
73204
|
/**
|
|
72985
73205
|
* List files matching a prefix.
|
|
@@ -72996,8 +73216,8 @@ var init_storage_proxy = __esm2({
|
|
|
72996
73216
|
* @param path - File path
|
|
72997
73217
|
* @returns True if file exists, false otherwise
|
|
72998
73218
|
*/
|
|
72999
|
-
async exists(
|
|
73000
|
-
return await this.callRemote("exists", [
|
|
73219
|
+
async exists(path52) {
|
|
73220
|
+
return await this.callRemote("exists", [path52]);
|
|
73001
73221
|
}
|
|
73002
73222
|
// ═══════════════════════════════════════════════════════════════════════
|
|
73003
73223
|
// EXTENDED METHODS (optional - implements IStorage extended interface)
|
|
@@ -73009,8 +73229,8 @@ var init_storage_proxy = __esm2({
|
|
|
73009
73229
|
* @param path - File path
|
|
73010
73230
|
* @returns File metadata or null if not found
|
|
73011
73231
|
*/
|
|
73012
|
-
async stat(
|
|
73013
|
-
return await this.callRemote("stat", [
|
|
73232
|
+
async stat(path52) {
|
|
73233
|
+
return await this.callRemote("stat", [path52]);
|
|
73014
73234
|
}
|
|
73015
73235
|
/**
|
|
73016
73236
|
* Copy file within storage.
|
|
@@ -73370,7 +73590,7 @@ async function createAnalyticsContext(cwd) {
|
|
|
73370
73590
|
}
|
|
73371
73591
|
async function detectSource(cwd) {
|
|
73372
73592
|
try {
|
|
73373
|
-
const pkgPath =
|
|
73593
|
+
const pkgPath = path5.join(cwd, "package.json");
|
|
73374
73594
|
const pkgContent = await fs3.readFile(pkgPath, "utf-8");
|
|
73375
73595
|
const pkg = JSON.parse(pkgContent);
|
|
73376
73596
|
return {
|
|
@@ -75760,7 +75980,7 @@ async function initPlatform(config2 = {}, cwd = process.cwd(), uiProvider) {
|
|
|
75760
75980
|
const subpath = modulePath.includes("/") && modulePath.split("/").length > 2 ? modulePath.split("/").slice(2).join("/") : null;
|
|
75761
75981
|
const adapter = discovered.get(basePkgName);
|
|
75762
75982
|
if (adapter && subpath) {
|
|
75763
|
-
const subpathFile =
|
|
75983
|
+
const subpathFile = path5__namespace.default.join(adapter.pkgRoot, "dist", `${subpath}.js`);
|
|
75764
75984
|
try {
|
|
75765
75985
|
await fs4.promises.access(subpathFile);
|
|
75766
75986
|
const module = await import(url$1.pathToFileURL(subpathFile).href);
|
|
@@ -75779,7 +75999,7 @@ async function initPlatform(config2 = {}, cwd = process.cwd(), uiProvider) {
|
|
|
75779
75999
|
return { createAdapter: factory2, manifest: manifest2 };
|
|
75780
76000
|
} catch (err) {
|
|
75781
76001
|
const baseModule = await import(url$1.pathToFileURL(
|
|
75782
|
-
|
|
76002
|
+
path5__namespace.default.join(adapter.pkgRoot, "dist", "index.js")
|
|
75783
76003
|
).href);
|
|
75784
76004
|
const factory2 = baseModule.createAdapter || baseModule.default;
|
|
75785
76005
|
const manifest2 = baseModule.manifest;
|
|
@@ -75797,7 +76017,7 @@ async function initPlatform(config2 = {}, cwd = process.cwd(), uiProvider) {
|
|
|
75797
76017
|
}
|
|
75798
76018
|
} else if (adapter) {
|
|
75799
76019
|
const module = await import(url$1.pathToFileURL(
|
|
75800
|
-
|
|
76020
|
+
path5__namespace.default.join(adapter.pkgRoot, "dist", "index.js")
|
|
75801
76021
|
).href);
|
|
75802
76022
|
const factory2 = module.createAdapter || module.default;
|
|
75803
76023
|
const manifest2 = module.manifest;
|
|
@@ -76262,11 +76482,12 @@ async function initPlatform(config2 = {}, cwd = process.cwd(), uiProvider) {
|
|
|
76262
76482
|
}
|
|
76263
76483
|
}
|
|
76264
76484
|
init_container();
|
|
76265
|
-
var
|
|
76266
|
-
|
|
76267
|
-
|
|
76268
|
-
|
|
76269
|
-
|
|
76485
|
+
var CONFIG_RELATIVE_PATHS = [
|
|
76486
|
+
path5__namespace.default.join(".kb", "kb.config.json"),
|
|
76487
|
+
"kb.config.json"
|
|
76488
|
+
];
|
|
76489
|
+
function loadEnvFile(dir) {
|
|
76490
|
+
const envPath = path5__namespace.default.join(dir, ".env");
|
|
76270
76491
|
if (!fs4.existsSync(envPath)) {
|
|
76271
76492
|
return;
|
|
76272
76493
|
}
|
|
@@ -76289,10 +76510,88 @@ function _loadEnvFile(dir) {
|
|
|
76289
76510
|
} catch {
|
|
76290
76511
|
}
|
|
76291
76512
|
}
|
|
76292
|
-
function
|
|
76293
|
-
const
|
|
76294
|
-
|
|
76513
|
+
function findConfigAtRoot(root) {
|
|
76514
|
+
for (const rel of CONFIG_RELATIVE_PATHS) {
|
|
76515
|
+
const full = path5__namespace.default.join(root, rel);
|
|
76516
|
+
if (fs4.existsSync(full)) {
|
|
76517
|
+
return full;
|
|
76518
|
+
}
|
|
76519
|
+
}
|
|
76520
|
+
return void 0;
|
|
76521
|
+
}
|
|
76522
|
+
async function readConfigFile(configPath) {
|
|
76523
|
+
const result = await readJsonWithDiagnostics(configPath);
|
|
76524
|
+
if (!result.ok) {
|
|
76525
|
+
return {};
|
|
76526
|
+
}
|
|
76527
|
+
const data = result.data;
|
|
76528
|
+
return {
|
|
76529
|
+
platformSection: data.platform,
|
|
76530
|
+
rawConfig: data
|
|
76531
|
+
};
|
|
76532
|
+
}
|
|
76533
|
+
async function loadPlatformConfig(options = {}) {
|
|
76534
|
+
const {
|
|
76535
|
+
moduleUrl,
|
|
76536
|
+
startDir = process.cwd(),
|
|
76537
|
+
env = process.env,
|
|
76538
|
+
loadEnvFile: shouldLoadEnv = true
|
|
76539
|
+
} = options;
|
|
76540
|
+
const roots = await resolveRoots({
|
|
76541
|
+
moduleUrl,
|
|
76542
|
+
startDir,
|
|
76543
|
+
env
|
|
76544
|
+
});
|
|
76545
|
+
if (shouldLoadEnv) {
|
|
76546
|
+
loadEnvFile(roots.projectRoot);
|
|
76547
|
+
}
|
|
76548
|
+
const platformConfigPath = findConfigAtRoot(roots.platformRoot);
|
|
76549
|
+
const projectConfigPath = findConfigAtRoot(roots.projectRoot);
|
|
76550
|
+
let platformDefaults;
|
|
76551
|
+
let projectPlatformConfig;
|
|
76552
|
+
let rawProjectConfig;
|
|
76553
|
+
let platformDefaultsSource;
|
|
76554
|
+
let projectConfigSource;
|
|
76555
|
+
const samePath = !!platformConfigPath && !!projectConfigPath && path5__namespace.default.resolve(platformConfigPath) === path5__namespace.default.resolve(projectConfigPath);
|
|
76556
|
+
if (samePath && projectConfigPath) {
|
|
76557
|
+
const { platformSection, rawConfig } = await readConfigFile(projectConfigPath);
|
|
76558
|
+
projectPlatformConfig = platformSection;
|
|
76559
|
+
rawProjectConfig = rawConfig;
|
|
76560
|
+
projectConfigSource = projectConfigPath;
|
|
76561
|
+
} else {
|
|
76562
|
+
if (platformConfigPath) {
|
|
76563
|
+
const { platformSection } = await readConfigFile(platformConfigPath);
|
|
76564
|
+
platformDefaults = platformSection;
|
|
76565
|
+
platformDefaultsSource = platformConfigPath;
|
|
76566
|
+
}
|
|
76567
|
+
if (projectConfigPath) {
|
|
76568
|
+
const { platformSection, rawConfig } = await readConfigFile(projectConfigPath);
|
|
76569
|
+
projectPlatformConfig = platformSection;
|
|
76570
|
+
rawProjectConfig = rawConfig;
|
|
76571
|
+
projectConfigSource = projectConfigPath;
|
|
76572
|
+
}
|
|
76573
|
+
}
|
|
76574
|
+
const base = { adapters: {} };
|
|
76575
|
+
const effective = mergeDefined(
|
|
76576
|
+
mergeDefined(base, platformDefaults),
|
|
76577
|
+
projectPlatformConfig
|
|
76578
|
+
);
|
|
76579
|
+
return {
|
|
76580
|
+
platformConfig: effective,
|
|
76581
|
+
rawConfig: rawProjectConfig,
|
|
76582
|
+
platformRoot: roots.platformRoot,
|
|
76583
|
+
projectRoot: roots.projectRoot,
|
|
76584
|
+
sameLocation: roots.sameLocation,
|
|
76585
|
+
sources: {
|
|
76586
|
+
platformDefaults: platformDefaultsSource,
|
|
76587
|
+
projectConfig: projectConfigSource,
|
|
76588
|
+
roots: roots.sources
|
|
76589
|
+
}
|
|
76590
|
+
};
|
|
76295
76591
|
}
|
|
76592
|
+
var _initialized = false;
|
|
76593
|
+
var _registeredHooks = /* @__PURE__ */ new Set();
|
|
76594
|
+
var _signalHandlersRegistered = false;
|
|
76296
76595
|
function _ensureSignalHandlers(appId) {
|
|
76297
76596
|
if (_signalHandlersRegistered) {
|
|
76298
76597
|
return;
|
|
@@ -76358,51 +76657,41 @@ async function createServiceBootstrap(options) {
|
|
|
76358
76657
|
if (_initialized) {
|
|
76359
76658
|
return platform;
|
|
76360
76659
|
}
|
|
76361
|
-
if (loadEnv) {
|
|
76362
|
-
_loadEnvFile(repoRoot);
|
|
76363
|
-
}
|
|
76364
76660
|
try {
|
|
76365
|
-
const {
|
|
76661
|
+
const {
|
|
76662
|
+
platformConfig,
|
|
76663
|
+
rawConfig,
|
|
76664
|
+
platformRoot,
|
|
76665
|
+
projectRoot,
|
|
76666
|
+
sources
|
|
76667
|
+
} = await loadPlatformConfig({
|
|
76366
76668
|
startDir: repoRoot,
|
|
76367
|
-
|
|
76669
|
+
loadEnvFile: loadEnv
|
|
76368
76670
|
});
|
|
76369
|
-
if (
|
|
76370
|
-
|
|
76371
|
-
`);
|
|
76372
|
-
await initPlatform({ adapters: {} }, repoRoot);
|
|
76373
|
-
_initialized = true;
|
|
76374
|
-
return platform;
|
|
76375
|
-
}
|
|
76376
|
-
const result = await readJsonWithDiagnostics(configPath);
|
|
76377
|
-
const platformRoot = _resolvePlatformRoot(configPath);
|
|
76378
|
-
if (!result.ok) {
|
|
76379
|
-
process.stderr.write(`[${appId}:platform] Failed to read kb.config.json, using NoOp adapters
|
|
76380
|
-
`);
|
|
76381
|
-
await initPlatform({ adapters: {} }, repoRoot);
|
|
76382
|
-
_initialized = true;
|
|
76383
|
-
return platform;
|
|
76671
|
+
if (storeRawConfig && rawConfig) {
|
|
76672
|
+
globalThis.__KB_RAW_CONFIG__ = rawConfig;
|
|
76384
76673
|
}
|
|
76385
|
-
|
|
76386
|
-
globalThis.__KB_RAW_CONFIG__ = result.data;
|
|
76387
|
-
}
|
|
76388
|
-
const platformConfig = result.data.platform;
|
|
76389
|
-
if (!platformConfig) {
|
|
76390
|
-
process.stderr.write(`[${appId}:platform] No platform section in kb.config.json, using NoOp adapters
|
|
76391
|
-
`);
|
|
76392
|
-
await initPlatform({ adapters: {} }, repoRoot);
|
|
76393
|
-
_initialized = true;
|
|
76394
|
-
return platform;
|
|
76395
|
-
}
|
|
76396
|
-
await initPlatform(platformConfig, platformRoot);
|
|
76674
|
+
await initPlatform(platformConfig, projectRoot);
|
|
76397
76675
|
_initialized = true;
|
|
76676
|
+
const hasConfig = !!sources.platformDefaults || !!sources.projectConfig;
|
|
76677
|
+
if (!hasConfig) {
|
|
76678
|
+
process.stderr.write(
|
|
76679
|
+
`[${appId}:platform] No kb.config.json found, using NoOp adapters
|
|
76680
|
+
`
|
|
76681
|
+
);
|
|
76682
|
+
}
|
|
76398
76683
|
platform.logger.info("Platform adapters initialized", {
|
|
76399
76684
|
app: appId,
|
|
76400
76685
|
adapters: Object.keys(platformConfig.adapters ?? {}),
|
|
76401
|
-
platformRoot
|
|
76686
|
+
platformRoot,
|
|
76687
|
+
projectRoot,
|
|
76688
|
+
sources
|
|
76402
76689
|
});
|
|
76403
76690
|
} catch (error48) {
|
|
76404
|
-
process.stderr.write(
|
|
76405
|
-
`)
|
|
76691
|
+
process.stderr.write(
|
|
76692
|
+
`[${appId}:platform] Initialization failed, using NoOp adapters: ${error48 instanceof Error ? error48.message : String(error48)}
|
|
76693
|
+
`
|
|
76694
|
+
);
|
|
76406
76695
|
await initPlatform({ adapters: {} }, repoRoot);
|
|
76407
76696
|
_initialized = true;
|
|
76408
76697
|
}
|
|
@@ -76424,25 +76713,6 @@ init_embeddings_proxy();
|
|
|
76424
76713
|
init_vector_store_proxy();
|
|
76425
76714
|
init_storage_proxy();
|
|
76426
76715
|
init_container();
|
|
76427
|
-
async function findRepoRoot(startDir = process.cwd()) {
|
|
76428
|
-
const markersPriority = ["pnpm-workspace.yaml", ".git", "package.json"];
|
|
76429
|
-
for (const marker of markersPriority) {
|
|
76430
|
-
let dir = path4__namespace.default.resolve(startDir);
|
|
76431
|
-
while (true) {
|
|
76432
|
-
try {
|
|
76433
|
-
await fs4.promises.access(path4__namespace.default.join(dir, marker));
|
|
76434
|
-
return dir;
|
|
76435
|
-
} catch {
|
|
76436
|
-
}
|
|
76437
|
-
const parent = path4__namespace.default.dirname(dir);
|
|
76438
|
-
if (parent === dir) {
|
|
76439
|
-
break;
|
|
76440
|
-
}
|
|
76441
|
-
dir = parent;
|
|
76442
|
-
}
|
|
76443
|
-
}
|
|
76444
|
-
return path4__namespace.default.resolve(startDir);
|
|
76445
|
-
}
|
|
76446
76716
|
|
|
76447
76717
|
// src/server.ts
|
|
76448
76718
|
var import_fastify = __toESM(require_fastify());
|
|
@@ -77232,7 +77502,7 @@ __export(util_exports, {
|
|
|
77232
77502
|
getSizableOrigin: () => getSizableOrigin,
|
|
77233
77503
|
hexToUint8Array: () => hexToUint8Array,
|
|
77234
77504
|
isObject: () => isObject,
|
|
77235
|
-
isPlainObject: () =>
|
|
77505
|
+
isPlainObject: () => isPlainObject2,
|
|
77236
77506
|
issue: () => issue,
|
|
77237
77507
|
joinValues: () => joinValues,
|
|
77238
77508
|
jsonStringifyReplacer: () => jsonStringifyReplacer,
|
|
@@ -77374,8 +77644,8 @@ function getElementAtPath(obj, path6) {
|
|
|
77374
77644
|
}
|
|
77375
77645
|
function promiseAllObject(promisesObj) {
|
|
77376
77646
|
const keys = Object.keys(promisesObj);
|
|
77377
|
-
const
|
|
77378
|
-
return Promise.all(
|
|
77647
|
+
const promises5 = keys.map((key) => promisesObj[key]);
|
|
77648
|
+
return Promise.all(promises5).then((results) => {
|
|
77379
77649
|
const resolvedObj = {};
|
|
77380
77650
|
for (let i = 0; i < keys.length; i++) {
|
|
77381
77651
|
resolvedObj[keys[i]] = results[i];
|
|
@@ -77414,7 +77684,7 @@ var allowsEval = cached(() => {
|
|
|
77414
77684
|
return false;
|
|
77415
77685
|
}
|
|
77416
77686
|
});
|
|
77417
|
-
function
|
|
77687
|
+
function isPlainObject2(o) {
|
|
77418
77688
|
if (isObject(o) === false)
|
|
77419
77689
|
return false;
|
|
77420
77690
|
const ctor = o.constructor;
|
|
@@ -77431,7 +77701,7 @@ function isPlainObject(o) {
|
|
|
77431
77701
|
return true;
|
|
77432
77702
|
}
|
|
77433
77703
|
function shallowClone(o) {
|
|
77434
|
-
if (
|
|
77704
|
+
if (isPlainObject2(o))
|
|
77435
77705
|
return { ...o };
|
|
77436
77706
|
if (Array.isArray(o))
|
|
77437
77707
|
return [...o];
|
|
@@ -77624,7 +77894,7 @@ function omit(schema, mask) {
|
|
|
77624
77894
|
return clone(schema, def);
|
|
77625
77895
|
}
|
|
77626
77896
|
function extend(schema, shape) {
|
|
77627
|
-
if (!
|
|
77897
|
+
if (!isPlainObject2(shape)) {
|
|
77628
77898
|
throw new Error("Invalid input to extend: expected a plain object");
|
|
77629
77899
|
}
|
|
77630
77900
|
const checks = schema._zod.def.checks;
|
|
@@ -77647,7 +77917,7 @@ function extend(schema, shape) {
|
|
|
77647
77917
|
return clone(schema, def);
|
|
77648
77918
|
}
|
|
77649
77919
|
function safeExtend(schema, shape) {
|
|
77650
|
-
if (!
|
|
77920
|
+
if (!isPlainObject2(shape)) {
|
|
77651
77921
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
77652
77922
|
}
|
|
77653
77923
|
const def = mergeDefs(schema._zod.def, {
|
|
@@ -79922,7 +80192,7 @@ function mergeValues2(a, b) {
|
|
|
79922
80192
|
if (a instanceof Date && b instanceof Date && +a === +b) {
|
|
79923
80193
|
return { valid: true, data: a };
|
|
79924
80194
|
}
|
|
79925
|
-
if (
|
|
80195
|
+
if (isPlainObject2(a) && isPlainObject2(b)) {
|
|
79926
80196
|
const bKeys = Object.keys(b);
|
|
79927
80197
|
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
79928
80198
|
const newObj = { ...a, ...b };
|
|
@@ -80076,7 +80346,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
80076
80346
|
$ZodType.init(inst, def);
|
|
80077
80347
|
inst._zod.parse = (payload, ctx) => {
|
|
80078
80348
|
const input = payload.value;
|
|
80079
|
-
if (!
|
|
80349
|
+
if (!isPlainObject2(input)) {
|
|
80080
80350
|
payload.issues.push({
|
|
80081
80351
|
expected: "record",
|
|
80082
80352
|
code: "invalid_type",
|