@cydm/pie 1.0.25 → 1.0.26

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,7 +1,7 @@
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-O4DPFYYP.js";
4
+ } from "../../../chunks/chunk-L63BJMTT.js";
5
5
  import "../../../chunks/chunk-4B42ZU4B.js";
6
6
  import "../../../chunks/chunk-64XJIKVK.js";
7
7
  import "../../../chunks/chunk-TG2EQLX2.js";
@@ -7,7 +7,7 @@ import {
7
7
  isPlanModeSafeCommand,
8
8
  markCompletedPlanSteps,
9
9
  restoreExecutionState
10
- } from "../../../chunks/chunk-O4DPFYYP.js";
10
+ } from "../../../chunks/chunk-L63BJMTT.js";
11
11
  import "../../../chunks/chunk-4B42ZU4B.js";
12
12
  import "../../../chunks/chunk-64XJIKVK.js";
13
13
  import "../../../chunks/chunk-TG2EQLX2.js";
@@ -1,11 +1,11 @@
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-BEWVRLCP.js";
4
+ } from "../../../chunks/chunk-GARJAWH6.js";
5
5
  import {
6
6
  createSharedFileSystemTools,
7
7
  createSubagentCapability
8
- } from "../../../chunks/chunk-O4DPFYYP.js";
8
+ } from "../../../chunks/chunk-L63BJMTT.js";
9
9
  import "../../../chunks/chunk-4B42ZU4B.js";
10
10
  import "../../../chunks/chunk-64XJIKVK.js";
11
11
  import "../../../chunks/chunk-TG2EQLX2.js";
@@ -7,7 +7,7 @@ import {
7
7
  executeManageTodoList,
8
8
  executionStateToTodos,
9
9
  restoreExecutionState
10
- } from "../../../chunks/chunk-O4DPFYYP.js";
10
+ } from "../../../chunks/chunk-L63BJMTT.js";
11
11
  import "../../../chunks/chunk-4B42ZU4B.js";
12
12
  import "../../../chunks/chunk-64XJIKVK.js";
13
13
  import "../../../chunks/chunk-TG2EQLX2.js";
@@ -7,7 +7,7 @@ import {
7
7
  createSharedWebSearchTool,
8
8
  interpretShellExit,
9
9
  requestInteraction
10
- } from "./chunk-O4DPFYYP.js";
10
+ } from "./chunk-L63BJMTT.js";
11
11
  import {
12
12
  Type
13
13
  } from "./chunk-64XJIKVK.js";
@@ -2945,6 +2945,62 @@ function generateSessionId() {
2945
2945
  const random = Math.random().toString(36).substring(2, 8);
2946
2946
  return `${timestamp}-${random}`;
2947
2947
  }
2948
+ function isRecord2(value) {
2949
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2950
+ }
2951
+ function normalizeSessionDisplayName(raw) {
2952
+ const title = raw.trim().replace(/\s+/g, " ").slice(0, 60);
2953
+ if (!title) return null;
2954
+ if (title.startsWith("/")) return null;
2955
+ return title;
2956
+ }
2957
+ function extractUserText(message) {
2958
+ if (!isRecord2(message) || message.role !== "user") return "";
2959
+ const content = message.content;
2960
+ if (typeof content === "string") return content;
2961
+ if (!Array.isArray(content)) return "";
2962
+ return content.map((block) => isRecord2(block) && block.type === "text" && typeof block.text === "string" ? block.text : "").join(" ");
2963
+ }
2964
+ function isAutoGeneratedSessionName(name) {
2965
+ return /^Session (\d|[a-z0-9]{6,8}$)/i.test(name.trim());
2966
+ }
2967
+ function firstUserTitleOnActivePath(entries, activeEntryId) {
2968
+ if (!activeEntryId) return null;
2969
+ const byId = new Map(entries.map((entry) => [entry.id, entry]));
2970
+ const path4 = [];
2971
+ let current = activeEntryId;
2972
+ while (current) {
2973
+ const entry = byId.get(current);
2974
+ if (!entry) break;
2975
+ path4.unshift(entry);
2976
+ current = entry.parentId;
2977
+ }
2978
+ for (const entry of path4) {
2979
+ if (entry.type !== "message") continue;
2980
+ const title = normalizeSessionDisplayName(extractUserText(entry.message));
2981
+ if (title) return title;
2982
+ }
2983
+ return null;
2984
+ }
2985
+ function canAutoDeriveSessionName(metadata) {
2986
+ const nameSource = metadata.nameSource;
2987
+ return nameSource === "generated" || nameSource === "derived" || nameSource === void 0 && isAutoGeneratedSessionName(metadata.name);
2988
+ }
2989
+ function applyDerivedSessionName(metadata, entries) {
2990
+ if (!canAutoDeriveSessionName(metadata)) return false;
2991
+ const title = firstUserTitleOnActivePath(entries, metadata.activeEntryId);
2992
+ if (title) {
2993
+ const changed = metadata.name !== title || metadata.nameSource !== "derived";
2994
+ metadata.name = title;
2995
+ metadata.nameSource = "derived";
2996
+ return changed;
2997
+ }
2998
+ if (metadata.nameSource === void 0) {
2999
+ metadata.nameSource = "generated";
3000
+ return true;
3001
+ }
3002
+ return false;
3003
+ }
2948
3004
  var SessionManager = class {
2949
3005
  store;
2950
3006
  activeSession = null;
@@ -3008,6 +3064,7 @@ var SessionManager = class {
3008
3064
  metadata: {
3009
3065
  id,
3010
3066
  name: name ?? `Session ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
3067
+ nameSource: name ? "manual" : "generated",
3011
3068
  createdAt: Date.now(),
3012
3069
  updatedAt: Date.now(),
3013
3070
  entryCount: 0,
@@ -3070,6 +3127,7 @@ var SessionManager = class {
3070
3127
  this.activeSession.metadata.rootEntryId = this.activeSession.entries.find(
3071
3128
  (e) => e.parentId === null
3072
3129
  )?.id ?? null;
3130
+ applyDerivedSessionName(this.activeSession.metadata, this.activeSession.entries);
3073
3131
  await this.store.save(
3074
3132
  this.activeSession.id,
3075
3133
  this.activeSession.entries,
@@ -3316,6 +3374,7 @@ var SessionManager = class {
3316
3374
  throw new Error("No active session");
3317
3375
  }
3318
3376
  this.activeSession.metadata.name = name;
3377
+ this.activeSession.metadata.nameSource = "manual";
3319
3378
  this.activeSession.isDirty = true;
3320
3379
  await this.save();
3321
3380
  }
@@ -3354,6 +3413,25 @@ var SessionManager = class {
3354
3413
  const all = await this.store.listMetadata();
3355
3414
  return { metadata: all.slice(0, limit), totalCount: all.length };
3356
3415
  }
3416
+ /**
3417
+ * Refresh an inactive session's display name from its first user prompt when
3418
+ * it still has an auto-generated name. This is used by /resume to lazily
3419
+ * repair legacy sessions as the user points at them, without scanning every
3420
+ * session on open or changing its metadata updatedAt value.
3421
+ */
3422
+ async refreshDerivedName(sessionId) {
3423
+ const data = await this.store.load(sessionId);
3424
+ if (!data) return null;
3425
+ const nextMetadata = { ...data.metadata };
3426
+ if (!applyDerivedSessionName(nextMetadata, data.entries)) {
3427
+ return data.metadata;
3428
+ }
3429
+ await this.store.save(sessionId, data.entries, {
3430
+ ...nextMetadata,
3431
+ updatedAt: data.metadata.updatedAt
3432
+ });
3433
+ return await this.store.getMetadata(sessionId) ?? nextMetadata;
3434
+ }
3357
3435
  /**
3358
3436
  * Check if a session exists
3359
3437
  */
@@ -10511,23 +10589,23 @@ async function understandFileWithModel(deps, request) {
10511
10589
  }
10512
10590
 
10513
10591
  // ../../packages/shared-headless-capabilities/src/session-trace.ts
10514
- function isRecord2(value) {
10592
+ function isRecord3(value) {
10515
10593
  return !!value && typeof value === "object" && !Array.isArray(value);
10516
10594
  }
10517
10595
  function getTextFromMessageContent(content) {
10518
10596
  if (typeof content === "string") return content;
10519
10597
  if (!Array.isArray(content)) return "";
10520
- return content.filter((block) => isRecord2(block) && block.type === "text").map((block) => String(block.text || "")).join("");
10598
+ return content.filter((block) => isRecord3(block) && block.type === "text").map((block) => String(block.text || "")).join("");
10521
10599
  }
10522
10600
  function summarizeToolResult(result) {
10523
- if (!isRecord2(result)) return void 0;
10601
+ if (!isRecord3(result)) return void 0;
10524
10602
  const content = Array.isArray(result.content) ? result.content : [];
10525
- const text = content.filter((item) => isRecord2(item) && item.type === "text").map((item) => String(item.text || "")).join("\n").trim();
10603
+ const text = content.filter((item) => isRecord3(item) && item.type === "text").map((item) => String(item.text || "")).join("\n").trim();
10526
10604
  if (!text) return void 0;
10527
10605
  return text.length > 500 ? `${text.slice(0, 500)}...` : text;
10528
10606
  }
10529
10607
  function summarizeToolResultDetails(result) {
10530
- if (!isRecord2(result) || !isRecord2(result.details)) return void 0;
10608
+ if (!isRecord3(result) || !isRecord3(result.details)) return void 0;
10531
10609
  const details = result.details;
10532
10610
  const keys = [
10533
10611
  "providerMode",
@@ -10562,7 +10640,7 @@ function summarizeToolResultDetails(result) {
10562
10640
  const value = details[key];
10563
10641
  if (key === "attempts" && Array.isArray(value)) {
10564
10642
  summary[key] = value.slice(-5).map((attempt) => {
10565
- if (!isRecord2(attempt)) return attempt;
10643
+ if (!isRecord3(attempt)) return attempt;
10566
10644
  return {
10567
10645
  provider: attempt.provider,
10568
10646
  modelId: attempt.modelId,
@@ -10580,7 +10658,7 @@ function summarizeToolResultDetails(result) {
10580
10658
  summary[key] = {
10581
10659
  count: value.length,
10582
10660
  items: value.slice(0, 5).map((entry) => {
10583
- if (!isRecord2(entry)) return entry;
10661
+ if (!isRecord3(entry)) return entry;
10584
10662
  return {
10585
10663
  url: entry.finalUrl || entry.url,
10586
10664
  title: entry.title,
@@ -10596,7 +10674,7 @@ function summarizeToolResultDetails(result) {
10596
10674
  }
10597
10675
  if (key === "providerHealth" && Array.isArray(value)) {
10598
10676
  summary[key] = value.slice(0, 5).map((entry) => {
10599
- if (!isRecord2(entry)) return entry;
10677
+ if (!isRecord3(entry)) return entry;
10600
10678
  return {
10601
10679
  routeKey: entry.routeKey,
10602
10680
  attempts: entry.attempts,
@@ -10611,7 +10689,7 @@ function summarizeToolResultDetails(result) {
10611
10689
  }
10612
10690
  if (key === "providerAttempts" && Array.isArray(value)) {
10613
10691
  summary[key] = value.slice(-5).map((attempt) => {
10614
- if (!isRecord2(attempt)) return attempt;
10692
+ if (!isRecord3(attempt)) return attempt;
10615
10693
  return {
10616
10694
  provider: attempt.provider,
10617
10695
  modelId: attempt.modelId,
@@ -10643,10 +10721,10 @@ function summarizeString(value, maxLength = 300) {
10643
10721
  return value.length > maxLength ? `${value.slice(0, maxLength)}...` : value;
10644
10722
  }
10645
10723
  function summarizeMessage(message) {
10646
- if (!isRecord2(message)) return typeof message;
10724
+ if (!isRecord3(message)) return typeof message;
10647
10725
  if ("contentBlocks" in message && !("content" in message)) return message;
10648
10726
  const content = Array.isArray(message.content) ? message.content : [];
10649
- const blockTypes = content.filter(isRecord2).map((block) => String(block.type || "unknown")).slice(0, 10);
10727
+ const blockTypes = content.filter(isRecord3).map((block) => String(block.type || "unknown")).slice(0, 10);
10650
10728
  const text = getTextFromMessageContent(content);
10651
10729
  return {
10652
10730
  role: message.role,
@@ -10658,12 +10736,12 @@ function summarizeMessage(message) {
10658
10736
  };
10659
10737
  }
10660
10738
  function summarizeToolResults(value) {
10661
- if (isRecord2(value) && typeof value.count === "number" && !Array.isArray(value)) return value;
10739
+ if (isRecord3(value) && typeof value.count === "number" && !Array.isArray(value)) return value;
10662
10740
  if (!Array.isArray(value)) return typeof value;
10663
10741
  let errors = 0;
10664
10742
  const toolNames = [];
10665
10743
  for (const result of value) {
10666
- if (!isRecord2(result)) continue;
10744
+ if (!isRecord3(result)) continue;
10667
10745
  if (result.isError === true) errors++;
10668
10746
  const toolName = typeof result.toolName === "string" ? result.toolName : typeof result.name === "string" ? result.name : void 0;
10669
10747
  if (toolName && toolNames.length < 10) toolNames.push(toolName);
@@ -10675,7 +10753,7 @@ function collectTextLength(content) {
10675
10753
  if (!Array.isArray(content)) return 0;
10676
10754
  let length = 0;
10677
10755
  for (const block of content) {
10678
- if (!isRecord2(block)) continue;
10756
+ if (!isRecord3(block)) continue;
10679
10757
  if (typeof block.text === "string") length += block.text.length;
10680
10758
  }
10681
10759
  return length;
@@ -10684,7 +10762,7 @@ function collectArgumentLength(content) {
10684
10762
  if (!Array.isArray(content)) return 0;
10685
10763
  let length = 0;
10686
10764
  for (const block of content) {
10687
- if (!isRecord2(block) || !("arguments" in block)) continue;
10765
+ if (!isRecord3(block) || !("arguments" in block)) continue;
10688
10766
  if (typeof block.arguments === "string") {
10689
10767
  length += block.arguments.length;
10690
10768
  continue;
@@ -10707,7 +10785,7 @@ function summarizeMessages(value) {
10707
10785
  let textLength = 0;
10708
10786
  let argumentLength = 0;
10709
10787
  for (const message of value) {
10710
- if (!isRecord2(message)) continue;
10788
+ if (!isRecord3(message)) continue;
10711
10789
  const role = typeof message.role === "string" ? message.role : void 0;
10712
10790
  if (role && roles.length < 20) roles.push(role);
10713
10791
  if (typeof message.stopReason === "string" && stopReasons.length < 20) stopReasons.push(message.stopReason);
@@ -10718,7 +10796,7 @@ function summarizeMessages(value) {
10718
10796
  textLength += collectTextLength(message.content);
10719
10797
  argumentLength += collectArgumentLength(message.content);
10720
10798
  for (const block of content) {
10721
- if (isRecord2(block) && typeof block.name === "string" && toolNames.length < 20) {
10799
+ if (isRecord3(block) && typeof block.name === "string" && toolNames.length < 20) {
10722
10800
  toolNames.push(block.name);
10723
10801
  }
10724
10802
  }
@@ -10735,7 +10813,7 @@ function summarizeMessages(value) {
10735
10813
  };
10736
10814
  }
10737
10815
  function summarizeFailure(value) {
10738
- if (!isRecord2(value)) return typeof value;
10816
+ if (!isRecord3(value)) return typeof value;
10739
10817
  return {
10740
10818
  kind: value.kind,
10741
10819
  retryable: value.retryable,
@@ -10746,7 +10824,7 @@ function summarizeFailure(value) {
10746
10824
  };
10747
10825
  }
10748
10826
  function summarizeRuntimeEvent(value) {
10749
- if (!isRecord2(value)) return typeof value;
10827
+ if (!isRecord3(value)) return typeof value;
10750
10828
  const summary = {
10751
10829
  type: value.type
10752
10830
  };
@@ -10779,7 +10857,7 @@ function recomputeRuntimeSummaryFromTimeline(events) {
10779
10857
  return summary;
10780
10858
  }
10781
10859
  function summarizeMeta(meta) {
10782
- if (!isRecord2(meta)) return meta;
10860
+ if (!isRecord3(meta)) return meta;
10783
10861
  const summary = {};
10784
10862
  for (const [key, value] of Object.entries(meta)) {
10785
10863
  if (key === "messages" || key === "queuedInputs" || key === "result") {
@@ -10806,7 +10884,7 @@ function summarizeMeta(meta) {
10806
10884
  summary[key] = summarizeRuntimeEvent(value);
10807
10885
  continue;
10808
10886
  }
10809
- if (key === "queuedInput" && isRecord2(value)) {
10887
+ if (key === "queuedInput" && isRecord3(value)) {
10810
10888
  summary[key] = {
10811
10889
  mode: value.mode,
10812
10890
  source: value.source,
@@ -10826,18 +10904,18 @@ function toStringArray(value) {
10826
10904
  }
10827
10905
  function summarizeExcludedTools(value) {
10828
10906
  if (!Array.isArray(value)) return void 0;
10829
- const entries = value.filter(isRecord2).map((entry) => ({
10907
+ const entries = value.filter(isRecord3).map((entry) => ({
10830
10908
  name: String(entry.name || ""),
10831
10909
  reason: String(entry.reason || "")
10832
10910
  })).filter((entry) => entry.name);
10833
10911
  return entries.length > 0 ? entries : void 0;
10834
10912
  }
10835
10913
  function extractSubagentSummaries(toolCallId, toolName, result) {
10836
- if (toolName !== "spawn_subagents_parallel" || !isRecord2(result)) return [];
10837
- const details = isRecord2(result.details) ? result.details : void 0;
10914
+ if (toolName !== "spawn_subagents_parallel" || !isRecord3(result)) return [];
10915
+ const details = isRecord3(result.details) ? result.details : void 0;
10838
10916
  const tasks = Array.isArray(details?.tasks) ? details.tasks : [];
10839
- return tasks.filter(isRecord2).map((task) => {
10840
- const plan = isRecord2(task.plan) ? task.plan : void 0;
10917
+ return tasks.filter(isRecord3).map((task) => {
10918
+ const plan = isRecord3(task.plan) ? task.plan : void 0;
10841
10919
  const evidence = Array.isArray(task.evidence) ? task.evidence : [];
10842
10920
  const confidenceSignals = Array.isArray(task.confidenceSignals) ? task.confidenceSignals : [];
10843
10921
  const runtimeEvidence = Array.isArray(task.runtimeEvidence) ? task.runtimeEvidence : [];
@@ -10864,7 +10942,7 @@ function extractSubagentSummaries(toolCallId, toolName, result) {
10864
10942
  }
10865
10943
  function timelineEventFromTraceEvent(type, meta) {
10866
10944
  const normalizedType = type.startsWith("runtime:") ? type.slice("runtime:".length) : type;
10867
- const data = isRecord2(meta) ? meta : {};
10945
+ const data = isRecord3(meta) ? meta : {};
10868
10946
  const detail = summarizeMeta(meta);
10869
10947
  if (normalizedType === "assistant_update" || normalizedType === "dispatch_settled" || normalizedType === "wait_for_idle_settled") {
10870
10948
  return null;
@@ -11660,14 +11738,14 @@ function extractAnthropicContent(content, originalQuery) {
11660
11738
  results.push(makeTextSegment(block.text));
11661
11739
  }
11662
11740
  if (block?.type === "server_tool_use") {
11663
- const input = isRecord3(block.input) ? block.input : void 0;
11741
+ const input = isRecord4(block.input) ? block.input : void 0;
11664
11742
  if (typeof input?.query === "string" && input.query.trim()) {
11665
11743
  actualQueries.push(input.query.trim());
11666
11744
  }
11667
11745
  }
11668
11746
  if (block?.type === "web_search_tool_result") {
11669
11747
  if (!Array.isArray(block.content)) {
11670
- const errorCode = isRecord3(block.content) && typeof block.content.error_code === "string" ? block.content.error_code : "unknown";
11748
+ const errorCode = isRecord4(block.content) && typeof block.content.error_code === "string" ? block.content.error_code : "unknown";
11671
11749
  results.push({
11672
11750
  type: "error",
11673
11751
  toolUseId: typeof block.tool_use_id === "string" ? block.tool_use_id : void 0,
@@ -11711,7 +11789,7 @@ function collectUrlStrings(text, sources) {
11711
11789
  function resolveResponsesEndpoint(baseUrl) {
11712
11790
  return `${baseUrl.replace(/\/+$/, "")}/responses`;
11713
11791
  }
11714
- function isRecord3(value) {
11792
+ function isRecord4(value) {
11715
11793
  return typeof value === "object" && value !== null;
11716
11794
  }
11717
11795
  function collectUrlCitations(value, sources) {
@@ -11719,7 +11797,7 @@ function collectUrlCitations(value, sources) {
11719
11797
  for (const item of value) collectUrlCitations(item, sources);
11720
11798
  return;
11721
11799
  }
11722
- if (!isRecord3(value)) return;
11800
+ if (!isRecord4(value)) return;
11723
11801
  if (value.type === "url_citation" && typeof value.url === "string") {
11724
11802
  sources.push(sourceFromUrl(value.url, typeof value.title === "string" ? value.title : void 0));
11725
11803
  }
@@ -11738,7 +11816,7 @@ function collectOutputText(value, chunks) {
11738
11816
  for (const item of value) collectOutputText(item, chunks);
11739
11817
  return;
11740
11818
  }
11741
- if (!isRecord3(value)) return;
11819
+ if (!isRecord4(value)) return;
11742
11820
  if (value.type === "output_text" && typeof value.text === "string") {
11743
11821
  chunks.push(value.text);
11744
11822
  return;
@@ -11752,7 +11830,7 @@ function collectOutputText(value, chunks) {
11752
11830
  }
11753
11831
  }
11754
11832
  function extractOpenAIResponsesContent(response, originalQuery) {
11755
- const body = isRecord3(response) ? response : {};
11833
+ const body = isRecord4(response) ? response : {};
11756
11834
  const sources = [];
11757
11835
  collectUrlCitations(body.output, sources);
11758
11836
  if (typeof body.output_text === "string" && body.output_text.trim()) {
@@ -11769,12 +11847,12 @@ function extractOpenAIResponsesContent(response, originalQuery) {
11769
11847
  return { text, sources: uniqueSources(sources), results: text ? [makeTextSegment(text)] : [], actualQueries: [originalQuery] };
11770
11848
  }
11771
11849
  function extractChatCompletionsContent(response, originalQuery) {
11772
- const body = isRecord3(response) ? response : {};
11850
+ const body = isRecord4(response) ? response : {};
11773
11851
  const sources = [];
11774
11852
  collectUrlCitations(body, sources);
11775
11853
  const choices = Array.isArray(body.choices) ? body.choices : [];
11776
- const firstChoice = isRecord3(choices[0]) ? choices[0] : {};
11777
- const message = isRecord3(firstChoice.message) ? firstChoice.message : {};
11854
+ const firstChoice = isRecord4(choices[0]) ? choices[0] : {};
11855
+ const message = isRecord4(firstChoice.message) ? firstChoice.message : {};
11778
11856
  const content = typeof message.content === "string" ? message.content : "";
11779
11857
  if (content) {
11780
11858
  collectUrlStrings(content, sources);
@@ -12586,7 +12664,7 @@ var webResearchSchema = Type.Object({
12586
12664
  var DEFAULT_WEB_RESEARCH_SEARCH_ATTEMPT_TIMEOUT_MS = 45e3;
12587
12665
  var DEFAULT_WEB_RESEARCH_FETCH_ATTEMPT_TIMEOUT_MS = 3e4;
12588
12666
  var DEFAULT_WEB_RESEARCH_BROWSER_ATTEMPT_TIMEOUT_MS = 45e3;
12589
- function isRecord4(value) {
12667
+ function isRecord5(value) {
12590
12668
  return !!value && typeof value === "object" && !Array.isArray(value);
12591
12669
  }
12592
12670
  function textFromResult(result) {
@@ -12800,7 +12878,7 @@ function updateProviderHealth(current, attempts) {
12800
12878
  return [...byKey.values()].sort((a, b) => b.updatedAt - a.updatedAt).slice(0, 20);
12801
12879
  }
12802
12880
  function contentDetails(result) {
12803
- return isRecord4(result.details) ? result.details : {};
12881
+ return isRecord5(result.details) ? result.details : {};
12804
12882
  }
12805
12883
  function excerpt(text, max = 1400) {
12806
12884
  const clean = text.replace(/\s+/g, " ").trim();
package/dist/cli.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  getSettingsPath,
18
18
  getThemesDir,
19
19
  migrateConfigFromAgentDir
20
- } from "./chunks/chunk-BEWVRLCP.js";
20
+ } from "./chunks/chunk-GARJAWH6.js";
21
21
  import {
22
22
  AGENTS_CONTEXT_FILE_NAME,
23
23
  AgentSessionController,
@@ -67,7 +67,7 @@ import {
67
67
  setExtensionEnabledInSettings,
68
68
  shouldPreserveExecutionStateForUserText,
69
69
  supersedeExecutionState
70
- } from "./chunks/chunk-O4DPFYYP.js";
70
+ } from "./chunks/chunk-L63BJMTT.js";
71
71
  import "./chunks/chunk-4B42ZU4B.js";
72
72
  import {
73
73
  Deref,
@@ -46663,7 +46663,7 @@ async function renameSession(args) {
46663
46663
  const store = new FileSessionStore(getSessionsDir());
46664
46664
  const data = await store.load(sessionId);
46665
46665
  if (!data) throw new Error(`Session not found: ${sessionId}`);
46666
- await store.save(sessionId, data.entries, { ...data.metadata, name, ...cwd ? { cwd } : {}, updatedAt: Date.now() });
46666
+ await store.save(sessionId, data.entries, { ...data.metadata, name, nameSource: "manual", ...cwd ? { cwd } : {}, updatedAt: Date.now() });
46667
46667
  const updated = await store.getMetadata(sessionId);
46668
46668
  if (!updated) throw new Error(`Session not found after rename: ${sessionId}`);
46669
46669
  const response = { ok: true, session: sessionSummary(updated) };
@@ -61196,6 +61196,12 @@ var SessionSelectorComponent = class extends Container {
61196
61196
  sessions;
61197
61197
  callbacks;
61198
61198
  options;
61199
+ items;
61200
+ refreshAttempted = /* @__PURE__ */ new Set();
61201
+ refreshInFlight = false;
61202
+ pendingRefreshId;
61203
+ refreshTimer;
61204
+ destroyed = false;
61199
61205
  constructor(sessions, callbacks, options = {}) {
61200
61206
  super();
61201
61207
  this.sessions = sessions;
@@ -61205,10 +61211,10 @@ var SessionSelectorComponent = class extends Container {
61205
61211
  const title = truncated ? `Resume Session (recent ${sessions.length} of ${options.totalCount})` : "Resume Session";
61206
61212
  this.addChild(new Text(theme.bold(theme.fg("accent", title)), 0, 0));
61207
61213
  this.addChild(new Spacer(1));
61208
- const items = sessions.map((session) => this.createItem(session));
61214
+ this.items = sessions.map((session) => this.createItem(session));
61209
61215
  this.selectList = new SelectList(
61210
- items,
61211
- Math.min(items.length, 8),
61216
+ this.items,
61217
+ Math.min(this.items.length, 8),
61212
61218
  {
61213
61219
  selectedPrefix: (text) => theme.fg("accent", text),
61214
61220
  selectedText: (text) => theme.fg("accent", text),
@@ -61218,16 +61224,25 @@ var SessionSelectorComponent = class extends Container {
61218
61224
  }
61219
61225
  );
61220
61226
  this.selectList.onSelect = (item) => {
61227
+ this.destroyed = true;
61228
+ this.clearRefreshTimer();
61221
61229
  this.callbacks.onSelect(item.value);
61222
61230
  };
61223
61231
  this.selectList.onCancel = () => {
61232
+ this.destroyed = true;
61233
+ this.clearRefreshTimer();
61224
61234
  this.callbacks.onCancel();
61225
61235
  };
61236
+ this.selectList.onSelectionChange = (item) => {
61237
+ this.scheduleRefresh(item.value);
61238
+ };
61226
61239
  this.addChild(this.selectList);
61227
61240
  this.addChild(new Spacer(1));
61228
61241
  this.addChild(
61229
61242
  new Text(theme.fg("dim", " \u2191\u2193 to navigate \xB7 \u2190\u2192 to page \xB7 Enter to select \xB7 Esc to cancel"), 0, 0)
61230
61243
  );
61244
+ const selected = this.selectList.getSelectedItem();
61245
+ if (selected) this.scheduleRefresh(selected.value);
61231
61246
  }
61232
61247
  handleInput(data) {
61233
61248
  this.selectList.handleInput(data);
@@ -61243,6 +61258,55 @@ var SessionSelectorComponent = class extends Container {
61243
61258
  description: cwdTag ? `${cwdTag} \xB7 ${session.messageCount} messages \xB7 ${formatDate(session.updatedAt)}` : `${session.messageCount} messages \xB7 ${formatDate(session.updatedAt)}`
61244
61259
  };
61245
61260
  }
61261
+ clearRefreshTimer() {
61262
+ if (this.refreshTimer) {
61263
+ clearTimeout(this.refreshTimer);
61264
+ this.refreshTimer = void 0;
61265
+ }
61266
+ }
61267
+ scheduleRefresh(sessionId) {
61268
+ if (!this.options.refreshMetadata || this.destroyed || this.refreshAttempted.has(sessionId)) return;
61269
+ this.pendingRefreshId = sessionId;
61270
+ this.clearRefreshTimer();
61271
+ this.refreshTimer = setTimeout(() => {
61272
+ this.refreshTimer = void 0;
61273
+ void this.runPendingRefresh();
61274
+ }, this.options.refreshDelayMs ?? 150);
61275
+ }
61276
+ async runPendingRefresh() {
61277
+ if (this.destroyed || !this.options.refreshMetadata) return;
61278
+ if (this.refreshInFlight) return;
61279
+ const sessionId = this.pendingRefreshId;
61280
+ this.pendingRefreshId = void 0;
61281
+ if (!sessionId || this.refreshAttempted.has(sessionId)) return;
61282
+ this.refreshAttempted.add(sessionId);
61283
+ this.refreshInFlight = true;
61284
+ try {
61285
+ const metadata = await this.options.refreshMetadata(sessionId);
61286
+ if (metadata && !this.destroyed) {
61287
+ this.updateItem(metadata);
61288
+ }
61289
+ } catch {
61290
+ } finally {
61291
+ this.refreshInFlight = false;
61292
+ if (this.pendingRefreshId && !this.destroyed) {
61293
+ void this.runPendingRefresh();
61294
+ }
61295
+ }
61296
+ }
61297
+ updateItem(metadata) {
61298
+ const sessionIndex = this.sessions.findIndex((session) => session.id === metadata.id);
61299
+ if (sessionIndex >= 0) this.sessions[sessionIndex] = metadata;
61300
+ const itemIndex = this.items.findIndex((item2) => item2.value === metadata.id);
61301
+ if (itemIndex < 0) return;
61302
+ const nextItem = this.createItem(metadata);
61303
+ const item = this.items[itemIndex];
61304
+ if (item.label === nextItem.label && item.description === nextItem.description) return;
61305
+ item.label = nextItem.label;
61306
+ item.description = nextItem.description;
61307
+ this.selectList.invalidate();
61308
+ this.options.requestRender?.();
61309
+ }
61246
61310
  };
61247
61311
 
61248
61312
  // src/components/tree-selector.ts
@@ -62809,6 +62873,8 @@ async function handleResumeCommand(host) {
62809
62873
  }, {
62810
62874
  currentCwd: host.options.cwd,
62811
62875
  homeDir: os5.homedir(),
62876
+ refreshMetadata: (sessionId) => host.sessionManager.refreshDerivedName(sessionId),
62877
+ requestRender: () => host.ui.requestRender(),
62812
62878
  totalCount
62813
62879
  });
62814
62880
  return { component: selector, focus: selector.getSelectList() };
@@ -64034,26 +64100,6 @@ function createExtensionContextForCommands(host) {
64034
64100
  };
64035
64101
  }
64036
64102
  function registerBuiltinCommands(host) {
64037
- commandTree.register(["new"], {
64038
- description: "Start a new session",
64039
- handler: () => host.handleClearCommand()
64040
- });
64041
- commandTree.register(["resume"], {
64042
- description: "Resume a different session",
64043
- handler: () => host.handleResumeCommand()
64044
- });
64045
- commandTree.register(["tree"], {
64046
- description: "Navigate session tree",
64047
- handler: () => host.handleTreeCommand()
64048
- });
64049
- commandTree.register(["session"], {
64050
- description: "Show session info and stats",
64051
- handler: () => host.handleSessionCommand()
64052
- });
64053
- commandTree.register(["fork"], {
64054
- description: "Create a new fork from a previous message",
64055
- handler: () => host.handleForkCommand()
64056
- });
64057
64103
  commandTree.register(["sessions", "compact"], {
64058
64104
  description: "Summarize history and replace it with a compact checkpoint",
64059
64105
  handler: () => host.handleCompactCommand()
@@ -64082,18 +64128,6 @@ function registerBuiltinCommands(host) {
64082
64128
  description: "Show help information (keyboard shortcuts and commands)",
64083
64129
  handler: () => host.handleHotkeysCommand()
64084
64130
  });
64085
- commandTree.register(["model"], {
64086
- description: "Select model (e.g., /model kimi-api/kimi-k2.5)",
64087
- handler: (_2, args) => host.handleModelCommand(args)
64088
- });
64089
- commandTree.register(["hotkeys"], {
64090
- description: "Show all keyboard shortcuts",
64091
- handler: () => host.handleHotkeysCommand()
64092
- });
64093
- commandTree.register(["export"], {
64094
- description: "Export session to HTML file",
64095
- handler: (_2, args) => host.handleExportCommand(args ? `/export ${args}` : "/export")
64096
- });
64097
64131
  commandTree.register(["settings"], {
64098
64132
  description: "Open settings menu",
64099
64133
  handler: () => host.showSettingsSelector()
@@ -64138,14 +64172,6 @@ function registerBuiltinCommands(host) {
64138
64172
  description: "List available skills",
64139
64173
  handler: () => host.handleSkillsCommand()
64140
64174
  });
64141
- commandTree.register(["skills"], {
64142
- description: "List available skills",
64143
- handler: () => host.handleSkillsCommand()
64144
- });
64145
- commandTree.register(["skill"], {
64146
- description: "Activate a skill (e.g., /skill code-review)",
64147
- handler: (_2, args) => host.handleSkillCommand(args || "")
64148
- });
64149
64175
  commandTree.register(["skills", "use"], {
64150
64176
  description: "Use a skill",
64151
64177
  handler: (_2, args) => host.handleSkillCommand(args || "")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cydm/pie",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "Pie AI Agent CLI",
5
5
  "type": "module",
6
6
  "bin": {