@abelxiaoxing/cadence 2.0.17 → 2.0.19
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 +106 -0
- package/README.es.md +106 -0
- package/README.fr.md +106 -0
- package/README.ja.md +127 -0
- package/README.ko.md +124 -0
- package/README.md +64 -709
- package/README.pt-BR.md +106 -0
- package/README.ru.md +107 -0
- package/README.zh-CN.md +106 -0
- package/THIRD_PARTY_NOTICES.md +0 -8
- package/docs/reuse-and-distribution.md +1 -24
- package/docs/service-management.md +8 -0
- package/package.json +9 -1
- package/src/conversation-context.mjs +22 -9
- package/src/service-host.mjs +56 -40
- package/web/dist/assets/cadence.js +9 -9
- package/web/dist/manifest.json +4 -4
- package/licenses/pi-web-ui-reuse.md +0 -24
package/src/service-host.mjs
CHANGED
|
@@ -21038,7 +21038,8 @@ import { createHash as createHash21 } from "node:crypto";
|
|
|
21038
21038
|
import { lstatSync as lstatSync12, readdirSync as readdirSync3, readlinkSync } from "node:fs";
|
|
21039
21039
|
import { join as join19, relative as relative7 } from "node:path";
|
|
21040
21040
|
var admin = (path) => path === ".cadence/assistant/tasks" || path.startsWith(".cadence/assistant/tasks/");
|
|
21041
|
-
|
|
21041
|
+
var GIT_OUTPUT_BYTES = 16 * 1024 * 1024;
|
|
21042
|
+
function captureChanges(root, outputBytes = GIT_OUTPUT_BYTES) {
|
|
21042
21043
|
const deadline = Date.now() + 3000;
|
|
21043
21044
|
const hash3 = createHash21("sha256");
|
|
21044
21045
|
const parts = [];
|
|
@@ -21050,24 +21051,25 @@ function captureChanges(root) {
|
|
|
21050
21051
|
hash3.update(label).update("\x00").update(data2).update("\x00");
|
|
21051
21052
|
};
|
|
21052
21053
|
const git = (args) => {
|
|
21053
|
-
|
|
21054
|
-
|
|
21055
|
-
|
|
21056
|
-
|
|
21057
|
-
|
|
21058
|
-
|
|
21059
|
-
|
|
21060
|
-
|
|
21061
|
-
|
|
21062
|
-
|
|
21063
|
-
|
|
21064
|
-
|
|
21065
|
-
|
|
21066
|
-
|
|
21067
|
-
|
|
21068
|
-
limits.push(`Unavailable/limited Git observation: ${args[0]}`);
|
|
21054
|
+
let outcome;
|
|
21055
|
+
if (Date.now() >= deadline)
|
|
21056
|
+
outcome = "time budget exhausted";
|
|
21057
|
+
else {
|
|
21058
|
+
const result = spawnSync2("git", gitArguments(["-c", "core.quotepath=true", ...args]), {
|
|
21059
|
+
cwd: root,
|
|
21060
|
+
encoding: "buffer",
|
|
21061
|
+
timeout: Math.max(1, deadline - Date.now()),
|
|
21062
|
+
maxBuffer: outputBytes,
|
|
21063
|
+
windowsHide: true,
|
|
21064
|
+
env: gitEnvironment()
|
|
21065
|
+
});
|
|
21066
|
+
if (!result.error && result.status === 0)
|
|
21067
|
+
return { stdout: result.stdout, limited: false };
|
|
21068
|
+
outcome = result.error ? result.error.code ?? "error" : result.signal ? `signal ${result.signal}` : `exit ${result.status}`;
|
|
21069
21069
|
}
|
|
21070
|
-
|
|
21070
|
+
complete = false;
|
|
21071
|
+
limits.push(`Unavailable/limited Git observation: ${args[0]} (${outcome})`);
|
|
21072
|
+
return { stdout: Buffer.from(`[limited: ${outcome}]`), limited: true };
|
|
21071
21073
|
};
|
|
21072
21074
|
const inventory = (name) => {
|
|
21073
21075
|
if (admin(name))
|
|
@@ -21120,7 +21122,7 @@ function captureChanges(root) {
|
|
|
21120
21122
|
":(exclude).cadence/assistant/tasks/**"
|
|
21121
21123
|
];
|
|
21122
21124
|
const head = git(["rev-parse", "--verify", "HEAD"]);
|
|
21123
|
-
add("HEAD", head.stdout
|
|
21125
|
+
add("HEAD", head.stdout);
|
|
21124
21126
|
for (const [label, args] of [
|
|
21125
21127
|
[
|
|
21126
21128
|
"Status (includes pre-existing dirt)",
|
|
@@ -21156,15 +21158,14 @@ function captureChanges(root) {
|
|
|
21156
21158
|
]
|
|
21157
21159
|
]
|
|
21158
21160
|
]) {
|
|
21159
|
-
const
|
|
21160
|
-
const data2 = result.stdout ?? Buffer.alloc(0);
|
|
21161
|
+
const data2 = git([...args]).stdout;
|
|
21161
21162
|
add(label, data2);
|
|
21162
21163
|
parts.push(`## ${label}
|
|
21163
21164
|
${data2.toString("utf8")}`);
|
|
21164
21165
|
}
|
|
21165
21166
|
const index = git(["ls-files", "--stage", "-z", ...pathspec]);
|
|
21166
|
-
add("Index entries", index.stdout
|
|
21167
|
-
for (const entry of
|
|
21167
|
+
add("Index entries", index.stdout);
|
|
21168
|
+
for (const entry of index.stdout.toString("utf8").split("\x00")) {
|
|
21168
21169
|
if (!entry.startsWith("160000 "))
|
|
21169
21170
|
continue;
|
|
21170
21171
|
complete = false;
|
|
@@ -21178,19 +21179,25 @@ ${data2.toString("utf8")}`);
|
|
|
21178
21179
|
...pathspec
|
|
21179
21180
|
]);
|
|
21180
21181
|
parts.push("## Untracked identities (content not automatically sent to model)");
|
|
21181
|
-
|
|
21182
|
-
|
|
21182
|
+
if (untracked.limited)
|
|
21183
|
+
add("Untracked", untracked.stdout);
|
|
21184
|
+
else
|
|
21185
|
+
for (const name of untracked.stdout.toString("utf8").split("\x00").filter(Boolean))
|
|
21186
|
+
inventory(name);
|
|
21183
21187
|
const ignored = git([
|
|
21184
21188
|
"ls-files",
|
|
21185
21189
|
"--others",
|
|
21186
21190
|
"--ignored",
|
|
21187
21191
|
"--exclude-standard",
|
|
21192
|
+
"--directory",
|
|
21193
|
+
"--no-empty-directory",
|
|
21188
21194
|
"-z",
|
|
21189
21195
|
...pathspec
|
|
21190
21196
|
]);
|
|
21191
|
-
if (ignored.stdout
|
|
21197
|
+
if (ignored.stdout.length) {
|
|
21192
21198
|
complete = false;
|
|
21193
|
-
|
|
21199
|
+
if (!ignored.limited)
|
|
21200
|
+
limits.push("Ignored files exist and are not inspected; review coverage is incomplete.");
|
|
21194
21201
|
add("ignored paths", ignored.stdout);
|
|
21195
21202
|
}
|
|
21196
21203
|
parts.push("Administrative .cadence/assistant/tasks records are excluded from business freshness; configuration is not excluded.");
|
|
@@ -21937,6 +21944,22 @@ function argumentsData(value, secrets) {
|
|
|
21937
21944
|
throw new Error("Unsupported context arguments");
|
|
21938
21945
|
return parseWireJson(source, 64 * 1024);
|
|
21939
21946
|
}
|
|
21947
|
+
function own(value, key2) {
|
|
21948
|
+
const d = value && typeof value === "object" ? Object.getOwnPropertyDescriptor(value, key2) : undefined;
|
|
21949
|
+
if (!d || !("value" in d))
|
|
21950
|
+
throw new Error("Invalid usage");
|
|
21951
|
+
return d.value;
|
|
21952
|
+
}
|
|
21953
|
+
function counts(value, keys3) {
|
|
21954
|
+
const out = Object.create(null);
|
|
21955
|
+
for (const key2 of keys3) {
|
|
21956
|
+
const n = own(value, key2);
|
|
21957
|
+
if (typeof n !== "number" || !Number.isFinite(n) || n < 0)
|
|
21958
|
+
throw new Error("Invalid usage");
|
|
21959
|
+
out[key2] = n;
|
|
21960
|
+
}
|
|
21961
|
+
return out;
|
|
21962
|
+
}
|
|
21940
21963
|
function conversationMessages(messages, secrets = []) {
|
|
21941
21964
|
return list(messages, 4096, (message) => {
|
|
21942
21965
|
if (!message || typeof message !== "object")
|
|
@@ -21966,27 +21989,20 @@ function conversationMessages(messages, secrets = []) {
|
|
|
21966
21989
|
toolName: clean(message.toolName, secrets, 128),
|
|
21967
21990
|
isError: message.isError === true
|
|
21968
21991
|
};
|
|
21969
|
-
const usage =
|
|
21992
|
+
const usage = counts(message.usage, [
|
|
21970
21993
|
"input",
|
|
21971
21994
|
"output",
|
|
21972
21995
|
"cacheRead",
|
|
21973
21996
|
"cacheWrite",
|
|
21974
|
-
"totalTokens"
|
|
21975
|
-
"cost"
|
|
21997
|
+
"totalTokens"
|
|
21976
21998
|
]);
|
|
21977
|
-
|
|
21999
|
+
usage.cost = counts(own(message.usage, "cost"), [
|
|
21978
22000
|
"input",
|
|
21979
22001
|
"output",
|
|
21980
22002
|
"cacheRead",
|
|
21981
22003
|
"cacheWrite",
|
|
21982
22004
|
"total"
|
|
21983
22005
|
]);
|
|
21984
|
-
for (const value of [
|
|
21985
|
-
...Object.values(usage).filter((v) => typeof v !== "object"),
|
|
21986
|
-
...Object.values(cost)
|
|
21987
|
-
])
|
|
21988
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value < 0)
|
|
21989
|
-
throw new Error("Invalid usage");
|
|
21990
22006
|
return {
|
|
21991
22007
|
role: role2,
|
|
21992
22008
|
timestamp,
|
|
@@ -24845,7 +24861,7 @@ class TaskActions {
|
|
|
24845
24861
|
const graph = action.kind === "start" ? plan?.graph ?? this.defaultGraph(selected2.record, selected2.identity, expected.model) : null;
|
|
24846
24862
|
if (graph && hash2(canonicalJson(graph)) !== expected.task.graphIdentity)
|
|
24847
24863
|
throw new ContractError("stale");
|
|
24848
|
-
let
|
|
24864
|
+
let own3 = {
|
|
24849
24865
|
revision: selected2.record.revision,
|
|
24850
24866
|
identity: selected2.identity
|
|
24851
24867
|
};
|
|
@@ -24875,7 +24891,7 @@ class TaskActions {
|
|
|
24875
24891
|
try {
|
|
24876
24892
|
this.assertChoice(expected);
|
|
24877
24893
|
const latest = h.coordination.store.loadSnapshot(action.taskId);
|
|
24878
|
-
return latest?.identity ===
|
|
24894
|
+
return latest?.identity === own3.identity && latest.record.revision === own3.revision && this.sources.current();
|
|
24879
24895
|
} catch {
|
|
24880
24896
|
return false;
|
|
24881
24897
|
}
|
|
@@ -24903,7 +24919,7 @@ class TaskActions {
|
|
|
24903
24919
|
});
|
|
24904
24920
|
if (publication.status !== "published" || !publication.observed)
|
|
24905
24921
|
throw new ContractError("conflict");
|
|
24906
|
-
|
|
24922
|
+
own3 = publication.observed;
|
|
24907
24923
|
}
|
|
24908
24924
|
});
|
|
24909
24925
|
accepted2.activate(work);
|