@yitom/agy-acp-map 0.1.6 → 0.1.8

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,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/agy-acp-win-x64.exe
3
- size: 86637568 bytes
4
- sha256: a382550f80df362aea3dc5491aeeb3c12cc3a23dbd2ec4e24e3e93740d7b2352
3
+ size: 86638592 bytes
4
+ sha256: 04f1c91b9f04b9971c5054925401246c5e2ce70cb34f2c0668ca1527a4f91930
Binary file
package/dist/bin.js CHANGED
@@ -12451,6 +12451,14 @@ class SessionHistoryStore {
12451
12451
  fs7.appendFileSync(this.filePath(sessionId), payload, "utf8");
12452
12452
  }
12453
12453
  read(sessionId) {
12454
+ return this.readUpTo(sessionId, Infinity);
12455
+ }
12456
+ firstUserText(sessionId) {
12457
+ const records = this.readUpTo(sessionId, 50);
12458
+ const first = records.find((r) => r.role === "user" && r.text.trim());
12459
+ return first ? first.text : null;
12460
+ }
12461
+ readUpTo(sessionId, maxLines) {
12454
12462
  const file = this.filePath(sessionId);
12455
12463
  if (!fs7.existsSync(file))
12456
12464
  return [];
@@ -12461,9 +12469,12 @@ class SessionHistoryStore {
12461
12469
  return [];
12462
12470
  }
12463
12471
  const records = [];
12472
+ let lines = 0;
12464
12473
  for (const line of raw.split(/\r?\n/)) {
12465
12474
  if (!line.trim())
12466
12475
  continue;
12476
+ if (++lines > maxLines)
12477
+ break;
12467
12478
  try {
12468
12479
  const parsed = JSON.parse(line);
12469
12480
  if (isRecord2(parsed) && parsed.sessionId === sessionId) {
@@ -12488,7 +12499,7 @@ class SessionHistoryStore {
12488
12499
  var AGENT_INFO = {
12489
12500
  name: "agy-acp",
12490
12501
  title: "agy ACP (stream-json)",
12491
- version: "0.1.6"
12502
+ version: "0.1.8"
12492
12503
  };
12493
12504
  var BRIDGE_CAPABILITIES = {
12494
12505
  prompt: true,
@@ -12595,6 +12606,13 @@ function debugLog(msg) {
12595
12606
  }
12596
12607
 
12597
12608
  // src/core/session-core.ts
12609
+ var EMPTY_SESSION_MAX_AGE_MS = 60 * 60 * 1000;
12610
+ function deriveTitle(text, maxLen = 60) {
12611
+ const line = String(text || "").split(/\r?\n/).map((s) => s.trim()).find(Boolean) || "";
12612
+ const flat = line.replace(/\s+/g, " ");
12613
+ return flat.length > maxLen ? flat.slice(0, maxLen) + "…" : flat;
12614
+ }
12615
+
12598
12616
  class AgySessionCore {
12599
12617
  sessions = new Map;
12600
12618
  sessionStore;
@@ -12960,6 +12978,13 @@ class AgySessionCore {
12960
12978
  }
12961
12979
  const discovery = await this.getDiscovery();
12962
12980
  this.applyCatalogDefaults(session, discovery);
12981
+ if (!session.title) {
12982
+ try {
12983
+ const first = this.historyStore.firstUserText(sessionId);
12984
+ if (first && first.trim())
12985
+ session.title = deriveTitle(first);
12986
+ } catch {}
12987
+ }
12963
12988
  this.persistSession(session);
12964
12989
  if (opts?.warmup !== false) {
12965
12990
  this.warmupSession(sessionId);
@@ -13017,7 +13042,7 @@ class AgySessionCore {
13017
13042
  meta: this.sessionMeta(session)
13018
13043
  };
13019
13044
  }
13020
- async listSessions(params) {
13045
+ async listSessions(params, opts) {
13021
13046
  const filterCwd = params?.cwd;
13022
13047
  if (filterCwd !== undefined && filterCwd !== null) {
13023
13048
  if (typeof filterCwd !== "string" || !path10.isAbsolute(filterCwd)) {
@@ -13042,6 +13067,13 @@ class AgySessionCore {
13042
13067
  diskById.delete(id);
13043
13068
  }
13044
13069
  for (const r of diskById.values()) {
13070
+ if (!r.conversationId) {
13071
+ const updated = r.updatedAt ? new Date(r.updatedAt).getTime() : NaN;
13072
+ const now = opts?.now ?? Date.now();
13073
+ if (Number.isFinite(updated) && now - updated > EMPTY_SESSION_MAX_AGE_MS) {
13074
+ continue;
13075
+ }
13076
+ }
13045
13077
  allSessions.push({
13046
13078
  sessionId: r.sessionId,
13047
13079
  cwd: r.cwd,
@@ -13243,6 +13275,9 @@ class AgySessionCore {
13243
13275
  }
13244
13276
  }
13245
13277
  this.persistTurnHistory(sessionId, text, visibleAssistantText, stopReason, historyTurnEligible);
13278
+ if (!session.title && text.trim()) {
13279
+ session.title = deriveTitle(text);
13280
+ }
13246
13281
  this.persistSession(session);
13247
13282
  if (process.env.AGY_ACP_KEEP_STAGING !== "1" && session.stagedFiles.length) {
13248
13283
  for (const f of session.stagedFiles) {
@@ -13452,8 +13487,8 @@ class AgyAcpV1Service {
13452
13487
  ...meta ? { _meta: meta } : {}
13453
13488
  };
13454
13489
  }
13455
- async listSessions(params) {
13456
- return this.core.listSessions(params);
13490
+ async listSessions(params, opts) {
13491
+ return this.core.listSessions(params, opts);
13457
13492
  }
13458
13493
  async closeSession(params) {
13459
13494
  return this.core.closeSession(params);
@@ -13565,8 +13600,8 @@ class AgyAcpV2Service {
13565
13600
  ...meta ? { _meta: meta } : {}
13566
13601
  };
13567
13602
  }
13568
- async listSessions(params) {
13569
- return this.core.listSessions(params);
13603
+ async listSessions(params, opts) {
13604
+ return this.core.listSessions(params, opts);
13570
13605
  }
13571
13606
  async closeSession(params) {
13572
13607
  return this.core.closeSession(params);
@@ -6,6 +6,11 @@ export interface SessionCoreOptions {
6
6
  sessionStore?: SessionStore | string;
7
7
  historyStore?: SessionHistoryStore | string;
8
8
  }
9
+ /** Rows without any completed turn older than this are hidden from
10
+ * session/list (still resumable/deletable by id — the store keeps them). */
11
+ export declare const EMPTY_SESSION_MAX_AGE_MS: number;
12
+ /** First user prompt collapsed to one line, capped for list display. */
13
+ export declare function deriveTitle(text: string, maxLen?: number): string;
9
14
  export declare class AgySessionCore {
10
15
  readonly sessions: Map<string, SdkSession>;
11
16
  readonly sessionStore: SessionStore;
@@ -54,7 +59,9 @@ export declare class AgySessionCore {
54
59
  configOptions: any[];
55
60
  meta?: Record<string, unknown>;
56
61
  }>;
57
- listSessions(params?: any): Promise<{
62
+ listSessions(params?: any, opts?: {
63
+ now?: number;
64
+ }): Promise<{
58
65
  sessions: any[];
59
66
  nextCursor?: string | null;
60
67
  }>;
package/dist/index.js CHANGED
@@ -12238,6 +12238,14 @@ class SessionHistoryStore {
12238
12238
  fs7.appendFileSync(this.filePath(sessionId), payload, "utf8");
12239
12239
  }
12240
12240
  read(sessionId) {
12241
+ return this.readUpTo(sessionId, Infinity);
12242
+ }
12243
+ firstUserText(sessionId) {
12244
+ const records = this.readUpTo(sessionId, 50);
12245
+ const first = records.find((r) => r.role === "user" && r.text.trim());
12246
+ return first ? first.text : null;
12247
+ }
12248
+ readUpTo(sessionId, maxLines) {
12241
12249
  const file = this.filePath(sessionId);
12242
12250
  if (!fs7.existsSync(file))
12243
12251
  return [];
@@ -12248,9 +12256,12 @@ class SessionHistoryStore {
12248
12256
  return [];
12249
12257
  }
12250
12258
  const records = [];
12259
+ let lines = 0;
12251
12260
  for (const line of raw.split(/\r?\n/)) {
12252
12261
  if (!line.trim())
12253
12262
  continue;
12263
+ if (++lines > maxLines)
12264
+ break;
12254
12265
  try {
12255
12266
  const parsed = JSON.parse(line);
12256
12267
  if (isRecord2(parsed) && parsed.sessionId === sessionId) {
@@ -12275,7 +12286,7 @@ class SessionHistoryStore {
12275
12286
  var AGENT_INFO = {
12276
12287
  name: "agy-acp",
12277
12288
  title: "agy ACP (stream-json)",
12278
- version: "0.1.6"
12289
+ version: "0.1.8"
12279
12290
  };
12280
12291
  var BRIDGE_CAPABILITIES = {
12281
12292
  prompt: true,
@@ -12395,6 +12406,13 @@ function installFileLogging() {
12395
12406
  }
12396
12407
 
12397
12408
  // src/core/session-core.ts
12409
+ var EMPTY_SESSION_MAX_AGE_MS = 60 * 60 * 1000;
12410
+ function deriveTitle(text, maxLen = 60) {
12411
+ const line = String(text || "").split(/\r?\n/).map((s) => s.trim()).find(Boolean) || "";
12412
+ const flat = line.replace(/\s+/g, " ");
12413
+ return flat.length > maxLen ? flat.slice(0, maxLen) + "…" : flat;
12414
+ }
12415
+
12398
12416
  class AgySessionCore {
12399
12417
  sessions = new Map;
12400
12418
  sessionStore;
@@ -12760,6 +12778,13 @@ class AgySessionCore {
12760
12778
  }
12761
12779
  const discovery = await this.getDiscovery();
12762
12780
  this.applyCatalogDefaults(session, discovery);
12781
+ if (!session.title) {
12782
+ try {
12783
+ const first = this.historyStore.firstUserText(sessionId);
12784
+ if (first && first.trim())
12785
+ session.title = deriveTitle(first);
12786
+ } catch {}
12787
+ }
12763
12788
  this.persistSession(session);
12764
12789
  if (opts?.warmup !== false) {
12765
12790
  this.warmupSession(sessionId);
@@ -12817,7 +12842,7 @@ class AgySessionCore {
12817
12842
  meta: this.sessionMeta(session)
12818
12843
  };
12819
12844
  }
12820
- async listSessions(params) {
12845
+ async listSessions(params, opts) {
12821
12846
  const filterCwd = params?.cwd;
12822
12847
  if (filterCwd !== undefined && filterCwd !== null) {
12823
12848
  if (typeof filterCwd !== "string" || !path10.isAbsolute(filterCwd)) {
@@ -12842,6 +12867,13 @@ class AgySessionCore {
12842
12867
  diskById.delete(id);
12843
12868
  }
12844
12869
  for (const r of diskById.values()) {
12870
+ if (!r.conversationId) {
12871
+ const updated = r.updatedAt ? new Date(r.updatedAt).getTime() : NaN;
12872
+ const now = opts?.now ?? Date.now();
12873
+ if (Number.isFinite(updated) && now - updated > EMPTY_SESSION_MAX_AGE_MS) {
12874
+ continue;
12875
+ }
12876
+ }
12845
12877
  allSessions.push({
12846
12878
  sessionId: r.sessionId,
12847
12879
  cwd: r.cwd,
@@ -13043,6 +13075,9 @@ class AgySessionCore {
13043
13075
  }
13044
13076
  }
13045
13077
  this.persistTurnHistory(sessionId, text, visibleAssistantText, stopReason, historyTurnEligible);
13078
+ if (!session.title && text.trim()) {
13079
+ session.title = deriveTitle(text);
13080
+ }
13046
13081
  this.persistSession(session);
13047
13082
  if (process.env.AGY_ACP_KEEP_STAGING !== "1" && session.stagedFiles.length) {
13048
13083
  for (const f of session.stagedFiles) {
@@ -13252,8 +13287,8 @@ class AgyAcpV1Service {
13252
13287
  ...meta ? { _meta: meta } : {}
13253
13288
  };
13254
13289
  }
13255
- async listSessions(params) {
13256
- return this.core.listSessions(params);
13290
+ async listSessions(params, opts) {
13291
+ return this.core.listSessions(params, opts);
13257
13292
  }
13258
13293
  async closeSession(params) {
13259
13294
  return this.core.closeSession(params);
@@ -13365,8 +13400,8 @@ class AgyAcpV2Service {
13365
13400
  ...meta ? { _meta: meta } : {}
13366
13401
  };
13367
13402
  }
13368
- async listSessions(params) {
13369
- return this.core.listSessions(params);
13403
+ async listSessions(params, opts) {
13404
+ return this.core.listSessions(params, opts);
13370
13405
  }
13371
13406
  async closeSession(params) {
13372
13407
  return this.core.closeSession(params);
@@ -17583,7 +17618,9 @@ __export(exports_core3, {
17583
17618
  AgySessionCore: () => AgySessionCore,
17584
17619
  AsyncSerialQueue: () => AsyncSerialQueue,
17585
17620
  BRIDGE_CAPABILITIES: () => BRIDGE_CAPABILITIES,
17586
- catalogChoices: () => catalogChoices
17621
+ EMPTY_SESSION_MAX_AGE_MS: () => EMPTY_SESSION_MAX_AGE_MS,
17622
+ catalogChoices: () => catalogChoices,
17623
+ deriveTitle: () => deriveTitle
17587
17624
  });
17588
17625
  // src/v1/index.ts
17589
17626
  var exports_v1 = {};
@@ -29,5 +29,11 @@ export declare class SessionHistoryStore {
29
29
  appendTurn(sessionId: string, userText: string, assistantText?: string): void;
30
30
  /** Read valid records and ignore incomplete/corrupt trailing lines. */
31
31
  read(sessionId: string): SessionHistoryRecord[];
32
+ /**
33
+ * First user prompt text for backfilling list titles. Stops at the first
34
+ * valid user record instead of parsing the whole journal.
35
+ */
36
+ firstUserText(sessionId: string): string | null;
37
+ private readUpTo;
32
38
  delete(sessionId: string): void;
33
39
  }
@@ -7,7 +7,9 @@ export declare class AgyAcpV1Service {
7
7
  resumeSession(params: any): Promise<any>;
8
8
  loadSession(params: any, notifyClient: (update: any) => Promise<void> | void): Promise<any>;
9
9
  setConfigOption(params: any): Promise<any>;
10
- listSessions(params?: any): Promise<any>;
10
+ listSessions(params?: any, opts?: {
11
+ now?: number;
12
+ }): Promise<any>;
11
13
  closeSession(params: any): Promise<any>;
12
14
  deleteSession(params: any): Promise<any>;
13
15
  cancelSession(params: any): void;
@@ -6,7 +6,9 @@ export declare class AgyAcpV2Service {
6
6
  newSession(params: any): Promise<any>;
7
7
  resumeSession(params: any, notifyClient?: (update: any) => Promise<void> | void): Promise<any>;
8
8
  setConfigOption(params: any): Promise<any>;
9
- listSessions(params?: any): Promise<any>;
9
+ listSessions(params?: any, opts?: {
10
+ now?: number;
11
+ }): Promise<any>;
10
12
  closeSession(params: any): Promise<any>;
11
13
  deleteSession(params: any): Promise<any>;
12
14
  cancelSession(params: any): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yitom/agy-acp-map",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },