@clawos-dev/clawd 0.2.648 → 0.2.649
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/cli.cjs +37 -4
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -61489,6 +61489,7 @@ async function storeGithubAuth(args) {
|
|
|
61489
61489
|
init_zod();
|
|
61490
61490
|
var SLUG = "ottin4ttc/clawos";
|
|
61491
61491
|
var WORKFLOW = ".github/workflows/base-image-acr.yml";
|
|
61492
|
+
var DOCKERFILE = "cloud-host/Dockerfile.base";
|
|
61492
61493
|
var SHA = external_exports.string().regex(/^[a-f0-9]{40}$/);
|
|
61493
61494
|
var SourceSchema = external_exports.object({ cloudHost: SHA, workflow: SHA });
|
|
61494
61495
|
var BaseSchema = external_exports.object({
|
|
@@ -61514,6 +61515,25 @@ async function currentSource(api) {
|
|
|
61514
61515
|
if (!source.success) throw new Error("\u5E95\u5EA7\u6E90\u7801\u7248\u672C\u8BB0\u5F55\u4E0D\u5B8C\u6574\uFF0C\u8BF7\u5237\u65B0\u540E\u518D\u53D1\u5E03");
|
|
61515
61516
|
return { commit, source: source.data };
|
|
61516
61517
|
}
|
|
61518
|
+
function dockerfileInputs(text) {
|
|
61519
|
+
if (!/^\s*FROM\s+/im.test(text)) throw new Error("\u8BFB\u4E0D\u5230\u53EF\u4FE1\u7684\u5E95\u5EA7\u6784\u5EFA\u914D\u65B9");
|
|
61520
|
+
const logical = text.replace(/\\\r?\n/g, " ");
|
|
61521
|
+
if (/^\s*RUN\b.*--mount=/im.test(logical)) throw new Error("\u5E95\u5EA7\u6302\u8F7D\u8F93\u5165\u65E0\u6CD5\u5B8C\u6574\u6BD4\u8F83\uFF0C\u8BF7\u91CD\u65B0\u6784\u5EFA");
|
|
61522
|
+
const inputs = /* @__PURE__ */ new Set([DOCKERFILE, "cloud-host/.dockerignore", "cloud-host/Dockerfile.base.dockerignore"]);
|
|
61523
|
+
for (const line of logical.split("\n")) {
|
|
61524
|
+
const instruction = /^\s*(?:COPY|ADD)\s+(.+)$/i.exec(line)?.[1];
|
|
61525
|
+
if (!instruction || /^--from=\S+\s/.test(instruction)) continue;
|
|
61526
|
+
const tokens = instruction.startsWith("[") ? JSON.parse(instruction) : instruction.trim().split(/\s+/);
|
|
61527
|
+
if (!Array.isArray(tokens) || tokens.length < 2) throw new Error("\u5E95\u5EA7 COPY \u8F93\u5165\u4E0D\u5B8C\u6574\uFF0C\u8BF7\u91CD\u65B0\u6784\u5EFA");
|
|
61528
|
+
for (const source of tokens.slice(0, -1)) {
|
|
61529
|
+
if (typeof source !== "string" || !/^[A-Za-z0-9_-][A-Za-z0-9_./-]*$/.test(source) || source.split("/").some((segment) => !segment || segment === "." || segment === "..")) {
|
|
61530
|
+
throw new Error("\u5E95\u5EA7 COPY \u8F93\u5165\u65E0\u6CD5\u5B8C\u6574\u6BD4\u8F83\uFF0C\u8BF7\u91CD\u65B0\u6784\u5EFA");
|
|
61531
|
+
}
|
|
61532
|
+
inputs.add("cloud-host/" + source.replace(/\/$/, ""));
|
|
61533
|
+
}
|
|
61534
|
+
}
|
|
61535
|
+
return inputs;
|
|
61536
|
+
}
|
|
61517
61537
|
async function readCurrentBase(api) {
|
|
61518
61538
|
const current = await currentSource(api);
|
|
61519
61539
|
const listed = await api.getJsonStrict(`/repos/${SLUG}/actions/workflows/base-image-acr.yml/runs?branch=release&per_page=1`);
|
|
@@ -61535,10 +61555,23 @@ async function readCurrentBase(api) {
|
|
|
61535
61555
|
const parsed = BaseSchema.safeParse(await readReleaseArchive(await api.downloadArtifact(SLUG, artifact.id)));
|
|
61536
61556
|
if (!parsed.success) throw new Error("\u5E95\u5EA7\u5236\u54C1\u7248\u672C\u8BB0\u5F55\u65E0\u6548\uFF0C\u8BF7\u91CD\u65B0\u8FD0\u884C\u5E95\u5EA7\u6784\u5EFA");
|
|
61537
61557
|
const release2 = parsed.data;
|
|
61538
|
-
const matches = (
|
|
61539
|
-
|
|
61558
|
+
const matches = async (candidate) => {
|
|
61559
|
+
if (release2.source.workflow !== candidate.source.workflow) return false;
|
|
61560
|
+
if (release2.source.cloudHost === candidate.source.cloudHost) return true;
|
|
61561
|
+
if (release2.commit === candidate.commit) return false;
|
|
61562
|
+
const comparison = await api.getJsonStrict(`/repos/${SLUG}/compare/${release2.commit}...${candidate.commit}`);
|
|
61563
|
+
if (comparison.status !== "ahead" || !Array.isArray(comparison.files) || comparison.files.length >= 300 || comparison.files.some((file) => typeof file.filename !== "string" || !file.filename)) {
|
|
61564
|
+
throw new Error("\u65E0\u6CD5\u5B8C\u6574\u6BD4\u8F83\u5E95\u5EA7\u8F93\u5165\uFF0C\u8BF7\u91CD\u65B0\u8FD0\u884C\u5E95\u5EA7\u6D41\u6C34\u7EBF");
|
|
61565
|
+
}
|
|
61566
|
+
if (comparison.files.some((file) => file.filename === DOCKERFILE || file.previous_filename === DOCKERFILE)) return false;
|
|
61567
|
+
const recipe = await api.getJsonStrict(`/repos/${SLUG}/contents/${DOCKERFILE}?ref=${candidate.commit}`);
|
|
61568
|
+
if (recipe.type !== "file" || recipe.encoding !== "base64" || typeof recipe.content !== "string") throw new Error("\u8BFB\u4E0D\u5230\u5E95\u5EA7\u6784\u5EFA\u914D\u65B9");
|
|
61569
|
+
const inputs = dockerfileInputs(Buffer.from(recipe.content, "base64").toString("utf8"));
|
|
61570
|
+
return comparison.files.every((file) => ![file.filename, file.previous_filename].some((filename) => filename && [...inputs].some((input) => filename === input || filename.startsWith(input + "/"))));
|
|
61571
|
+
};
|
|
61572
|
+
if (release2.commit !== run.head_sha || release2.workflowCommit !== run.head_sha || !await matches(current)) throw new Error("\u5E95\u5EA7\u5C1A\u672A\u6784\u5EFA\u5F53\u524D release \u6E90\u7801\uFF0C\u8BF7\u7B49\u5F85\u6216\u91CD\u65B0\u8FD0\u884C\u5E95\u5EA7\u6D41\u6C34\u7EBF");
|
|
61540
61573
|
const after = await currentSource(api);
|
|
61541
|
-
if (
|
|
61574
|
+
if ((after.source.cloudHost !== current.source.cloudHost || after.source.workflow !== current.source.workflow) && !await matches(after)) throw new Error("\u5E95\u5EA7\u6E90\u7801\u5728\u53D1\u5E03\u51C6\u5907\u671F\u95F4\u53D8\u5316\uFF0C\u8BF7\u7B49\u65B0\u6784\u5EFA\u6210\u529F\u540E\u518D\u53D1\u5E03");
|
|
61542
61575
|
return release2;
|
|
61543
61576
|
}
|
|
61544
61577
|
|
|
@@ -74335,7 +74368,7 @@ function computeMethodAccess(args) {
|
|
|
74335
74368
|
}
|
|
74336
74369
|
|
|
74337
74370
|
// src/version.ts
|
|
74338
|
-
var version = "0.2.
|
|
74371
|
+
var version = "0.2.649".length > 0 ? "0.2.649" : "dev";
|
|
74339
74372
|
|
|
74340
74373
|
// src/cli-probe/probe.ts
|
|
74341
74374
|
var fs85 = __toESM(require("fs"), 1);
|