@downcity/agent 1.1.166 → 1.1.168

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.
Files changed (41) hide show
  1. package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts.map +1 -1
  2. package/bin/agent/remote/transports/HttpRemoteAgentTransport.js +2 -0
  3. package/bin/agent/remote/transports/HttpRemoteAgentTransport.js.map +1 -1
  4. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts +1 -0
  5. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts.map +1 -1
  6. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js +2 -1
  7. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js.map +1 -1
  8. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts.map +1 -1
  9. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js +2 -1
  10. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js.map +1 -1
  11. package/bin/executor/types/SessionMessages.d.ts +2 -0
  12. package/bin/executor/types/SessionMessages.d.ts.map +1 -1
  13. package/bin/session/browse/Browse.d.ts +8 -0
  14. package/bin/session/browse/Browse.d.ts.map +1 -1
  15. package/bin/session/browse/Browse.js +58 -6
  16. package/bin/session/browse/Browse.js.map +1 -1
  17. package/bin/session/index.d.ts +2 -2
  18. package/bin/session/index.d.ts.map +1 -1
  19. package/bin/session/index.js +2 -2
  20. package/bin/session/index.js.map +1 -1
  21. package/bin/session/services/SessionViewService.d.ts.map +1 -1
  22. package/bin/session/services/SessionViewService.js +8 -4
  23. package/bin/session/services/SessionViewService.js.map +1 -1
  24. package/bin/session/storage/Paths.d.ts +8 -0
  25. package/bin/session/storage/Paths.d.ts.map +1 -1
  26. package/bin/session/storage/Paths.js +10 -0
  27. package/bin/session/storage/Paths.js.map +1 -1
  28. package/bin/types/agent/SessionTypes.d.ts +26 -2
  29. package/bin/types/agent/SessionTypes.d.ts.map +1 -1
  30. package/package.json +3 -3
  31. package/scripts/session-history-archive.test.mjs +188 -0
  32. package/src/agent/remote/transports/HttpRemoteAgentTransport.ts +1 -0
  33. package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.ts +3 -2
  34. package/src/executor/store/history/jsonl/JsonlSessionHistoryStore.ts +2 -1
  35. package/src/executor/types/SessionMessages.ts +2 -0
  36. package/src/session/browse/Browse.ts +72 -6
  37. package/src/session/index.ts +2 -0
  38. package/src/session/services/SessionViewService.ts +16 -3
  39. package/src/session/storage/Paths.ts +19 -0
  40. package/src/types/agent/SessionTypes.ts +26 -2
  41. package/tsconfig.tsbuildinfo +1 -1
@@ -185,6 +185,25 @@ export function getSdkAgentSessionArchiveDirPath(
185
185
  );
186
186
  }
187
187
 
188
+ /**
189
+ * 单个 session 的 compact archive JSON 文件路径。
190
+ *
191
+ * 关键点(中文)
192
+ * - `archiveId` 来自 compact summary metadata,不由调用方拼接扩展名。
193
+ * - 这里统一 encode,避免 archiveId 中的特殊字符影响文件路径。
194
+ */
195
+ export function getSdkAgentSessionArchiveFilePath(
196
+ projectRoot: string,
197
+ agentId: string,
198
+ sessionId: string,
199
+ archiveId: string,
200
+ ): string {
201
+ return path.join(
202
+ getSdkAgentSessionArchiveDirPath(projectRoot, agentId, sessionId),
203
+ `${encodeURIComponent(String(archiveId || "").trim())}.json`,
204
+ );
205
+ }
206
+
188
207
  /**
189
208
  * 单个 session 的 inflight assistant 路径。
190
209
  *
@@ -272,6 +272,14 @@ export interface AgentSessionHistoryInput {
272
272
  limit?: number;
273
273
  /** 分页游标。 */
274
274
  cursor?: string;
275
+ /**
276
+ * 要读取的 compact archive 层 ID。
277
+ *
278
+ * 说明(中文)
279
+ * - 省略时读取当前 `messages.jsonl`。
280
+ * - 传入时读取 `messages/archive/<archive_id>.json` 中保存的上一层历史。
281
+ */
282
+ archive_id?: string;
275
283
  /**
276
284
  * 返回顺序。
277
285
  *
@@ -315,9 +323,25 @@ export interface AgentSessionHistoryPage {
315
323
  */
316
324
  total: number;
317
325
  /** 下一页游标。 */
318
- nextCursor?: string;
326
+ next_cursor?: string;
319
327
  /** 是否仍有更多数据。 */
320
- hasMore: boolean;
328
+ has_more: boolean;
329
+ /**
330
+ * 当前读取的 compact archive 层 ID。
331
+ *
332
+ * 说明(中文)
333
+ * - 省略表示当前页来自主历史 `messages.jsonl`。
334
+ * - 有值表示当前页来自指定 compact archive。
335
+ */
336
+ archive_id?: string;
337
+ /**
338
+ * 当前层更早一次 compact 对应的 archive ID。
339
+ *
340
+ * 关键点(中文)
341
+ * - compact summary 不会出现在 `items` 中。
342
+ * - 若当前层包含 compact summary,则这里暴露其 archive ID,供调用方继续 `session.history({ archive_id })`。
343
+ */
344
+ previous_archive_id?: string;
321
345
  }
322
346
 
323
347
  /**