@abelxiaoxing/cadence 2.1.10 → 2.1.13
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 +12 -4
- package/docs/reuse-and-distribution.md +8 -0
- package/docs/service-management.md +6 -4
- package/package.json +1 -1
- package/src/cadence-instructions.ts +1 -1
- package/src/cadence-mode.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 +107 -9
- package/src/service/contracts/workflow.ts +3 -3
- package/src/service-cli.mjs +9 -0
- package/src/service-client.ts +5 -1
- package/src/service-host.mjs +715 -214
- 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.
|
|
@@ -295,7 +303,7 @@ A revision may also change the assignments that have not started yet (drop, rewr
|
|
|
295
303
|
The unified WebUI sidebar automatically lists active work in this account and state home, including projects you have never selected.
|
|
296
304
|
An interactive terminal must load the Cadence extension: a real model/tool round appears even without `/cadence`, but an idle terminal or idle owner does not.
|
|
297
305
|
Terminal rounds are observe-only; owner turns and workflows retain their actual queue, execution, recovery and settlement phases and existing authorized controls.
|
|
298
|
-
|
|
306
|
+
Separate terminal instances and owner work keep their own rows; work already shown under **Running work** is not repeated.
|
|
299
307
|
|
|
300
308
|
Click an activity to remember its directory and read the shared Pi session at the observed branch.
|
|
301
309
|
This does not start or associate an owner, grant execution consent or expand workbench Stop.
|
|
@@ -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.
|
|
@@ -107,7 +107,7 @@ Install and restart print the private entry link once the owner answers; the JSO
|
|
|
107
107
|
A successful manager start request is not owner readiness: an unready owner reports `quarantined` or `unconfirmed`, retains the separate `managerStatus`, exits nonzero and names `cadence doctor`.
|
|
108
108
|
Status also retains the manager's `active`/`activating`/`failed` observation separately.
|
|
109
109
|
A definition whose project directory was removed gets a readable refusal (exit78, so the unit does not restart in a loop); `cadence server install` switches it to the workbench.
|
|
110
|
-
`restart` rewrites an existing definition with the current Node and package paths, keeping its workspace and the user's disable choices, and starts it; run it after an npm upgrade
|
|
110
|
+
`restart` rewrites an existing definition with the current Node and package paths, keeping its workspace and the user's disable choices, and starts it; run it after an npm upgrade or a Node change.
|
|
111
111
|
The `upgrade` command (Linux) installs the latest version, or exactly `--to VERSION`, with the detected installation's package manager and restarts; see [Restart and upgrade from the WebUI](#restart-and-upgrade-from-the-webui) for its steps.
|
|
112
112
|
Commands that change the service (`install`, `restart`, `stop`, `uninstall`, `upgrade`) refuse with `inside-service` when they run inside the service they would stop, for example from a tool of its own agent: stopping a systemd unit ends every process in it, so the command would die before it started the service again.
|
|
113
113
|
Use the WebUI or a terminal outside the service instead.
|
|
@@ -335,9 +335,11 @@ At sign-out or shutdown Windows ends the owner without orderly Stop: running wor
|
|
|
335
335
|
The conversation model picker offers every thinking level the pinned SDK supports for a model, `off` through `xhigh` and `max`; a model whose `thinkingLevelMap` maps only `max` (as some DeepSeek configurations do) is chosen at `max`, and a child runs only at exactly that level.
|
|
336
336
|
A model whose provider or model ID contains a known credential value is withheld from the catalog, since showing the ID would reveal that value; the catalog says how many models are withheld, and the rest stay selectable.
|
|
337
337
|
Credential values are `auth.json` keys, `models.json` `apiKey` and header values (and the variables they name) and service-environment variables whose names contain `KEY`, `TOKEN`, `SECRET`, `PASS`, `AUTH` or `COOKIE`.
|
|
338
|
-
The common Ollama placeholder `"apiKey": "ollama"` under a provider named `ollama` is such a case: give the placeholder a value that matches no provider or model ID (for example `"local-no-auth"`), then
|
|
339
|
-
|
|
340
|
-
|
|
338
|
+
The common Ollama placeholder `"apiKey": "ollama"` under a provider named `ollama` is such a case: give the placeholder a value that matches no provider or model ID (for example `"local-no-auth"`), then reopen the model picker.
|
|
339
|
+
Opening the conversation model picker reads `models.json` again without restarting the service.
|
|
340
|
+
An invalid edit refuses that read; fix the file and reopen the picker.
|
|
341
|
+
There is no background reload or message replay.
|
|
342
|
+
Saved preferences remain; execution still verifies its pinned model.
|
|
341
343
|
- A foreground owner can be managed from another terminal.
|
|
342
344
|
Ctrl-C, SIGTERM, machine crash or terminal destruction is **not** the authenticated orderly Stop route: running work is interrupted, and the next start recovers the owner automatically.
|
|
343
345
|
A recovered `stopped` registration records that the old owner was proven gone, not that its interrupted work completed.
|
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/cadence-mode.ts
CHANGED
|
@@ -1347,7 +1347,7 @@ export function registerCadenceMode(pi: ExtensionAPI): void {
|
|
|
1347
1347
|
// Preference selection must never block observation/cancellation or the picker.
|
|
1348
1348
|
await connect(ctx, false);
|
|
1349
1349
|
current();
|
|
1350
|
-
const catalog = value(await client().models(undefined, location));
|
|
1350
|
+
const catalog = value(await client().models(undefined, location, true));
|
|
1351
1351
|
current();
|
|
1352
1352
|
const models = catalog.entries.filter(
|
|
1353
1353
|
(m) => m.eligibility === "candidate" && m.api,
|
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
|
|
@@ -100,7 +100,10 @@ export type WorkbenchRead =
|
|
|
100
100
|
offset: number;
|
|
101
101
|
}
|
|
102
102
|
| {
|
|
103
|
-
kind:
|
|
103
|
+
kind:
|
|
104
|
+
| "conversation-context"
|
|
105
|
+
| "conversation-models"
|
|
106
|
+
| "reload-conversation-models";
|
|
104
107
|
location: ConversationLocation;
|
|
105
108
|
}
|
|
106
109
|
| { kind: "cadence-conversation"; id: string }
|
|
@@ -329,11 +332,31 @@ export interface ChatImage {
|
|
|
329
332
|
index: number;
|
|
330
333
|
mimeType: string;
|
|
331
334
|
}
|
|
332
|
-
|
|
335
|
+
/** Rendering identity is independent of the step/part read coordinates. */
|
|
336
|
+
export interface ChatPresentation {
|
|
337
|
+
renderId?: string;
|
|
338
|
+
/** Version of the full redacted content, not its part count or execution state. */
|
|
339
|
+
version?: string;
|
|
340
|
+
state?:
|
|
341
|
+
| "pending"
|
|
342
|
+
| "streaming"
|
|
343
|
+
| "running"
|
|
344
|
+
| "completed"
|
|
345
|
+
| "failed"
|
|
346
|
+
| "canceled"
|
|
347
|
+
| "unavailable";
|
|
348
|
+
}
|
|
349
|
+
/** Last actual capture activity; sequence advances only on observed events. */
|
|
350
|
+
export interface ChatActivity {
|
|
351
|
+
kind: "waiting" | "thinking" | "text" | "tool";
|
|
352
|
+
sequence: number;
|
|
353
|
+
name?: string;
|
|
354
|
+
}
|
|
355
|
+
export interface ChatItem extends ChatPresentation {
|
|
333
356
|
images?: ChatImage[];
|
|
334
357
|
id: string;
|
|
335
|
-
/** `thinking` is
|
|
336
|
-
*
|
|
358
|
+
/** `thinking` is a recorded readable block, or an explicit body-free
|
|
359
|
+
* activity placeholder; its signature is never returned. */
|
|
337
360
|
role: "user" | "assistant" | "tool" | "thinking";
|
|
338
361
|
text: string;
|
|
339
362
|
name: string;
|
|
@@ -362,7 +385,7 @@ export interface ChatTurn {
|
|
|
362
385
|
* arguments or output or a thinking block's text, and keeps at most
|
|
363
386
|
* `STEP_TEXT_BYTES` of message text; the full item is read per step with
|
|
364
387
|
* `conversation-step`, one part at a time. */
|
|
365
|
-
export interface ChatStep {
|
|
388
|
+
export interface ChatStep extends ChatPresentation {
|
|
366
389
|
images?: ChatImage[];
|
|
367
390
|
id: string;
|
|
368
391
|
role: ChatItem["role"];
|
|
@@ -379,6 +402,7 @@ export interface ChatStep {
|
|
|
379
402
|
}
|
|
380
403
|
/** One turn of a conversation branch: a user message and what followed it. */
|
|
381
404
|
export interface ChatTurnHeader {
|
|
405
|
+
activity?: ChatActivity;
|
|
382
406
|
execution?: ExecutionContext;
|
|
383
407
|
retry?: ModelRetry;
|
|
384
408
|
/** The user message's session entry id; a browser command id while Pi has not
|
|
@@ -502,6 +526,7 @@ export function chatStep(
|
|
|
502
526
|
const text = lazy ? "" : clipText(item.text, STEP_TEXT_BYTES);
|
|
503
527
|
return {
|
|
504
528
|
id: item.id,
|
|
529
|
+
...presentation(item),
|
|
505
530
|
role: item.role,
|
|
506
531
|
text,
|
|
507
532
|
...(item.images?.length ? { images: item.images } : {}),
|
|
@@ -668,7 +693,7 @@ export type WorkbenchResult =
|
|
|
668
693
|
| { kind: "accepted"; commandId: string }
|
|
669
694
|
| { kind: "project"; commandId: string; path: string; link: string };
|
|
670
695
|
export interface WorkbenchPort {
|
|
671
|
-
read(request: WorkbenchRead): WorkbenchResult
|
|
696
|
+
read(request: WorkbenchRead): WorkbenchResult | Promise<WorkbenchResult>;
|
|
672
697
|
command(
|
|
673
698
|
request: WorkbenchCommand,
|
|
674
699
|
caller?: {
|
|
@@ -691,6 +716,7 @@ export function decodeWorkbenchRead(v: unknown): WorkbenchRead {
|
|
|
691
716
|
const kind = Object.getOwnPropertyDescriptor(v ?? {}, "kind")?.value;
|
|
692
717
|
switch (kind) {
|
|
693
718
|
case "conversation-context":
|
|
719
|
+
case "reload-conversation-models":
|
|
694
720
|
case "conversation-models": {
|
|
695
721
|
const o = closed(v, ["kind", "location"]);
|
|
696
722
|
return { kind, location: decodeConversationLocation(o.location) };
|
|
@@ -1191,8 +1217,56 @@ function decodeChatImages(v: unknown): ChatImage[] {
|
|
|
1191
1217
|
};
|
|
1192
1218
|
});
|
|
1193
1219
|
}
|
|
1220
|
+
const PRESENTATION_KEYS = ["renderId", "version", "state"] as const;
|
|
1221
|
+
function presentationKeys(v: unknown): string[] {
|
|
1222
|
+
return PRESENTATION_KEYS.filter((key) => Object.hasOwn(v ?? {}, key));
|
|
1223
|
+
}
|
|
1224
|
+
function presentation(v: ChatPresentation): ChatPresentation {
|
|
1225
|
+
return {
|
|
1226
|
+
...(v.renderId === undefined ? {} : { renderId: v.renderId }),
|
|
1227
|
+
...(v.version === undefined ? {} : { version: v.version }),
|
|
1228
|
+
...(v.state === undefined ? {} : { state: v.state }),
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
function decodePresentation(o: Record<string, unknown>): ChatPresentation {
|
|
1232
|
+
return {
|
|
1233
|
+
...(o.renderId === undefined
|
|
1234
|
+
? {}
|
|
1235
|
+
: { renderId: text(o.renderId, 160, true) }),
|
|
1236
|
+
...(o.version === undefined ? {} : { version: decodeHash(o.version) }),
|
|
1237
|
+
...(o.state === undefined
|
|
1238
|
+
? {}
|
|
1239
|
+
: {
|
|
1240
|
+
state: oneOf(o.state, [
|
|
1241
|
+
"pending",
|
|
1242
|
+
"streaming",
|
|
1243
|
+
"running",
|
|
1244
|
+
"completed",
|
|
1245
|
+
"failed",
|
|
1246
|
+
"canceled",
|
|
1247
|
+
"unavailable",
|
|
1248
|
+
] as const),
|
|
1249
|
+
}),
|
|
1250
|
+
};
|
|
1251
|
+
}
|
|
1252
|
+
function decodeChatActivity(v: unknown): ChatActivity {
|
|
1253
|
+
const o = closed(v, [
|
|
1254
|
+
"kind",
|
|
1255
|
+
"sequence",
|
|
1256
|
+
...(Object.hasOwn(v ?? {}, "name") ? ["name"] : []),
|
|
1257
|
+
]);
|
|
1258
|
+
const kind = oneOf(o.kind, ["waiting", "thinking", "text", "tool"] as const);
|
|
1259
|
+
if (o.name !== undefined && kind !== "tool")
|
|
1260
|
+
throw new ContractError("invalid");
|
|
1261
|
+
return {
|
|
1262
|
+
kind,
|
|
1263
|
+
sequence: integer(o.sequence, 0),
|
|
1264
|
+
...(o.name === undefined ? {} : { name: text(o.name, 128) }),
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1194
1267
|
export function decodeChatItem(v: unknown): ChatItem {
|
|
1195
1268
|
const i = closed(v, [
|
|
1269
|
+
...presentationKeys(v),
|
|
1196
1270
|
"id",
|
|
1197
1271
|
"role",
|
|
1198
1272
|
"text",
|
|
@@ -1202,6 +1276,7 @@ export function decodeChatItem(v: unknown): ChatItem {
|
|
|
1202
1276
|
...(Object.hasOwn(v ?? {}, "images") ? ["images"] : []),
|
|
1203
1277
|
]);
|
|
1204
1278
|
return {
|
|
1279
|
+
...decodePresentation(i),
|
|
1205
1280
|
...(i.images === undefined ? {} : { images: decodeChatImages(i.images) }),
|
|
1206
1281
|
id: text(i.id, 160, true),
|
|
1207
1282
|
role: oneOf(i.role, ITEM_ROLES),
|
|
@@ -1213,6 +1288,7 @@ export function decodeChatItem(v: unknown): ChatItem {
|
|
|
1213
1288
|
}
|
|
1214
1289
|
function decodeChatStep(v: unknown): ChatStep {
|
|
1215
1290
|
const o = closed(v, [
|
|
1291
|
+
...presentationKeys(v),
|
|
1216
1292
|
"id",
|
|
1217
1293
|
"role",
|
|
1218
1294
|
"text",
|
|
@@ -1224,6 +1300,7 @@ function decodeChatStep(v: unknown): ChatStep {
|
|
|
1224
1300
|
"parts",
|
|
1225
1301
|
]);
|
|
1226
1302
|
const step = {
|
|
1303
|
+
...decodePresentation(o),
|
|
1227
1304
|
...(o.images === undefined ? {} : { images: decodeChatImages(o.images) }),
|
|
1228
1305
|
id: text(o.id, 160, true),
|
|
1229
1306
|
role: oneOf(o.role, ITEM_ROLES),
|
|
@@ -1239,13 +1316,31 @@ function decodeChatStep(v: unknown): ChatStep {
|
|
|
1239
1316
|
(step.text || step.clipped)
|
|
1240
1317
|
)
|
|
1241
1318
|
throw new ContractError("invalid");
|
|
1242
|
-
//
|
|
1243
|
-
|
|
1244
|
-
|
|
1319
|
+
// Legacy thinking steps require readable text. New activity placeholders
|
|
1320
|
+
// explicitly carry state and identity, and cannot fabricate detail parts.
|
|
1321
|
+
if (step.role === "thinking") {
|
|
1322
|
+
if (
|
|
1323
|
+
!step.parts &&
|
|
1324
|
+
!(
|
|
1325
|
+
step.renderId &&
|
|
1326
|
+
[
|
|
1327
|
+
"streaming",
|
|
1328
|
+
"completed",
|
|
1329
|
+
"unavailable",
|
|
1330
|
+
"canceled",
|
|
1331
|
+
"failed",
|
|
1332
|
+
].includes(step.state ?? "")
|
|
1333
|
+
)
|
|
1334
|
+
)
|
|
1335
|
+
throw new ContractError("invalid");
|
|
1336
|
+
if (step.parts && step.state !== undefined && step.state !== "completed")
|
|
1337
|
+
throw new ContractError("invalid");
|
|
1338
|
+
}
|
|
1245
1339
|
return step;
|
|
1246
1340
|
}
|
|
1247
1341
|
function decodeChatTurnHeader(v: unknown): ChatTurnHeader {
|
|
1248
1342
|
const o = closed(v, [
|
|
1343
|
+
...(Object.hasOwn(v ?? {}, "activity") ? ["activity"] : []),
|
|
1249
1344
|
"id",
|
|
1250
1345
|
"status",
|
|
1251
1346
|
"notice",
|
|
@@ -1261,6 +1356,9 @@ function decodeChatTurnHeader(v: unknown): ChatTurnHeader {
|
|
|
1261
1356
|
const omitted = closed(o.omitted, ["thinking", "media", "other"]);
|
|
1262
1357
|
const steps = integer(o.steps, 0);
|
|
1263
1358
|
return {
|
|
1359
|
+
...(o.activity === undefined
|
|
1360
|
+
? {}
|
|
1361
|
+
: { activity: decodeChatActivity(o.activity) }),
|
|
1264
1362
|
...(o.execution === undefined
|
|
1265
1363
|
? {}
|
|
1266
1364
|
: { 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 {
|
package/src/service-client.ts
CHANGED
|
@@ -233,11 +233,15 @@ export class ServiceClient {
|
|
|
233
233
|
async models(
|
|
234
234
|
signal?: AbortSignal,
|
|
235
235
|
location?: ConversationLocation,
|
|
236
|
+
reload = false,
|
|
236
237
|
): Promise<Reply<ModelCatalog>> {
|
|
237
238
|
try {
|
|
238
239
|
if (location) {
|
|
239
240
|
const reply = await this.workbenchRead(
|
|
240
|
-
{
|
|
241
|
+
{
|
|
242
|
+
kind: reload ? "reload-conversation-models" : "conversation-models",
|
|
243
|
+
location,
|
|
244
|
+
},
|
|
241
245
|
signal,
|
|
242
246
|
);
|
|
243
247
|
if (reply.kind === "error") return reply;
|