@abelxiaoxing/cadence 2.0.21 → 2.0.23
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 +5 -11
- package/README.es.md +5 -11
- package/README.fr.md +5 -11
- package/README.ja.md +5 -11
- package/README.ko.md +5 -11
- package/README.md +6 -14
- package/README.pt-BR.md +5 -11
- package/README.ru.md +5 -11
- package/README.zh-CN.md +5 -13
- package/docs/conversation-mode.md +20 -9
- package/docs/history.md +50 -0
- package/docs/service-management.md +1 -1
- package/package.json +8 -7
- package/src/agent-panel-cadence.ts +302 -10
- package/src/cadence-instructions.ts +1 -1
- package/src/cadence-mode.ts +682 -226
- package/src/cadence-preferences.ts +43 -8
- package/src/data-shapes.ts +16 -0
- package/src/history-shell.ts +370 -0
- package/src/index.ts +3 -3
- package/src/native-build.ts +1 -1
- package/src/native-client.ts +45 -2
- package/src/native-workflow-history.ts +132 -0
- package/src/operator-cli.mjs +93 -65
- package/src/service/checkout-lock.ts +142 -0
- package/src/service/contracts/workbench.ts +82 -26
- package/src/service/contracts/workflow.ts +43 -13
- package/src/service/coordination.ts +6 -7
- package/src/service/private-files.ts +2 -1
- package/src/service-cli.mjs +244 -423
- package/src/service-host.mjs +5722 -7097
- package/src/workspace.ts +302 -0
- package/web/dist/assets/cadence.css +1 -1
- package/web/dist/assets/cadence.js +15 -15
- package/web/dist/manifest.json +7 -7
- package/config/workflow-task.example.json +0 -7
- package/src/plan-proposal.ts +0 -87
- package/src/task-shell.ts +0 -1059
- package/src/task-store.ts +0 -593
- package/src/task-types.ts +0 -184
package/src/task-types.ts
DELETED
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/** Plain workflow context, not executable approvals or certified evidence. */
|
|
2
|
-
export const TASK_SCHEMA = "cadence-workflow-assistant/1";
|
|
3
|
-
export const MAX_RECORD_BYTES = 128 * 1024;
|
|
4
|
-
export type TaskKind = "code" | "research" | "diagnosis";
|
|
5
|
-
export type TaskPhase =
|
|
6
|
-
| "planning"
|
|
7
|
-
| "running"
|
|
8
|
-
| "review"
|
|
9
|
-
| "interrupted"
|
|
10
|
-
| "failed"
|
|
11
|
-
| "done";
|
|
12
|
-
export interface CheckDefinition {
|
|
13
|
-
name: string;
|
|
14
|
-
command: string;
|
|
15
|
-
timeoutMs: number;
|
|
16
|
-
}
|
|
17
|
-
export interface CheckRecord extends CheckDefinition {
|
|
18
|
-
cwd: string;
|
|
19
|
-
exitCode: number | null;
|
|
20
|
-
durationMs: number;
|
|
21
|
-
status: "passed" | "failed" | "canceled" | "stale";
|
|
22
|
-
fingerprint: string;
|
|
23
|
-
log?: string;
|
|
24
|
-
}
|
|
25
|
-
export interface TaskRecord {
|
|
26
|
-
schema: typeof TASK_SCHEMA;
|
|
27
|
-
id: string;
|
|
28
|
-
revision: number;
|
|
29
|
-
kind: TaskKind;
|
|
30
|
-
goal: string;
|
|
31
|
-
plan: string;
|
|
32
|
-
cwd: string;
|
|
33
|
-
phase: TaskPhase;
|
|
34
|
-
result: string;
|
|
35
|
-
baseline: string;
|
|
36
|
-
checks: CheckRecord[];
|
|
37
|
-
review?: {
|
|
38
|
-
fingerprint: string;
|
|
39
|
-
outcome: "reviewed" | "reviewed-with-issues";
|
|
40
|
-
};
|
|
41
|
-
activity: { at: string; text: string }[];
|
|
42
|
-
}
|
|
43
|
-
export interface ChangeView {
|
|
44
|
-
fingerprint: string;
|
|
45
|
-
text: string;
|
|
46
|
-
complete: boolean;
|
|
47
|
-
git: boolean;
|
|
48
|
-
}
|
|
49
|
-
export interface RunResult {
|
|
50
|
-
outcome: "completed" | "failed" | "canceled" | "timeout" | "unknown";
|
|
51
|
-
closed: boolean;
|
|
52
|
-
exitCode: number | null;
|
|
53
|
-
signal: string | null;
|
|
54
|
-
durationMs: number;
|
|
55
|
-
text: string;
|
|
56
|
-
output: string;
|
|
57
|
-
truncated: boolean;
|
|
58
|
-
}
|
|
59
|
-
export function object(value: unknown): value is Record<string, unknown> {
|
|
60
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
61
|
-
}
|
|
62
|
-
export function boundedString(value: unknown, max: number): value is string {
|
|
63
|
-
return (
|
|
64
|
-
typeof value === "string" &&
|
|
65
|
-
Buffer.byteLength(value) <= max &&
|
|
66
|
-
!value.includes("\0")
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
export function validId(value: string): boolean {
|
|
70
|
-
return /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(
|
|
71
|
-
value,
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
export function decodeCheck(value: unknown): CheckDefinition {
|
|
75
|
-
if (
|
|
76
|
-
!object(value) ||
|
|
77
|
-
!boundedString(value.name, 128) ||
|
|
78
|
-
!value.name.trim() ||
|
|
79
|
-
!boundedString(value.command, 4096) ||
|
|
80
|
-
!value.command.trim() ||
|
|
81
|
-
!Number.isInteger(value.timeoutMs) ||
|
|
82
|
-
Number(value.timeoutMs) < 100 ||
|
|
83
|
-
Number(value.timeoutMs) > 1_200_000
|
|
84
|
-
)
|
|
85
|
-
throw new Error("Invalid check definition");
|
|
86
|
-
// biome-ignore lint/suspicious/noControlCharactersInRegex: reject invisible terminal controls in executable confirmations
|
|
87
|
-
const controls = /[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;
|
|
88
|
-
if (
|
|
89
|
-
controls.test(value.command) ||
|
|
90
|
-
controls.test(value.name) ||
|
|
91
|
-
/[\n\t]/u.test(value.name)
|
|
92
|
-
)
|
|
93
|
-
throw new Error(
|
|
94
|
-
"Check commands/names must be visibly representable in the terminal",
|
|
95
|
-
);
|
|
96
|
-
return {
|
|
97
|
-
name: value.name,
|
|
98
|
-
command: value.command,
|
|
99
|
-
timeoutMs: Number(value.timeoutMs),
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
export function decodeTask(value: unknown): TaskRecord {
|
|
103
|
-
if (
|
|
104
|
-
!object(value) ||
|
|
105
|
-
value.schema !== TASK_SCHEMA ||
|
|
106
|
-
typeof value.id !== "string" ||
|
|
107
|
-
!validId(value.id) ||
|
|
108
|
-
!Number.isSafeInteger(value.revision) ||
|
|
109
|
-
Number(value.revision) < 1 ||
|
|
110
|
-
typeof value.kind !== "string" ||
|
|
111
|
-
!["code", "research", "diagnosis"].includes(value.kind) ||
|
|
112
|
-
typeof value.phase !== "string" ||
|
|
113
|
-
![
|
|
114
|
-
"planning",
|
|
115
|
-
"running",
|
|
116
|
-
"review",
|
|
117
|
-
"interrupted",
|
|
118
|
-
"failed",
|
|
119
|
-
"done",
|
|
120
|
-
].includes(value.phase) ||
|
|
121
|
-
!boundedString(value.goal, 8192) ||
|
|
122
|
-
!value.goal.trim() ||
|
|
123
|
-
!boundedString(value.plan, 32768) ||
|
|
124
|
-
!boundedString(value.cwd, 4096) ||
|
|
125
|
-
!boundedString(value.result, 16384) ||
|
|
126
|
-
!boundedString(value.baseline, 16384) ||
|
|
127
|
-
!Array.isArray(value.checks) ||
|
|
128
|
-
value.checks.length > 32 ||
|
|
129
|
-
!Array.isArray(value.activity) ||
|
|
130
|
-
value.activity.length > 64
|
|
131
|
-
)
|
|
132
|
-
throw new Error("Unknown or corrupt task record");
|
|
133
|
-
for (const check of value.checks) {
|
|
134
|
-
decodeCheck(check);
|
|
135
|
-
if (
|
|
136
|
-
!object(check) ||
|
|
137
|
-
!boundedString(check.cwd, 4096) ||
|
|
138
|
-
!(check.exitCode === null || Number.isInteger(check.exitCode)) ||
|
|
139
|
-
typeof check.durationMs !== "number" ||
|
|
140
|
-
!Number.isFinite(check.durationMs) ||
|
|
141
|
-
check.durationMs < 0 ||
|
|
142
|
-
typeof check.status !== "string" ||
|
|
143
|
-
!["passed", "failed", "canceled", "stale"].includes(check.status) ||
|
|
144
|
-
!boundedString(check.fingerprint, 128) ||
|
|
145
|
-
(check.log !== undefined &&
|
|
146
|
-
(typeof check.log !== "string" || !/^[a-f0-9-]+\.log$/.test(check.log)))
|
|
147
|
-
)
|
|
148
|
-
throw new Error("Corrupt check record");
|
|
149
|
-
}
|
|
150
|
-
for (const entry of value.activity) {
|
|
151
|
-
if (
|
|
152
|
-
!object(entry) ||
|
|
153
|
-
!boundedString(entry.at, 64) ||
|
|
154
|
-
!boundedString(entry.text, 512)
|
|
155
|
-
)
|
|
156
|
-
throw new Error("Corrupt activity");
|
|
157
|
-
}
|
|
158
|
-
if (
|
|
159
|
-
value.review !== undefined &&
|
|
160
|
-
(!object(value.review) ||
|
|
161
|
-
!boundedString(value.review.fingerprint, 128) ||
|
|
162
|
-
typeof value.review.outcome !== "string" ||
|
|
163
|
-
!["reviewed", "reviewed-with-issues"].includes(value.review.outcome))
|
|
164
|
-
)
|
|
165
|
-
throw new Error("Corrupt review");
|
|
166
|
-
const allowed = new Set([
|
|
167
|
-
"schema",
|
|
168
|
-
"id",
|
|
169
|
-
"revision",
|
|
170
|
-
"kind",
|
|
171
|
-
"goal",
|
|
172
|
-
"plan",
|
|
173
|
-
"cwd",
|
|
174
|
-
"phase",
|
|
175
|
-
"result",
|
|
176
|
-
"baseline",
|
|
177
|
-
"checks",
|
|
178
|
-
"review",
|
|
179
|
-
"activity",
|
|
180
|
-
]);
|
|
181
|
-
if (Object.keys(value).some((key) => !allowed.has(key)))
|
|
182
|
-
throw new Error("Unknown task fields");
|
|
183
|
-
return structuredClone(value) as unknown as TaskRecord;
|
|
184
|
-
}
|