@agen-ai/agent-history 0.0.0-stage → 0.4.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.
Files changed (213) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +389 -2
  3. package/dist/acp.d.ts +3 -0
  4. package/dist/acp.js +4 -0
  5. package/dist/claude.d.ts +3 -0
  6. package/dist/claude.js +4 -0
  7. package/dist/codex.d.ts +3 -0
  8. package/dist/codex.js +5 -0
  9. package/dist/contracts/index.d.ts +3 -0
  10. package/dist/contracts/index.js +0 -0
  11. package/dist/contracts/operations.d.ts +182 -0
  12. package/dist/contracts/operations.js +0 -0
  13. package/dist/contracts/records.d.ts +152 -0
  14. package/dist/contracts/records.js +0 -0
  15. package/dist/cursor.d.ts +3 -0
  16. package/dist/cursor.js +4 -0
  17. package/dist/grok.d.ts +4 -0
  18. package/dist/grok.js +7 -0
  19. package/dist/index.d.ts +7 -0
  20. package/dist/index.js +13 -0
  21. package/dist/lifecycle/boundary.d.ts +11 -0
  22. package/dist/lifecycle/boundary.js +38 -0
  23. package/dist/lifecycle/create.d.ts +10 -0
  24. package/dist/lifecycle/create.js +35 -0
  25. package/dist/lifecycle/errors.d.ts +16 -0
  26. package/dist/lifecycle/errors.js +30 -0
  27. package/dist/lifecycle/limits.d.ts +12 -0
  28. package/dist/lifecycle/limits.js +33 -0
  29. package/dist/lifecycle/mutations.d.ts +4 -0
  30. package/dist/lifecycle/mutations.js +69 -0
  31. package/dist/lifecycle/owner.d.ts +33 -0
  32. package/dist/lifecycle/owner.js +113 -0
  33. package/dist/lifecycle/reads.d.ts +5 -0
  34. package/dist/lifecycle/reads.js +128 -0
  35. package/dist/lifecycle/views.d.ts +6 -0
  36. package/dist/lifecycle/views.js +43 -0
  37. package/dist/opencode.d.ts +3 -0
  38. package/dist/opencode.js +4 -0
  39. package/dist/pagination/cursor.d.ts +27 -0
  40. package/dist/pagination/cursor.js +61 -0
  41. package/dist/pagination/page.d.ts +15 -0
  42. package/dist/pagination/page.js +31 -0
  43. package/dist/providers/acp/continuation.d.ts +12 -0
  44. package/dist/providers/acp/continuation.js +23 -0
  45. package/dist/providers/acp/contracts.d.ts +36 -0
  46. package/dist/providers/acp/contracts.js +0 -0
  47. package/dist/providers/acp/create.d.ts +4 -0
  48. package/dist/providers/acp/create.js +47 -0
  49. package/dist/providers/acp/native.d.ts +24 -0
  50. package/dist/providers/acp/native.js +47 -0
  51. package/dist/providers/acp/options.d.ts +8 -0
  52. package/dist/providers/acp/options.js +53 -0
  53. package/dist/providers/acp/session.d.ts +4 -0
  54. package/dist/providers/acp/session.js +72 -0
  55. package/dist/providers/claude/continuation.d.ts +11 -0
  56. package/dist/providers/claude/continuation.js +44 -0
  57. package/dist/providers/claude/create.d.ts +4 -0
  58. package/dist/providers/claude/create.js +57 -0
  59. package/dist/providers/claude/driver.d.ts +5 -0
  60. package/dist/providers/claude/driver.js +57 -0
  61. package/dist/providers/claude/identity.d.ts +2 -0
  62. package/dist/providers/claude/identity.js +35 -0
  63. package/dist/providers/claude/mutations.d.ts +10 -0
  64. package/dist/providers/claude/mutations.js +34 -0
  65. package/dist/providers/claude/options.d.ts +31 -0
  66. package/dist/providers/claude/options.js +38 -0
  67. package/dist/providers/claude/process.d.ts +12 -0
  68. package/dist/providers/claude/process.js +49 -0
  69. package/dist/providers/claude/session.d.ts +34 -0
  70. package/dist/providers/claude/session.js +127 -0
  71. package/dist/providers/claude/transcript.d.ts +4 -0
  72. package/dist/providers/claude/transcript.js +205 -0
  73. package/dist/providers/claude/worker/main.d.ts +2 -0
  74. package/dist/providers/claude/worker/main.js +95 -0
  75. package/dist/providers/claude/worker/protocol.d.ts +54 -0
  76. package/dist/providers/claude/worker/protocol.js +156 -0
  77. package/dist/providers/codex/content.d.ts +4 -0
  78. package/dist/providers/codex/content.js +174 -0
  79. package/dist/providers/codex/continuation.d.ts +24 -0
  80. package/dist/providers/codex/continuation.js +59 -0
  81. package/dist/providers/codex/contracts.d.ts +104 -0
  82. package/dist/providers/codex/contracts.js +0 -0
  83. package/dist/providers/codex/create.d.ts +5 -0
  84. package/dist/providers/codex/create.js +75 -0
  85. package/dist/providers/codex/driver.d.ts +4 -0
  86. package/dist/providers/codex/driver.js +53 -0
  87. package/dist/providers/codex/identity.d.ts +4 -0
  88. package/dist/providers/codex/identity.js +48 -0
  89. package/dist/providers/codex/mutations.d.ts +4 -0
  90. package/dist/providers/codex/mutations.js +57 -0
  91. package/dist/providers/codex/native.d.ts +39 -0
  92. package/dist/providers/codex/native.js +103 -0
  93. package/dist/providers/codex/options.d.ts +17 -0
  94. package/dist/providers/codex/options.js +93 -0
  95. package/dist/providers/codex/process.d.ts +11 -0
  96. package/dist/providers/codex/process.js +100 -0
  97. package/dist/providers/codex/session.d.ts +8 -0
  98. package/dist/providers/codex/session.js +117 -0
  99. package/dist/providers/codex/transcript.d.ts +4 -0
  100. package/dist/providers/codex/transcript.js +161 -0
  101. package/dist/providers/codex/transport.d.ts +27 -0
  102. package/dist/providers/codex/transport.js +172 -0
  103. package/dist/providers/cursor/content.d.ts +8 -0
  104. package/dist/providers/cursor/content.js +132 -0
  105. package/dist/providers/cursor/continuation.d.ts +16 -0
  106. package/dist/providers/cursor/continuation.js +43 -0
  107. package/dist/providers/cursor/contracts.d.ts +25 -0
  108. package/dist/providers/cursor/contracts.js +0 -0
  109. package/dist/providers/cursor/create.d.ts +4 -0
  110. package/dist/providers/cursor/create.js +58 -0
  111. package/dist/providers/cursor/driver.d.ts +5 -0
  112. package/dist/providers/cursor/driver.js +50 -0
  113. package/dist/providers/cursor/identity.d.ts +5 -0
  114. package/dist/providers/cursor/identity.js +35 -0
  115. package/dist/providers/cursor/mutations.d.ts +10 -0
  116. package/dist/providers/cursor/mutations.js +45 -0
  117. package/dist/providers/cursor/native.d.ts +92 -0
  118. package/dist/providers/cursor/native.js +69 -0
  119. package/dist/providers/cursor/options.d.ts +9 -0
  120. package/dist/providers/cursor/options.js +30 -0
  121. package/dist/providers/cursor/process.d.ts +12 -0
  122. package/dist/providers/cursor/process.js +43 -0
  123. package/dist/providers/cursor/runtime.d.ts +3 -0
  124. package/dist/providers/cursor/runtime.js +6 -0
  125. package/dist/providers/cursor/session.d.ts +19 -0
  126. package/dist/providers/cursor/session.js +116 -0
  127. package/dist/providers/cursor/transcript.d.ts +4 -0
  128. package/dist/providers/cursor/transcript.js +90 -0
  129. package/dist/providers/cursor/worker/main.d.ts +2 -0
  130. package/dist/providers/cursor/worker/main.js +86 -0
  131. package/dist/providers/cursor/worker/protocol.d.ts +67 -0
  132. package/dist/providers/cursor/worker/protocol.js +157 -0
  133. package/dist/providers/cursor/worker/sdk.d.ts +4 -0
  134. package/dist/providers/cursor/worker/sdk.js +59 -0
  135. package/dist/providers/grok/content.d.ts +7 -0
  136. package/dist/providers/grok/content.js +113 -0
  137. package/dist/providers/grok/continuation.d.ts +16 -0
  138. package/dist/providers/grok/continuation.js +27 -0
  139. package/dist/providers/grok/contracts.d.ts +96 -0
  140. package/dist/providers/grok/contracts.js +0 -0
  141. package/dist/providers/grok/create.d.ts +5 -0
  142. package/dist/providers/grok/create.js +81 -0
  143. package/dist/providers/grok/driver.d.ts +7 -0
  144. package/dist/providers/grok/driver.js +81 -0
  145. package/dist/providers/grok/extensions.d.ts +6 -0
  146. package/dist/providers/grok/extensions.js +51 -0
  147. package/dist/providers/grok/identity.d.ts +12 -0
  148. package/dist/providers/grok/identity.js +81 -0
  149. package/dist/providers/grok/management.d.ts +5 -0
  150. package/dist/providers/grok/management.js +33 -0
  151. package/dist/providers/grok/mounts.d.ts +8 -0
  152. package/dist/providers/grok/mounts.js +35 -0
  153. package/dist/providers/grok/native.d.ts +144 -0
  154. package/dist/providers/grok/native.js +114 -0
  155. package/dist/providers/grok/options.d.ts +50 -0
  156. package/dist/providers/grok/options.js +96 -0
  157. package/dist/providers/grok/process.d.ts +15 -0
  158. package/dist/providers/grok/process.js +129 -0
  159. package/dist/providers/grok/request.d.ts +2 -0
  160. package/dist/providers/grok/request.js +27 -0
  161. package/dist/providers/grok/search.d.ts +6 -0
  162. package/dist/providers/grok/search.js +127 -0
  163. package/dist/providers/grok/session.d.ts +34 -0
  164. package/dist/providers/grok/session.js +62 -0
  165. package/dist/providers/grok/transcript.d.ts +4 -0
  166. package/dist/providers/grok/transcript.js +89 -0
  167. package/dist/providers/grok/transport.d.ts +9 -0
  168. package/dist/providers/grok/transport.js +82 -0
  169. package/dist/providers/opencode/client.d.ts +4 -0
  170. package/dist/providers/opencode/client.js +143 -0
  171. package/dist/providers/opencode/content.d.ts +4 -0
  172. package/dist/providers/opencode/content.js +196 -0
  173. package/dist/providers/opencode/continuation.d.ts +16 -0
  174. package/dist/providers/opencode/continuation.js +49 -0
  175. package/dist/providers/opencode/contracts.d.ts +58 -0
  176. package/dist/providers/opencode/contracts.js +0 -0
  177. package/dist/providers/opencode/create.d.ts +4 -0
  178. package/dist/providers/opencode/create.js +73 -0
  179. package/dist/providers/opencode/identity.d.ts +2 -0
  180. package/dist/providers/opencode/identity.js +17 -0
  181. package/dist/providers/opencode/mutations.d.ts +5 -0
  182. package/dist/providers/opencode/mutations.js +48 -0
  183. package/dist/providers/opencode/native.d.ts +46 -0
  184. package/dist/providers/opencode/native.js +65 -0
  185. package/dist/providers/opencode/options.d.ts +7 -0
  186. package/dist/providers/opencode/options.js +80 -0
  187. package/dist/providers/opencode/session.d.ts +8 -0
  188. package/dist/providers/opencode/session.js +94 -0
  189. package/dist/providers/opencode/transcript.d.ts +5 -0
  190. package/dist/providers/opencode/transcript.js +93 -0
  191. package/dist/providers/process/group.d.ts +3 -0
  192. package/dist/providers/process/group.js +29 -0
  193. package/dist/providers/process/json-worker.d.ts +23 -0
  194. package/dist/providers/process/json-worker.js +152 -0
  195. package/dist/providers/process/owner.d.ts +15 -0
  196. package/dist/providers/process/owner.js +64 -0
  197. package/dist/providers/process/runtime.d.ts +3 -0
  198. package/dist/providers/process/runtime.js +10 -0
  199. package/dist/providers/process/worker-channel.d.ts +10 -0
  200. package/dist/providers/process/worker-channel.js +49 -0
  201. package/dist/validation/bounds.d.ts +8 -0
  202. package/dist/validation/bounds.js +98 -0
  203. package/dist/validation/errors.d.ts +7 -0
  204. package/dist/validation/errors.js +19 -0
  205. package/dist/validation/operations.d.ts +38 -0
  206. package/dist/validation/operations.js +103 -0
  207. package/dist/validation/parse.d.ts +29 -0
  208. package/dist/validation/parse.js +121 -0
  209. package/dist/validation/records.d.ts +39 -0
  210. package/dist/validation/records.js +175 -0
  211. package/dist/zod.d.ts +3 -0
  212. package/dist/zod.js +82 -0
  213. package/package.json +109 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Trevor Nichols
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,390 @@
1
- # Temporary Holding Version
1
+ # @agen-ai/agent-history
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Portable native conversation discovery, transcript reading, search and explicitly enabled saved-session management. History is separate from agent execution: browsing does not create a session, generate a prompt, resume a turn or answer a pending request.
4
+
5
+ This package is the eighth package in the coordinated **0.4.4 source candidate**, with Agent Protocol V12 unchanged. The candidate is unpublished. The recorded npm `latest` and `beta` release remains the seven-package **0.4.3** set, which did not include agent-history. Use a built candidate checkout or its complete matching packed artifacts; agent-history 0.4.4 is not a published installation target in this source-readiness record.
6
+
7
+ The root exports plain contracts, bounded parsers and `createAgentHistory` for custom adapter composition. The explicit `/zod` entrypoint exposes schemas. Root imports do not open a store, inspect a home, start a process, authenticate or access the network. No native vendor SDK is required to install or import this root.
8
+
9
+ ## Explicit sources and qualification
10
+
11
+ Choose a provider entrypoint and construct a source with explicit native roots or a caller-owned connection. Imports remain inert, including when optional peers are absent. Native setup, identity checks and resource acquisition occur only at construction or operation boundaries.
12
+
13
+ | Entrypoint and constructor | Qualified native version | Source and main coverage |
14
+ | --- | --- | --- |
15
+ | `/claude`: `createClaudeHistory` | Claude Agent SDK 0.3.306; Code 2.1.306 baseline | Explicit configuration home; project/worktree policy or all projects; `retained_chain`. |
16
+ | `/codex`: `createCodexHistoryProcess` or borrowed `createCodexHistory` | Codex app-server 0.163.0 | Explicit home/initialized connection, project or all projects, selected catalog policy/source kinds; `retained_chain`. |
17
+ | `/opencode`: `createOpenCodeHistory` | OpenCode runtime and client 2.1.2 | Supplied server and exact project directory in its namespace; `retained_chain`. |
18
+ | `/cursor`: `createCursorHistory` | Cursor SDK 1.0.40 | Existing SDK JSONL/SQLite store and exact project; main `current_checkpoint`, terminal run views `stored_updates`. |
19
+ | `/grok`: `createGrokHistoryProcess` or borrowed `createGrokHistory` | Grok Build 1.0.62 | Exact selected native project; surviving-branch `stored_updates`. |
20
+ | `/acp`: `createAcpHistory` | ACP `schema-v1.23.0` | Already initialized caller-owned transport, project or all projects; negotiated catalog only. |
21
+
22
+ Exact-native qualification used Linux x86_64 and Node 24.18.0. The portable root requires Node >=22; Cursor construction requires Node >=22.13. Version checks and retained executable/module digests identify the qualified inputs rather than authenticating a publisher. These source kinds do not establish general platform, account or store compatibility. Cursor IDE and legacy CLI stores are unqualified; Cursor cloud transcript replay is also unqualified and has no shipped constructor. The cloud observation reached metadata but the sampled retained run stream returned HTTP 410.
23
+
24
+ ## Reading history
25
+
26
+ Operations have independent supported/unsupported discriminants. Unsupported operations have a reason and no callable method. Catalog discovery and metadata lookup are separate because some native protocols provide only listing. A consumer can browse any constructed source through the same interface:
27
+
28
+ ```ts
29
+ import type { AgentHistory } from '@agen-ai/agent-history';
30
+
31
+ export async function browse(history: AgentHistory) {
32
+ try {
33
+ if (history.catalog.status === 'unsupported') return history.catalog.reason;
34
+ const catalog = await history.catalog.list({ limit: 20 });
35
+ const conversation = catalog.items[0];
36
+ if (!conversation || history.transcript.status === 'unsupported') return catalog;
37
+ const transcript = await history.transcript.read({ conversation: conversation.ref, limit: 20 });
38
+ return { conversation, transcript };
39
+ } finally {
40
+ await history.close();
41
+ }
42
+ }
43
+ ```
44
+
45
+ Pages include observation time, live/snapshot consistency and coverage. End of pagination means the selected native view has ended. It does not mean deleted or compacted history was recovered. Records preserve native turn/item references when available; they never invent live SDK turn IDs or stable message IDs from mutable offsets. Tool calls, tool results and attachment references are inert data. Reading does not execute tools or fetch attachment URIs.
46
+
47
+ Pass `nextCursor` back to the same history instance with the same operation, source generation, conversation, view and query. Changing filters or order starts a new traversal. Cursors are bounded opaque continuations sealed by a key held only by that history instance. Reopening a source starts a new traversal even when references retain the same source generation. The seal protects continuation integrity; it grants no account authorization or execution authority. They can contain native continuation data and should be handled like other history metadata.
48
+
49
+ A source has a stable caller-assigned `sourceId` and a configuration `generation`. Change the generation when its account, native root, server identity or effective scope changes. References from a different source/generation fail before delegation. Do not put credentials in either identifier. Supplying a history reference to an execution API still requires that API's explicit binding and authority.
50
+
51
+ ## Limits and lifecycle
52
+
53
+ Default limits are 100 records and 1 MiB normalized output per page, four concurrent reads, a 30-second operation deadline and a 10-second cleanup deadline. Configuration may lower page/concurrency limits; operation deadlines cannot exceed the configured maximum or the absolute 120-second ceiling. Cursor envelopes are limited to 64 KiB. An indivisible oversized record fails instead of being truncated and skipped. Provider limits may be lower.
54
+
55
+ These limits apply to SDK-owned operations and output. Native helper input work, worker address space and caller-owned remote server memory are separate concerns. A small returned page does not prove a small native read. Native provider construction must disclose its resource policy and storage effects; a package must not infer aggregate process-tree memory limits from a per-process limit.
56
+
57
+ Admission is immediate: occupied capacity returns `busy` rather than queuing indefinitely. A timeout or caller cancellation releases the caller's wait while retaining operation capacity until the driver actually settles. Cancellation is passed through an `AbortSignal`. A driver must stop owned work on cancellation; a borrowed connection remains its owner's responsibility.
58
+
59
+ `close()` rejects new operations, aborts entered work, initiates owned disposal and then joins entered operations. Simultaneous closes share one attempt; successful repeated close is harmless. Failed cleanup throws `AgentHistoryCleanupError` with `retryCleanup()`. Keep that error or the history source until cleanup succeeds. A retry shares any still-running disposal attempt instead of starting a second one. Borrowed sources never dispose the supplied native client.
60
+
61
+ ## Search and management
62
+
63
+ Metadata search and content search are separate ports. Descriptors state syntax, case sensitivity, ranking and scope; title matching does not imply transcript search. The package does not build its own index or emulate missing search by reading every conversation. Optional search scores and matched fields come from the native provider; scores are not comparable across providers. `totalEstimate` is an estimate, even when a native response can count its current result set.
64
+
65
+ Management defaults disabled. Select individual operations through the constructor's `management` array, then narrow the relevant port. Each mutation input must include `acceptEffects` matching that port's declared effects, including local/remote scope, descendants, active-session constraints and atomicity. A mismatch returns `not_applied` before native dispatch.
66
+
67
+ Well-formed mutation requests return `applied`, `not_applied` or `outcome_unknown`. Malformed arguments and foreign references reject before delegation. Once native dispatch has occurred, timeout, cancellation or an unclassified transport failure can produce `outcome_unknown`; they do not prove rollback. Never automatically retry an uncertain mutation. Further mutations on that source are fenced until the caller inspects native state and reopens; available read ports remain usable. Valid successful native receipts remain applied, including when a caller selects a small read-page budget or cleanup subsequently fails. Normal success waits for owned cleanup. If a receipt was recorded before cancellation or a deadline, that known result can return while cleanup retains operation capacity. A receipt arriving after an already returned unknown outcome cannot rewrite it.
68
+
69
+ The qualified operations differ by source:
70
+
71
+ | Source | Metadata search | Content search | Opt-in management |
72
+ | --- | --- | --- | --- |
73
+ | Claude local | Unavailable | Unavailable | Rename, delete with subagents |
74
+ | Codex app-server | Case-sensitive literal title | Unavailable | Rename, archive descendants, restore selected thread, delete descendants |
75
+ | OpenCode V2 server | Case-insensitive SQL-LIKE title | Unavailable | Rename, archive, restore, delete descendants |
76
+ | Cursor local SDK | Unavailable | Unavailable | Archive, restore, delete selected agent and its stored run data |
77
+ | Grok Build | Case-insensitive native metadata | Native ranked title/user-prompt search | Owned, caller-quiescent local rename/delete |
78
+ | Generic ACP | Unsupported by the pinned standard | Unsupported by the pinned standard | Delete unqualified; other operations unsupported |
79
+
80
+ An accepted descendant effect can include children whose project differs from their root. Project-scoped admission checks the selected root; it does not restrict a native cascade to that project. `requires_quiescent` is a caller obligation covering the affected subtree. A preflight activity observation is not a lock, lease or compare-and-swap guarantee. No native mutation is automatically retried.
81
+
82
+ ```ts
83
+ // Include management: ['rename'] when constructing a provider that supports it.
84
+ if (history.rename.status === 'supported') {
85
+ const result = await history.rename.apply({
86
+ conversation: selected.ref,
87
+ title: 'Release investigation',
88
+ acceptEffects: history.rename.descriptor.effects,
89
+ });
90
+ // Handle all three outcomes; reconcile native state after outcome_unknown.
91
+ console.log(result.status);
92
+ }
93
+ ```
94
+
95
+ Rename accepts canonical nonblank text, up to 2,000 UTF-16 code units, with no leading/trailing whitespace or control characters. Grok has a narrower native limit described below. Empty-name native behaviors, including generated titles, are deliberately unavailable.
96
+
97
+ Read-only describes the exposed operations. Native reads may initialize storage, maintain an index or update auxiliary files. The source descriptor reports these effects; it does not promise filesystem immutability. Private native-file scraping, SDK-implemented migration of native formats and loading live sessions to simulate history are outside this package's contract.
98
+
99
+ ## Public browsing examples
100
+
101
+ The standalone candidate checkout includes `examples/history/README.md` and the reusable `browseHistory(history, options)` helper. After building that checkout, `pnpm examples:history` runs its synthetic source without native SDKs, credentials or execution. `pnpm examples:history:claude` is a separate explicitly configured native reader; follow its documented root/project/resource arguments and install the exact optional peer first. The helper narrows each port, preserves pages and coverage, bounds traversal, and closes its supplied source in `finally`. Its default summary excludes IDs, titles, text, paths and cursors; the reusable result retains actual records for its caller.
102
+
103
+ MS009 compiled and executed the unchanged examples from eight packed development archives across the core-only, vendor-absent history/borrowed Codex, Claude, Codex, OpenCode, Cursor, ACP/Grok and complete-SDK compositions. Those archives retained the temporary 0.4.3 development version and were not a publication. A newly packed 0.4.4 candidate requires its own assembly checks; it does not inherit the old archive identities or broaden native qualification.
104
+
105
+ ## Implementing a custom driver
106
+
107
+ `createAgentHistory({ source, driver, limits?, management? })` synchronously validates a preconstructed driver and returns the portable boundary. Every port must explicitly declare support. Supported descriptors and returned records pass through the public parsers. The driver receives validated input and a context containing `signal` and `markDispatched()`; public cursors are decoded to the driver's native continuation string.
108
+
109
+ Call `markDispatched()` immediately before entering a native mutation. Before that call, a rejected operation must have had no native mutation effect. After dispatch, return `not_applied` only when the native outcome establishes that fact; preserve an actual successful receipt. Mutation contexts additionally provide `recordReceipt(result)`: validate the native response and record its portable result once, before follow-up reads, signal checks or cleanup can fail. Return the same result when the operation settles. The boundary validates and preserves that recorded truth without relinquishing native cleanup ownership. This dispatch evidence is what lets the boundary distinguish a rejected request from a lost response. Driver errors must use bounded `AgentHistoryError` codes rather than exposing vendor response bodies, endpoints or credentials.
110
+
111
+ An owned source must provide `dispose()`, which stops native producers and resolves only when cleanup is complete. A borrowed source must not provide disposal. Driver construction and startup belong to the adapter; ownership transfers to the history object only after successful synchronous construction. If construction rejects, the caller still owns its supplied driver and any resources it already created. Native adapters must validate configuration before acquisition and retain cleanup responsibility on startup failure.
112
+
113
+ The root's portable validation does not replace native transport response limits. Validate and bound untrusted vendor responses at their ingress, normalize them into these contracts, and keep native classes and payloads out of public declarations.
114
+
115
+ ## Claude native history
116
+
117
+ The explicit `/claude` entrypoint uses the official `@anthropic-ai/claude-agent-sdk@0.3.306` history helpers. Install that exact optional peer only when using Claude. Importing `/claude` works without the peer and performs no native I/O; construction checks the installed package version and qualified SDK entry digest. History helpers do not require launching the Claude Code executable. The qualification baseline records Code 2.1.306 separately.
118
+
119
+ ```ts
120
+ import { createClaudeHistory } from '@agen-ai/agent-history/claude';
121
+
122
+ const history = await createClaudeHistory({
123
+ sourceId: 'local-claude',
124
+ generation: 'config-v1',
125
+ configHome: '/absolute/claude-config',
126
+ scope: { kind: 'project', projectPath: '/absolute/project', worktrees: 'excluded' },
127
+ includeProgrammatic: true,
128
+ resources: {
129
+ kind: 'linux-prlimit',
130
+ executable: '/usr/bin/prlimit',
131
+ temporaryRoot: '/absolute/existing-temporary-directory',
132
+ },
133
+ });
134
+
135
+ try {
136
+ if (history.catalog.status === 'supported') {
137
+ const page = await history.catalog.list({ limit: 20 });
138
+ const first = page.items[0];
139
+ if (first && history.transcript.status === 'supported') {
140
+ const transcript = await history.transcript.read({ conversation: first.ref, limit: 20 });
141
+ console.log(transcript.items, transcript.coverage);
142
+ }
143
+ }
144
+ } finally {
145
+ await history.close();
146
+ }
147
+ ```
148
+
149
+ Configuration and project directories must already exist. Each source creates a private temporary directory beneath the supplied temporary root; close removes that owned directory after its workers exit. The configured native home is never a temporary cleanup target. Select `{ kind: 'all_projects' }` to use the helper's all-project discovery. Project-only lookup/read checks the native metadata's physical working directory because the upstream direct helpers can otherwise traverse linked worktrees. Unavailable or deleted project metadata cannot establish that restricted scope. `includeProgrammatic` controls catalog discovery only; it does not restrict lookup by a known native ID.
150
+
151
+ Claude currently exposes catalog, metadata lookup and the main transcript, in native order. Search, archive and restore are unavailable. `management: ['rename', 'delete']` selectively enables native rename and deletion. Rename affects the selected session; deletion removes its native subagent artifacts but preserves independently forked sessions. Both are local, non-atomic operations requiring caller quiescence. Workers check scope before asking their parent for a single mutation permit; cancellation before that permit cannot dispatch the mutation. A titled existing conversation can have an empty transcript; missing, sidechain and summaryless files may all be unavailable through the metadata helper and return `not_found`. Reads check metadata before and after transcript retrieval, so an observed concurrent deletion does not become a successful empty result. Live native history can still change between observations.
152
+
153
+ The transcript reports `retained_chain`, with native-retention and subagent omissions. The helper can omit old content after compaction and strips some system-record metadata. Opaque system records become notices; they are never guessed to be compaction events. Ordered text/thinking/attachment content and tool observations remain in their native order across pages. Several normalized records can share the same genuine native history anchor. A continuation inside a native message checks that anchor again and rejects a changed record. Attachments remain inert references; small bounded inline data references are preserved, while unsupported or larger inline content reports an omission.
154
+
155
+ The qualified implementation uses a separate Linux process for each operation, with the configured home set before SDK import and no mutation of the caller's environment. The worker verifies kernel limits: 4 GiB address space, 12 CPU seconds, 128 file descriptors and zero core-file bytes. Supplementary Node settings are JITless execution and a 128 MiB heap. Each worker has a 20-second wall ceiling, a 32 KiB input envelope and a 256 KiB combined output ceiling. Source defaults lower normalized pages to 192 KiB and operation deadlines to 20 seconds. A 2 KiB continuation allowance means smaller page budgets must leave room for records and metadata.
156
+
157
+ Native helpers may load an entire file or enumerate a catalog before slicing; the process limits provide bounded failure, not a promise that every store fits. Individual returned native records also pass a 1 MiB/depth-16 ingress boundary before normalization. These per-process limits do not establish aggregate RSS containment or a general filesystem/network sandbox. The source bounds concurrent workers through ordinary read admission. Cancellation and close terminate owned process groups and wait for cleanup; incomplete cleanup remains retryable. The reader does not pass backend credentials or loader overrides into its worker environment.
158
+
159
+ ## Codex native history
160
+
161
+ The explicit `/codex` entrypoint supports the qualified local app-server **0.163.0**. It exposes catalog, metadata lookup, main-transcript reading and literal, case-sensitive title search. `management` can independently enable rename, archive, restore and delete. Content search is unavailable. Importing the entrypoint does not find a home, start a process or require installation of the Codex npm package.
162
+
163
+ For an owned process, supply the exact qualified Linux x86_64 executable and explicit existing directories and launchers:
164
+
165
+ ```ts
166
+ import { createCodexHistoryProcess } from '@agen-ai/agent-history/codex';
167
+
168
+ const history = await createCodexHistoryProcess({
169
+ sourceId: 'local-codex',
170
+ generation: 'config-v1',
171
+ executable: '/absolute/path/to/native/codex',
172
+ configHome: '/absolute/codex-home',
173
+ scope: { kind: 'project', projectPath: '/absolute/project', worktrees: 'excluded' },
174
+ catalogPolicy: 'state_db_only',
175
+ resources: {
176
+ kind: 'linux-prlimit-bubblewrap',
177
+ resourceLauncher: '/usr/bin/prlimit',
178
+ sandboxLauncher: '/usr/bin/bwrap',
179
+ temporaryRoot: '/absolute/existing-temporary-directory',
180
+ },
181
+ });
182
+
183
+ try {
184
+ if (history.catalog.status === 'supported') {
185
+ console.log(await history.catalog.list({ limit: 20, archived: 'exclude' }));
186
+ }
187
+ } finally {
188
+ await history.close();
189
+ }
190
+ ```
191
+
192
+ This constructor checks the native executable SHA-256 `399ff69c431c066e40de318fba45c2b07f45a76b19939d247ee4828fc70c4215` at construction and before every operation. Pass the native binary, not an npm launcher script. The package's exact Codex development dependency supplies qualification fixtures; consumers explicitly provide their executable. The host must support the configured Bubblewrap namespace policy. Unsupported hosts fail instead of silently running without containment.
193
+
194
+ `createCodexHistory` accepts a borrowed, already initialized `CodexHistoryConnection`, explicit `{ kind: 'caller_owned' }` resources, and the same source/scope/catalog configuration. That plain public connection port admits only the closed qualified history request shapes, including the four named mutation methods and returns bounded UTF-8 JSON-RPC response envelopes as `Uint8Array`. The host owns correlation, authentication, endpoint identity, startup policy and native resource containment; it must enforce the requested response-byte ceiling before allocating a complete response and honor cancellation. The adapter validates bytes before normalization, but cannot bound allocations or work that already occurred inside a supplied connection. Closing the history source never closes that connection. Its runtime assertion must identify exact `0.163.0`; this is a host assertion, not executable attestation.
195
+
196
+ Choose `catalogPolicy` deliberately. `state_db_only` omits threads that native metadata has not indexed and avoids list-time rollout scanning/repair. `scan_and_repair` uses native list repair and can add those threads to the index. On exact 0.163.0, a cold repair scan can return only a prefix and no continuation because the native index contains only that newly repaired prefix. The reader reports `provider_omission` and preserves the native cursor; it does not silently warm the whole store or invent a cursor. Complete catalog traversal is qualified for an already populated native metadata index. Neither policy promises an immutable store: native startup can initialize or migrate its SQL schema and update auxiliary files. The owned reader explicitly disables background rollout-to-indexed-store migration. Existing indexed stores are supported without enabling that migration; the qualification suite creates indexed fixtures separately.
197
+
198
+ Catalog defaults select all ten qualified native source kinds, including CLI, VS Code, app-server, programmatic and subagent categories. An explicit `sourceKinds` constructor selection limits catalog discovery, and per-call filters can only narrow it. Source-kind filters do not restrict a known-ID lookup within the configured project. The model-provider filter is unrestricted. Project matching is an exact native working-directory match, with no automatic linked-worktree traversal. Catalog supports separate active (`exclude`, the default) or archived (`only`) traversals; `include` and parent queries are unsupported. Parent references use the native subagent parent field, with the qualified stored thread-spawn source as a fallback when that field is absent. A separate native fork origin is not relabeled as a subagent parent. Native ordering means creation time descending; explicit creation/update ascending/descending orders are available. Empty saved threads can be retrieved by ID even when the catalog omits them. The qualified native file lookup can fall back to fuzzy search when an exact saved ID is missing. The adapter rejects a returned different ID with `native_failure`; it never relabels that other thread as the requested one.
199
+
200
+ Transcripts use metadata-only `thread/read`, then ascending `thread/turns/list` for legacy stores or ascending `thread/items/list` for already indexed stores. They never request a resumed execution session or a prompt. Legacy turn pagination may replay the entire native rollout internally before returning a turn; a returned page limit is not a native input-work limit. Each public read performs at most eight native requests, including metadata checks around transcript traversal. A page can be short or empty with a continuation; keep following `nextCursor`. Intra-item continuations retain genuine native turn/item anchors and reject observed changes or store-mode changes. Records preserve native order, tool call/result pairs and explicit compaction items. Unsupported native content becomes an omission or notice. The main view reports the retained chain and excludes subagent transcripts; it does not recover content removed by native compaction.
201
+
202
+ The owned reader starts a fresh stdio app-server for each operation in a clean environment. Bubblewrap provides a networkless PID namespace, a read-only host mount and writable access to the explicitly supplied native home and owned scratch directory. Remote-control startup, automatic gateway login, apps, plugins, analytics and update checks are disabled on the qualified tuple. Startup does not resume persisted threads or dispatch their queued/goal work. The reader's closed protocol surface contains no execution methods or approval replies.
203
+
204
+ Metadata search uses native `searchTerm` with the same catalog filters, ordering and continuation rules. It searches titles, not transcript contents. Rename affects the selected thread; archive and delete cascade to native descendants, including descendants in other projects and already archived descendants where the native operation includes them. Restore unarchives the selected thread only. Management reports local effects and unknown atomicity. Preflight requires the root's observed state to be idle or not loaded; callers must independently quiesce the full affected subtree, including other app-server processes.
205
+
206
+ The process verifies kernel ceilings of 2 GiB address space, 30 CPU seconds, 256 descriptors and zero core bytes. Framing limits are 2 MiB per response, 16 MiB combined output, 256 frames and one outstanding native request; each request has a 10-second ceiling and each process a 30-second ceiling. Normalized pages default to 192 KiB, with bounded continuation overhead; individual parsed envelopes also pass the shared 1 MiB/depth-16 data boundary. Native ascending catalog listing can enumerate the filesystem before returning a small page. These are per-process and per-operation bounds, not an aggregate RSS guarantee or a promise that arbitrary native stores fit. Cancellation and close terminate and join the owned process group before removing scratch data. Claude and Codex share this resource-ownership implementation; native homes are never cleanup targets.
207
+
208
+ ## OpenCode V2 native history
209
+
210
+ The explicit `/opencode` entrypoint uses `@opencode/client/promise` from the exact optional peer **`@opencode/client@2.1.2`** against a supplied **OpenCode 2.1.2** server. It exposes catalog, metadata lookup and the main retained transcript. It does not start or stop the server. Importing the entrypoint works without the optional peer and makes no network request; asynchronous construction verifies the installed client version and calls the bounded native server-info route to check its reported runtime version. These checks establish compatibility, not executable or publisher attestation.
211
+
212
+ ```ts
213
+ import { createOpenCodeHistory } from '@agen-ai/agent-history/opencode';
214
+
215
+ const history = await createOpenCodeHistory({
216
+ sourceId: 'development-opencode',
217
+ generation: 'server-project-v1',
218
+ server: {
219
+ baseUrl: 'http://127.0.0.1:4096/',
220
+ runtimeVersion: '2.1.2',
221
+ // Supply this server's authentication headers here when required.
222
+ },
223
+ scope: { kind: 'project', projectPath: '/absolute/server/project', worktrees: 'excluded' },
224
+ resources: { kind: 'caller_owned' },
225
+ });
226
+
227
+ try {
228
+ if (history.catalog.status === 'supported') {
229
+ console.log(await history.catalog.list({ archived: 'exclude', limit: 20 }));
230
+ }
231
+ } finally {
232
+ await history.close();
233
+ }
234
+ ```
235
+
236
+ The directory is an exact, normalized absolute POSIX path in the server's namespace; it need not exist on the SDK host. No local `realpath` or implicit process working directory is used. Optional `projectID` additionally restricts the native project identity. Catalog filters cannot widen this configured scope, and returned catalog and lookup metadata are checked against it. Source kind `opencode-v2-server` makes no claim that the server is local. Server access and native resource containment remain the caller's responsibility. Native storage effects are reported as unknown because server policy and auxiliary effects are outside this reader's ownership.
237
+
238
+ Catalog traversal defaults to native update time descending and includes archived sessions unless narrowed to `exclude` or `only`. Explicit update ascending/descending and native parent filters are supported. Creation-time orders are unavailable. The native cursor carries the initial catalog filters; subsequent native requests pass that cursor without respecifying them. Message traversal is ascending, with an optional fixed constructor `messageType` selection. The selected type is repeated on native continuation requests while order comes from the native cursor. A final nonempty native page can have a continuation followed by an empty terminal page. Follow `nextCursor` until it is absent, including after short or empty pages.
239
+
240
+ Transcripts preserve native message identifiers, ordered user/assistant/system content, tool observations and completed compaction summaries. Partial or failed compaction remains an observation, not a claim that compaction completed. Splitting a message across portable pages retains its native anchor and content fingerprint; an observed change invalidates that continuation. Native retention, excluded subagents, selected message types and unsupported content are disclosed through coverage and inert omission records. Attachments are bounded references and are never fetched. Metadata is checked before and after each transcript page so an observed deletion or scope change cannot be returned as a successful empty conversation.
241
+
242
+ The client admits only the qualified GET history/server-info/activity routes and explicitly selected PATCH/DELETE session routes on the configured origin and base path. Redirects are rejected. Request URLs and headers together are capped at 32 KiB; response streams are stopped above 1 MiB before the official client parses JSON, with strict UTF-8 validation. Parsed history also passes the shared structural bounds. Each public operation makes at most eight native requests; transcript pages reserve two of those for metadata checks. Normalized pages default to and cannot exceed 192 KiB, and operation deadlines cannot exceed 30 seconds. These limits bound client-owned work; they do not bound the remote server's memory or prove a small native input scan.
243
+
244
+ Authentication denial returns a sanitized `access_denied` error. Native missing sessions, invalid continuations, inaccessible scope, malformed responses and oversized bodies remain distinct outcomes. Cancellation and close abort and drain this client's entered HTTP operations, while leaving the supplied server usable. They do not assert that a remote server rolled back or stopped all internal work. Metadata search uses native title SQL-LIKE matching: `%` and `_` retain wildcard meanings and native ASCII case folding. Catalog filters and continuation rules also apply to search. Transcript content search is unavailable.
245
+
246
+ Opt-in rename, archive and restore affect the selected session. Delete cascades through native descendants, including cross-project children. Effects have `provider_managed` scope because the supplied server owns storage and any replication; the adapter cannot promise local-only deletion. All operations require caller quiescence and report unknown atomicity. The bounded active-session map can reject an observed active root, but cannot certify inactivity across processes or lock its descendants. Only the official successful HTTP 204 response confirms application; interruption after dispatch remains uncertain.
247
+
248
+ ## Cursor local SDK history
249
+
250
+ The explicit `/cursor` entrypoint reads existing **`@cursor/sdk@1.0.40`** JSONL or SQLite local stores through the official SDK. Install that exact optional peer when using this provider. Construction requires Linux, Node **22.13 or later**, explicit existing store/project directories and an executable resource launcher. The ordinary package root retains Node >=22 compatibility. Importing `/cursor` remains inert without the optional peer; construction and each isolated worker verify the qualified SDK entry bytes. Executor platform binaries are unnecessary for these history reads.
251
+
252
+ ```ts
253
+ import { createCursorHistory } from '@agen-ai/agent-history/cursor';
254
+
255
+ const history = await createCursorHistory({
256
+ sourceId: 'local-cursor-sdk',
257
+ generation: 'store-project-v1',
258
+ store: { kind: 'jsonl', path: '/absolute/existing-sdk-store' },
259
+ scope: { kind: 'project', projectPath: '/absolute/project', worktrees: 'excluded' },
260
+ resources: {
261
+ kind: 'linux-prlimit',
262
+ executable: '/usr/bin/prlimit',
263
+ temporaryRoot: '/absolute/existing-temporary-directory',
264
+ },
265
+ });
266
+
267
+ try {
268
+ if (history.catalog.status === 'supported' && history.views.status === 'supported'
269
+ && history.transcript.status === 'supported') {
270
+ const conversation = (await history.catalog.list({ limit: 20 })).items[0];
271
+ if (conversation) {
272
+ const checkpoint = await history.transcript.read({ conversation: conversation.ref });
273
+ const runs = await history.views.list({ conversation: conversation.ref, kind: 'run' });
274
+ const run = runs.items[0];
275
+ const replay = run && await history.transcript.read({
276
+ conversation: conversation.ref, view: run.view,
277
+ });
278
+ console.log({ checkpoint, runs, replay });
279
+ }
280
+ }
281
+ } finally {
282
+ await history.close();
283
+ }
284
+ ```
285
+
286
+ Use `store.kind: 'sqlite'` for the official SQLite backend. Source kind `cursor-local-sdk` identifies a specific SDK store and project; it does not discover arbitrary IDE chats or legacy CLI databases. Project matching is exact, with no implicit current directory or worktree expansion. An omitted project would let the native helper use the worker's working directory, so all-project browsing is unavailable. Cloud-shaped IDs are rejected before native lookup, preventing the SDK's automatic cloud routing.
287
+
288
+ Catalog and lookup preserve native agent identity, title, available timestamps and archive observations. Catalog uses native order and project scope; it has no archive filter or search fallback. Catalog and run discovery each make at most eight native list calls per page, preserving continuations after short or empty pages. `views.list` discovers terminal run views for the selected conversation. Running/queued runs are excluded because their native conversation reader can tail execution. Runs are named transcript views, not child conversations or fabricated portable turn IDs. Other providers explicitly report whether named-view discovery is supported.
289
+
290
+ The main transcript comes from `Agent.messages.list` and describes the **current checkpoint**. A run view comes from `Agent.getRun(...).conversation()` and describes **stored updates** for that run; a checkpoint-only run can have no replay events. Neither promises a complete lifetime transcript. Native helper omissions, retention and excluded subagents remain visible in coverage, including the native helper's ability to return an empty result for malformed checkpoint content. Tools and attachments remain inert. Genuine stored user message IDs are preserved; native helper identifiers derived from list offsets, missing assistant IDs, tool call IDs and timestamps are never invented. Continuations retain checkpoint-root or settled-run revision observations and content fingerprints, rejecting observed changes during traversal.
291
+
292
+ JSONL reads do not modify the selected source store. SQLite opening can initialize or migrate native storage and update auxiliary files, which the source descriptor discloses. Worker-owned home/cache/temp directories are separate from the selected store. The adapter never configures the SDK globally in the caller process, starts a run, resumes an agent or supplies a backend key.
293
+
294
+ Opt-in archive/restore update the selected agent's native status and require caller quiescence. Delete removes the selected agent and its native runs, events and checkpoints; it does not recursively delete other agent conversations. All three are local and non-atomic. Preflight rejects an observed active agent/run, and native deletion also rejects its nonterminal active run. This guard is not an atomic cross-process exclusion guarantee. Missing selected agents fail preflight; repeated archive/restore preserve native idempotent status behavior. Rename and search are unavailable. The shared worker sends its native receipt before SQLite disposal, so a later disposal failure cannot rewrite a confirmed mutation.
295
+
296
+ Claude and Cursor share the isolated JSON worker transport: 4 GiB address space, 12 CPU seconds, 128 file descriptors, zero core bytes, a 128 MiB Node heap and a 20-second wall ceiling. Worker input is capped at 32 KiB, combined output at 256 KiB and normalized pages at 192 KiB. The native SDK can read a whole checkpoint or replay before returning a page; these limits can reject large stores and do not establish aggregate RSS bounds or filesystem sandboxing. Cancellation and close terminate and join owned process groups before deleting scratch directories. Native stores are never cleanup targets.
297
+
298
+ Cursor on Node 22 uses a separate bounded WebAssembly profile: JIT is enabled and `--disable-wasm-trap-handler` selects inline WebAssembly bounds checks so Node's bundled HTTP implementation fits the existing address-space limit. Its ESM HTTP import otherwise initializes Undici with WebAssembly unavailable under `--jitless`. All numeric worker limits remain enforced and checked inside the worker. Cursor on Node 24 retains the JITless profile; Claude always retains its existing JITless profile. This is an internal compatibility policy, not caller-selected Node flags or a general executable-memory isolation guarantee.
299
+
300
+ Cursor Cloud is a separate **unqualified source kind** in this release. Authenticated read-only probes established that current v1 agent/run metadata was reachable, but the sampled saved run's event stream had expired with HTTP 410. The current API documents retention-limited run streams; metadata availability alone does not qualify successful transcript replay. The SDK's local message helper is not a cloud transcript API. No cloud constructor, legacy v0 fallback, private IDE scraping, or universal Cursor-history claim is shipped. See the official [TypeScript SDK](https://cursor.com/docs/sdk/typescript) and [Cloud API stream retention](https://cursor.com/docs/cloud-agent/api/endpoints#retention) for the native distinction.
301
+
302
+ ## Negotiated ACP discovery
303
+
304
+ The explicit `/acp` entrypoint provides saved-session discovery through an already initialized ACP connection using **`schema-v1.23.0`**. It does not launch or initialize the agent. Supply the actual initialization response and a narrow listing port backed by the existing `@agen-ai/acp-transport` implementation:
305
+
306
+ ```ts
307
+ import { createAcpStandardSessionOperations } from '@agen-ai/acp-transport';
308
+ import { createAcpHistory } from '@agen-ai/agent-history/acp';
309
+
310
+ // The host constructs and owns a bounded ACP client and its native process.
311
+ const operations = createAcpStandardSessionOperations(client);
312
+ const initialization = await operations.initialize({
313
+ protocolVersion: 1,
314
+ clientCapabilities: {},
315
+ });
316
+ const history = createAcpHistory({
317
+ providerKey: 'my-acp-agent',
318
+ sourceId: 'connected-agent',
319
+ generation: 'connection-project-v1',
320
+ scope: { kind: 'project', projectPath: '/absolute/native/project', worktrees: 'excluded' },
321
+ connection: {
322
+ protocolProfile: 'schema-v1.23.0',
323
+ initialization,
324
+ resources: { kind: 'caller_owned', maxInboundFrameBytes: 1_048_576 },
325
+ listSessions: (params, options) => operations.listSessions(params, options),
326
+ },
327
+ });
328
+ try {
329
+ if (history.catalog.status === 'supported') {
330
+ console.log(await history.catalog.list({ limit: 20 }));
331
+ }
332
+ } finally {
333
+ await history.close();
334
+ // The host still owns client disposal and native process cleanup.
335
+ }
336
+ ```
337
+
338
+ The connection's ingress limit describes the bound the host actually configured on the transport; it is not a request to reconfigure that client. The adapter additionally validates bounded parsed responses. `providerKey` identifies the connected provider but grants no capability. Catalog support requires the observed native `agentCapabilities.sessionCapabilities.list` field. Absent negotiation produces an unsupported port and no list dispatch. A previously initialized client supplies its existing result instead of initializing again.
339
+
340
+ Generic ACP exposes catalog discovery only. The native standard has no independent saved-transcript, lookup, search, rename, archive or restore operation. Optional standard deletion has a typed transport facade but remains unqualified in this generic history adapter; negotiation alone cannot establish its effects. `session/load` is not used as a transcript reader. A provider name never enables Grok-specific extension behavior.
341
+
342
+ Scope is an exact native project directory or explicit `all_projects`; a project filter may narrow all-project browsing. Paths belong to the native agent, not the SDK host filesystem. Catalog uses native order, unknown archive state and provider-defined coverage. The source kind is `acp-standard-discovery`, native ownership is borrowed and storage effects are unknown. Closing history aborts and drains its entered calls while preserving the host's connection.
343
+
344
+ The pinned standard list request has no page-size control. The adapter reads at most eight native pages per operation and splits an already bounded page when necessary. Continuations retain the native page-start cursor, offset and content fingerprint, then refetch that page; an observed change invalidates continuation. They never contain a copied page of messages. Short or empty pages with continuations remain valid. Parsed envelopes are limited to 1 MiB and 1,000 sessions; normalized pages to 192 KiB, with a 30-second maximum operation deadline. These bounds do not contain work or allocations inside the caller-owned agent. The standard facade preserves existing legacy-profile behavior: listing remains available there, while deletion is admitted only by a profile that includes it.
345
+
346
+ ## Grok Build stored history
347
+
348
+ The explicit `/grok` entrypoint reads the qualified **Grok Build 1.0.62** saved-session store through the existing ACP transport. It supports catalog, metadata lookup and surviving stored updates for one exact project. The owned-process constructor requires the exact executable, an existing native home containing its `sessions` directory, and Linux resource launchers:
349
+
350
+ ```ts
351
+ import { createGrokHistoryProcess } from '@agen-ai/agent-history/grok';
352
+
353
+ const history = await createGrokHistoryProcess({
354
+ sourceId: 'local-grok-build',
355
+ generation: 'home-project-v1',
356
+ executable: '/absolute/qualified/grok',
357
+ nativeHome: '/absolute/existing/grok-home',
358
+ scope: { kind: 'project', projectPath: '/absolute/project', worktrees: 'excluded' },
359
+ resources: {
360
+ kind: 'linux-prlimit-bubblewrap',
361
+ resourceLauncher: '/usr/bin/prlimit',
362
+ sandboxLauncher: '/usr/bin/bwrap',
363
+ temporaryRoot: '/absolute/existing-temporary-directory',
364
+ },
365
+ });
366
+ try {
367
+ if (history.catalog.status === 'supported' && history.transcript.status === 'supported') {
368
+ const conversation = (await history.catalog.list({ limit: 20 })).items[0];
369
+ if (conversation) console.log(await history.transcript.read({ conversation: conversation.ref }));
370
+ }
371
+ } finally {
372
+ await history.close();
373
+ }
374
+ ```
375
+
376
+ Catalog, lookup and transcript operations start a fresh native home and mount the selected `sessions` directory read-only. A held directory descriptor and identity checks preserve the selected store across launch; Bubblewrap must support `--ro-bind-fd`. Home, XDG and launch directories live beneath a fixed sandbox path in a fresh `/tmp`, preventing configuration discovery through the host scratch directory's ancestors. The explicit host scratch root must be outside the original native home and selected project. Original account credentials, home/project configuration and machine configuration are excluded, and networking is disabled. Search indexes and read-time auxiliary caches belong to scratch storage; explicit management has the separate writable policy below. The original store is never a cleanup target. This exact storage-layout mapping is version-qualified; it is not a generic parser for Grok files.
377
+
378
+ The constructor verifies the executable SHA-256 `2a46d9e4d7ebd7a9cff7f95716714b19dad5f21dd2a497822400b1fb128969aa` and observed native version. This identifies the qualified bytes, not publisher authenticity. The official exact npm distribution contains the same executable; the history package does not install or launch it at import. Install the coordinated optional `@agen-ai/acp-transport` peer when constructing an owned reader.
379
+
380
+ For an already initialized host-owned process, synchronous `createGrokHistory` accepts the actual initialization result, exact runtime/profile identity and three required named methods: `listSessions`, `sessionState` and `sessionUpdates`. Optional `sessionSearch` enables native content search. The connection's `resources` declares its actual ingress bound. `grokHistoryExtensions()` supplies the exact outbound history/search extension definitions; an explicit management selection additionally registers only the chosen admin definitions for the host's existing ACP registry. Borrowed history does not initialize or dispose that connection, and cannot promise the owned constructor's source isolation or native resource limits. Its storage effects are unknown.
381
+
382
+ Catalog selects native Build sessions and excludes child sessions. Direct metadata and transcript reads check the returned native project, including when Grok looks up an ID outside the requested directory. Missing state is distinguished from an empty stored update list. Transcripts use `_x.ai/session/updates`, with `_x.ai/session/state` providing metadata and revision observations. Neither `session/load`, the unsupported `load_history` route, nor a prompt is used.
383
+
384
+ The main view describes **stored updates** on the surviving branch, with native-retention, provider and subagent omissions. Adjacent text chunks remain separate records; their count is not a message or turn count. Genuine event IDs and timestamps are preserved when available. Tool observations and attachments are inert; native display titles do not establish executable tool identity. Unsupported or oversized inline content produces explicit omissions. Continuations retain a native offset, observed state revision, total update count and preceding-update fingerprint. Native launch-home metadata is excluded from that revision because it describes launch context rather than persisted conversation content. Observed changes invalidate continuation; this is a live traversal, not a snapshot.
385
+
386
+ Owned reads have a 20-second wall ceiling, 4 GiB address space, 20 CPU seconds, 256 file descriptors and zero core bytes per process. ACP ingress is capped at 1 MiB, with one outstanding request, at most eight native calls per operation including initialization, and 192 KiB normalized pages. Native update retrieval can read the whole saved file before returning one update, so a small requested page does not promise success for an arbitrarily large store. Cancellation and close stop and join the owned process group before removing scratch storage. Metadata search uses native list filtering, preserves native order and excludes child sessions. Content search uses the native FTS index, including saved titles and user prompts; it does not promise assistant/tool-text matching or full lifetime history. Native token-prefix matching, AND/OR fallback, ASCII folding and UUID handling are provider-defined. Results preserve native ranking, snippets, matched fields and optional estimates. The native search window permits offsets through 1,000; truncation reports `resource_limit`, and native omissions remain disclosed, including body content in saved files larger than 30 MiB (their titles remain searchable). A settling index is retried only within the read budget and never becomes a false complete empty page.
387
+
388
+ Owned content search gives the native helper a fresh writable cache and mounts its original encoded-project directories read-only through held descriptors. Directory discovery is bounded to 256 entries and 64 project mounts; it reads no saved-session content itself. The native query and returned hits must match the exact selected project. Search neither copies the user's history into an SDK index nor modifies the source store.
389
+
390
+ Owned rename/delete require both an individual `management` selection and `localManagement: { kind: 'caller_quiescent' }`. The latter is an explicit caller obligation to exclude writers; it is not an SDK lease. After read-only scope/existence preflight, the isolated, unauthenticated, networkless native process receives a writable held-descriptor sessions mount (`--bind-fd`). These effects are local, have unknown atomicity, and preserve child conversations. Native index maintenance may accompany the explicit mutation. Rename further requires at most 100 Unicode scalars and 464 UTF-8 bytes. Native delete of an already missing ID is idempotent. Borrowed management and authenticated local/remote deletion remain unqualified; archive/restore are unavailable.
package/dist/acp.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { createAcpHistory } from './providers/acp/create.js';
2
+ export type { AcpHistoryConnection, AcpHistoryListParams, AcpHistoryRequestOptions, AcpHistoryScope, CreateAcpHistoryOptions, } from './providers/acp/contracts.js';
3
+ //# sourceMappingURL=acp.d.ts.map
package/dist/acp.js ADDED
@@ -0,0 +1,4 @@
1
+ import { createAcpHistory } from "./providers/acp/create.js";
2
+ export {
3
+ createAcpHistory
4
+ };
@@ -0,0 +1,3 @@
1
+ export { createClaudeHistory } from './providers/claude/create.js';
2
+ export type { CreateClaudeHistoryOptions, ClaudeHistoryResourcePolicy, ClaudeHistoryScope } from './providers/claude/options.js';
3
+ //# sourceMappingURL=claude.d.ts.map
package/dist/claude.js ADDED
@@ -0,0 +1,4 @@
1
+ import { createClaudeHistory } from "./providers/claude/create.js";
2
+ export {
3
+ createClaudeHistory
4
+ };
@@ -0,0 +1,3 @@
1
+ export { createCodexHistory, createCodexHistoryProcess } from './providers/codex/create.js';
2
+ export type { CodexHistoryCatalogPolicy, CodexHistoryConnection, CodexHistoryOptions, CodexHistoryRequest, CodexHistoryRequestContext, CodexHistoryScope, CodexHistorySourceKind, CreateCodexHistoryOptions, CreateCodexHistoryProcessOptions, } from './providers/codex/contracts.js';
3
+ //# sourceMappingURL=codex.d.ts.map
package/dist/codex.js ADDED
@@ -0,0 +1,5 @@
1
+ import { createCodexHistory, createCodexHistoryProcess } from "./providers/codex/create.js";
2
+ export {
3
+ createCodexHistory,
4
+ createCodexHistoryProcess
5
+ };
@@ -0,0 +1,3 @@
1
+ export type * from './records.js';
2
+ export type * from './operations.js';
3
+ //# sourceMappingURL=index.d.ts.map
File without changes