@cydm/pie 1.0.44 → 1.0.46

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-7C5E245X.js";
5
- import "../../../chunks/chunk-JVLAKTAS.js";
6
- import "../../../chunks/chunk-NGQ3PUOC.js";
4
+ } from "../../../chunks/chunk-PKR3PO73.js";
5
+ import "../../../chunks/chunk-FKAO25XH.js";
6
+ import "../../../chunks/chunk-K6ZOCJ4V.js";
7
7
  import "../../../chunks/chunk-LZQXQOPJ.js";
8
8
 
9
9
  // builtin/extensions/ask-user/index.ts
@@ -7,11 +7,11 @@ import {
7
7
  isPlanModeSafeCommand,
8
8
  markCompletedPlanSteps,
9
9
  restoreExecutionState
10
- } from "../../../chunks/chunk-7C5E245X.js";
11
- import "../../../chunks/chunk-JVLAKTAS.js";
10
+ } from "../../../chunks/chunk-PKR3PO73.js";
11
+ import "../../../chunks/chunk-FKAO25XH.js";
12
12
  import {
13
13
  Type
14
- } from "../../../chunks/chunk-NGQ3PUOC.js";
14
+ } from "../../../chunks/chunk-K6ZOCJ4V.js";
15
15
  import "../../../chunks/chunk-LZQXQOPJ.js";
16
16
 
17
17
  // builtin/extensions/plan-mode/index.ts
@@ -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-DSVPYK5S.js";
4
+ } from "../../../chunks/chunk-75JWZPRK.js";
5
5
  import {
6
6
  createSharedFileSystemTools,
7
7
  createSubagentCapability
8
- } from "../../../chunks/chunk-7C5E245X.js";
9
- import "../../../chunks/chunk-JVLAKTAS.js";
10
- import "../../../chunks/chunk-NGQ3PUOC.js";
8
+ } from "../../../chunks/chunk-PKR3PO73.js";
9
+ import "../../../chunks/chunk-FKAO25XH.js";
10
+ import "../../../chunks/chunk-K6ZOCJ4V.js";
11
11
  import "../../../chunks/chunk-LZQXQOPJ.js";
12
12
 
13
13
  // builtin/extensions/subagent/index.ts
@@ -7,9 +7,9 @@ import {
7
7
  executeManageTodoList,
8
8
  executionStateToTodos,
9
9
  restoreExecutionState
10
- } from "../../../chunks/chunk-7C5E245X.js";
11
- import "../../../chunks/chunk-JVLAKTAS.js";
12
- import "../../../chunks/chunk-NGQ3PUOC.js";
10
+ } from "../../../chunks/chunk-PKR3PO73.js";
11
+ import "../../../chunks/chunk-FKAO25XH.js";
12
+ import "../../../chunks/chunk-K6ZOCJ4V.js";
13
13
  import "../../../chunks/chunk-LZQXQOPJ.js";
14
14
 
15
15
  // builtin/extensions/todo/index.ts
@@ -8,10 +8,10 @@ import {
8
8
  createSharedWebSearchTool,
9
9
  interpretShellExit,
10
10
  requestInteraction
11
- } from "./chunk-7C5E245X.js";
11
+ } from "./chunk-PKR3PO73.js";
12
12
  import {
13
13
  Type
14
- } from "./chunk-NGQ3PUOC.js";
14
+ } from "./chunk-K6ZOCJ4V.js";
15
15
 
16
16
  // src/config.ts
17
17
  import { existsSync, mkdirSync, readFileSync, renameSync } from "fs";
@@ -3,7 +3,7 @@ import {
3
3
  EventStream,
4
4
  streamSimple,
5
5
  validateToolArguments
6
- } from "./chunk-NGQ3PUOC.js";
6
+ } from "./chunk-K6ZOCJ4V.js";
7
7
 
8
8
  // ../../packages/agent-core/src/agent-loop.ts
9
9
  function createLoopErrorMessage(error, config, signal) {
@@ -4238,9 +4238,10 @@ var NodeHttpClient = class {
4238
4238
  async request(url, options = {}) {
4239
4239
  const requestStartTime = Date.now();
4240
4240
  const requestId = `${Date.now()}-${Math.random().toString(36).slice(2, 7)}`;
4241
+ const reqTag = options.label ? `${requestId}/${options.label}` : requestId;
4241
4242
  const requestTimeoutMs = options.timeoutMs ?? 6e4;
4242
4243
  let requestTimeoutError;
4243
- logHttp("DEBUG", `Request [${requestId}] started`, {
4244
+ logHttp("DEBUG", `Request [${reqTag}] started`, {
4244
4245
  url: url.slice(0, 100),
4245
4246
  method: options.method || "GET",
4246
4247
  hasBody: !!options.body
@@ -4278,7 +4279,7 @@ var NodeHttpClient = class {
4278
4279
  agentStats.httpReusedConnections++;
4279
4280
  }
4280
4281
  }
4281
- logHttp("DEBUG", `Request [${requestId}] connected`, {
4282
+ logHttp("DEBUG", `Request [${reqTag}] connected`, {
4282
4283
  status: res.statusCode,
4283
4284
  connectTimeMs: connectTime,
4284
4285
  connectionReused: wasReused,
@@ -4301,14 +4302,14 @@ var NodeHttpClient = class {
4301
4302
  res.on("data", (chunk) => chunks.push(chunk));
4302
4303
  res.on("end", () => {
4303
4304
  const body = Buffer.concat(chunks).toString("utf-8");
4304
- logHttp("DEBUG", `Request [${requestId}] body received`, {
4305
+ logHttp("DEBUG", `Request [${reqTag}] body received`, {
4305
4306
  bodyLength: body.length,
4306
4307
  totalTimeMs: Date.now() - requestStartTime
4307
4308
  });
4308
4309
  resolveText(body);
4309
4310
  });
4310
4311
  res.on("error", (err) => {
4311
- logHttp("ERROR", `Request [${requestId}] body read error`, { error: err.message });
4312
+ logHttp("ERROR", `Request [${reqTag}] body read error`, { error: err.message });
4312
4313
  rejectText(err);
4313
4314
  });
4314
4315
  });
@@ -4318,7 +4319,7 @@ var NodeHttpClient = class {
4318
4319
  try {
4319
4320
  return JSON.parse(text);
4320
4321
  } catch (err) {
4321
- logHttp("ERROR", `Request [${requestId}] JSON parse error`, {
4322
+ logHttp("ERROR", `Request [${reqTag}] JSON parse error`, {
4322
4323
  error: err.message,
4323
4324
  textPreview: text.slice(0, 200)
4324
4325
  });
@@ -4351,7 +4352,15 @@ var NodeHttpClient = class {
4351
4352
  error = e;
4352
4353
  done = true;
4353
4354
  wake({ done: true, value: void 0 });
4354
- logHttp("ERROR", `Request [${requestId}] SSE stream error`, { error: e.message });
4355
+ if (signal?.aborted === true || isAbortErrorMessage(e.message)) {
4356
+ logHttp("INFO", `Request [${reqTag}] SSE stream aborted by caller`, { error: e.message });
4357
+ } else if (requestTimeoutError) {
4358
+ logHttp("WARN", `Request [${reqTag}] SSE stream failed (request timeout)`, { error: e.message });
4359
+ } else if (e.message === "SSE stream aborted" || e.message === "SSE stream closed before end" || e.message === "SSE stream ended before response completed") {
4360
+ logHttp("WARN", `Request [${reqTag}] SSE stream closed by remote`, { error: e.message });
4361
+ } else {
4362
+ logHttp("ERROR", `Request [${reqTag}] SSE stream error`, { error: e.message });
4363
+ }
4355
4364
  };
4356
4365
  const flushBuffer = (final = false) => {
4357
4366
  if (final) {
@@ -4403,7 +4412,7 @@ var NodeHttpClient = class {
4403
4412
  }
4404
4413
  done = true;
4405
4414
  wake({ done: true, value: void 0 });
4406
- logHttp("DEBUG", `Request [${requestId}] SSE stream ended`, {
4415
+ logHttp("DEBUG", `Request [${reqTag}] SSE stream ended`, {
4407
4416
  totalBytes,
4408
4417
  lineCount,
4409
4418
  durationMs: Date.now() - sseStartTime
@@ -4454,13 +4463,13 @@ var NodeHttpClient = class {
4454
4463
  });
4455
4464
  req.on("error", (e) => {
4456
4465
  if (isAbortErrorMessage(e.message) && options.signal?.aborted) {
4457
- logHttp("DEBUG", `Request [${requestId}] aborted`, {
4466
+ logHttp("DEBUG", `Request [${reqTag}] aborted`, {
4458
4467
  totalTimeMs: Date.now() - requestStartTime
4459
4468
  });
4460
4469
  reject(e);
4461
4470
  return;
4462
4471
  }
4463
- logHttp("ERROR", `Request [${requestId}] failed`, {
4472
+ logHttp("ERROR", `Request [${reqTag}] failed`, {
4464
4473
  error: e.message,
4465
4474
  totalTimeMs: Date.now() - requestStartTime
4466
4475
  });
@@ -4468,13 +4477,13 @@ var NodeHttpClient = class {
4468
4477
  });
4469
4478
  req.on("timeout", () => {
4470
4479
  requestTimeoutError = new Error("Request timeout");
4471
- logHttp("ERROR", `Request [${requestId}] timeout`);
4480
+ logHttp("ERROR", `Request [${reqTag}] timeout`);
4472
4481
  req.destroy(requestTimeoutError);
4473
4482
  });
4474
4483
  req.setTimeout(requestTimeoutMs);
4475
4484
  if (options.signal) {
4476
4485
  options.signal.addEventListener("abort", () => {
4477
- logHttp("DEBUG", `Request [${requestId}] aborted`);
4486
+ logHttp("DEBUG", `Request [${reqTag}] aborted`);
4478
4487
  req.destroy(new Error("Request was aborted"));
4479
4488
  }, { once: true });
4480
4489
  }
@@ -5723,7 +5732,9 @@ var streamOpenAICompletions = (model, context, options) => {
5723
5732
  headers,
5724
5733
  body: JSON.stringify(params),
5725
5734
  signal: options?.signal,
5726
- timeoutMs: options?.timeoutMs ?? getOpenAICompatStreamTimeoutMs()
5735
+ timeoutMs: options?.timeoutMs ?? getOpenAICompatStreamTimeoutMs(),
5736
+ // Log attribution only (never sent over the wire).
5737
+ label: `${model.provider}/${model.id}`
5727
5738
  });
5728
5739
  if (!response.ok) {
5729
5740
  const errorBody = await response.text().catch(() => "");
@@ -5993,11 +6004,24 @@ var streamOpenAICompletions = (model, context, options) => {
5993
6004
  throw createProtocolError(`OpenAI-compatible stream ended with finish_reason=${rawFinishReason} but did not include any tool calls.`);
5994
6005
  }
5995
6006
  if (output.stopReason === "length" && toolCallEntries.length > 0) {
5996
- const hasTruncatedArgs = toolCallEntries.some(
6007
+ const truncatedEntries = toolCallEntries.filter(
5997
6008
  ({ partialArgs }) => tryParseFinalToolArguments(partialArgs) === null
5998
6009
  );
5999
- if (hasTruncatedArgs) {
6000
- throw new Error("OpenAI-compatible stream ended with finish_reason=length before tool call arguments were complete. Increase maxTokens or reduce prompt size.");
6010
+ if (truncatedEntries.length > 0) {
6011
+ const truncatedBlocks = new Set(truncatedEntries.map((entry) => entry.block));
6012
+ for (let i = toolCallEntries.length - 1; i >= 0; i--) {
6013
+ if (truncatedBlocks.has(toolCallEntries[i].block)) {
6014
+ toolCallEntries.splice(i, 1);
6015
+ }
6016
+ }
6017
+ output.content = output.content.filter(
6018
+ (block) => block.type !== "toolCall" || !truncatedBlocks.has(block)
6019
+ );
6020
+ const dropped = truncatedEntries.map((entry) => entry.block.name || "unnamed").sort().map((name) => `"${name}"`).join(", ");
6021
+ output.content.push({
6022
+ type: "text",
6023
+ text: `[output truncated: finish_reason=length cut ${truncatedEntries.length === 1 ? "a tool call" : `${truncatedEntries.length} tool calls`} mid-arguments (${dropped}); the call${truncatedEntries.length === 1 ? " was" : "s were"} dropped. Re-issue the call or continue with fewer/smaller requests.]`
6024
+ });
6001
6025
  }
6002
6026
  }
6003
6027
  for (const { block, partialArgs, contentIndex } of toolCallEntries) {
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  Agent
4
- } from "./chunk-JVLAKTAS.js";
4
+ } from "./chunk-FKAO25XH.js";
5
5
  import {
6
6
  FileSystemGateway,
7
7
  Type,
@@ -11,7 +11,7 @@ import {
11
11
  getPlatformConfig,
12
12
  hashText,
13
13
  streamSimple
14
- } from "./chunk-NGQ3PUOC.js";
14
+ } from "./chunk-K6ZOCJ4V.js";
15
15
  import {
16
16
  __commonJS,
17
17
  __toESM
@@ -3,8 +3,8 @@ import {
3
3
  Agent,
4
4
  agentLoop,
5
5
  agentLoopContinue
6
- } from "./chunk-JVLAKTAS.js";
7
- import "./chunk-NGQ3PUOC.js";
6
+ } from "./chunk-FKAO25XH.js";
7
+ import "./chunk-K6ZOCJ4V.js";
8
8
  import "./chunk-LZQXQOPJ.js";
9
9
  export {
10
10
  Agent,
@@ -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-NGQ3PUOC.js";
4
+ } from "./chunk-K6ZOCJ4V.js";
5
5
  import "./chunk-LZQXQOPJ.js";
6
6
 
7
7
  // src/app/test-stream.ts
package/dist/cli.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  getThemesDir,
20
20
  migrateConfigFromAgentDir,
21
21
  truncateHeadTail
22
- } from "./chunks/chunk-DSVPYK5S.js";
22
+ } from "./chunks/chunk-75JWZPRK.js";
23
23
  import {
24
24
  AGENTS_CONTEXT_FILE_NAME,
25
25
  AgentSessionController,
@@ -69,8 +69,8 @@ import {
69
69
  setExtensionEnabledInSettings,
70
70
  shouldPreserveExecutionStateForUserText,
71
71
  supersedeExecutionState
72
- } from "./chunks/chunk-7C5E245X.js";
73
- import "./chunks/chunk-JVLAKTAS.js";
72
+ } from "./chunks/chunk-PKR3PO73.js";
73
+ import "./chunks/chunk-FKAO25XH.js";
74
74
  import {
75
75
  Deref,
76
76
  EMPTY_ASSISTANT_CONTENT_ERROR,
@@ -106,7 +106,7 @@ import {
106
106
  setLogger,
107
107
  sortToolModelCandidatesByCapability,
108
108
  type_exports
109
- } from "./chunks/chunk-NGQ3PUOC.js";
109
+ } from "./chunks/chunk-K6ZOCJ4V.js";
110
110
  import {
111
111
  resolveCliProjectRoot
112
112
  } from "./chunks/chunk-WLFOBECN.js";
@@ -61840,7 +61840,6 @@ var BUILTIN_SLASH_COMMANDS = [
61840
61840
  { name: "settings/theme", description: "Change theme" },
61841
61841
  { name: "settings/thinking", description: "Set thinking level" },
61842
61842
  { name: "settings/calm", description: "Toggle calm mode: show only questions and answers" },
61843
- { name: "calm", description: "Alias for /settings/calm" },
61844
61843
  { name: "settings/yolo", description: "Toggle or set YOLO mode" },
61845
61844
  { name: "settings/debugs/cache-test", description: "Run provider cache diagnostics with a dedicated 2-request probe" },
61846
61845
  { name: "settings/debugs/context", description: "Append a context summary to ~/.pie/logs/pie-cli.log" },
@@ -65272,10 +65271,6 @@ function registerBuiltinCommands(host) {
65272
65271
  description: "Toggle calm mode: show only questions and answers (on/off/status)",
65273
65272
  handler: (_2, args) => host.handleCalmCommand(args)
65274
65273
  });
65275
- commandTree.register(["calm"], {
65276
- description: "Alias for /settings/calm (questions and answers only)",
65277
- handler: (_2, args) => host.handleCalmCommand(args)
65278
- });
65279
65274
  commandTree.register(["settings", "extensions"], {
65280
65275
  description: "List extensions and manage enable/disable toggles",
65281
65276
  handler: (_2, args) => host.handleExtensionsCommand(args)
@@ -70714,7 +70709,7 @@ var InteractiveMode = class {
70714
70709
  if (savedLevel) {
70715
70710
  this.thinkingLevel = savedLevel;
70716
70711
  }
70717
- const { Agent } = await import("./chunks/src-TQNFXZGK.js");
70712
+ const { Agent } = await import("./chunks/src-HYZFAW4V.js");
70718
70713
  const activeSession = this.sessionManager.getActiveSession();
70719
70714
  this.agent = new Agent({
70720
70715
  initialState: {
@@ -70932,7 +70927,7 @@ var InteractiveMode = class {
70932
70927
  this.todoWidget.setCalmMode(enabled);
70933
70928
  this.extensionWidgets.setCalmMode(enabled);
70934
70929
  this.showStatus(`Calm mode ${enabled ? "on \u2014 showing questions and answers only" : "off"}`);
70935
- this.safeRequestRender();
70930
+ this.safeRequestRender(true);
70936
70931
  }
70937
70932
  async handleCalmCommand(args) {
70938
70933
  return handleCalmCommand(this, args);
@@ -71503,7 +71498,7 @@ async function runPrintMode(params) {
71503
71498
  `);
71504
71499
  console.log("Assistant: ");
71505
71500
  }
71506
- const { Agent: AgentClass } = await import("./chunks/src-TQNFXZGK.js");
71501
+ const { Agent: AgentClass } = await import("./chunks/src-HYZFAW4V.js");
71507
71502
  let agent;
71508
71503
  const printModeExtensions = await loadPrintModeExtensions({
71509
71504
  cwd: runtime.cwd,
@@ -72470,7 +72465,7 @@ async function runJsonEventsMode(params) {
72470
72465
  if (runtime.initialModel.unconfigured || controller) {
72471
72466
  return;
72472
72467
  }
72473
- const { Agent: AgentClass } = await import("./chunks/src-TQNFXZGK.js");
72468
+ const { Agent: AgentClass } = await import("./chunks/src-HYZFAW4V.js");
72474
72469
  const jsonModeExtensions = await loadJsonModeExtensions({ runtime, getAgent: () => agent });
72475
72470
  const tools = [...runtime.tools, ...jsonModeExtensions.extensionTools];
72476
72471
  const restoredApiKey = runtime.modelRegistry.getApiKey(runtime.model);
@@ -73104,7 +73099,7 @@ async function runWithJsonEventsConsoleIsolation(fn) {
73104
73099
  }
73105
73100
  async function createCliTestStreamFnFromEnv() {
73106
73101
  if (!process.env.PIE_TEST_MOCK_STREAM_SEQUENCE) return void 0;
73107
- return (await import("./chunks/test-stream-IPBFEEWH.js")).createTestStreamFnFromSequenceEnv();
73102
+ return (await import("./chunks/test-stream-XCE2KXJU.js")).createTestStreamFnFromSequenceEnv();
73108
73103
  }
73109
73104
  async function startChat(initialPrompt, testCommand) {
73110
73105
  const rawOutput = process.argv.includes("--raw-output");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cydm/pie",
3
- "version": "1.0.44",
3
+ "version": "1.0.46",
4
4
  "description": "Pie AI Agent CLI",
5
5
  "type": "module",
6
6
  "bin": {