@clawos-dev/clawd 0.2.631 → 0.2.632
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/app-builder-plugin/mcp-server.cjs +9782 -59
- package/dist/cli.cjs +177 -156
- package/dist/persona-defaults/persona-app-builder/mcp/clawd-app-builder/mcp-server.cjs +9782 -59
- package/dist/persona-defaults/persona-dataclaw-builder/mcp/clawd-app-builder/mcp-server.cjs +9782 -59
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -42487,7 +42487,7 @@ var require_websocket = __commonJS({
|
|
|
42487
42487
|
var http2 = require("http");
|
|
42488
42488
|
var net2 = require("net");
|
|
42489
42489
|
var tls = require("tls");
|
|
42490
|
-
var { randomBytes: randomBytes2, createHash:
|
|
42490
|
+
var { randomBytes: randomBytes2, createHash: createHash5 } = require("crypto");
|
|
42491
42491
|
var { Duplex, Readable: Readable4 } = require("stream");
|
|
42492
42492
|
var { URL: URL2 } = require("url");
|
|
42493
42493
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -43147,7 +43147,7 @@ var require_websocket = __commonJS({
|
|
|
43147
43147
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
43148
43148
|
return;
|
|
43149
43149
|
}
|
|
43150
|
-
const digest =
|
|
43150
|
+
const digest = createHash5("sha1").update(key + GUID).digest("base64");
|
|
43151
43151
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
43152
43152
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
43153
43153
|
return;
|
|
@@ -43514,7 +43514,7 @@ var require_websocket_server = __commonJS({
|
|
|
43514
43514
|
var EventEmitter2 = require("events");
|
|
43515
43515
|
var http2 = require("http");
|
|
43516
43516
|
var { Duplex } = require("stream");
|
|
43517
|
-
var { createHash:
|
|
43517
|
+
var { createHash: createHash5 } = require("crypto");
|
|
43518
43518
|
var extension2 = require_extension();
|
|
43519
43519
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
43520
43520
|
var subprotocol2 = require_subprotocol();
|
|
@@ -43815,7 +43815,7 @@ var require_websocket_server = __commonJS({
|
|
|
43815
43815
|
);
|
|
43816
43816
|
}
|
|
43817
43817
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
43818
|
-
const digest =
|
|
43818
|
+
const digest = createHash5("sha1").update(key + GUID).digest("base64");
|
|
43819
43819
|
const headers = [
|
|
43820
43820
|
"HTTP/1.1 101 Switching Protocols",
|
|
43821
43821
|
"Upgrade: websocket",
|
|
@@ -45483,7 +45483,7 @@ function requireEnvironmentIdentity(stores, environment) {
|
|
|
45483
45483
|
var import_node_path85 = __toESM(require("path"), 1);
|
|
45484
45484
|
var import_node_fs66 = __toESM(require("fs"), 1);
|
|
45485
45485
|
var import_node_os31 = __toESM(require("os"), 1);
|
|
45486
|
-
var
|
|
45486
|
+
var import_node_crypto29 = require("crypto");
|
|
45487
45487
|
var import_node_url6 = require("url");
|
|
45488
45488
|
|
|
45489
45489
|
// src/logger.ts
|
|
@@ -56538,11 +56538,72 @@ function buildShiftInternalHandlers(deps) {
|
|
|
56538
56538
|
}
|
|
56539
56539
|
|
|
56540
56540
|
// src/handlers/deploy.ts
|
|
56541
|
-
var
|
|
56541
|
+
var import_node_crypto13 = require("crypto");
|
|
56542
56542
|
|
|
56543
56543
|
// src/deploy/verified-release.ts
|
|
56544
|
-
var
|
|
56544
|
+
var import_node_crypto11 = require("crypto");
|
|
56545
|
+
|
|
56546
|
+
// src/deploy/release-archive.ts
|
|
56545
56547
|
var import_jszip = __toESM(require_lib3(), 1);
|
|
56548
|
+
function inspectArchive(bytes) {
|
|
56549
|
+
const data = Buffer.from(bytes);
|
|
56550
|
+
let end = -1;
|
|
56551
|
+
for (let at4 = data.length - 22; at4 >= Math.max(0, data.length - 65557); at4--) {
|
|
56552
|
+
if (data.readUInt32LE(at4) === 101010256 && at4 + 22 + data.readUInt16LE(at4 + 20) === data.length) {
|
|
56553
|
+
end = at4;
|
|
56554
|
+
break;
|
|
56555
|
+
}
|
|
56556
|
+
}
|
|
56557
|
+
if (end < 0 || data.readUInt16LE(end + 4) || data.readUInt16LE(end + 6)) throw new Error("\u5236\u54C1\u5F52\u6863\u683C\u5F0F\u4E0D\u652F\u6301");
|
|
56558
|
+
const count = data.readUInt16LE(end + 10);
|
|
56559
|
+
const length = data.readUInt32LE(end + 12);
|
|
56560
|
+
let at3 = data.readUInt32LE(end + 16), roots = 0;
|
|
56561
|
+
if (count === 65535 || at3 + length !== end) throw new Error("\u5236\u54C1\u5F52\u6863\u683C\u5F0F\u4E0D\u652F\u6301");
|
|
56562
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
56563
|
+
if (at3 + 46 > end || data.readUInt32LE(at3) !== 33639248) throw new Error("\u5236\u54C1\u5F52\u6863\u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
56564
|
+
const nameLength = data.readUInt16LE(at3 + 28);
|
|
56565
|
+
const next = at3 + 46 + nameLength + data.readUInt16LE(at3 + 30) + data.readUInt16LE(at3 + 32);
|
|
56566
|
+
if (next > end) throw new Error("\u5236\u54C1\u5F52\u6863\u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
56567
|
+
const name = data.subarray(at3 + 46, at3 + 46 + nameLength).toString("utf8");
|
|
56568
|
+
if (name === "candidate-release.json") {
|
|
56569
|
+
roots++;
|
|
56570
|
+
if (data.readUInt32LE(at3 + 24) > 64 * 1024) throw new Error("\u5236\u54C1 JSON \u8D85\u8FC7\u5927\u5C0F\u9650\u5236");
|
|
56571
|
+
if (data.readUInt16LE(at3 + 8) & 1) throw new Error("\u5236\u54C1\u5F52\u6863\u4E0D\u80FD\u52A0\u5BC6");
|
|
56572
|
+
}
|
|
56573
|
+
at3 = next;
|
|
56574
|
+
}
|
|
56575
|
+
if (at3 !== end) throw new Error("\u5236\u54C1\u5F52\u6863\u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
56576
|
+
if (roots > 1) throw new Error("\u5236\u54C1\u5F52\u6863\u6709\u91CD\u590D\u7684\u6839 JSON");
|
|
56577
|
+
if (roots !== 1) throw new Error("\u5236\u54C1\u7F3A\u5C11\u6839\u76EE\u5F55\u7684 candidate-release.json");
|
|
56578
|
+
}
|
|
56579
|
+
async function readReleaseArchive(bytes) {
|
|
56580
|
+
if (bytes.length > 1024 * 1024) throw new Error("\u5236\u54C1\u5F52\u6863\u8D85\u8FC7\u5927\u5C0F\u9650\u5236");
|
|
56581
|
+
inspectArchive(bytes);
|
|
56582
|
+
const zip = await import_jszip.default.loadAsync(bytes);
|
|
56583
|
+
const entry = zip.file("candidate-release.json");
|
|
56584
|
+
if (!entry || entry.dir || entry.unsafeOriginalName && entry.unsafeOriginalName !== "candidate-release.json") throw new Error("\u5236\u54C1\u7F3A\u5C11\u6839\u76EE\u5F55\u7684 candidate-release.json");
|
|
56585
|
+
const chunks = [];
|
|
56586
|
+
let size = 0;
|
|
56587
|
+
await new Promise((resolve9, reject) => {
|
|
56588
|
+
const stream = entry.nodeStream("nodebuffer");
|
|
56589
|
+
stream.on("data", (data) => {
|
|
56590
|
+
size += data.length;
|
|
56591
|
+
if (size > 64 * 1024) {
|
|
56592
|
+
stream.pause();
|
|
56593
|
+
reject(new Error("\u5236\u54C1 JSON \u8D85\u8FC7\u5927\u5C0F\u9650\u5236"));
|
|
56594
|
+
return;
|
|
56595
|
+
}
|
|
56596
|
+
chunks.push(Buffer.from(data));
|
|
56597
|
+
}).on("error", reject).on("end", resolve9).resume();
|
|
56598
|
+
});
|
|
56599
|
+
let raw;
|
|
56600
|
+
try {
|
|
56601
|
+
raw = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
56602
|
+
} catch {
|
|
56603
|
+
throw new Error("\u5236\u54C1 JSON \u4E0D\u662F\u5408\u6CD5\u683C\u5F0F");
|
|
56604
|
+
}
|
|
56605
|
+
return raw;
|
|
56606
|
+
}
|
|
56546
56607
|
|
|
56547
56608
|
// src/cloud/gateway-client.ts
|
|
56548
56609
|
init_protocol();
|
|
@@ -60940,6 +61001,63 @@ async function storeGithubAuth(args) {
|
|
|
60940
61001
|
return { token: args.token, source: "file" };
|
|
60941
61002
|
}
|
|
60942
61003
|
|
|
61004
|
+
// src/deploy/base-release.ts
|
|
61005
|
+
init_zod();
|
|
61006
|
+
var SLUG = "ottin4ttc/clawos";
|
|
61007
|
+
var WORKFLOW = ".github/workflows/base-image-acr.yml";
|
|
61008
|
+
var SHA = external_exports.string().regex(/^[a-f0-9]{40}$/);
|
|
61009
|
+
var SourceSchema = external_exports.object({ cloudHost: SHA, workflow: SHA });
|
|
61010
|
+
var BaseSchema = external_exports.object({
|
|
61011
|
+
version: external_exports.literal(1),
|
|
61012
|
+
component: external_exports.literal("base"),
|
|
61013
|
+
environment: external_exports.literal("integration"),
|
|
61014
|
+
commit: SHA,
|
|
61015
|
+
image: external_exports.string().regex(/^registry(?:-vpc)?\.cn-hangzhou\.aliyuncs\.com\/ttc-prod\/clawd-persona-base@sha256:[a-f0-9]{64}$/),
|
|
61016
|
+
source: SourceSchema,
|
|
61017
|
+
workflowCommit: SHA,
|
|
61018
|
+
buildId: external_exports.string().min(1)
|
|
61019
|
+
});
|
|
61020
|
+
async function currentSource(api) {
|
|
61021
|
+
const head = await api.getJsonStrict(`/repos/${SLUG}/commits/release`);
|
|
61022
|
+
if (!SHA.safeParse(head?.sha).success || !SHA.safeParse(head?.commit?.tree?.sha).success) throw new Error("\u8BFB\u4E0D\u5230\u53EF\u4FE1\u7684 release \u5E95\u5EA7\u6E90\u7801\u7248\u672C");
|
|
61023
|
+
const commit = SHA.parse(head?.sha), tree = SHA.parse(head?.commit?.tree?.sha);
|
|
61024
|
+
const [root, workflow] = await Promise.all([
|
|
61025
|
+
api.getJsonStrict(`/repos/${SLUG}/git/trees/${tree}`),
|
|
61026
|
+
api.getJsonStrict(`/repos/${SLUG}/contents/${WORKFLOW}?ref=${commit}`)
|
|
61027
|
+
]);
|
|
61028
|
+
if (root?.truncated || workflow?.type !== "file") throw new Error("\u8BFB\u4E0D\u5230\u5B8C\u6574\u5E95\u5EA7\u6E90\u7801\u7248\u672C");
|
|
61029
|
+
const source = SourceSchema.safeParse({ cloudHost: root?.tree?.find((e) => e.path === "cloud-host" && e.type === "tree")?.sha, workflow: workflow.sha });
|
|
61030
|
+
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");
|
|
61031
|
+
return { commit, source: source.data };
|
|
61032
|
+
}
|
|
61033
|
+
async function readCurrentBase(api) {
|
|
61034
|
+
const current = await currentSource(api);
|
|
61035
|
+
const listed = await api.getJsonStrict(`/repos/${SLUG}/actions/workflows/base-image-acr.yml/runs?branch=release&per_page=1`);
|
|
61036
|
+
const run = listed?.workflow_runs?.[0];
|
|
61037
|
+
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 release \u5E95\u5EA7\u6784\u5EFA\uFF0C\u8BF7\u8FD0\u884C\u5E95\u5EA7\u6D41\u6C34\u7EBF\u540E\u518D\u53D1\u5E03");
|
|
61038
|
+
if (run.status !== "completed" || run.conclusion !== "success") throw new Error("\u6700\u65B0\u5E95\u5EA7\u6784\u5EFA\u5C1A\u672A\u6210\u529F\uFF0C\u8BF7\u67E5\u770B clawos \u5E95\u5EA7 Actions \u540E\u518D\u53D1\u5E03");
|
|
61039
|
+
SHA.parse(run.head_sha);
|
|
61040
|
+
let artifact;
|
|
61041
|
+
for (let page = 1; page <= 30; page++) {
|
|
61042
|
+
const list = await api.getJsonStrict(`/repos/${SLUG}/actions/runs/${run.id}/artifacts?per_page=100&page=${page}`);
|
|
61043
|
+
if (!Array.isArray(list?.artifacts)) throw new Error("\u8BFB\u4E0D\u5230\u5E95\u5EA7\u6784\u5EFA\u5236\u54C1");
|
|
61044
|
+
const hits = list.artifacts.filter((a2) => a2.name === `base-candidate-${run.id}-${run.run_attempt}`);
|
|
61045
|
+
if (hits.length > 1 || artifact && hits.length) throw new Error("\u5E95\u5EA7\u6784\u5EFA\u6709\u591A\u4EFD\u5339\u914D\u5236\u54C1\uFF0C\u8BF7\u91CD\u65B0\u6784\u5EFA");
|
|
61046
|
+
artifact ??= hits[0];
|
|
61047
|
+
if (list.artifacts.length < 100 && (list.total_count === void 0 || page * 100 >= list.total_count)) break;
|
|
61048
|
+
if (page === 30) throw new Error("\u5E95\u5EA7\u5236\u54C1\u540D\u5355\u672A\u5B8C\u6574\u8BFB\u5230");
|
|
61049
|
+
}
|
|
61050
|
+
if (!artifact || artifact.expired || !Number.isSafeInteger(artifact.id) || artifact.id <= 0 || !artifact.workflow_run || artifact.workflow_run.id !== run.id || artifact.workflow_run.head_sha !== run.head_sha) throw new Error("\u5E95\u5EA7\u5236\u54C1\u4E0D\u5B58\u5728\u3001\u5DF2\u8FC7\u671F\u6216\u7248\u672C\u4E0D\u5339\u914D\uFF0C\u8BF7\u91CD\u65B0\u6784\u5EFA");
|
|
61051
|
+
const parsed = BaseSchema.safeParse(await readReleaseArchive(await api.downloadArtifact(SLUG, artifact.id)));
|
|
61052
|
+
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");
|
|
61053
|
+
const release2 = parsed.data;
|
|
61054
|
+
const matches = (source) => release2.source.cloudHost === source.cloudHost && release2.source.workflow === source.workflow;
|
|
61055
|
+
if (release2.workflowCommit !== run.head_sha || !matches(current.source)) 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");
|
|
61056
|
+
const after = await currentSource(api);
|
|
61057
|
+
if (!matches(after.source)) 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");
|
|
61058
|
+
return release2;
|
|
61059
|
+
}
|
|
61060
|
+
|
|
60943
61061
|
// src/deploy/release-workflow.ts
|
|
60944
61062
|
init_protocol();
|
|
60945
61063
|
function renderDeployWorkflow(config) {
|
|
@@ -61164,30 +61282,6 @@ function renderDeployWorkflow(config) {
|
|
|
61164
61282
|
].join("\n");
|
|
61165
61283
|
}
|
|
61166
61284
|
|
|
61167
|
-
// src/deploy/templates.ts
|
|
61168
|
-
var import_node_crypto11 = require("crypto");
|
|
61169
|
-
|
|
61170
|
-
// src/deploy/default-base-release.json
|
|
61171
|
-
var default_base_release_default = {
|
|
61172
|
-
version: 1,
|
|
61173
|
-
environment: "integration",
|
|
61174
|
-
component: "base",
|
|
61175
|
-
image: "registry-vpc.cn-hangzhou.aliyuncs.com/ttc-prod/clawd-persona-base@sha256:9a0952c6bc94a6595374da7db125b5089b476d0bd88f280bd981757d9f572c22",
|
|
61176
|
-
commit: "8dfab2c57781e9f9600e3f99a79adcfbef455f2e",
|
|
61177
|
-
verification: {
|
|
61178
|
-
status: "passed",
|
|
61179
|
-
fingerprint: "d7b03abb9d2bf3a4d7f6f88ac43a2d33d6ec7a7c94ae816f7dae11d67d338194",
|
|
61180
|
-
checks: [
|
|
61181
|
-
"base-smoke",
|
|
61182
|
-
"codex-smoke",
|
|
61183
|
-
"pi-smoke",
|
|
61184
|
-
"workspace-persistence"
|
|
61185
|
-
],
|
|
61186
|
-
endpoint: "https://persona-int.clawos.chat",
|
|
61187
|
-
verifiedAt: "2026-10-08T09:34:53.131Z"
|
|
61188
|
-
}
|
|
61189
|
-
};
|
|
61190
|
-
|
|
61191
61285
|
// src/deploy/templates.ts
|
|
61192
61286
|
init_protocol();
|
|
61193
61287
|
var CLAWOS_REPO = "ottin4ttc/clawos";
|
|
@@ -61201,17 +61295,6 @@ var DOCKERIGNORE_PATH = ".dockerignore";
|
|
|
61201
61295
|
var ACR_REGISTRY = "registry.cn-hangzhou.aliyuncs.com";
|
|
61202
61296
|
var ACR_VPC_REGISTRY = "registry-vpc.cn-hangzhou.aliyuncs.com";
|
|
61203
61297
|
var ACR_NAMESPACE = "ttc-prod";
|
|
61204
|
-
var acceptedBase = VerifiedBaseReleaseSchema.parse(default_base_release_default);
|
|
61205
|
-
var baseFingerprint = (0, import_node_crypto11.createHash)("sha256").update(JSON.stringify({
|
|
61206
|
-
component: acceptedBase.component,
|
|
61207
|
-
image: acceptedBase.image,
|
|
61208
|
-
commit: acceptedBase.commit,
|
|
61209
|
-
baseImage: null,
|
|
61210
|
-
pipelineCommit: null,
|
|
61211
|
-
repository: null
|
|
61212
|
-
})).digest("hex");
|
|
61213
|
-
if (baseFingerprint !== acceptedBase.verification.fingerprint) throw new Error("\u5E73\u53F0\u9ED8\u8BA4\u5E95\u5EA7\u4E0E\u5DF2\u9A8C\u6536\u5236\u54C1\u4E0D\u4E00\u81F4");
|
|
61214
|
-
var BASE_IMAGE = acceptedBase.image.replace(`${ACR_VPC_REGISTRY}/`, `${ACR_REGISTRY}/`);
|
|
61215
61298
|
var PERSONA_LAYER_SCRIPT = "/opt/persona-layer.mjs";
|
|
61216
61299
|
var CLOUD_PERSONAS_ROOT = "/clawd/personas";
|
|
61217
61300
|
var GITIGNORE_LINES = [
|
|
@@ -61236,9 +61319,9 @@ function personaIdOf(repoName) {
|
|
|
61236
61319
|
return String(repoName).toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/^-+|-+$/g, "").slice(0, 40);
|
|
61237
61320
|
}
|
|
61238
61321
|
function renderDockerfile(personaId2, baseImage) {
|
|
61239
|
-
if (baseImage !==
|
|
61322
|
+
if (typeof baseImage !== "string" || !/^[a-z0-9.-]+(?::[0-9]+)?\/[a-z0-9._/-]+@sha256:[a-f0-9]{64}$/.test(baseImage)) throw new Error("base image must be a complete digest reference");
|
|
61240
61323
|
if (!/^[a-z0-9][a-z0-9-]{0,39}$/.test(personaId2)) throw new Error(`persona id \u4E0D\u5408\u5F62\u72B6\uFF08[a-z0-9-]\uFF0C\u226440\uFF09\uFF1A${JSON.stringify(personaId2)}`);
|
|
61241
|
-
const fromImage =
|
|
61324
|
+
const fromImage = baseImage.replace(`${ACR_VPC_REGISTRY}/`, `${ACR_REGISTRY}/`);
|
|
61242
61325
|
const dir = `${CLOUD_PERSONAS_ROOT}/${personaId2}`;
|
|
61243
61326
|
return [
|
|
61244
61327
|
"# \u7531 clawd \u751F\u6210\u3001\u7531 clawd \u7EF4\u62A4\uFF1A\u6BCF\u6B21\u300C\u53D1\u5E03\u300D\u90FD\u4F1A\u7528\u5F53\u524D\u6A21\u677F\u91CD\u5199\u8FD9\u4EFD\u6587\u4EF6\u518D\u63D0\u4EA4\uFF0C\u624B\u6539\u4F1A\u88AB\u76D6\u6389\u3002",
|
|
@@ -61522,19 +61605,11 @@ async function writeWorkflow(dir) {
|
|
|
61522
61605
|
await import_promises5.default.writeFile(wf, body);
|
|
61523
61606
|
}
|
|
61524
61607
|
}
|
|
61525
|
-
async function writeDockerfile(dir, personaId2) {
|
|
61526
|
-
|
|
61527
|
-
|
|
61528
|
-
|
|
61529
|
-
} catch (error) {
|
|
61530
|
-
if (error.code !== "ENOENT") throw error;
|
|
61531
|
-
}
|
|
61532
|
-
if (baseImage === void 0) {
|
|
61533
|
-
baseImage = BASE_IMAGE;
|
|
61534
|
-
await import_promises5.default.mkdir(import_node_path38.default.join(dir, ".clawd"), { recursive: true });
|
|
61535
|
-
await import_promises5.default.writeFile(import_node_path38.default.join(dir, ".clawd", "base-image.txt"), `${baseImage}
|
|
61608
|
+
async function writeDockerfile(dir, personaId2, image) {
|
|
61609
|
+
const baseImage = image.replace("registry-vpc.cn-hangzhou.aliyuncs.com/", "registry.cn-hangzhou.aliyuncs.com/");
|
|
61610
|
+
await import_promises5.default.mkdir(import_node_path38.default.join(dir, ".clawd"), { recursive: true });
|
|
61611
|
+
await import_promises5.default.writeFile(import_node_path38.default.join(dir, ".clawd", "base-image.txt"), `${baseImage}
|
|
61536
61612
|
`);
|
|
61537
|
-
}
|
|
61538
61613
|
await import_promises5.default.writeFile(import_node_path38.default.join(dir, DOCKERFILE_PATH), renderDockerfile(personaId2, baseImage));
|
|
61539
61614
|
await import_promises5.default.writeFile(import_node_path38.default.join(dir, DOCKERIGNORE_PATH), DOCKERIGNORE_TEMPLATE);
|
|
61540
61615
|
}
|
|
@@ -61638,6 +61713,7 @@ async function commitAll(exec, args) {
|
|
|
61638
61713
|
async function release(exec, api, args) {
|
|
61639
61714
|
const info = await repoInfo(exec, args.dir);
|
|
61640
61715
|
if (!info) throw new RepoError("\u8FD8\u6CA1\u6709\u4ED3\u5E93\uFF0C\u5148\u70B9\u4E00\u6B21\u300C\u53D1\u5E03\u5230\u4E91\u4E0A\u300D\u5EFA\u4ED3");
|
|
61716
|
+
const base = await readCurrentBase(api);
|
|
61641
61717
|
await prepareIntegration(exec, args.dir, args.auth);
|
|
61642
61718
|
const before = await readDeployFileRaw(args.dir);
|
|
61643
61719
|
let committed = false;
|
|
@@ -61646,7 +61722,7 @@ async function release(exec, api, args) {
|
|
|
61646
61722
|
await api.enableActions(repoSlug(info.url));
|
|
61647
61723
|
await writeGitignore(args.dir);
|
|
61648
61724
|
await writeWorkflow(args.dir);
|
|
61649
|
-
await writeDockerfile(args.dir, cloudPersonaIdOf(info.url));
|
|
61725
|
+
await writeDockerfile(args.dir, cloudPersonaIdOf(info.url), base.image);
|
|
61650
61726
|
const identity = await identityArgs(exec, args.dir);
|
|
61651
61727
|
await mustGit(exec, args.dir, ["add", "-A"], "\u6682\u5B58\u6587\u4EF6");
|
|
61652
61728
|
const stamp = new Date(args.now()).toISOString();
|
|
@@ -61668,7 +61744,7 @@ init_protocol();
|
|
|
61668
61744
|
function validatePersonaRelease(raw, expected) {
|
|
61669
61745
|
const record4 = VerifiedPersonaReleaseSchema.parse(raw);
|
|
61670
61746
|
if (record4.repository !== expected.repository || record4.commit !== expected.commit || new URL(record4.verification.endpoint).origin !== expected.endpoint) throw new Error("\u5236\u54C1\u4E0E\u672C\u6B21\u6D4B\u8BD5\u4ED3\u5E93\u3001\u63D0\u4EA4\u6216\u73AF\u5883\u4E0D\u4E00\u81F4");
|
|
61671
|
-
const fingerprint = (0,
|
|
61747
|
+
const fingerprint = (0, import_node_crypto11.createHash)("sha256").update(JSON.stringify({
|
|
61672
61748
|
component: record4.component,
|
|
61673
61749
|
image: record4.image,
|
|
61674
61750
|
commit: record4.commit,
|
|
@@ -61679,37 +61755,6 @@ function validatePersonaRelease(raw, expected) {
|
|
|
61679
61755
|
if (record4.verification.fingerprint !== fingerprint) throw new Error("\u5236\u54C1\u5DF2\u504F\u79BB\u6D4B\u8BD5\u65F6\u7684\u7248\u672C\uFF0C\u8BF7\u91CD\u65B0\u6D4B\u8BD5");
|
|
61680
61756
|
return record4;
|
|
61681
61757
|
}
|
|
61682
|
-
function inspectArchive(bytes) {
|
|
61683
|
-
const data = Buffer.from(bytes);
|
|
61684
|
-
let end = -1;
|
|
61685
|
-
for (let at4 = data.length - 22; at4 >= Math.max(0, data.length - 65557); at4--) {
|
|
61686
|
-
if (data.readUInt32LE(at4) === 101010256 && at4 + 22 + data.readUInt16LE(at4 + 20) === data.length) {
|
|
61687
|
-
end = at4;
|
|
61688
|
-
break;
|
|
61689
|
-
}
|
|
61690
|
-
}
|
|
61691
|
-
if (end < 0 || data.readUInt16LE(end + 4) || data.readUInt16LE(end + 6)) throw new Error("\u5236\u54C1\u5F52\u6863\u683C\u5F0F\u4E0D\u652F\u6301");
|
|
61692
|
-
const count = data.readUInt16LE(end + 10);
|
|
61693
|
-
const length = data.readUInt32LE(end + 12);
|
|
61694
|
-
let at3 = data.readUInt32LE(end + 16), roots = 0;
|
|
61695
|
-
if (count === 65535 || at3 + length !== end) throw new Error("\u5236\u54C1\u5F52\u6863\u683C\u5F0F\u4E0D\u652F\u6301");
|
|
61696
|
-
for (let i2 = 0; i2 < count; i2++) {
|
|
61697
|
-
if (at3 + 46 > end || data.readUInt32LE(at3) !== 33639248) throw new Error("\u5236\u54C1\u5F52\u6863\u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
61698
|
-
const nameLength = data.readUInt16LE(at3 + 28);
|
|
61699
|
-
const next = at3 + 46 + nameLength + data.readUInt16LE(at3 + 30) + data.readUInt16LE(at3 + 32);
|
|
61700
|
-
if (next > end) throw new Error("\u5236\u54C1\u5F52\u6863\u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
61701
|
-
const name = data.subarray(at3 + 46, at3 + 46 + nameLength).toString("utf8");
|
|
61702
|
-
if (name === "candidate-release.json") {
|
|
61703
|
-
roots++;
|
|
61704
|
-
if (data.readUInt32LE(at3 + 24) > 64 * 1024) throw new Error("\u5236\u54C1 JSON \u8D85\u8FC7\u5927\u5C0F\u9650\u5236");
|
|
61705
|
-
if (data.readUInt16LE(at3 + 8) & 1) throw new Error("\u5236\u54C1\u5F52\u6863\u4E0D\u80FD\u52A0\u5BC6");
|
|
61706
|
-
}
|
|
61707
|
-
at3 = next;
|
|
61708
|
-
}
|
|
61709
|
-
if (at3 !== end) throw new Error("\u5236\u54C1\u5F52\u6863\u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
61710
|
-
if (roots > 1) throw new Error("\u5236\u54C1\u5F52\u6863\u6709\u91CD\u590D\u7684\u6839 JSON");
|
|
61711
|
-
if (roots !== 1) throw new Error("\u5236\u54C1\u7F3A\u5C11\u6839\u76EE\u5F55\u7684 candidate-release.json");
|
|
61712
|
-
}
|
|
61713
61758
|
async function readVerifiedRelease(api, slug, run) {
|
|
61714
61759
|
if (run.environment !== "integration" || run.status !== "completed" || run.conclusion !== "success" || !run.jobs.some((j2) => j2.key === "deploy" && j2.status === "done")) throw new Error("\u6D4B\u8BD5\u90E8\u7F72\u8FD8\u6CA1\u6709\u6210\u529F\uFF0C\u4E0D\u80FD\u8BFB\u53D6\u5DF2\u6D4B\u5236\u54C1");
|
|
61715
61760
|
let artifact;
|
|
@@ -61725,31 +61770,7 @@ async function readVerifiedRelease(api, slug, run) {
|
|
|
61725
61770
|
if (!artifact || artifact.expired || !Number.isSafeInteger(artifact.id) || artifact.id <= 0) throw new Error("\u5DF2\u6D4B\u5236\u54C1\u4E0D\u5B58\u5728\u6216\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u53D1\u5E03\u6D4B\u8BD5");
|
|
61726
61771
|
if (artifact.workflow_run && (artifact.workflow_run.id !== run.runId || artifact.workflow_run.head_sha !== run.headSha)) throw new Error("\u5236\u54C1\u4E0D\u5C5E\u4E8E\u672C\u6B21\u6D4B\u8BD5\u6D41\u6C34\u7EBF");
|
|
61727
61772
|
const bytes = await api.downloadArtifact(slug, artifact.id);
|
|
61728
|
-
|
|
61729
|
-
inspectArchive(bytes);
|
|
61730
|
-
const zip = await import_jszip.default.loadAsync(bytes);
|
|
61731
|
-
const entry = zip.file("candidate-release.json");
|
|
61732
|
-
if (!entry || entry.dir || entry.unsafeOriginalName && entry.unsafeOriginalName !== "candidate-release.json") throw new Error("\u5236\u54C1\u7F3A\u5C11\u6839\u76EE\u5F55\u7684 candidate-release.json");
|
|
61733
|
-
const chunks = [];
|
|
61734
|
-
let size = 0;
|
|
61735
|
-
await new Promise((resolve9, reject) => {
|
|
61736
|
-
const stream = entry.nodeStream("nodebuffer");
|
|
61737
|
-
stream.on("data", (data) => {
|
|
61738
|
-
size += data.length;
|
|
61739
|
-
if (size > 64 * 1024) {
|
|
61740
|
-
stream.pause();
|
|
61741
|
-
reject(new Error("\u5236\u54C1 JSON \u8D85\u8FC7\u5927\u5C0F\u9650\u5236"));
|
|
61742
|
-
return;
|
|
61743
|
-
}
|
|
61744
|
-
chunks.push(Buffer.from(data));
|
|
61745
|
-
}).on("error", reject).on("end", resolve9).resume();
|
|
61746
|
-
});
|
|
61747
|
-
let raw;
|
|
61748
|
-
try {
|
|
61749
|
-
raw = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
61750
|
-
} catch {
|
|
61751
|
-
throw new Error("\u5236\u54C1 JSON \u4E0D\u662F\u5408\u6CD5\u683C\u5F0F");
|
|
61752
|
-
}
|
|
61773
|
+
const raw = await readReleaseArchive(bytes);
|
|
61753
61774
|
return { artifactId: artifact.id, release: validatePersonaRelease(raw, {
|
|
61754
61775
|
repository: slug,
|
|
61755
61776
|
commit: run.headSha,
|
|
@@ -61757,8 +61778,8 @@ async function readVerifiedRelease(api, slug, run) {
|
|
|
61757
61778
|
}) };
|
|
61758
61779
|
}
|
|
61759
61780
|
function requireDialogueVerification(release2, run) {
|
|
61760
|
-
if (!release2.verification.checks.includes(
|
|
61761
|
-
throw new Error("\u8FD9\u6B21\u53D1\u5E03\u8FD8\u6CA1\u6709\u901A\u8FC7\u81EA\u52A8\
|
|
61781
|
+
if (!["persona-dialogue", "persona-task"].every((check) => release2.verification.checks.includes(check)) || !run.jobs.some((j2) => j2.key === DEPLOY_VERIFY_STAGE && j2.status === "done")) {
|
|
61782
|
+
throw new Error("\u8FD9\u6B21\u53D1\u5E03\u8FD8\u6CA1\u6709\u901A\u8FC7\u81EA\u52A8 Conversation / Task \u9A8C\u8BC1\uFF0C\u8BF7\u91CD\u65B0\u626B\u63CF\u5E76\u53D1\u5E03\u6D4B\u8BD5\u73AF\u5883");
|
|
61762
61783
|
}
|
|
61763
61784
|
}
|
|
61764
61785
|
function integrationPersonaForRelease(cloud, release2, releaseId) {
|
|
@@ -61844,7 +61865,7 @@ async function resumePromotion(deps, original, options = {}) {
|
|
|
61844
61865
|
init_protocol();
|
|
61845
61866
|
|
|
61846
61867
|
// src/deploy/artifact.ts
|
|
61847
|
-
var
|
|
61868
|
+
var import_node_crypto12 = require("crypto");
|
|
61848
61869
|
var import_node_fs34 = __toESM(require("fs"), 1);
|
|
61849
61870
|
var import_node_os11 = __toESM(require("os"), 1);
|
|
61850
61871
|
var import_node_path39 = __toESM(require("path"), 1);
|
|
@@ -61883,7 +61904,7 @@ function downloadArtifact(exec) {
|
|
|
61883
61904
|
if (declared > ARTIFACT_MAX_BYTES) throw new Error(`\u8D44\u4EA7 ${declared} \u5B57\u8282\uFF0C\u8D85\u8FC7\u4E0A\u9650 ${ARTIFACT_MAX_BYTES}\uFF1A${url}`);
|
|
61884
61905
|
const dir = await import_node_fs34.default.promises.mkdtemp(import_node_path39.default.join(import_node_os11.default.tmpdir(), "clawd-artifact-"));
|
|
61885
61906
|
const file = import_node_path39.default.join(dir, "pkg");
|
|
61886
|
-
const hash = (0,
|
|
61907
|
+
const hash = (0, import_node_crypto12.createHash)("sha256");
|
|
61887
61908
|
let size = 0;
|
|
61888
61909
|
const meter = new import_node_stream3.Transform({
|
|
61889
61910
|
transform(chunk, _enc, cb) {
|
|
@@ -62781,7 +62802,7 @@ function buildDeployHandlers(deps) {
|
|
|
62781
62802
|
if (blockers.length > 0) throw invalid(`\u8FD8\u5DEE\uFF1A${blockers.join("\uFF1B")}`);
|
|
62782
62803
|
await configureTestIdentity(api, repoSlug(repo2.url));
|
|
62783
62804
|
if (await deps.claimPublisher(cloudPersonaIdOf(repo2.url), "integration") === "taken") throw invalid("\u6D4B\u8BD5\u73AF\u5883\u91CC\u7684\u8FD9\u4E2A\u540D\u5B57\u5DF2\u7531\u522B\u4EBA\u53D1\u5E03");
|
|
62784
|
-
const releaseId = (0,
|
|
62805
|
+
const releaseId = (0, import_node_crypto13.randomUUID)();
|
|
62785
62806
|
try {
|
|
62786
62807
|
const result = await release(deps.exec, api, { dir, now: deps.now, auth, manifest: entry.manifest, onPrepared: async (head) => {
|
|
62787
62808
|
const latest2 = await readHistory(dir);
|
|
@@ -62934,7 +62955,7 @@ function buildDeployHandlers(deps) {
|
|
|
62934
62955
|
const latest = await readHistory(mustPersona(personaId2));
|
|
62935
62956
|
await writeScanFile(mustPersona(personaId2), { ...latest, promotions: latest.promotions.map((p3) => p3.id === old.id ? { ...p3, phase: "failed", error: "\u51C6\u5907\u9636\u6BB5\u6D4B\u8BD5\u7248\u672C\u5DF2\u53D8\u5316\uFF0C\u5DF2\u7531\u91CD\u65B0\u786E\u8BA4\u7684\u65B0\u4EFB\u52A1\u66FF\u4EE3" } : p3) });
|
|
62936
62957
|
}
|
|
62937
|
-
const promotion = await continuePromotion(personaId2, record4, reuse ? { ...old, verified: snapshot ?? record4.verified } : { id: (0,
|
|
62958
|
+
const promotion = await continuePromotion(personaId2, record4, reuse ? { ...old, verified: snapshot ?? record4.verified } : { id: (0, import_node_crypto13.randomUUID)(), releaseId, at: deps.now(), phase: "prepared", verified: record4.verified }, true);
|
|
62938
62959
|
return { response: { type: "deploy:promote", promotion } };
|
|
62939
62960
|
};
|
|
62940
62961
|
const openTest = async (frame, _client, ctx) => {
|
|
@@ -64720,7 +64741,7 @@ ${formatLarkSpeakerReminder(speaker)}`
|
|
|
64720
64741
|
}
|
|
64721
64742
|
|
|
64722
64743
|
// src/lark-bot-connector/envelope.ts
|
|
64723
|
-
var
|
|
64744
|
+
var import_node_crypto14 = require("crypto");
|
|
64724
64745
|
var LARK_ENVELOPE_PREFIX = "clawdlbe1";
|
|
64725
64746
|
function verifyLarkEventEnvelope(args) {
|
|
64726
64747
|
const { token, publicKeyPem } = args;
|
|
@@ -64739,7 +64760,7 @@ function verifyLarkEventEnvelope(args) {
|
|
|
64739
64760
|
const data = Buffer.from(`${prefix}.${payloadB64}`, "utf8");
|
|
64740
64761
|
let sigOk = false;
|
|
64741
64762
|
try {
|
|
64742
|
-
sigOk = (0,
|
|
64763
|
+
sigOk = (0, import_node_crypto14.verify)(null, data, publicKeyPem, Buffer.from(sigB64, "base64url"));
|
|
64743
64764
|
} catch {
|
|
64744
64765
|
sigOk = false;
|
|
64745
64766
|
}
|
|
@@ -65342,7 +65363,7 @@ async function portableCloudInput(text, resolvers) {
|
|
|
65342
65363
|
}
|
|
65343
65364
|
|
|
65344
65365
|
// src/tools/cloud-turn-session.ts
|
|
65345
|
-
var
|
|
65366
|
+
var import_node_crypto15 = require("crypto");
|
|
65346
65367
|
function createCloudTurnSession(args) {
|
|
65347
65368
|
const { ctx, sink, client, personaId: personaId2, engine, instructions, engineSessionId, prepare } = args;
|
|
65348
65369
|
let conversationId = ctx.cloudConversationId ?? ctx.cloudExecutionId;
|
|
@@ -65364,7 +65385,7 @@ function createCloudTurnSession(args) {
|
|
|
65364
65385
|
void client.commandTurn(personaId2, conversationId, turnId, command).catch((e) => sink.onError(`\u4E91\u4E0A\u547D\u4EE4\u5931\u8D25\uFF1A${e.message}`));
|
|
65365
65386
|
};
|
|
65366
65387
|
return {
|
|
65367
|
-
startTurn(text, commandId = (0,
|
|
65388
|
+
startTurn(text, commandId = (0, import_node_crypto15.randomUUID)(), prepared = false) {
|
|
65368
65389
|
if (closed || live.has(commandId)) return;
|
|
65369
65390
|
conversationId ??= commandId;
|
|
65370
65391
|
live.add(commandId);
|
|
@@ -65677,7 +65698,7 @@ var PiRpcClient = class {
|
|
|
65677
65698
|
|
|
65678
65699
|
// src/tools/pi-session.ts
|
|
65679
65700
|
var import_node_child_process11 = require("child_process");
|
|
65680
|
-
var
|
|
65701
|
+
var import_node_crypto16 = require("crypto");
|
|
65681
65702
|
var import_node_fs40 = __toESM(require("fs"), 1);
|
|
65682
65703
|
var import_node_path44 = __toESM(require("path"), 1);
|
|
65683
65704
|
|
|
@@ -65959,7 +65980,7 @@ ${dirs.map((d2) => `- ${d2}`).join("\n")}`;
|
|
|
65959
65980
|
}
|
|
65960
65981
|
function createPiSession(ctx, sink, deps = {}) {
|
|
65961
65982
|
const cmd = process.env.PI_BIN ?? "pi";
|
|
65962
|
-
const sessionId = ctx.toolSessionId ?? (0,
|
|
65983
|
+
const sessionId = ctx.toolSessionId ?? (0, import_node_crypto16.randomUUID)();
|
|
65963
65984
|
const skillsDir = import_node_path44.default.join(ctx.cwd, ".claude", "skills");
|
|
65964
65985
|
const exists = deps.skillsDirExists ?? ((d2) => import_node_fs40.default.existsSync(d2));
|
|
65965
65986
|
const args = buildPiArgs(ctx, {
|
|
@@ -67321,7 +67342,7 @@ var wrapper_default = import_websocket.default;
|
|
|
67321
67342
|
|
|
67322
67343
|
// src/transport/local-ws-server.ts
|
|
67323
67344
|
var import_node_http = __toESM(require("http"), 1);
|
|
67324
|
-
var
|
|
67345
|
+
var import_node_crypto17 = require("crypto");
|
|
67325
67346
|
var LocalWsServer = class {
|
|
67326
67347
|
constructor(opts) {
|
|
67327
67348
|
this.opts = opts;
|
|
@@ -67531,7 +67552,7 @@ var LocalWsServer = class {
|
|
|
67531
67552
|
}
|
|
67532
67553
|
}
|
|
67533
67554
|
onConnection(socket, remoteAddress) {
|
|
67534
|
-
const id = (0,
|
|
67555
|
+
const id = (0, import_node_crypto17.randomUUID)();
|
|
67535
67556
|
const subscribedSessions = /* @__PURE__ */ new Map();
|
|
67536
67557
|
const handle = {
|
|
67537
67558
|
id,
|
|
@@ -68447,7 +68468,7 @@ var import_node_path53 = __toESM(require("path"), 1);
|
|
|
68447
68468
|
// src/attachment/upload.ts
|
|
68448
68469
|
var import_node_fs47 = __toESM(require("fs"), 1);
|
|
68449
68470
|
var import_node_path51 = __toESM(require("path"), 1);
|
|
68450
|
-
var
|
|
68471
|
+
var import_node_crypto18 = __toESM(require("crypto"), 1);
|
|
68451
68472
|
var import_promises8 = require("stream/promises");
|
|
68452
68473
|
var UploadError = class extends Error {
|
|
68453
68474
|
constructor(code, message) {
|
|
@@ -68471,11 +68492,11 @@ async function writeUploadedAttachment(args) {
|
|
|
68471
68492
|
} catch (err) {
|
|
68472
68493
|
throw new UploadError("STORAGE_ERROR", `mkdir failed: ${err.message}`);
|
|
68473
68494
|
}
|
|
68474
|
-
const hasher =
|
|
68495
|
+
const hasher = import_node_crypto18.default.createHash("sha256");
|
|
68475
68496
|
let actualSize = 0;
|
|
68476
68497
|
const tmpPath = import_node_path51.default.join(
|
|
68477
68498
|
attachmentsRoot,
|
|
68478
|
-
`.upload-${process.pid}-${Date.now()}-${
|
|
68499
|
+
`.upload-${process.pid}-${Date.now()}-${import_node_crypto18.default.randomBytes(4).toString("hex")}`
|
|
68479
68500
|
);
|
|
68480
68501
|
try {
|
|
68481
68502
|
await (0, import_promises8.pipeline)(
|
|
@@ -69325,7 +69346,7 @@ function runAttachmentGc(args) {
|
|
|
69325
69346
|
// src/attachment/group.ts
|
|
69326
69347
|
var import_node_fs50 = __toESM(require("fs"), 1);
|
|
69327
69348
|
var import_node_path55 = __toESM(require("path"), 1);
|
|
69328
|
-
var
|
|
69349
|
+
var import_node_crypto19 = __toESM(require("crypto"), 1);
|
|
69329
69350
|
init_protocol();
|
|
69330
69351
|
var GroupFileStore = class {
|
|
69331
69352
|
dataDir;
|
|
@@ -69403,7 +69424,7 @@ var GroupFileStore = class {
|
|
|
69403
69424
|
entries[idx] = next;
|
|
69404
69425
|
} else {
|
|
69405
69426
|
next = {
|
|
69406
|
-
id: `gf-${
|
|
69427
|
+
id: `gf-${import_node_crypto19.default.randomBytes(6).toString("base64url")}`,
|
|
69407
69428
|
relPath: input.relPath,
|
|
69408
69429
|
from: input.from,
|
|
69409
69430
|
label: input.label,
|
|
@@ -69525,7 +69546,7 @@ function readSpawnedByDesktopFromEnv(env = process.env) {
|
|
|
69525
69546
|
// src/tunnel/tunnel-manager.ts
|
|
69526
69547
|
var import_node_fs55 = __toESM(require("fs"), 1);
|
|
69527
69548
|
var import_node_path60 = __toESM(require("path"), 1);
|
|
69528
|
-
var
|
|
69549
|
+
var import_node_crypto20 = __toESM(require("crypto"), 1);
|
|
69529
69550
|
var import_node_child_process16 = require("child_process");
|
|
69530
69551
|
|
|
69531
69552
|
// src/tunnel/tunnel-store.ts
|
|
@@ -70022,7 +70043,7 @@ var TunnelManager = class {
|
|
|
70022
70043
|
override: this.deps.frpcBinaryOverride ?? void 0
|
|
70023
70044
|
});
|
|
70024
70045
|
const tomlPath = import_node_path60.default.join(this.deps.dataDir, "frpc.toml");
|
|
70025
|
-
const proxyName = `clawd-${t2.subdomain}-${localPort}-${
|
|
70046
|
+
const proxyName = `clawd-${t2.subdomain}-${localPort}-${import_node_crypto20.default.randomBytes(3).toString("hex")}`;
|
|
70026
70047
|
const toml = buildFrpcToml({
|
|
70027
70048
|
serverAddr: t2.frpsHost,
|
|
70028
70049
|
serverPort: t2.frpsPort,
|
|
@@ -70123,7 +70144,7 @@ async function waitForFrpcReady(proc, timeoutMs) {
|
|
|
70123
70144
|
// src/tunnel/device-key.ts
|
|
70124
70145
|
var import_node_os22 = __toESM(require("os"), 1);
|
|
70125
70146
|
var import_node_path61 = __toESM(require("path"), 1);
|
|
70126
|
-
var
|
|
70147
|
+
var import_node_crypto21 = __toESM(require("crypto"), 1);
|
|
70127
70148
|
var DERIVE_SALT = "clawd-tunnel-device-v1";
|
|
70128
70149
|
function deriveStableDeviceKey(opts = {}) {
|
|
70129
70150
|
const hostname = opts.hostname ?? import_node_os22.default.hostname();
|
|
@@ -70133,13 +70154,13 @@ function deriveStableDeviceKey(opts = {}) {
|
|
|
70133
70154
|
const normalizedDataDir = opts.dataDir ? import_node_path61.default.resolve(opts.dataDir) : null;
|
|
70134
70155
|
const isDefaultDir = normalizedDataDir == null || normalizedDataDir === defaultDataDir;
|
|
70135
70156
|
const input = isDefaultDir ? `${hostname}::${uid}` : `${hostname}::${uid}::${normalizedDataDir}`;
|
|
70136
|
-
return
|
|
70157
|
+
return import_node_crypto21.default.createHmac("sha256", DERIVE_SALT).update(input).digest("hex").slice(0, 32);
|
|
70137
70158
|
}
|
|
70138
70159
|
|
|
70139
70160
|
// src/auth-store.ts
|
|
70140
70161
|
var import_node_fs56 = __toESM(require("fs"), 1);
|
|
70141
70162
|
var import_node_path62 = __toESM(require("path"), 1);
|
|
70142
|
-
var
|
|
70163
|
+
var import_node_crypto22 = __toESM(require("crypto"), 1);
|
|
70143
70164
|
var AUTH_FILE_NAME = "auth.json";
|
|
70144
70165
|
function authFilePath(dataDir) {
|
|
70145
70166
|
return import_node_path62.default.join(dataDir, AUTH_FILE_NAME);
|
|
@@ -70176,10 +70197,10 @@ function loadOrCreateTunnelDeviceKey(opts) {
|
|
|
70176
70197
|
return tunnelDeviceKey;
|
|
70177
70198
|
}
|
|
70178
70199
|
function defaultGenerateToken() {
|
|
70179
|
-
return
|
|
70200
|
+
return import_node_crypto22.default.randomBytes(32).toString("base64url");
|
|
70180
70201
|
}
|
|
70181
70202
|
function defaultGenerateOwnerPrincipalId() {
|
|
70182
|
-
return `owner-${
|
|
70203
|
+
return `owner-${import_node_crypto22.default.randomUUID()}`;
|
|
70183
70204
|
}
|
|
70184
70205
|
function readAuthFile(file) {
|
|
70185
70206
|
try {
|
|
@@ -70311,7 +70332,7 @@ var OwnerIdentityStore = class {
|
|
|
70311
70332
|
};
|
|
70312
70333
|
|
|
70313
70334
|
// src/feishu-auth/login-flow.ts
|
|
70314
|
-
var
|
|
70335
|
+
var import_node_crypto23 = __toESM(require("crypto"), 1);
|
|
70315
70336
|
var STATE_TTL_MS = 5 * 60 * 1e3;
|
|
70316
70337
|
var LoginFlow = class {
|
|
70317
70338
|
constructor(deps) {
|
|
@@ -70321,7 +70342,7 @@ var LoginFlow = class {
|
|
|
70321
70342
|
pendingStates = /* @__PURE__ */ new Map();
|
|
70322
70343
|
generation = 0;
|
|
70323
70344
|
start() {
|
|
70324
|
-
const state =
|
|
70345
|
+
const state = import_node_crypto23.default.randomBytes(16).toString("base64url");
|
|
70325
70346
|
const now = (this.deps.now ?? Date.now)();
|
|
70326
70347
|
this.pendingStates.set(state, { issuedAt: now, owner: this.deps.expectedUnionId?.() });
|
|
70327
70348
|
this.gcExpired(now);
|
|
@@ -70855,7 +70876,7 @@ init_protocol();
|
|
|
70855
70876
|
var import_node_fs59 = __toESM(require("fs"), 1);
|
|
70856
70877
|
var import_node_os24 = __toESM(require("os"), 1);
|
|
70857
70878
|
var import_node_path65 = __toESM(require("path"), 1);
|
|
70858
|
-
var
|
|
70879
|
+
var import_node_crypto24 = require("crypto");
|
|
70859
70880
|
init_claude_history();
|
|
70860
70881
|
function readJsonlEntries(file) {
|
|
70861
70882
|
const raw = import_node_fs59.default.readFileSync(file, "utf8");
|
|
@@ -70892,7 +70913,7 @@ function forkSession(input) {
|
|
|
70892
70913
|
throw new Error(`fork: messageUuid not found in transcript: ${input.messageUuid}`);
|
|
70893
70914
|
}
|
|
70894
70915
|
const sliced = mainEntries.slice(0, targetIdx + 1);
|
|
70895
|
-
const forkedToolSessionId = (0,
|
|
70916
|
+
const forkedToolSessionId = (0, import_node_crypto24.randomUUID)();
|
|
70896
70917
|
let parentUuid = null;
|
|
70897
70918
|
const forkedLines = [];
|
|
70898
70919
|
for (const entry of sliced) {
|
|
@@ -73651,7 +73672,7 @@ function computeMethodAccess(args) {
|
|
|
73651
73672
|
}
|
|
73652
73673
|
|
|
73653
73674
|
// src/version.ts
|
|
73654
|
-
var version = "0.2.
|
|
73675
|
+
var version = "0.2.632".length > 0 ? "0.2.632" : "dev";
|
|
73655
73676
|
|
|
73656
73677
|
// src/cli-probe/probe.ts
|
|
73657
73678
|
var fs84 = __toESM(require("fs"), 1);
|
|
@@ -74045,7 +74066,7 @@ init_protocol();
|
|
|
74045
74066
|
// src/extension/bundle-zip.ts
|
|
74046
74067
|
var import_promises12 = __toESM(require("fs/promises"), 1);
|
|
74047
74068
|
var import_node_path74 = __toESM(require("path"), 1);
|
|
74048
|
-
var
|
|
74069
|
+
var import_node_crypto25 = __toESM(require("crypto"), 1);
|
|
74049
74070
|
var import_jszip3 = __toESM(require_lib3(), 1);
|
|
74050
74071
|
async function bundleExtensionDir(dir) {
|
|
74051
74072
|
const entries = await listFilesSorted(dir);
|
|
@@ -74060,7 +74081,7 @@ async function bundleExtensionDir(dir) {
|
|
|
74060
74081
|
compression: "DEFLATE",
|
|
74061
74082
|
compressionOptions: { level: 6 }
|
|
74062
74083
|
});
|
|
74063
|
-
const sha256 =
|
|
74084
|
+
const sha256 = import_node_crypto25.default.createHash("sha256").update(buffer).digest("hex");
|
|
74064
74085
|
return { buffer, sha256 };
|
|
74065
74086
|
}
|
|
74066
74087
|
var FIXED_DATE = /* @__PURE__ */ new Date("2020-01-01T00:00:00.000Z");
|
|
@@ -74128,7 +74149,7 @@ function computePublishCheck(args) {
|
|
|
74128
74149
|
var import_promises13 = __toESM(require("fs/promises"), 1);
|
|
74129
74150
|
var import_node_path76 = __toESM(require("path"), 1);
|
|
74130
74151
|
var import_node_os28 = __toESM(require("os"), 1);
|
|
74131
|
-
var
|
|
74152
|
+
var import_node_crypto26 = __toESM(require("crypto"), 1);
|
|
74132
74153
|
var import_jszip4 = __toESM(require_lib3(), 1);
|
|
74133
74154
|
|
|
74134
74155
|
// src/extension/paths.ts
|
|
@@ -74157,7 +74178,7 @@ var InstallError = class extends Error {
|
|
|
74157
74178
|
};
|
|
74158
74179
|
async function installFromChannel(args, deps) {
|
|
74159
74180
|
const { channelRef, snapshotHash, bundleZip } = args;
|
|
74160
|
-
const computed =
|
|
74181
|
+
const computed = import_node_crypto26.default.createHash("sha256").update(bundleZip).digest("hex");
|
|
74161
74182
|
if (computed !== snapshotHash) {
|
|
74162
74183
|
throw new InstallError(
|
|
74163
74184
|
"HASH_MISMATCH",
|
|
@@ -74249,7 +74270,7 @@ async function installFromChannel(args, deps) {
|
|
|
74249
74270
|
var import_promises14 = __toESM(require("fs/promises"), 1);
|
|
74250
74271
|
var import_node_path77 = __toESM(require("path"), 1);
|
|
74251
74272
|
var import_node_os29 = __toESM(require("os"), 1);
|
|
74252
|
-
var
|
|
74273
|
+
var import_node_crypto27 = __toESM(require("crypto"), 1);
|
|
74253
74274
|
var import_jszip5 = __toESM(require_lib3(), 1);
|
|
74254
74275
|
var UpdateError = class extends Error {
|
|
74255
74276
|
constructor(code, message) {
|
|
@@ -74287,7 +74308,7 @@ async function updateFromChannel(args, deps) {
|
|
|
74287
74308
|
if (e instanceof UpdateError) throw e;
|
|
74288
74309
|
throw e;
|
|
74289
74310
|
}
|
|
74290
|
-
const computed =
|
|
74311
|
+
const computed = import_node_crypto27.default.createHash("sha256").update(bundleZip).digest("hex");
|
|
74291
74312
|
if (computed !== snapshotHash) {
|
|
74292
74313
|
throw new UpdateError(
|
|
74293
74314
|
"HASH_MISMATCH",
|
|
@@ -75415,7 +75436,7 @@ async function uninstall(deps) {
|
|
|
75415
75436
|
}
|
|
75416
75437
|
|
|
75417
75438
|
// src/handlers/index.ts
|
|
75418
|
-
var
|
|
75439
|
+
var import_node_crypto28 = require("crypto");
|
|
75419
75440
|
|
|
75420
75441
|
// src/handlers/peer-exec.ts
|
|
75421
75442
|
init_protocol();
|
|
@@ -75572,7 +75593,7 @@ function buildMethodHandlers(deps) {
|
|
|
75572
75593
|
const c2 = deps.contactStore.get(deviceId);
|
|
75573
75594
|
return c2 ? { deviceId: c2.deviceId, remoteUrl: c2.remoteUrl, connectToken: c2.connectToken } : null;
|
|
75574
75595
|
},
|
|
75575
|
-
genId: () => (0,
|
|
75596
|
+
genId: () => (0, import_node_crypto28.randomUUID)(),
|
|
75576
75597
|
now: () => Date.now(),
|
|
75577
75598
|
forwardInboxPostToPeer,
|
|
75578
75599
|
logger: deps.logger
|
|
@@ -76292,7 +76313,7 @@ async function startDaemon(config) {
|
|
|
76292
76313
|
const channelStore = createChannelStore({
|
|
76293
76314
|
filePath: import_node_path85.default.join(config.dataDir, "channels.json"),
|
|
76294
76315
|
now: () => Date.now(),
|
|
76295
|
-
genId: () => `ch-${(0,
|
|
76316
|
+
genId: () => `ch-${(0, import_node_crypto29.randomUUID)().slice(0, 8)}`,
|
|
76296
76317
|
onFlushError: (err) => logger.error("channel store flush failed", {
|
|
76297
76318
|
reason: err instanceof Error ? err.message : String(err)
|
|
76298
76319
|
})
|
|
@@ -76301,7 +76322,7 @@ async function startDaemon(config) {
|
|
|
76301
76322
|
const topicStore = createTopicStore({
|
|
76302
76323
|
filePath: import_node_path85.default.join(config.dataDir, "topics.json"),
|
|
76303
76324
|
now: () => Date.now(),
|
|
76304
|
-
genId: () => `tp-${(0,
|
|
76325
|
+
genId: () => `tp-${(0, import_node_crypto29.randomUUID)().slice(0, 8)}`,
|
|
76305
76326
|
onFlushError: (err) => logger.error("topic store flush failed", {
|
|
76306
76327
|
reason: err instanceof Error ? err.message : String(err)
|
|
76307
76328
|
})
|
|
@@ -76309,7 +76330,7 @@ async function startDaemon(config) {
|
|
|
76309
76330
|
await topicStore.load();
|
|
76310
76331
|
let deliverPendingRef;
|
|
76311
76332
|
const personaDispatchManager = new PersonaDispatchManager({
|
|
76312
|
-
genId: () => (0,
|
|
76333
|
+
genId: () => (0, import_node_crypto29.randomUUID)(),
|
|
76313
76334
|
store: dispatchStore,
|
|
76314
76335
|
now: () => Date.now(),
|
|
76315
76336
|
onCompleted: (sid) => deliverPendingRef?.(sid),
|