@clawos-dev/clawd 0.2.630 → 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 +228 -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) {
|
|
@@ -61953,6 +61974,56 @@ function lookupDebianPackage(fetchFn = fetch) {
|
|
|
61953
61974
|
// src/handlers/deploy.ts
|
|
61954
61975
|
init_protocol();
|
|
61955
61976
|
|
|
61977
|
+
// src/deploy/publishing-config.ts
|
|
61978
|
+
async function requireIntegrationPublishingConfig(api, slug) {
|
|
61979
|
+
const base = `/repos/${slug}`;
|
|
61980
|
+
async function rows(path107, field, absentEnvironment = false) {
|
|
61981
|
+
const result = [];
|
|
61982
|
+
for (let page = 1; page <= 30; page++) {
|
|
61983
|
+
let raw;
|
|
61984
|
+
try {
|
|
61985
|
+
raw = await api.getJsonStrict(`${path107}?per_page=100&page=${page}`);
|
|
61986
|
+
} catch (error) {
|
|
61987
|
+
if (absentEnvironment && page === 1 && error instanceof GithubApiError && error.status === 404) return [];
|
|
61988
|
+
throw error;
|
|
61989
|
+
}
|
|
61990
|
+
const data = raw;
|
|
61991
|
+
const list = data?.[field];
|
|
61992
|
+
if (!Array.isArray(list) || list.some((r2) => !r2 || typeof r2.name !== "string" || field === "variables" && typeof r2.value !== "string")) {
|
|
61993
|
+
throw new Error("\u65E0\u6CD5\u5B8C\u6574\u8BFB\u53D6\u516C\u5171\u6D4B\u8BD5\u53D1\u5E03\u914D\u7F6E\u540D\u5355\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
|
|
61994
|
+
}
|
|
61995
|
+
result.push(...list);
|
|
61996
|
+
if (list.length < 100 && (data?.total_count === void 0 || result.length >= data.total_count)) return result;
|
|
61997
|
+
}
|
|
61998
|
+
throw new Error("\u516C\u5171\u6D4B\u8BD5\u53D1\u5E03\u914D\u7F6E\u540D\u5355\u672A\u5B8C\u6574\u8BFB\u5230\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
|
|
61999
|
+
}
|
|
62000
|
+
const [orgVars, repoVars, envVars, orgSecrets, repoSecrets, envSecrets] = await Promise.all([
|
|
62001
|
+
rows(`${base}/actions/organization-variables`, "variables"),
|
|
62002
|
+
rows(`${base}/actions/variables`, "variables"),
|
|
62003
|
+
rows(`${base}/environments/integration/variables`, "variables", true),
|
|
62004
|
+
rows(`${base}/actions/organization-secrets`, "secrets"),
|
|
62005
|
+
api.listSecrets(slug),
|
|
62006
|
+
api.listSecrets(slug, "integration")
|
|
62007
|
+
]);
|
|
62008
|
+
const variables = new Map([...orgVars, ...repoVars, ...envVars].map((v3) => [v3.name, v3.value]));
|
|
62009
|
+
const inheritedSecrets = orgSecrets.map((s2) => s2.name).sort().slice(0, 100);
|
|
62010
|
+
const secrets = /* @__PURE__ */ new Set([...inheritedSecrets, ...repoSecrets.map((s2) => s2.env), ...envSecrets.map((s2) => s2.env)]);
|
|
62011
|
+
const missing = [];
|
|
62012
|
+
const endpoint = variables.get("CLAWD_INT_GATEWAY_URL");
|
|
62013
|
+
if (!endpoint?.trim()) missing.push("\u6D4B\u8BD5\u7F51\u5173\u5730\u5740\uFF08CLAWD_INT_GATEWAY_URL\uFF09");
|
|
62014
|
+
if (!secrets.has("CLAWD_INT_GATEWAY_ADMIN_KEY")) missing.push("\u6D4B\u8BD5\u7F51\u5173\u7BA1\u7406\u51ED\u636E\uFF08CLAWD_INT_GATEWAY_ADMIN_KEY\uFF09");
|
|
62015
|
+
if (missing.length) throw new Error(`\u516C\u5171\u6D4B\u8BD5\u53D1\u5E03\u914D\u7F6E\u7F3A\u5C11\uFF1A${missing.join("\u3001")}\u3002\u8BF7\u7531\u7EC4\u7EC7\u7BA1\u7406\u5458\u7EDF\u4E00\u914D\u7F6E\u5E76\u5F00\u653E\u7ED9\u6B64\u4ED3\u5E93\uFF0C\u65E0\u9700\u6BCF\u4E2A Persona \u5355\u72EC\u586B\u5199\u3002`);
|
|
62016
|
+
let url;
|
|
62017
|
+
try {
|
|
62018
|
+
url = new URL(endpoint);
|
|
62019
|
+
} catch {
|
|
62020
|
+
throw new Error("\u516C\u5171\u6D4B\u8BD5\u53D1\u5E03\u914D\u7F6E\u4E2D\u7684\u7F51\u5173\u5730\u5740\u65E0\u6548\uFF0C\u8BF7\u7531\u7EC4\u7EC7\u7BA1\u7406\u5458\u68C0\u67E5");
|
|
62021
|
+
}
|
|
62022
|
+
if (url.origin !== DEPLOY_TARGETS.integration.gateway || url.username || url.password || url.search || url.hash || url.pathname !== "/") {
|
|
62023
|
+
throw new Error("\u516C\u5171\u6D4B\u8BD5\u53D1\u5E03\u914D\u7F6E\u4E2D\u7684\u7F51\u5173\u5730\u5740\u4E0D\u662F\u5E73\u53F0\u6D4B\u8BD5\u73AF\u5883\uFF0C\u8BF7\u68C0\u67E5\u4ED3\u5E93\u6216\u73AF\u5883\u4E2D\u7684\u540C\u540D\u8986\u76D6\u914D\u7F6E");
|
|
62024
|
+
}
|
|
62025
|
+
}
|
|
62026
|
+
|
|
61956
62027
|
// src/deploy/scan-base.ts
|
|
61957
62028
|
function pickScanBase(args) {
|
|
61958
62029
|
if (args.want === "hard") return { kind: "hard" };
|
|
@@ -62676,6 +62747,7 @@ function buildDeployHandlers(deps) {
|
|
|
62676
62747
|
return view(personaId2);
|
|
62677
62748
|
};
|
|
62678
62749
|
const configureTestIdentity = async (api, slug) => {
|
|
62750
|
+
await requireIntegrationPublishingConfig(api, slug);
|
|
62679
62751
|
await api.putSecret(slug, "CLAWD_INT_TEST_LOGIN_PASS", await deps.testLoginPass(), "integration");
|
|
62680
62752
|
};
|
|
62681
62753
|
const releaseHandler = async (frame, _client, ctx) => {
|
|
@@ -62730,7 +62802,7 @@ function buildDeployHandlers(deps) {
|
|
|
62730
62802
|
if (blockers.length > 0) throw invalid(`\u8FD8\u5DEE\uFF1A${blockers.join("\uFF1B")}`);
|
|
62731
62803
|
await configureTestIdentity(api, repoSlug(repo2.url));
|
|
62732
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");
|
|
62733
|
-
const releaseId = (0,
|
|
62805
|
+
const releaseId = (0, import_node_crypto13.randomUUID)();
|
|
62734
62806
|
try {
|
|
62735
62807
|
const result = await release(deps.exec, api, { dir, now: deps.now, auth, manifest: entry.manifest, onPrepared: async (head) => {
|
|
62736
62808
|
const latest2 = await readHistory(dir);
|
|
@@ -62883,7 +62955,7 @@ function buildDeployHandlers(deps) {
|
|
|
62883
62955
|
const latest = await readHistory(mustPersona(personaId2));
|
|
62884
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) });
|
|
62885
62957
|
}
|
|
62886
|
-
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);
|
|
62887
62959
|
return { response: { type: "deploy:promote", promotion } };
|
|
62888
62960
|
};
|
|
62889
62961
|
const openTest = async (frame, _client, ctx) => {
|
|
@@ -64669,7 +64741,7 @@ ${formatLarkSpeakerReminder(speaker)}`
|
|
|
64669
64741
|
}
|
|
64670
64742
|
|
|
64671
64743
|
// src/lark-bot-connector/envelope.ts
|
|
64672
|
-
var
|
|
64744
|
+
var import_node_crypto14 = require("crypto");
|
|
64673
64745
|
var LARK_ENVELOPE_PREFIX = "clawdlbe1";
|
|
64674
64746
|
function verifyLarkEventEnvelope(args) {
|
|
64675
64747
|
const { token, publicKeyPem } = args;
|
|
@@ -64688,7 +64760,7 @@ function verifyLarkEventEnvelope(args) {
|
|
|
64688
64760
|
const data = Buffer.from(`${prefix}.${payloadB64}`, "utf8");
|
|
64689
64761
|
let sigOk = false;
|
|
64690
64762
|
try {
|
|
64691
|
-
sigOk = (0,
|
|
64763
|
+
sigOk = (0, import_node_crypto14.verify)(null, data, publicKeyPem, Buffer.from(sigB64, "base64url"));
|
|
64692
64764
|
} catch {
|
|
64693
64765
|
sigOk = false;
|
|
64694
64766
|
}
|
|
@@ -65291,7 +65363,7 @@ async function portableCloudInput(text, resolvers) {
|
|
|
65291
65363
|
}
|
|
65292
65364
|
|
|
65293
65365
|
// src/tools/cloud-turn-session.ts
|
|
65294
|
-
var
|
|
65366
|
+
var import_node_crypto15 = require("crypto");
|
|
65295
65367
|
function createCloudTurnSession(args) {
|
|
65296
65368
|
const { ctx, sink, client, personaId: personaId2, engine, instructions, engineSessionId, prepare } = args;
|
|
65297
65369
|
let conversationId = ctx.cloudConversationId ?? ctx.cloudExecutionId;
|
|
@@ -65313,7 +65385,7 @@ function createCloudTurnSession(args) {
|
|
|
65313
65385
|
void client.commandTurn(personaId2, conversationId, turnId, command).catch((e) => sink.onError(`\u4E91\u4E0A\u547D\u4EE4\u5931\u8D25\uFF1A${e.message}`));
|
|
65314
65386
|
};
|
|
65315
65387
|
return {
|
|
65316
|
-
startTurn(text, commandId = (0,
|
|
65388
|
+
startTurn(text, commandId = (0, import_node_crypto15.randomUUID)(), prepared = false) {
|
|
65317
65389
|
if (closed || live.has(commandId)) return;
|
|
65318
65390
|
conversationId ??= commandId;
|
|
65319
65391
|
live.add(commandId);
|
|
@@ -65626,7 +65698,7 @@ var PiRpcClient = class {
|
|
|
65626
65698
|
|
|
65627
65699
|
// src/tools/pi-session.ts
|
|
65628
65700
|
var import_node_child_process11 = require("child_process");
|
|
65629
|
-
var
|
|
65701
|
+
var import_node_crypto16 = require("crypto");
|
|
65630
65702
|
var import_node_fs40 = __toESM(require("fs"), 1);
|
|
65631
65703
|
var import_node_path44 = __toESM(require("path"), 1);
|
|
65632
65704
|
|
|
@@ -65908,7 +65980,7 @@ ${dirs.map((d2) => `- ${d2}`).join("\n")}`;
|
|
|
65908
65980
|
}
|
|
65909
65981
|
function createPiSession(ctx, sink, deps = {}) {
|
|
65910
65982
|
const cmd = process.env.PI_BIN ?? "pi";
|
|
65911
|
-
const sessionId = ctx.toolSessionId ?? (0,
|
|
65983
|
+
const sessionId = ctx.toolSessionId ?? (0, import_node_crypto16.randomUUID)();
|
|
65912
65984
|
const skillsDir = import_node_path44.default.join(ctx.cwd, ".claude", "skills");
|
|
65913
65985
|
const exists = deps.skillsDirExists ?? ((d2) => import_node_fs40.default.existsSync(d2));
|
|
65914
65986
|
const args = buildPiArgs(ctx, {
|
|
@@ -67270,7 +67342,7 @@ var wrapper_default = import_websocket.default;
|
|
|
67270
67342
|
|
|
67271
67343
|
// src/transport/local-ws-server.ts
|
|
67272
67344
|
var import_node_http = __toESM(require("http"), 1);
|
|
67273
|
-
var
|
|
67345
|
+
var import_node_crypto17 = require("crypto");
|
|
67274
67346
|
var LocalWsServer = class {
|
|
67275
67347
|
constructor(opts) {
|
|
67276
67348
|
this.opts = opts;
|
|
@@ -67480,7 +67552,7 @@ var LocalWsServer = class {
|
|
|
67480
67552
|
}
|
|
67481
67553
|
}
|
|
67482
67554
|
onConnection(socket, remoteAddress) {
|
|
67483
|
-
const id = (0,
|
|
67555
|
+
const id = (0, import_node_crypto17.randomUUID)();
|
|
67484
67556
|
const subscribedSessions = /* @__PURE__ */ new Map();
|
|
67485
67557
|
const handle = {
|
|
67486
67558
|
id,
|
|
@@ -68396,7 +68468,7 @@ var import_node_path53 = __toESM(require("path"), 1);
|
|
|
68396
68468
|
// src/attachment/upload.ts
|
|
68397
68469
|
var import_node_fs47 = __toESM(require("fs"), 1);
|
|
68398
68470
|
var import_node_path51 = __toESM(require("path"), 1);
|
|
68399
|
-
var
|
|
68471
|
+
var import_node_crypto18 = __toESM(require("crypto"), 1);
|
|
68400
68472
|
var import_promises8 = require("stream/promises");
|
|
68401
68473
|
var UploadError = class extends Error {
|
|
68402
68474
|
constructor(code, message) {
|
|
@@ -68420,11 +68492,11 @@ async function writeUploadedAttachment(args) {
|
|
|
68420
68492
|
} catch (err) {
|
|
68421
68493
|
throw new UploadError("STORAGE_ERROR", `mkdir failed: ${err.message}`);
|
|
68422
68494
|
}
|
|
68423
|
-
const hasher =
|
|
68495
|
+
const hasher = import_node_crypto18.default.createHash("sha256");
|
|
68424
68496
|
let actualSize = 0;
|
|
68425
68497
|
const tmpPath = import_node_path51.default.join(
|
|
68426
68498
|
attachmentsRoot,
|
|
68427
|
-
`.upload-${process.pid}-${Date.now()}-${
|
|
68499
|
+
`.upload-${process.pid}-${Date.now()}-${import_node_crypto18.default.randomBytes(4).toString("hex")}`
|
|
68428
68500
|
);
|
|
68429
68501
|
try {
|
|
68430
68502
|
await (0, import_promises8.pipeline)(
|
|
@@ -69274,7 +69346,7 @@ function runAttachmentGc(args) {
|
|
|
69274
69346
|
// src/attachment/group.ts
|
|
69275
69347
|
var import_node_fs50 = __toESM(require("fs"), 1);
|
|
69276
69348
|
var import_node_path55 = __toESM(require("path"), 1);
|
|
69277
|
-
var
|
|
69349
|
+
var import_node_crypto19 = __toESM(require("crypto"), 1);
|
|
69278
69350
|
init_protocol();
|
|
69279
69351
|
var GroupFileStore = class {
|
|
69280
69352
|
dataDir;
|
|
@@ -69352,7 +69424,7 @@ var GroupFileStore = class {
|
|
|
69352
69424
|
entries[idx] = next;
|
|
69353
69425
|
} else {
|
|
69354
69426
|
next = {
|
|
69355
|
-
id: `gf-${
|
|
69427
|
+
id: `gf-${import_node_crypto19.default.randomBytes(6).toString("base64url")}`,
|
|
69356
69428
|
relPath: input.relPath,
|
|
69357
69429
|
from: input.from,
|
|
69358
69430
|
label: input.label,
|
|
@@ -69474,7 +69546,7 @@ function readSpawnedByDesktopFromEnv(env = process.env) {
|
|
|
69474
69546
|
// src/tunnel/tunnel-manager.ts
|
|
69475
69547
|
var import_node_fs55 = __toESM(require("fs"), 1);
|
|
69476
69548
|
var import_node_path60 = __toESM(require("path"), 1);
|
|
69477
|
-
var
|
|
69549
|
+
var import_node_crypto20 = __toESM(require("crypto"), 1);
|
|
69478
69550
|
var import_node_child_process16 = require("child_process");
|
|
69479
69551
|
|
|
69480
69552
|
// src/tunnel/tunnel-store.ts
|
|
@@ -69971,7 +70043,7 @@ var TunnelManager = class {
|
|
|
69971
70043
|
override: this.deps.frpcBinaryOverride ?? void 0
|
|
69972
70044
|
});
|
|
69973
70045
|
const tomlPath = import_node_path60.default.join(this.deps.dataDir, "frpc.toml");
|
|
69974
|
-
const proxyName = `clawd-${t2.subdomain}-${localPort}-${
|
|
70046
|
+
const proxyName = `clawd-${t2.subdomain}-${localPort}-${import_node_crypto20.default.randomBytes(3).toString("hex")}`;
|
|
69975
70047
|
const toml = buildFrpcToml({
|
|
69976
70048
|
serverAddr: t2.frpsHost,
|
|
69977
70049
|
serverPort: t2.frpsPort,
|
|
@@ -70072,7 +70144,7 @@ async function waitForFrpcReady(proc, timeoutMs) {
|
|
|
70072
70144
|
// src/tunnel/device-key.ts
|
|
70073
70145
|
var import_node_os22 = __toESM(require("os"), 1);
|
|
70074
70146
|
var import_node_path61 = __toESM(require("path"), 1);
|
|
70075
|
-
var
|
|
70147
|
+
var import_node_crypto21 = __toESM(require("crypto"), 1);
|
|
70076
70148
|
var DERIVE_SALT = "clawd-tunnel-device-v1";
|
|
70077
70149
|
function deriveStableDeviceKey(opts = {}) {
|
|
70078
70150
|
const hostname = opts.hostname ?? import_node_os22.default.hostname();
|
|
@@ -70082,13 +70154,13 @@ function deriveStableDeviceKey(opts = {}) {
|
|
|
70082
70154
|
const normalizedDataDir = opts.dataDir ? import_node_path61.default.resolve(opts.dataDir) : null;
|
|
70083
70155
|
const isDefaultDir = normalizedDataDir == null || normalizedDataDir === defaultDataDir;
|
|
70084
70156
|
const input = isDefaultDir ? `${hostname}::${uid}` : `${hostname}::${uid}::${normalizedDataDir}`;
|
|
70085
|
-
return
|
|
70157
|
+
return import_node_crypto21.default.createHmac("sha256", DERIVE_SALT).update(input).digest("hex").slice(0, 32);
|
|
70086
70158
|
}
|
|
70087
70159
|
|
|
70088
70160
|
// src/auth-store.ts
|
|
70089
70161
|
var import_node_fs56 = __toESM(require("fs"), 1);
|
|
70090
70162
|
var import_node_path62 = __toESM(require("path"), 1);
|
|
70091
|
-
var
|
|
70163
|
+
var import_node_crypto22 = __toESM(require("crypto"), 1);
|
|
70092
70164
|
var AUTH_FILE_NAME = "auth.json";
|
|
70093
70165
|
function authFilePath(dataDir) {
|
|
70094
70166
|
return import_node_path62.default.join(dataDir, AUTH_FILE_NAME);
|
|
@@ -70125,10 +70197,10 @@ function loadOrCreateTunnelDeviceKey(opts) {
|
|
|
70125
70197
|
return tunnelDeviceKey;
|
|
70126
70198
|
}
|
|
70127
70199
|
function defaultGenerateToken() {
|
|
70128
|
-
return
|
|
70200
|
+
return import_node_crypto22.default.randomBytes(32).toString("base64url");
|
|
70129
70201
|
}
|
|
70130
70202
|
function defaultGenerateOwnerPrincipalId() {
|
|
70131
|
-
return `owner-${
|
|
70203
|
+
return `owner-${import_node_crypto22.default.randomUUID()}`;
|
|
70132
70204
|
}
|
|
70133
70205
|
function readAuthFile(file) {
|
|
70134
70206
|
try {
|
|
@@ -70260,7 +70332,7 @@ var OwnerIdentityStore = class {
|
|
|
70260
70332
|
};
|
|
70261
70333
|
|
|
70262
70334
|
// src/feishu-auth/login-flow.ts
|
|
70263
|
-
var
|
|
70335
|
+
var import_node_crypto23 = __toESM(require("crypto"), 1);
|
|
70264
70336
|
var STATE_TTL_MS = 5 * 60 * 1e3;
|
|
70265
70337
|
var LoginFlow = class {
|
|
70266
70338
|
constructor(deps) {
|
|
@@ -70270,7 +70342,7 @@ var LoginFlow = class {
|
|
|
70270
70342
|
pendingStates = /* @__PURE__ */ new Map();
|
|
70271
70343
|
generation = 0;
|
|
70272
70344
|
start() {
|
|
70273
|
-
const state =
|
|
70345
|
+
const state = import_node_crypto23.default.randomBytes(16).toString("base64url");
|
|
70274
70346
|
const now = (this.deps.now ?? Date.now)();
|
|
70275
70347
|
this.pendingStates.set(state, { issuedAt: now, owner: this.deps.expectedUnionId?.() });
|
|
70276
70348
|
this.gcExpired(now);
|
|
@@ -70804,7 +70876,7 @@ init_protocol();
|
|
|
70804
70876
|
var import_node_fs59 = __toESM(require("fs"), 1);
|
|
70805
70877
|
var import_node_os24 = __toESM(require("os"), 1);
|
|
70806
70878
|
var import_node_path65 = __toESM(require("path"), 1);
|
|
70807
|
-
var
|
|
70879
|
+
var import_node_crypto24 = require("crypto");
|
|
70808
70880
|
init_claude_history();
|
|
70809
70881
|
function readJsonlEntries(file) {
|
|
70810
70882
|
const raw = import_node_fs59.default.readFileSync(file, "utf8");
|
|
@@ -70841,7 +70913,7 @@ function forkSession(input) {
|
|
|
70841
70913
|
throw new Error(`fork: messageUuid not found in transcript: ${input.messageUuid}`);
|
|
70842
70914
|
}
|
|
70843
70915
|
const sliced = mainEntries.slice(0, targetIdx + 1);
|
|
70844
|
-
const forkedToolSessionId = (0,
|
|
70916
|
+
const forkedToolSessionId = (0, import_node_crypto24.randomUUID)();
|
|
70845
70917
|
let parentUuid = null;
|
|
70846
70918
|
const forkedLines = [];
|
|
70847
70919
|
for (const entry of sliced) {
|
|
@@ -73600,7 +73672,7 @@ function computeMethodAccess(args) {
|
|
|
73600
73672
|
}
|
|
73601
73673
|
|
|
73602
73674
|
// src/version.ts
|
|
73603
|
-
var version = "0.2.
|
|
73675
|
+
var version = "0.2.632".length > 0 ? "0.2.632" : "dev";
|
|
73604
73676
|
|
|
73605
73677
|
// src/cli-probe/probe.ts
|
|
73606
73678
|
var fs84 = __toESM(require("fs"), 1);
|
|
@@ -73994,7 +74066,7 @@ init_protocol();
|
|
|
73994
74066
|
// src/extension/bundle-zip.ts
|
|
73995
74067
|
var import_promises12 = __toESM(require("fs/promises"), 1);
|
|
73996
74068
|
var import_node_path74 = __toESM(require("path"), 1);
|
|
73997
|
-
var
|
|
74069
|
+
var import_node_crypto25 = __toESM(require("crypto"), 1);
|
|
73998
74070
|
var import_jszip3 = __toESM(require_lib3(), 1);
|
|
73999
74071
|
async function bundleExtensionDir(dir) {
|
|
74000
74072
|
const entries = await listFilesSorted(dir);
|
|
@@ -74009,7 +74081,7 @@ async function bundleExtensionDir(dir) {
|
|
|
74009
74081
|
compression: "DEFLATE",
|
|
74010
74082
|
compressionOptions: { level: 6 }
|
|
74011
74083
|
});
|
|
74012
|
-
const sha256 =
|
|
74084
|
+
const sha256 = import_node_crypto25.default.createHash("sha256").update(buffer).digest("hex");
|
|
74013
74085
|
return { buffer, sha256 };
|
|
74014
74086
|
}
|
|
74015
74087
|
var FIXED_DATE = /* @__PURE__ */ new Date("2020-01-01T00:00:00.000Z");
|
|
@@ -74077,7 +74149,7 @@ function computePublishCheck(args) {
|
|
|
74077
74149
|
var import_promises13 = __toESM(require("fs/promises"), 1);
|
|
74078
74150
|
var import_node_path76 = __toESM(require("path"), 1);
|
|
74079
74151
|
var import_node_os28 = __toESM(require("os"), 1);
|
|
74080
|
-
var
|
|
74152
|
+
var import_node_crypto26 = __toESM(require("crypto"), 1);
|
|
74081
74153
|
var import_jszip4 = __toESM(require_lib3(), 1);
|
|
74082
74154
|
|
|
74083
74155
|
// src/extension/paths.ts
|
|
@@ -74106,7 +74178,7 @@ var InstallError = class extends Error {
|
|
|
74106
74178
|
};
|
|
74107
74179
|
async function installFromChannel(args, deps) {
|
|
74108
74180
|
const { channelRef, snapshotHash, bundleZip } = args;
|
|
74109
|
-
const computed =
|
|
74181
|
+
const computed = import_node_crypto26.default.createHash("sha256").update(bundleZip).digest("hex");
|
|
74110
74182
|
if (computed !== snapshotHash) {
|
|
74111
74183
|
throw new InstallError(
|
|
74112
74184
|
"HASH_MISMATCH",
|
|
@@ -74198,7 +74270,7 @@ async function installFromChannel(args, deps) {
|
|
|
74198
74270
|
var import_promises14 = __toESM(require("fs/promises"), 1);
|
|
74199
74271
|
var import_node_path77 = __toESM(require("path"), 1);
|
|
74200
74272
|
var import_node_os29 = __toESM(require("os"), 1);
|
|
74201
|
-
var
|
|
74273
|
+
var import_node_crypto27 = __toESM(require("crypto"), 1);
|
|
74202
74274
|
var import_jszip5 = __toESM(require_lib3(), 1);
|
|
74203
74275
|
var UpdateError = class extends Error {
|
|
74204
74276
|
constructor(code, message) {
|
|
@@ -74236,7 +74308,7 @@ async function updateFromChannel(args, deps) {
|
|
|
74236
74308
|
if (e instanceof UpdateError) throw e;
|
|
74237
74309
|
throw e;
|
|
74238
74310
|
}
|
|
74239
|
-
const computed =
|
|
74311
|
+
const computed = import_node_crypto27.default.createHash("sha256").update(bundleZip).digest("hex");
|
|
74240
74312
|
if (computed !== snapshotHash) {
|
|
74241
74313
|
throw new UpdateError(
|
|
74242
74314
|
"HASH_MISMATCH",
|
|
@@ -75364,7 +75436,7 @@ async function uninstall(deps) {
|
|
|
75364
75436
|
}
|
|
75365
75437
|
|
|
75366
75438
|
// src/handlers/index.ts
|
|
75367
|
-
var
|
|
75439
|
+
var import_node_crypto28 = require("crypto");
|
|
75368
75440
|
|
|
75369
75441
|
// src/handlers/peer-exec.ts
|
|
75370
75442
|
init_protocol();
|
|
@@ -75521,7 +75593,7 @@ function buildMethodHandlers(deps) {
|
|
|
75521
75593
|
const c2 = deps.contactStore.get(deviceId);
|
|
75522
75594
|
return c2 ? { deviceId: c2.deviceId, remoteUrl: c2.remoteUrl, connectToken: c2.connectToken } : null;
|
|
75523
75595
|
},
|
|
75524
|
-
genId: () => (0,
|
|
75596
|
+
genId: () => (0, import_node_crypto28.randomUUID)(),
|
|
75525
75597
|
now: () => Date.now(),
|
|
75526
75598
|
forwardInboxPostToPeer,
|
|
75527
75599
|
logger: deps.logger
|
|
@@ -76241,7 +76313,7 @@ async function startDaemon(config) {
|
|
|
76241
76313
|
const channelStore = createChannelStore({
|
|
76242
76314
|
filePath: import_node_path85.default.join(config.dataDir, "channels.json"),
|
|
76243
76315
|
now: () => Date.now(),
|
|
76244
|
-
genId: () => `ch-${(0,
|
|
76316
|
+
genId: () => `ch-${(0, import_node_crypto29.randomUUID)().slice(0, 8)}`,
|
|
76245
76317
|
onFlushError: (err) => logger.error("channel store flush failed", {
|
|
76246
76318
|
reason: err instanceof Error ? err.message : String(err)
|
|
76247
76319
|
})
|
|
@@ -76250,7 +76322,7 @@ async function startDaemon(config) {
|
|
|
76250
76322
|
const topicStore = createTopicStore({
|
|
76251
76323
|
filePath: import_node_path85.default.join(config.dataDir, "topics.json"),
|
|
76252
76324
|
now: () => Date.now(),
|
|
76253
|
-
genId: () => `tp-${(0,
|
|
76325
|
+
genId: () => `tp-${(0, import_node_crypto29.randomUUID)().slice(0, 8)}`,
|
|
76254
76326
|
onFlushError: (err) => logger.error("topic store flush failed", {
|
|
76255
76327
|
reason: err instanceof Error ? err.message : String(err)
|
|
76256
76328
|
})
|
|
@@ -76258,7 +76330,7 @@ async function startDaemon(config) {
|
|
|
76258
76330
|
await topicStore.load();
|
|
76259
76331
|
let deliverPendingRef;
|
|
76260
76332
|
const personaDispatchManager = new PersonaDispatchManager({
|
|
76261
|
-
genId: () => (0,
|
|
76333
|
+
genId: () => (0, import_node_crypto29.randomUUID)(),
|
|
76262
76334
|
store: dispatchStore,
|
|
76263
76335
|
now: () => Date.now(),
|
|
76264
76336
|
onCompleted: (sid) => deliverPendingRef?.(sid),
|