@cydm/pie 2.6.3 → 2.6.4

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.
@@ -1,9 +1,9 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  createAskUserCapability
4
- } from "../../../chunks/chunk-WG6E54WK.js";
5
- import "../../../chunks/chunk-Y4CYXJR7.js";
6
- import "../../../chunks/chunk-O2DKMLNX.js";
4
+ } from "../../../chunks/chunk-3AOMWS2Z.js";
5
+ import "../../../chunks/chunk-YEUBQBOB.js";
6
+ import "../../../chunks/chunk-OCEYHWVX.js";
7
7
  import "../../../chunks/chunk-XXGYUYXI.js";
8
8
  import "../../../chunks/chunk-LZQXQOPJ.js";
9
9
 
@@ -7,9 +7,9 @@ import {
7
7
  isPlanModeSafeCommand,
8
8
  markCompletedPlanSteps,
9
9
  restoreExecutionState
10
- } from "../../../chunks/chunk-WG6E54WK.js";
11
- import "../../../chunks/chunk-Y4CYXJR7.js";
12
- import "../../../chunks/chunk-O2DKMLNX.js";
10
+ } from "../../../chunks/chunk-3AOMWS2Z.js";
11
+ import "../../../chunks/chunk-YEUBQBOB.js";
12
+ import "../../../chunks/chunk-OCEYHWVX.js";
13
13
  import {
14
14
  Type
15
15
  } from "../../../chunks/chunk-XXGYUYXI.js";
@@ -1,13 +1,13 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  createCliHostCapabilities
4
- } from "../../../chunks/chunk-KTSUOXA7.js";
4
+ } from "../../../chunks/chunk-6QEDYZUR.js";
5
5
  import {
6
6
  createSharedFileSystemTools,
7
7
  createSubagentCapability
8
- } from "../../../chunks/chunk-WG6E54WK.js";
9
- import "../../../chunks/chunk-Y4CYXJR7.js";
10
- import "../../../chunks/chunk-O2DKMLNX.js";
8
+ } from "../../../chunks/chunk-3AOMWS2Z.js";
9
+ import "../../../chunks/chunk-YEUBQBOB.js";
10
+ import "../../../chunks/chunk-OCEYHWVX.js";
11
11
  import "../../../chunks/chunk-5353DEEC.js";
12
12
  import "../../../chunks/chunk-XXGYUYXI.js";
13
13
  import "../../../chunks/chunk-LZQXQOPJ.js";
@@ -8,9 +8,9 @@ import {
8
8
  executeManageTodoList,
9
9
  executionStateToTodos,
10
10
  restoreExecutionState
11
- } from "../../../chunks/chunk-WG6E54WK.js";
12
- import "../../../chunks/chunk-Y4CYXJR7.js";
13
- import "../../../chunks/chunk-O2DKMLNX.js";
11
+ } from "../../../chunks/chunk-3AOMWS2Z.js";
12
+ import "../../../chunks/chunk-YEUBQBOB.js";
13
+ import "../../../chunks/chunk-OCEYHWVX.js";
14
14
  import "../../../chunks/chunk-XXGYUYXI.js";
15
15
  import "../../../chunks/chunk-LZQXQOPJ.js";
16
16
 
@@ -2,7 +2,7 @@ import { createRequire as __createRequire } from "node:module"; const require =
2
2
  import {
3
3
  Agent,
4
4
  getToolCallerIdentity
5
- } from "./chunk-Y4CYXJR7.js";
5
+ } from "./chunk-YEUBQBOB.js";
6
6
  import {
7
7
  FileSystemGateway,
8
8
  completeSimple,
@@ -11,7 +11,7 @@ import {
11
11
  getPlatformConfig,
12
12
  hashText,
13
13
  streamSimple
14
- } from "./chunk-O2DKMLNX.js";
14
+ } from "./chunk-OCEYHWVX.js";
15
15
  import {
16
16
  Type
17
17
  } from "./chunk-XXGYUYXI.js";
@@ -3344,7 +3344,10 @@ var FileSessionStore = class {
3344
3344
  const previous = head.metadata;
3345
3345
  const merged = mergeMetadata(previous, {
3346
3346
  ...metadataPatch ?? {},
3347
- entryCount: previous.entryCount + newHeaders.length,
3347
+ // Self-heal drifted counters: seqs are dense, so the committed
3348
+ // frontier is also a lower bound on the entry count. A stale
3349
+ // entryCount (concurrent-writer lost update) must not persist.
3350
+ entryCount: Math.max(previous.entryCount + newHeaders.length, seq),
3348
3351
  messageCount: previous.messageCount + newHeaders.filter((header) => header.type === "message").length,
3349
3352
  rootEntryId: metadataPatch?.rootEntryId ?? previous.rootEntryId ?? newHeaders.find((header) => header.parentSeq === null)?.id ?? null,
3350
3353
  activeEntryId: activeEntryId ?? metadataPatch?.activeEntryId ?? newHeaders[newHeaders.length - 1]?.id ?? previous.activeEntryId
@@ -3419,7 +3422,12 @@ var FileSessionStore = class {
3419
3422
  return {
3420
3423
  summaries: collected.slice(0, limit).map(toSummary),
3421
3424
  hasMore: collected.length > limit,
3422
- total: head.metadata.entryCount
3425
+ // Sequence numbers are dense (one per committed entry), so
3426
+ // committedSeq is the authoritative entry count. metadata.entryCount
3427
+ // can drift behind it when concurrent writers race head manifests
3428
+ // (lost update), which would otherwise surface as ranges like
3429
+ // "seqs 1582-1621 of 1574" in paged UIs.
3430
+ total: Math.max(head.metadata.entryCount, head.committedSeq)
3423
3431
  };
3424
3432
  }
3425
3433
  getEntrySummary(sessionId, entryId) {
@@ -8,7 +8,7 @@ import {
8
8
  createSharedWebSearchTool,
9
9
  interpretShellExit,
10
10
  requestInteraction
11
- } from "./chunk-WG6E54WK.js";
11
+ } from "./chunk-3AOMWS2Z.js";
12
12
  import {
13
13
  getBuiltinDir,
14
14
  getConfigDir
@@ -3223,6 +3223,7 @@ var DEFAULT_OPENAI_COMPAT_STREAM_IDLE_TIMEOUT_MS = 2 * 60 * 1e3;
3223
3223
  var DEFAULT_OPENAI_COMPAT_FIRST_BYTE_TIMEOUT_MS = 3 * 60 * 1e3;
3224
3224
  var OPENAI_COMPAT_FIRST_BYTE_MAX_ESCALATION_STEPS = 3;
3225
3225
  var openAICompatFirstByteTimeoutsByEndpoint = /* @__PURE__ */ new Map();
3226
+ var OPENAI_COMPAT_MAX_DUPLICATE_TOOL_CALLS = 3;
3226
3227
  var OPENAI_COMPAT_PROTOCOL_ERROR_CODE = "provider_response_protocol_error";
3227
3228
  var OpenAICompatProtocolError = class extends Error {
3228
3229
  code = OPENAI_COMPAT_PROTOCOL_ERROR_CODE;
@@ -3679,6 +3680,53 @@ var streamOpenAICompletions = (model, context, options) => {
3679
3680
  });
3680
3681
  }
3681
3682
  }
3683
+ const knownToolNames = new Set((context.tools ?? []).map((tool) => tool.name));
3684
+ const droppedToolCallBlocks = /* @__PURE__ */ new Set();
3685
+ const unknownNameSamples = [];
3686
+ if (knownToolNames.size > 0) {
3687
+ for (let i = toolCallEntries.length - 1; i >= 0; i--) {
3688
+ const entry = toolCallEntries[i];
3689
+ if (entry.block.name.trim() && !knownToolNames.has(entry.block.name)) {
3690
+ if (unknownNameSamples.length < 3) unknownNameSamples.push(JSON.stringify(entry.block.name));
3691
+ droppedToolCallBlocks.add(entry.block);
3692
+ toolCallEntries.splice(i, 1);
3693
+ }
3694
+ }
3695
+ }
3696
+ const emittedCallCounts = /* @__PURE__ */ new Map();
3697
+ const excessDuplicateEntries = /* @__PURE__ */ new Set();
3698
+ for (const entry of toolCallEntries) {
3699
+ const key = `${entry.block.name}
3700
+ ${entry.partialArgs}`;
3701
+ const seen = (emittedCallCounts.get(key) ?? 0) + 1;
3702
+ emittedCallCounts.set(key, seen);
3703
+ if (seen > OPENAI_COMPAT_MAX_DUPLICATE_TOOL_CALLS) excessDuplicateEntries.add(entry);
3704
+ }
3705
+ if (excessDuplicateEntries.size > 0) {
3706
+ for (let i = toolCallEntries.length - 1; i >= 0; i--) {
3707
+ if (excessDuplicateEntries.has(toolCallEntries[i])) {
3708
+ droppedToolCallBlocks.add(toolCallEntries[i].block);
3709
+ toolCallEntries.splice(i, 1);
3710
+ }
3711
+ }
3712
+ }
3713
+ if (droppedToolCallBlocks.size > 0) {
3714
+ const unknownCount = droppedToolCallBlocks.size - excessDuplicateEntries.size;
3715
+ output.content = output.content.filter(
3716
+ (block) => block.type !== "toolCall" || !droppedToolCallBlocks.has(block)
3717
+ );
3718
+ const reasons = [];
3719
+ if (unknownCount > 0) {
3720
+ reasons.push(`${unknownCount} named tools that are not part of this request (samples: ${unknownNameSamples.join(", ")})`);
3721
+ }
3722
+ if (excessDuplicateEntries.size > 0) {
3723
+ reasons.push(`${excessDuplicateEntries.size} were exact duplicates of an earlier call in the same message`);
3724
+ }
3725
+ output.content.push({
3726
+ type: "text",
3727
+ text: `[dropped ${droppedToolCallBlocks.size} tool call${droppedToolCallBlocks.size === 1 ? "" : "s"}: ${reasons.join("; ")}. Re-issue only the intended calls.]`
3728
+ });
3729
+ }
3682
3730
  for (const { block, partialArgs, contentIndex } of toolCallEntries) {
3683
3731
  if (!block.name.trim()) {
3684
3732
  throw createProtocolError("OpenAI-compatible stream returned a tool call without a function name.");
@@ -3,7 +3,7 @@ import {
3
3
  EventStream,
4
4
  streamSimple,
5
5
  validateToolArguments
6
- } from "./chunk-O2DKMLNX.js";
6
+ } from "./chunk-OCEYHWVX.js";
7
7
 
8
8
  // ../../packages/agent-core/src/agent-loop.ts
9
9
  function createLoopErrorMessage(error, config, signal) {
@@ -6,8 +6,8 @@ import {
6
6
  bindToolCallerIdentity,
7
7
  createToolCallerIdentity,
8
8
  getToolCallerIdentity
9
- } from "./chunk-Y4CYXJR7.js";
10
- import "./chunk-O2DKMLNX.js";
9
+ } from "./chunk-YEUBQBOB.js";
10
+ import "./chunk-OCEYHWVX.js";
11
11
  import "./chunk-XXGYUYXI.js";
12
12
  import "./chunk-LZQXQOPJ.js";
13
13
  export {
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  EventStream
4
- } from "./chunk-O2DKMLNX.js";
4
+ } from "./chunk-OCEYHWVX.js";
5
5
  import "./chunk-XXGYUYXI.js";
6
6
  import "./chunk-LZQXQOPJ.js";
7
7
 
package/dist/cli.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  createCliWebResearchHealthStore,
8
8
  formatSize,
9
9
  truncateHeadTail
10
- } from "./chunks/chunk-KTSUOXA7.js";
10
+ } from "./chunks/chunk-6QEDYZUR.js";
11
11
  import {
12
12
  AGENTS_CONTEXT_FILE_NAME,
13
13
  AgentSessionController,
@@ -60,8 +60,8 @@ import {
60
60
  setExtensionEnabledInSettings,
61
61
  shouldPreserveExecutionStateForUserText,
62
62
  supersedeExecutionState
63
- } from "./chunks/chunk-WG6E54WK.js";
64
- import "./chunks/chunk-Y4CYXJR7.js";
63
+ } from "./chunks/chunk-3AOMWS2Z.js";
64
+ import "./chunks/chunk-YEUBQBOB.js";
65
65
  import {
66
66
  Deref,
67
67
  EMPTY_ASSISTANT_CONTENT_ERROR,
@@ -85,7 +85,7 @@ import {
85
85
  setLogger,
86
86
  sortToolModelCandidatesByCapability,
87
87
  type_exports
88
- } from "./chunks/chunk-O2DKMLNX.js";
88
+ } from "./chunks/chunk-OCEYHWVX.js";
89
89
  import {
90
90
  VERSION,
91
91
  getAgentDir,
@@ -73141,8 +73141,11 @@ var TreeSelectorComponent = class {
73141
73141
  /**
73142
73142
  * Iteratively flatten the resident window. Parents always commit before
73143
73143
  * children, so one forward pass resolves in-window ancestry; an explicit
73144
- * stack (no recursion) emits DFS rows whose prefixes are capped to
73145
- * prefixDepthCap segments, so prefix memory stays O(rows).
73144
+ * stack (no recursion) emits DFS rows. Visual depth counts fork points
73145
+ * (see the component doc): a single-child parent continues at its own
73146
+ * level, so a forkless chain renders flat and only real branches indent.
73147
+ * Row prefixes are still capped to prefixDepthCap segments, keeping
73148
+ * prefix memory O(rows).
73146
73149
  */
73147
73150
  rebuildRows() {
73148
73151
  const count = this.pageSummaries.length;
@@ -73155,7 +73158,8 @@ var TreeSelectorComponent = class {
73155
73158
  seqToIndex.set(summary.seq, i);
73156
73159
  const parent = summary.parentSeq === null ? -1 : seqToIndex.get(summary.parentSeq) ?? -1;
73157
73160
  if (parent >= 0) {
73158
- depth[i] = depth[parent] + 1;
73161
+ const parentSummary = this.pageSummaries[parent];
73162
+ depth[i] = depth[parent] + (parentSummary.childCount > 1 ? 1 : 0);
73159
73163
  parentIndex[i] = parent;
73160
73164
  const bucket = childLists[parent];
73161
73165
  if (bucket) bucket.push(i);
@@ -73171,14 +73175,13 @@ var TreeSelectorComponent = class {
73171
73175
  const rows = [];
73172
73176
  const stack = [];
73173
73177
  for (let i = roots.length - 1; i >= 0; i--) {
73174
- stack.push({ index: roots[i], base: "", isLast: i === roots.length - 1 });
73178
+ stack.push({ index: roots[i], base: "", connector: "", rail: "" });
73175
73179
  }
73176
73180
  while (stack.length > 0) {
73177
73181
  const item = stack.pop();
73178
73182
  const summary = this.pageSummaries[item.index];
73179
73183
  const rowDepth = depth[item.index];
73180
- const connector = rowDepth === 0 ? "" : item.isLast ? TREE_CHARS.corner : TREE_CHARS.branch;
73181
- const segments = capSegments(item.base + connector);
73184
+ const segments = capSegments(item.base + item.connector);
73182
73185
  const ancestryHidden = rowDepth > this.prefixDepthCap || summary.parentSeq !== null && parentIndex[item.index] === -1;
73183
73186
  const prefix = ancestryHidden ? TREE_CHARS.hiddenAncestry + segments : segments;
73184
73187
  rows.push({
@@ -73190,10 +73193,21 @@ var TreeSelectorComponent = class {
73190
73193
  if (prefix.length > this.maxPrefixCharsSeen) this.maxPrefixCharsSeen = prefix.length;
73191
73194
  if (this.collapsed.has(summary.id)) continue;
73192
73195
  const children = childLists[item.index];
73193
- if (children === void 0) continue;
73194
- const childBase = capSegments(item.base + (item.isLast ? TREE_CHARS.space : TREE_CHARS.pipe));
73196
+ if (children === void 0 || children.length === 0) continue;
73197
+ const isFork = summary.childCount > 1 || children.length > 1;
73198
+ if (!isFork) {
73199
+ const rail = capSegments(item.rail);
73200
+ stack.push({ index: children[0], base: rail, connector: "", rail });
73201
+ continue;
73202
+ }
73195
73203
  for (let i = children.length - 1; i >= 0; i--) {
73196
- stack.push({ index: children[i], base: childBase, isLast: i === children.length - 1 });
73204
+ const last = i === children.length - 1;
73205
+ stack.push({
73206
+ index: children[i],
73207
+ base: capSegments(item.rail),
73208
+ connector: last ? TREE_CHARS.corner : TREE_CHARS.branch,
73209
+ rail: capSegments(item.rail + (last ? TREE_CHARS.space : TREE_CHARS.pipe))
73210
+ });
73197
73211
  }
73198
73212
  }
73199
73213
  this.rows = rows;
@@ -80251,7 +80265,7 @@ var InteractiveMode = class {
80251
80265
  async init() {
80252
80266
  const activeSession = this.sessionManager.getActiveSession();
80253
80267
  this.thinkingLevel = resolveInitialThinkingLevel({ session: activeSession, settingsManager: this.options.settingsManager });
80254
- const { Agent } = await import("./chunks/src-VCWCE7YV.js");
80268
+ const { Agent } = await import("./chunks/src-XT5S6AUQ.js");
80255
80269
  this.agent = new Agent({
80256
80270
  initialState: {
80257
80271
  systemPrompt: this.buildSystemPrompt(),
@@ -81083,7 +81097,7 @@ async function runPrintMode(params) {
81083
81097
  `);
81084
81098
  console.log("Assistant: ");
81085
81099
  }
81086
- const { Agent: AgentClass } = await import("./chunks/src-VCWCE7YV.js");
81100
+ const { Agent: AgentClass } = await import("./chunks/src-XT5S6AUQ.js");
81087
81101
  let agent;
81088
81102
  const printModeExtensions = await loadPrintModeExtensions({
81089
81103
  cwd: runtime.cwd,
@@ -81944,7 +81958,7 @@ async function runJsonEventsMode(params) {
81944
81958
  return;
81945
81959
  }
81946
81960
  const parent = agent;
81947
- const { Agent: AgentClass } = await import("./chunks/src-VCWCE7YV.js");
81961
+ const { Agent: AgentClass } = await import("./chunks/src-XT5S6AUQ.js");
81948
81962
  const sideAgent = new AgentClass({
81949
81963
  initialState: {
81950
81964
  systemPrompt: parent.state.systemPrompt,
@@ -82288,7 +82302,7 @@ async function runJsonEventsMode(params) {
82288
82302
  if (runtime.initialModel.unconfigured || controller) {
82289
82303
  return;
82290
82304
  }
82291
- const { Agent: AgentClass } = await import("./chunks/src-VCWCE7YV.js");
82305
+ const { Agent: AgentClass } = await import("./chunks/src-XT5S6AUQ.js");
82292
82306
  const jsonModeExtensions = await loadJsonModeExtensions({ runtime, getAgent: () => agent });
82293
82307
  extensionRunner = jsonModeExtensions.runner;
82294
82308
  const tools = [...runtime.tools, ...jsonModeExtensions.extensionTools];
@@ -82882,7 +82896,7 @@ async function runWithJsonEventsConsoleIsolation(fn) {
82882
82896
  }
82883
82897
  async function createCliTestStreamFnFromEnv() {
82884
82898
  if (!process.env.PIE_TEST_MOCK_STREAM_SEQUENCE) return void 0;
82885
- return (await import("./chunks/test-stream-GOSEWMJ3.js")).createTestStreamFnFromSequenceEnv();
82899
+ return (await import("./chunks/test-stream-FNWDHRTM.js")).createTestStreamFnFromSequenceEnv();
82886
82900
  }
82887
82901
  function resolveJsonEventsDetailFlag() {
82888
82902
  for (let index = 0; index < process.argv.length; index += 1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cydm/pie",
3
- "version": "2.6.3",
3
+ "version": "2.6.4",
4
4
  "description": "Pie AI Agent CLI",
5
5
  "type": "module",
6
6
  "bin": {