@abelxiaoxing/cadence 2.1.0 → 2.1.2
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/README.de.md +72 -76
- package/README.es.md +71 -75
- package/README.fr.md +72 -76
- package/README.ja.md +83 -101
- package/README.ko.md +81 -97
- package/README.md +71 -86
- package/README.pt-BR.md +72 -76
- package/README.ru.md +72 -77
- package/README.zh-CN.md +74 -84
- package/docs/reuse-and-distribution.md +1 -0
- package/package.json +5 -2
- package/src/native-build.ts +1 -1
- package/src/service/contracts/workbench.ts +82 -0
- package/src/service/knowledge-store.ts +496 -0
- package/src/service/project-knowledge.ts +539 -0
- package/src/service/workflow-git.ts +773 -0
- package/src/service-host.mjs +172 -83
- package/web/dist/assets/cadence.css +1 -1
- package/web/dist/assets/cadence.js +28 -28
- package/web/dist/manifest.json +7 -7
package/src/service-host.mjs
CHANGED
|
@@ -6090,6 +6090,8 @@ function decodeEntryId(v) {
|
|
|
6090
6090
|
throw new ContractError("invalid");
|
|
6091
6091
|
return s;
|
|
6092
6092
|
}
|
|
6093
|
+
var FILE_PART_BYTES = 192 * 1024;
|
|
6094
|
+
var FILE_DOWNLOAD_BYTES = 64 * 1024 * 1024;
|
|
6093
6095
|
var CONVERSATION_SEND_BYTES = 16 * 1024;
|
|
6094
6096
|
var CONVERSATION_NAME_CHARS = 100;
|
|
6095
6097
|
var RUN_INPUTS = 32;
|
|
@@ -6283,6 +6285,24 @@ function decodeWorkbenchRead(v) {
|
|
|
6283
6285
|
known: nullable(o.known, decodeEntryId)
|
|
6284
6286
|
};
|
|
6285
6287
|
}
|
|
6288
|
+
case "file-part": {
|
|
6289
|
+
const scoped = Object.hasOwn(v ?? {}, "location");
|
|
6290
|
+
const o = closed(v, [
|
|
6291
|
+
"kind",
|
|
6292
|
+
"path",
|
|
6293
|
+
"offset",
|
|
6294
|
+
...scoped ? ["location"] : []
|
|
6295
|
+
]);
|
|
6296
|
+
const offset = integer(o.offset, 0);
|
|
6297
|
+
if (offset % FILE_PART_BYTES || offset >= FILE_DOWNLOAD_BYTES)
|
|
6298
|
+
throw new ContractError("invalid");
|
|
6299
|
+
return {
|
|
6300
|
+
kind,
|
|
6301
|
+
path: text(o.path, 4096),
|
|
6302
|
+
offset,
|
|
6303
|
+
...scoped ? { location: decodeConversationLocation(o.location) } : {}
|
|
6304
|
+
};
|
|
6305
|
+
}
|
|
6286
6306
|
default: {
|
|
6287
6307
|
const scoped = (kind === "file" || kind === "files") && Object.hasOwn(v ?? {}, "location");
|
|
6288
6308
|
const o = closed(v, ["kind", "path", ...scoped ? ["location"] : []]);
|
|
@@ -6698,6 +6718,14 @@ function decodeChatContext(v) {
|
|
|
6698
6718
|
model: text(o.model, 256)
|
|
6699
6719
|
};
|
|
6700
6720
|
}
|
|
6721
|
+
function decodeChatCache(v) {
|
|
6722
|
+
const o = closed(v, ["input", "read", "write"]);
|
|
6723
|
+
return {
|
|
6724
|
+
input: integer(o.input, 0),
|
|
6725
|
+
read: integer(o.read, 0),
|
|
6726
|
+
write: integer(o.write, 0)
|
|
6727
|
+
};
|
|
6728
|
+
}
|
|
6701
6729
|
function decodeChatTreeNode(v) {
|
|
6702
6730
|
const o = closed(v, ["id", "parent", "text", "at", "leaf", "current"]);
|
|
6703
6731
|
return {
|
|
@@ -6847,6 +6875,7 @@ function decodeWorkbenchResult(v) {
|
|
|
6847
6875
|
"attempt",
|
|
6848
6876
|
...Object.hasOwn(v ?? {}, "commands") ? ["commands"] : [],
|
|
6849
6877
|
...Object.hasOwn(v ?? {}, "context") ? ["context"] : [],
|
|
6878
|
+
...Object.hasOwn(v ?? {}, "cache") ? ["cache"] : [],
|
|
6850
6879
|
...Object.hasOwn(v ?? {}, "pending") ? ["pending"] : [],
|
|
6851
6880
|
...Object.hasOwn(v ?? {}, "undelivered") ? ["undelivered"] : []
|
|
6852
6881
|
]);
|
|
@@ -6857,6 +6886,7 @@ function decodeWorkbenchResult(v) {
|
|
|
6857
6886
|
kind,
|
|
6858
6887
|
...o2.commands === undefined ? {} : { commands: list(o2.commands, 64, decodeId) },
|
|
6859
6888
|
...o2.context === undefined ? {} : { context: decodeChatContext(o2.context) },
|
|
6889
|
+
...o2.cache === undefined ? {} : { cache: decodeChatCache(o2.cache) },
|
|
6860
6890
|
...o2.pending === undefined ? {} : { pending: list(o2.pending, WAITING_INPUTS, decodeChatPending) },
|
|
6861
6891
|
...o2.undelivered === undefined ? {} : {
|
|
6862
6892
|
undelivered: list(o2.undelivered, WAITING_INPUTS, decodeChatAttempt)
|
|
@@ -6948,6 +6978,13 @@ function decodeWorkbenchResult(v) {
|
|
|
6948
6978
|
limited: bool(o2.limited)
|
|
6949
6979
|
};
|
|
6950
6980
|
}
|
|
6981
|
+
if (kind === "file-part") {
|
|
6982
|
+
const o2 = closed(v, ["kind", "path", "size", "version", "data", "next"]);
|
|
6983
|
+
const size = integer(o2.size, 0), data = text(o2.data, FILE_PART_BYTES / 3 * 4), next = nullable(o2.next, (n) => integer(n, 1)), version = text(o2.version, 32, true);
|
|
6984
|
+
if (size > FILE_DOWNLOAD_BYTES || !/^[a-f0-9]{32}$/.test(version) || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(data) || next !== null && (next % FILE_PART_BYTES !== 0 || next >= size))
|
|
6985
|
+
throw new ContractError("invalid");
|
|
6986
|
+
return { kind, path: text(o2.path, 4096), size, version, data, next };
|
|
6987
|
+
}
|
|
6951
6988
|
if (kind === "projects") {
|
|
6952
6989
|
const o2 = closed(v, ["kind", "entries"]);
|
|
6953
6990
|
return {
|
|
@@ -8992,6 +9029,13 @@ function reportedUsage(entry) {
|
|
|
8992
9029
|
model: typeof model === "string" ? model : ""
|
|
8993
9030
|
};
|
|
8994
9031
|
}
|
|
9032
|
+
function recordedUsage(entry) {
|
|
9033
|
+
if (["usage", "compaction", "branch_summary"].includes(entry.type))
|
|
9034
|
+
return own2(entry.raw, "usage");
|
|
9035
|
+
const m = message(entry);
|
|
9036
|
+
const from = m && own2(m, "role");
|
|
9037
|
+
return m && (from === "assistant" || from === "toolResult") ? own2(m, "usage") : undefined;
|
|
9038
|
+
}
|
|
8995
9039
|
function emptySummary() {
|
|
8996
9040
|
return {
|
|
8997
9041
|
id: "",
|
|
@@ -9055,6 +9099,7 @@ class ParsedSession {
|
|
|
9055
9099
|
bodies = new Map;
|
|
9056
9100
|
bodyBytes = 0;
|
|
9057
9101
|
usages = new Map;
|
|
9102
|
+
cache = { input: 0, read: 0, write: 0 };
|
|
9058
9103
|
boundaries = new Map;
|
|
9059
9104
|
constructor(path) {
|
|
9060
9105
|
this.path = path;
|
|
@@ -9098,6 +9143,19 @@ class ParsedSession {
|
|
|
9098
9143
|
}
|
|
9099
9144
|
return value;
|
|
9100
9145
|
}
|
|
9146
|
+
count(entry) {
|
|
9147
|
+
const usage = recordedUsage(entry);
|
|
9148
|
+
if (!usage || typeof usage !== "object" || Array.isArray(usage))
|
|
9149
|
+
return;
|
|
9150
|
+
const add = (key, name) => {
|
|
9151
|
+
const value = own2(usage, name);
|
|
9152
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0)
|
|
9153
|
+
this.cache[key] = Math.min(this.cache[key] + Math.ceil(value), Number.MAX_SAFE_INTEGER);
|
|
9154
|
+
};
|
|
9155
|
+
add("input", "input");
|
|
9156
|
+
add("read", "cacheRead");
|
|
9157
|
+
add("write", "cacheWrite");
|
|
9158
|
+
}
|
|
9101
9159
|
refresh() {
|
|
9102
9160
|
const ino = lstatSync7(this.path).ino;
|
|
9103
9161
|
const next = readLines(this.path, this.read, (text2, pos) => {
|
|
@@ -9128,6 +9186,7 @@ class ParsedSession {
|
|
|
9128
9186
|
this.boundaries.set(commandId, [boundary]);
|
|
9129
9187
|
}
|
|
9130
9188
|
}
|
|
9189
|
+
this.count(entry);
|
|
9131
9190
|
const bytes = Buffer.byteLength(text2);
|
|
9132
9191
|
Object.defineProperty(entry, "raw", {
|
|
9133
9192
|
enumerable: true,
|
|
@@ -9149,6 +9208,7 @@ class ParsedSession {
|
|
|
9149
9208
|
this.bodies.clear();
|
|
9150
9209
|
this.bodyBytes = 0;
|
|
9151
9210
|
this.usages.clear();
|
|
9211
|
+
this.cache.input = this.cache.read = this.cache.write = 0;
|
|
9152
9212
|
this.boundaries.clear();
|
|
9153
9213
|
this.header = null;
|
|
9154
9214
|
});
|
|
@@ -14758,12 +14818,14 @@ class ConversationRecords {
|
|
|
14758
14818
|
const summary = this.summary(id, running);
|
|
14759
14819
|
const listed = this.sessions.find(id);
|
|
14760
14820
|
const context = this.context(view);
|
|
14821
|
+
const cache = view.session?.cache;
|
|
14761
14822
|
const pending = running ? this.pending(running, view.session) : [];
|
|
14762
14823
|
const undelivered = running ? [] : this.undelivered(id, view);
|
|
14763
14824
|
return {
|
|
14764
14825
|
kind: "conversation",
|
|
14765
14826
|
commands: this.index(id).commands,
|
|
14766
14827
|
...context ? { context } : {},
|
|
14828
|
+
...cache && cache.input + cache.read + cache.write > 0 ? { cache: { ...cache } } : {},
|
|
14767
14829
|
...pending.length ? { pending } : {},
|
|
14768
14830
|
...undelivered.length ? { undelivered } : {},
|
|
14769
14831
|
summary,
|
|
@@ -15263,6 +15325,7 @@ class ConversationControls {
|
|
|
15263
15325
|
}
|
|
15264
15326
|
|
|
15265
15327
|
// src/service/workbench-files.ts
|
|
15328
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
15266
15329
|
import {
|
|
15267
15330
|
closeSync as closeSync7,
|
|
15268
15331
|
constants as constants7,
|
|
@@ -15374,7 +15437,7 @@ class WorkbenchFiles {
|
|
|
15374
15437
|
limited
|
|
15375
15438
|
};
|
|
15376
15439
|
}
|
|
15377
|
-
|
|
15440
|
+
bytes(path, offset, limit, maximum = Number.POSITIVE_INFINITY) {
|
|
15378
15441
|
const selected2 = this.selected(path), before = lstatSync16(selected2);
|
|
15379
15442
|
if (!before.isFile())
|
|
15380
15443
|
throw new ContractError("forbidden");
|
|
@@ -15383,30 +15446,53 @@ class WorkbenchFiles {
|
|
|
15383
15446
|
const opened = fstatSync6(fd);
|
|
15384
15447
|
if (!opened.isFile() || opened.nlink !== 1 || before.dev !== opened.dev || before.ino !== opened.ino)
|
|
15385
15448
|
throw new ContractError("stale");
|
|
15386
|
-
|
|
15449
|
+
if (opened.size > maximum)
|
|
15450
|
+
throw new ContractError("oversize");
|
|
15451
|
+
if (offset > opened.size || offset > 0 && offset === opened.size)
|
|
15452
|
+
throw new ContractError("stale");
|
|
15453
|
+
const buffer = Buffer.alloc(Math.min(opened.size - offset, limit));
|
|
15387
15454
|
let at = 0;
|
|
15388
15455
|
while (at < buffer.length) {
|
|
15389
|
-
const n = readSync5(fd, buffer, at, buffer.length - at, at);
|
|
15456
|
+
const n = readSync5(fd, buffer, at, buffer.length - at, offset + at);
|
|
15390
15457
|
if (!n)
|
|
15391
15458
|
break;
|
|
15392
15459
|
at += n;
|
|
15393
15460
|
}
|
|
15394
15461
|
const after = fstatSync6(fd), current = lstatSync16(selected2);
|
|
15395
|
-
if (after.size !== opened.size || after.mtimeMs !== opened.mtimeMs || after.nlink !== 1 || current.isSymbolicLink() || current.nlink !== 1 || current.ino !== opened.ino || current.dev !== opened.dev)
|
|
15462
|
+
if (at !== buffer.length || after.size !== opened.size || after.mtimeMs !== opened.mtimeMs || after.nlink !== 1 || current.isSymbolicLink() || current.nlink !== 1 || current.ino !== opened.ino || current.dev !== opened.dev)
|
|
15396
15463
|
throw new ContractError("stale");
|
|
15397
|
-
|
|
15398
|
-
if (decoded2.includes("\x00"))
|
|
15399
|
-
throw new ContractError("unsupported-context");
|
|
15400
|
-
return {
|
|
15401
|
-
kind: "file",
|
|
15402
|
-
path,
|
|
15403
|
-
text: new TextSanitizer(this.secrets()).write(decoded2, at === opened.size),
|
|
15404
|
-
limited: at < opened.size
|
|
15405
|
-
};
|
|
15464
|
+
return { buffer, stat: opened };
|
|
15406
15465
|
} finally {
|
|
15407
15466
|
closeSync7(fd);
|
|
15408
15467
|
}
|
|
15409
15468
|
}
|
|
15469
|
+
read(path) {
|
|
15470
|
+
const { buffer, stat } = this.bytes(path, 0, 128 * 1024);
|
|
15471
|
+
const whole2 = buffer.length === stat.size;
|
|
15472
|
+
const decoded2 = new TextDecoder("utf-8", { fatal: true }).decode(buffer, {
|
|
15473
|
+
stream: !whole2
|
|
15474
|
+
});
|
|
15475
|
+
if (decoded2.includes("\x00"))
|
|
15476
|
+
throw new ContractError("unsupported-context");
|
|
15477
|
+
return {
|
|
15478
|
+
kind: "file",
|
|
15479
|
+
path,
|
|
15480
|
+
text: new TextSanitizer(this.secrets()).write(decoded2, whole2),
|
|
15481
|
+
limited: !whole2
|
|
15482
|
+
};
|
|
15483
|
+
}
|
|
15484
|
+
part(path, offset) {
|
|
15485
|
+
const { buffer, stat } = this.bytes(path, offset, FILE_PART_BYTES, FILE_DOWNLOAD_BYTES);
|
|
15486
|
+
const end = offset + buffer.length;
|
|
15487
|
+
return {
|
|
15488
|
+
kind: "file-part",
|
|
15489
|
+
path,
|
|
15490
|
+
size: stat.size,
|
|
15491
|
+
version: createHash11("sha256").update(`${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeMs}`).digest("hex").slice(0, 32),
|
|
15492
|
+
data: buffer.toString("base64"),
|
|
15493
|
+
next: end < stat.size ? end : null
|
|
15494
|
+
};
|
|
15495
|
+
}
|
|
15410
15496
|
}
|
|
15411
15497
|
|
|
15412
15498
|
// src/service/gateway-conversations.ts
|
|
@@ -15422,7 +15508,8 @@ function retainedRead(request2) {
|
|
|
15422
15508
|
"conversation-context",
|
|
15423
15509
|
"conversation-tree",
|
|
15424
15510
|
"files",
|
|
15425
|
-
"file"
|
|
15511
|
+
"file",
|
|
15512
|
+
"file-part"
|
|
15426
15513
|
].includes(request2.kind);
|
|
15427
15514
|
}
|
|
15428
15515
|
function unpreparedDirectory(c, project) {
|
|
@@ -15559,12 +15646,13 @@ class GatewayConversations {
|
|
|
15559
15646
|
result = { kind: request2.kind, state: view.controls.state(request2.id) };
|
|
15560
15647
|
break;
|
|
15561
15648
|
case "files":
|
|
15562
|
-
case "file":
|
|
15649
|
+
case "file":
|
|
15650
|
+
case "file-part": {
|
|
15563
15651
|
const secrets = records.readSecrets();
|
|
15564
15652
|
const cwd = request2.location ? new ConversationContextRecords(c, records.sessions).read(request2.location).context.cwd : project.cwd;
|
|
15565
15653
|
assertConversationDirectory(c.store.root, cwd, secrets);
|
|
15566
15654
|
const files = new WorkbenchFiles(cwd, [c.files.namespace, agentDir], () => records.readSecrets());
|
|
15567
|
-
result = request2.kind === "files" ? files.list(request2.path) : files.read(request2.path);
|
|
15655
|
+
result = request2.kind === "files" ? files.list(request2.path) : request2.kind === "file" ? files.read(request2.path) : files.part(request2.path, request2.offset);
|
|
15568
15656
|
break;
|
|
15569
15657
|
}
|
|
15570
15658
|
default:
|
|
@@ -15610,7 +15698,7 @@ async function readGatewayModels(project, input, secrets, read) {
|
|
|
15610
15698
|
}
|
|
15611
15699
|
|
|
15612
15700
|
// src/service/http.ts
|
|
15613
|
-
import { createHash as
|
|
15701
|
+
import { createHash as createHash12, randomUUID as randomUUID13 } from "node:crypto";
|
|
15614
15702
|
import {
|
|
15615
15703
|
createServer
|
|
15616
15704
|
} from "node:http";
|
|
@@ -15699,7 +15787,7 @@ class ServiceHttpServer {
|
|
|
15699
15787
|
this.assets.set(asset.path, {
|
|
15700
15788
|
...asset,
|
|
15701
15789
|
bytes: Uint8Array.from(asset.bytes),
|
|
15702
|
-
etag: `"${
|
|
15790
|
+
etag: `"${createHash12("sha256").update(asset.bytes).digest("hex")}"`
|
|
15703
15791
|
});
|
|
15704
15792
|
}
|
|
15705
15793
|
this.server = createServer({
|
|
@@ -16257,7 +16345,7 @@ Content-Length: 0\r
|
|
|
16257
16345
|
res.setHeader("Content-Type", operation === "download" && request2.format === "markdown" ? "text/markdown; charset=utf-8" : "application/x-ndjson; charset=utf-8");
|
|
16258
16346
|
res.setHeader("Content-Disposition", `attachment; filename="cadence-export.${operation === "download" && request2.format === "markdown" ? "md" : "ndjson"}"`);
|
|
16259
16347
|
let trailer;
|
|
16260
|
-
const digest =
|
|
16348
|
+
const digest = createHash12("sha256");
|
|
16261
16349
|
const write2 = async (frame) => {
|
|
16262
16350
|
const data2 = Buffer.from(operation === "download" ? encodeExportFrame(frame, request2.format) : `${canonicalJson(frame)}
|
|
16263
16351
|
`);
|
|
@@ -16495,7 +16583,7 @@ Content-Length: 0\r
|
|
|
16495
16583
|
|
|
16496
16584
|
// src/service/model-preview-process.ts
|
|
16497
16585
|
import { spawn as spawn4 } from "node:child_process";
|
|
16498
|
-
import { createHash as
|
|
16586
|
+
import { createHash as createHash13 } from "node:crypto";
|
|
16499
16587
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
16500
16588
|
|
|
16501
16589
|
// src/service/model-preview-protocol.ts
|
|
@@ -16545,7 +16633,7 @@ class ModelPreviewProcesses {
|
|
|
16545
16633
|
});
|
|
16546
16634
|
const body = canonicalJson(input, PREVIEW_INPUT_BYTES);
|
|
16547
16635
|
const env = captureEnvironment(hostEnvironment(environment2));
|
|
16548
|
-
const key =
|
|
16636
|
+
const key = createHash13("sha256").update(body).update(JSON.stringify(env)).digest("hex");
|
|
16549
16637
|
const previous = this.jobs.get(key);
|
|
16550
16638
|
if (previous)
|
|
16551
16639
|
return previous.result;
|
|
@@ -16695,7 +16783,7 @@ async function createGateway(value, hostUrl, source) {
|
|
|
16695
16783
|
const input = decodeGatewayInput(value), store = new GatewayStore(input.serverConfig, input.stateHome);
|
|
16696
16784
|
const web = loadWebAssets(source?.webDirectory);
|
|
16697
16785
|
const build2 = {
|
|
16698
|
-
contractHash: "
|
|
16786
|
+
contractHash: "46e67668411af8fc9cdc99bb5dcee56ea093a33d18fce3545d5c9bbb5847948b",
|
|
16699
16787
|
assets: {
|
|
16700
16788
|
sourceHash: web.manifest.sourceHash,
|
|
16701
16789
|
contractHash: web.manifest.contractHash,
|
|
@@ -17584,7 +17672,7 @@ import { join as join44 } from "node:path";
|
|
|
17584
17672
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
17585
17673
|
|
|
17586
17674
|
// src/agent-registry.ts
|
|
17587
|
-
import { createHash as
|
|
17675
|
+
import { createHash as createHash14 } from "node:crypto";
|
|
17588
17676
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
17589
17677
|
var AGENT_FILES = [
|
|
17590
17678
|
"design-explorer.md",
|
|
@@ -17601,7 +17689,7 @@ function loadAgentDefinitions() {
|
|
|
17601
17689
|
role: fileName.replace(/\.md$/, ""),
|
|
17602
17690
|
fileName,
|
|
17603
17691
|
path,
|
|
17604
|
-
sha256:
|
|
17692
|
+
sha256: createHash14("sha256").update(data2).digest("hex"),
|
|
17605
17693
|
bytes: data2.length,
|
|
17606
17694
|
content: data2.toString("utf8")
|
|
17607
17695
|
};
|
|
@@ -17856,7 +17944,7 @@ class HistoryLive {
|
|
|
17856
17944
|
}
|
|
17857
17945
|
|
|
17858
17946
|
// src/history/navigation.ts
|
|
17859
|
-
import { createHash as
|
|
17947
|
+
import { createHash as createHash15 } from "node:crypto";
|
|
17860
17948
|
import { lstatSync as lstatSync18 } from "node:fs";
|
|
17861
17949
|
import { dirname as dirname18, join as join29 } from "node:path";
|
|
17862
17950
|
|
|
@@ -19083,7 +19171,7 @@ class HistoryNavigation {
|
|
|
19083
19171
|
continue;
|
|
19084
19172
|
}
|
|
19085
19173
|
let pending = Buffer.alloc(0), at = offset, bodyBytes = 0;
|
|
19086
|
-
const checksum =
|
|
19174
|
+
const checksum = createHash15("sha256"), rows = [];
|
|
19087
19175
|
while (at < size2) {
|
|
19088
19176
|
const chunk = this.block(path, at, size2, budget);
|
|
19089
19177
|
at += chunk.length;
|
|
@@ -19586,7 +19674,7 @@ function navigationKeys(row) {
|
|
|
19586
19674
|
}
|
|
19587
19675
|
|
|
19588
19676
|
// src/history/projection.ts
|
|
19589
|
-
import { createHash as
|
|
19677
|
+
import { createHash as createHash21 } from "node:crypto";
|
|
19590
19678
|
|
|
19591
19679
|
// src/history/task-folds.ts
|
|
19592
19680
|
var TASKS = 1024;
|
|
@@ -19929,17 +20017,17 @@ function materializeEntity(s, sources) {
|
|
|
19929
20017
|
}
|
|
19930
20018
|
|
|
19931
20019
|
// src/history/export.ts
|
|
19932
|
-
import { createHash as
|
|
20020
|
+
import { createHash as createHash19, randomUUID as randomUUID15 } from "node:crypto";
|
|
19933
20021
|
import { readFileSync as readFileSync5 } from "node:fs";
|
|
19934
20022
|
|
|
19935
20023
|
// src/history/search.ts
|
|
19936
|
-
import { createHash as
|
|
20024
|
+
import { createHash as createHash18 } from "node:crypto";
|
|
19937
20025
|
|
|
19938
20026
|
// src/history/read-proof.ts
|
|
19939
20027
|
import {
|
|
19940
20028
|
createCipheriv,
|
|
19941
20029
|
createDecipheriv,
|
|
19942
|
-
createHash as
|
|
20030
|
+
createHash as createHash16,
|
|
19943
20031
|
randomBytes as randomBytes5
|
|
19944
20032
|
} from "node:crypto";
|
|
19945
20033
|
var PREFIX = "rp1.";
|
|
@@ -19991,7 +20079,7 @@ class HistoryReadProof {
|
|
|
19991
20079
|
root: this.files.format.rootIdentity,
|
|
19992
20080
|
format: material.formatStamp,
|
|
19993
20081
|
key: material.keyStamp,
|
|
19994
|
-
request:
|
|
20082
|
+
request: createHash16("sha256").update(canonicalJson(readIdentity(request3))).digest("hex")
|
|
19995
20083
|
}));
|
|
19996
20084
|
}
|
|
19997
20085
|
seal(context, plaintext, budget) {
|
|
@@ -20763,11 +20851,11 @@ function decodeRetainedProgress(value) {
|
|
|
20763
20851
|
}
|
|
20764
20852
|
|
|
20765
20853
|
// src/history/retained-traversal.ts
|
|
20766
|
-
import { createHash as
|
|
20854
|
+
import { createHash as createHash17 } from "node:crypto";
|
|
20767
20855
|
function bad5() {
|
|
20768
20856
|
throw new ContractError("corrupt-selected");
|
|
20769
20857
|
}
|
|
20770
|
-
var fingerprint = (v) =>
|
|
20858
|
+
var fingerprint = (v) => createHash17("sha256").update(canonicalJson(v)).digest("hex");
|
|
20771
20859
|
var ready = (v) => {
|
|
20772
20860
|
const s = v.state;
|
|
20773
20861
|
if (s.phase !== "ready")
|
|
@@ -21123,11 +21211,11 @@ var digits = (id) => {
|
|
|
21123
21211
|
return s.slice(0, 12) + s.slice(13, 16) + s.slice(17);
|
|
21124
21212
|
};
|
|
21125
21213
|
var publicTextRef = (id, label, text2, field, batch, row, slot) => ({
|
|
21126
|
-
recordId: uuid(address(batch.pointer).toString(16).padStart(14, "0") +
|
|
21214
|
+
recordId: uuid(address(batch.pointer).toString(16).padStart(14, "0") + createHash18("sha256").update(`${id}/${label}`).digest("hex").slice(0, 16)),
|
|
21127
21215
|
version: batch.rows.indexOf(row) * EVENT_SLOTS + slot + 1,
|
|
21128
21216
|
field,
|
|
21129
21217
|
bytes: Buffer.byteLength(text2),
|
|
21130
|
-
sha256:
|
|
21218
|
+
sha256: createHash18("sha256").update(text2).digest("hex")
|
|
21131
21219
|
});
|
|
21132
21220
|
var initial = () => ({
|
|
21133
21221
|
pos: { segment: 1, offset: 0 },
|
|
@@ -21143,7 +21231,7 @@ function scanCursor(base, p) {
|
|
|
21143
21231
|
const snapshot = p.snapshot.toString(16).padStart(14, "0");
|
|
21144
21232
|
if (snapshot.length !== 14)
|
|
21145
21233
|
throw new ContractError("capacity");
|
|
21146
|
-
const binding =
|
|
21234
|
+
const binding = createHash18("sha256").update(canonicalJson({
|
|
21147
21235
|
...readIdentity(base),
|
|
21148
21236
|
recordId: null,
|
|
21149
21237
|
recordVersion: version,
|
|
@@ -21484,7 +21572,7 @@ class RetainedScan {
|
|
|
21484
21572
|
graph: {
|
|
21485
21573
|
recordId: v.intent.operationId,
|
|
21486
21574
|
revision: graph.revision,
|
|
21487
|
-
sha256:
|
|
21575
|
+
sha256: createHash18("sha256").update(canonicalJson(graph)).digest("hex")
|
|
21488
21576
|
}
|
|
21489
21577
|
},
|
|
21490
21578
|
graph
|
|
@@ -21783,7 +21871,7 @@ async function searchQuantum(reader, value, limit = LIMITS.pageEntries) {
|
|
|
21783
21871
|
// src/history/export.ts
|
|
21784
21872
|
var exporterIdentity;
|
|
21785
21873
|
function buildIdentity() {
|
|
21786
|
-
exporterIdentity ??=
|
|
21874
|
+
exporterIdentity ??= createHash19("sha256").update(readFileSync5(new URL(import.meta.url))).digest("hex");
|
|
21787
21875
|
return exporterIdentity;
|
|
21788
21876
|
}
|
|
21789
21877
|
function aborted(signal) {
|
|
@@ -21843,7 +21931,7 @@ Coverage: ${canonicalJson(event.coverage)}
|
|
|
21843
21931
|
}
|
|
21844
21932
|
}
|
|
21845
21933
|
async function* exportHistory(projection, input, signal) {
|
|
21846
|
-
const request3 = decodeExportRequest(input), exportId = randomUUID15(), digest =
|
|
21934
|
+
const request3 = decodeExportRequest(input), exportId = randomUUID15(), digest = createHash19("sha256");
|
|
21847
21935
|
let ordinal = 0, encodedBytes = 0, coverage = { ...COMPLETE, omissions: [] };
|
|
21848
21936
|
const frame = (event) => {
|
|
21849
21937
|
aborted(signal);
|
|
@@ -21912,7 +22000,7 @@ async function* exportHistory(projection, input, signal) {
|
|
|
21912
22000
|
const { detail, owner } = item, original = open2.get(detail.content.recordId);
|
|
21913
22001
|
if (detail.content.bytes ? !original || original.bytes !== detail.content.bytes || original.content !== canonicalJson(detail.content) : original !== undefined)
|
|
21914
22002
|
throw new ContractError("corrupt-selected");
|
|
21915
|
-
if ((original?.hash ??
|
|
22003
|
+
if ((original?.hash ?? createHash19("sha256")).digest("hex") !== detail.content.sha256)
|
|
21916
22004
|
throw new ContractError("corrupt-selected");
|
|
21917
22005
|
open2.delete(detail.content.recordId);
|
|
21918
22006
|
const events = [];
|
|
@@ -21943,7 +22031,7 @@ async function* exportHistory(projection, input, signal) {
|
|
|
21943
22031
|
coverage = combineCoverage(coverage, item.coverage);
|
|
21944
22032
|
const length = Buffer.byteLength(item.text);
|
|
21945
22033
|
if (item.inline) {
|
|
21946
|
-
if (item.start !== 0 || length !== item.content.bytes ||
|
|
22034
|
+
if (item.start !== 0 || length !== item.content.bytes || createHash19("sha256").update(item.text).digest("hex") !== item.content.sha256)
|
|
21947
22035
|
throw new ContractError("corrupt-selected");
|
|
21948
22036
|
} else {
|
|
21949
22037
|
let original = open2.get(item.content.recordId);
|
|
@@ -21953,7 +22041,7 @@ async function* exportHistory(projection, input, signal) {
|
|
|
21953
22041
|
original = {
|
|
21954
22042
|
bytes: 0,
|
|
21955
22043
|
content: canonicalJson(item.content),
|
|
21956
|
-
hash:
|
|
22044
|
+
hash: createHash19("sha256")
|
|
21957
22045
|
};
|
|
21958
22046
|
open2.set(item.content.recordId, original);
|
|
21959
22047
|
}
|
|
@@ -22068,7 +22156,7 @@ async function* exportHistory(projection, input, signal) {
|
|
|
22068
22156
|
}
|
|
22069
22157
|
|
|
22070
22158
|
// src/history/list-progress.ts
|
|
22071
|
-
import { createHash as
|
|
22159
|
+
import { createHash as createHash20 } from "node:crypto";
|
|
22072
22160
|
|
|
22073
22161
|
// src/history/detail-progress.ts
|
|
22074
22162
|
function bad7() {
|
|
@@ -22542,7 +22630,7 @@ function fits(link, scope) {
|
|
|
22542
22630
|
return scope.kind === "workspace" || (scope.kind === "task" ? link.taskId === scope.id : scope.kind === "run" ? link.runId === scope.id : link.childRunId === scope.id);
|
|
22543
22631
|
}
|
|
22544
22632
|
function nextAfter(request3, n) {
|
|
22545
|
-
const h =
|
|
22633
|
+
const h = createHash20("sha256").update(canonicalJson({ ...readIdentity(request3), after: null, ordinal: n })).digest("hex");
|
|
22546
22634
|
return {
|
|
22547
22635
|
recordId: `${h.slice(0, 8)}-${h.slice(8, 12)}-4${h.slice(13, 16)}-8${h.slice(17, 20)}-${h.slice(20, 32)}`,
|
|
22548
22636
|
version: 1,
|
|
@@ -22926,7 +23014,7 @@ async function read(p, request3, entity) {
|
|
|
22926
23014
|
const tasks = [...p.environment.legacyTasks(budget)].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
|
|
22927
23015
|
if (tasks.length > 1000)
|
|
22928
23016
|
throw new ContractError("capacity");
|
|
22929
|
-
const sum =
|
|
23017
|
+
const sum = createHash20("sha256");
|
|
22930
23018
|
for (const task2 of tasks) {
|
|
22931
23019
|
budget.reserve(0);
|
|
22932
23020
|
sum.update(JSON.stringify({
|
|
@@ -22939,7 +23027,7 @@ async function read(p, request3, entity) {
|
|
|
22939
23027
|
if (s.legacy > tasks.length)
|
|
22940
23028
|
bad9();
|
|
22941
23029
|
if (!s.legacyIdentity && request3.after?.version === Number.MAX_SAFE_INTEGER) {
|
|
22942
|
-
const h =
|
|
23030
|
+
const h = createHash20("sha256").update(canonicalJson({
|
|
22943
23031
|
...readIdentity(request3),
|
|
22944
23032
|
after: null,
|
|
22945
23033
|
legacy: s.legacy === 0 ? "begin" : identity,
|
|
@@ -23219,7 +23307,7 @@ class HistoryProjection {
|
|
|
23219
23307
|
};
|
|
23220
23308
|
cursor(request3, pos, row, item) {
|
|
23221
23309
|
const offset = pos.offset * (LIMITS.segmentRecords + 1) * ROW_SLOTS + row * ROW_SLOTS + item;
|
|
23222
|
-
const digest =
|
|
23310
|
+
const digest = createHash21("sha256").update(canonicalJson({
|
|
23223
23311
|
...readIdentity(request3),
|
|
23224
23312
|
after: null,
|
|
23225
23313
|
position: { ...pos, row, item }
|
|
@@ -23410,7 +23498,7 @@ class HistoryProjection {
|
|
|
23410
23498
|
if (legacyPhase)
|
|
23411
23499
|
this.navigation.snapshot(snapshot, budget);
|
|
23412
23500
|
const cursor = (offset2, identity2) => {
|
|
23413
|
-
const digest2 =
|
|
23501
|
+
const digest2 = createHash21("sha256").update(canonicalJson({ ...request3, after: null, legacy: identity2, offset: offset2 })).digest("hex");
|
|
23414
23502
|
return {
|
|
23415
23503
|
recordId: `${digest2.slice(0, 8)}-${digest2.slice(8, 12)}-4${digest2.slice(13, 16)}-8${digest2.slice(17, 20)}-${digest2.slice(20, 32)}`,
|
|
23416
23504
|
version: legacyVersion,
|
|
@@ -23437,7 +23525,7 @@ class HistoryProjection {
|
|
|
23437
23525
|
}
|
|
23438
23526
|
if (legacy.length > 1000)
|
|
23439
23527
|
throw new ContractError("capacity");
|
|
23440
|
-
const items = [...legacy].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0), digest =
|
|
23528
|
+
const items = [...legacy].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0), digest = createHash21("sha256");
|
|
23441
23529
|
for (const item of items) {
|
|
23442
23530
|
budget.reserve(0);
|
|
23443
23531
|
if (Buffer.byteLength(item.goal) > 8192)
|
|
@@ -23627,7 +23715,7 @@ class HistoryProjection {
|
|
|
23627
23715
|
}
|
|
23628
23716
|
|
|
23629
23717
|
// src/history/reader.ts
|
|
23630
|
-
import { createHash as
|
|
23718
|
+
import { createHash as createHash22 } from "node:crypto";
|
|
23631
23719
|
import { existsSync as existsSync3 } from "node:fs";
|
|
23632
23720
|
import { join as join30 } from "node:path";
|
|
23633
23721
|
|
|
@@ -24289,7 +24377,7 @@ class HistoryReader {
|
|
|
24289
24377
|
}
|
|
24290
24378
|
}
|
|
24291
24379
|
const text2 = Buffer.concat(pieces);
|
|
24292
|
-
if (end !== detail.content.bytes ||
|
|
24380
|
+
if (end !== detail.content.bytes || createHash22("sha256").update(text2).digest("hex") !== detail.content.sha256)
|
|
24293
24381
|
return;
|
|
24294
24382
|
return { detail, bytes: text2 };
|
|
24295
24383
|
} catch {
|
|
@@ -24324,7 +24412,7 @@ class HistoryReader {
|
|
|
24324
24412
|
if (!current2 || current2.length < expected.bytes || hash(current2.subarray(0, expected.bytes)) !== expected.identity)
|
|
24325
24413
|
throw new ContractError("corrupt-selected");
|
|
24326
24414
|
}
|
|
24327
|
-
const checksum =
|
|
24415
|
+
const checksum = createHash22("sha256");
|
|
24328
24416
|
let bytes = 0;
|
|
24329
24417
|
let cached;
|
|
24330
24418
|
for (const e of locator.chunks) {
|
|
@@ -24598,16 +24686,16 @@ class HistoryReader {
|
|
|
24598
24686
|
}
|
|
24599
24687
|
|
|
24600
24688
|
// src/history/recovery.ts
|
|
24601
|
-
import { createHash as
|
|
24689
|
+
import { createHash as createHash26, randomUUID as randomUUID19 } from "node:crypto";
|
|
24602
24690
|
import { lstatSync as lstatSync19, opendirSync as opendirSync11 } from "node:fs";
|
|
24603
24691
|
import { join as join34, relative as relative7 } from "node:path";
|
|
24604
24692
|
|
|
24605
24693
|
// src/history/writer.ts
|
|
24606
|
-
import { createHash as
|
|
24694
|
+
import { createHash as createHash25, randomUUID as randomUUID18 } from "node:crypto";
|
|
24607
24695
|
import { join as join33 } from "node:path";
|
|
24608
24696
|
|
|
24609
24697
|
// src/task-store.ts
|
|
24610
|
-
import { createHash as
|
|
24698
|
+
import { createHash as createHash23, randomUUID as randomUUID16 } from "node:crypto";
|
|
24611
24699
|
import {
|
|
24612
24700
|
closeSync as closeSync8,
|
|
24613
24701
|
fsyncSync as fsyncSync4,
|
|
@@ -24695,7 +24783,7 @@ function recordText(record3) {
|
|
|
24695
24783
|
`;
|
|
24696
24784
|
}
|
|
24697
24785
|
function contentIdentity(text2) {
|
|
24698
|
-
return
|
|
24786
|
+
return createHash23("sha256").update(text2).digest("hex");
|
|
24699
24787
|
}
|
|
24700
24788
|
function savedRecordIdentity(record3) {
|
|
24701
24789
|
return contentIdentity(recordText(record3));
|
|
@@ -24840,11 +24928,11 @@ function legacyTaskStore(c) {
|
|
|
24840
24928
|
}
|
|
24841
24929
|
|
|
24842
24930
|
// src/history/plans.ts
|
|
24843
|
-
import { createHash as
|
|
24931
|
+
import { createHash as createHash24, randomUUID as randomUUID17 } from "node:crypto";
|
|
24844
24932
|
function assertPlanContent(plan, reference, secrets) {
|
|
24845
24933
|
text(plan, 32768);
|
|
24846
24934
|
const ref = decodeContentRef(reference);
|
|
24847
|
-
if (ref.field !== "plan" || ref.bytes !== Buffer.byteLength(plan) || ref.sha256 !==
|
|
24935
|
+
if (ref.field !== "plan" || ref.bytes !== Buffer.byteLength(plan) || ref.sha256 !== createHash24("sha256").update(plan).digest("hex") || sanitizeText(plan, secrets) !== plan)
|
|
24848
24936
|
throw new ContractError("invalid");
|
|
24849
24937
|
}
|
|
24850
24938
|
function planRecording(plan, graph, operationId, epoch) {
|
|
@@ -26493,7 +26581,7 @@ class HistoryWriter {
|
|
|
26493
26581
|
recordId: randomUUID18(),
|
|
26494
26582
|
version: 1,
|
|
26495
26583
|
bytes: 0,
|
|
26496
|
-
hash:
|
|
26584
|
+
hash: createHash25("sha256"),
|
|
26497
26585
|
parts: 0,
|
|
26498
26586
|
ended: null,
|
|
26499
26587
|
committedSeq: null
|
|
@@ -26871,7 +26959,7 @@ function readOperationStateForPublication(files, operationId) {
|
|
|
26871
26959
|
// src/history/recovery.ts
|
|
26872
26960
|
function digestHistory(files, exclude) {
|
|
26873
26961
|
files.assertFormat();
|
|
26874
|
-
const digest =
|
|
26962
|
+
const digest = createHash26("sha256");
|
|
26875
26963
|
let count2 = 0;
|
|
26876
26964
|
const walk = (path, depth) => {
|
|
26877
26965
|
if (depth > 8 || !files.files.directory(path))
|
|
@@ -26983,12 +27071,12 @@ async function healHistory(lease, log) {
|
|
|
26983
27071
|
|
|
26984
27072
|
// src/subagent-process.ts
|
|
26985
27073
|
import { spawn as spawn5 } from "node:child_process";
|
|
26986
|
-
import { createHash as
|
|
27074
|
+
import { createHash as createHash28, randomUUID as randomUUID21 } from "node:crypto";
|
|
26987
27075
|
import { join as join35 } from "node:path";
|
|
26988
27076
|
import { StringDecoder } from "node:string_decoder";
|
|
26989
27077
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
26990
27078
|
// src/worker-capture.mjs
|
|
26991
|
-
import { createHash as
|
|
27079
|
+
import { createHash as createHash27, randomUUID as randomUUID20 } from "node:crypto";
|
|
26992
27080
|
var completeCoverage = () => ({
|
|
26993
27081
|
observed: "complete",
|
|
26994
27082
|
source: "complete",
|
|
@@ -27091,7 +27179,7 @@ class CaptureState {
|
|
|
27091
27179
|
final: null,
|
|
27092
27180
|
stopReason: null,
|
|
27093
27181
|
finalIndices: new Set,
|
|
27094
|
-
finalHash:
|
|
27182
|
+
finalHash: createHash27("sha256"),
|
|
27095
27183
|
finalBytes: 0,
|
|
27096
27184
|
finalIndex: -1
|
|
27097
27185
|
});
|
|
@@ -27118,7 +27206,7 @@ class CaptureState {
|
|
|
27118
27206
|
}
|
|
27119
27207
|
this.details.set(e.detailId, {
|
|
27120
27208
|
descriptor: e.descriptor,
|
|
27121
|
-
hash:
|
|
27209
|
+
hash: createHash27("sha256"),
|
|
27122
27210
|
bytes: 0,
|
|
27123
27211
|
ended: false,
|
|
27124
27212
|
preview: ""
|
|
@@ -28175,7 +28263,7 @@ function launchConversation(prepared, conversation, signal, options) {
|
|
|
28175
28263
|
const imageInput = options.images?.length ? JSON.stringify(options.images) : undefined;
|
|
28176
28264
|
const imageDescriptor = imageInput === undefined ? undefined : {
|
|
28177
28265
|
bytes: Buffer.byteLength(imageInput),
|
|
28178
|
-
sha256:
|
|
28266
|
+
sha256: createHash28("sha256").update(imageInput).digest("hex")
|
|
28179
28267
|
};
|
|
28180
28268
|
return prepared.consume((material) => {
|
|
28181
28269
|
encoded2 = encodeEnvelope({
|
|
@@ -29828,7 +29916,7 @@ For follow-up to a settled or interrupted run, inspect retained outcomes first.
|
|
|
29828
29916
|
|
|
29829
29917
|
// src/service/project-knowledge.ts
|
|
29830
29918
|
import { isUtf8 } from "node:buffer";
|
|
29831
|
-
import { createHash as
|
|
29919
|
+
import { createHash as createHash30 } from "node:crypto";
|
|
29832
29920
|
import {
|
|
29833
29921
|
closeSync as closeSync11,
|
|
29834
29922
|
constants as constants10,
|
|
@@ -29846,7 +29934,7 @@ import { dirname as dirname22, posix } from "node:path";
|
|
|
29846
29934
|
|
|
29847
29935
|
// src/service/workflow-git.ts
|
|
29848
29936
|
import { spawn as spawn6, spawnSync as spawnSync5 } from "node:child_process";
|
|
29849
|
-
import { createHash as
|
|
29937
|
+
import { createHash as createHash29 } from "node:crypto";
|
|
29850
29938
|
import {
|
|
29851
29939
|
closeSync as closeSync10,
|
|
29852
29940
|
constants as constants9,
|
|
@@ -30008,7 +30096,7 @@ function fileIdentity(p, st, hashBytes) {
|
|
|
30008
30096
|
try {
|
|
30009
30097
|
if (!fstatSync7(fd).isFile())
|
|
30010
30098
|
throw new ContractError("stale");
|
|
30011
|
-
const digest =
|
|
30099
|
+
const digest = createHash29("sha256"), buffer = Buffer.alloc(CHUNK);
|
|
30012
30100
|
for (let n = readSync6(fd, buffer);n > 0; n = readSync6(fd, buffer))
|
|
30013
30101
|
digest.update(buffer.subarray(0, n));
|
|
30014
30102
|
return `sha256:${digest.digest("hex")}`;
|
|
@@ -30035,7 +30123,7 @@ async function fileIdentityAsync(p, st, hashBytes, signal) {
|
|
|
30035
30123
|
const same2 = (a, b) => a.isFile() && b.isFile() && a.dev === b.dev && a.ino === b.ino && a.size === b.size && a.mtimeMs === b.mtimeMs && a.ctimeMs === b.ctimeMs;
|
|
30036
30124
|
if (!same2(st, before))
|
|
30037
30125
|
throw new ContractError("stale");
|
|
30038
|
-
const digest =
|
|
30126
|
+
const digest = createHash29("sha256"), buffer = Buffer.alloc(CHUNK);
|
|
30039
30127
|
let remaining = before.size;
|
|
30040
30128
|
while (remaining > 0) {
|
|
30041
30129
|
if (signal?.aborted)
|
|
@@ -30776,7 +30864,7 @@ ${line}`;
|
|
|
30776
30864
|
`);
|
|
30777
30865
|
}
|
|
30778
30866
|
var roots = ["engineering", "docs", ".trellis/spec", ".cadence/knowledge"];
|
|
30779
|
-
var digest = (s) =>
|
|
30867
|
+
var digest = (s) => createHash30("sha256").update(s).digest("hex");
|
|
30780
30868
|
var markdown2 = (p) => /\.md$/iu.test(p) && !/^(?:\.cadence\/assistant|\.trellis\/(?:workspace|tasks))(?:\/|$)/u.test(p) && !p.split("/").some((part) => part === ".." || part === ".git" || part === "node_modules" || part.startsWith(".env") || part.startsWith(".") && part !== ".cadence" && part !== ".trellis");
|
|
30781
30869
|
function readKnowledgeFile(root, path) {
|
|
30782
30870
|
if (!markdown2(path))
|
|
@@ -32266,14 +32354,14 @@ import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
|
32266
32354
|
|
|
32267
32355
|
// src/task-diff.ts
|
|
32268
32356
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
32269
|
-
import { createHash as
|
|
32357
|
+
import { createHash as createHash31 } from "node:crypto";
|
|
32270
32358
|
import { lstatSync as lstatSync24, readdirSync as readdirSync5, readlinkSync as readlinkSync2 } from "node:fs";
|
|
32271
32359
|
import { join as join40, relative as relative9 } from "node:path";
|
|
32272
32360
|
var admin = (path) => path === ".cadence/assistant/tasks" || path.startsWith(".cadence/assistant/tasks/");
|
|
32273
32361
|
var GIT_OUTPUT_BYTES = 16 * 1024 * 1024;
|
|
32274
32362
|
function captureChanges(root, outputBytes = GIT_OUTPUT_BYTES) {
|
|
32275
32363
|
const deadline = Date.now() + 3000;
|
|
32276
|
-
const hash3 =
|
|
32364
|
+
const hash3 = createHash31("sha256");
|
|
32277
32365
|
const parts = [];
|
|
32278
32366
|
let complete = true;
|
|
32279
32367
|
const limits = [];
|
|
@@ -32331,7 +32419,7 @@ function captureChanges(root, outputBytes = GIT_OUTPUT_BYTES) {
|
|
|
32331
32419
|
fileBytes += data2.length;
|
|
32332
32420
|
add(name, data2);
|
|
32333
32421
|
const binary = data2.includes(0);
|
|
32334
|
-
parts.push(`${name} (${binary ? "binary" : "text"}, ${data2.length} bytes, sha256 ${
|
|
32422
|
+
parts.push(`${name} (${binary ? "binary" : "text"}, ${data2.length} bytes, sha256 ${createHash31("sha256").update(data2).digest("hex")})`);
|
|
32335
32423
|
} catch {
|
|
32336
32424
|
complete = false;
|
|
32337
32425
|
limits.push(`Unreadable/changing: ${name}`);
|
|
@@ -32507,7 +32595,7 @@ function executionDirectory(execution, tree) {
|
|
|
32507
32595
|
}
|
|
32508
32596
|
|
|
32509
32597
|
// src/service/investigations.ts
|
|
32510
|
-
import { createHash as
|
|
32598
|
+
import { createHash as createHash32 } from "node:crypto";
|
|
32511
32599
|
import { readFileSync as readFileSync7, statSync as statSync3 } from "node:fs";
|
|
32512
32600
|
var INVESTIGATIONS = {
|
|
32513
32601
|
cited: 32,
|
|
@@ -32523,7 +32611,7 @@ function fileDigest(root, path) {
|
|
|
32523
32611
|
const st = statSync3(file);
|
|
32524
32612
|
if (!st.isFile() || st.size > INVESTIGATIONS.fileBytes)
|
|
32525
32613
|
return null;
|
|
32526
|
-
return
|
|
32614
|
+
return createHash32("sha256").update(readFileSync7(file)).digest("hex");
|
|
32527
32615
|
} catch {
|
|
32528
32616
|
return null;
|
|
32529
32617
|
}
|
|
@@ -32551,14 +32639,14 @@ function changedFiles(root, files) {
|
|
|
32551
32639
|
return files.filter((file) => fileDigest(root, file.path) !== file.digest).map((file) => file.path);
|
|
32552
32640
|
}
|
|
32553
32641
|
function questionKey(question, roots2) {
|
|
32554
|
-
return
|
|
32642
|
+
return createHash32("sha256").update(JSON.stringify([
|
|
32555
32643
|
question.trim().replace(/\s+/gu, " "),
|
|
32556
32644
|
[...roots2 ?? []].sort()
|
|
32557
32645
|
])).digest("hex");
|
|
32558
32646
|
}
|
|
32559
32647
|
|
|
32560
32648
|
// src/service/workflow-controller.ts
|
|
32561
|
-
import { createHash as
|
|
32649
|
+
import { createHash as createHash33 } from "node:crypto";
|
|
32562
32650
|
var RECOVERY_BYTES = 32768;
|
|
32563
32651
|
|
|
32564
32652
|
class AttemptFailure extends Error {
|
|
@@ -32799,7 +32887,7 @@ class DeliveryController {
|
|
|
32799
32887
|
this.ports.assertRunning();
|
|
32800
32888
|
if (decision.action === "blocked")
|
|
32801
32889
|
break;
|
|
32802
|
-
const fingerprint2 =
|
|
32890
|
+
const fingerprint2 = createHash33("sha256").update(canonicalJson({
|
|
32803
32891
|
stage,
|
|
32804
32892
|
observation,
|
|
32805
32893
|
failure: error.message.replace(/[0-9a-f]{8}-[0-9a-f-]{27,}/gu, "<step>"),
|
|
@@ -33722,8 +33810,8 @@ function workflowResultDetail(value, secrets) {
|
|
|
33722
33810
|
|
|
33723
33811
|
// src/service/workflows.ts
|
|
33724
33812
|
var OWNER_RUNTIME = Object.freeze({
|
|
33725
|
-
version: "2.1.
|
|
33726
|
-
build: "
|
|
33813
|
+
version: "2.1.2",
|
|
33814
|
+
build: "4f23f702e5853bcb2a5e9bb73d871d4446346fc117cf88abddaafb481a1d0376",
|
|
33727
33815
|
entry: fileURLToPath7(import.meta.url),
|
|
33728
33816
|
pid: process.pid,
|
|
33729
33817
|
node: process.versions.node,
|
|
@@ -36089,10 +36177,11 @@ class Workbench {
|
|
|
36089
36177
|
case "conversation-tree":
|
|
36090
36178
|
return this.conversations.records.tree(request3.id, request3.leaf);
|
|
36091
36179
|
case "files":
|
|
36092
|
-
case "file":
|
|
36180
|
+
case "file":
|
|
36181
|
+
case "file-part": {
|
|
36093
36182
|
const cwd = this.contexts.directory(request3.location);
|
|
36094
36183
|
const files = new WorkbenchFiles(cwd, [this.o.coordination.files.namespace, this.o.agentDir], this.o.secrets);
|
|
36095
|
-
return request3.kind === "files" ? files.list(request3.path) : files.read(request3.path);
|
|
36184
|
+
return request3.kind === "files" ? files.list(request3.path) : request3.kind === "file" ? files.read(request3.path) : files.part(request3.path, request3.offset);
|
|
36096
36185
|
}
|
|
36097
36186
|
case "directories":
|
|
36098
36187
|
return this.files.list(request3.path, true);
|
|
@@ -36416,7 +36505,7 @@ var processLifetime = {
|
|
|
36416
36505
|
}
|
|
36417
36506
|
};
|
|
36418
36507
|
async function createServiceHost(value, sourceBuild, lifetime) {
|
|
36419
|
-
const embedded = "
|
|
36508
|
+
const embedded = "46e67668411af8fc9cdc99bb5dcee56ea093a33d18fce3545d5c9bbb5847948b";
|
|
36420
36509
|
if (embedded && sourceBuild)
|
|
36421
36510
|
throw new ContractError("unsupported-context");
|
|
36422
36511
|
const contractHash = decodeHash(embedded ?? sourceBuild?.contractHash);
|