@harrylabsj/kiwi-merchant-cloud 0.12.21 → 0.12.22
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/app/cloud-sample/products.json +3 -3
- package/build-manifest.json +15 -15
- package/package.json +1 -1
- package/prepare.mjs +55 -4
- package/runtime-package.json +1 -1
- package/scripts/check-install-toolchain.mjs +40 -0
- package/shipping-sbom.cdx.json +6 -6
- package/shipping-source.json +11 -11
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"schema_version": "0.1.2",
|
|
3
3
|
"merchant_id": "merchant-001",
|
|
4
4
|
"source": "test_fixture",
|
|
5
|
-
"generated_at": "2026-11-
|
|
5
|
+
"generated_at": "2026-11-02T14:40:59.969Z",
|
|
6
6
|
"products": [
|
|
7
7
|
{
|
|
8
8
|
"sku": "smoke-sku-1",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"price": 120,
|
|
13
13
|
"moq": 1,
|
|
14
14
|
"supply_note": "Local smoke fixture only",
|
|
15
|
-
"updated_at": "2026-11-
|
|
16
|
-
"valid_until": "2026-11-
|
|
15
|
+
"updated_at": "2026-11-02T14:40:59.969Z",
|
|
16
|
+
"valid_until": "2026-11-09T14:40:59.969Z",
|
|
17
17
|
"status": "active",
|
|
18
18
|
"stock": 5,
|
|
19
19
|
"test": true
|
package/build-manifest.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": "0.1.2",
|
|
3
3
|
"artifact_kind": "kiwi-merchant-cloud-package",
|
|
4
|
-
"runtime_version": "0.12.
|
|
5
|
-
"source_commit": "
|
|
6
|
-
"source_artifact_sha256": "sha256:
|
|
7
|
-
"source_contract_sha256": "sha256:
|
|
8
|
-
"artifact_sha256": "sha256:
|
|
4
|
+
"runtime_version": "0.12.22",
|
|
5
|
+
"source_commit": "a99ba838ea98cae7e98c139a91f00b122f984b49",
|
|
6
|
+
"source_artifact_sha256": "sha256:18f82daba7542bb839ffa190eb2fdc69043f1ab4e92c2fff1a2203617cdbcb20",
|
|
7
|
+
"source_contract_sha256": "sha256:fa1c055d188a70c0370ba4f731338453c66e28125c6aacd3fc2cdf628298e221",
|
|
8
|
+
"artifact_sha256": "sha256:e08e9999392af8e25870e4640dbf034838b691c79229e5c51931fecfb30338ff",
|
|
9
9
|
"files": [
|
|
10
10
|
{
|
|
11
11
|
"path": "app/a2a/access/gateway-cookie-jar.d.ts",
|
|
@@ -1800,7 +1800,7 @@
|
|
|
1800
1800
|
{
|
|
1801
1801
|
"path": "app/cloud-sample/products.json",
|
|
1802
1802
|
"size": 531,
|
|
1803
|
-
"sha256": "sha256:
|
|
1803
|
+
"sha256": "sha256:09b4a3b632eb5d72c9badc53915f39040a7aa9b9bf7a8b6f0450e6bc3e07e8bc"
|
|
1804
1804
|
},
|
|
1805
1805
|
{
|
|
1806
1806
|
"path": "app/cloud/access/local-share-vault.d.ts",
|
|
@@ -111025,36 +111025,36 @@
|
|
|
111025
111025
|
{
|
|
111026
111026
|
"path": "package.json",
|
|
111027
111027
|
"size": 1964,
|
|
111028
|
-
"sha256": "sha256:
|
|
111028
|
+
"sha256": "sha256:d9c9227adc6dfebabb7ff9dd645618c3299e43135bf0201ecb8aef76ab30247e"
|
|
111029
111029
|
},
|
|
111030
111030
|
{
|
|
111031
111031
|
"path": "prepare.mjs",
|
|
111032
|
-
"size":
|
|
111033
|
-
"sha256": "sha256:
|
|
111032
|
+
"size": 20053,
|
|
111033
|
+
"sha256": "sha256:df5066ba9da73d5b9ad4001ac2b7590ca9a62e8f3cbc4c20a2d2e1e61ae19202"
|
|
111034
111034
|
},
|
|
111035
111035
|
{
|
|
111036
111036
|
"path": "runtime-package.json",
|
|
111037
111037
|
"size": 1185,
|
|
111038
|
-
"sha256": "sha256:
|
|
111038
|
+
"sha256": "sha256:8ab1cba5fab3d3c63e3ae35896ca35e4f4b8dd9c1a667204df5e83c608906127"
|
|
111039
111039
|
},
|
|
111040
111040
|
{
|
|
111041
111041
|
"path": "scripts/check-install-toolchain.mjs",
|
|
111042
|
-
"size":
|
|
111043
|
-
"sha256": "sha256:
|
|
111042
|
+
"size": 5426,
|
|
111043
|
+
"sha256": "sha256:ccb86a2707cb23f385f6428eb8c3f28df9ad0c0fe59b584e2b29ffe4eafd9c69"
|
|
111044
111044
|
},
|
|
111045
111045
|
{
|
|
111046
111046
|
"path": "shipping-sbom.cdx.json",
|
|
111047
111047
|
"size": 279543,
|
|
111048
|
-
"sha256": "sha256:
|
|
111048
|
+
"sha256": "sha256:1a751209f55873fd2028b9ad028e51e222bab8441fa8dfa592dacba94a9c2ded"
|
|
111049
111049
|
},
|
|
111050
111050
|
{
|
|
111051
111051
|
"path": "shipping-source.json",
|
|
111052
111052
|
"size": 5709,
|
|
111053
|
-
"sha256": "sha256:
|
|
111053
|
+
"sha256": "sha256:7421f681e300b8e7a78990038e43e230fb939639ffa83091c1a266136789e0f4"
|
|
111054
111054
|
}
|
|
111055
111055
|
],
|
|
111056
111056
|
"file_count": 22209,
|
|
111057
|
-
"total_bytes":
|
|
111057
|
+
"total_bytes": 150857029,
|
|
111058
111058
|
"notes": [
|
|
111059
111059
|
"Complete normal npm bundle plan, every shipped file byte except build-manifest itself; no SDK pruning. Project tgz budget <100000000, not an npmjs official limit."
|
|
111060
111060
|
]
|
package/package.json
CHANGED
package/prepare.mjs
CHANGED
|
@@ -260,6 +260,9 @@ function makeAdminBootstrap(identity) {
|
|
|
260
260
|
return password;
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
+
// 失败回滚钩子:只在本次运行创建了临时输出时才非空(见 main 内的 outExisted)。
|
|
264
|
+
let rollbackOnFailure = null;
|
|
265
|
+
|
|
263
266
|
function main() {
|
|
264
267
|
const options = parseArgs(process.argv.slice(2));
|
|
265
268
|
const publicOrigin = validateOrigin(options.origin);
|
|
@@ -269,20 +272,61 @@ function main() {
|
|
|
269
272
|
const manifest = verifyManifest();
|
|
270
273
|
const out = path.resolve(options.out);
|
|
271
274
|
if (out === PACKAGE_ROOT || out.startsWith(`${PACKAGE_ROOT}${path.sep}`)) throw new Error("部署目录必须在包目录之外");
|
|
275
|
+
// 先校验 out(已存在且非空即拒绝),再创建任何临时目录:拒绝路径不得泄漏 mkdtemp。
|
|
276
|
+
if (existsSync(out) && readdirSync(out).length > 0) throw new Error("部署目录已存在且非空;请提供新的空目录");
|
|
277
|
+
// 只有"未显式 --data-dir 且平台 /workspace 不存在"时才会 mkdtemp 出临时目录,
|
|
278
|
+
// 失败回滚只回收这种本次新建的目录。
|
|
279
|
+
const autoDataDir = options.dataDir === undefined && !existsSync(PLATFORM_WORKSPACE_DIR);
|
|
272
280
|
const dataDirRaw = options.dataDir ?? defaultDataDir(out);
|
|
273
281
|
if (!path.isAbsolute(dataDirRaw)) throw new Error("--data-dir 必须是部署目录外的绝对路径");
|
|
274
282
|
const dataDir = path.resolve(dataDirRaw);
|
|
275
|
-
if (dataDir === out || dataDir.startsWith(`${out}${path.sep}`))
|
|
276
|
-
|
|
283
|
+
if (dataDir === out || dataDir.startsWith(`${out}${path.sep}`)) {
|
|
284
|
+
// 临时目录此时已创建:立即回收(仅限自动 mkdtemp 的那个;显式 --data-dir 不动)。
|
|
285
|
+
if (autoDataDir) rmSync(dataDir, { recursive: true, force: true });
|
|
286
|
+
throw new Error("--data-dir 必须是部署目录外的绝对路径");
|
|
287
|
+
}
|
|
277
288
|
rmSync(path.join(PACKAGE_ROOT, "admin-bootstrap.json"), { force: true });
|
|
289
|
+
// 安全清理:只回收本次新建的临时输出,不删除用户既有目录或数据。
|
|
290
|
+
// - out 在本次运行前不存在:删除整个 out(它是我们刚创建的);
|
|
291
|
+
// - out 是用户既有的空目录:只删除本次写入的顶层条目,目录本身保留;
|
|
292
|
+
// - 仅自动 mkdtemp 出来的 data dir 会被回收;显式 --data-dir 与平台 /workspace 永不删除。
|
|
293
|
+
const outExisted = existsSync(out);
|
|
294
|
+
const createdNames = [];
|
|
295
|
+
rollbackOnFailure = () => {
|
|
296
|
+
rmSync(path.join(PACKAGE_ROOT, "admin-bootstrap.json"), { force: true });
|
|
297
|
+
if (!outExisted) rmSync(out, { recursive: true, force: true });
|
|
298
|
+
else for (const name of createdNames) rmSync(path.join(out, name), { recursive: true, force: true });
|
|
299
|
+
if (autoDataDir) rmSync(dataDir, { recursive: true, force: true });
|
|
300
|
+
};
|
|
278
301
|
mkdirSync(out, { recursive: true });
|
|
279
|
-
|
|
302
|
+
// scripts/ 必须一起复制:部署产物的 package.json 保留 preinstall
|
|
303
|
+
// (node scripts/check-install-toolchain.mjs,A106 依赖树守卫),漏复制会让
|
|
304
|
+
// 平台安装以 SITES_INSTALL_FAILED 失败(0.12.21 实测根因)。
|
|
305
|
+
for (const name of ["app", "contracts", "node_modules", "index.js", "package.json", "build-manifest.json", "scripts"]) {
|
|
280
306
|
const source = path.join(PACKAGE_ROOT, name);
|
|
281
|
-
if (existsSync(source))
|
|
307
|
+
if (!existsSync(source)) continue;
|
|
308
|
+
createdNames.push(name);
|
|
309
|
+
cpSync(source, path.join(out, name), { recursive: true });
|
|
310
|
+
}
|
|
311
|
+
// 产物自洽:npm 生命周期钩子(preinstall/install/postinstall/prepare)若以
|
|
312
|
+
// `node <相对文件>` 引用脚本,其目标必须已在部署目录内,否则在这里 fail-closed,
|
|
313
|
+
// 而不是把 MODULE_NOT_FOUND 留给平台安装阶段(0.12.21 的 SITES_INSTALL_FAILED)。
|
|
314
|
+
// 自定义脚本(如 prepare-cloud)只在开发时使用,不要求随部署产物分发。
|
|
315
|
+
const LIFECYCLE_HOOKS = new Set(["preinstall", "install", "postinstall", "prepare"]);
|
|
316
|
+
const deployedPkg = JSON.parse(readFileSync(path.join(out, "package.json"), "utf8"));
|
|
317
|
+
for (const [hook, command] of Object.entries(deployedPkg.scripts ?? {})) {
|
|
318
|
+
if (!LIFECYCLE_HOOKS.has(hook)) continue;
|
|
319
|
+
const target = /^node\s+(\S+)/.exec(String(command))?.[1];
|
|
320
|
+
if (target !== undefined && !target.startsWith("/") && !existsSync(path.join(out, target))) {
|
|
321
|
+
throw new Error(
|
|
322
|
+
`部署产物缺少 ${hook} 引用的文件 ${target};prepare 的复制清单必须与 package.json 的生命周期脚本保持一致`,
|
|
323
|
+
);
|
|
324
|
+
}
|
|
282
325
|
}
|
|
283
326
|
const identity = { owner_id: `merchant-${randomBytes(16).toString("hex")}` };
|
|
284
327
|
identity.agent_id = `merchant-agent:${identity.owner_id}`;
|
|
285
328
|
const pilotDir = path.join(out, "pilot");
|
|
329
|
+
createdNames.push("pilot");
|
|
286
330
|
mkdirSync(pilotDir, { recursive: true });
|
|
287
331
|
if (options.sample) {
|
|
288
332
|
const sampleSource = path.join(PACKAGE_ROOT, "app", "cloud-sample", "products.json");
|
|
@@ -308,18 +352,25 @@ function main() {
|
|
|
308
352
|
? { owned_runtime: "require", owned_policy: validateOwnedPolicyFile(options.ownedPolicyPath) }
|
|
309
353
|
: {}),
|
|
310
354
|
};
|
|
355
|
+
createdNames.push("cloud.config.json");
|
|
311
356
|
writeFileSync(path.join(out, "cloud.config.json"), `${JSON.stringify(config, null, 2)}\n`, { mode: 0o644 });
|
|
312
357
|
let password;
|
|
313
358
|
if (options.adminBootstrap) {
|
|
314
359
|
password = makeAdminBootstrap(identity);
|
|
360
|
+
createdNames.push("admin-bootstrap.json");
|
|
315
361
|
cpSync(path.join(PACKAGE_ROOT, "admin-bootstrap.json"), path.join(out, "admin-bootstrap.json"));
|
|
316
362
|
rmSync(path.join(PACKAGE_ROOT, "admin-bootstrap.json"), { force: true });
|
|
317
363
|
}
|
|
318
364
|
process.stdout.write(`${JSON.stringify({ deployment_dir: out, artifact_sha256: manifest.artifact_sha256, version: manifest.runtime_version, agent_id: identity.agent_id, catalog_url: catalogUrl, sample: options.sample, allow_insecure_catalog: options.allowInsecureCatalog })}\n`);
|
|
319
365
|
if (password !== undefined) process.stdout.write(`一次性管理员口令(请立即保存):${password}\n`);
|
|
366
|
+
rollbackOnFailure = null;
|
|
320
367
|
}
|
|
321
368
|
|
|
322
369
|
try { main(); } catch (error) {
|
|
370
|
+
if (rollbackOnFailure !== null) {
|
|
371
|
+
try { rollbackOnFailure(); } catch { /* best-effort:清理失败不掩盖原始错误 */ }
|
|
372
|
+
rollbackOnFailure = null;
|
|
373
|
+
}
|
|
323
374
|
process.stderr.write(`[prepare] ${error instanceof Error ? error.message : String(error)}\n`);
|
|
324
375
|
process.exitCode = 1;
|
|
325
376
|
}
|
package/runtime-package.json
CHANGED
|
@@ -78,6 +78,46 @@ function recordIfVulnerable(pkgDir, name, out) {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
const root = process.env.npm_config_local_prefix || process.cwd();
|
|
81
|
+
|
|
82
|
+
// Node 下界守卫:随包依赖(undici 8.10.2、@earendil-works/pi-* 1.2.0)声明
|
|
83
|
+
// engines.node >=22.19.0。低版本 npm 默认只报 EBADENGINE 警告后继续安装,故障
|
|
84
|
+
// 会推迟到运行时(undici 8 需要 22.19+ 的运行时行为)。这里按**被安装包自己的**
|
|
85
|
+
// engines 显式 fail-closed,并给出固定错误码,便于平台/排障直接定位。
|
|
86
|
+
let enginesNode = "";
|
|
87
|
+
try {
|
|
88
|
+
enginesNode = String(
|
|
89
|
+
JSON.parse(readFileSync(path.join(root, "package.json"), "utf8")).engines?.node ?? "",
|
|
90
|
+
).trim();
|
|
91
|
+
} catch {
|
|
92
|
+
/* 没有可读的 package.json 时不额外约束(保持原有行为)。 */
|
|
93
|
+
}
|
|
94
|
+
if (enginesNode !== "") {
|
|
95
|
+
// 只支持单一下界 ">=X.Y" / ">=X.Y.Z"(后者语义更严,必须逐位比较 patch)。
|
|
96
|
+
// 复合范围(">=22.19.0 <23"、向上/波浪号、|| 等)不做近似解释,直接 fail-closed:
|
|
97
|
+
// 静默跳过或只比 major/minor 都会错误放行更低 patch。
|
|
98
|
+
const nodeFloor = /^>=\s*(\d+)\.(\d+)(?:\.(\d+))?$/.exec(enginesNode);
|
|
99
|
+
if (nodeFloor === null) {
|
|
100
|
+
console.error(
|
|
101
|
+
`[a106] NODE_ENGINE_UNSUPPORTED: engines.node=${JSON.stringify(enginesNode)}; ` +
|
|
102
|
+
'only a single lower bound ">=X.Y[.Z]" is supported. Rewrite the package engines ' +
|
|
103
|
+
"to that form instead of skipping the Node check.",
|
|
104
|
+
);
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
const need = [Number(nodeFloor[1]), Number(nodeFloor[2]), Number(nodeFloor[3] ?? "0")];
|
|
108
|
+
const current = process.versions.node.split(".").map(Number);
|
|
109
|
+
const atLeast = (a, b) =>
|
|
110
|
+
a[0] !== b[0] ? a[0] > b[0] : a[1] !== b[1] ? a[1] > b[1] : a[2] >= b[2];
|
|
111
|
+
if (!atLeast(current, need)) {
|
|
112
|
+
console.error(
|
|
113
|
+
`[a106] NODE_VERSION_UNSUPPORTED: package requires node ${enginesNode}, ` +
|
|
114
|
+
`current ${process.versions.node}; deploy on Node >=${need[0]}.${need[1]}.${need[2]} ` +
|
|
115
|
+
"(e.g. 22.19.0) instead of an older sandbox runtime.",
|
|
116
|
+
);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
81
121
|
const offenders = [];
|
|
82
122
|
for (const vuln of VULNERABLE) {
|
|
83
123
|
collectCopies(root, vuln.name, offenders);
|
package/shipping-sbom.cdx.json
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
|
|
3
3
|
"bomFormat": "CycloneDX",
|
|
4
4
|
"specVersion": "1.5",
|
|
5
|
-
"serialNumber": "urn:uuid:
|
|
5
|
+
"serialNumber": "urn:uuid:bd6284eb-59d4-4de3-9807-27ae118f9af2",
|
|
6
6
|
"version": 1,
|
|
7
7
|
"metadata": {
|
|
8
|
-
"timestamp": "2026-11-
|
|
8
|
+
"timestamp": "2026-11-02T14:40:49.550Z",
|
|
9
9
|
"lifecycles": [
|
|
10
10
|
{
|
|
11
11
|
"phase": "build"
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
}
|
|
20
20
|
],
|
|
21
21
|
"component": {
|
|
22
|
-
"bom-ref": "@harrylabsj/kiwi-npm-shipping-stage@0.12.
|
|
22
|
+
"bom-ref": "@harrylabsj/kiwi-npm-shipping-stage@0.12.22",
|
|
23
23
|
"type": "library",
|
|
24
24
|
"name": "@harrylabsj/kiwi-npm-shipping-stage",
|
|
25
|
-
"version": "0.12.
|
|
25
|
+
"version": "0.12.22",
|
|
26
26
|
"scope": "required",
|
|
27
|
-
"purl": "pkg:npm/%40harrylabsj/kiwi-npm-shipping-stage@0.12.
|
|
27
|
+
"purl": "pkg:npm/%40harrylabsj/kiwi-npm-shipping-stage@0.12.22",
|
|
28
28
|
"properties": [
|
|
29
29
|
{
|
|
30
30
|
"name": "cdx:npm:package:private",
|
|
@@ -8378,7 +8378,7 @@
|
|
|
8378
8378
|
],
|
|
8379
8379
|
"dependencies": [
|
|
8380
8380
|
{
|
|
8381
|
-
"ref": "@harrylabsj/kiwi-npm-shipping-stage@0.12.
|
|
8381
|
+
"ref": "@harrylabsj/kiwi-npm-shipping-stage@0.12.22",
|
|
8382
8382
|
"dependsOn": [
|
|
8383
8383
|
"@earendil-works/pi-agent-core@1.2.0",
|
|
8384
8384
|
"@earendil-works/pi-ai@1.2.0",
|
package/shipping-source.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"source_commit": "
|
|
2
|
+
"source_commit": "a99ba838ea98cae7e98c139a91f00b122f984b49",
|
|
3
3
|
"source_base": "e703bc0d67e24a98c417274e46f37d210eff86ac",
|
|
4
|
-
"contract_sha256": "sha256:
|
|
4
|
+
"contract_sha256": "sha256:fa1c055d188a70c0370ba4f731338453c66e28125c6aacd3fc2cdf628298e221",
|
|
5
5
|
"tool": {
|
|
6
6
|
"node": "v22.22.3",
|
|
7
7
|
"npm": "12.2.0",
|
|
@@ -97,21 +97,21 @@
|
|
|
97
97
|
"arch": "x64"
|
|
98
98
|
},
|
|
99
99
|
"stage": {
|
|
100
|
-
"package_sha256": "sha256:
|
|
101
|
-
"lock_sha256": "sha256:
|
|
100
|
+
"package_sha256": "sha256:8ab1cba5fab3d3c63e3ae35896ca35e4f4b8dd9c1a667204df5e83c608906127",
|
|
101
|
+
"lock_sha256": "sha256:98199cff09a50f47622f236a935cef19d75b4ca385c5e5049bfdc83aba1e84bb"
|
|
102
102
|
},
|
|
103
|
-
"runtime_version": "0.12.
|
|
103
|
+
"runtime_version": "0.12.22",
|
|
104
104
|
"root_pack": {
|
|
105
|
-
"compressed_bytes":
|
|
106
|
-
"plain_tar_bytes":
|
|
105
|
+
"compressed_bytes": 2628699,
|
|
106
|
+
"plain_tar_bytes": 12458496,
|
|
107
107
|
"file_count": 1596,
|
|
108
|
-
"sha256": "sha256:
|
|
109
|
-
"integrity": "sha512-
|
|
108
|
+
"sha256": "sha256:290d625daa3c09e7e14f868196690c3515987c92e09a5a36264906b4a5f6aacc",
|
|
109
|
+
"integrity": "sha512-Om+lHyUqR8ZZvvY8Zpn63dWhzzI1+p7wKJpMOxOl0gwKa20nIXKTj+sK5rFR5Ztr2qjYN0swzqhJoJPi2z6iWA=="
|
|
110
110
|
},
|
|
111
|
-
"root_build_receipt_sha256": "sha256:
|
|
111
|
+
"root_build_receipt_sha256": "sha256:8203b40ab5dca4d7a2679a5430ea9a4ceb034920bef4ba7567d22cca080c86a1",
|
|
112
112
|
"complete_root_production_dependencies": true,
|
|
113
113
|
"dependency_policy": "normal npm12 whole original installed packages; no buyer/vendor/SDK pruning",
|
|
114
|
-
"source_lock_sha256": "sha256:
|
|
114
|
+
"source_lock_sha256": "sha256:6f90591ef231d24c2726d9e81b2d78aae4fabdd21bf747116b4ba1fb9cf8d206",
|
|
115
115
|
"installed_target": {
|
|
116
116
|
"platform": "linux",
|
|
117
117
|
"arch": "x64"
|