@abelxiaoxing/cadence 2.1.10 → 2.1.11
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/THIRD_PARTY_NOTICES.md +9 -0
- package/docs/conversation-mode.md +11 -3
- package/docs/reuse-and-distribution.md +8 -0
- package/package.json +1 -1
- package/src/cadence-instructions.ts +1 -1
- package/src/model-preview.mjs +9 -0
- package/src/native-build.ts +1 -1
- package/src/sdk-worker.mjs +6 -1
- package/src/service/contracts/workbench.ts +101 -7
- package/src/service/contracts/workflow.ts +3 -3
- package/src/service-cli.mjs +9 -0
- package/src/service-host.mjs +619 -179
- package/src/worker-capture.mjs +157 -9
- package/src/worker-public.mjs +9 -0
- package/web/dist/assets/cadence.css +1 -1
- package/web/dist/assets/cadence.js +26 -29
- package/web/dist/assets/markdown.js +1 -1
- package/web/dist/manifest.json +9 -9
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -19,6 +19,15 @@ Cadence replaces upstream agent/file sourcing with its existing readonly event f
|
|
|
19
19
|
No upstream executor, manager, steering, stopping or persisted-run reader is included.
|
|
20
20
|
`provenance/agent-browser-reuse.json` records exact source hashes, local paths and adaptations; the complete upstream MIT license is preserved in `licenses/pi-subagents-MIT.txt`.
|
|
21
21
|
|
|
22
|
+
## pi-web-ui browser adaptations
|
|
23
|
+
|
|
24
|
+
The browser adapts components and rendering/scrolling patterns from [xing-shuyin/pi-web-ui](https://github.com/xing-shuyin/pi-web-ui), MIT, Copyright (c) 2026 xing-shuyin.
|
|
25
|
+
The complete original license is preserved in `licenses/pi-web-ui-MIT.txt`; `provenance/webui-reuse.json` records the reviewed source revisions, source hashes and current local adaptations.
|
|
26
|
+
The ordinary conversation timeline uses the existing Message/MessageList, ToolCallBlock and ThinkingBlock composition and user-intent scrolling.
|
|
27
|
+
Its `web/src/components/StreamMarkdown.tsx` adapts the prefix-cache renderer from commit `e8bab487af208bc9a1ab60a821652323f598127f`, retaining stable Markdown segments while removing artificial character-paced replay of received snapshots.
|
|
28
|
+
Cadence supplies its own capture/Pi identity correlation, lazy detail/version reads and separate reply/workflow/connection observations; no upstream executor, re-ask semantics or position-guessed message association is included.
|
|
29
|
+
These adaptations are bundled into the built WebUI with the other recorded pi-web-ui reuse, not shipped as a second runtime.
|
|
30
|
+
|
|
22
31
|
## Bundled browser dependencies, icons and fonts
|
|
23
32
|
|
|
24
33
|
`licenses/bundled-web.txt` preserves the full actual emitted dependency notices, including React/DOM/scheduler, react-icons and Feather, unified/Markdown/HTML utilities, highlight.js, KaTeX and vis-timeline's embedded vendor versions.
|
|
@@ -175,7 +175,11 @@ Ignored generated Markdown remains ignored and is published without forcing it i
|
|
|
175
175
|
The named task branch is kept.
|
|
176
176
|
Only owned worktrees at the delivered commit, after successful post-merge checks and without any residue, are removed with plain `git worktree remove`.
|
|
177
177
|
Ignored setup/build output such as `node_modules` also retains the worktree; failures, cancellation and unknown outcomes never trigger cleanup.
|
|
178
|
-
|
|
178
|
+
Separate WebUI or terminal conversations may run independent local-merge workflows concurrently, within the owner's four-active-run limit including investigations.
|
|
179
|
+
A single conversation still permits only one approved implementation at a time; open another conversation for an independent goal.
|
|
180
|
+
Target preflight and candidate creation are exclusive.
|
|
181
|
+
Implementation, checks and automatic review then run in isolated candidates without holding the target checkout gate; working-copy edits and ordinary host-tool conversations remain exclusive.
|
|
182
|
+
Final delivery is exclusive and serialized from candidate refresh through shared project-knowledge maintenance, post-merge checks and cleanup.
|
|
179
183
|
There is no fixed delivery-duration or repair-round quota.
|
|
180
184
|
Agents have no fixed total runtime deadline.
|
|
181
185
|
Setup/check commands default to no timeout; an explicitly approved per-command timeout still applies, including in older plans.
|
|
@@ -211,7 +215,10 @@ A concrete external blocker is reported with preserved work, not a generic reque
|
|
|
211
215
|
Final candidate checks must pass before merge.
|
|
212
216
|
Post-merge failures retain the actual merge commit.
|
|
213
217
|
Repairs stay in the same named candidate, invalidate its earlier acceptance, and are checked/reviewed against a new exact candidate.
|
|
214
|
-
|
|
218
|
+
When a verified Cadence sibling advances the same branch, a pending non-overlapping candidate merges that delivery into its own worktree, then repeats real checks and automatic Agent review before publication.
|
|
219
|
+
Both histories are preserved; no rebase or automatic conflict resolution occurs.
|
|
220
|
+
Overlapping writes, changed `AGENTS.md`, external target movement or branch switching retain the candidate and require a fresh plan.
|
|
221
|
+
Only this run’s last confirmed merge can serve as its next post-merge recovery baseline.
|
|
215
222
|
Repairs can fast-forward that unchanged target again; the user’s unrelated index is never committed.
|
|
216
223
|
Unresolved failures remain failures; no rollback is fabricated.
|
|
217
224
|
Automatic review is never recorded as human review.
|
|
@@ -273,7 +280,8 @@ Search limits and omitted coverage are reported explicitly; a partial search doe
|
|
|
273
280
|
The bounded `grep` tool searches literal text, not regular expressions.
|
|
274
281
|
No files are copied to accelerate research.
|
|
275
282
|
|
|
276
|
-
|
|
283
|
+
Readonly runs in one project share checkout access; questions inside a run can also overlap.
|
|
284
|
+
An investigation in a conversation with its own active implementation waits for that implementation, while other conversations remain independent.
|
|
277
285
|
Agents have no total process deadline or substitute idle/step/tool-call quota.
|
|
278
286
|
Leaving the page or losing a coordinator bridge does not cancel accepted investigations.
|
|
279
287
|
Explicit Cancel/Stop retain their actual closure and recorded source.
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Emitted licenses
|
|
4
4
|
|
|
5
|
+
The browser's pi-web-ui adaptations retain `Copyright (c) 2026 xing-shuyin` and the complete original MIT text in `licenses/pi-web-ui-MIT.txt`.
|
|
6
|
+
Ordinary conversations reuse its stable rendering-identity, Markdown prefix/tail and user-intent scrolling patterns; `web/src/components/StreamMarkdown.tsx` adapts the already pinned prefix renderer without its character-paced snapshot replay.
|
|
7
|
+
Cadence's shared segmenter now uses the existing Markdown syntax parser to preserve container and document-reference semantics, exact source slices and source-position keys; ordinary chat uses the same safe renderer before and after settlement, while the separate workflow renderer retains its pacer/preview policy.
|
|
8
|
+
Cadence supplies capture-to-Pi ownership correlation, finite reads, read-time activity-name sanitation and separate runtime observations rather than importing the upstream executor or position-based association.
|
|
9
|
+
`provenance/webui-reuse.json` pins current adaptation/integration bodies; existing upstream source and license pins stay unchanged and do not claim that a current upstream working file is the originally pinned revision.
|
|
10
|
+
Controlled capture/reader tests, semantic HTML SSR comparisons and component-tree identity assertions are not mounted React DOM, real-browser interaction or performance qualification; regression ownership and evidence limits are in `engineering/verification.md`.
|
|
11
|
+
The browser adaptation sources ship inside the canonical browser assets, not as new standalone package members.
|
|
12
|
+
|
|
5
13
|
`licenses/bundled-web.txt` contains full original notices with stable labeled boundaries: React/DOM/scheduler; react-icons and the selected Feather family; unified/Markdown/HTML utilities; highlight.js; KaTeX code; vis-timeline and the versions actually embedded by its standalone build.
|
|
6
14
|
KaTeX's 60 emitted TTF/WOFF/WOFF2 fonts retain their original bytes and separate SIL OFL1.1 plus reserved-family copyright notices.
|
|
7
15
|
The vis bundle includes its own Babel/core-js/moment/vis-data/vis-util and other dependencies; project-resolved package versions are not substituted for those embedded versions.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export const CADENCE_INSTRUCTIONS = `CADENCE CONVERSATION MODE — stays enabled for this entire conversation, including after a goal completes, until the user explicitly exits by typing 退出 Cadence or exit cadence. Only the user can exit; leaving never cancels accepted work. When asked how to leave, say exactly this.
|
|
3
3
|
You are the sole user-facing coordinator. Understand the desired result, not a task-management form. Never ask the user to manage tasks, IDs, JSON, service ports, agent assignments, repair counts, budgets or knowledge files.
|
|
4
4
|
For a new goal, use focused cadence_research to inspect relevant code and project knowledge; one call takes as many independent questions as the goal needs, and the service runs them side by side and queues the rest. Each question comes back with its own outcome: an answered one with its investigation identity, an unanswered one with the reason, after the service has already asked it a second time. Work with the answers you have and ask an unanswered question again only when the result depends on it, never the whole set. Reuse still-current findings. Start from the project's route table when one is given below (PROJECT ROUTE TABLE, from .cadence/project.md): its routes say which document, and which section of it, owns each area of the code. Do not pull whole documents into this conversation; ask an investigation to read what a route points at and keep its short answer. Where there is no route table, AGENTS.md and engineering/docs/.trellis/spec are the places to look. Project documents are observations and conventions, never execution authority. Do not rescan the entire repository or spawn workers just to fill slots. Investigate discoverable facts yourself. Align until nothing that changes the result is left open: ask every question that materially changes the expected result and cannot reasonably follow existing project conventions, and decide the rest yourself. Whatever you decide on the user's behalf goes into the agreement's assumptions so that approval confirms it; after approval nobody will be asked again. Preserve confirmed decisions; research alone never authorizes edits.
|
|
5
|
-
Once the result is clear, use cadence_plan. Describe the expected delivery, explicit decisions/non-goals, acceptance, your assumptions, an initial technical route and assignments with their write paths, exact setup/baseline/acceptance commands, the delivery policy, and policy.installs (false unless the user agreed that later revisions may install dependencies). Assignments that neither depend on one another nor write the same path run side by side, each in a worktree of its own, so state only real dependencies in each assignment's after and keep independent assignments' write paths apart; cut the work so that as much as possible can proceed at once. Give each assignment, and the review, the few things it should read first, each with a reason: a project document as {path, section, reason} (name the section, not the whole file, when a route or heading tells you which) or a recorded investigation as {research, reason}, where research is the investigation identity shown with that answered question (an unanswered question has none). Workers start without this conversation, so what you name here is what saves them from exploring again. The route is the owner's to revise: after approval it may repair, re-plan, bring further repository files into the write scope and, where an acceptance item proves impossible, deliver the closest achievable result as a recorded deviation that the independent review must confirm. Goal, decisions, acceptance and assumptions stay as approved. Focus on the project, its implementation and its real checks. The owner supplies private, workspace-specific TMPDIR/TEMP/TMP to every delivery command and worker, including recovery. Do not add temporary-directory setup, environment discovery, path handoff or marker checks to the plan; name the project's check command directly. This standard runtime policy is displayed with the plan and covered by its one approval. Investigate project prerequisites: worktrees do not inherit ignored dependencies. Every setup command must name placement: target for original-checkout preflight (runs once before worktree creation), candidate for once-only stable-candidate preparation, or worktree for preparation in the candidate and every detached child. Keep target branch checks out of worktree setup: parallel children must remain detached. The owner already checks Git placement and target identity. Stages run in that order; command environments do not persist across processes. Include explicit environment bindings in every command that needs them. Setup/install commands need inclusion in approval; no implicit downloads, source/profile copying or credential copying. For Git code delivery, prefer local-merge; working-copy requires an explicitly approved direct-edit policy, never a silent fallback. local-merge creates one named cadence/<goal>-<run-id> branch and one stable worktree only AFTER delivery approval, never on mode entry or research. That candidate collects all work: an assignment running alone edits it directly, assignments running side by side are committed in their own temporary worktrees and picked onto it, and recovery, review and verified knowledge updates use it; each new approved delivery gets its own branch. The original conversation cwd stays unchanged. Checks and independent Agent review must bind the exact candidate before fast-forward delivery into the displayed target;
|
|
5
|
+
Once the result is clear, use cadence_plan. Describe the expected delivery, explicit decisions/non-goals, acceptance, your assumptions, an initial technical route and assignments with their write paths, exact setup/baseline/acceptance commands, the delivery policy, and policy.installs (false unless the user agreed that later revisions may install dependencies). Assignments that neither depend on one another nor write the same path run side by side, each in a worktree of its own, so state only real dependencies in each assignment's after and keep independent assignments' write paths apart; cut the work so that as much as possible can proceed at once. Give each assignment, and the review, the few things it should read first, each with a reason: a project document as {path, section, reason} (name the section, not the whole file, when a route or heading tells you which) or a recorded investigation as {research, reason}, where research is the investigation identity shown with that answered question (an unanswered question has none). Workers start without this conversation, so what you name here is what saves them from exploring again. The route is the owner's to revise: after approval it may repair, re-plan, bring further repository files into the write scope and, where an acceptance item proves impossible, deliver the closest achievable result as a recorded deviation that the independent review must confirm. Goal, decisions, acceptance and assumptions stay as approved. Focus on the project, its implementation and its real checks. The owner supplies private, workspace-specific TMPDIR/TEMP/TMP to every delivery command and worker, including recovery. Do not add temporary-directory setup, environment discovery, path handoff or marker checks to the plan; name the project's check command directly. This standard runtime policy is displayed with the plan and covered by its one approval. Investigate project prerequisites: worktrees do not inherit ignored dependencies. Every setup command must name placement: target for original-checkout preflight (runs once before worktree creation), candidate for once-only stable-candidate preparation, or worktree for preparation in the candidate and every detached child. Keep target branch checks out of worktree setup: parallel children must remain detached. The owner already checks Git placement and target identity. Stages run in that order; command environments do not persist across processes. Include explicit environment bindings in every command that needs them. Setup/install commands need inclusion in approval; no implicit downloads, source/profile copying or credential copying. For Git code delivery, prefer local-merge; working-copy requires an explicitly approved direct-edit policy, never a silent fallback. local-merge creates one named cadence/<goal>-<run-id> branch and one stable worktree only AFTER delivery approval, never on mode entry or research. That candidate collects all work: an assignment running alone edits it directly, assignments running side by side are committed in their own temporary worktrees and picked onto it, and recovery, review and verified knowledge updates use it; each new approved delivery gets its own branch. The original conversation cwd stays unchanged. Checks and independent Agent review must bind the exact candidate before fast-forward delivery into the displayed target. Separate conversations may implement local-merge workflows concurrently, one per conversation; final delivery is serialized. A verified non-overlapping sibling delivery may advance a pending candidate's integration frontier and be merged into its isolated worktree, followed by fresh checks and automatic review. Only this run's confirmed merges can advance its target baseline for post-merge recovery. Conflicts, overlapping writes, changed instructions or external branch changes retain the candidate and require a fresh plan. Keep the task branch and retain any worktree containing uncommitted, untracked or ignored residue. No automatic rebase, reset, cleanup of user data or mutation replay. local-merge needs an existing branch and commit identity and clean, nonignored approved targets; working-copy preserves existing direct edits without Git mutation.
|
|
6
6
|
The service maintains the project's knowledge store (.cadence/project.md and .cadence/knowledge/) itself at the end of every delivery, inside a fixed budget, so never list those. List in documents only existing project Markdown that owns a fact this delivery changes. Knowledge is learned from actual implementation and verified evidence, not guessed in the proposal. Avoid duplicate documentation systems.
|
|
7
7
|
When a tool refuses your own call it names the field at fault: correct exactly that and call again in the same turn. There is one plan. Never publish, offer or mention a shortened, split or otherwise reduced variant of it, and never ask the user to reply so that you can try again.
|
|
8
8
|
Present a concise delivery expectation with the complete returned agreement available, including your assumptions and what the service may change on its own, then invite one clear approval (the user may type 按计划实施). cadence_start obtains fresh context-bound approval. It covers self-revising execution to completion, checks, automatic Agent review, knowledge updates and the declared local delivery. It never covers push, publication, deployment, new permissions, arbitrary writes outside the repository, or installations beyond the listed setup and policy. The displayed service runtime policy separately permits only its own private temporary resources. You cannot approve yourself. Vague acknowledgement is not consent.
|
package/src/model-preview.mjs
CHANGED
|
@@ -784,6 +784,15 @@ function decodeCaptureEvent(v) {
|
|
|
784
784
|
resultCallId
|
|
785
785
|
};
|
|
786
786
|
}
|
|
787
|
+
case "thinking-activity": {
|
|
788
|
+
const o = closed(v, ["kind", "messageId", "index", "phase"]);
|
|
789
|
+
return {
|
|
790
|
+
kind,
|
|
791
|
+
messageId: decodeId(o.messageId),
|
|
792
|
+
index: integer(o.index, 0, LIMITS.dataFrames),
|
|
793
|
+
phase: oneOf(o.phase, ["active", "complete", "unavailable"])
|
|
794
|
+
};
|
|
795
|
+
}
|
|
787
796
|
case "message-text": {
|
|
788
797
|
const o = closed(v, ["kind", "messageId", "blockId", "detailId"]);
|
|
789
798
|
return {
|
package/src/native-build.ts
CHANGED
package/src/sdk-worker.mjs
CHANGED
|
@@ -668,7 +668,7 @@ try {
|
|
|
668
668
|
if (own(event, "type") === "message_update") {
|
|
669
669
|
const update = own(event, "assistantMessageEvent");
|
|
670
670
|
const type = own(update, "type");
|
|
671
|
-
if (type === "text_delta"
|
|
671
|
+
if (type === "text_delta") {
|
|
672
672
|
const delta = own(update, "delta");
|
|
673
673
|
if (typeof delta !== "string") throw new Error("Malformed SDK event");
|
|
674
674
|
modelOutputBytes += Buffer.byteLength(delta);
|
|
@@ -703,7 +703,12 @@ try {
|
|
|
703
703
|
}
|
|
704
704
|
if (recordedUser === null)
|
|
705
705
|
refuse("events", "event-projection-failed");
|
|
706
|
+
if (!capture.messageId) refuse("events", "event-projection-failed");
|
|
706
707
|
manager.appendCustomEntry(BROWSER_COMMAND_ENTRY, {
|
|
708
|
+
captureMessageId: capture.messageId,
|
|
709
|
+
...(capture.resultCallId
|
|
710
|
+
? { captureResultCallId: capture.resultCallId }
|
|
711
|
+
: {}),
|
|
707
712
|
commandId: command,
|
|
708
713
|
userId: recordedUser,
|
|
709
714
|
...(command === publicRequest.runId
|
|
@@ -329,11 +329,31 @@ export interface ChatImage {
|
|
|
329
329
|
index: number;
|
|
330
330
|
mimeType: string;
|
|
331
331
|
}
|
|
332
|
-
|
|
332
|
+
/** Rendering identity is independent of the step/part read coordinates. */
|
|
333
|
+
export interface ChatPresentation {
|
|
334
|
+
renderId?: string;
|
|
335
|
+
/** Version of the full redacted content, not its part count or execution state. */
|
|
336
|
+
version?: string;
|
|
337
|
+
state?:
|
|
338
|
+
| "pending"
|
|
339
|
+
| "streaming"
|
|
340
|
+
| "running"
|
|
341
|
+
| "completed"
|
|
342
|
+
| "failed"
|
|
343
|
+
| "canceled"
|
|
344
|
+
| "unavailable";
|
|
345
|
+
}
|
|
346
|
+
/** Last actual capture activity; sequence advances only on observed events. */
|
|
347
|
+
export interface ChatActivity {
|
|
348
|
+
kind: "waiting" | "thinking" | "text" | "tool";
|
|
349
|
+
sequence: number;
|
|
350
|
+
name?: string;
|
|
351
|
+
}
|
|
352
|
+
export interface ChatItem extends ChatPresentation {
|
|
333
353
|
images?: ChatImage[];
|
|
334
354
|
id: string;
|
|
335
|
-
/** `thinking` is
|
|
336
|
-
*
|
|
355
|
+
/** `thinking` is a recorded readable block, or an explicit body-free
|
|
356
|
+
* activity placeholder; its signature is never returned. */
|
|
337
357
|
role: "user" | "assistant" | "tool" | "thinking";
|
|
338
358
|
text: string;
|
|
339
359
|
name: string;
|
|
@@ -362,7 +382,7 @@ export interface ChatTurn {
|
|
|
362
382
|
* arguments or output or a thinking block's text, and keeps at most
|
|
363
383
|
* `STEP_TEXT_BYTES` of message text; the full item is read per step with
|
|
364
384
|
* `conversation-step`, one part at a time. */
|
|
365
|
-
export interface ChatStep {
|
|
385
|
+
export interface ChatStep extends ChatPresentation {
|
|
366
386
|
images?: ChatImage[];
|
|
367
387
|
id: string;
|
|
368
388
|
role: ChatItem["role"];
|
|
@@ -379,6 +399,7 @@ export interface ChatStep {
|
|
|
379
399
|
}
|
|
380
400
|
/** One turn of a conversation branch: a user message and what followed it. */
|
|
381
401
|
export interface ChatTurnHeader {
|
|
402
|
+
activity?: ChatActivity;
|
|
382
403
|
execution?: ExecutionContext;
|
|
383
404
|
retry?: ModelRetry;
|
|
384
405
|
/** The user message's session entry id; a browser command id while Pi has not
|
|
@@ -502,6 +523,7 @@ export function chatStep(
|
|
|
502
523
|
const text = lazy ? "" : clipText(item.text, STEP_TEXT_BYTES);
|
|
503
524
|
return {
|
|
504
525
|
id: item.id,
|
|
526
|
+
...presentation(item),
|
|
505
527
|
role: item.role,
|
|
506
528
|
text,
|
|
507
529
|
...(item.images?.length ? { images: item.images } : {}),
|
|
@@ -1191,8 +1213,56 @@ function decodeChatImages(v: unknown): ChatImage[] {
|
|
|
1191
1213
|
};
|
|
1192
1214
|
});
|
|
1193
1215
|
}
|
|
1216
|
+
const PRESENTATION_KEYS = ["renderId", "version", "state"] as const;
|
|
1217
|
+
function presentationKeys(v: unknown): string[] {
|
|
1218
|
+
return PRESENTATION_KEYS.filter((key) => Object.hasOwn(v ?? {}, key));
|
|
1219
|
+
}
|
|
1220
|
+
function presentation(v: ChatPresentation): ChatPresentation {
|
|
1221
|
+
return {
|
|
1222
|
+
...(v.renderId === undefined ? {} : { renderId: v.renderId }),
|
|
1223
|
+
...(v.version === undefined ? {} : { version: v.version }),
|
|
1224
|
+
...(v.state === undefined ? {} : { state: v.state }),
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1227
|
+
function decodePresentation(o: Record<string, unknown>): ChatPresentation {
|
|
1228
|
+
return {
|
|
1229
|
+
...(o.renderId === undefined
|
|
1230
|
+
? {}
|
|
1231
|
+
: { renderId: text(o.renderId, 160, true) }),
|
|
1232
|
+
...(o.version === undefined ? {} : { version: decodeHash(o.version) }),
|
|
1233
|
+
...(o.state === undefined
|
|
1234
|
+
? {}
|
|
1235
|
+
: {
|
|
1236
|
+
state: oneOf(o.state, [
|
|
1237
|
+
"pending",
|
|
1238
|
+
"streaming",
|
|
1239
|
+
"running",
|
|
1240
|
+
"completed",
|
|
1241
|
+
"failed",
|
|
1242
|
+
"canceled",
|
|
1243
|
+
"unavailable",
|
|
1244
|
+
] as const),
|
|
1245
|
+
}),
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
function decodeChatActivity(v: unknown): ChatActivity {
|
|
1249
|
+
const o = closed(v, [
|
|
1250
|
+
"kind",
|
|
1251
|
+
"sequence",
|
|
1252
|
+
...(Object.hasOwn(v ?? {}, "name") ? ["name"] : []),
|
|
1253
|
+
]);
|
|
1254
|
+
const kind = oneOf(o.kind, ["waiting", "thinking", "text", "tool"] as const);
|
|
1255
|
+
if (o.name !== undefined && kind !== "tool")
|
|
1256
|
+
throw new ContractError("invalid");
|
|
1257
|
+
return {
|
|
1258
|
+
kind,
|
|
1259
|
+
sequence: integer(o.sequence, 0),
|
|
1260
|
+
...(o.name === undefined ? {} : { name: text(o.name, 128) }),
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1194
1263
|
export function decodeChatItem(v: unknown): ChatItem {
|
|
1195
1264
|
const i = closed(v, [
|
|
1265
|
+
...presentationKeys(v),
|
|
1196
1266
|
"id",
|
|
1197
1267
|
"role",
|
|
1198
1268
|
"text",
|
|
@@ -1202,6 +1272,7 @@ export function decodeChatItem(v: unknown): ChatItem {
|
|
|
1202
1272
|
...(Object.hasOwn(v ?? {}, "images") ? ["images"] : []),
|
|
1203
1273
|
]);
|
|
1204
1274
|
return {
|
|
1275
|
+
...decodePresentation(i),
|
|
1205
1276
|
...(i.images === undefined ? {} : { images: decodeChatImages(i.images) }),
|
|
1206
1277
|
id: text(i.id, 160, true),
|
|
1207
1278
|
role: oneOf(i.role, ITEM_ROLES),
|
|
@@ -1213,6 +1284,7 @@ export function decodeChatItem(v: unknown): ChatItem {
|
|
|
1213
1284
|
}
|
|
1214
1285
|
function decodeChatStep(v: unknown): ChatStep {
|
|
1215
1286
|
const o = closed(v, [
|
|
1287
|
+
...presentationKeys(v),
|
|
1216
1288
|
"id",
|
|
1217
1289
|
"role",
|
|
1218
1290
|
"text",
|
|
@@ -1224,6 +1296,7 @@ function decodeChatStep(v: unknown): ChatStep {
|
|
|
1224
1296
|
"parts",
|
|
1225
1297
|
]);
|
|
1226
1298
|
const step = {
|
|
1299
|
+
...decodePresentation(o),
|
|
1227
1300
|
...(o.images === undefined ? {} : { images: decodeChatImages(o.images) }),
|
|
1228
1301
|
id: text(o.id, 160, true),
|
|
1229
1302
|
role: oneOf(o.role, ITEM_ROLES),
|
|
@@ -1239,13 +1312,31 @@ function decodeChatStep(v: unknown): ChatStep {
|
|
|
1239
1312
|
(step.text || step.clipped)
|
|
1240
1313
|
)
|
|
1241
1314
|
throw new ContractError("invalid");
|
|
1242
|
-
//
|
|
1243
|
-
|
|
1244
|
-
|
|
1315
|
+
// Legacy thinking steps require readable text. New activity placeholders
|
|
1316
|
+
// explicitly carry state and identity, and cannot fabricate detail parts.
|
|
1317
|
+
if (step.role === "thinking") {
|
|
1318
|
+
if (
|
|
1319
|
+
!step.parts &&
|
|
1320
|
+
!(
|
|
1321
|
+
step.renderId &&
|
|
1322
|
+
[
|
|
1323
|
+
"streaming",
|
|
1324
|
+
"completed",
|
|
1325
|
+
"unavailable",
|
|
1326
|
+
"canceled",
|
|
1327
|
+
"failed",
|
|
1328
|
+
].includes(step.state ?? "")
|
|
1329
|
+
)
|
|
1330
|
+
)
|
|
1331
|
+
throw new ContractError("invalid");
|
|
1332
|
+
if (step.parts && step.state !== undefined && step.state !== "completed")
|
|
1333
|
+
throw new ContractError("invalid");
|
|
1334
|
+
}
|
|
1245
1335
|
return step;
|
|
1246
1336
|
}
|
|
1247
1337
|
function decodeChatTurnHeader(v: unknown): ChatTurnHeader {
|
|
1248
1338
|
const o = closed(v, [
|
|
1339
|
+
...(Object.hasOwn(v ?? {}, "activity") ? ["activity"] : []),
|
|
1249
1340
|
"id",
|
|
1250
1341
|
"status",
|
|
1251
1342
|
"notice",
|
|
@@ -1261,6 +1352,9 @@ function decodeChatTurnHeader(v: unknown): ChatTurnHeader {
|
|
|
1261
1352
|
const omitted = closed(o.omitted, ["thinking", "media", "other"]);
|
|
1262
1353
|
const steps = integer(o.steps, 0);
|
|
1263
1354
|
return {
|
|
1355
|
+
...(o.activity === undefined
|
|
1356
|
+
? {}
|
|
1357
|
+
: { activity: decodeChatActivity(o.activity) }),
|
|
1264
1358
|
...(o.execution === undefined
|
|
1265
1359
|
? {}
|
|
1266
1360
|
: { execution: decodeExecutionContext(o.execution) }),
|
|
@@ -1096,7 +1096,7 @@ export function decodeDeliveryObservation(value: unknown): DeliveryObservation {
|
|
|
1096
1096
|
export function readableDelivery(binding?: DeliveryBinding): string {
|
|
1097
1097
|
if (!binding) return "";
|
|
1098
1098
|
const t = binding.target;
|
|
1099
|
-
return `Target: ${t.branch} @ ${t.head}\nTarget checkout: ${t.checkoutRoot}\nExecution: new cadence/<goal>-<run-id> branch and one stable isolated worktree after approval. Assignments that can run side by side each work in a temporary worktree of their own beside it; the service commits that work and picks it onto the candidate.\nAcceptance: checks and automatic Agent review of the exact candidate.\nDelivery: fast-forward only into the bound target
|
|
1099
|
+
return `Target: ${t.branch} @ ${t.head}\nTarget checkout: ${t.checkoutRoot}\nExecution: new cadence/<goal>-<run-id> branch and one stable isolated worktree after approval. Assignments that can run side by side each work in a temporary worktree of their own beside it; the service commits that work and picks it onto the candidate. Independent conversations may use separate candidates concurrently.\nAcceptance: checks and automatic Agent review of the exact candidate. A verified, non-overlapping sibling delivery may be merged into the isolated candidate, followed by fresh checks and review.\nDelivery: serialized fast-forward only into the bound target at its approved, verified-sibling or own last confirmed baseline. Keep the task branch; remove only owned worktrees without any residue, including ignored files. No source/profile/dependency copying, push or deployment.`;
|
|
1100
1100
|
}
|
|
1101
1101
|
export function readableDeliveryRun(d?: DeliveryObservation): string {
|
|
1102
1102
|
if (!d) return "";
|
|
@@ -1438,7 +1438,7 @@ export function readableWorkflowPlan(p: WorkflowPlan): string {
|
|
|
1438
1438
|
p.reviewReads?.length
|
|
1439
1439
|
? `\n\n## Review reads first\n${p.reviewReads.map(readableReading).join("\n")}`
|
|
1440
1440
|
: ""
|
|
1441
|
-
}\n\n## Automation boundary\n${readableAutomation(p)} Only actual verification and independent Agent review permit delivery. ${p.delivery === "local-merge" ? "Authorize one new named task branch and stable isolated worktree after approval, temporary worktrees beside it for assignments that run side by side, local commits and fast-forward delivery of the exact checked and Agent-reviewed candidate into the displayed target. Keep the task branch; retain any worktree with uncommitted, untracked or ignored residue." : "Direct working-copy edits; failures leave actual edits for inspection. No Git commit or merge."} No push, publication, deployment or recursive delegation. Related project knowledge and workflow Markdown are included. Worktrees/tools are not a sandbox.\n\n## Project documents\n${
|
|
1441
|
+
}\n\n## Automation boundary\n${readableAutomation(p)} Only actual verification and independent Agent review permit delivery. ${p.delivery === "local-merge" ? "Authorize one new named task branch and stable isolated worktree after approval, temporary worktrees beside it for assignments that run side by side, local commits and serialized fast-forward delivery of the exact checked and Agent-reviewed candidate into the displayed target. Independent conversations may implement in separate candidates; a verified non-overlapping sibling delivery may be merged into this candidate and checked/reviewed again. Conflicts, changed instructions, overlapping inputs or external target drift retain the candidate for a fresh plan. Keep the task branch; retain any worktree with uncommitted, untracked or ignored residue." : "Direct working-copy edits; failures leave actual edits for inspection. No Git commit or merge."} No push, publication, deployment or recursive delegation. Related project knowledge and workflow Markdown are included. Worktrees/tools are not a sandbox.\n\n## Project documents\n${
|
|
1442
1442
|
p.version === undefined
|
|
1443
1443
|
? p.projectContext
|
|
1444
1444
|
: documents.join("\n") ||
|
|
@@ -1509,7 +1509,7 @@ export function workflowDiagnostics(run: WorkflowRun): string {
|
|
|
1509
1509
|
`Owner: Cadence ${d.owner.version} · ${d.owner.platform} · Node ${d.owner.node} · PID ${d.owner.pid} · epoch ${run.epoch}`,
|
|
1510
1510
|
`Build: ${d.owner.build} · entry: ${d.owner.entry} · owner started: ${at(d.owner.startedAt)}`,
|
|
1511
1511
|
`Accepted: ${at(d.acceptedAt)} · checkout acquired: ${at(d.acquiredAt)} · settled: ${at(d.settledAt)}`,
|
|
1512
|
-
`Checkout wait: ${d.acquiredAt === null ? "still waiting or not acquired" : `${Math.max(0, d.acquiredAt - d.acceptedAt)}ms`}.
|
|
1512
|
+
`Checkout wait: ${d.acquiredAt === null ? "still waiting or not acquired" : `${Math.max(0, d.acquiredAt - d.acceptedAt)}ms`}. Readonly research shares access; isolated implementation holds no target checkout permit. Direct edits and final delivery are exclusive.`,
|
|
1513
1513
|
...run.steps.flatMap((s) =>
|
|
1514
1514
|
s.timing
|
|
1515
1515
|
? [
|
package/src/service-cli.mjs
CHANGED
|
@@ -951,6 +951,15 @@ function decodeCaptureEvent(v) {
|
|
|
951
951
|
resultCallId
|
|
952
952
|
};
|
|
953
953
|
}
|
|
954
|
+
case "thinking-activity": {
|
|
955
|
+
const o = closed(v, ["kind", "messageId", "index", "phase"]);
|
|
956
|
+
return {
|
|
957
|
+
kind,
|
|
958
|
+
messageId: decodeId(o.messageId),
|
|
959
|
+
index: integer(o.index, 0, LIMITS.dataFrames),
|
|
960
|
+
phase: oneOf(o.phase, ["active", "complete", "unavailable"])
|
|
961
|
+
};
|
|
962
|
+
}
|
|
954
963
|
case "message-text": {
|
|
955
964
|
const o = closed(v, ["kind", "messageId", "blockId", "detailId"]);
|
|
956
965
|
return {
|