@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
|
@@ -19,7 +19,11 @@ export const WORKFLOW_LIMITS = {
|
|
|
19
19
|
checks: 16,
|
|
20
20
|
repairs: 2,
|
|
21
21
|
bytes: 256 * 1024,
|
|
22
|
-
|
|
22
|
+
// Read budgets, never a lifetime cap on retained runs.
|
|
23
|
+
historyScanEntries: 200,
|
|
24
|
+
historyPage: 20,
|
|
25
|
+
historyScans: 16,
|
|
26
|
+
historyIdleMs: 120000,
|
|
23
27
|
durationMs: 90 * 60 * 1000,
|
|
24
28
|
} as const;
|
|
25
29
|
export interface WorkflowCheck {
|
|
@@ -117,7 +121,22 @@ export type WorkflowResponse =
|
|
|
117
121
|
}
|
|
118
122
|
| { type: "run"; run: WorkflowRun };
|
|
119
123
|
|
|
120
|
-
|
|
124
|
+
/** Clip by UTF-16 units without leaving a lone surrogate (unencodable on the wire). */
|
|
125
|
+
export function clipUnits(value: string, units: number): string {
|
|
126
|
+
if (value.length <= units) return value;
|
|
127
|
+
const last = value.charCodeAt(units - 1);
|
|
128
|
+
return value.slice(0, last >= 0xd800 && last <= 0xdbff ? units - 1 : units);
|
|
129
|
+
}
|
|
130
|
+
/** A declared write path owns itself and, as a directory, everything below it. */
|
|
131
|
+
export function workflowCovers(
|
|
132
|
+
scope: readonly string[],
|
|
133
|
+
name: string,
|
|
134
|
+
): boolean {
|
|
135
|
+
return scope.some((p) => name === p || name.startsWith(`${p}/`));
|
|
136
|
+
}
|
|
137
|
+
/** Read decoding accepts every path 2.0.21 accepted; `strict` (new plans only)
|
|
138
|
+
* additionally refuses invisible format characters. */
|
|
139
|
+
export function workflowPath(v: unknown, strict = false): string {
|
|
121
140
|
const p = text(v, 1024, true);
|
|
122
141
|
if (
|
|
123
142
|
p.startsWith("/") ||
|
|
@@ -125,6 +144,9 @@ export function workflowPath(v: unknown): string {
|
|
|
125
144
|
[...p].some(
|
|
126
145
|
(c) => c.charCodeAt(0) < 32 || c.charCodeAt(0) === 127 || c === ":",
|
|
127
146
|
) ||
|
|
147
|
+
// Bidi overrides/isolates/marks, zero-width and other format characters
|
|
148
|
+
// make a displayed scope differ from the enforced one.
|
|
149
|
+
(strict && /[\p{Cf}\p{Zl}\p{Zp}]/u.test(p)) ||
|
|
128
150
|
p
|
|
129
151
|
.split("/")
|
|
130
152
|
.some(
|
|
@@ -135,9 +157,12 @@ export function workflowPath(v: unknown): string {
|
|
|
135
157
|
throw new Error("Invalid workflow file path");
|
|
136
158
|
return p;
|
|
137
159
|
}
|
|
138
|
-
|
|
160
|
+
// Task IDs are worker assignment IDs and worktree names. New plans use the
|
|
161
|
+
// assignmentId bound (48); reads still accept retained 2.0.21 IDs (64).
|
|
162
|
+
const taskId = (v: unknown, strict = false) => {
|
|
139
163
|
const s = text(v, 64, true);
|
|
140
|
-
if (!/^[a-z][a-z0-9-]*$/u.test(s)
|
|
164
|
+
if (!/^[a-z][a-z0-9-]*$/u.test(s) || (strict && s.length > 48))
|
|
165
|
+
throw new Error("Invalid task id");
|
|
141
166
|
return s;
|
|
142
167
|
};
|
|
143
168
|
export function decodeWorkflowCheck(v: unknown): WorkflowCheck {
|
|
@@ -180,7 +205,13 @@ export function workflowAncestors(
|
|
|
180
205
|
visit(id);
|
|
181
206
|
return workflowOrder(tasks).filter((t) => needed.has(t.id));
|
|
182
207
|
}
|
|
183
|
-
|
|
208
|
+
/** Retained plans decode with the rules they were accepted under; `strict` is
|
|
209
|
+
* for validating a new plan before publication or execution. */
|
|
210
|
+
export function decodeWorkflowPlan(
|
|
211
|
+
v: unknown,
|
|
212
|
+
options: { strict?: boolean } = {},
|
|
213
|
+
): WorkflowPlan {
|
|
214
|
+
const strict = options.strict === true;
|
|
184
215
|
canonicalJson(v, WORKFLOW_LIMITS.bytes);
|
|
185
216
|
const o = closed(v, [
|
|
186
217
|
"goal",
|
|
@@ -198,11 +229,13 @@ export function decodeWorkflowPlan(v: unknown): WorkflowPlan {
|
|
|
198
229
|
const tasks = list(o.tasks, WORKFLOW_LIMITS.tasks, (value) => {
|
|
199
230
|
const t = closed(value, ["id", "title", "instructions", "writes", "after"]);
|
|
200
231
|
return {
|
|
201
|
-
id: taskId(t.id),
|
|
232
|
+
id: taskId(t.id, strict),
|
|
202
233
|
title: text(t.title, 256, true),
|
|
203
234
|
instructions: text(t.instructions, 8192, true),
|
|
204
|
-
writes: list(t.writes, 128, workflowPath),
|
|
205
|
-
after: list(t.after, WORKFLOW_LIMITS.tasks,
|
|
235
|
+
writes: list(t.writes, 128, (p: unknown) => workflowPath(p, strict)),
|
|
236
|
+
after: list(t.after, WORKFLOW_LIMITS.tasks, (id: unknown) =>
|
|
237
|
+
taskId(id, strict),
|
|
238
|
+
),
|
|
206
239
|
};
|
|
207
240
|
});
|
|
208
241
|
if (
|
|
@@ -225,11 +258,8 @@ export function decodeWorkflowPlan(v: unknown): WorkflowPlan {
|
|
|
225
258
|
)
|
|
226
259
|
continue;
|
|
227
260
|
if (
|
|
228
|
-
a.writes.some((p) =>
|
|
229
|
-
|
|
230
|
-
(q) => p === q || p.startsWith(`${q}/`) || q.startsWith(`${p}/`),
|
|
231
|
-
),
|
|
232
|
-
)
|
|
261
|
+
a.writes.some((p) => workflowCovers(b.writes, p)) ||
|
|
262
|
+
b.writes.some((q) => workflowCovers(a.writes, q))
|
|
233
263
|
)
|
|
234
264
|
throw new Error(
|
|
235
265
|
"Independent tasks share write paths; assign an owner and dependency",
|
|
@@ -3,12 +3,11 @@ import { opendirSync } from "node:fs";
|
|
|
3
3
|
import { hostname } from "node:os";
|
|
4
4
|
import { dirname, isAbsolute, join, relative, sep } from "node:path";
|
|
5
5
|
import {
|
|
6
|
-
type CheckoutLock,
|
|
7
6
|
canonicalAmbientRoot,
|
|
8
7
|
defaultStateHome,
|
|
9
8
|
resolveWorkspace,
|
|
10
|
-
|
|
11
|
-
} from "
|
|
9
|
+
} from "../workspace.ts";
|
|
10
|
+
import { type CheckoutLock, CheckoutStore } from "./checkout-lock.ts";
|
|
12
11
|
import {
|
|
13
12
|
ContractError,
|
|
14
13
|
closed,
|
|
@@ -247,7 +246,7 @@ export type CoordinationStatus =
|
|
|
247
246
|
* task creation, stale reclaim or accepting execution route lives here.
|
|
248
247
|
*/
|
|
249
248
|
export class ServiceCoordination {
|
|
250
|
-
private readonly project?:
|
|
249
|
+
private readonly project?: CheckoutStore;
|
|
251
250
|
readonly files: PrivateFiles;
|
|
252
251
|
readonly registryDirectory: string;
|
|
253
252
|
readonly stateHome: string;
|
|
@@ -256,7 +255,7 @@ export class ServiceCoordination {
|
|
|
256
255
|
this.project =
|
|
257
256
|
workspace === null
|
|
258
257
|
? undefined
|
|
259
|
-
: new
|
|
258
|
+
: new CheckoutStore(resolveWorkspace(workspace).root, stateHome);
|
|
260
259
|
this.stateHome = this.project
|
|
261
260
|
? dirname(dirname(this.project.privateRoot))
|
|
262
261
|
: canonicalAmbientRoot(stateHome ?? defaultStateHome());
|
|
@@ -264,7 +263,7 @@ export class ServiceCoordination {
|
|
|
264
263
|
this.files = new PrivateFiles(namespace);
|
|
265
264
|
this.registryDirectory = join(namespace, "service-registry-v1");
|
|
266
265
|
}
|
|
267
|
-
get store():
|
|
266
|
+
get store(): CheckoutStore {
|
|
268
267
|
if (!this.project) throw new ContractError("forbidden");
|
|
269
268
|
return this.project;
|
|
270
269
|
}
|
|
@@ -1079,7 +1078,7 @@ export class ServiceCoordination {
|
|
|
1079
1078
|
}
|
|
1080
1079
|
|
|
1081
1080
|
/** Held only by the original owner. Raw-byte AND inode/time identities supplement
|
|
1082
|
-
*
|
|
1081
|
+
* CheckoutStore's semantic lock assertion, including whitespace-only interference. */
|
|
1083
1082
|
export class OwnerLease {
|
|
1084
1083
|
private released = false;
|
|
1085
1084
|
constructor(
|
|
@@ -14,7 +14,8 @@ import {
|
|
|
14
14
|
writeFileSync,
|
|
15
15
|
} from "node:fs";
|
|
16
16
|
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
17
|
-
import { retryWindowsFileOperation, safeDirectory } from "../
|
|
17
|
+
import { retryWindowsFileOperation, safeDirectory } from "../workspace.ts";
|
|
18
|
+
|
|
18
19
|
import { ContractError, parseWireJson } from "./contracts/core.ts";
|
|
19
20
|
|
|
20
21
|
export const METADATA_BYTES = 16 * 1024;
|