zcode-app-cli 3.7.3-10 → 3.7.6-12

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.
@@ -33758,6 +33758,8 @@ var ModelRetryReason = {
33758
33758
  StreamIdleTimeout: "stream_idle_timeout",
33759
33759
  StaleConnection: "stale_connection",
33760
33760
  AuthRefresh: "auth_refresh",
33761
+ /** Anthropic 明确拒绝历史 thinking signature 后,对请求副本清理并立即重试一次。 */
33762
+ ReasoningSignatureRepair: "reasoning_signature_repair",
33761
33763
  /** off-peak 闲时排队(429/3105+Retry-After):豁免重试预算、无限探测(D24,仅 idle plan provider)。 */
33762
33764
  OffpeakQueued: "offpeak_queued"
33763
33765
  };
@@ -43411,7 +43413,7 @@ var MessageHistoryImpl = class {
43411
43413
  this.entries.push(...entries.map(cloneRuntimeMessageEntry));
43412
43414
  this.cacheStats.totalMessages = this.entries.length;
43413
43415
  }
43414
- addAssistant(content, toolCalls, reasoning) {
43416
+ addAssistant(content, toolCalls, reasoning, modelRef) {
43415
43417
  const reasoningBlocks = reasoning?.map((block) => cloneReasoningBlock(block)) ?? [];
43416
43418
  this.entries.push({
43417
43419
  message: {
@@ -43424,7 +43426,8 @@ var MessageHistoryImpl = class {
43424
43426
  id: tc.id,
43425
43427
  name: tc.name,
43426
43428
  input: tc.input
43427
- }))
43429
+ })),
43430
+ ...modelRef ? { modelRef: { ...modelRef } } : {}
43428
43431
  }
43429
43432
  });
43430
43433
  this.cacheStats.totalMessages = this.entries.length;
@@ -43592,6 +43595,8 @@ function cloneModelInputMessage(message) {
43592
43595
  next.toolName = message.toolName;
43593
43596
  if (message.isError !== void 0)
43594
43597
  next.isError = message.isError;
43598
+ if (message.modelRef)
43599
+ next.modelRef = { ...message.modelRef };
43595
43600
  return next;
43596
43601
  }
43597
43602
  function cloneReasoningBlock(block) {
@@ -43974,7 +43979,11 @@ async function hydrateMessageHistoryFromSession(input) {
43974
43979
  id: part.callID,
43975
43980
  input: part.state.input,
43976
43981
  name: providerToolNameFromPart(part)
43977
- })), reasoning);
43982
+ })), reasoning, {
43983
+ modelId: message.info.modelID,
43984
+ providerId: message.info.providerID,
43985
+ ...message.info.variant ? { variant: message.info.variant } : {}
43986
+ });
43978
43987
  appliedMessageCount++;
43979
43988
  for (const part of toolParts) {
43980
43989
  const providerToolName = providerToolNameFromPart(part);
@@ -46091,7 +46100,10 @@ ${customSystemPrompt}` : ""
46091
46100
  if (dynamicSystemContent) {
46092
46101
  messages.push({
46093
46102
  role: "system",
46094
- content: dynamicSystemContent,
46103
+ // ZCode by design:Main Agent 的 dynamic system block 自带左边界,所有 provider 保持一致。
46104
+ content: `
46105
+
46106
+ ${dynamicSystemContent}`,
46095
46107
  cacheControl: EPHEMERAL_CACHE_CONTROL
46096
46108
  });
46097
46109
  }
@@ -46520,7 +46532,12 @@ function buildManualCompactBoundary(input) {
46520
46532
  };
46521
46533
  }
46522
46534
  function estimateMessageTokens(messages) {
46523
- return messages.reduce((total, message) => total + Math.ceil(modelMessageContentToText(message.content).length / 4), 0);
46535
+ return messages.reduce((total, message) => total + Math.ceil(modelMessageContentToTokenEstimateText(message.content).length / 4), 0);
46536
+ }
46537
+ function modelMessageContentToTokenEstimateText(content) {
46538
+ if (typeof content === "string")
46539
+ return content;
46540
+ return content.map((block) => block.type === "reasoning" ? block.text : modelMessageContentBlockToText(block)).filter(Boolean).join("\n\n");
46524
46541
  }
46525
46542
  function isContextPrefixMessage(message) {
46526
46543
  return message.role === "system" || message.role === "user" && modelMessageContentToText(message.content).trimStart().startsWith("<system-reminder>");
@@ -63583,7 +63600,12 @@ var zcodePluginMarketplaceSummarySchema = external_exports2.object({
63583
63600
  pluginCount: external_exports2.number().int().nonnegative(),
63584
63601
  isOfficial: external_exports2.boolean().optional(),
63585
63602
  // 目录顶层 featured 策展名单(商店「公开」分段 Featured 区)。
63586
- featured: external_exports2.array(external_exports2.string()).optional()
63603
+ featured: external_exports2.array(external_exports2.string()).optional(),
63604
+ refreshFailure: external_exports2.object({
63605
+ code: external_exports2.string(),
63606
+ failedAt: external_exports2.string(),
63607
+ message: external_exports2.string()
63608
+ }).strict().optional()
63587
63609
  }).strict();
63588
63610
  var zcodeAvailablePluginSummarySchema = external_exports2.object({
63589
63611
  id: nonEmptyString3,
@@ -64865,7 +64887,8 @@ var hostInitLocalMessageSchema = external_exports2.object({
64865
64887
  workspacePath: nonEmptyStringSchema2.optional(),
64866
64888
  workspaceIdentity: nonEmptyStringSchema2.optional(),
64867
64889
  agentWarmupTargets: external_exports2.array(hostAgentWarmupTargetSchema).max(3).optional(),
64868
- agentSpawnFallbackCwd: nonEmptyStringSchema2.optional()
64890
+ agentSpawnFallbackCwd: nonEmptyStringSchema2.optional(),
64891
+ runtimeProcessEnvPatch: external_exports2.record(external_exports2.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/), external_exports2.string()).optional()
64869
64892
  });
64870
64893
  var hostInitRemoteMessageSchema = external_exports2.object({
64871
64894
  type: external_exports2.literal("init-remote"),
@@ -100720,32 +100743,38 @@ function createSubagentContextBuilder(config5) {
100720
100743
  return new SubagentContextBuilder(config5);
100721
100744
  }
100722
100745
  function buildSubagentContextSections(config5) {
100723
- const sections = [
100724
- buildCliPrefixSection(),
100725
- createSubagentSection({
100746
+ const sections = [buildCliPrefixSection()];
100747
+ const agentPrompt = config5.agentPrompt.trimEnd();
100748
+ if (agentPrompt) {
100749
+ sections.push(createSubagentSection({
100726
100750
  name: "Subagent Agent Prompt",
100727
100751
  source: "subagent_agent_prompt",
100728
100752
  cacheHint: "stable",
100729
- // Runtime 已规范化普通 agent prompt;这里只保留空 base prompt 与 persistent Memory
100730
- // 拼接产生的两个前导换行,确保最终 provider-visible 文本与基线一致。
100731
- content: config5.agentPrompt.trimEnd()
100732
- }),
100733
- createSubagentSection({
100734
- name: "Subagent Notes",
100735
- source: "subagent_notes",
100736
- cacheHint: "stable",
100737
- content: buildSubagentCommonNotes()
100738
- }),
100739
- createSubagentSection({
100740
- name: "Subagent Environment",
100741
- source: "subagent_environment",
100742
- cacheHint: "dynamic",
100743
- content: buildSubagentEnvironmentContext({
100744
- agentPrompt: config5.agentPrompt,
100745
- envInfo: config5.envInfo
100746
- })
100747
- })
100748
- ];
100753
+ // 修复原因:空 prompt 不是语义段,不能让左边界单独成为 system block。
100754
+ // ZCode by design:Subagent agent prompt 自带相对 CLI prefix 的单换行左边界。
100755
+ content: `
100756
+ ${agentPrompt}`
100757
+ }));
100758
+ }
100759
+ sections.push(createSubagentSection({
100760
+ name: "Subagent Notes",
100761
+ source: "subagent_notes",
100762
+ cacheHint: "stable",
100763
+ // ZCode by design:后续 Subagent system block 统一自带双换行左边界。
100764
+ content: `
100765
+
100766
+ ${buildSubagentCommonNotes()}`
100767
+ }), createSubagentSection({
100768
+ name: "Subagent Environment",
100769
+ source: "subagent_environment",
100770
+ cacheHint: "dynamic",
100771
+ content: `
100772
+
100773
+ ${buildSubagentEnvironmentContext({
100774
+ agentPrompt: config5.agentPrompt,
100775
+ envInfo: config5.envInfo
100776
+ })}`
100777
+ }));
100749
100778
  const requestUserContextSection = buildRequestUserContextSection({
100750
100779
  userInstructions: config5.userInstructions
100751
100780
  });
@@ -104002,7 +104031,7 @@ function estimateRuntimeEntryTokens(entries, options = {}) {
104002
104031
  applyCacheControl: false,
104003
104032
  useMidConversationSystem: options.useMidConversationSystem
104004
104033
  }).messages;
104005
- return providerMessages.reduce((total, message) => total + Math.ceil(modelMessageContentToText(message.content).length / 4), 0);
104034
+ return estimateMessageTokens(providerMessages);
104006
104035
  }
104007
104036
  function truncateCompactSummaryRequestEntriesAfterPromptTooLong(options) {
104008
104037
  if (options.attempt >= MAX_COMPACT_PROMPT_TOO_LONG_RETRIES) {
@@ -108392,7 +108421,7 @@ async function recoverPartialTextOnlyFailure(input) {
108392
108421
  }
108393
108422
  },
108394
108423
  finish: "stream_recovery_discarded"
108395
- }, input.options.traceContext);
108424
+ }, input.options.traceContext, input.options.modelRef);
108396
108425
  input.state.modelResponse = "";
108397
108426
  input.state.modelStepCount += 1;
108398
108427
  recordModelHistoryRound(input.state);
@@ -110406,9 +110435,7 @@ function createDefaultSubagentPort(deps) {
110406
110435
  traceContext: request.traceContext,
110407
110436
  workspaceRoot: request.workspaceRoot
110408
110437
  });
110409
- const agentPrompt = persistentMemory ? `${baseAgentPrompt ?? ""}
110410
-
110411
- ${persistentMemory.prompt}` : baseAgentPrompt;
110438
+ const agentPrompt = [baseAgentPrompt, persistentMemory?.prompt].filter((part) => typeof part === "string" && part.length > 0).join("\n\n");
110412
110439
  const childPromptEnvInfo = {
110413
110440
  ...childEnvInfo,
110414
110441
  // 修复原因:CC 2.1.167 subagent env 段读取 child 当前 cwd;旧 envInfo snapshot 可能仍停在父会话初始目录。
@@ -113875,7 +113902,7 @@ async function persistToolModelStepFinish(runtime, state, options) {
113875
113902
  completed: Date.now(),
113876
113903
  finish: options.result.finishReason,
113877
113904
  tokens: toTokenUsageInfo(options.result.usage)
113878
- }, options.modelTraceContext);
113905
+ }, options.modelTraceContext, options.result.model);
113879
113906
  }
113880
113907
 
113881
113908
  // ../core/dist/runtime/methods/tool-part-metadata.js
@@ -114470,7 +114497,7 @@ async function enqueueFollowUpUserInputFromToolResult(state, result, traceContex
114470
114497
 
114471
114498
  // ../core/dist/runtime/methods/turn-stop.js
114472
114499
  async function finishModelStepWithoutToolCalls(state, options) {
114473
- this.messageHistory.addAssistant(state.modelResponse, void 0, options.result.reasoning);
114500
+ this.messageHistory.addAssistant(state.modelResponse, void 0, options.result.reasoning, options.result.model);
114474
114501
  await this.persistPart({
114475
114502
  id: createPartId(),
114476
114503
  sessionID: this.sessionId,
@@ -114484,7 +114511,7 @@ async function finishModelStepWithoutToolCalls(state, options) {
114484
114511
  completed: Date.now(),
114485
114512
  finish: options.result.finishReason,
114486
114513
  tokens: toTokenUsageInfo(options.result.usage)
114487
- }, options.modelTraceContext);
114514
+ }, options.modelTraceContext, options.result.model);
114488
114515
  if (state.automationCreateLimitReached) {
114489
114516
  if (state.activeTurn) {
114490
114517
  await this.fallbackPendingGuidesToQueue({
@@ -114628,7 +114655,7 @@ function createStreamingToolCoordinator(runtime, state, options) {
114628
114655
  state.modelStepCount += 1;
114629
114656
  recordModelHistoryRound(state);
114630
114657
  state.toolCallCount += streamedToolResults.length;
114631
- runtime.messageHistory.addAssistant("", toolCalls);
114658
+ runtime.messageHistory.addAssistant("", toolCalls, void 0, options.modelRef);
114632
114659
  state.turnMachine = new TurnMachineImpl(state.turnMachine.receiveModelResponse(""));
114633
114660
  await executeToolCallsForModelStep.call(runtime, state, {
114634
114661
  assistantCreatedAt,
@@ -114636,7 +114663,7 @@ function createStreamingToolCoordinator(runtime, state, options) {
114636
114663
  modelTraceContext: options.traceContext,
114637
114664
  result: {
114638
114665
  finishReason: "tool-calls",
114639
- model: runtime.defaultModelRef,
114666
+ model: options.modelRef,
114640
114667
  providerMetadata: { recoveredFromStreamFailure: true },
114641
114668
  text: "",
114642
114669
  toolCalls,
@@ -115338,7 +115365,7 @@ async function runModelBackedTurnStepImpl(state, options, assistantMessageId) {
115338
115365
  modelStepCount: state.modelStepCount,
115339
115366
  traceContext: modelTraceContext
115340
115367
  });
115341
- await this.persistAssistantMessage(assistantMessageId, state.currentUserMessageId, assistantCreatedAt, void 0, modelTraceContext);
115368
+ await this.persistAssistantMessage(assistantMessageId, state.currentUserMessageId, assistantCreatedAt, void 0, modelTraceContext, executionModelRef);
115342
115369
  await this.persistPart({
115343
115370
  id: createPartId(),
115344
115371
  sessionID: this.sessionId,
@@ -115357,6 +115384,7 @@ async function runModelBackedTurnStepImpl(state, options, assistantMessageId) {
115357
115384
  state.events.push(modelRequestEvent);
115358
115385
  const streamingToolCoordinator = createStreamingToolCoordinator(this, state, {
115359
115386
  assistantMessageId,
115387
+ modelRef: executionModelRef,
115360
115388
  traceContext: modelTraceContext
115361
115389
  });
115362
115390
  const networkEventStartIndex = state.events.length;
@@ -115446,7 +115474,7 @@ async function runModelBackedTurnStepImpl(state, options, assistantMessageId) {
115446
115474
  await this.persistAssistantMessage(assistantMessageId, state.userMessageId, assistantCreatedAt, {
115447
115475
  completed: Date.now(),
115448
115476
  finish: "start_plan_admission_retry_discarded"
115449
- }, modelTraceContext);
115477
+ }, modelTraceContext, executionModelRef);
115450
115478
  state.modelResponse = "";
115451
115479
  state.modelStepCount += 1;
115452
115480
  recordModelHistoryRound(state);
@@ -115497,7 +115525,7 @@ async function runModelBackedTurnStepImpl(state, options, assistantMessageId) {
115497
115525
  ...persistedTurnResult ? { turnResult: persistedTurnResult } : {}
115498
115526
  }
115499
115527
  }
115500
- }, modelTraceContext);
115528
+ }, modelTraceContext, executionModelRef);
115501
115529
  if (isModelContextExceededError(finalError) && await recoverModelStepAfterContextExceeded.call(this, state, finalError, modelStepIndex)) {
115502
115530
  return "continue";
115503
115531
  }
@@ -115652,7 +115680,7 @@ async function runModelBackedTurnStepImpl(state, options, assistantMessageId) {
115652
115680
  });
115653
115681
  }
115654
115682
  state.toolCallCount += executableToolCalls.length;
115655
- this.messageHistory.addAssistant(state.modelResponse, executableToolCalls, result.reasoning);
115683
+ this.messageHistory.addAssistant(state.modelResponse, executableToolCalls, result.reasoning, result.model);
115656
115684
  const toolStepResult = await executeToolCallsForModelStep.call(this, state, {
115657
115685
  assistantCreatedAt,
115658
115686
  assistantMessageId,
@@ -117255,6 +117283,8 @@ var EXTRACTION_DRAIN_TIMEOUT_MS = 6e4;
117255
117283
  function scheduleProjectMemoryExtraction(runtime, input) {
117256
117284
  if (runtime.shuttingDown)
117257
117285
  return;
117286
+ if (runtime.config.memory?.extractionEnabled === false)
117287
+ return;
117258
117288
  const memoryRoot = resolveEnabledProjectMemoryRoot(runtime.config, runtime.workspaceRoot);
117259
117289
  if (!memoryRoot)
117260
117290
  return;
@@ -122796,13 +122826,13 @@ async function recordExternalUserPrompt(input, options) {
122796
122826
  resultType: "success",
122797
122827
  inputId: options?.intent?.sourceCommandId
122798
122828
  }, turnTraceContext), turnTraceContext);
122799
- this.turnNumber += 1;
122800
122829
  const titleGenerationStarted = maybeStartSessionTitleGeneration.call(this, canonicalInput, messageId, traceContext, { goalSummaryTargetID: options?.goalSummaryTargetID });
122801
122830
  if (!titleGenerationStarted && options?.goalSummaryTargetID) {
122802
122831
  maybeStartGoalSummaryTitleGeneration.call(this, canonicalInput, options.goalSummaryTargetID, {
122803
122832
  traceContext
122804
122833
  });
122805
122834
  }
122835
+ this.turnNumber += 1;
122806
122836
  this.messageHistory.setCacheMiss();
122807
122837
  return messageId;
122808
122838
  }
@@ -122861,7 +122891,7 @@ async function persistSyntheticUserNoticeForSession(options) {
122861
122891
  metadata: partMetadata
122862
122892
  }, options.traceContext);
122863
122893
  }
122864
- async function persistAssistantMessage(messageID, parentID, created, update, traceContext) {
122894
+ async function persistAssistantMessage(messageID, parentID, created, update, traceContext, modelRef = this.defaultModelRef) {
122865
122895
  this.latestConversationMessageId = messageID;
122866
122896
  this.latestAssistantMessageId = messageID;
122867
122897
  if (traceContext.turnId) {
@@ -122879,11 +122909,11 @@ async function persistAssistantMessage(messageID, parentID, created, update, tra
122879
122909
  },
122880
122910
  error: update?.error,
122881
122911
  parentID,
122882
- modelID: this.defaultModelRef.modelId,
122883
- providerID: this.defaultModelRef.providerId,
122884
- // Bug 根因:user message 已持久化 variant,但 assistant(通常是恢复扫描命中的最后一条)
122885
- // 没有写,derivePersistedRuntimeSettings 因而只能恢复 model,不能恢复 task-local thought。
122886
- variant: this.defaultModelRef.variant,
122912
+ // Bug 根因:默认模型可能在请求进行中切换;模型请求路径必须显式传入生成这条
122913
+ // 消息的模型。默认值只保留给不经过模型结果的既有 synthetic/fallback 路径。
122914
+ modelID: modelRef.modelId,
122915
+ providerID: modelRef.providerId,
122916
+ variant: modelRef.variant,
122887
122917
  mode: this.config.mode ?? "build",
122888
122918
  agent: this.config.agentName ?? "zcode-agent",
122889
122919
  path: {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: pptx
3
- description: Inspect and narrowly update PowerPoint PPTX elements selected in ZCode Preview Pane using fingerprint-checked OOXML references. Use when a prompt contains a `# Presentation elements:` block or the user asks to edit a referenced slide shape or table cell.
3
+ description: Inspect and narrowly update PowerPoint PPTX elements selected in ZCode Preview Pane using fingerprint-checked OOXML references. Use when a prompt contains a `# Presentation element comments:` or legacy `# Presentation elements:` block, or the user asks to edit a referenced slide shape or table cell.
4
4
  ---
5
5
 
6
6
  # PPTX referenced-element editing
@@ -11,12 +11,14 @@ containers may be inspected, but must not be generically rewritten.
11
11
 
12
12
  ## Required workflow
13
13
 
14
- 1. Read the `# Presentation elements:` JSON block from the prompt. Keep `sourceFingerprint`, `slidePart`,
14
+ 1. Read the `# Presentation element comments:` JSON block, or a legacy `# Presentation elements:` block, from the prompt. Keep `sourceFingerprint`, `slidePart`,
15
15
  `nodeId`, and table `rowIndex`/`cellIndex` exactly as supplied.
16
16
  2. Run `inspect` before proposing or performing an update.
17
- 3. When `selectedText` is present, treat it only as the user's intended editing context. Use the full element text
18
- returned by `inspect` to construct the complete replacement passed to `update-text`; never pass the selected
19
- substring alone unless the intended complete element text is exactly that substring.
17
+ 3. Treat optional `selectedText` as the user's intended text focus and every non-empty `comment` as the user's
18
+ requested change to that specific element. They are model context only. Process all comments without applying
19
+ one reference's comment to another. Use the full element text returned by `inspect`
20
+ to construct the complete replacement passed to `update-text`; never pass the selected substring or instruction
21
+ alone unless the intended complete element text is exactly that value.
20
22
  4. If inspect reports a fingerprint, missing-node, ambiguous-node, type, name, text, or cell-coordinate conflict,
21
23
  stop. Ask the user to reopen the PPTX preview and select the element again. Never guess by similar text/name.
22
24
  5. For shape text or table-cell text, run `update-text` to a user-requested output path. Prefer a new `.pptx`
@@ -70,7 +72,7 @@ Exit code `2` means the structured reference is stale or ambiguous and no output
70
72
  - Never treat the Preview Pane bounds, node name, or visible text as the authoritative locator. They are only
71
73
  diagnostics after `sourceFingerprint + slidePart + nodeId (+ cell coordinates)` resolves uniquely.
72
74
  - `textFingerprint` always guards the complete shape or table-cell text. Never recompute it from `selectedText`
73
- or use `selectedText` as a conflict-check target.
75
+ or `comment`, and never use either context field as a conflict-check target.
74
76
  - Do not modify the source through ad-hoc ZIP extraction. The provided script writes and validates a temporary
75
77
  archive before an atomic output replace.
76
78
  - PPTX OOXML text replacement can change line wrapping. It does not provide PowerPoint layout reflow,
@@ -155,11 +155,12 @@ class PptxReferenceTest(unittest.TestCase):
155
155
  self.assertIn(b">FY 2027 review<", slide)
156
156
  self.assertIn(b">84<", slide)
157
157
 
158
- def test_selected_text_is_context_while_full_text_fingerprint_guards_targets(self):
158
+ def test_user_context_does_not_change_full_text_fingerprint_guards(self):
159
159
  output = self.root / "selected-text-updated.pptx"
160
160
  shape_reference = reference(
161
161
  self.source,
162
162
  selectedText="Quarterly",
163
+ comment="Replace review with summary",
163
164
  textFingerprint=text_fingerprint("Quarterly review"),
164
165
  )
165
166
  table_reference = reference(
@@ -171,6 +172,7 @@ class PptxReferenceTest(unittest.TestCase):
171
172
  cellIndex=1,
172
173
  text="42",
173
174
  selectedText="4",
175
+ comment="Double this value",
174
176
  textFingerprint=text_fingerprint("42"),
175
177
  )
176
178