@clawos-dev/clawd 0.2.658 → 0.2.660
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 +18 -48
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -62051,7 +62051,6 @@ async function storeGithubAuth(args) {
|
|
|
62051
62051
|
init_zod();
|
|
62052
62052
|
var SLUG = "ottin4ttc/clawos";
|
|
62053
62053
|
var WORKFLOW = ".github/workflows/base-image-acr.yml";
|
|
62054
|
-
var DOCKERFILE = "cloud-host/Dockerfile.base";
|
|
62055
62054
|
var SHA = external_exports.string().regex(/^[a-f0-9]{40}$/);
|
|
62056
62055
|
var SourceSchema = external_exports.object({ cloudHost: SHA, workflow: SHA });
|
|
62057
62056
|
var BaseSchema = external_exports.object({
|
|
@@ -62064,10 +62063,10 @@ var BaseSchema = external_exports.object({
|
|
|
62064
62063
|
workflowCommit: SHA,
|
|
62065
62064
|
buildId: external_exports.string().min(1)
|
|
62066
62065
|
});
|
|
62067
|
-
async function
|
|
62068
|
-
const head = await api.getJsonStrict(`/repos/${SLUG}/commits
|
|
62069
|
-
if (
|
|
62070
|
-
const
|
|
62066
|
+
async function buildSource(api, commit) {
|
|
62067
|
+
const head = await api.getJsonStrict(`/repos/${SLUG}/commits/${commit}`);
|
|
62068
|
+
if (head?.sha !== commit || !SHA.safeParse(head?.commit?.tree?.sha).success) throw new Error("\u8BFB\u4E0D\u5230\u53EF\u4FE1\u7684\u5E95\u5EA7\u6784\u5EFA\u6E90\u7801\u7248\u672C");
|
|
62069
|
+
const tree = SHA.parse(head?.commit?.tree?.sha);
|
|
62071
62070
|
const [root, workflow] = await Promise.all([
|
|
62072
62071
|
api.getJsonStrict(`/repos/${SLUG}/git/trees/${tree}`),
|
|
62073
62072
|
api.getJsonStrict(`/repos/${SLUG}/contents/${WORKFLOW}?ref=${commit}`)
|
|
@@ -62075,33 +62074,13 @@ async function currentSource(api) {
|
|
|
62075
62074
|
if (root?.truncated || workflow?.type !== "file") throw new Error("\u8BFB\u4E0D\u5230\u5B8C\u6574\u5E95\u5EA7\u6E90\u7801\u7248\u672C");
|
|
62076
62075
|
const source = SourceSchema.safeParse({ cloudHost: root?.tree?.find((e) => e.path === "cloud-host" && e.type === "tree")?.sha, workflow: workflow.sha });
|
|
62077
62076
|
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");
|
|
62078
|
-
return
|
|
62079
|
-
}
|
|
62080
|
-
function dockerfileInputs(text) {
|
|
62081
|
-
if (!/^\s*FROM\s+/im.test(text)) throw new Error("\u8BFB\u4E0D\u5230\u53EF\u4FE1\u7684\u5E95\u5EA7\u6784\u5EFA\u914D\u65B9");
|
|
62082
|
-
const logical = text.replace(/\\\r?\n/g, " ");
|
|
62083
|
-
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");
|
|
62084
|
-
const inputs = /* @__PURE__ */ new Set([DOCKERFILE, "cloud-host/.dockerignore", "cloud-host/Dockerfile.base.dockerignore"]);
|
|
62085
|
-
for (const line of logical.split("\n")) {
|
|
62086
|
-
const instruction = /^\s*(?:COPY|ADD)\s+(.+)$/i.exec(line)?.[1];
|
|
62087
|
-
if (!instruction || /^--from=\S+\s/.test(instruction)) continue;
|
|
62088
|
-
const tokens = instruction.startsWith("[") ? JSON.parse(instruction) : instruction.trim().split(/\s+/);
|
|
62089
|
-
if (!Array.isArray(tokens) || tokens.length < 2) throw new Error("\u5E95\u5EA7 COPY \u8F93\u5165\u4E0D\u5B8C\u6574\uFF0C\u8BF7\u91CD\u65B0\u6784\u5EFA");
|
|
62090
|
-
for (const source of tokens.slice(0, -1)) {
|
|
62091
|
-
if (typeof source !== "string" || !/^[A-Za-z0-9_-][A-Za-z0-9_./-]*$/.test(source) || source.split("/").some((segment) => !segment || segment === "." || segment === "..")) {
|
|
62092
|
-
throw new Error("\u5E95\u5EA7 COPY \u8F93\u5165\u65E0\u6CD5\u5B8C\u6574\u6BD4\u8F83\uFF0C\u8BF7\u91CD\u65B0\u6784\u5EFA");
|
|
62093
|
-
}
|
|
62094
|
-
inputs.add("cloud-host/" + source.replace(/\/$/, ""));
|
|
62095
|
-
}
|
|
62096
|
-
}
|
|
62097
|
-
return inputs;
|
|
62077
|
+
return source.data;
|
|
62098
62078
|
}
|
|
62099
62079
|
async function readCurrentBase(api) {
|
|
62100
|
-
const
|
|
62101
|
-
const listed = await api.getJsonStrict(`/repos/${SLUG}/actions/workflows/base-image-acr.yml/runs?branch=release&per_page=1`);
|
|
62080
|
+
const listed = await api.getJsonStrict(`/repos/${SLUG}/actions/workflows/base-image-acr.yml/runs?branch=release&status=success&per_page=1`);
|
|
62102
62081
|
const run = listed?.workflow_runs?.[0];
|
|
62103
|
-
if (!run || !Number.isSafeInteger(run.id) || run.id <= 0 || !Number.isSafeInteger(run.run_attempt) || run.run_attempt <= 0 || run.head_branch !== "release" || run.path !== WORKFLOW || run.head_repository?.full_name !== SLUG || !["push", "workflow_dispatch"].includes(run.event)) throw new Error("\u6CA1\u6709\u53EF\u4FE1\u7684
|
|
62104
|
-
if (run.status !== "completed" || run.conclusion !== "success") throw new Error("\
|
|
62082
|
+
if (!run || !Number.isSafeInteger(run.id) || run.id <= 0 || !Number.isSafeInteger(run.run_attempt) || run.run_attempt <= 0 || run.head_branch !== "release" || run.path !== WORKFLOW || run.head_repository?.full_name !== SLUG || !["push", "workflow_dispatch"].includes(run.event)) throw new Error("\u6CA1\u6709\u53EF\u4FE1\u7684\u6210\u529F\u5E95\u5EA7\u6784\u5EFA\uFF0C\u8BF7\u8FD0\u884C\u5E95\u5EA7\u6D41\u6C34\u7EBF\u540E\u518D\u53D1\u5E03");
|
|
62083
|
+
if (run.status !== "completed" || run.conclusion !== "success") throw new Error("\u5E95\u5EA7\u6784\u5EFA\u5C1A\u672A\u6210\u529F\uFF0C\u8BF7\u67E5\u770B clawos \u5E95\u5EA7 Actions \u540E\u518D\u53D1\u5E03");
|
|
62105
62084
|
SHA.parse(run.head_sha);
|
|
62106
62085
|
let artifact;
|
|
62107
62086
|
for (let page = 1; page <= 30; page++) {
|
|
@@ -62117,23 +62096,9 @@ async function readCurrentBase(api) {
|
|
|
62117
62096
|
const parsed = BaseSchema.safeParse(await readReleaseArchive(await api.downloadArtifact(SLUG, artifact.id)));
|
|
62118
62097
|
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");
|
|
62119
62098
|
const release2 = parsed.data;
|
|
62120
|
-
|
|
62121
|
-
|
|
62122
|
-
|
|
62123
|
-
if (release2.commit === candidate.commit) return false;
|
|
62124
|
-
const comparison = await api.getJsonStrict(`/repos/${SLUG}/compare/${release2.commit}...${candidate.commit}`);
|
|
62125
|
-
if (comparison.status !== "ahead" || !Array.isArray(comparison.files) || comparison.files.length >= 300 || comparison.files.some((file) => typeof file.filename !== "string" || !file.filename)) {
|
|
62126
|
-
throw new Error("\u65E0\u6CD5\u5B8C\u6574\u6BD4\u8F83\u5E95\u5EA7\u8F93\u5165\uFF0C\u8BF7\u91CD\u65B0\u8FD0\u884C\u5E95\u5EA7\u6D41\u6C34\u7EBF");
|
|
62127
|
-
}
|
|
62128
|
-
if (comparison.files.some((file) => file.filename === DOCKERFILE || file.previous_filename === DOCKERFILE)) return false;
|
|
62129
|
-
const recipe = await api.getJsonStrict(`/repos/${SLUG}/contents/${DOCKERFILE}?ref=${candidate.commit}`);
|
|
62130
|
-
if (recipe.type !== "file" || recipe.encoding !== "base64" || typeof recipe.content !== "string") throw new Error("\u8BFB\u4E0D\u5230\u5E95\u5EA7\u6784\u5EFA\u914D\u65B9");
|
|
62131
|
-
const inputs = dockerfileInputs(Buffer.from(recipe.content, "base64").toString("utf8"));
|
|
62132
|
-
return comparison.files.every((file) => ![file.filename, file.previous_filename].some((filename) => filename && [...inputs].some((input) => filename === input || filename.startsWith(input + "/"))));
|
|
62133
|
-
};
|
|
62134
|
-
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");
|
|
62135
|
-
const after = await currentSource(api);
|
|
62136
|
-
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");
|
|
62099
|
+
if (release2.commit !== run.head_sha || release2.workflowCommit !== run.head_sha) throw new Error("\u5E95\u5EA7\u5236\u54C1\u4E0E\u6784\u5EFA\u63D0\u4EA4\u4E0D\u5339\u914D\uFF0C\u8BF7\u91CD\u65B0\u8FD0\u884C\u5E95\u5EA7\u6D41\u6C34\u7EBF");
|
|
62100
|
+
const source = await buildSource(api, run.head_sha);
|
|
62101
|
+
if (release2.source.cloudHost !== source.cloudHost || release2.source.workflow !== source.workflow) throw new Error("\u5E95\u5EA7\u5236\u54C1\u6E90\u7801\u7248\u672C\u4E0E\u6784\u5EFA\u63D0\u4EA4\u4E0D\u5339\u914D\uFF0C\u8BF7\u91CD\u65B0\u8FD0\u884C\u5E95\u5EA7\u6D41\u6C34\u7EBF");
|
|
62137
62102
|
return release2;
|
|
62138
62103
|
}
|
|
62139
62104
|
|
|
@@ -63715,7 +63680,12 @@ function buildDeployHandlers(deps) {
|
|
|
63715
63680
|
if (/[\s\p{Cc}]/u.test(apiKey)) throw invalid("key \u91CC\u4E0D\u80FD\u6709\u7A7A\u767D\u6216\u63A7\u5236\u5B57\u7B26\uFF08\u591A\u534A\u662F\u7C98\u8D34\u65F6\u5E26\u8FDB\u4E86\u6362\u884C\u6216\u7A7A\u683C\uFF09");
|
|
63716
63681
|
writes = [[ENGINE_AUTH_SECRETS.apiKey, apiKey], [ENGINE_AUTH_SECRETS.baseUrl, baseUrl]];
|
|
63717
63682
|
}
|
|
63718
|
-
const { api } = await requireGithub();
|
|
63683
|
+
const { auth: githubAuth, api } = await requireGithub();
|
|
63684
|
+
try {
|
|
63685
|
+
await ensureRepo(deps.exec, api, { dir, org: deps.org, personaId: args.personaId, auth: githubAuth });
|
|
63686
|
+
} catch (err) {
|
|
63687
|
+
throw toClawdError(err);
|
|
63688
|
+
}
|
|
63719
63689
|
const before = await readHistory(dir);
|
|
63720
63690
|
await writeScanFile(dir, { ...before, engineChannels: { ...before.engineChannels, [args.environment]: null } });
|
|
63721
63691
|
try {
|
|
@@ -74685,7 +74655,7 @@ function computeMethodAccess(args) {
|
|
|
74685
74655
|
}
|
|
74686
74656
|
|
|
74687
74657
|
// src/version.ts
|
|
74688
|
-
var version = "0.2.
|
|
74658
|
+
var version = "0.2.660".length > 0 ? "0.2.660" : "dev";
|
|
74689
74659
|
|
|
74690
74660
|
// src/cli-probe/probe.ts
|
|
74691
74661
|
var fs85 = __toESM(require("fs"), 1);
|