@cydm/pie 2.7.1 → 2.7.3

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/dist/cli.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  logTransportLifecycle,
24
24
  migrateConfigFromAgentDir,
25
25
  truncateHeadTail
26
- } from "./chunks/chunk-W74NRSRV.js";
26
+ } from "./chunks/chunk-WLLZTG4W.js";
27
27
  import {
28
28
  resolveCliProjectRoot
29
29
  } from "./chunks/chunk-WLFOBECN.js";
@@ -86,8 +86,8 @@ import {
86
86
  shouldPreserveExecutionStateForUserText,
87
87
  supersedeExecutionState,
88
88
  verifyPreparedCompactionCommit
89
- } from "./chunks/chunk-M44CWVDZ.js";
90
- import "./chunks/chunk-NJFPBU36.js";
89
+ } from "./chunks/chunk-F3U2TYDT.js";
90
+ import "./chunks/chunk-MPTME6HX.js";
91
91
  import {
92
92
  Deref,
93
93
  EMPTY_ASSISTANT_CONTENT_ERROR,
@@ -112,7 +112,7 @@ import {
112
112
  sortToolModelCandidatesByCapability,
113
113
  streamSimple,
114
114
  type_exports
115
- } from "./chunks/chunk-XUROMYTT.js";
115
+ } from "./chunks/chunk-E5JQ5SVA.js";
116
116
  import {
117
117
  IsArray,
118
118
  IsBigInt,
@@ -52515,6 +52515,9 @@ function validateCompat(value, label) {
52515
52515
  "store",
52516
52516
  "supportsEncryptedReasoning",
52517
52517
  "responsesContinuation",
52518
+ "supportsReasoningSummary",
52519
+ "reasoningSummary",
52520
+ "timeoutReplay",
52518
52521
  "supportsStore",
52519
52522
  "supportsDeveloperRole",
52520
52523
  "supportsReasoningEffort",
@@ -52531,10 +52534,16 @@ function validateCompat(value, label) {
52531
52534
  if (value.forcedReasoningEffort !== void 0 && value.forcedReasoningEffort !== "none") {
52532
52535
  throw new Error(`${label}.forcedReasoningEffort must be "none"`);
52533
52536
  }
52537
+ if (value.reasoningSummary !== void 0 && !["auto", "concise", "detailed", "none"].includes(String(value.reasoningSummary))) {
52538
+ throw new Error(`${label}.reasoningSummary must be auto | concise | detailed | none`);
52539
+ }
52534
52540
  for (const field of [
52535
52541
  "store",
52536
52542
  "supportsEncryptedReasoning",
52537
52543
  "responsesContinuation",
52544
+ "supportsReasoningSummary",
52545
+ "reasoningSummary",
52546
+ "timeoutReplay",
52538
52547
  "supportsStore",
52539
52548
  "supportsDeveloperRole",
52540
52549
  "supportsReasoningEffort",
@@ -70278,19 +70287,25 @@ var SessionTraceWriter = class extends SessionTraceSnapshotWriter {
70278
70287
  import { createHash as createHash4 } from "crypto";
70279
70288
  function applyContextSignalsToFooter(target) {
70280
70289
  if (!target.agent?.state) return;
70290
+ const state = target.agent.state;
70291
+ const route = {
70292
+ model: state.model ? `${state.model.provider ?? ""}/${state.model.id ?? ""}` : void 0,
70293
+ thinkingLevel: state.thinkingLevel
70294
+ };
70281
70295
  const signals = computeContextSignals(
70282
70296
  target,
70283
- target.agent.state.systemPrompt ?? "",
70284
- target.agent.state.tools,
70285
- target.sessionManager.getMessages()
70297
+ state.systemPrompt ?? "",
70298
+ state.tools,
70299
+ target.sessionManager.getMessages(),
70300
+ route
70286
70301
  );
70287
70302
  target.footer.setState({
70288
70303
  prefixHash: signals.prefixHash,
70289
70304
  prefixHashChanged: signals.prefixHashChanged,
70290
- cacheHitRate: signals.cacheHitRate
70305
+ cacheHitRate: signals.recentCacheHitRate ?? signals.cacheHitRate
70291
70306
  });
70292
70307
  }
70293
- function computePromptPrefixHash(systemPrompt, tools) {
70308
+ function computePromptPrefixHash(systemPrompt, tools, route) {
70294
70309
  return createHash4("sha256").update(
70295
70310
  JSON.stringify({
70296
70311
  systemPrompt,
@@ -70298,19 +70313,25 @@ function computePromptPrefixHash(systemPrompt, tools) {
70298
70313
  name: tool.name,
70299
70314
  description: tool.description ?? "",
70300
70315
  parameters: tool.parameters ?? null
70301
- }))
70316
+ })),
70317
+ route: { model: route?.model ?? "", thinkingLevel: route?.thinkingLevel ?? "" }
70302
70318
  })
70303
70319
  ).digest("hex").slice(0, 8);
70304
70320
  }
70305
- function calculateCumulativeCacheHitRate(messages) {
70306
- let input = 0;
70307
- let cacheRead = 0;
70308
- let cacheWrite = 0;
70309
- let cacheWriteLong = 0;
70321
+ function calculateCumulativeCacheHitRate(messages, recentTurns) {
70322
+ const usages = [];
70310
70323
  for (const message of messages) {
70311
70324
  if (message.role !== "assistant") continue;
70312
70325
  const usage = message.usage;
70313
70326
  if (!usage) continue;
70327
+ usages.push(usage);
70328
+ }
70329
+ const windowed = recentTurns !== void 0 && usages.length > recentTurns ? usages.slice(-recentTurns) : usages;
70330
+ let input = 0;
70331
+ let cacheRead = 0;
70332
+ let cacheWrite = 0;
70333
+ let cacheWriteLong = 0;
70334
+ for (const usage of windowed) {
70314
70335
  input += usage.input;
70315
70336
  cacheRead += usage.cacheRead;
70316
70337
  cacheWrite += usage.cacheWrite;
@@ -70324,14 +70345,16 @@ var lastSignals = /* @__PURE__ */ new WeakMap();
70324
70345
  function getLastContextSignals(hostKey) {
70325
70346
  return lastSignals.get(hostKey) ?? null;
70326
70347
  }
70327
- function computeContextSignals(hostKey, systemPrompt, tools, messages) {
70328
- const prefixHash = computePromptPrefixHash(systemPrompt, tools);
70348
+ var RECENT_HIT_RATE_TURNS = 5;
70349
+ function computeContextSignals(hostKey, systemPrompt, tools, messages, route) {
70350
+ const routeKey = `${route?.model ?? ""}|${route?.thinkingLevel ?? ""}`;
70351
+ const prefixHash = computePromptPrefixHash(systemPrompt, tools, route);
70329
70352
  const systemHash = computePromptPrefixHash(systemPrompt, []);
70330
70353
  const toolsHash = computePromptPrefixHash("", tools);
70331
70354
  const previous = signalMemories.get(hostKey);
70332
70355
  const prefixHashChanged = previous !== void 0 && previous.hash !== prefixHash;
70333
70356
  if (previous?.hash !== prefixHash) {
70334
- signalMemories.set(hostKey, { hash: prefixHash, systemHash, toolsHash });
70357
+ signalMemories.set(hostKey, { hash: prefixHash, systemHash, toolsHash, routeKey });
70335
70358
  }
70336
70359
  const signals = {
70337
70360
  prefixHash,
@@ -70339,7 +70362,9 @@ function computeContextSignals(hostKey, systemPrompt, tools, messages) {
70339
70362
  ...prefixHashChanged && previous ? { previousPrefixHash: previous.hash } : {},
70340
70363
  systemPromptChanged: prefixHashChanged && previous !== void 0 && previous.systemHash !== systemHash,
70341
70364
  toolsChanged: prefixHashChanged && previous !== void 0 && previous.toolsHash !== toolsHash,
70342
- cacheHitRate: calculateCumulativeCacheHitRate(messages)
70365
+ routeChanged: prefixHashChanged && previous !== void 0 && previous.routeKey !== routeKey,
70366
+ cacheHitRate: calculateCumulativeCacheHitRate(messages),
70367
+ recentCacheHitRate: calculateCumulativeCacheHitRate(messages, RECENT_HIT_RATE_TURNS)
70343
70368
  };
70344
70369
  lastSignals.set(hostKey, signals);
70345
70370
  return signals;
@@ -70349,10 +70374,11 @@ function computeContextSignals(hostKey, systemPrompt, tools, messages) {
70349
70374
  function noteCacheInvalidationInChat(host, signals) {
70350
70375
  if (!signals || !signals.prefixHashChanged) return;
70351
70376
  const parts = [];
70377
+ if (signals.routeChanged) parts.push(signals.systemPromptChanged || signals.toolsChanged ? "route + prompt rebuilt" : "model/thinking route changed");
70352
70378
  if (signals.systemPromptChanged && signals.toolsChanged) parts.push("system prompt + tools rebuilt");
70353
70379
  else if (signals.toolsChanged) parts.push("tools rebuilt");
70354
70380
  else if (signals.systemPromptChanged) parts.push("system prompt rebuilt");
70355
- else parts.push("prefix rebuilt");
70381
+ if (parts.length === 0) parts.push("prefix rebuilt");
70356
70382
  const from = signals.previousPrefixHash ?? "?";
70357
70383
  const line = `\u26A1 Prompt cache invalidated: \u2301${from} \u2192 \u2301${signals.prefixHash} (${parts.join(", ")})`;
70358
70384
  if (host.chatContainer && host.ui) {
@@ -70364,7 +70390,8 @@ function noteCacheInvalidationInChat(host, signals) {
70364
70390
  from,
70365
70391
  to: signals.prefixHash,
70366
70392
  systemPromptChanged: signals.systemPromptChanged,
70367
- toolsChanged: signals.toolsChanged
70393
+ toolsChanged: signals.toolsChanged,
70394
+ routeChanged: signals.routeChanged
70368
70395
  });
70369
70396
  }
70370
70397
  function applyContextSignalsWithTrace(host) {
@@ -71363,11 +71390,20 @@ var TreeSelectorComponent = class {
71363
71390
  this.statusMessage = null;
71364
71391
  }
71365
71392
  }
71393
+ /** Cursor on the resident entry with the highest seq (the newest), not the last rendered row. */
71394
+ selectNewestResidentRow(message) {
71395
+ if (this.filteredRows.length === 0) return;
71396
+ let newestIndex = 0;
71397
+ for (let i = 1; i < this.filteredRows.length; i++) {
71398
+ if (this.filteredRows[i].summary.seq > this.filteredRows[newestIndex].summary.seq) newestIndex = i;
71399
+ }
71400
+ this.selectedIndex = newestIndex;
71401
+ if (message !== null) this.statusMessage = message;
71402
+ }
71366
71403
  /** Jump to the newest page. Seqs are 1..total (append-only journal), so the last window starts at total - pageSize. */
71367
71404
  jumpToLastPage() {
71368
71405
  if (this.pageSummaries.length > 0 && !this.hasNext) {
71369
- this.selectedIndex = Math.max(0, this.filteredRows.length - 1);
71370
- this.statusMessage = "latest page - at newest entry";
71406
+ this.selectNewestResidentRow("latest page - at newest entry");
71371
71407
  return;
71372
71408
  }
71373
71409
  let anchor = Math.max(0, this.totalEntries - this.pageSizeValue);
@@ -71377,8 +71413,7 @@ var TreeSelectorComponent = class {
71377
71413
  anchor = this.pageSummaries[this.pageSummaries.length - 1].seq;
71378
71414
  continue;
71379
71415
  }
71380
- this.selectedIndex = Math.max(0, this.filteredRows.length - 1);
71381
- this.statusMessage = null;
71416
+ this.selectNewestResidentRow(null);
71382
71417
  return;
71383
71418
  }
71384
71419
  if (anchor === 0 || !this.hasNext) break;
@@ -74273,6 +74308,9 @@ function isControllerRecovering(host) {
74273
74308
  function handleMessageStart(host, event) {
74274
74309
  if (event.message?.role === "assistant") {
74275
74310
  host.clearContinuationTimeout("assistant_message_start");
74311
+ for (const [id, component] of host.pendingTools) {
74312
+ if (!component.calm) host.pendingTools.delete(id);
74313
+ }
74276
74314
  host.streamingComponent = new AssistantMessageComponent(void 0, host.thinkingLevel === "off");
74277
74315
  host.streamingComponent.setCalmMode(host.calmMode);
74278
74316
  host.streamingMessageHadToolCalls = false;
@@ -75805,13 +75843,18 @@ function handleContextReportCommand(host) {
75805
75843
  const reserveTokens = host.options.settingsManager.getAutoCompactReserveTokens();
75806
75844
  const autoCompactEnabled = host.options.settingsManager.getAutoCompactEnabled();
75807
75845
  const autoCompactLimit = contextWindow > 0 ? getAutoCompactTokenLimit(contextWindow, reserveTokens) ?? null : null;
75846
+ const state = host.agent.state;
75808
75847
  const prefixHash = computePromptPrefixHash(
75809
75848
  systemPrompt,
75810
- host.agent.state.tools.map((tool) => ({
75849
+ state.tools.map((tool) => ({
75811
75850
  name: tool.name,
75812
75851
  description: tool.description,
75813
75852
  parameters: tool.parameters
75814
- }))
75853
+ })),
75854
+ {
75855
+ model: state.model ? `${state.model.provider ?? ""}/${state.model.id ?? ""}` : void 0,
75856
+ thinkingLevel: state.thinkingLevel
75857
+ }
75815
75858
  );
75816
75859
  const lastSignals2 = getLastContextSignals(host);
75817
75860
  const promptPrefixChanged = lastSignals2 !== null && lastSignals2.prefixHash !== prefixHash;
@@ -79879,10 +79922,25 @@ function createCliRetryPolicy(isRetryableErrorOverride) {
79879
79922
  maxRetries: CLI_RETRY_MAX_RETRIES,
79880
79923
  baseDelayMs: getCliRetryBaseDelayMs(),
79881
79924
  maxDelayMs: getCliRetryMaxDelayMs(),
79882
- maxRetriesForFailure: (failure) => failure.kind === "transient_network" ? getCliTransientNetworkMaxRetries() : CLI_RETRY_MAX_RETRIES,
79883
- maxTotalRetries: getCliRetryTotalMaxRetries()
79925
+ maxRetriesForFailure: (failure) => failure.kind === "transient_network" ? getCliTransientNetworkMaxRetries() : failure.replayExempt === true ? getCliTimeoutReplayMaxRetries() : CLI_RETRY_MAX_RETRIES,
79926
+ maxTotalRetries: getCliRetryTotalMaxRetries(),
79927
+ systemicReplayStallLimit: getCliSystemicReplayStallLimit()
79884
79928
  };
79885
79929
  }
79930
+ var CLI_TIMEOUT_REPLAY_MAX_RETRIES = 5;
79931
+ function getCliTimeoutReplayMaxRetries() {
79932
+ const override = process.env.PIE_TIMEOUT_REPLAY_MAX_RETRIES;
79933
+ if (!override) return CLI_TIMEOUT_REPLAY_MAX_RETRIES;
79934
+ const parsed = Number(override);
79935
+ return Number.isFinite(parsed) && parsed >= 0 ? Math.floor(parsed) : CLI_TIMEOUT_REPLAY_MAX_RETRIES;
79936
+ }
79937
+ var CLI_SYSTEMIC_REPLAY_STALL_LIMIT = 3;
79938
+ function getCliSystemicReplayStallLimit() {
79939
+ const override = process.env.PIE_SYSTEMIC_REPLAY_STALL_LIMIT;
79940
+ if (!override) return CLI_SYSTEMIC_REPLAY_STALL_LIMIT;
79941
+ const parsed = Number(override);
79942
+ return Number.isFinite(parsed) && parsed >= 1 ? Math.floor(parsed) : CLI_SYSTEMIC_REPLAY_STALL_LIMIT;
79943
+ }
79886
79944
 
79887
79945
  // src/runtime/interactive-context-ui.ts
79888
79946
  function calculateContextUsage(host) {
@@ -82504,7 +82562,7 @@ var InteractiveMode = class {
82504
82562
  async init() {
82505
82563
  const activeSession = this.sessionManager.getActiveSession();
82506
82564
  this.thinkingLevel = resolveInitialThinkingLevel({ session: activeSession, settingsManager: this.options.settingsManager });
82507
- const { Agent } = await import("./chunks/src-C4KA4G75.js");
82565
+ const { Agent } = await import("./chunks/src-TOJ3HCEX.js");
82508
82566
  this.agent = new Agent({
82509
82567
  initialState: {
82510
82568
  systemPrompt: this.buildSystemPrompt(),
@@ -83362,7 +83420,7 @@ async function runPrintMode(params) {
83362
83420
  `);
83363
83421
  console.log("Assistant: ");
83364
83422
  }
83365
- const { Agent: AgentClass } = await import("./chunks/src-C4KA4G75.js");
83423
+ const { Agent: AgentClass } = await import("./chunks/src-TOJ3HCEX.js");
83366
83424
  let agent;
83367
83425
  const printModeExtensions = await loadPrintModeExtensions({
83368
83426
  cwd: runtime.cwd,
@@ -84215,7 +84273,7 @@ async function runJsonEventsMode(params) {
84215
84273
  return;
84216
84274
  }
84217
84275
  const parent = agent;
84218
- const { Agent: AgentClass } = await import("./chunks/src-C4KA4G75.js");
84276
+ const { Agent: AgentClass } = await import("./chunks/src-TOJ3HCEX.js");
84219
84277
  const sideAgent = new AgentClass({
84220
84278
  initialState: {
84221
84279
  systemPrompt: parent.state.systemPrompt,
@@ -84563,7 +84621,7 @@ async function runJsonEventsMode(params) {
84563
84621
  if (runtime.initialModel.unconfigured || controller) {
84564
84622
  return;
84565
84623
  }
84566
- const { Agent: AgentClass } = await import("./chunks/src-C4KA4G75.js");
84624
+ const { Agent: AgentClass } = await import("./chunks/src-TOJ3HCEX.js");
84567
84625
  const jsonModeExtensions = await loadJsonModeExtensions({ runtime, getAgent: () => agent });
84568
84626
  extensionRunner = jsonModeExtensions.runner;
84569
84627
  const tools = [...runtime.tools, ...jsonModeExtensions.extensionTools];
@@ -85162,7 +85220,7 @@ async function runWithJsonEventsConsoleIsolation(fn) {
85162
85220
  }
85163
85221
  async function createCliTestStreamFnFromEnv() {
85164
85222
  if (!process.env.PIE_TEST_MOCK_STREAM_SEQUENCE) return void 0;
85165
- return (await import("./chunks/test-stream-A5ZELKNG.js")).createTestStreamFnFromSequenceEnv();
85223
+ return (await import("./chunks/test-stream-6426JXLY.js")).createTestStreamFnFromSequenceEnv();
85166
85224
  }
85167
85225
  function resolveJsonEventsDetailFlag() {
85168
85226
  for (let index = 0; index < process.argv.length; index += 1) {
@@ -346,6 +346,21 @@
346
346
  },
347
347
  "cacheCapability": {
348
348
  "$ref": "#/$defs/cacheCapability"
349
+ },
350
+ "supportsReasoningSummary": {
351
+ "type": "boolean"
352
+ },
353
+ "reasoningSummary": {
354
+ "type": "string",
355
+ "enum": [
356
+ "auto",
357
+ "concise",
358
+ "detailed",
359
+ "none"
360
+ ]
361
+ },
362
+ "timeoutReplay": {
363
+ "type": "boolean"
349
364
  }
350
365
  }
351
366
  },
@@ -363,7 +378,11 @@
363
378
  },
364
379
  "api": {
365
380
  "type": "string",
366
- "enum": ["openai-completions", "openai-responses", "anthropic-messages"]
381
+ "enum": [
382
+ "openai-completions",
383
+ "openai-responses",
384
+ "anthropic-messages"
385
+ ]
367
386
  },
368
387
  "model": {
369
388
  "type": "object",
@@ -467,7 +486,9 @@
467
486
  "endpoints": {
468
487
  "type": "object",
469
488
  "description": "Optional API-specific roots; keys must be supported APIs. Routing relationships are validated by the runtime.",
470
- "propertyNames": { "$ref": "#/$defs/api" },
489
+ "propertyNames": {
490
+ "$ref": "#/$defs/api"
491
+ },
471
492
  "additionalProperties": {
472
493
  "type": "string",
473
494
  "format": "uri",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cydm/pie",
3
- "version": "2.7.1",
3
+ "version": "2.7.3",
4
4
  "description": "Pie AI Agent CLI",
5
5
  "type": "module",
6
6
  "bin": {