@abelxiaoxing/cadence 2.0.47 → 2.0.48

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.
@@ -140,7 +140,9 @@ Only owned worktrees at the delivered commit, after successful post-merge checks
140
140
  Ignored setup/build output such as `node_modules` also retains the worktree; failures, cancellation and unknown outcomes never trigger cleanup.
141
141
  Only one approved implementation runs at a time; approving a second while one is active is refused with `conflict`.
142
142
  There is no fixed delivery-duration or repair-round quota.
143
- Individual workers/checks retain their process deadlines; a settled failure can trigger diagnosis and continuation, not automatic goal termination.
143
+ Agents have no fixed total runtime deadline.
144
+ Setup/check commands default to no timeout; an explicitly approved per-command timeout still applies, including in older plans.
145
+ A settled failure can trigger diagnosis and continuation, not automatic goal termination.
144
146
  Cancel/Stop never interrupt the final fast-forward (a hung `git merge` therefore delays Stop until Git exits).
145
147
  Local-merge plans need clean, nonignored code and knowledge targets; use working-copy delivery for dirty or ignored documentation.
146
148
  Generated workflow notes remain separate.
@@ -154,7 +156,8 @@ No dependency/browser download or source-profile copying is implicit.
154
156
  Baseline checks are separate from acceptance checks that need newly implemented files.
155
157
  Failed setup, baseline, implementation, checks or review enter source-backed diagnosis when their actual operations have settled.
156
158
  Cadence can preserve partial outputs, split remaining work and choose alternative implementations within the approval; it never expands permissions or weakens acceptance.
157
- Known transient provider HTTP failures back off automatically after actual cleanup, without holding the checkout while waiting; re-entry checks that the approved files have not changed.
159
+ Transient model-request failures recover inside the original SDK worker, with visible, cancellable backoff; completed tool results and the checkout gate stay with that worker.
160
+ An exhausted or nonretryable model request stops the delivery with partial work preserved, rather than rerunning the entire step or launching another model just to diagnose an unavailable provider.
158
161
  An unchanged failure and identical recovery strategy cannot become an endless replay loop.
159
162
  A concrete external blocker is reported with preserved work, not a generic request to type “continue”.
160
163
  Final candidate checks must pass before merge.
@@ -169,6 +172,23 @@ To request orderly closure, ask Cadence to cancel in Pi, or use **Cancel workflo
169
172
  A pending or unknown cancellation is not reported as stopped.
170
173
  Failures, timeouts and unknown process/auth/storage outcomes remain distinct; an owner that cannot settle unknown work restarts itself and recovers automatically.
171
174
 
175
+ ## Waiting for an unstable provider
176
+
177
+ The WebUI shows the retry number and scheduled delay when a model stream breaks, then shows when the replacement request is in progress.
178
+ There is no need to send the same message again while recovery is active.
179
+ Refreshing or leaving the page only detaches; return to observe the same accepted turn, or use its existing Stop/Cancel control.
180
+ Automatic recovery resends only the failed model request: it does not repeat completed tool operations, renew approval, switch models or replay work after a service restart.
181
+ A failed partial answer stays in history and is not presented as a complete reply.
182
+ Waiting, requests and tool work stay in the same SDK session without a total runtime deadline.
183
+
184
+ `OpenAI Responses stream ended before a terminal response event` means the stream ended without a protocol completion event, not necessarily that the local timeout was too short.
185
+ An already closed stream cannot be repaired by waiting on that connection.
186
+ If every attempt fails the same way, check the upstream provider/proxy's streaming support and timeout policy; automatic recovery is not a fix for a consistently malformed stream.
187
+
188
+ Native Pi's main dialogue uses Pi's own retry settings, separately from Cadence's service workers.
189
+ Cadence does not change those settings or load a user profile into a worker.
190
+ If a native dialogue stops, distinguish exhausted retries from disabled/overridden settings or cancellation before changing its retry limits.
191
+
172
192
  ## Service and compatibility
173
193
 
174
194
  An explicit native mode entry/current user Send may start or reuse its local project owner on demand.
@@ -202,7 +222,9 @@ The bounded `grep` tool searches literal text, not regular expressions.
202
222
  No files are copied to accelerate research.
203
223
 
204
224
  Separate runs in one project wait for the shared checkout gate; questions inside a run can overlap.
205
- The worker's total process deadline includes model and tool time, is not an inactivity timer, and is not renewed by progress.
225
+ Agents have no total process deadline or substitute idle/step/tool-call quota.
226
+ Leaving the page or losing a coordinator bridge does not cancel accepted investigations.
227
+ Explicit Cancel/Stop retain their actual closure and recorded source.
206
228
  A timeout that confirms direct-child close does not prove all descendants stopped, nor does it prove any survived.
207
229
 
208
230
  Research replies include `runId` and step identities.
@@ -245,3 +267,21 @@ Searches use already available `rg` and `fd`/`fdfind` binaries or Pi's existing
245
267
  Readonly subagents do not have shell or editing tools: use the direct listing, search and read tools rather than a `bash` pipeline.
246
268
  Approved implementation workers keep their existing shell and editing tools.
247
269
  This distinction preserves execution consent; it is not an OS sandbox or permission to copy credentials or profiles.
270
+
271
+ ### Pi settings and tools
272
+
273
+ On Send, Cadence captures persisted Pi preferences from its owner's selected agent directory and the conversation directory.
274
+ Pi merges user settings with trusted project `.pi/settings.json`.
275
+ Automatic compaction (including model-specific token settings), agent-level request retries and configured standard tools take effect without a second Cadence configuration.
276
+ For example, Pi's `defaultTools: ["+grep", "+find", "+ls"]` adds those tools to its normal coding defaults.
277
+ Selecting `powershell` is also supported when that backend is available on the host.
278
+
279
+ A delivery agreement shows the runtime summary.
280
+ Changing settings/tools requires a fresh agreement before execution; accepted work keeps its snapshot through implementation and independent readonly Review.
281
+ Workers do not copy profiles into worktrees or write settings back.
282
+ Persisted Pi project trust controls project **settings**, not execution consent.
283
+ Terminal-only overrides and extension/MCP closures are not silently loaded; unavailable configured tools refuse instead of silently falling back.
284
+
285
+ Service differences remain explicit: cache warming and provider-internal retries are off; HTTP idle timeout defaults to disabled unless configured in Pi.
286
+ This does not add an Agent lifetime deadline.
287
+ Shell output is bounded/redacted rather than written to raw spill files; per-command timeout and explicit Cancel/Stop still apply.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abelxiaoxing/cadence",
3
- "version": "2.0.47",
3
+ "version": "2.0.48",
4
4
  "description": "Conversation-driven Pi workspace: persistent native and WebUI workflows, explicit plan approval, checks and local delivery.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -29,6 +29,7 @@
29
29
  "src/native-history.ts",
30
30
  "src/operator-cli.mjs",
31
31
  "src/sdk-worker.mjs",
32
+ "src/worker-model.mjs",
32
33
  "src/service-cli.mjs",
33
34
  "src/service-client.ts",
34
35
  "src/service-contract.ts",
@@ -5,5 +5,5 @@ For a new goal, use focused cadence_research to inspect relevant code and projec
5
5
  Once the result is clear, use cadence_plan with version:2. Describe the expected delivery, explicit decisions/non-goals, immutable acceptance, an initial technical route and assignments, approved write paths, exact setup/baseline/acceptance commands and delivery policy. The initial route is automatically adjustable; the owner may diagnose, preserve partial work, split remaining work and select equivalent implementations without routine reconfirmation. Do not ask users to classify every adjustable detail. Never weaken core requirements or checks. Investigate prerequisites first: worktrees do not inherit ignored dependencies. 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. All implementation, recovery and verified knowledge updates reuse that candidate; 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; only this run's confirmed merges can advance that target baseline for post-merge recovery. 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
  Include knowledge as exact Markdown write paths for relevant existing documentation, or .cadence/project.md and a focused .cadence/knowledge/<topic>.md only where no existing document owns the fact. Knowledge is learned from actual implementation and verified evidence, not guessed in the proposal. Avoid duplicate documentation systems. Include necessary tests and documentation in the approved scope so routine delivery does not need scope expansion.
7
7
  Present a concise delivery expectation with the complete returned agreement available, then invite one clear approval (the user may type 按计划实施). cadence_start obtains fresh context-bound approval. It covers adaptive execution, checks, automatic Agent review, knowledge updates and the declared local delivery. It never covers push, publication, deployment, new permissions, unplanned installations or changing core requirements. You cannot approve yourself. Vague acknowledgement is not consent.
8
- During accepted work the service owns progress and recovery. Report actual cadence_status observations; do not start replacement workflows or ask for 'continue' after an individual child fails. Child failure is not delivery failure. The owner proceeds while there is an evidence-based in-scope route, without a fixed repair quota or total delivery deadline. Native worker deadlines and actual closure still apply. If work is genuinely blocked, explain the concrete missing condition and preserved outcomes, not a generic request to continue.
8
+ During accepted work the service owns progress and recovery. Report actual cadence_status observations; do not start replacement workflows or ask for 'continue' after an individual child fails. Child failure is not delivery failure. The owner proceeds while there is an evidence-based in-scope route, without a fixed repair quota or total delivery deadline. Agents have no total runtime deadline; explicit command timeouts and actual closure still apply. If work is genuinely blocked, explain the concrete missing condition and preserved outcomes, not a generic request to continue.
9
9
  For follow-up to a settled or interrupted run, inspect retained outcomes first. Partial outputs are not unexplained user edits. Unknown results must be observed and reconciled, never blindly replayed; a new delivery requires fresh approval. No automatic replay after owner restart. cadence_cancel is explicit cancellation, not navigation or exit. Worker prose is not passing checks; automatic review is never human review. Completion leaves Cadence ON and ready. Tools operate on the host; this is not a sandbox.`;
@@ -87,7 +87,7 @@ const idle = (): CadenceModeState => ({
87
87
  previousTools: [],
88
88
  });
89
89
  function readableProposal(proposal: WorkflowProposal): string {
90
- return `Working directory: ${proposal.cwd}\nCheckout root (declared write paths): ${proposal.checkoutRoot ?? proposal.cwd}\nModel: ${proposal.display?.model ?? "not recorded"}\n\n${readableDelivery(proposal.delivery)}\n\n${readableWorkflowPlan(proposal.plan)}`;
90
+ return `Working directory: ${proposal.cwd}\nCheckout root (declared write paths): ${proposal.checkoutRoot ?? proposal.cwd}\nModel: ${proposal.display?.model ?? "not recorded"}\n${proposal.display?.runtime ?? "Pi runtime settings not recorded."}\n\n${readableDelivery(proposal.delivery)}\n\n${readableWorkflowPlan(proposal.plan)}`;
91
91
  }
92
92
  /** Session restoration restores mode/context, NEVER a grant, pending command or action replay. */
93
93
  export function restoreCadenceMode(
@@ -232,7 +232,7 @@ export function transcriptText(turn: ChatTurn | null): string {
232
232
  const CHECK = Type.Object({
233
233
  name: Type.String(),
234
234
  command: Type.String(),
235
- timeoutMs: Type.Integer({ minimum: 100, maximum: 1200000 }),
235
+ timeoutMs: Type.Optional(Type.Integer({ minimum: 100, maximum: 2147483647 })),
236
236
  });
237
237
  const PLAN = Type.Object({
238
238
  goal: Type.String(),
@@ -4,7 +4,7 @@ import { Type } from "typebox";
4
4
  const CHECK = Type.Object({
5
5
  name: Type.String(),
6
6
  command: Type.String(),
7
- timeoutMs: Type.Integer({ minimum: 100, maximum: 1200000 }),
7
+ timeoutMs: Type.Optional(Type.Integer({ minimum: 100, maximum: 2147483647 })),
8
8
  });
9
9
  const PLAN = Type.Object({
10
10
  goal: Type.String(),
@@ -47,6 +47,8 @@ export function createCoordinatorTools() {
47
47
  };
48
48
  process.on("disconnect", closed);
49
49
  const receive = (reply) => {
50
+ // Credential replies share the private transport, never the tool channel.
51
+ if (reply?.kind === "auth") return;
50
52
  if (
51
53
  !reply ||
52
54
  typeof reply !== "object" ||
@@ -17,7 +17,6 @@ var LIMITS = Object.freeze({
17
17
  wsClientFrameBytes: 16 * 1024,
18
18
  startWaitMs: 1e4,
19
19
  stopWaitMs: 60000,
20
- authWaitMs: 30000,
21
20
  authValidityMarginMs: 120000,
22
21
  browserLifetimeMs: 12 * 60 * 60 * 1000,
23
22
  terminateGraceMs: 1000,
@@ -34,23 +33,17 @@ var LIMITS = Object.freeze({
34
33
  frameBytes: 64 * 1024,
35
34
  chunkBytes: 8 * 1024,
36
35
  detailBytes: 32 * 1024 * 1024,
37
- childProtocolBytes: 128 * 1024 * 1024,
38
36
  dataFrames: 1e5,
39
37
  controlFrames: 256,
40
- sdkEvents: 1e6,
38
+ captureEntries: 4096,
41
39
  workerQueueBytes: 4 * 1024 * 1024,
42
40
  workerQueueFrames: 1024,
43
41
  ownerQueueBytes: 8 * 1024 * 1024,
44
42
  ownerQueueFrames: 2048,
45
43
  ownerControlBytes: 1024 * 1024,
46
44
  ownerControlFrames: 256,
47
- recordingStallMs: 5000,
48
45
  episodes: 8,
49
- queuedAssignments: 128,
50
46
  childReservations: 2,
51
- episodeMs: 6 * 60 * 60 * 1000,
52
- readyWaitMs: 10 * 60 * 1000,
53
- workerMs: 1200000,
54
47
  artifactPartBytes: 256 * 1024,
55
48
  progressBatchMs: 100,
56
49
  progressBatchBytes: 256 * 1024,
@@ -488,7 +481,7 @@ function checkSelection(v) {
488
481
  kind: oneOf(o.kind, ["configured", "manual"]),
489
482
  name: text(o.name, 128, true),
490
483
  command: text(o.command, 4096, true),
491
- timeoutMs: integer(o.timeoutMs, 100, LIMITS.workerMs)
484
+ timeoutMs: integer(o.timeoutMs, 100, 1200000)
492
485
  };
493
486
  const controls = /[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;
494
487
  if (controls.test(result.name) || controls.test(result.command) || /[\n\t]/.test(result.name) || result.name === "Manual command")
@@ -561,8 +554,25 @@ function decodeHandoff(v) {
561
554
  })
562
555
  };
563
556
  }
557
+ function decodeStopCause(v) {
558
+ const o = closed(v, ["source", "reason", "target"]);
559
+ return {
560
+ source: oneOf(o.source, [
561
+ "user",
562
+ "service",
563
+ "owner",
564
+ "command",
565
+ "worker",
566
+ "coordinator",
567
+ "unknown"
568
+ ]),
569
+ reason: text(o.reason, 128, true),
570
+ target: text(o.target, 128, true)
571
+ };
572
+ }
564
573
  function decodeNativeSettlement(v) {
565
574
  const o = closed(v, [
575
+ ...Object.hasOwn(v ?? {}, "stop") ? ["stop"] : [],
566
576
  "outcome",
567
577
  "closure",
568
578
  "exitCode",
@@ -574,6 +584,7 @@ function decodeNativeSettlement(v) {
574
584
  "capture"
575
585
  ]);
576
586
  const r = {
587
+ ...o.stop === undefined ? {} : { stop: decodeStopCause(o.stop) },
577
588
  outcome: oneOf(o.outcome, [
578
589
  "completed",
579
590
  "failed",
@@ -707,6 +718,19 @@ function sourceId(v) {
707
718
  invalid();
708
719
  return s;
709
720
  }
721
+ function decodeModelRetry(v) {
722
+ const o = closed(v, ["phase", "attempt", "maxAttempts", "delayMs"]);
723
+ const maxAttempts = integer(o.maxAttempts, 1);
724
+ const progress = {
725
+ phase: oneOf(o.phase, ["waiting", "requesting"]),
726
+ attempt: integer(o.attempt, 1, maxAttempts),
727
+ maxAttempts,
728
+ delayMs: integer(o.delayMs, 0, 2147483647)
729
+ };
730
+ if (progress.phase === "requesting" && progress.delayMs !== 0)
731
+ throw new ContractError("invalid");
732
+ return progress;
733
+ }
710
734
  function decodeCaptureEvent(v) {
711
735
  const kind = tag(v);
712
736
  switch (kind) {
@@ -894,6 +918,10 @@ function decodeCaptureEvent(v) {
894
918
  coverage: decodeCoverage(o.coverage)
895
919
  };
896
920
  }
921
+ case "model-retry": {
922
+ const o = closed(v, ["kind", "progress"]);
923
+ return { kind, progress: nullable(o.progress, decodeModelRetry) };
924
+ }
897
925
  case "capture-status": {
898
926
  const o = closed(v, ["kind", "coverage"]);
899
927
  return { kind, coverage: decodeCoverage(o.coverage) };
@@ -928,6 +956,7 @@ function decodeCaptureEvent(v) {
928
956
  }
929
957
  function decodeCheckNativeSettlement(v) {
930
958
  const o = closed(v, [
959
+ ...Object.hasOwn(v ?? {}, "stop") ? ["stop"] : [],
931
960
  "outcome",
932
961
  "closure",
933
962
  "exitCode",
@@ -936,6 +965,7 @@ function decodeCheckNativeSettlement(v) {
936
965
  "stdin"
937
966
  ]);
938
967
  const r = {
968
+ ...o.stop === undefined ? {} : { stop: decodeStopCause(o.stop) },
939
969
  outcome: oneOf(o.outcome, [
940
970
  "completed",
941
971
  "failed",
@@ -1053,8 +1083,8 @@ function decodeRunSettlement(v) {
1053
1083
  }
1054
1084
  function decodeSourceRange(v) {
1055
1085
  const o = closed(v, ["first", "last", "firstObservedMs", "lastObservedMs"]);
1056
- const first = integer(o.first, 1, LIMITS.dataFrames + LIMITS.controlFrames);
1057
- const last = integer(o.last, first, LIMITS.dataFrames + LIMITS.controlFrames);
1086
+ const first = integer(o.first, 1, Number.MAX_SAFE_INTEGER);
1087
+ const last = integer(o.last, first, Number.MAX_SAFE_INTEGER);
1058
1088
  const firstObservedMs = integer(o.firstObservedMs);
1059
1089
  const lastObservedMs = integer(o.lastObservedMs, firstObservedMs);
1060
1090
  if (first === last && firstObservedMs !== lastObservedMs)
@@ -2,5 +2,5 @@
2
2
  export const nativeBuild = {
3
3
  kind: "native",
4
4
  contractHash:
5
- "ee8ae17515fd8baf0aba38eb6a78a27e8c574cda265ddc17884c0741a6fb56b1",
5
+ "069d95cf6e4efcd6d8975b2ee3f707c51d11038477a01f76398a610712f1c9d7",
6
6
  } as const;
@@ -10,12 +10,13 @@ import {
10
10
  } from "@earendil-works/pi-coding-agent";
11
11
 
12
12
  export const RESEARCH_INSTRUCTIONS =
13
- "Use Pi's read, grep, find and ls tools directly. read accepts one path with optional offset/limit; follow its next-offset notice for more text. grep accepts one pattern, find accepts a glob, and ls lists a directory. Searches respect .gitignore; use explicit paths and directory listings when investigating ignored dependencies or backups. Explicit absolute paths outside the checkout remain readable. Relative paths use the first investigation root. These are live filesystem reads, not a snapshot: report truncation and unresolved coverage honestly. There is no bash, write or edit tool in this readonly role; shell work belongs to an authorized implementation. Keep credentials and private session content out of reports.";
13
+ "Use the configured Pi readonly tools directly, following their native parameter schemas and continuation notices. Searches respect .gitignore; use explicit paths and directory listings when investigating ignored dependencies or backups. Explicit absolute paths outside the checkout remain readable. Relative paths use the first investigation root. These are live filesystem reads, not a snapshot: report truncation and unresolved coverage honestly. There is no bash, write or edit tool in this readonly role; shell work belongs to an authorized implementation. Keep credentials and private session content out of reports.";
14
14
 
15
- export function createResearchTools(workspace) {
15
+ export function createResearchTools(workspace, names, settings) {
16
16
  const cwd = workspace.roots[0];
17
17
  const definitions = [
18
18
  createReadToolDefinition(cwd, {
19
+ ...(settings ? { autoResizeImages: settings.images.autoResize } : {}),
19
20
  operations: {
20
21
  readFile,
21
22
  detectImageMimeType: detectSupportedImageMimeTypeFromFile,
@@ -31,25 +32,31 @@ export function createResearchTools(workspace) {
31
32
  createFindToolDefinition(cwd),
32
33
  createLsToolDefinition(cwd),
33
34
  ];
35
+ if (names?.some((name) => !definitions.some((tool) => tool.name === name)))
36
+ throw new Error(
37
+ "Readonly work cannot inherit a mutating or unavailable tool",
38
+ );
34
39
  return {
35
- tools: definitions.map((tool) => ({
36
- ...tool,
37
- async execute(id, args, signal, update, context) {
38
- if (signal?.aborted) throw new Error("Investigation canceled");
39
- // The worker already enforces offline mode before creating its session.
40
- // Keep direct uses equally noninstalling without changing ambient env.
41
- if (
42
- ["grep", "find"].includes(tool.name) &&
43
- process.env.PI_OFFLINE !== "1"
44
- )
45
- throw new Error(
46
- "Readonly search requires PI_OFFLINE=1; no tools were downloaded",
47
- );
48
- const selected = { ...context, cwd };
49
- // Original-operation accounting and cancellation belong to the toolkit,
50
- // just as they do for the standard file tools of an editing worker.
51
- return tool.execute(id, args, signal, update, selected);
52
- },
53
- })),
40
+ tools: definitions
41
+ .filter((tool) => names === undefined || names.includes(tool.name))
42
+ .map((tool) => ({
43
+ ...tool,
44
+ async execute(id, args, signal, update, context) {
45
+ if (signal?.aborted) throw new Error("Investigation canceled");
46
+ // The worker already enforces offline mode before creating its session.
47
+ // Keep direct uses equally noninstalling without changing ambient env.
48
+ if (
49
+ ["grep", "find"].includes(tool.name) &&
50
+ process.env.PI_OFFLINE !== "1"
51
+ )
52
+ throw new Error(
53
+ "Readonly search requires PI_OFFLINE=1; no tools were downloaded",
54
+ );
55
+ const selected = { ...context, cwd };
56
+ // Original-operation accounting and cancellation belong to the toolkit,
57
+ // just as they do for the standard file tools of an editing worker.
58
+ return tool.execute(id, args, signal, update, selected);
59
+ },
60
+ })),
54
61
  };
55
62
  }