@clawos-dev/clawd 0.2.631 → 0.2.633
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 +9788 -60
- package/dist/cli.cjs +184 -158
- package/dist/cloud-persona-conversations.html +20 -20
- package/dist/cloud-persona-metrics.html +1 -1
- package/dist/dispatch/mcp-server.cjs +5 -1
- package/dist/persona-defaults/persona-app-builder/mcp/clawd-app-builder/mcp-server.cjs +9788 -60
- package/dist/persona-defaults/persona-dataclaw-builder/mcp/clawd-app-builder/mcp-server.cjs +9788 -60
- package/dist/share-md-viewer-error.html +1 -1
- package/dist/share-md-viewer.html +1 -1
- package/dist/share-ui/assets/{guest-ChwUkuXp.js → guest-C54v8Zd6.js} +116 -116
- package/dist/share-ui/assets/guest-tpz-2SdL.css +32 -0
- package/dist/share-ui/guest.html +2 -2
- package/package.json +1 -1
- package/dist/share-ui/assets/guest-BgjpLYnI.css +0 -32
package/dist/cli.cjs
CHANGED
|
@@ -7690,14 +7690,16 @@ var init_dashboard_schemas = __esm({
|
|
|
7690
7690
|
});
|
|
7691
7691
|
|
|
7692
7692
|
// ../protocol/src/persona-schemas.ts
|
|
7693
|
-
var PERSONA_SIZES, PersonaSizeSchema, PersonaFileSchema, PersonaSkillSummarySchema, PersonaPluginSummarySchema, CodexSandboxSettingsSchema, PersonaSandboxSettingsSchema, PersonaInfoResponseSchema, PersonaCreateArgsSchema, PersonaIdArgsSchema, PersonaUpdateArgsSchema;
|
|
7693
|
+
var PERSONA_SIZES, PersonaSizeSchema, PERSONA_CPUS, PersonaCpuSchema, PersonaFileSchema, PersonaSkillSummarySchema, PersonaPluginSummarySchema, CodexSandboxSettingsSchema, PersonaSandboxSettingsSchema, PersonaInfoResponseSchema, PersonaCreateArgsSchema, PersonaIdArgsSchema, PersonaUpdateArgsSchema;
|
|
7694
7694
|
var init_persona_schemas = __esm({
|
|
7695
7695
|
"../protocol/src/persona-schemas.ts"() {
|
|
7696
7696
|
"use strict";
|
|
7697
7697
|
init_zod();
|
|
7698
7698
|
init_release_schemas();
|
|
7699
|
-
PERSONA_SIZES = ["tiny", "small", "medium", "large"];
|
|
7699
|
+
PERSONA_SIZES = ["tiny", "small", "medium", "large", "xlarge"];
|
|
7700
7700
|
PersonaSizeSchema = external_exports.enum(PERSONA_SIZES);
|
|
7701
|
+
PERSONA_CPUS = [0.5, 1, 2];
|
|
7702
|
+
PersonaCpuSchema = external_exports.number().refine((cpu) => PERSONA_CPUS.includes(cpu), "Unsupported CPU");
|
|
7701
7703
|
PersonaFileSchema = external_exports.object({
|
|
7702
7704
|
personaId: external_exports.string(),
|
|
7703
7705
|
label: external_exports.string(),
|
|
@@ -7714,6 +7716,7 @@ var init_persona_schemas = __esm({
|
|
|
7714
7716
|
tool: external_exports.string().optional(),
|
|
7715
7717
|
/** Cloud resource size is string-compatible in stored files and narrowed at update/deploy boundaries; local execution ignores it. */
|
|
7716
7718
|
size: external_exports.string().optional(),
|
|
7719
|
+
cpu: external_exports.number().finite().optional(),
|
|
7717
7720
|
/** Cloud task-Pod concurrency, validated at release. Local execution ignores it; changes apply on the next publication. */
|
|
7718
7721
|
taskConcurrency: external_exports.number().int().positive().optional(),
|
|
7719
7722
|
createdAt: external_exports.number(),
|
|
@@ -7811,6 +7814,7 @@ var init_persona_schemas = __esm({
|
|
|
7811
7814
|
effort: external_exports.string().optional(),
|
|
7812
7815
|
tool: external_exports.string().optional(),
|
|
7813
7816
|
size: PersonaSizeSchema.optional(),
|
|
7817
|
+
cpu: PersonaCpuSchema.optional(),
|
|
7814
7818
|
taskConcurrency: PersonaFileSchema.shape.taskConcurrency,
|
|
7815
7819
|
personality: external_exports.string().optional(),
|
|
7816
7820
|
// 人格补充层正文(见 PersonaInfoResponseSchema.personalityLocal)。与 personality 各写
|
|
@@ -42487,7 +42491,7 @@ var require_websocket = __commonJS({
|
|
|
42487
42491
|
var http2 = require("http");
|
|
42488
42492
|
var net2 = require("net");
|
|
42489
42493
|
var tls = require("tls");
|
|
42490
|
-
var { randomBytes: randomBytes2, createHash:
|
|
42494
|
+
var { randomBytes: randomBytes2, createHash: createHash5 } = require("crypto");
|
|
42491
42495
|
var { Duplex, Readable: Readable4 } = require("stream");
|
|
42492
42496
|
var { URL: URL2 } = require("url");
|
|
42493
42497
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -43147,7 +43151,7 @@ var require_websocket = __commonJS({
|
|
|
43147
43151
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
43148
43152
|
return;
|
|
43149
43153
|
}
|
|
43150
|
-
const digest =
|
|
43154
|
+
const digest = createHash5("sha1").update(key + GUID).digest("base64");
|
|
43151
43155
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
43152
43156
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
43153
43157
|
return;
|
|
@@ -43514,7 +43518,7 @@ var require_websocket_server = __commonJS({
|
|
|
43514
43518
|
var EventEmitter2 = require("events");
|
|
43515
43519
|
var http2 = require("http");
|
|
43516
43520
|
var { Duplex } = require("stream");
|
|
43517
|
-
var { createHash:
|
|
43521
|
+
var { createHash: createHash5 } = require("crypto");
|
|
43518
43522
|
var extension2 = require_extension();
|
|
43519
43523
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
43520
43524
|
var subprotocol2 = require_subprotocol();
|
|
@@ -43815,7 +43819,7 @@ var require_websocket_server = __commonJS({
|
|
|
43815
43819
|
);
|
|
43816
43820
|
}
|
|
43817
43821
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
43818
|
-
const digest =
|
|
43822
|
+
const digest = createHash5("sha1").update(key + GUID).digest("base64");
|
|
43819
43823
|
const headers = [
|
|
43820
43824
|
"HTTP/1.1 101 Switching Protocols",
|
|
43821
43825
|
"Upgrade: websocket",
|
|
@@ -45483,7 +45487,7 @@ function requireEnvironmentIdentity(stores, environment) {
|
|
|
45483
45487
|
var import_node_path85 = __toESM(require("path"), 1);
|
|
45484
45488
|
var import_node_fs66 = __toESM(require("fs"), 1);
|
|
45485
45489
|
var import_node_os31 = __toESM(require("os"), 1);
|
|
45486
|
-
var
|
|
45490
|
+
var import_node_crypto29 = require("crypto");
|
|
45487
45491
|
var import_node_url6 = require("url");
|
|
45488
45492
|
|
|
45489
45493
|
// src/logger.ts
|
|
@@ -56538,11 +56542,72 @@ function buildShiftInternalHandlers(deps) {
|
|
|
56538
56542
|
}
|
|
56539
56543
|
|
|
56540
56544
|
// src/handlers/deploy.ts
|
|
56541
|
-
var
|
|
56545
|
+
var import_node_crypto13 = require("crypto");
|
|
56542
56546
|
|
|
56543
56547
|
// src/deploy/verified-release.ts
|
|
56544
|
-
var
|
|
56548
|
+
var import_node_crypto11 = require("crypto");
|
|
56549
|
+
|
|
56550
|
+
// src/deploy/release-archive.ts
|
|
56545
56551
|
var import_jszip = __toESM(require_lib3(), 1);
|
|
56552
|
+
function inspectArchive(bytes) {
|
|
56553
|
+
const data = Buffer.from(bytes);
|
|
56554
|
+
let end = -1;
|
|
56555
|
+
for (let at4 = data.length - 22; at4 >= Math.max(0, data.length - 65557); at4--) {
|
|
56556
|
+
if (data.readUInt32LE(at4) === 101010256 && at4 + 22 + data.readUInt16LE(at4 + 20) === data.length) {
|
|
56557
|
+
end = at4;
|
|
56558
|
+
break;
|
|
56559
|
+
}
|
|
56560
|
+
}
|
|
56561
|
+
if (end < 0 || data.readUInt16LE(end + 4) || data.readUInt16LE(end + 6)) throw new Error("\u5236\u54C1\u5F52\u6863\u683C\u5F0F\u4E0D\u652F\u6301");
|
|
56562
|
+
const count = data.readUInt16LE(end + 10);
|
|
56563
|
+
const length = data.readUInt32LE(end + 12);
|
|
56564
|
+
let at3 = data.readUInt32LE(end + 16), roots = 0;
|
|
56565
|
+
if (count === 65535 || at3 + length !== end) throw new Error("\u5236\u54C1\u5F52\u6863\u683C\u5F0F\u4E0D\u652F\u6301");
|
|
56566
|
+
for (let i2 = 0; i2 < count; i2++) {
|
|
56567
|
+
if (at3 + 46 > end || data.readUInt32LE(at3) !== 33639248) throw new Error("\u5236\u54C1\u5F52\u6863\u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
56568
|
+
const nameLength = data.readUInt16LE(at3 + 28);
|
|
56569
|
+
const next = at3 + 46 + nameLength + data.readUInt16LE(at3 + 30) + data.readUInt16LE(at3 + 32);
|
|
56570
|
+
if (next > end) throw new Error("\u5236\u54C1\u5F52\u6863\u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
56571
|
+
const name = data.subarray(at3 + 46, at3 + 46 + nameLength).toString("utf8");
|
|
56572
|
+
if (name === "candidate-release.json") {
|
|
56573
|
+
roots++;
|
|
56574
|
+
if (data.readUInt32LE(at3 + 24) > 64 * 1024) throw new Error("\u5236\u54C1 JSON \u8D85\u8FC7\u5927\u5C0F\u9650\u5236");
|
|
56575
|
+
if (data.readUInt16LE(at3 + 8) & 1) throw new Error("\u5236\u54C1\u5F52\u6863\u4E0D\u80FD\u52A0\u5BC6");
|
|
56576
|
+
}
|
|
56577
|
+
at3 = next;
|
|
56578
|
+
}
|
|
56579
|
+
if (at3 !== end) throw new Error("\u5236\u54C1\u5F52\u6863\u683C\u5F0F\u4E0D\u6B63\u786E");
|
|
56580
|
+
if (roots > 1) throw new Error("\u5236\u54C1\u5F52\u6863\u6709\u91CD\u590D\u7684\u6839 JSON");
|
|
56581
|
+
if (roots !== 1) throw new Error("\u5236\u54C1\u7F3A\u5C11\u6839\u76EE\u5F55\u7684 candidate-release.json");
|
|
56582
|
+
}
|
|
56583
|
+
async function readReleaseArchive(bytes) {
|
|
56584
|
+
if (bytes.length > 1024 * 1024) throw new Error("\u5236\u54C1\u5F52\u6863\u8D85\u8FC7\u5927\u5C0F\u9650\u5236");
|
|
56585
|
+
inspectArchive(bytes);
|
|
56586
|
+
const zip = await import_jszip.default.loadAsync(bytes);
|
|
56587
|
+
const entry = zip.file("candidate-release.json");
|
|
56588
|
+
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");
|
|
56589
|
+
const chunks = [];
|
|
56590
|
+
let size = 0;
|
|
56591
|
+
await new Promise((resolve9, reject) => {
|
|
56592
|
+
const stream = entry.nodeStream("nodebuffer");
|
|
56593
|
+
stream.on("data", (data) => {
|
|
56594
|
+
size += data.length;
|
|
56595
|
+
if (size > 64 * 1024) {
|
|
56596
|
+
stream.pause();
|
|
56597
|
+
reject(new Error("\u5236\u54C1 JSON \u8D85\u8FC7\u5927\u5C0F\u9650\u5236"));
|
|
56598
|
+
return;
|
|
56599
|
+
}
|
|
56600
|
+
chunks.push(Buffer.from(data));
|
|
56601
|
+
}).on("error", reject).on("end", resolve9).resume();
|
|
56602
|
+
});
|
|
56603
|
+
let raw;
|
|
56604
|
+
try {
|
|
56605
|
+
raw = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
56606
|
+
} catch {
|
|
56607
|
+
throw new Error("\u5236\u54C1 JSON \u4E0D\u662F\u5408\u6CD5\u683C\u5F0F");
|
|
56608
|
+
}
|
|
56609
|
+
return raw;
|
|
56610
|
+
}
|
|
56546
56611
|
|
|
56547
56612
|
// src/cloud/gateway-client.ts
|
|
56548
56613
|
init_protocol();
|
|
@@ -60940,6 +61005,63 @@ async function storeGithubAuth(args) {
|
|
|
60940
61005
|
return { token: args.token, source: "file" };
|
|
60941
61006
|
}
|
|
60942
61007
|
|
|
61008
|
+
// src/deploy/base-release.ts
|
|
61009
|
+
init_zod();
|
|
61010
|
+
var SLUG = "ottin4ttc/clawos";
|
|
61011
|
+
var WORKFLOW = ".github/workflows/base-image-acr.yml";
|
|
61012
|
+
var SHA = external_exports.string().regex(/^[a-f0-9]{40}$/);
|
|
61013
|
+
var SourceSchema = external_exports.object({ cloudHost: SHA, workflow: SHA });
|
|
61014
|
+
var BaseSchema = external_exports.object({
|
|
61015
|
+
version: external_exports.literal(1),
|
|
61016
|
+
component: external_exports.literal("base"),
|
|
61017
|
+
environment: external_exports.literal("integration"),
|
|
61018
|
+
commit: SHA,
|
|
61019
|
+
image: external_exports.string().regex(/^registry(?:-vpc)?\.cn-hangzhou\.aliyuncs\.com\/ttc-prod\/clawd-persona-base@sha256:[a-f0-9]{64}$/),
|
|
61020
|
+
source: SourceSchema,
|
|
61021
|
+
workflowCommit: SHA,
|
|
61022
|
+
buildId: external_exports.string().min(1)
|
|
61023
|
+
});
|
|
61024
|
+
async function currentSource(api) {
|
|
61025
|
+
const head = await api.getJsonStrict(`/repos/${SLUG}/commits/release`);
|
|
61026
|
+
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");
|
|
61027
|
+
const commit = SHA.parse(head?.sha), tree = SHA.parse(head?.commit?.tree?.sha);
|
|
61028
|
+
const [root, workflow] = await Promise.all([
|
|
61029
|
+
api.getJsonStrict(`/repos/${SLUG}/git/trees/${tree}`),
|
|
61030
|
+
api.getJsonStrict(`/repos/${SLUG}/contents/${WORKFLOW}?ref=${commit}`)
|
|
61031
|
+
]);
|
|
61032
|
+
if (root?.truncated || workflow?.type !== "file") throw new Error("\u8BFB\u4E0D\u5230\u5B8C\u6574\u5E95\u5EA7\u6E90\u7801\u7248\u672C");
|
|
61033
|
+
const source = SourceSchema.safeParse({ cloudHost: root?.tree?.find((e) => e.path === "cloud-host" && e.type === "tree")?.sha, workflow: workflow.sha });
|
|
61034
|
+
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");
|
|
61035
|
+
return { commit, source: source.data };
|
|
61036
|
+
}
|
|
61037
|
+
async function readCurrentBase(api) {
|
|
61038
|
+
const current = await currentSource(api);
|
|
61039
|
+
const listed = await api.getJsonStrict(`/repos/${SLUG}/actions/workflows/base-image-acr.yml/runs?branch=release&per_page=1`);
|
|
61040
|
+
const run = listed?.workflow_runs?.[0];
|
|
61041
|
+
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");
|
|
61042
|
+
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");
|
|
61043
|
+
SHA.parse(run.head_sha);
|
|
61044
|
+
let artifact;
|
|
61045
|
+
for (let page = 1; page <= 30; page++) {
|
|
61046
|
+
const list = await api.getJsonStrict(`/repos/${SLUG}/actions/runs/${run.id}/artifacts?per_page=100&page=${page}`);
|
|
61047
|
+
if (!Array.isArray(list?.artifacts)) throw new Error("\u8BFB\u4E0D\u5230\u5E95\u5EA7\u6784\u5EFA\u5236\u54C1");
|
|
61048
|
+
const hits = list.artifacts.filter((a2) => a2.name === `base-candidate-${run.id}-${run.run_attempt}`);
|
|
61049
|
+
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");
|
|
61050
|
+
artifact ??= hits[0];
|
|
61051
|
+
if (list.artifacts.length < 100 && (list.total_count === void 0 || page * 100 >= list.total_count)) break;
|
|
61052
|
+
if (page === 30) throw new Error("\u5E95\u5EA7\u5236\u54C1\u540D\u5355\u672A\u5B8C\u6574\u8BFB\u5230");
|
|
61053
|
+
}
|
|
61054
|
+
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");
|
|
61055
|
+
const parsed = BaseSchema.safeParse(await readReleaseArchive(await api.downloadArtifact(SLUG, artifact.id)));
|
|
61056
|
+
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");
|
|
61057
|
+
const release2 = parsed.data;
|
|
61058
|
+
const matches = (source) => release2.source.cloudHost === source.cloudHost && release2.source.workflow === source.workflow;
|
|
61059
|
+
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");
|
|
61060
|
+
const after = await currentSource(api);
|
|
61061
|
+
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");
|
|
61062
|
+
return release2;
|
|
61063
|
+
}
|
|
61064
|
+
|
|
60943
61065
|
// src/deploy/release-workflow.ts
|
|
60944
61066
|
init_protocol();
|
|
60945
61067
|
function renderDeployWorkflow(config) {
|
|
@@ -61040,6 +61162,7 @@ function renderDeployWorkflow(config) {
|
|
|
61040
61162
|
" --model '${{ steps.plan.outputs.model }}' \\",
|
|
61041
61163
|
" --effort '${{ steps.plan.outputs.effort }}' \\",
|
|
61042
61164
|
" --size '${{ steps.plan.outputs.size }}' \\",
|
|
61165
|
+
" --cpu '${{ steps.plan.outputs.cpu }}' \\",
|
|
61043
61166
|
" --task-concurrency '${{ steps.plan.outputs.task_concurrency }}' \\",
|
|
61044
61167
|
" --engine '${{ steps.plan.outputs.engine }}' \\",
|
|
61045
61168
|
" --connectors '${{ steps.plan.outputs.connectors }}' \\",
|
|
@@ -61164,30 +61287,6 @@ function renderDeployWorkflow(config) {
|
|
|
61164
61287
|
].join("\n");
|
|
61165
61288
|
}
|
|
61166
61289
|
|
|
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
61290
|
// src/deploy/templates.ts
|
|
61192
61291
|
init_protocol();
|
|
61193
61292
|
var CLAWOS_REPO = "ottin4ttc/clawos";
|
|
@@ -61201,17 +61300,6 @@ var DOCKERIGNORE_PATH = ".dockerignore";
|
|
|
61201
61300
|
var ACR_REGISTRY = "registry.cn-hangzhou.aliyuncs.com";
|
|
61202
61301
|
var ACR_VPC_REGISTRY = "registry-vpc.cn-hangzhou.aliyuncs.com";
|
|
61203
61302
|
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
61303
|
var PERSONA_LAYER_SCRIPT = "/opt/persona-layer.mjs";
|
|
61216
61304
|
var CLOUD_PERSONAS_ROOT = "/clawd/personas";
|
|
61217
61305
|
var GITIGNORE_LINES = [
|
|
@@ -61236,9 +61324,9 @@ function personaIdOf(repoName) {
|
|
|
61236
61324
|
return String(repoName).toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/^-+|-+$/g, "").slice(0, 40);
|
|
61237
61325
|
}
|
|
61238
61326
|
function renderDockerfile(personaId2, baseImage) {
|
|
61239
|
-
if (baseImage !==
|
|
61327
|
+
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
61328
|
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 =
|
|
61329
|
+
const fromImage = baseImage.replace(`${ACR_VPC_REGISTRY}/`, `${ACR_REGISTRY}/`);
|
|
61242
61330
|
const dir = `${CLOUD_PERSONAS_ROOT}/${personaId2}`;
|
|
61243
61331
|
return [
|
|
61244
61332
|
"# \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 +61610,11 @@ async function writeWorkflow(dir) {
|
|
|
61522
61610
|
await import_promises5.default.writeFile(wf, body);
|
|
61523
61611
|
}
|
|
61524
61612
|
}
|
|
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}
|
|
61613
|
+
async function writeDockerfile(dir, personaId2, image) {
|
|
61614
|
+
const baseImage = image.replace("registry-vpc.cn-hangzhou.aliyuncs.com/", "registry.cn-hangzhou.aliyuncs.com/");
|
|
61615
|
+
await import_promises5.default.mkdir(import_node_path38.default.join(dir, ".clawd"), { recursive: true });
|
|
61616
|
+
await import_promises5.default.writeFile(import_node_path38.default.join(dir, ".clawd", "base-image.txt"), `${baseImage}
|
|
61536
61617
|
`);
|
|
61537
|
-
}
|
|
61538
61618
|
await import_promises5.default.writeFile(import_node_path38.default.join(dir, DOCKERFILE_PATH), renderDockerfile(personaId2, baseImage));
|
|
61539
61619
|
await import_promises5.default.writeFile(import_node_path38.default.join(dir, DOCKERIGNORE_PATH), DOCKERIGNORE_TEMPLATE);
|
|
61540
61620
|
}
|
|
@@ -61638,6 +61718,7 @@ async function commitAll(exec, args) {
|
|
|
61638
61718
|
async function release(exec, api, args) {
|
|
61639
61719
|
const info = await repoInfo(exec, args.dir);
|
|
61640
61720
|
if (!info) throw new RepoError("\u8FD8\u6CA1\u6709\u4ED3\u5E93\uFF0C\u5148\u70B9\u4E00\u6B21\u300C\u53D1\u5E03\u5230\u4E91\u4E0A\u300D\u5EFA\u4ED3");
|
|
61721
|
+
const base = await readCurrentBase(api);
|
|
61641
61722
|
await prepareIntegration(exec, args.dir, args.auth);
|
|
61642
61723
|
const before = await readDeployFileRaw(args.dir);
|
|
61643
61724
|
let committed = false;
|
|
@@ -61646,7 +61727,7 @@ async function release(exec, api, args) {
|
|
|
61646
61727
|
await api.enableActions(repoSlug(info.url));
|
|
61647
61728
|
await writeGitignore(args.dir);
|
|
61648
61729
|
await writeWorkflow(args.dir);
|
|
61649
|
-
await writeDockerfile(args.dir, cloudPersonaIdOf(info.url));
|
|
61730
|
+
await writeDockerfile(args.dir, cloudPersonaIdOf(info.url), base.image);
|
|
61650
61731
|
const identity = await identityArgs(exec, args.dir);
|
|
61651
61732
|
await mustGit(exec, args.dir, ["add", "-A"], "\u6682\u5B58\u6587\u4EF6");
|
|
61652
61733
|
const stamp = new Date(args.now()).toISOString();
|
|
@@ -61668,7 +61749,7 @@ init_protocol();
|
|
|
61668
61749
|
function validatePersonaRelease(raw, expected) {
|
|
61669
61750
|
const record4 = VerifiedPersonaReleaseSchema.parse(raw);
|
|
61670
61751
|
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,
|
|
61752
|
+
const fingerprint = (0, import_node_crypto11.createHash)("sha256").update(JSON.stringify({
|
|
61672
61753
|
component: record4.component,
|
|
61673
61754
|
image: record4.image,
|
|
61674
61755
|
commit: record4.commit,
|
|
@@ -61679,37 +61760,6 @@ function validatePersonaRelease(raw, expected) {
|
|
|
61679
61760
|
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
61761
|
return record4;
|
|
61681
61762
|
}
|
|
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
61763
|
async function readVerifiedRelease(api, slug, run) {
|
|
61714
61764
|
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
61765
|
let artifact;
|
|
@@ -61725,31 +61775,7 @@ async function readVerifiedRelease(api, slug, run) {
|
|
|
61725
61775
|
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
61776
|
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
61777
|
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
|
-
}
|
|
61778
|
+
const raw = await readReleaseArchive(bytes);
|
|
61753
61779
|
return { artifactId: artifact.id, release: validatePersonaRelease(raw, {
|
|
61754
61780
|
repository: slug,
|
|
61755
61781
|
commit: run.headSha,
|
|
@@ -61757,8 +61783,8 @@ async function readVerifiedRelease(api, slug, run) {
|
|
|
61757
61783
|
}) };
|
|
61758
61784
|
}
|
|
61759
61785
|
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\
|
|
61786
|
+
if (!["persona-dialogue", "persona-task"].every((check) => release2.verification.checks.includes(check)) || !run.jobs.some((j2) => j2.key === DEPLOY_VERIFY_STAGE && j2.status === "done")) {
|
|
61787
|
+
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
61788
|
}
|
|
61763
61789
|
}
|
|
61764
61790
|
function integrationPersonaForRelease(cloud, release2, releaseId) {
|
|
@@ -61844,7 +61870,7 @@ async function resumePromotion(deps, original, options = {}) {
|
|
|
61844
61870
|
init_protocol();
|
|
61845
61871
|
|
|
61846
61872
|
// src/deploy/artifact.ts
|
|
61847
|
-
var
|
|
61873
|
+
var import_node_crypto12 = require("crypto");
|
|
61848
61874
|
var import_node_fs34 = __toESM(require("fs"), 1);
|
|
61849
61875
|
var import_node_os11 = __toESM(require("os"), 1);
|
|
61850
61876
|
var import_node_path39 = __toESM(require("path"), 1);
|
|
@@ -61883,7 +61909,7 @@ function downloadArtifact(exec) {
|
|
|
61883
61909
|
if (declared > ARTIFACT_MAX_BYTES) throw new Error(`\u8D44\u4EA7 ${declared} \u5B57\u8282\uFF0C\u8D85\u8FC7\u4E0A\u9650 ${ARTIFACT_MAX_BYTES}\uFF1A${url}`);
|
|
61884
61910
|
const dir = await import_node_fs34.default.promises.mkdtemp(import_node_path39.default.join(import_node_os11.default.tmpdir(), "clawd-artifact-"));
|
|
61885
61911
|
const file = import_node_path39.default.join(dir, "pkg");
|
|
61886
|
-
const hash = (0,
|
|
61912
|
+
const hash = (0, import_node_crypto12.createHash)("sha256");
|
|
61887
61913
|
let size = 0;
|
|
61888
61914
|
const meter = new import_node_stream3.Transform({
|
|
61889
61915
|
transform(chunk, _enc, cb) {
|
|
@@ -62781,7 +62807,7 @@ function buildDeployHandlers(deps) {
|
|
|
62781
62807
|
if (blockers.length > 0) throw invalid(`\u8FD8\u5DEE\uFF1A${blockers.join("\uFF1B")}`);
|
|
62782
62808
|
await configureTestIdentity(api, repoSlug(repo2.url));
|
|
62783
62809
|
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,
|
|
62810
|
+
const releaseId = (0, import_node_crypto13.randomUUID)();
|
|
62785
62811
|
try {
|
|
62786
62812
|
const result = await release(deps.exec, api, { dir, now: deps.now, auth, manifest: entry.manifest, onPrepared: async (head) => {
|
|
62787
62813
|
const latest2 = await readHistory(dir);
|
|
@@ -62934,7 +62960,7 @@ function buildDeployHandlers(deps) {
|
|
|
62934
62960
|
const latest = await readHistory(mustPersona(personaId2));
|
|
62935
62961
|
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
62962
|
}
|
|
62937
|
-
const promotion = await continuePromotion(personaId2, record4, reuse ? { ...old, verified: snapshot ?? record4.verified } : { id: (0,
|
|
62963
|
+
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
62964
|
return { response: { type: "deploy:promote", promotion } };
|
|
62939
62965
|
};
|
|
62940
62966
|
const openTest = async (frame, _client, ctx) => {
|
|
@@ -64720,7 +64746,7 @@ ${formatLarkSpeakerReminder(speaker)}`
|
|
|
64720
64746
|
}
|
|
64721
64747
|
|
|
64722
64748
|
// src/lark-bot-connector/envelope.ts
|
|
64723
|
-
var
|
|
64749
|
+
var import_node_crypto14 = require("crypto");
|
|
64724
64750
|
var LARK_ENVELOPE_PREFIX = "clawdlbe1";
|
|
64725
64751
|
function verifyLarkEventEnvelope(args) {
|
|
64726
64752
|
const { token, publicKeyPem } = args;
|
|
@@ -64739,7 +64765,7 @@ function verifyLarkEventEnvelope(args) {
|
|
|
64739
64765
|
const data = Buffer.from(`${prefix}.${payloadB64}`, "utf8");
|
|
64740
64766
|
let sigOk = false;
|
|
64741
64767
|
try {
|
|
64742
|
-
sigOk = (0,
|
|
64768
|
+
sigOk = (0, import_node_crypto14.verify)(null, data, publicKeyPem, Buffer.from(sigB64, "base64url"));
|
|
64743
64769
|
} catch {
|
|
64744
64770
|
sigOk = false;
|
|
64745
64771
|
}
|
|
@@ -65342,7 +65368,7 @@ async function portableCloudInput(text, resolvers) {
|
|
|
65342
65368
|
}
|
|
65343
65369
|
|
|
65344
65370
|
// src/tools/cloud-turn-session.ts
|
|
65345
|
-
var
|
|
65371
|
+
var import_node_crypto15 = require("crypto");
|
|
65346
65372
|
function createCloudTurnSession(args) {
|
|
65347
65373
|
const { ctx, sink, client, personaId: personaId2, engine, instructions, engineSessionId, prepare } = args;
|
|
65348
65374
|
let conversationId = ctx.cloudConversationId ?? ctx.cloudExecutionId;
|
|
@@ -65364,7 +65390,7 @@ function createCloudTurnSession(args) {
|
|
|
65364
65390
|
void client.commandTurn(personaId2, conversationId, turnId, command).catch((e) => sink.onError(`\u4E91\u4E0A\u547D\u4EE4\u5931\u8D25\uFF1A${e.message}`));
|
|
65365
65391
|
};
|
|
65366
65392
|
return {
|
|
65367
|
-
startTurn(text, commandId = (0,
|
|
65393
|
+
startTurn(text, commandId = (0, import_node_crypto15.randomUUID)(), prepared = false) {
|
|
65368
65394
|
if (closed || live.has(commandId)) return;
|
|
65369
65395
|
conversationId ??= commandId;
|
|
65370
65396
|
live.add(commandId);
|
|
@@ -65677,7 +65703,7 @@ var PiRpcClient = class {
|
|
|
65677
65703
|
|
|
65678
65704
|
// src/tools/pi-session.ts
|
|
65679
65705
|
var import_node_child_process11 = require("child_process");
|
|
65680
|
-
var
|
|
65706
|
+
var import_node_crypto16 = require("crypto");
|
|
65681
65707
|
var import_node_fs40 = __toESM(require("fs"), 1);
|
|
65682
65708
|
var import_node_path44 = __toESM(require("path"), 1);
|
|
65683
65709
|
|
|
@@ -65959,7 +65985,7 @@ ${dirs.map((d2) => `- ${d2}`).join("\n")}`;
|
|
|
65959
65985
|
}
|
|
65960
65986
|
function createPiSession(ctx, sink, deps = {}) {
|
|
65961
65987
|
const cmd = process.env.PI_BIN ?? "pi";
|
|
65962
|
-
const sessionId = ctx.toolSessionId ?? (0,
|
|
65988
|
+
const sessionId = ctx.toolSessionId ?? (0, import_node_crypto16.randomUUID)();
|
|
65963
65989
|
const skillsDir = import_node_path44.default.join(ctx.cwd, ".claude", "skills");
|
|
65964
65990
|
const exists = deps.skillsDirExists ?? ((d2) => import_node_fs40.default.existsSync(d2));
|
|
65965
65991
|
const args = buildPiArgs(ctx, {
|
|
@@ -67321,7 +67347,7 @@ var wrapper_default = import_websocket.default;
|
|
|
67321
67347
|
|
|
67322
67348
|
// src/transport/local-ws-server.ts
|
|
67323
67349
|
var import_node_http = __toESM(require("http"), 1);
|
|
67324
|
-
var
|
|
67350
|
+
var import_node_crypto17 = require("crypto");
|
|
67325
67351
|
var LocalWsServer = class {
|
|
67326
67352
|
constructor(opts) {
|
|
67327
67353
|
this.opts = opts;
|
|
@@ -67531,7 +67557,7 @@ var LocalWsServer = class {
|
|
|
67531
67557
|
}
|
|
67532
67558
|
}
|
|
67533
67559
|
onConnection(socket, remoteAddress) {
|
|
67534
|
-
const id = (0,
|
|
67560
|
+
const id = (0, import_node_crypto17.randomUUID)();
|
|
67535
67561
|
const subscribedSessions = /* @__PURE__ */ new Map();
|
|
67536
67562
|
const handle = {
|
|
67537
67563
|
id,
|
|
@@ -68447,7 +68473,7 @@ var import_node_path53 = __toESM(require("path"), 1);
|
|
|
68447
68473
|
// src/attachment/upload.ts
|
|
68448
68474
|
var import_node_fs47 = __toESM(require("fs"), 1);
|
|
68449
68475
|
var import_node_path51 = __toESM(require("path"), 1);
|
|
68450
|
-
var
|
|
68476
|
+
var import_node_crypto18 = __toESM(require("crypto"), 1);
|
|
68451
68477
|
var import_promises8 = require("stream/promises");
|
|
68452
68478
|
var UploadError = class extends Error {
|
|
68453
68479
|
constructor(code, message) {
|
|
@@ -68471,11 +68497,11 @@ async function writeUploadedAttachment(args) {
|
|
|
68471
68497
|
} catch (err) {
|
|
68472
68498
|
throw new UploadError("STORAGE_ERROR", `mkdir failed: ${err.message}`);
|
|
68473
68499
|
}
|
|
68474
|
-
const hasher =
|
|
68500
|
+
const hasher = import_node_crypto18.default.createHash("sha256");
|
|
68475
68501
|
let actualSize = 0;
|
|
68476
68502
|
const tmpPath = import_node_path51.default.join(
|
|
68477
68503
|
attachmentsRoot,
|
|
68478
|
-
`.upload-${process.pid}-${Date.now()}-${
|
|
68504
|
+
`.upload-${process.pid}-${Date.now()}-${import_node_crypto18.default.randomBytes(4).toString("hex")}`
|
|
68479
68505
|
);
|
|
68480
68506
|
try {
|
|
68481
68507
|
await (0, import_promises8.pipeline)(
|
|
@@ -69325,7 +69351,7 @@ function runAttachmentGc(args) {
|
|
|
69325
69351
|
// src/attachment/group.ts
|
|
69326
69352
|
var import_node_fs50 = __toESM(require("fs"), 1);
|
|
69327
69353
|
var import_node_path55 = __toESM(require("path"), 1);
|
|
69328
|
-
var
|
|
69354
|
+
var import_node_crypto19 = __toESM(require("crypto"), 1);
|
|
69329
69355
|
init_protocol();
|
|
69330
69356
|
var GroupFileStore = class {
|
|
69331
69357
|
dataDir;
|
|
@@ -69403,7 +69429,7 @@ var GroupFileStore = class {
|
|
|
69403
69429
|
entries[idx] = next;
|
|
69404
69430
|
} else {
|
|
69405
69431
|
next = {
|
|
69406
|
-
id: `gf-${
|
|
69432
|
+
id: `gf-${import_node_crypto19.default.randomBytes(6).toString("base64url")}`,
|
|
69407
69433
|
relPath: input.relPath,
|
|
69408
69434
|
from: input.from,
|
|
69409
69435
|
label: input.label,
|
|
@@ -69525,7 +69551,7 @@ function readSpawnedByDesktopFromEnv(env = process.env) {
|
|
|
69525
69551
|
// src/tunnel/tunnel-manager.ts
|
|
69526
69552
|
var import_node_fs55 = __toESM(require("fs"), 1);
|
|
69527
69553
|
var import_node_path60 = __toESM(require("path"), 1);
|
|
69528
|
-
var
|
|
69554
|
+
var import_node_crypto20 = __toESM(require("crypto"), 1);
|
|
69529
69555
|
var import_node_child_process16 = require("child_process");
|
|
69530
69556
|
|
|
69531
69557
|
// src/tunnel/tunnel-store.ts
|
|
@@ -70022,7 +70048,7 @@ var TunnelManager = class {
|
|
|
70022
70048
|
override: this.deps.frpcBinaryOverride ?? void 0
|
|
70023
70049
|
});
|
|
70024
70050
|
const tomlPath = import_node_path60.default.join(this.deps.dataDir, "frpc.toml");
|
|
70025
|
-
const proxyName = `clawd-${t2.subdomain}-${localPort}-${
|
|
70051
|
+
const proxyName = `clawd-${t2.subdomain}-${localPort}-${import_node_crypto20.default.randomBytes(3).toString("hex")}`;
|
|
70026
70052
|
const toml = buildFrpcToml({
|
|
70027
70053
|
serverAddr: t2.frpsHost,
|
|
70028
70054
|
serverPort: t2.frpsPort,
|
|
@@ -70123,7 +70149,7 @@ async function waitForFrpcReady(proc, timeoutMs) {
|
|
|
70123
70149
|
// src/tunnel/device-key.ts
|
|
70124
70150
|
var import_node_os22 = __toESM(require("os"), 1);
|
|
70125
70151
|
var import_node_path61 = __toESM(require("path"), 1);
|
|
70126
|
-
var
|
|
70152
|
+
var import_node_crypto21 = __toESM(require("crypto"), 1);
|
|
70127
70153
|
var DERIVE_SALT = "clawd-tunnel-device-v1";
|
|
70128
70154
|
function deriveStableDeviceKey(opts = {}) {
|
|
70129
70155
|
const hostname = opts.hostname ?? import_node_os22.default.hostname();
|
|
@@ -70133,13 +70159,13 @@ function deriveStableDeviceKey(opts = {}) {
|
|
|
70133
70159
|
const normalizedDataDir = opts.dataDir ? import_node_path61.default.resolve(opts.dataDir) : null;
|
|
70134
70160
|
const isDefaultDir = normalizedDataDir == null || normalizedDataDir === defaultDataDir;
|
|
70135
70161
|
const input = isDefaultDir ? `${hostname}::${uid}` : `${hostname}::${uid}::${normalizedDataDir}`;
|
|
70136
|
-
return
|
|
70162
|
+
return import_node_crypto21.default.createHmac("sha256", DERIVE_SALT).update(input).digest("hex").slice(0, 32);
|
|
70137
70163
|
}
|
|
70138
70164
|
|
|
70139
70165
|
// src/auth-store.ts
|
|
70140
70166
|
var import_node_fs56 = __toESM(require("fs"), 1);
|
|
70141
70167
|
var import_node_path62 = __toESM(require("path"), 1);
|
|
70142
|
-
var
|
|
70168
|
+
var import_node_crypto22 = __toESM(require("crypto"), 1);
|
|
70143
70169
|
var AUTH_FILE_NAME = "auth.json";
|
|
70144
70170
|
function authFilePath(dataDir) {
|
|
70145
70171
|
return import_node_path62.default.join(dataDir, AUTH_FILE_NAME);
|
|
@@ -70176,10 +70202,10 @@ function loadOrCreateTunnelDeviceKey(opts) {
|
|
|
70176
70202
|
return tunnelDeviceKey;
|
|
70177
70203
|
}
|
|
70178
70204
|
function defaultGenerateToken() {
|
|
70179
|
-
return
|
|
70205
|
+
return import_node_crypto22.default.randomBytes(32).toString("base64url");
|
|
70180
70206
|
}
|
|
70181
70207
|
function defaultGenerateOwnerPrincipalId() {
|
|
70182
|
-
return `owner-${
|
|
70208
|
+
return `owner-${import_node_crypto22.default.randomUUID()}`;
|
|
70183
70209
|
}
|
|
70184
70210
|
function readAuthFile(file) {
|
|
70185
70211
|
try {
|
|
@@ -70311,7 +70337,7 @@ var OwnerIdentityStore = class {
|
|
|
70311
70337
|
};
|
|
70312
70338
|
|
|
70313
70339
|
// src/feishu-auth/login-flow.ts
|
|
70314
|
-
var
|
|
70340
|
+
var import_node_crypto23 = __toESM(require("crypto"), 1);
|
|
70315
70341
|
var STATE_TTL_MS = 5 * 60 * 1e3;
|
|
70316
70342
|
var LoginFlow = class {
|
|
70317
70343
|
constructor(deps) {
|
|
@@ -70321,7 +70347,7 @@ var LoginFlow = class {
|
|
|
70321
70347
|
pendingStates = /* @__PURE__ */ new Map();
|
|
70322
70348
|
generation = 0;
|
|
70323
70349
|
start() {
|
|
70324
|
-
const state =
|
|
70350
|
+
const state = import_node_crypto23.default.randomBytes(16).toString("base64url");
|
|
70325
70351
|
const now = (this.deps.now ?? Date.now)();
|
|
70326
70352
|
this.pendingStates.set(state, { issuedAt: now, owner: this.deps.expectedUnionId?.() });
|
|
70327
70353
|
this.gcExpired(now);
|
|
@@ -70855,7 +70881,7 @@ init_protocol();
|
|
|
70855
70881
|
var import_node_fs59 = __toESM(require("fs"), 1);
|
|
70856
70882
|
var import_node_os24 = __toESM(require("os"), 1);
|
|
70857
70883
|
var import_node_path65 = __toESM(require("path"), 1);
|
|
70858
|
-
var
|
|
70884
|
+
var import_node_crypto24 = require("crypto");
|
|
70859
70885
|
init_claude_history();
|
|
70860
70886
|
function readJsonlEntries(file) {
|
|
70861
70887
|
const raw = import_node_fs59.default.readFileSync(file, "utf8");
|
|
@@ -70892,7 +70918,7 @@ function forkSession(input) {
|
|
|
70892
70918
|
throw new Error(`fork: messageUuid not found in transcript: ${input.messageUuid}`);
|
|
70893
70919
|
}
|
|
70894
70920
|
const sliced = mainEntries.slice(0, targetIdx + 1);
|
|
70895
|
-
const forkedToolSessionId = (0,
|
|
70921
|
+
const forkedToolSessionId = (0, import_node_crypto24.randomUUID)();
|
|
70896
70922
|
let parentUuid = null;
|
|
70897
70923
|
const forkedLines = [];
|
|
70898
70924
|
for (const entry of sliced) {
|
|
@@ -73651,7 +73677,7 @@ function computeMethodAccess(args) {
|
|
|
73651
73677
|
}
|
|
73652
73678
|
|
|
73653
73679
|
// src/version.ts
|
|
73654
|
-
var version = "0.2.
|
|
73680
|
+
var version = "0.2.633".length > 0 ? "0.2.633" : "dev";
|
|
73655
73681
|
|
|
73656
73682
|
// src/cli-probe/probe.ts
|
|
73657
73683
|
var fs84 = __toESM(require("fs"), 1);
|
|
@@ -74045,7 +74071,7 @@ init_protocol();
|
|
|
74045
74071
|
// src/extension/bundle-zip.ts
|
|
74046
74072
|
var import_promises12 = __toESM(require("fs/promises"), 1);
|
|
74047
74073
|
var import_node_path74 = __toESM(require("path"), 1);
|
|
74048
|
-
var
|
|
74074
|
+
var import_node_crypto25 = __toESM(require("crypto"), 1);
|
|
74049
74075
|
var import_jszip3 = __toESM(require_lib3(), 1);
|
|
74050
74076
|
async function bundleExtensionDir(dir) {
|
|
74051
74077
|
const entries = await listFilesSorted(dir);
|
|
@@ -74060,7 +74086,7 @@ async function bundleExtensionDir(dir) {
|
|
|
74060
74086
|
compression: "DEFLATE",
|
|
74061
74087
|
compressionOptions: { level: 6 }
|
|
74062
74088
|
});
|
|
74063
|
-
const sha256 =
|
|
74089
|
+
const sha256 = import_node_crypto25.default.createHash("sha256").update(buffer).digest("hex");
|
|
74064
74090
|
return { buffer, sha256 };
|
|
74065
74091
|
}
|
|
74066
74092
|
var FIXED_DATE = /* @__PURE__ */ new Date("2020-01-01T00:00:00.000Z");
|
|
@@ -74128,7 +74154,7 @@ function computePublishCheck(args) {
|
|
|
74128
74154
|
var import_promises13 = __toESM(require("fs/promises"), 1);
|
|
74129
74155
|
var import_node_path76 = __toESM(require("path"), 1);
|
|
74130
74156
|
var import_node_os28 = __toESM(require("os"), 1);
|
|
74131
|
-
var
|
|
74157
|
+
var import_node_crypto26 = __toESM(require("crypto"), 1);
|
|
74132
74158
|
var import_jszip4 = __toESM(require_lib3(), 1);
|
|
74133
74159
|
|
|
74134
74160
|
// src/extension/paths.ts
|
|
@@ -74157,7 +74183,7 @@ var InstallError = class extends Error {
|
|
|
74157
74183
|
};
|
|
74158
74184
|
async function installFromChannel(args, deps) {
|
|
74159
74185
|
const { channelRef, snapshotHash, bundleZip } = args;
|
|
74160
|
-
const computed =
|
|
74186
|
+
const computed = import_node_crypto26.default.createHash("sha256").update(bundleZip).digest("hex");
|
|
74161
74187
|
if (computed !== snapshotHash) {
|
|
74162
74188
|
throw new InstallError(
|
|
74163
74189
|
"HASH_MISMATCH",
|
|
@@ -74249,7 +74275,7 @@ async function installFromChannel(args, deps) {
|
|
|
74249
74275
|
var import_promises14 = __toESM(require("fs/promises"), 1);
|
|
74250
74276
|
var import_node_path77 = __toESM(require("path"), 1);
|
|
74251
74277
|
var import_node_os29 = __toESM(require("os"), 1);
|
|
74252
|
-
var
|
|
74278
|
+
var import_node_crypto27 = __toESM(require("crypto"), 1);
|
|
74253
74279
|
var import_jszip5 = __toESM(require_lib3(), 1);
|
|
74254
74280
|
var UpdateError = class extends Error {
|
|
74255
74281
|
constructor(code, message) {
|
|
@@ -74287,7 +74313,7 @@ async function updateFromChannel(args, deps) {
|
|
|
74287
74313
|
if (e instanceof UpdateError) throw e;
|
|
74288
74314
|
throw e;
|
|
74289
74315
|
}
|
|
74290
|
-
const computed =
|
|
74316
|
+
const computed = import_node_crypto27.default.createHash("sha256").update(bundleZip).digest("hex");
|
|
74291
74317
|
if (computed !== snapshotHash) {
|
|
74292
74318
|
throw new UpdateError(
|
|
74293
74319
|
"HASH_MISMATCH",
|
|
@@ -75415,7 +75441,7 @@ async function uninstall(deps) {
|
|
|
75415
75441
|
}
|
|
75416
75442
|
|
|
75417
75443
|
// src/handlers/index.ts
|
|
75418
|
-
var
|
|
75444
|
+
var import_node_crypto28 = require("crypto");
|
|
75419
75445
|
|
|
75420
75446
|
// src/handlers/peer-exec.ts
|
|
75421
75447
|
init_protocol();
|
|
@@ -75572,7 +75598,7 @@ function buildMethodHandlers(deps) {
|
|
|
75572
75598
|
const c2 = deps.contactStore.get(deviceId);
|
|
75573
75599
|
return c2 ? { deviceId: c2.deviceId, remoteUrl: c2.remoteUrl, connectToken: c2.connectToken } : null;
|
|
75574
75600
|
},
|
|
75575
|
-
genId: () => (0,
|
|
75601
|
+
genId: () => (0, import_node_crypto28.randomUUID)(),
|
|
75576
75602
|
now: () => Date.now(),
|
|
75577
75603
|
forwardInboxPostToPeer,
|
|
75578
75604
|
logger: deps.logger
|
|
@@ -76292,7 +76318,7 @@ async function startDaemon(config) {
|
|
|
76292
76318
|
const channelStore = createChannelStore({
|
|
76293
76319
|
filePath: import_node_path85.default.join(config.dataDir, "channels.json"),
|
|
76294
76320
|
now: () => Date.now(),
|
|
76295
|
-
genId: () => `ch-${(0,
|
|
76321
|
+
genId: () => `ch-${(0, import_node_crypto29.randomUUID)().slice(0, 8)}`,
|
|
76296
76322
|
onFlushError: (err) => logger.error("channel store flush failed", {
|
|
76297
76323
|
reason: err instanceof Error ? err.message : String(err)
|
|
76298
76324
|
})
|
|
@@ -76301,7 +76327,7 @@ async function startDaemon(config) {
|
|
|
76301
76327
|
const topicStore = createTopicStore({
|
|
76302
76328
|
filePath: import_node_path85.default.join(config.dataDir, "topics.json"),
|
|
76303
76329
|
now: () => Date.now(),
|
|
76304
|
-
genId: () => `tp-${(0,
|
|
76330
|
+
genId: () => `tp-${(0, import_node_crypto29.randomUUID)().slice(0, 8)}`,
|
|
76305
76331
|
onFlushError: (err) => logger.error("topic store flush failed", {
|
|
76306
76332
|
reason: err instanceof Error ? err.message : String(err)
|
|
76307
76333
|
})
|
|
@@ -76309,7 +76335,7 @@ async function startDaemon(config) {
|
|
|
76309
76335
|
await topicStore.load();
|
|
76310
76336
|
let deliverPendingRef;
|
|
76311
76337
|
const personaDispatchManager = new PersonaDispatchManager({
|
|
76312
|
-
genId: () => (0,
|
|
76338
|
+
genId: () => (0, import_node_crypto29.randomUUID)(),
|
|
76313
76339
|
store: dispatchStore,
|
|
76314
76340
|
now: () => Date.now(),
|
|
76315
76341
|
onCompleted: (sid) => deliverPendingRef?.(sid),
|