@hcmai/sdk 0.4.8 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +62 -1
- package/dist/index.js +330 -210
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -1094,18 +1094,18 @@ async function action(http, model, actionName, input) {
|
|
|
1094
1094
|
if (scope === "object" && !input.id) {
|
|
1095
1095
|
throw new Error(`object action ${model}.${actionName} requires id`);
|
|
1096
1096
|
}
|
|
1097
|
-
const
|
|
1097
|
+
const path25 = scope === "object" ? `/api/models/${model}/${input.id}/action/${actionName}` : `/api/models/${model}/action/${actionName}`;
|
|
1098
1098
|
const resp = await (async () => {
|
|
1099
1099
|
if (method === "GET") {
|
|
1100
|
-
return http.get(
|
|
1100
|
+
return http.get(path25, { params: queryParams(input) });
|
|
1101
1101
|
}
|
|
1102
1102
|
if (method === "DELETE") {
|
|
1103
|
-
return http.delete(
|
|
1103
|
+
return http.delete(path25, { params: queryParams(input) });
|
|
1104
1104
|
}
|
|
1105
1105
|
if (method === "PUT") {
|
|
1106
|
-
return http.put(
|
|
1106
|
+
return http.put(path25, scope === "object" ? objectBody(input) : classBody(input));
|
|
1107
1107
|
}
|
|
1108
|
-
return http.post(
|
|
1108
|
+
return http.post(path25, scope === "object" ? objectBody(input) : classBody(input));
|
|
1109
1109
|
})();
|
|
1110
1110
|
return resp.data;
|
|
1111
1111
|
}
|
|
@@ -1399,33 +1399,33 @@ import yaml5, { JSON_SCHEMA } from "js-yaml";
|
|
|
1399
1399
|
var REQUIRED = ["model", "key_field", "count", "items"];
|
|
1400
1400
|
function parseFixture(yamlText, sourcePath) {
|
|
1401
1401
|
const where = sourcePath ? ` (${sourcePath})` : "";
|
|
1402
|
-
const
|
|
1402
|
+
const fail2 = (message) => {
|
|
1403
1403
|
throw new CliError({ code: "INVALID_ARGUMENT" /* INVALID_ARGUMENT */, message: `import: ${message}${where}` });
|
|
1404
1404
|
};
|
|
1405
1405
|
let parsed;
|
|
1406
1406
|
try {
|
|
1407
1407
|
parsed = yaml5.load(yamlText, { schema: JSON_SCHEMA });
|
|
1408
1408
|
} catch (e) {
|
|
1409
|
-
return
|
|
1409
|
+
return fail2(`YAML \u89E3\u6790\u5931\u8D25: ${e.message}`);
|
|
1410
1410
|
}
|
|
1411
1411
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1412
|
-
return
|
|
1412
|
+
return fail2("fixture \u4E3A\u7A7A\u6216\u4E0D\u662F mapping");
|
|
1413
1413
|
}
|
|
1414
1414
|
const doc = parsed;
|
|
1415
1415
|
for (const f of REQUIRED) {
|
|
1416
|
-
if (doc[f] === void 0) return
|
|
1416
|
+
if (doc[f] === void 0) return fail2(`fixture \u7F3A\u5FC5\u9700\u5B57\u6BB5 "${f}"`);
|
|
1417
1417
|
}
|
|
1418
|
-
if (!Array.isArray(doc.items)) return
|
|
1419
|
-
if (!Number.isInteger(doc.count)) return
|
|
1418
|
+
if (!Array.isArray(doc.items)) return fail2('"items" \u5FC5\u987B\u662F list');
|
|
1419
|
+
if (!Number.isInteger(doc.count)) return fail2('"count" \u5FC5\u987B\u662F\u6574\u6570');
|
|
1420
1420
|
if (doc.items.length !== doc.count) {
|
|
1421
|
-
return
|
|
1421
|
+
return fail2(`count mismatch: count=${doc.count} \u4F46 items \u6709 ${doc.items.length}`);
|
|
1422
1422
|
}
|
|
1423
1423
|
const keyField = doc.key_field;
|
|
1424
1424
|
const seen = /* @__PURE__ */ new Set();
|
|
1425
1425
|
for (const item of doc.items) {
|
|
1426
1426
|
const k = item[keyField];
|
|
1427
|
-
if (k === void 0 || k === null || k === "") return
|
|
1428
|
-
if (seen.has(String(k))) return
|
|
1427
|
+
if (k === void 0 || k === null || k === "") return fail2(`item \u7F3A key_field "${keyField}"`);
|
|
1428
|
+
if (seen.has(String(k))) return fail2(`duplicate key "${k}" in ${String(doc.model)}`);
|
|
1429
1429
|
seen.add(String(k));
|
|
1430
1430
|
}
|
|
1431
1431
|
return { ...doc, sourcePath };
|
|
@@ -2003,7 +2003,7 @@ var WsClient = class {
|
|
|
2003
2003
|
});
|
|
2004
2004
|
}
|
|
2005
2005
|
this.ws = new WebSocket(this.opts.endpoint);
|
|
2006
|
-
return new Promise((
|
|
2006
|
+
return new Promise((resolve6, reject2) => {
|
|
2007
2007
|
const settle = (fn) => {
|
|
2008
2008
|
off();
|
|
2009
2009
|
fn();
|
|
@@ -2042,7 +2042,7 @@ var WsClient = class {
|
|
|
2042
2042
|
this.intentionalClose = false;
|
|
2043
2043
|
this.sessionId = msg.sessionId;
|
|
2044
2044
|
this.startHeartbeat();
|
|
2045
|
-
settle(
|
|
2045
|
+
settle(resolve6);
|
|
2046
2046
|
this.ws.on("message", this.persistentOnMessage);
|
|
2047
2047
|
this.ws.on("close", this.persistentOnClose);
|
|
2048
2048
|
this.ws.on("error", this.persistentOnClose);
|
|
@@ -2312,13 +2312,13 @@ async function sendMessageAndStream(ws, prompt, opts = {}) {
|
|
|
2312
2312
|
ws.send(cmd);
|
|
2313
2313
|
const events = {
|
|
2314
2314
|
[Symbol.asyncIterator]: () => ({
|
|
2315
|
-
next: () => new Promise((
|
|
2315
|
+
next: () => new Promise((resolve6) => {
|
|
2316
2316
|
if (queue.length) {
|
|
2317
|
-
|
|
2317
|
+
resolve6({ value: queue.shift(), done: false });
|
|
2318
2318
|
} else if (done) {
|
|
2319
|
-
|
|
2319
|
+
resolve6({ value: void 0, done: true });
|
|
2320
2320
|
} else {
|
|
2321
|
-
waiters.push(
|
|
2321
|
+
waiters.push(resolve6);
|
|
2322
2322
|
}
|
|
2323
2323
|
})
|
|
2324
2324
|
})
|
|
@@ -5193,6 +5193,123 @@ function toPosix(value) {
|
|
|
5193
5193
|
return value.replace(/\\/g, "/");
|
|
5194
5194
|
}
|
|
5195
5195
|
|
|
5196
|
+
// src/datapackage/pack.ts
|
|
5197
|
+
import * as fsp2 from "fs/promises";
|
|
5198
|
+
import * as fs10 from "fs";
|
|
5199
|
+
import * as path6 from "path";
|
|
5200
|
+
import yaml7, { JSON_SCHEMA as JSON_SCHEMA2 } from "js-yaml";
|
|
5201
|
+
import * as yazl from "yazl";
|
|
5202
|
+
function fail(message) {
|
|
5203
|
+
throw new CliError({ code: "INVALID_ARGUMENT" /* INVALID_ARGUMENT */, message: `datapackage pack: ${message}` });
|
|
5204
|
+
}
|
|
5205
|
+
function parseManifest(text2, manifestPath) {
|
|
5206
|
+
let parsed;
|
|
5207
|
+
try {
|
|
5208
|
+
parsed = yaml7.load(text2, { schema: JSON_SCHEMA2 });
|
|
5209
|
+
} catch (e) {
|
|
5210
|
+
return fail(`package.yml \u89E3\u6790\u5931\u8D25: ${e.message} (${manifestPath})`);
|
|
5211
|
+
}
|
|
5212
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
5213
|
+
return fail(`package.yml \u4E3A\u7A7A\u6216\u4E0D\u662F mapping (${manifestPath})`);
|
|
5214
|
+
}
|
|
5215
|
+
const doc = parsed;
|
|
5216
|
+
if (typeof doc.name !== "string" || !doc.name.trim()) return fail("package.yml \u7F3A name");
|
|
5217
|
+
if (typeof doc.version !== "string" || !doc.version.trim()) return fail("package.yml \u7F3A version");
|
|
5218
|
+
if (!Array.isArray(doc.models) || doc.models.length === 0) return fail("package.yml \u7F3A models \u5217\u8868");
|
|
5219
|
+
const referenced = [];
|
|
5220
|
+
for (const [i, m] of doc.models.entries()) {
|
|
5221
|
+
const entry = m;
|
|
5222
|
+
if (typeof entry.name !== "string" || !entry.name) return fail(`models[${i}] \u7F3A name`);
|
|
5223
|
+
if (typeof entry.file !== "string" || !entry.file) return fail(`models[${i}] \u7F3A file`);
|
|
5224
|
+
if (!Array.isArray(entry.keys) || entry.keys.length === 0) return fail(`models[${i}] \u7F3A keys`);
|
|
5225
|
+
referenced.push(entry.file);
|
|
5226
|
+
}
|
|
5227
|
+
if (doc.metas !== void 0) {
|
|
5228
|
+
if (!Array.isArray(doc.metas)) return fail("metas \u5FC5\u987B\u662F list");
|
|
5229
|
+
for (const [i, m] of doc.metas.entries()) {
|
|
5230
|
+
const entry = m;
|
|
5231
|
+
if (typeof entry.file !== "string" || !entry.file) return fail(`metas[${i}] \u7F3A file`);
|
|
5232
|
+
referenced.push(entry.file);
|
|
5233
|
+
}
|
|
5234
|
+
}
|
|
5235
|
+
return { name: doc.name.trim(), version: doc.version.trim(), referenced };
|
|
5236
|
+
}
|
|
5237
|
+
async function collectFiles(root, skipAbs) {
|
|
5238
|
+
const out = [];
|
|
5239
|
+
async function walk4(dir, rel) {
|
|
5240
|
+
const entries = await fsp2.readdir(dir, { withFileTypes: true });
|
|
5241
|
+
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
5242
|
+
for (const e of entries) {
|
|
5243
|
+
if (e.name.startsWith(".")) continue;
|
|
5244
|
+
const abs = path6.join(dir, e.name);
|
|
5245
|
+
const relPath = rel ? `${rel}/${e.name}` : e.name;
|
|
5246
|
+
if (e.isDirectory()) {
|
|
5247
|
+
await walk4(abs, relPath);
|
|
5248
|
+
} else if (e.isFile() && !skipAbs.has(path6.resolve(abs))) {
|
|
5249
|
+
out.push(relPath);
|
|
5250
|
+
}
|
|
5251
|
+
}
|
|
5252
|
+
}
|
|
5253
|
+
await walk4(root, "");
|
|
5254
|
+
return out;
|
|
5255
|
+
}
|
|
5256
|
+
async function packDataPackage(packageDir, outPath) {
|
|
5257
|
+
const root = path6.resolve(packageDir);
|
|
5258
|
+
const manifestPath = path6.join(root, "package.yml");
|
|
5259
|
+
let manifestText;
|
|
5260
|
+
try {
|
|
5261
|
+
manifestText = await fsp2.readFile(manifestPath, "utf8");
|
|
5262
|
+
} catch {
|
|
5263
|
+
return fail(`\u76EE\u5F55\u91CC\u6CA1\u6709 package.yml\uFF1A${root}\uFF08\u8981\u4F20\u5305\u7248\u672C\u76EE\u5F55\uFF0C\u5982 fixtures/scenario/<pkg>/v1.0.0\uFF09`);
|
|
5264
|
+
}
|
|
5265
|
+
const { name, version, referenced } = parseManifest(manifestText, manifestPath);
|
|
5266
|
+
for (const relFile of referenced) {
|
|
5267
|
+
const abs = path6.resolve(root, relFile);
|
|
5268
|
+
if (!abs.startsWith(root + path6.sep)) return fail(`\u5F15\u7528\u8DEF\u5F84\u8D8A\u51FA\u5305\u76EE\u5F55: ${relFile}`);
|
|
5269
|
+
if (!fs10.existsSync(abs) || !fs10.statSync(abs).isFile()) {
|
|
5270
|
+
return fail(`manifest \u5F15\u7528\u7684\u6587\u4EF6\u4E0D\u5B58\u5728: ${relFile}`);
|
|
5271
|
+
}
|
|
5272
|
+
}
|
|
5273
|
+
const lastSegment = name.includes("/") ? name.slice(name.lastIndexOf("/") + 1) : name;
|
|
5274
|
+
const artifactPath = path6.resolve(outPath ?? `${lastSegment}-${version}.hcmpkg`);
|
|
5275
|
+
const files = await collectFiles(root, /* @__PURE__ */ new Set([artifactPath]));
|
|
5276
|
+
if (!files.includes("package.yml")) return fail("\u6536\u96C6\u4E0D\u5230 package.yml\uFF08\u4E0D\u5E94\u53D1\u751F\uFF09");
|
|
5277
|
+
await fsp2.mkdir(path6.dirname(artifactPath), { recursive: true });
|
|
5278
|
+
await new Promise((resolve6, reject2) => {
|
|
5279
|
+
const zip = new yazl.ZipFile();
|
|
5280
|
+
for (const rel of files) {
|
|
5281
|
+
zip.addFile(path6.join(root, rel), rel);
|
|
5282
|
+
}
|
|
5283
|
+
zip.end();
|
|
5284
|
+
const ws = fs10.createWriteStream(artifactPath);
|
|
5285
|
+
zip.outputStream.pipe(ws);
|
|
5286
|
+
ws.on("close", () => resolve6());
|
|
5287
|
+
ws.on("error", reject2);
|
|
5288
|
+
zip.outputStream.on("error", reject2);
|
|
5289
|
+
});
|
|
5290
|
+
return { artifactPath, name, version, entryCount: files.length };
|
|
5291
|
+
}
|
|
5292
|
+
|
|
5293
|
+
// src/datapackage/install.ts
|
|
5294
|
+
var DEFAULT_ARTIFACT_CATEGORY = "attachment";
|
|
5295
|
+
async function installDataPackageArtifact(client, artifactPath, opts = {}) {
|
|
5296
|
+
const meta = await uploadDocument(
|
|
5297
|
+
client.raw(),
|
|
5298
|
+
artifactPath,
|
|
5299
|
+
opts.category ?? DEFAULT_ARTIFACT_CATEGORY
|
|
5300
|
+
);
|
|
5301
|
+
const resp = await action(
|
|
5302
|
+
client.raw(),
|
|
5303
|
+
"DataPackage",
|
|
5304
|
+
"installFromDocument",
|
|
5305
|
+
{
|
|
5306
|
+
params: { documentId: meta.documentId, tenantId: client.tenantId }
|
|
5307
|
+
}
|
|
5308
|
+
);
|
|
5309
|
+
const view = resp.result ?? resp;
|
|
5310
|
+
return { documentId: meta.documentId, view };
|
|
5311
|
+
}
|
|
5312
|
+
|
|
5196
5313
|
// src/cache.ts
|
|
5197
5314
|
async function getCacheStats(http, model) {
|
|
5198
5315
|
const resp = await http.get(`/api/models/${model}/cache`);
|
|
@@ -5254,23 +5371,23 @@ async function listTenantMeta(http, opts = {}) {
|
|
|
5254
5371
|
const total = typeof body?.total === "number" ? body.total : payload?.total;
|
|
5255
5372
|
return { items, total, raw: payload };
|
|
5256
5373
|
}
|
|
5257
|
-
async function getTenantMeta(http,
|
|
5258
|
-
const resp = await http.get("/api/tenant-meta/meta", { params: { path:
|
|
5374
|
+
async function getTenantMeta(http, path25) {
|
|
5375
|
+
const resp = await http.get("/api/tenant-meta/meta", { params: { path: path25 } });
|
|
5259
5376
|
const payload = resp.data?.data ?? resp.data;
|
|
5260
5377
|
if (typeof payload === "string") return payload;
|
|
5261
5378
|
return String(payload?.content ?? "");
|
|
5262
5379
|
}
|
|
5263
|
-
async function saveTenantMeta(http,
|
|
5264
|
-
const resp = await http.put("/api/tenant-meta/meta", { content }, { params: { path:
|
|
5380
|
+
async function saveTenantMeta(http, path25, content) {
|
|
5381
|
+
const resp = await http.put("/api/tenant-meta/meta", { content }, { params: { path: path25 } });
|
|
5265
5382
|
return resp.data?.data ?? resp.data;
|
|
5266
5383
|
}
|
|
5267
|
-
async function deleteTenantMeta(http,
|
|
5268
|
-
const resp = await http.delete("/api/tenant-meta/meta", { params: { path:
|
|
5384
|
+
async function deleteTenantMeta(http, path25) {
|
|
5385
|
+
const resp = await http.delete("/api/tenant-meta/meta", { params: { path: path25 } });
|
|
5269
5386
|
return resp.data?.data ?? resp.data;
|
|
5270
5387
|
}
|
|
5271
5388
|
|
|
5272
5389
|
// src/skills.ts
|
|
5273
|
-
import
|
|
5390
|
+
import yaml8, { JSON_SCHEMA as JSON_SCHEMA3 } from "js-yaml";
|
|
5274
5391
|
var CHIRON_BASE_CANDIDATES = ["/api", ""];
|
|
5275
5392
|
function looksLikeManifest(data) {
|
|
5276
5393
|
if (!data || typeof data !== "object") return false;
|
|
@@ -5367,14 +5484,14 @@ function resolveSkillInstallOrder(manifest2, targetId) {
|
|
|
5367
5484
|
throw invalid(`\u6280\u80FD\u76EE\u5F55\u4E2D\u4E0D\u5B58\u5728 ${targetId}`);
|
|
5368
5485
|
}
|
|
5369
5486
|
const state = /* @__PURE__ */ new Map();
|
|
5370
|
-
const
|
|
5487
|
+
const path25 = [];
|
|
5371
5488
|
const order = [];
|
|
5372
5489
|
const visit = (id, requiredBy) => {
|
|
5373
5490
|
const current = state.get(id);
|
|
5374
5491
|
if (current === "done") return;
|
|
5375
5492
|
if (current === "visiting") {
|
|
5376
|
-
const cycleStart =
|
|
5377
|
-
const cycle = [...
|
|
5493
|
+
const cycleStart = path25.indexOf(id);
|
|
5494
|
+
const cycle = [...path25.slice(Math.max(0, cycleStart)), id];
|
|
5378
5495
|
throw invalid(`\u6280\u80FD\u4F9D\u8D56\u5B58\u5728\u73AF: ${cycle.join(" -> ")}`);
|
|
5379
5496
|
}
|
|
5380
5497
|
const skill = byId.get(id);
|
|
@@ -5383,11 +5500,11 @@ function resolveSkillInstallOrder(manifest2, targetId) {
|
|
|
5383
5500
|
}
|
|
5384
5501
|
assertSafeSkillId(skill.id);
|
|
5385
5502
|
state.set(id, "visiting");
|
|
5386
|
-
|
|
5503
|
+
path25.push(id);
|
|
5387
5504
|
for (const required2 of normalizeRequirements(skill.requires, skill.id)) {
|
|
5388
5505
|
visit(required2, skill.id);
|
|
5389
5506
|
}
|
|
5390
|
-
|
|
5507
|
+
path25.pop();
|
|
5391
5508
|
state.set(id, "done");
|
|
5392
5509
|
order.push(skill);
|
|
5393
5510
|
};
|
|
@@ -5409,7 +5526,7 @@ function parseSkillFrontmatter(markdown, skillId) {
|
|
|
5409
5526
|
if (!match) return {};
|
|
5410
5527
|
let frontmatter;
|
|
5411
5528
|
try {
|
|
5412
|
-
frontmatter =
|
|
5529
|
+
frontmatter = yaml8.load(match[1] ?? "", { schema: JSON_SCHEMA3 });
|
|
5413
5530
|
} catch (cause) {
|
|
5414
5531
|
throw new CliError({
|
|
5415
5532
|
code: "INVALID_ARGUMENT" /* INVALID_ARGUMENT */,
|
|
@@ -5478,18 +5595,18 @@ async function resetSettingItem(http, domain, namespace, settingKey, revision) {
|
|
|
5478
5595
|
function parseSettingAssignment(raw) {
|
|
5479
5596
|
const eq = raw.indexOf("=");
|
|
5480
5597
|
if (eq <= 0) throw new Error(`--set \u9700\u8981 namespace.key=value \u5F62\u6001\uFF0C\u6536\u5230 "${raw}"`);
|
|
5481
|
-
const
|
|
5598
|
+
const path25 = raw.slice(0, eq).trim();
|
|
5482
5599
|
const value = raw.slice(eq + 1);
|
|
5483
|
-
const dot =
|
|
5484
|
-
if (dot <= 0) throw new Error(`--set \u7684\u952E\u9700\u542B namespace\uFF0C\u5982 security.password.passwordPolicy=complex\uFF0C\u6536\u5230 "${
|
|
5485
|
-
return { namespace:
|
|
5600
|
+
const dot = path25.lastIndexOf(".");
|
|
5601
|
+
if (dot <= 0) throw new Error(`--set \u7684\u952E\u9700\u542B namespace\uFF0C\u5982 security.password.passwordPolicy=complex\uFF0C\u6536\u5230 "${path25}"`);
|
|
5602
|
+
return { namespace: path25.slice(0, dot), settingKey: path25.slice(dot + 1), value };
|
|
5486
5603
|
}
|
|
5487
5604
|
|
|
5488
5605
|
// src/fde/layout.ts
|
|
5489
5606
|
import { createHash as createHash3, randomBytes as randomBytes2 } from "crypto";
|
|
5490
5607
|
import {
|
|
5491
5608
|
closeSync,
|
|
5492
|
-
existsSync as
|
|
5609
|
+
existsSync as existsSync3,
|
|
5493
5610
|
fsyncSync,
|
|
5494
5611
|
linkSync,
|
|
5495
5612
|
mkdirSync,
|
|
@@ -5500,7 +5617,7 @@ import {
|
|
|
5500
5617
|
writeFileSync,
|
|
5501
5618
|
writeSync
|
|
5502
5619
|
} from "fs";
|
|
5503
|
-
import * as
|
|
5620
|
+
import * as path7 from "path";
|
|
5504
5621
|
var UNSAFE = /[^A-Za-z0-9._-]/g;
|
|
5505
5622
|
function slug(value) {
|
|
5506
5623
|
return (value || "unknown").replace(UNSAFE, "_");
|
|
@@ -5514,10 +5631,10 @@ function tenantSegment(value) {
|
|
|
5514
5631
|
return safeSegment(value);
|
|
5515
5632
|
}
|
|
5516
5633
|
function isInside(p, container) {
|
|
5517
|
-
const rel =
|
|
5634
|
+
const rel = path7.relative(container, p);
|
|
5518
5635
|
if (rel === "") return true;
|
|
5519
|
-
if (
|
|
5520
|
-
return !rel.split(
|
|
5636
|
+
if (path7.isAbsolute(rel)) return false;
|
|
5637
|
+
return !rel.split(path7.sep).includes("..");
|
|
5521
5638
|
}
|
|
5522
5639
|
function hasDotDotComponent(rel) {
|
|
5523
5640
|
return rel.split(/[/\\]/).includes("..");
|
|
@@ -5531,14 +5648,14 @@ var ReconLayout = class {
|
|
|
5531
5648
|
this.root = root;
|
|
5532
5649
|
this.tenantId = String(tenantId);
|
|
5533
5650
|
this.sourceKey = sourceKey;
|
|
5534
|
-
this.dir =
|
|
5651
|
+
this.dir = path7.join(
|
|
5535
5652
|
this.root,
|
|
5536
5653
|
"recon",
|
|
5537
5654
|
tenantSegment(this.tenantId),
|
|
5538
5655
|
safeSegment(sourceKey)
|
|
5539
5656
|
);
|
|
5540
|
-
const container =
|
|
5541
|
-
if (!isInside(
|
|
5657
|
+
const container = path7.resolve(this.root, "recon");
|
|
5658
|
+
if (!isInside(path7.resolve(this.dir), container)) {
|
|
5542
5659
|
throw new LayoutContainmentError(
|
|
5543
5660
|
`\u79DF\u6237\u6BB5\u8D8A\u754C\uFF0C\u62D2\u7EDD\u6784\u9020\u4EA7\u7269\u76EE\u5F55\uFF1AtenantId=${JSON.stringify(tenantId)}\uFF08\u4EA7\u7269\u6839 ${container}\uFF09`
|
|
5544
5661
|
);
|
|
@@ -5561,19 +5678,19 @@ var ReconLayout = class {
|
|
|
5561
5678
|
* ⚠️ 拒绝而不是消毒:消毒会让 `meta/<modelKey>.json` 不再能按 modelKey grep 回去。
|
|
5562
5679
|
*/
|
|
5563
5680
|
resolvePath(rel, createParents = true) {
|
|
5564
|
-
const p =
|
|
5681
|
+
const p = path7.join(this.dir, rel);
|
|
5565
5682
|
if (hasDotDotComponent(rel)) {
|
|
5566
5683
|
throw new LayoutContainmentError(
|
|
5567
5684
|
`\u4EA7\u7269\u76F8\u5BF9\u8DEF\u5F84\u542B \`..\` \u5206\u91CF\uFF0C\u62D2\u7EDD\u5199\u5165\uFF1A${JSON.stringify(rel)}\uFF08\u4F1A\u8D8A\u51FA\u9884\u671F\u5B50\u76EE\u5F55\u3001\u9759\u9ED8\u9876\u6389\u540C\u7EA7\u4EA7\u7269\uFF1B\u4EA7\u7269\u6839 ${this.dir}\uFF09`
|
|
5568
5685
|
);
|
|
5569
5686
|
}
|
|
5570
|
-
if (!isInside(
|
|
5687
|
+
if (!isInside(path7.resolve(p), path7.resolve(this.dir))) {
|
|
5571
5688
|
throw new LayoutContainmentError(
|
|
5572
5689
|
`\u4EA7\u7269\u76F8\u5BF9\u8DEF\u5F84\u8D8A\u754C\uFF0C\u62D2\u7EDD\u5199\u5165\uFF1A${JSON.stringify(rel)}\uFF08\u4EA7\u7269\u6839 ${this.dir}\uFF09`
|
|
5573
5690
|
);
|
|
5574
5691
|
}
|
|
5575
5692
|
if (createParents) {
|
|
5576
|
-
mkdirSync(
|
|
5693
|
+
mkdirSync(path7.dirname(p), { recursive: true });
|
|
5577
5694
|
}
|
|
5578
5695
|
return p;
|
|
5579
5696
|
}
|
|
@@ -5622,18 +5739,18 @@ var WorkLayout = class {
|
|
|
5622
5739
|
}
|
|
5623
5740
|
/** 与 {@link ReconLayout.resolvePath} 同样的两道闸,理由见那里。 */
|
|
5624
5741
|
resolvePath(rel, createParents = true) {
|
|
5625
|
-
const p =
|
|
5742
|
+
const p = path7.join(this.dir, rel);
|
|
5626
5743
|
if (hasDotDotComponent(rel)) {
|
|
5627
5744
|
throw new LayoutContainmentError(
|
|
5628
5745
|
`work \u76EE\u5F55\u76F8\u5BF9\u8DEF\u5F84\u542B \`..\` \u5206\u91CF\uFF0C\u62D2\u7EDD\u5199\u5165\uFF1A${JSON.stringify(rel)}\uFF08work \u6839 ${this.dir}\uFF09`
|
|
5629
5746
|
);
|
|
5630
5747
|
}
|
|
5631
|
-
if (!isInside(
|
|
5748
|
+
if (!isInside(path7.resolve(p), path7.resolve(this.dir))) {
|
|
5632
5749
|
throw new LayoutContainmentError(
|
|
5633
5750
|
`work \u76EE\u5F55\u76F8\u5BF9\u8DEF\u5F84\u8D8A\u754C\uFF0C\u62D2\u7EDD\u5199\u5165\uFF1A${JSON.stringify(rel)}\uFF08work \u6839 ${this.dir}\uFF09`
|
|
5634
5751
|
);
|
|
5635
5752
|
}
|
|
5636
|
-
if (createParents) mkdirSync(
|
|
5753
|
+
if (createParents) mkdirSync(path7.dirname(p), { recursive: true });
|
|
5637
5754
|
return p;
|
|
5638
5755
|
}
|
|
5639
5756
|
/** 写一份 JSON 产物。中文逐字落盘(本地 grep 才找得到),末尾带换行。 */
|
|
@@ -5741,7 +5858,7 @@ var WorkLayout = class {
|
|
|
5741
5858
|
return readFileSync2(this.resolvePath(rel, false));
|
|
5742
5859
|
}
|
|
5743
5860
|
exists(rel) {
|
|
5744
|
-
return
|
|
5861
|
+
return existsSync3(this.resolvePath(rel, false));
|
|
5745
5862
|
}
|
|
5746
5863
|
};
|
|
5747
5864
|
function tempPath(target) {
|
|
@@ -5871,11 +5988,11 @@ function classifyStatus(status) {
|
|
|
5871
5988
|
return "bad-response";
|
|
5872
5989
|
}
|
|
5873
5990
|
var CAPABILITIES_HEADER = "x-hcm-capabilities";
|
|
5874
|
-
function buildUrl(
|
|
5991
|
+
function buildUrl(path25, params) {
|
|
5875
5992
|
const entries = Object.entries(params ?? {}).filter(([, v]) => v !== void 0 && v !== null);
|
|
5876
|
-
if (entries.length === 0) return
|
|
5993
|
+
if (entries.length === 0) return path25;
|
|
5877
5994
|
const qs = entries.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`).join("&");
|
|
5878
|
-
return `${
|
|
5995
|
+
return `${path25}${path25.includes("?") ? "&" : "?"}${qs}`;
|
|
5879
5996
|
}
|
|
5880
5997
|
function lowerHeaders(raw) {
|
|
5881
5998
|
const out = {};
|
|
@@ -5917,14 +6034,14 @@ function httpProbe(http, capabilities) {
|
|
|
5917
6034
|
const headers = { [CAPABILITIES_HEADER]: capabilities };
|
|
5918
6035
|
const probe = {
|
|
5919
6036
|
capabilities,
|
|
5920
|
-
get(
|
|
6037
|
+
get(path25, params) {
|
|
5921
6038
|
return once(
|
|
5922
|
-
() => http.get(buildUrl(
|
|
6039
|
+
() => http.get(buildUrl(path25, params), { headers, validateStatus: () => true })
|
|
5923
6040
|
);
|
|
5924
6041
|
},
|
|
5925
|
-
post(
|
|
6042
|
+
post(path25, body) {
|
|
5926
6043
|
return once(
|
|
5927
|
-
() => http.post(
|
|
6044
|
+
() => http.post(path25, body, {
|
|
5928
6045
|
headers: { ...headers, "content-type": "application/json" },
|
|
5929
6046
|
validateStatus: () => true
|
|
5930
6047
|
})
|
|
@@ -5967,8 +6084,8 @@ function networkOutcome() {
|
|
|
5967
6084
|
|
|
5968
6085
|
// src/fde/recon/runner.ts
|
|
5969
6086
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
5970
|
-
import { existsSync as
|
|
5971
|
-
import * as
|
|
6087
|
+
import { existsSync as existsSync5, readFileSync as readFileSync3, readdirSync } from "fs";
|
|
6088
|
+
import * as path9 from "path";
|
|
5972
6089
|
|
|
5973
6090
|
// src/fde/recon/carry-over.ts
|
|
5974
6091
|
var KIT_CARRY_OVER_KEY = "_kitCarryOver";
|
|
@@ -6036,8 +6153,8 @@ async function crawlMeta(probe, modelKeys2, metaType = DEFAULT_META_TYPE) {
|
|
|
6036
6153
|
const results = probe.getMany ? await probe.getMany([...paths.keys()]) : await sequentialGet(probe, [...paths.keys()]);
|
|
6037
6154
|
const metas = {};
|
|
6038
6155
|
const unavailable = [];
|
|
6039
|
-
for (const [
|
|
6040
|
-
const out = results[
|
|
6156
|
+
for (const [path25, key] of paths) {
|
|
6157
|
+
const out = results[path25];
|
|
6041
6158
|
if (out === void 0) {
|
|
6042
6159
|
unavailable.push({
|
|
6043
6160
|
modelKey: key,
|
|
@@ -6253,8 +6370,8 @@ async function collectActionGates(probe, modelKeys2, state = "") {
|
|
|
6253
6370
|
const statesEchoed = /* @__PURE__ */ new Set();
|
|
6254
6371
|
let noStateEcho = 0;
|
|
6255
6372
|
let answered = 0;
|
|
6256
|
-
for (const [
|
|
6257
|
-
const out = results[
|
|
6373
|
+
for (const [path25, model] of paths) {
|
|
6374
|
+
const out = results[path25];
|
|
6258
6375
|
if (out === void 0) {
|
|
6259
6376
|
unavailable.push({
|
|
6260
6377
|
modelKey: model,
|
|
@@ -6633,8 +6750,8 @@ async function collectMutation(probe, modelKeys2) {
|
|
|
6633
6750
|
const results = probe.getMany ? await probe.getMany([...paths.keys()]) : await sequentialGet(probe, [...paths.keys()]);
|
|
6634
6751
|
const mutation = {};
|
|
6635
6752
|
const problems = [];
|
|
6636
|
-
for (const [
|
|
6637
|
-
const out = results[
|
|
6753
|
+
for (const [path25, key] of paths) {
|
|
6754
|
+
const out = results[path25];
|
|
6638
6755
|
if (out === void 0) {
|
|
6639
6756
|
problems.push(`${key}: mutation-capability ${BATCH_LOST}`);
|
|
6640
6757
|
mutation[key] = Object.fromEntries(
|
|
@@ -6944,8 +7061,8 @@ function writeModelsMd(layout, text2) {
|
|
|
6944
7061
|
}
|
|
6945
7062
|
|
|
6946
7063
|
// src/fde/recon/pointer-audit.ts
|
|
6947
|
-
import { existsSync as
|
|
6948
|
-
import * as
|
|
7064
|
+
import { existsSync as existsSync4 } from "fs";
|
|
7065
|
+
import * as path8 from "path";
|
|
6949
7066
|
function isRecord3(v) {
|
|
6950
7067
|
return Boolean(v) && typeof v === "object" && !Array.isArray(v);
|
|
6951
7068
|
}
|
|
@@ -6958,7 +7075,7 @@ function auditValueDomainPointers(layout, sheets) {
|
|
|
6958
7075
|
const pointer = isRecord3(ref) ? ref.valueDomain : null;
|
|
6959
7076
|
if (typeof pointer !== "string" || pointer === "") continue;
|
|
6960
7077
|
if (!seen.has(pointer)) {
|
|
6961
|
-
seen.set(pointer,
|
|
7078
|
+
seen.set(pointer, existsSync4(path8.join(layout.dir, pointer)));
|
|
6962
7079
|
}
|
|
6963
7080
|
if (!seen.get(pointer)) {
|
|
6964
7081
|
problems.push(
|
|
@@ -7079,11 +7196,11 @@ async function collectCodeTables(probe, modelEntries2, opts = {}) {
|
|
|
7079
7196
|
keys.push(key);
|
|
7080
7197
|
}
|
|
7081
7198
|
for (const key of [...new Set(keys)].sort()) {
|
|
7082
|
-
const
|
|
7199
|
+
const path25 = listPath(key);
|
|
7083
7200
|
const started = tick();
|
|
7084
7201
|
let requests = 0;
|
|
7085
7202
|
let truncatedBy = null;
|
|
7086
|
-
const probeOut = await post.call(probe,
|
|
7203
|
+
const probeOut = await post.call(probe, path25, { page: 0, size: 0 });
|
|
7087
7204
|
requests += 1;
|
|
7088
7205
|
let total = null;
|
|
7089
7206
|
let reason = null;
|
|
@@ -7132,7 +7249,7 @@ async function collectCodeTables(probe, modelEntries2, opts = {}) {
|
|
|
7132
7249
|
failed = `\u89E6\u53D1\u5DE5\u5177\u7684\u6BCF\u8868${which === "requests" ? "\u8BF7\u6C42" : "\u5899\u949F"}\u4E0A\u9650\uFF08${which === "requests" ? `\u5DF2\u53D1 ${requests} \u6B21\u8BF7\u6C42` : `\u5DF2\u82B1 ${elapsed.toFixed(3)}s`}\uFF09\uFF0C\u505C\u5728\u7B2C ${page} \u9875\uFF0C\u5DF2\u6536 ${rows.length} \u884C / \u8BA1\u6570 ${total} \u884C\uFF0C\u672C\u8868\u6807 partial\u3002**\u8FD9\u662F\u5DE5\u5177\u7684\u622A\u65AD\uFF0C\u4E0D\u662F\u670D\u52A1\u7AEF\u7684\u6BDB\u75C5** \u2014\u2014 \u8C03\u5927 valuedomain.${which === "requests" ? "MAX_REQUESTS_PER_TABLE" : "MAX_SECONDS_PER_TABLE"} \u6216\u7ED9 collectCodeTables \u4F20 ${which === "requests" ? "maxRequests" : "maxSeconds"} \u540E\u91CD\u8DD1\u5C31\u80FD\u53D6\u5168`;
|
|
7133
7250
|
break;
|
|
7134
7251
|
}
|
|
7135
|
-
const out = await post.call(probe,
|
|
7252
|
+
const out = await post.call(probe, path25, { page, size: PAGE_SIZE });
|
|
7136
7253
|
requests += 1;
|
|
7137
7254
|
if (out.error !== "ok") {
|
|
7138
7255
|
failed = `\u7B2C ${page} \u9875\u5931\u8D25\uFF08HTTP ${out.status} / ${out.error}\uFF09`;
|
|
@@ -7353,7 +7470,7 @@ function readJsonSoft(file) {
|
|
|
7353
7470
|
}
|
|
7354
7471
|
}
|
|
7355
7472
|
function readCrawledAt(layout) {
|
|
7356
|
-
const body = readJsonSoft(
|
|
7473
|
+
const body = readJsonSoft(path9.join(layout.dir, KIT_CRAWLED_AT_FILE));
|
|
7357
7474
|
const models = isRecord5(body) ? body.models : null;
|
|
7358
7475
|
return isRecord5(models) ? models : {};
|
|
7359
7476
|
}
|
|
@@ -7383,7 +7500,7 @@ function writeCrawledAt(layout, freshKeys, carriedKeys, roundId, started) {
|
|
|
7383
7500
|
return sorted;
|
|
7384
7501
|
}
|
|
7385
7502
|
function finishRound(layout, models, roundId, started, products) {
|
|
7386
|
-
const written = [...new Set(products.filter((rel) => rel &&
|
|
7503
|
+
const written = [...new Set(products.filter((rel) => rel && existsSync5(path9.join(layout.dir, rel))))].sort();
|
|
7387
7504
|
layout.writeJson(KIT_CRAWLED_AT_FILE, {
|
|
7388
7505
|
note: CRAWLED_AT_NOTE,
|
|
7389
7506
|
roundNote: ROUND_NOTE,
|
|
@@ -7395,13 +7512,13 @@ function finishRound(layout, models, roundId, started, products) {
|
|
|
7395
7512
|
return written;
|
|
7396
7513
|
}
|
|
7397
7514
|
function relOf(layout, p) {
|
|
7398
|
-
const rel =
|
|
7515
|
+
const rel = path9.relative(layout.dir, p);
|
|
7399
7516
|
if (!rel || rel.startsWith("..")) return p;
|
|
7400
|
-
return rel.split(
|
|
7517
|
+
return rel.split(path9.sep).join("/");
|
|
7401
7518
|
}
|
|
7402
7519
|
function productRoundId(root, rel) {
|
|
7403
|
-
const p =
|
|
7404
|
-
if (!
|
|
7520
|
+
const p = path9.join(root, rel);
|
|
7521
|
+
if (!existsSync5(p)) return ["missing", null];
|
|
7405
7522
|
const body = readJsonSoft(p);
|
|
7406
7523
|
if (body === void 0 || !isRecord5(body)) return ["unreadable", null];
|
|
7407
7524
|
const rid = body.roundId;
|
|
@@ -7409,7 +7526,7 @@ function productRoundId(root, rel) {
|
|
|
7409
7526
|
return ["stamped", rid];
|
|
7410
7527
|
}
|
|
7411
7528
|
function inspectRound(root) {
|
|
7412
|
-
const raw = readJsonSoft(
|
|
7529
|
+
const raw = readJsonSoft(path9.join(root, KIT_CRAWLED_AT_FILE));
|
|
7413
7530
|
const ledger = isRecord5(raw) ? raw : {};
|
|
7414
7531
|
const rid = ledger.roundId;
|
|
7415
7532
|
const roundId = typeof rid === "string" && rid ? rid : null;
|
|
@@ -7417,7 +7534,7 @@ function inspectRound(root) {
|
|
|
7417
7534
|
const written = Array.isArray(rawWritten) ? rawWritten : null;
|
|
7418
7535
|
let ledgerMissing = null;
|
|
7419
7536
|
if (written !== null) {
|
|
7420
|
-
const gone = written.filter((rel) => typeof rel === "string" && !
|
|
7537
|
+
const gone = written.filter((rel) => typeof rel === "string" && !existsSync5(path9.join(root, rel))).sort();
|
|
7421
7538
|
ledgerMissing = { checked: written.length, count: gone.length, files: gone };
|
|
7422
7539
|
}
|
|
7423
7540
|
const products = [];
|
|
@@ -7516,7 +7633,7 @@ function renderRound(result) {
|
|
|
7516
7633
|
function collectCarryOver(layout, freshMetas) {
|
|
7517
7634
|
const problems = [];
|
|
7518
7635
|
const carriedMetas = {};
|
|
7519
|
-
const metaDir =
|
|
7636
|
+
const metaDir = path9.join(layout.dir, "meta");
|
|
7520
7637
|
const suffix = `.${DEFAULT_META_TYPE}.json`;
|
|
7521
7638
|
let names = [];
|
|
7522
7639
|
try {
|
|
@@ -7527,7 +7644,7 @@ function collectCarryOver(layout, freshMetas) {
|
|
|
7527
7644
|
for (const name of names) {
|
|
7528
7645
|
const key = name.slice(0, -suffix.length);
|
|
7529
7646
|
if (key in freshMetas) continue;
|
|
7530
|
-
const file =
|
|
7647
|
+
const file = path9.join(metaDir, name);
|
|
7531
7648
|
let body;
|
|
7532
7649
|
try {
|
|
7533
7650
|
body = JSON.parse(readFileSync3(file, "utf8"));
|
|
@@ -7543,7 +7660,7 @@ function collectCarryOver(layout, freshMetas) {
|
|
|
7543
7660
|
}
|
|
7544
7661
|
}
|
|
7545
7662
|
const carriedGates = [];
|
|
7546
|
-
const oldGates = readJsonSoft(
|
|
7663
|
+
const oldGates = readJsonSoft(path9.join(layout.dir, "gates.json"));
|
|
7547
7664
|
if (oldGates === void 0) {
|
|
7548
7665
|
problems.push("gates.json: \u6CA1\u6709\u53EF\u6CBF\u7528\u7684\u4E0A\u4E00\u8F6E\u95F8\u8868\uFF08\u4E0D\u5B58\u5728\u6216\u8BFB\u4E0D\u51FA JSON\uFF09");
|
|
7549
7666
|
}
|
|
@@ -7657,7 +7774,7 @@ async function runRecon(probe, layout, opts = {}) {
|
|
|
7657
7774
|
const writtenPaths = new Set(vdWritten);
|
|
7658
7775
|
const codeTableFiles = new Set(
|
|
7659
7776
|
Object.keys(codeTables).filter(
|
|
7660
|
-
(k) => unsafeTableKeyReason(k) === null && writtenPaths.has(
|
|
7777
|
+
(k) => unsafeTableKeyReason(k) === null && writtenPaths.has(path9.join(layout.dir, "valuedomain", `${k}.json`))
|
|
7661
7778
|
)
|
|
7662
7779
|
);
|
|
7663
7780
|
const { mutation, problems: mutProblems } = await collectMutation(probe, Object.keys(metas).sort());
|
|
@@ -7672,7 +7789,7 @@ async function runRecon(probe, layout, opts = {}) {
|
|
|
7672
7789
|
});
|
|
7673
7790
|
products.push(...mappingPaths.map((p) => relOf(layout, p)));
|
|
7674
7791
|
const sheetsWritten = Math.max(mappingPaths.length - 1, 0);
|
|
7675
|
-
let previous = readJsonSoft(
|
|
7792
|
+
let previous = readJsonSoft(path9.join(layout.dir, "fingerprint.json"));
|
|
7676
7793
|
if (!isRecord5(previous)) previous = null;
|
|
7677
7794
|
const current = await computeFingerprint(probe);
|
|
7678
7795
|
products.push(relOf(layout, layout.writeJson("fingerprint.json", current)));
|
|
@@ -7767,12 +7884,12 @@ async function runRecon(probe, layout, opts = {}) {
|
|
|
7767
7884
|
}
|
|
7768
7885
|
|
|
7769
7886
|
// src/fde/seed/command.ts
|
|
7770
|
-
import { existsSync as
|
|
7771
|
-
import * as
|
|
7887
|
+
import { existsSync as existsSync8, readFileSync as readFileSync7, readdirSync as readdirSync2, statSync as statSync7 } from "fs";
|
|
7888
|
+
import * as path15 from "path";
|
|
7772
7889
|
|
|
7773
7890
|
// src/fde/seed/risk.ts
|
|
7774
|
-
import { readFileSync as readFileSync6, realpathSync, statSync as
|
|
7775
|
-
import * as
|
|
7891
|
+
import { readFileSync as readFileSync6, realpathSync, statSync as statSync6 } from "fs";
|
|
7892
|
+
import * as path14 from "path";
|
|
7776
7893
|
|
|
7777
7894
|
// src/fde/seed/key-index.ts
|
|
7778
7895
|
var MAX_PAGE_SIZE = 1e4;
|
|
@@ -7872,7 +7989,7 @@ async function loadKeyIndex(client, model, keyFields, pageSize = PAGE_SIZE_DEFAU
|
|
|
7872
7989
|
for (const name of ["id", ...fields]) {
|
|
7873
7990
|
if (!projected.includes(name)) projected.push(name);
|
|
7874
7991
|
}
|
|
7875
|
-
const
|
|
7992
|
+
const path25 = listPath2(model);
|
|
7876
7993
|
const idx = /* @__PURE__ */ new Map();
|
|
7877
7994
|
let total = null;
|
|
7878
7995
|
let pages = 0;
|
|
@@ -7889,7 +8006,7 @@ async function loadKeyIndex(client, model, keyFields, pageSize = PAGE_SIZE_DEFAU
|
|
|
7889
8006
|
let repeatedIds = 0;
|
|
7890
8007
|
while (total === null || received < total) {
|
|
7891
8008
|
const pageNo = pages;
|
|
7892
|
-
const out = await client.post(
|
|
8009
|
+
const out = await client.post(path25, {
|
|
7893
8010
|
page: pageNo,
|
|
7894
8011
|
size: pageSize,
|
|
7895
8012
|
fields: projected,
|
|
@@ -8053,8 +8170,8 @@ async function loadKeyIndex(client, model, keyFields, pageSize = PAGE_SIZE_DEFAU
|
|
|
8053
8170
|
}
|
|
8054
8171
|
|
|
8055
8172
|
// src/fde/seed/artifacts.ts
|
|
8056
|
-
import * as
|
|
8057
|
-
import { existsSync as
|
|
8173
|
+
import * as path13 from "path";
|
|
8174
|
+
import { existsSync as existsSync7, readFileSync as readFileSync5, statSync as statSync5 } from "fs";
|
|
8058
8175
|
|
|
8059
8176
|
// src/fde/seed/errors.ts
|
|
8060
8177
|
var SourceError = class extends Error {
|
|
@@ -8072,17 +8189,17 @@ var SHEETED_SUFFIXES = [".xlsx", ".xlsm"];
|
|
|
8072
8189
|
var TEXT_SUFFIXES = [".csv", ".tsv"];
|
|
8073
8190
|
|
|
8074
8191
|
// src/fde/seed/source.ts
|
|
8075
|
-
import { existsSync as
|
|
8076
|
-
import * as
|
|
8192
|
+
import { existsSync as existsSync6, openSync as openSync3, readSync as readSync2, closeSync as closeSync3, statSync as statSync4 } from "fs";
|
|
8193
|
+
import * as path12 from "path";
|
|
8077
8194
|
|
|
8078
8195
|
// src/fde/seed/container.ts
|
|
8079
|
-
import { openSync as openSync2, readSync, closeSync as closeSync2, statSync as
|
|
8196
|
+
import { openSync as openSync2, readSync, closeSync as closeSync2, statSync as statSync3 } from "fs";
|
|
8080
8197
|
var CFB_MAGIC = Buffer.from([208, 207, 17, 224, 161, 177, 26, 225]);
|
|
8081
8198
|
var ENCRYPTED_PACKAGE = Buffer.from("EncryptedPackage", "utf16le");
|
|
8082
8199
|
var MAX_ENTRY_BYTES = 128 * 1024 * 1024;
|
|
8083
8200
|
var SCAN_CHUNK_BYTES = 1024 * 1024;
|
|
8084
|
-
function scanFor(
|
|
8085
|
-
const fd = openSync2(
|
|
8201
|
+
function scanFor(path25, needle = ENCRYPTED_PACKAGE, budget = MAX_ENTRY_BYTES) {
|
|
8202
|
+
const fd = openSync2(path25, "r");
|
|
8086
8203
|
try {
|
|
8087
8204
|
let tail = Buffer.alloc(0);
|
|
8088
8205
|
let seen = 0;
|
|
@@ -8103,9 +8220,9 @@ function scanFor(path24, needle = ENCRYPTED_PACKAGE, budget = MAX_ENTRY_BYTES) {
|
|
|
8103
8220
|
closeSync2(fd);
|
|
8104
8221
|
}
|
|
8105
8222
|
}
|
|
8106
|
-
function isCfb(
|
|
8107
|
-
if (
|
|
8108
|
-
const fd = openSync2(
|
|
8223
|
+
function isCfb(path25) {
|
|
8224
|
+
if (statSync3(path25).size < CFB_MAGIC.length) return false;
|
|
8225
|
+
const fd = openSync2(path25, "r");
|
|
8109
8226
|
try {
|
|
8110
8227
|
const head = Buffer.alloc(CFB_MAGIC.length);
|
|
8111
8228
|
const n = readSync(fd, head, 0, CFB_MAGIC.length, 0);
|
|
@@ -8114,9 +8231,9 @@ function isCfb(path24) {
|
|
|
8114
8231
|
closeSync2(fd);
|
|
8115
8232
|
}
|
|
8116
8233
|
}
|
|
8117
|
-
function classifyCfb(
|
|
8118
|
-
if (!isCfb(
|
|
8119
|
-
switch (scanFor(
|
|
8234
|
+
function classifyCfb(path25, budget = MAX_ENTRY_BYTES) {
|
|
8235
|
+
if (!isCfb(path25)) return "not-cfb";
|
|
8236
|
+
switch (scanFor(path25, ENCRYPTED_PACKAGE, budget)) {
|
|
8120
8237
|
case "found":
|
|
8121
8238
|
return "encrypted";
|
|
8122
8239
|
case "absent":
|
|
@@ -8128,7 +8245,7 @@ function classifyCfb(path24, budget = MAX_ENTRY_BYTES) {
|
|
|
8128
8245
|
|
|
8129
8246
|
// src/fde/seed/delimited.ts
|
|
8130
8247
|
import { readFileSync as readFileSync4 } from "fs";
|
|
8131
|
-
import * as
|
|
8248
|
+
import * as path10 from "path";
|
|
8132
8249
|
|
|
8133
8250
|
// src/fde/seed/columns.ts
|
|
8134
8251
|
function resolveColumns(headerCells, dataRows, label, origin, filename, notes) {
|
|
@@ -8295,7 +8412,7 @@ function parseDelimited(text2, delimiter) {
|
|
|
8295
8412
|
return records;
|
|
8296
8413
|
}
|
|
8297
8414
|
function readDelimited(file, suffix, sheet, headerRow, notes, makeDecoder = defaultDecoderFactory) {
|
|
8298
|
-
const filename =
|
|
8415
|
+
const filename = path10.basename(file);
|
|
8299
8416
|
if (sheet !== null && sheet !== void 0) {
|
|
8300
8417
|
throw new SourceError(
|
|
8301
8418
|
"sheet-not-applicable",
|
|
@@ -8376,31 +8493,31 @@ function readDelimited(file, suffix, sheet, headerRow, notes, makeDecoder = defa
|
|
|
8376
8493
|
}
|
|
8377
8494
|
|
|
8378
8495
|
// src/fde/seed/xlsx.ts
|
|
8379
|
-
import * as
|
|
8496
|
+
import * as path11 from "path";
|
|
8380
8497
|
|
|
8381
8498
|
// src/fde/seed/zip.ts
|
|
8382
8499
|
import yauzl from "yauzl";
|
|
8383
8500
|
var MAX_ENTRY_BYTES2 = 128 * 1024 * 1024;
|
|
8384
8501
|
var PROLOG_PEEK_BYTES = 4096;
|
|
8385
8502
|
function openZip(file) {
|
|
8386
|
-
return new Promise((
|
|
8503
|
+
return new Promise((resolve6, reject2) => {
|
|
8387
8504
|
yauzl.open(file, { lazyEntries: true, autoClose: false }, (err, zf) => {
|
|
8388
8505
|
if (err || !zf) {
|
|
8389
8506
|
reject2(err ?? new Error("zip \u6253\u4E0D\u5F00"));
|
|
8390
8507
|
return;
|
|
8391
8508
|
}
|
|
8392
|
-
|
|
8509
|
+
resolve6(zf);
|
|
8393
8510
|
});
|
|
8394
8511
|
});
|
|
8395
8512
|
}
|
|
8396
8513
|
function collectEntries(zf) {
|
|
8397
|
-
return new Promise((
|
|
8514
|
+
return new Promise((resolve6, reject2) => {
|
|
8398
8515
|
const out = /* @__PURE__ */ new Map();
|
|
8399
8516
|
zf.on("entry", (entry) => {
|
|
8400
8517
|
out.set(entry.fileName, entry);
|
|
8401
8518
|
zf.readEntry();
|
|
8402
8519
|
});
|
|
8403
|
-
zf.on("end", () =>
|
|
8520
|
+
zf.on("end", () => resolve6(out));
|
|
8404
8521
|
zf.on("error", reject2);
|
|
8405
8522
|
zf.readEntry();
|
|
8406
8523
|
});
|
|
@@ -8415,7 +8532,7 @@ function readEntryText(zf, entry, label, cap) {
|
|
|
8415
8532
|
)
|
|
8416
8533
|
);
|
|
8417
8534
|
}
|
|
8418
|
-
return new Promise((
|
|
8535
|
+
return new Promise((resolve6, reject2) => {
|
|
8419
8536
|
zf.openReadStream(entry, (err, stream) => {
|
|
8420
8537
|
if (err || !stream) {
|
|
8421
8538
|
reject2(new SourceError("not-xlsx", `${label} \u8BFB\u4E0D\u51FA\u6765\uFF1A${err?.message ?? "\u672A\u77E5"}`, "\u6587\u4EF6\u635F\u574F\u4E86\uFF0C\u91CD\u65B0\u5BFC\u51FA\u4E00\u4EFD"));
|
|
@@ -8469,7 +8586,7 @@ function readEntryText(zf, entry, label, cap) {
|
|
|
8469
8586
|
);
|
|
8470
8587
|
return;
|
|
8471
8588
|
}
|
|
8472
|
-
|
|
8589
|
+
resolve6(text2);
|
|
8473
8590
|
});
|
|
8474
8591
|
});
|
|
8475
8592
|
});
|
|
@@ -8817,7 +8934,7 @@ function readSheetText(text2, shared, headerRow, filename, notes) {
|
|
|
8817
8934
|
return { header, rows: assemble(header, body, headerRow) };
|
|
8818
8935
|
}
|
|
8819
8936
|
async function readXlsx(file, sheet, headerRow, notes, maxEntryBytes) {
|
|
8820
|
-
const filename =
|
|
8937
|
+
const filename = path11.basename(file);
|
|
8821
8938
|
const parts = await openParts(file, filename, maxEntryBytes);
|
|
8822
8939
|
try {
|
|
8823
8940
|
if (!parts.names.has("xl/workbook.xml")) {
|
|
@@ -8895,7 +9012,7 @@ function classifyContainer(file, filename, defaultReason, budget) {
|
|
|
8895
9012
|
);
|
|
8896
9013
|
}
|
|
8897
9014
|
function startsWithPk(file) {
|
|
8898
|
-
if (
|
|
9015
|
+
if (statSync4(file).size < 2) return false;
|
|
8899
9016
|
const fd = openSync3(file, "r");
|
|
8900
9017
|
try {
|
|
8901
9018
|
const head = Buffer.alloc(2);
|
|
@@ -8907,7 +9024,7 @@ function startsWithPk(file) {
|
|
|
8907
9024
|
async function readTable(file, options = {}) {
|
|
8908
9025
|
const sheet = options.sheet ?? null;
|
|
8909
9026
|
const headerRow = options.headerRow ?? 1;
|
|
8910
|
-
const filename =
|
|
9027
|
+
const filename = path12.basename(file);
|
|
8911
9028
|
if (headerRow < 1) {
|
|
8912
9029
|
throw new SourceError(
|
|
8913
9030
|
"bad-header-row",
|
|
@@ -8915,10 +9032,10 @@ async function readTable(file, options = {}) {
|
|
|
8915
9032
|
"\u8868\u5934\u884C\u53F7\u4ECE 1 \u8D77\u7B97\uFF08\u7B2C 1 \u884C\u5C31\u662F 1\uFF09\uFF0C\u4E0D\u662F\u4ECE 0"
|
|
8916
9033
|
);
|
|
8917
9034
|
}
|
|
8918
|
-
if (!
|
|
9035
|
+
if (!existsSync6(file) || !statSync4(file).isFile()) {
|
|
8919
9036
|
throw new SourceError("not-found", `\u627E\u4E0D\u5230\u6E90\u8868 ${file}`, "\u786E\u8BA4\u8DEF\u5F84\uFF0C\u4EE5\u53CA\u6587\u4EF6\u662F\u5426\u8FD8\u5728\u5171\u4EAB\u76D8\u4E0A\u6CA1\u540C\u6B65\u4E0B\u6765");
|
|
8920
9037
|
}
|
|
8921
|
-
const suffix =
|
|
9038
|
+
const suffix = path12.extname(file).toLowerCase();
|
|
8922
9039
|
if (suffix === ".xls") {
|
|
8923
9040
|
throw classifyContainer(file, filename, "legacy-xls", options.scanBudgetBytes);
|
|
8924
9041
|
}
|
|
@@ -9288,7 +9405,7 @@ var MODEL_KEYS = [
|
|
|
9288
9405
|
"valueMap"
|
|
9289
9406
|
];
|
|
9290
9407
|
function loadMapping(file) {
|
|
9291
|
-
if (!
|
|
9408
|
+
if (!existsSync7(file) || !statSync5(file).isFile()) {
|
|
9292
9409
|
throw new MappingError("not-found", `\u627E\u4E0D\u5230\u6620\u5C04\u5DE5\u4EF6 ${file}`, "\u786E\u8BA4\u8DEF\u5F84\uFF1B\u5DE5\u4EF6\u4E00\u822C\u5728 work/mapping.json");
|
|
9293
9410
|
}
|
|
9294
9411
|
let text2;
|
|
@@ -9537,14 +9654,14 @@ function stamp(note, model, file) {
|
|
|
9537
9654
|
}
|
|
9538
9655
|
async function scanSources(mapping, baseDir, options = {}) {
|
|
9539
9656
|
const read = options.readTableImpl ?? readTable;
|
|
9540
|
-
const base = baseDir ??
|
|
9657
|
+
const base = baseDir ?? path13.dirname(mapping.path);
|
|
9541
9658
|
const headers = /* @__PURE__ */ new Map();
|
|
9542
9659
|
const rows = /* @__PURE__ */ new Map();
|
|
9543
9660
|
const notes = [];
|
|
9544
9661
|
const problems = [];
|
|
9545
9662
|
const takenBy = /* @__PURE__ */ new Map();
|
|
9546
9663
|
for (const [index, mm] of mapping.models.entries()) {
|
|
9547
|
-
const file =
|
|
9664
|
+
const file = path13.join(base, mm.source.file);
|
|
9548
9665
|
const owner = takenBy.get(mm.model);
|
|
9549
9666
|
if (owner !== void 0) {
|
|
9550
9667
|
problems.push(
|
|
@@ -9715,7 +9832,7 @@ function checkOnExisting(mm) {
|
|
|
9715
9832
|
return [];
|
|
9716
9833
|
}
|
|
9717
9834
|
function checkSourceRef(mm) {
|
|
9718
|
-
const suffix =
|
|
9835
|
+
const suffix = path13.extname(mm.source.file).toLowerCase();
|
|
9719
9836
|
if (!SUPPORTED_SUFFIXES.includes(suffix)) {
|
|
9720
9837
|
return [
|
|
9721
9838
|
problem(
|
|
@@ -10656,16 +10773,16 @@ function rowCycles(parents) {
|
|
|
10656
10773
|
const cycles = [];
|
|
10657
10774
|
for (const start of [...parents.keys()].sort((a, b) => a - b)) {
|
|
10658
10775
|
if (done.has(start)) continue;
|
|
10659
|
-
const
|
|
10776
|
+
const path25 = [];
|
|
10660
10777
|
const seen = /* @__PURE__ */ new Map();
|
|
10661
10778
|
let node = start;
|
|
10662
10779
|
while (node !== void 0 && !seen.has(node) && !done.has(node)) {
|
|
10663
|
-
seen.set(node,
|
|
10664
|
-
|
|
10780
|
+
seen.set(node, path25.length);
|
|
10781
|
+
path25.push(node);
|
|
10665
10782
|
node = parents.get(node);
|
|
10666
10783
|
}
|
|
10667
|
-
if (node !== void 0 && seen.has(node)) cycles.push(
|
|
10668
|
-
for (const n of
|
|
10784
|
+
if (node !== void 0 && seen.has(node)) cycles.push(path25.slice(seen.get(node)));
|
|
10785
|
+
for (const n of path25) done.add(n);
|
|
10669
10786
|
}
|
|
10670
10787
|
return cycles;
|
|
10671
10788
|
}
|
|
@@ -11020,7 +11137,7 @@ var NEEDS_SHEET = [
|
|
|
11020
11137
|
];
|
|
11021
11138
|
function whyNoSheetNoChecks(sourceFile) {
|
|
11022
11139
|
const workbook = SHEETED_SUFFIXES.includes(
|
|
11023
|
-
|
|
11140
|
+
path14.extname(sourceFile).toLowerCase()
|
|
11024
11141
|
);
|
|
11025
11142
|
let text2 = `\u{1F534} \u4F9D\u8D56\u8FD9\u4EFD sheet \u7684 ${NEEDS_SHEET.length} \u7EC4\u5224\u636E**\u4E00\u7EC4\u90FD\u6CA1\u8DD1**\uFF1A${NEEDS_SHEET.join("\uFF1B")}`;
|
|
11026
11143
|
if (!workbook) {
|
|
@@ -11104,7 +11221,7 @@ function unsafeRelReason(rel) {
|
|
|
11104
11221
|
if (hasDotDotComponent(rel)) {
|
|
11105
11222
|
return `\u542B \`..\` \u5206\u91CF\uFF0C\u4F1A\u8BFB\u5230 recon \u4EA7\u7269\u76EE\u5F55\u4E4B\u5916\uFF1A${JSON.stringify(rel)}`;
|
|
11106
11223
|
}
|
|
11107
|
-
if (
|
|
11224
|
+
if (path14.isAbsolute(rel) || rel.startsWith("/") || rel.startsWith("\\")) {
|
|
11108
11225
|
return `\u662F\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4E0D\u662F recon \u4EA7\u7269\u91CC\u7684\u76F8\u5BF9\u4F4D\u7F6E\uFF1A${JSON.stringify(rel)}`;
|
|
11109
11226
|
}
|
|
11110
11227
|
return null;
|
|
@@ -11132,7 +11249,7 @@ var ReconView = class {
|
|
|
11132
11249
|
resolve(rel) {
|
|
11133
11250
|
const reason = unsafeRelReason(rel);
|
|
11134
11251
|
if (reason !== null) return { file: null, reason };
|
|
11135
|
-
const file =
|
|
11252
|
+
const file = path14.join(this.dir, rel);
|
|
11136
11253
|
if (!isInside(realOf(file), realOf(this.dir))) {
|
|
11137
11254
|
return { file: null, reason: `\u89E3\u6790\u4E4B\u540E\u843D\u5728 recon \u4EA7\u7269\u76EE\u5F55\u4E4B\u5916\uFF1A${file}` };
|
|
11138
11255
|
}
|
|
@@ -11165,7 +11282,7 @@ var ReconView = class {
|
|
|
11165
11282
|
const cached = this.sheets.get(modelKey);
|
|
11166
11283
|
if (cached !== void 0) return cached;
|
|
11167
11284
|
const rel = `${MAPPING_SUBDIR}/${modelKey}.json`;
|
|
11168
|
-
const got = { ...this.readJson(rel), path:
|
|
11285
|
+
const got = { ...this.readJson(rel), path: path14.join(this.dir, rel) };
|
|
11169
11286
|
this.sheets.set(modelKey, got);
|
|
11170
11287
|
return got;
|
|
11171
11288
|
}
|
|
@@ -11260,21 +11377,21 @@ function decodeUtf8(bytes2) {
|
|
|
11260
11377
|
}
|
|
11261
11378
|
function isFile(p) {
|
|
11262
11379
|
try {
|
|
11263
|
-
return
|
|
11380
|
+
return statSync6(p).isFile();
|
|
11264
11381
|
} catch {
|
|
11265
11382
|
return false;
|
|
11266
11383
|
}
|
|
11267
11384
|
}
|
|
11268
11385
|
function realOf(p) {
|
|
11269
11386
|
const rest = [];
|
|
11270
|
-
let cur =
|
|
11387
|
+
let cur = path14.resolve(p);
|
|
11271
11388
|
for (; ; ) {
|
|
11272
11389
|
try {
|
|
11273
|
-
return
|
|
11390
|
+
return path14.join(realpathSync(cur), ...rest);
|
|
11274
11391
|
} catch {
|
|
11275
|
-
const parent =
|
|
11276
|
-
if (parent === cur) return
|
|
11277
|
-
rest.unshift(
|
|
11392
|
+
const parent = path14.dirname(cur);
|
|
11393
|
+
if (parent === cur) return path14.resolve(p);
|
|
11394
|
+
rest.unshift(path14.basename(cur));
|
|
11278
11395
|
cur = parent;
|
|
11279
11396
|
}
|
|
11280
11397
|
}
|
|
@@ -11872,7 +11989,7 @@ function noteProblems(notes) {
|
|
|
11872
11989
|
const model = n.model;
|
|
11873
11990
|
const file = n.file;
|
|
11874
11991
|
const column = n.column;
|
|
11875
|
-
const suffix = typeof file === "string" ?
|
|
11992
|
+
const suffix = typeof file === "string" ? path14.extname(file).toLowerCase() : "";
|
|
11876
11993
|
const notation = NOTATION_BY_SUFFIX[suffix] ?? NOTATION_UNKNOWN;
|
|
11877
11994
|
out.push(
|
|
11878
11995
|
problem3(
|
|
@@ -12042,7 +12159,7 @@ function riskModel(mm, entry, recon, tables, plan = null) {
|
|
|
12042
12159
|
);
|
|
12043
12160
|
block("AC6_PREMISE_SOURCE_ROWS_EMPTY");
|
|
12044
12161
|
}
|
|
12045
|
-
if (!SHEETED_SUFFIXES.includes(
|
|
12162
|
+
if (!SHEETED_SUFFIXES.includes(path14.extname(mm.source.file).toLowerCase())) {
|
|
12046
12163
|
notApplicable.set(CHECK_DATE_SERIAL, WHY_NOT_A_WORKBOOK);
|
|
12047
12164
|
} else if (rows === void 0) {
|
|
12048
12165
|
block(WHY_NO_SOURCE_ROWS, [CHECK_DATE_SERIAL]);
|
|
@@ -12301,20 +12418,20 @@ var MAPPING_FILE = "mapping.json";
|
|
|
12301
12418
|
var OFFLINE_COMMANDS = ["find", "values"];
|
|
12302
12419
|
function seedWorkDir(args) {
|
|
12303
12420
|
if (args.work) return args.work;
|
|
12304
|
-
return
|
|
12421
|
+
return path15.join(args.out, WORK_DIRNAME, tenantSegment(String(args.tenant)));
|
|
12305
12422
|
}
|
|
12306
12423
|
function seedMappingPath(args, work) {
|
|
12307
|
-
return args.mapping ? args.mapping :
|
|
12424
|
+
return args.mapping ? args.mapping : path15.join(work, MAPPING_FILE);
|
|
12308
12425
|
}
|
|
12309
12426
|
function seedBaselines(out, tenant) {
|
|
12310
|
-
const base =
|
|
12311
|
-
if (!
|
|
12427
|
+
const base = path15.join(out, "recon", tenantSegment(String(tenant)));
|
|
12428
|
+
if (!existsSync8(base) || !statSync7(base).isDirectory()) return [base, []];
|
|
12312
12429
|
const found = [];
|
|
12313
12430
|
for (const name of readdirSync2(base).sort()) {
|
|
12314
|
-
const reconDir =
|
|
12315
|
-
if (!
|
|
12316
|
-
const indexFile =
|
|
12317
|
-
if (
|
|
12431
|
+
const reconDir = path15.join(base, name);
|
|
12432
|
+
if (!statSync7(reconDir).isDirectory()) continue;
|
|
12433
|
+
const indexFile = path15.join(reconDir, "index", "fields.jsonl");
|
|
12434
|
+
if (existsSync8(indexFile)) found.push({ indexFile, reconDir });
|
|
12318
12435
|
}
|
|
12319
12436
|
return [base, found];
|
|
12320
12437
|
}
|
|
@@ -12409,7 +12526,7 @@ var JOURNAL_STOP_UNKNOWN = [
|
|
|
12409
12526
|
""
|
|
12410
12527
|
];
|
|
12411
12528
|
function journalNote(journalPath, whenPresent = "") {
|
|
12412
|
-
if (!
|
|
12529
|
+
if (!existsSync8(journalPath)) {
|
|
12413
12530
|
return ` \u53F0\u8D26 \`${journalPath}\` **\u6B64\u523B\u4E0D\u5728\u76D8\u4E0A**\uFF08\u672C\u5C42\u521A\u67E5\u8FC7\uFF09\u2014\u2014\u6240\u4EE5\u6CA1\u6709\u300C\u5DF2\u7ECF\u8BB0\u4E0B\u6765\u7684\u5199\u300D\u53EF\u4EE5\u62FF\u3002`;
|
|
12414
12531
|
}
|
|
12415
12532
|
return ` \u53F0\u8D26\u5728 \`${journalPath}\`\u3002${whenPresent}`;
|
|
@@ -12445,7 +12562,7 @@ function existingJournalStop(journalPath, entries) {
|
|
|
12445
12562
|
}
|
|
12446
12563
|
|
|
12447
12564
|
// src/fde/seed/plan-io.ts
|
|
12448
|
-
import * as
|
|
12565
|
+
import * as path16 from "path";
|
|
12449
12566
|
var PLAN_JSON_KEYS = [
|
|
12450
12567
|
"version",
|
|
12451
12568
|
"roundId",
|
|
@@ -12582,7 +12699,7 @@ var PlanReadError = class extends Error {
|
|
|
12582
12699
|
};
|
|
12583
12700
|
function readImportPlan(out) {
|
|
12584
12701
|
const work = new WorkLayout(out);
|
|
12585
|
-
const target =
|
|
12702
|
+
const target = path16.join(out, IMPORT_PLAN_FILE);
|
|
12586
12703
|
if (!work.exists(IMPORT_PLAN_FILE)) {
|
|
12587
12704
|
throw new PlanReadError(
|
|
12588
12705
|
"plan-missing",
|
|
@@ -12774,9 +12891,9 @@ function rowFromJson(r) {
|
|
|
12774
12891
|
|
|
12775
12892
|
// src/fde/seed/journal.ts
|
|
12776
12893
|
import { createHash as createHash4 } from "crypto";
|
|
12777
|
-
import { existsSync as
|
|
12894
|
+
import { existsSync as existsSync9, statSync as statSync8 } from "fs";
|
|
12778
12895
|
import * as os3 from "os";
|
|
12779
|
-
import * as
|
|
12896
|
+
import * as path17 from "path";
|
|
12780
12897
|
var JOURNAL_FILE = "journal.jsonl";
|
|
12781
12898
|
var STATUSES = ["done", "skipped", "failed", "unknown", "quarantined"];
|
|
12782
12899
|
var STEP_SEND = "send";
|
|
@@ -13023,7 +13140,7 @@ function waiverFromJson(row, where) {
|
|
|
13023
13140
|
};
|
|
13024
13141
|
}
|
|
13025
13142
|
function workDirOf(p) {
|
|
13026
|
-
if (
|
|
13143
|
+
if (existsSync9(p) && !statSync8(p).isDirectory()) {
|
|
13027
13144
|
throw new JournalError(
|
|
13028
13145
|
"not-a-work-dir",
|
|
13029
13146
|
`${p} \u5DF2\u5B58\u5728\uFF0C\u4F46\u5B83\u4E0D\u662F\u76EE\u5F55 \u2014\u2014 \u53F0\u8D26\u6536\u7684\u662F **work \u76EE\u5F55**\uFF0C\u4E0D\u662F\u53F0\u8D26\u6587\u4EF6`,
|
|
@@ -13050,7 +13167,7 @@ var Journal = class _Journal {
|
|
|
13050
13167
|
constructor(workDir, entries = [], exists = false, waivers = []) {
|
|
13051
13168
|
this.workDir = workDirOf(workDir);
|
|
13052
13169
|
this.layout = new WorkLayout(this.workDir);
|
|
13053
|
-
this.path =
|
|
13170
|
+
this.path = path17.join(this.workDir, JOURNAL_FILE);
|
|
13054
13171
|
this.entries = [...entries];
|
|
13055
13172
|
this.waivers = [...waivers];
|
|
13056
13173
|
this.exists = exists;
|
|
@@ -13064,8 +13181,8 @@ var Journal = class _Journal {
|
|
|
13064
13181
|
*/
|
|
13065
13182
|
static load(p) {
|
|
13066
13183
|
const work = workDirOf(p);
|
|
13067
|
-
const target =
|
|
13068
|
-
if (!
|
|
13184
|
+
const target = path17.join(work, JOURNAL_FILE);
|
|
13185
|
+
if (!existsSync9(target)) return new _Journal(work, [], false);
|
|
13069
13186
|
let text2;
|
|
13070
13187
|
try {
|
|
13071
13188
|
text2 = new WorkLayout(work).readText(JOURNAL_FILE);
|
|
@@ -13360,8 +13477,8 @@ function sameIdentity(a, b) {
|
|
|
13360
13477
|
return a.length === b.length && a.every((x, i) => x === b[i]);
|
|
13361
13478
|
}
|
|
13362
13479
|
function readLease(layout, file = LEASE_FILE) {
|
|
13363
|
-
const p =
|
|
13364
|
-
if (!
|
|
13480
|
+
const p = path17.join(layout.dir, file);
|
|
13481
|
+
if (!existsSync9(p)) return [null, `${p} \u4E0D\u5B58\u5728`];
|
|
13365
13482
|
let text2;
|
|
13366
13483
|
try {
|
|
13367
13484
|
text2 = layout.readText(file);
|
|
@@ -13419,7 +13536,7 @@ var Lease = class {
|
|
|
13419
13536
|
beatMark;
|
|
13420
13537
|
constructor(layout, spec, reclaimed = null, clock = SYSTEM_CLOCK) {
|
|
13421
13538
|
this.layout = layout;
|
|
13422
|
-
this.path =
|
|
13539
|
+
this.path = path17.join(layout.dir, LEASE_FILE);
|
|
13423
13540
|
this.host = spec.host;
|
|
13424
13541
|
this.pid = spec.pid;
|
|
13425
13542
|
this.roundId = spec.roundId;
|
|
@@ -13487,7 +13604,7 @@ var Lease = class {
|
|
|
13487
13604
|
throw new LeaseViolation(
|
|
13488
13605
|
"lease-unwritable",
|
|
13489
13606
|
`\u76D6\u5FC3\u8DF3\u65F6\u5199\u4E0D\u8FDB\u79DF\u7EA6\u6587\u4EF6 ${this.path}\uFF1A${String(e)}`,
|
|
13490
|
-
`**\u8FD9\u4E00\u6B21\u5FC3\u8DF3\u6CA1\u6709\u76D6\u4E0A**\uFF0C\u79DF\u7EA6\u6587\u4EF6\u7684\u5185\u5BB9**\u6CA1\u6709\u88AB\u6539\u52A8**\uFF08\u4E34\u65F6\u6587\u4EF6\u5DF2\u6536\u62FE\u6389\uFF0C\u6539\u540D\u6CA1\u9876\u4E0A\u53BB\uFF09\u3002${leaseStampNote(held.heartbeatAt, beat, attemptedAt)}\u5199\u4E4B\u524D\u521A\u6838\u5BF9\u8FC7\u8EAB\u4EFD \u2014\u2014 **\u90A3\u4E00\u6B21\u8BFB\u5230\u7684**\u79DF\u7EA6\u662F\u6211\u65B9\u7684\u3002\u4E09\u79CD\u5E38\u89C1\u6210\u56E0\uFF1A\u2460 \u78C1\u76D8\u6EE1\uFF1B\u2461 \u76EE\u5F55\u53EA\u8BFB\u6216\u6743\u9650\u4E0D\u8DB3\uFF1B\u2462 \u4ECB\u8D28\u51FA\u9519\u3002**\u5148\u505C\u624B\u518D\u5904\u7406**\uFF1A\u5DF2\u7ECF\u53D1\u51FA\u53BB\u7684\u5199\u90FD\u8BB0\u5728 ${
|
|
13607
|
+
`**\u8FD9\u4E00\u6B21\u5FC3\u8DF3\u6CA1\u6709\u76D6\u4E0A**\uFF0C\u79DF\u7EA6\u6587\u4EF6\u7684\u5185\u5BB9**\u6CA1\u6709\u88AB\u6539\u52A8**\uFF08\u4E34\u65F6\u6587\u4EF6\u5DF2\u6536\u62FE\u6389\uFF0C\u6539\u540D\u6CA1\u9876\u4E0A\u53BB\uFF09\u3002${leaseStampNote(held.heartbeatAt, beat, attemptedAt)}\u5199\u4E4B\u524D\u521A\u6838\u5BF9\u8FC7\u8EAB\u4EFD \u2014\u2014 **\u90A3\u4E00\u6B21\u8BFB\u5230\u7684**\u79DF\u7EA6\u662F\u6211\u65B9\u7684\u3002\u4E09\u79CD\u5E38\u89C1\u6210\u56E0\uFF1A\u2460 \u78C1\u76D8\u6EE1\uFF1B\u2461 \u76EE\u5F55\u53EA\u8BFB\u6216\u6743\u9650\u4E0D\u8DB3\uFF1B\u2462 \u4ECB\u8D28\u51FA\u9519\u3002**\u5148\u505C\u624B\u518D\u5904\u7406**\uFF1A\u5DF2\u7ECF\u53D1\u51FA\u53BB\u7684\u5199\u90FD\u8BB0\u5728 ${path17.dirname(this.path)} \u7684\u53F0\u8D26\u91CC\uFF08\u5199\u524D\u843D\u8D26\uFF1A\u53D1\u8BF7\u6C42\u4E4B\u524D\u5148 begin \u843D\u4E00\u6761 unknown\uFF09\u3002${LEASE_JUDGE_SIGNPOST}`
|
|
13491
13608
|
);
|
|
13492
13609
|
}
|
|
13493
13610
|
this.beatMark = this.clock.monotonic();
|
|
@@ -13533,7 +13650,7 @@ function acquireLease(workDir, roundId, clock = SYSTEM_CLOCK) {
|
|
|
13533
13650
|
);
|
|
13534
13651
|
}
|
|
13535
13652
|
const layout = new WorkLayout(workDirOf(workDir));
|
|
13536
|
-
const p =
|
|
13653
|
+
const p = path17.join(layout.dir, LEASE_FILE);
|
|
13537
13654
|
const me = [hostname2(), process.pid, roundId];
|
|
13538
13655
|
const now = clock.now();
|
|
13539
13656
|
const fresh = new Lease(
|
|
@@ -14355,8 +14472,8 @@ function applyReportText(report) {
|
|
|
14355
14472
|
}
|
|
14356
14473
|
|
|
14357
14474
|
// src/fde/seed/drift.ts
|
|
14358
|
-
import { existsSync as
|
|
14359
|
-
import * as
|
|
14475
|
+
import { existsSync as existsSync10, readFileSync as readFileSync8, realpathSync as realpathSync2, statSync as statSync9 } from "fs";
|
|
14476
|
+
import * as path18 from "path";
|
|
14360
14477
|
var VERDICT_SAME = "same";
|
|
14361
14478
|
var VERDICT_DIVERGED = "diverged";
|
|
14362
14479
|
var VERDICT_INCOMPARABLE = "incomparable";
|
|
@@ -14383,21 +14500,21 @@ function resolveBaselineDir(outRoot, baselineRef) {
|
|
|
14383
14500
|
return [null, CAUSE_PLAN_HAS_NO_BASELINE];
|
|
14384
14501
|
}
|
|
14385
14502
|
const ref = String(baselineRef);
|
|
14386
|
-
const root =
|
|
14503
|
+
const root = path18.join(outRoot, RECON_DIRNAME);
|
|
14387
14504
|
const parts = ref.split(/[\\/]+/);
|
|
14388
|
-
if (!ref || parts.includes("..") ||
|
|
14505
|
+
if (!ref || parts.includes("..") || path18.isAbsolute(ref) || /^[A-Za-z]:/.test(ref)) {
|
|
14389
14506
|
return [null, CAUSE_BASELINE_NOT_ON_DISK];
|
|
14390
14507
|
}
|
|
14391
|
-
const base =
|
|
14508
|
+
const base = path18.join(root, ref);
|
|
14392
14509
|
let inside;
|
|
14393
14510
|
try {
|
|
14394
14511
|
const realRoot = realpathSync2(root);
|
|
14395
14512
|
const realBase = realpathSync2(base);
|
|
14396
|
-
inside = realBase === realRoot || realBase.startsWith(realRoot +
|
|
14513
|
+
inside = realBase === realRoot || realBase.startsWith(realRoot + path18.sep);
|
|
14397
14514
|
} catch {
|
|
14398
14515
|
inside = false;
|
|
14399
14516
|
}
|
|
14400
|
-
if (!inside || !
|
|
14517
|
+
if (!inside || !existsSync10(base) || !statSync9(base).isDirectory()) {
|
|
14401
14518
|
return [null, CAUSE_BASELINE_NOT_ON_DISK];
|
|
14402
14519
|
}
|
|
14403
14520
|
return [base, null];
|
|
@@ -14407,7 +14524,7 @@ function loadRecordedFingerprint(outRoot, baselineRef) {
|
|
|
14407
14524
|
if (cause !== null) return [null, cause];
|
|
14408
14525
|
let body;
|
|
14409
14526
|
try {
|
|
14410
|
-
body = JSON.parse(readFileSync8(
|
|
14527
|
+
body = JSON.parse(readFileSync8(path18.join(base, FINGERPRINT_FILE), "utf-8"));
|
|
14411
14528
|
} catch {
|
|
14412
14529
|
return [null, CAUSE_FINGERPRINT_UNREADABLE];
|
|
14413
14530
|
}
|
|
@@ -15256,8 +15373,8 @@ function writeRisk(risk, out) {
|
|
|
15256
15373
|
}
|
|
15257
15374
|
|
|
15258
15375
|
// src/fde/seed/value-hints.ts
|
|
15259
|
-
import { existsSync as
|
|
15260
|
-
import * as
|
|
15376
|
+
import { existsSync as existsSync11, readFileSync as readFileSync9 } from "fs";
|
|
15377
|
+
import * as path19 from "path";
|
|
15261
15378
|
var HINT_REF = (domain) => ` \u503C\uFF1A\u586B id\uFF08\u4E0D\u662F code\uFF09\u2190 ${domain}`;
|
|
15262
15379
|
var HINT_NO_DOMAIN = (to) => ` \u503C\uFF1A\u586B ${to} \u7684 id\uFF08\u4E0D\u662F code\uFF09\uFF1B\u65E0\u5BF9\u7167\u8868\uFF0C\u6309\u4E1A\u52A1\u952E\u73B0\u67E5`;
|
|
15263
15380
|
var HINT_ENUM = (n, model) => ` \u503C\uFF1A\u679A\u4E3E ${n} \u9879 \u2190 mapping/${model}.json`;
|
|
@@ -15273,7 +15390,7 @@ function isLocalName(name) {
|
|
|
15273
15390
|
if (typeof name !== "string" || name.length === 0) return false;
|
|
15274
15391
|
if (name.includes("/") || name.includes("\\")) return false;
|
|
15275
15392
|
if (name === "." || name === "..") return false;
|
|
15276
|
-
return !
|
|
15393
|
+
return !path19.isAbsolute(name);
|
|
15277
15394
|
}
|
|
15278
15395
|
var readJson = (file) => {
|
|
15279
15396
|
try {
|
|
@@ -15293,7 +15410,7 @@ var ValueHints = class {
|
|
|
15293
15410
|
/** → `{modelKey: completeness}`;**索引根本读不到时返回 `null`**(与「读到了但是空的」分开)。 */
|
|
15294
15411
|
domainIndex() {
|
|
15295
15412
|
if (this.domains === void 0) {
|
|
15296
|
-
const body = readJson(
|
|
15413
|
+
const body = readJson(path19.join(this.root, "valuedomain", "_index.json"));
|
|
15297
15414
|
const by = isRec(body) ? body.byCompleteness : void 0;
|
|
15298
15415
|
if (!isRec(by)) {
|
|
15299
15416
|
this.domains = null;
|
|
@@ -15314,7 +15431,7 @@ var ValueHints = class {
|
|
|
15314
15431
|
if (!this.sheets.has(key)) {
|
|
15315
15432
|
let fields = null;
|
|
15316
15433
|
if (isLocalName(key)) {
|
|
15317
|
-
const body = readJson(
|
|
15434
|
+
const body = readJson(path19.join(this.root, "mapping", `${key}.json`));
|
|
15318
15435
|
const rows = isRec(body) ? body.fields : void 0;
|
|
15319
15436
|
if (Array.isArray(rows)) {
|
|
15320
15437
|
fields = /* @__PURE__ */ new Map();
|
|
@@ -15332,7 +15449,7 @@ var ValueHints = class {
|
|
|
15332
15449
|
const index = this.domainIndex();
|
|
15333
15450
|
const completeness = index === null ? void 0 : index.get(target);
|
|
15334
15451
|
const pointer = ref.valueDomain;
|
|
15335
|
-
const landed = isLocalName(target) &&
|
|
15452
|
+
const landed = isLocalName(target) && existsSync11(path19.join(this.root, "valuedomain", `${target}.json`));
|
|
15336
15453
|
let line;
|
|
15337
15454
|
if (pointer && completeness && completeness !== "unavailable" && landed) {
|
|
15338
15455
|
line = HINT_REF(String(pointer));
|
|
@@ -15522,8 +15639,8 @@ function renderFind(hits, term, total, options = {}) {
|
|
|
15522
15639
|
}
|
|
15523
15640
|
|
|
15524
15641
|
// src/fde/seed/values.ts
|
|
15525
|
-
import { existsSync as
|
|
15526
|
-
import * as
|
|
15642
|
+
import { existsSync as existsSync12, readFileSync as readFileSync10 } from "fs";
|
|
15643
|
+
import * as path20 from "path";
|
|
15527
15644
|
var readJson2 = (file) => {
|
|
15528
15645
|
try {
|
|
15529
15646
|
return JSON.parse(readFileSync10(file, "utf-8"));
|
|
@@ -15570,13 +15687,13 @@ function valuesRoundCaveat(round) {
|
|
|
15570
15687
|
return VALUES_ROUND_MIXED(String(state ?? "unknown"));
|
|
15571
15688
|
}
|
|
15572
15689
|
function renderValues(root, model, options = {}) {
|
|
15573
|
-
const indexBody = readJson2(
|
|
15690
|
+
const indexBody = readJson2(path20.join(root, "valuedomain", "_index.json"));
|
|
15574
15691
|
const byCompleteness = isRec2(indexBody) ? indexBody.byCompleteness : void 0;
|
|
15575
15692
|
if (!isRec2(byCompleteness)) {
|
|
15576
15693
|
return {
|
|
15577
15694
|
ok: false,
|
|
15578
15695
|
kind: "index-unreadable",
|
|
15579
|
-
message: `\u8BFB\u4E0D\u5230 valuedomain/_index.json\uFF08${root}\uFF09\u2014\u2014 \u53EF\u80FD\u662F\uFF1A\u8FD9\u4EFD\u57FA\u7EBF\u7531\u66F4\u65E9\u7248\u672C\u722C\u7684\u3001\u4F60\u6CA1\u62F7 valuedomain/ \u76EE\u5F55\u8FC7\u6765\u3001\u6216\u8005\u90A3\u4E2A\u6587\u4EF6\u574F\u4E86\u3002\u5148 \`ls ${
|
|
15696
|
+
message: `\u8BFB\u4E0D\u5230 valuedomain/_index.json\uFF08${root}\uFF09\u2014\u2014 \u53EF\u80FD\u662F\uFF1A\u8FD9\u4EFD\u57FA\u7EBF\u7531\u66F4\u65E9\u7248\u672C\u722C\u7684\u3001\u4F60\u6CA1\u62F7 valuedomain/ \u76EE\u5F55\u8FC7\u6765\u3001\u6216\u8005\u90A3\u4E2A\u6587\u4EF6\u574F\u4E86\u3002\u5148 \`ls ${path20.join(root, "valuedomain")}\` \u770B\u4E00\u773C\uFF1B\u786E\u5B9E\u6CA1\u6709\u5C31\u91CD\u8DD1\u4E00\u6B21 recon\u3002`
|
|
15580
15697
|
};
|
|
15581
15698
|
}
|
|
15582
15699
|
let completeness;
|
|
@@ -15587,7 +15704,7 @@ function renderValues(root, model, options = {}) {
|
|
|
15587
15704
|
}
|
|
15588
15705
|
}
|
|
15589
15706
|
if (completeness === void 0) {
|
|
15590
|
-
if (isLocalName(model) &&
|
|
15707
|
+
if (isLocalName(model) && existsSync12(path20.join(root, "mapping", `${model}.json`))) {
|
|
15591
15708
|
return {
|
|
15592
15709
|
ok: false,
|
|
15593
15710
|
kind: "not-a-code-table",
|
|
@@ -15597,11 +15714,11 @@ function renderValues(root, model, options = {}) {
|
|
|
15597
15714
|
return {
|
|
15598
15715
|
ok: false,
|
|
15599
15716
|
kind: "model-not-in-baseline",
|
|
15600
|
-
message: `\u57FA\u7EBF\u91CC\u6CA1\u6709\u8FD9\u4E2A\u6A21\u578B\uFF1A${model}\u3002\`ls ${
|
|
15717
|
+
message: `\u57FA\u7EBF\u91CC\u6CA1\u6709\u8FD9\u4E2A\u6A21\u578B\uFF1A${model}\u3002\`ls ${path20.join(root, "mapping")}\` \u770B\u6709\u54EA\u4E9B\u3002`
|
|
15601
15718
|
};
|
|
15602
15719
|
}
|
|
15603
|
-
const file =
|
|
15604
|
-
if (!isLocalName(model) || !
|
|
15720
|
+
const file = path20.join(root, "valuedomain", `${model}.json`);
|
|
15721
|
+
if (!isLocalName(model) || !existsSync12(file)) {
|
|
15605
15722
|
return {
|
|
15606
15723
|
ok: false,
|
|
15607
15724
|
kind: "file-missing",
|
|
@@ -15654,8 +15771,8 @@ function renderValues(root, model, options = {}) {
|
|
|
15654
15771
|
}
|
|
15655
15772
|
|
|
15656
15773
|
// src/fde/gate0/aclass.ts
|
|
15657
|
-
import { existsSync as
|
|
15658
|
-
import * as
|
|
15774
|
+
import { existsSync as existsSync13, readFileSync as readFileSync12, readdirSync as readdirSync3, statSync as statSync10 } from "fs";
|
|
15775
|
+
import * as path21 from "path";
|
|
15659
15776
|
|
|
15660
15777
|
// src/fde/gate0/mapping-artifact.ts
|
|
15661
15778
|
import { readFileSync as readFileSync11 } from "fs";
|
|
@@ -15790,7 +15907,7 @@ function readText(file, kinds, scope, problems) {
|
|
|
15790
15907
|
return readFileSync12(file, "utf8");
|
|
15791
15908
|
} catch (e) {
|
|
15792
15909
|
const code = e?.code;
|
|
15793
|
-
const name =
|
|
15910
|
+
const name = path21.basename(file);
|
|
15794
15911
|
problems.push({
|
|
15795
15912
|
scope,
|
|
15796
15913
|
reason: REASON_UNREAD,
|
|
@@ -15803,7 +15920,7 @@ function readText(file, kinds, scope, problems) {
|
|
|
15803
15920
|
function readJsonl(file, kinds, scope, problems) {
|
|
15804
15921
|
const text2 = readText(file, kinds, scope, problems);
|
|
15805
15922
|
if (text2 === null) return [];
|
|
15806
|
-
const name =
|
|
15923
|
+
const name = path21.basename(file);
|
|
15807
15924
|
const rows = [];
|
|
15808
15925
|
text2.split("\n").forEach((raw, i) => {
|
|
15809
15926
|
const line = raw.trim();
|
|
@@ -15844,13 +15961,13 @@ function readJson3(file, kinds, scope, problems) {
|
|
|
15844
15961
|
scope,
|
|
15845
15962
|
reason: REASON_UNREAD,
|
|
15846
15963
|
kinds,
|
|
15847
|
-
message: `\u4EA7\u7269 ${
|
|
15964
|
+
message: `\u4EA7\u7269 ${path21.basename(file)} \u4E0D\u662F\u5408\u6CD5 JSON\uFF08${String(e)}\uFF09\u21D2 ${unguardedWord(kinds)} \u8FD9\u51E0\u7C7B\u6B64\u523B\u65E0\u4EBA\u5B88`
|
|
15848
15965
|
});
|
|
15849
15966
|
return UNREADABLE;
|
|
15850
15967
|
}
|
|
15851
15968
|
}
|
|
15852
15969
|
function listUnder(payload, key, file, kinds, scope, problems) {
|
|
15853
|
-
const name =
|
|
15970
|
+
const name = path21.basename(file);
|
|
15854
15971
|
if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
|
|
15855
15972
|
problems.push({
|
|
15856
15973
|
scope,
|
|
@@ -15886,7 +16003,7 @@ function deriveAclass(root, mappingArtifact = null) {
|
|
|
15886
16003
|
const problems = [];
|
|
15887
16004
|
const out = Object.fromEntries(ACLASS_KINDS.map((k) => [k, /* @__PURE__ */ new Set()]));
|
|
15888
16005
|
for (const row of readJsonl(
|
|
15889
|
-
|
|
16006
|
+
path21.join(root, ...FIELDS_INDEX),
|
|
15890
16007
|
["fieldKey", "fieldLabel", "caliber"],
|
|
15891
16008
|
CLASS_SCOPE,
|
|
15892
16009
|
problems
|
|
@@ -15902,7 +16019,7 @@ function deriveAclass(root, mappingArtifact = null) {
|
|
|
15902
16019
|
}
|
|
15903
16020
|
}
|
|
15904
16021
|
for (const row of readJsonl(
|
|
15905
|
-
|
|
16022
|
+
path21.join(root, ...ENUM_MIRROR),
|
|
15906
16023
|
["enumValue"],
|
|
15907
16024
|
CLASS_SCOPE,
|
|
15908
16025
|
problems
|
|
@@ -15916,7 +16033,7 @@ function deriveAclass(root, mappingArtifact = null) {
|
|
|
15916
16033
|
}
|
|
15917
16034
|
}
|
|
15918
16035
|
}
|
|
15919
|
-
const rosterPath =
|
|
16036
|
+
const rosterPath = path21.join(root, ...MODEL_ROSTER);
|
|
15920
16037
|
const roster = readJson3(rosterPath, ["modelName"], CLASS_SCOPE, problems);
|
|
15921
16038
|
if (roster !== UNREADABLE) {
|
|
15922
16039
|
const rows = listUnder(roster, "models", rosterPath, ["modelName"], CLASS_SCOPE, problems);
|
|
@@ -15944,11 +16061,11 @@ function deriveAclass(root, mappingArtifact = null) {
|
|
|
15944
16061
|
});
|
|
15945
16062
|
}
|
|
15946
16063
|
}
|
|
15947
|
-
const valueDomain =
|
|
15948
|
-
if (
|
|
16064
|
+
const valueDomain = path21.join(root, VALUE_DOMAIN_DIR);
|
|
16065
|
+
if (existsSync13(valueDomain) && statSync10(valueDomain).isDirectory()) {
|
|
15949
16066
|
const tables = readdirSync3(valueDomain).filter((f) => f.endsWith(".json") && !RESERVED_FILENAMES.includes(f)).sort();
|
|
15950
16067
|
for (const name of tables) {
|
|
15951
|
-
const file =
|
|
16068
|
+
const file = path21.join(valueDomain, name);
|
|
15952
16069
|
const payload = readJson3(file, ["codeValue"], ENTRY_SCOPE, problems);
|
|
15953
16070
|
if (payload === UNREADABLE) continue;
|
|
15954
16071
|
for (const row of listUnder(payload, "rows", file, ["codeValue"], ENTRY_SCOPE, problems)) {
|
|
@@ -16014,8 +16131,8 @@ function deriveAclass(root, mappingArtifact = null) {
|
|
|
16014
16131
|
}
|
|
16015
16132
|
|
|
16016
16133
|
// src/fde/gate0/facts.ts
|
|
16017
|
-
import { existsSync as
|
|
16018
|
-
import * as
|
|
16134
|
+
import { existsSync as existsSync14, readFileSync as readFileSync13 } from "fs";
|
|
16135
|
+
import * as path22 from "path";
|
|
16019
16136
|
var REGISTRY_SCOPE = "registry";
|
|
16020
16137
|
var ENTRY_SCOPE2 = "entry";
|
|
16021
16138
|
var REASON_NO_ENTRIES = "no-entries";
|
|
@@ -16102,9 +16219,9 @@ function loadProtocolFacts(entries = PROTOCOL_FACTS, options = {}) {
|
|
|
16102
16219
|
return;
|
|
16103
16220
|
}
|
|
16104
16221
|
if (probeRoot !== void 0) {
|
|
16105
|
-
const file =
|
|
16222
|
+
const file = path22.join(probeRoot, shape.groups.file);
|
|
16106
16223
|
const mark = `${PROBE_MARK_PREFIX} ${shape.groups.mark}`;
|
|
16107
|
-
const found =
|
|
16224
|
+
const found = existsSync14(file) && readFileSync13(file, "utf8").includes(mark);
|
|
16108
16225
|
if (!found) {
|
|
16109
16226
|
problems.push({
|
|
16110
16227
|
scope: ENTRY_SCOPE2,
|
|
@@ -16122,8 +16239,8 @@ function loadProtocolFacts(entries = PROTOCOL_FACTS, options = {}) {
|
|
|
16122
16239
|
}
|
|
16123
16240
|
|
|
16124
16241
|
// src/fde/gate0/scan.ts
|
|
16125
|
-
import { readFileSync as readFileSync14, readdirSync as readdirSync4, readlinkSync, statSync as
|
|
16126
|
-
import * as
|
|
16242
|
+
import { readFileSync as readFileSync14, readdirSync as readdirSync4, readlinkSync, statSync as statSync11 } from "fs";
|
|
16243
|
+
import * as path23 from "path";
|
|
16127
16244
|
|
|
16128
16245
|
// src/fde/gate0/owned.ts
|
|
16129
16246
|
var OWNED_CODE_SETS = [
|
|
@@ -16705,7 +16822,7 @@ function scan(skillRoot, aclass, facts, options = {}) {
|
|
|
16705
16822
|
}
|
|
16706
16823
|
premise2.push({
|
|
16707
16824
|
reason: REASON_SYMLINK_NOT_SCANNED,
|
|
16708
|
-
message: `${
|
|
16825
|
+
message: `${path23.relative(skillRoot, link)} \u662F\u4E00\u4E2A\u7B26\u53F7\u94FE\u63A5\uFF08\u6307\u5411 ${JSON.stringify(target)}\uFF09\u21D2 \u95E8 0 **\u6CA1\u6709\u987A\u7740\u5B83\u626B\u8FC7\u4E00\u4E2A\u5B57**\uFF0C\u8FD9\u4E00\u8F6E\u7684\u7EFF\u4E0D\u7B97\u6570\u3002\u51FA\u8DEF\uFF1A\u628A\u8FD9\u6761\u94FE\u4ECE skill \u91CC\u53BB\u6389 \u2014\u2014 \u94FE\u540E\u9762\u90A3\u4EFD\u5185\u5BB9\u672C\u8BE5\u88AB\u5224\u5C31 \`cp -RL\` \u62F7\u6210\u771F\u5185\u5BB9\uFF08\u26A0\uFE0F \u73AF\u8DEF\u4E0E\u65AD\u94FE\u4E0A\u5B83\u4F1A\u5F53\u573A\u62A5\u9519\uFF0C\u90A3\u4E24\u79CD\u76F4\u63A5\u5220\uFF09\uFF1B\u5185\u5BB9\u5DF2\u7ECF\u5728 skill \u91CC\uFF08\u6307\u5411\u540C\u6811\u7684\u522B\u540D\uFF09\u4E5F\u76F4\u63A5\u5220\u3002**\u4E0D\u8DDF\u968F**\u662F\u523B\u610F\u7684 \u2014\u2014 \u8DDF\u8FC7\u53BB\u4F1A\u8FDE\u4E0A\u73AF\u8DEF\u3001\u6216\u8D8A\u51FA skill \u76EE\u5F55\u626B\u5230\u65E0\u5173\u6587\u4EF6`
|
|
16709
16826
|
});
|
|
16710
16827
|
}
|
|
16711
16828
|
if (files.length === 0) {
|
|
@@ -16726,7 +16843,7 @@ function scan(skillRoot, aclass, facts, options = {}) {
|
|
|
16726
16843
|
});
|
|
16727
16844
|
continue;
|
|
16728
16845
|
}
|
|
16729
|
-
const rel =
|
|
16846
|
+
const rel = path23.relative(skillRoot, file);
|
|
16730
16847
|
scanned.push(rel);
|
|
16731
16848
|
text2.split("\n").forEach((line, i) => {
|
|
16732
16849
|
judgeLine(line, i + 1, rel, matcher, index, reds, gaps);
|
|
@@ -16753,7 +16870,7 @@ function scan(skillRoot, aclass, facts, options = {}) {
|
|
|
16753
16870
|
}
|
|
16754
16871
|
function isDirectory(target) {
|
|
16755
16872
|
try {
|
|
16756
|
-
return
|
|
16873
|
+
return statSync11(target).isDirectory();
|
|
16757
16874
|
} catch {
|
|
16758
16875
|
return false;
|
|
16759
16876
|
}
|
|
@@ -16763,10 +16880,10 @@ function walk3(root) {
|
|
|
16763
16880
|
const unscannedLinks = [];
|
|
16764
16881
|
const visit = (dir) => {
|
|
16765
16882
|
for (const entry of readdirSync4(dir, { withFileTypes: true })) {
|
|
16766
|
-
const full =
|
|
16883
|
+
const full = path23.join(dir, entry.name);
|
|
16767
16884
|
let followed = null;
|
|
16768
16885
|
try {
|
|
16769
|
-
followed =
|
|
16886
|
+
followed = statSync11(full);
|
|
16770
16887
|
} catch {
|
|
16771
16888
|
followed = null;
|
|
16772
16889
|
}
|
|
@@ -16848,7 +16965,7 @@ function buildCarrierResult(carrier, verdict2, options = {}) {
|
|
|
16848
16965
|
|
|
16849
16966
|
// src/fde/triage/probe.ts
|
|
16850
16967
|
import { readFileSync as readFileSync15 } from "fs";
|
|
16851
|
-
import * as
|
|
16968
|
+
import * as path24 from "path";
|
|
16852
16969
|
var WORKSPACES_PATH = "/api/tenant-extension/workspaces";
|
|
16853
16970
|
var MODELS_REL = "models.json";
|
|
16854
16971
|
var FIELDS_REL = "index/fields.jsonl";
|
|
@@ -16871,10 +16988,10 @@ function unavailableCell(carrier, err) {
|
|
|
16871
16988
|
});
|
|
16872
16989
|
}
|
|
16873
16990
|
function readArtifactJson(dir, rel) {
|
|
16874
|
-
return JSON.parse(readFileSync15(
|
|
16991
|
+
return JSON.parse(readFileSync15(path24.join(dir, rel), "utf8"));
|
|
16875
16992
|
}
|
|
16876
16993
|
function readArtifactJsonl(dir, rel) {
|
|
16877
|
-
const body = readFileSync15(
|
|
16994
|
+
const body = readFileSync15(path24.join(dir, rel), "utf8");
|
|
16878
16995
|
const rows = [];
|
|
16879
16996
|
for (const line of body.split("\n")) {
|
|
16880
16997
|
const trimmed = line.trim();
|
|
@@ -17942,6 +18059,7 @@ export {
|
|
|
17942
18059
|
DEBT_PREFIX,
|
|
17943
18060
|
DEBT_UNKNOWN,
|
|
17944
18061
|
DEFAULT_AGENT_ID,
|
|
18062
|
+
DEFAULT_ARTIFACT_CATEGORY,
|
|
17945
18063
|
DEFAULT_SESSION_TTL_SECONDS,
|
|
17946
18064
|
PREMISE_CODES4 as DELIVERY_PREMISE_CODES,
|
|
17947
18065
|
DEV_MODE_PATH,
|
|
@@ -18228,6 +18346,7 @@ export {
|
|
|
18228
18346
|
inferMiniWritableTemplateOptionsFromModel,
|
|
18229
18347
|
initMiniAppProject,
|
|
18230
18348
|
inspectRound,
|
|
18349
|
+
installDataPackageArtifact,
|
|
18231
18350
|
isCjk,
|
|
18232
18351
|
isDelegationToolName,
|
|
18233
18352
|
isLocalName,
|
|
@@ -18271,6 +18390,7 @@ export {
|
|
|
18271
18390
|
normalizeReferences,
|
|
18272
18391
|
notAsked,
|
|
18273
18392
|
oneShot,
|
|
18393
|
+
packDataPackage,
|
|
18274
18394
|
parseConfirmToolName,
|
|
18275
18395
|
parseFixture,
|
|
18276
18396
|
parseInteractionRequest,
|