@agentex/agent 0.0.23 → 0.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.
Files changed (177) hide show
  1. package/CHANGELOG.md +338 -0
  2. package/LICENSE +21 -0
  3. package/README.md +110 -0
  4. package/dist/derived.d.ts +5 -3
  5. package/dist/derived.d.ts.map +1 -1
  6. package/dist/derived.js +11 -7
  7. package/dist/derived.js.map +1 -1
  8. package/dist/index.d.ts +7 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +4 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/providers/acp/index.d.ts +1 -1
  13. package/dist/providers/acp/index.d.ts.map +1 -1
  14. package/dist/providers/acp/index.js +5 -97
  15. package/dist/providers/acp/index.js.map +1 -1
  16. package/dist/providers/acp/session.d.ts +8 -1
  17. package/dist/providers/acp/session.d.ts.map +1 -1
  18. package/dist/providers/acp/session.js +94 -0
  19. package/dist/providers/acp/session.js.map +1 -1
  20. package/dist/providers/claude/attach.d.ts +8 -0
  21. package/dist/providers/claude/attach.d.ts.map +1 -0
  22. package/dist/providers/claude/attach.js +113 -0
  23. package/dist/providers/claude/attach.js.map +1 -0
  24. package/dist/providers/claude/execute.d.ts.map +1 -1
  25. package/dist/providers/claude/execute.js +17 -2
  26. package/dist/providers/claude/execute.js.map +1 -1
  27. package/dist/providers/claude/goal-capability.d.ts +15 -0
  28. package/dist/providers/claude/goal-capability.d.ts.map +1 -0
  29. package/dist/providers/claude/goal-capability.js +20 -0
  30. package/dist/providers/claude/goal-capability.js.map +1 -0
  31. package/dist/providers/claude/index.d.ts.map +1 -1
  32. package/dist/providers/claude/index.js +8 -4
  33. package/dist/providers/claude/index.js.map +1 -1
  34. package/dist/providers/claude/session.d.ts +11 -9
  35. package/dist/providers/claude/session.d.ts.map +1 -1
  36. package/dist/providers/claude/session.js +36 -14
  37. package/dist/providers/claude/session.js.map +1 -1
  38. package/dist/providers/codex/attach.d.ts +9 -0
  39. package/dist/providers/codex/attach.d.ts.map +1 -0
  40. package/dist/providers/codex/attach.js +93 -0
  41. package/dist/providers/codex/attach.js.map +1 -0
  42. package/dist/providers/codex/execute.d.ts.map +1 -1
  43. package/dist/providers/codex/execute.js +17 -3
  44. package/dist/providers/codex/execute.js.map +1 -1
  45. package/dist/providers/codex/goal-capability.d.ts +13 -0
  46. package/dist/providers/codex/goal-capability.d.ts.map +1 -0
  47. package/dist/providers/codex/goal-capability.js +18 -0
  48. package/dist/providers/codex/goal-capability.js.map +1 -0
  49. package/dist/providers/codex/index.d.ts +1 -0
  50. package/dist/providers/codex/index.d.ts.map +1 -1
  51. package/dist/providers/codex/index.js +9 -6
  52. package/dist/providers/codex/index.js.map +1 -1
  53. package/dist/providers/codex/session.d.ts +11 -7
  54. package/dist/providers/codex/session.d.ts.map +1 -1
  55. package/dist/providers/codex/session.js +37 -12
  56. package/dist/providers/codex/session.js.map +1 -1
  57. package/dist/providers/codex/transcript-normalize.d.ts +28 -0
  58. package/dist/providers/codex/transcript-normalize.d.ts.map +1 -0
  59. package/dist/providers/codex/transcript-normalize.js +191 -0
  60. package/dist/providers/codex/transcript-normalize.js.map +1 -0
  61. package/dist/providers/cursor/index.d.ts.map +1 -1
  62. package/dist/providers/cursor/index.js +2 -2
  63. package/dist/providers/cursor/index.js.map +1 -1
  64. package/dist/providers/openclaw/index.d.ts.map +1 -1
  65. package/dist/providers/openclaw/index.js +2 -2
  66. package/dist/providers/openclaw/index.js.map +1 -1
  67. package/dist/providers/opencode/index.d.ts.map +1 -1
  68. package/dist/providers/opencode/index.js +3 -5
  69. package/dist/providers/opencode/index.js.map +1 -1
  70. package/dist/providers/pi/index.d.ts.map +1 -1
  71. package/dist/providers/pi/index.js +3 -5
  72. package/dist/providers/pi/index.js.map +1 -1
  73. package/dist/providers/process/index.d.ts.map +1 -1
  74. package/dist/providers/process/index.js +2 -2
  75. package/dist/providers/process/index.js.map +1 -1
  76. package/dist/registry.d.ts +0 -1
  77. package/dist/registry.d.ts.map +1 -1
  78. package/dist/registry.js +0 -4
  79. package/dist/registry.js.map +1 -1
  80. package/dist/sessions/index.d.ts +3 -0
  81. package/dist/sessions/index.d.ts.map +1 -0
  82. package/dist/sessions/index.js +2 -0
  83. package/dist/sessions/index.js.map +1 -0
  84. package/dist/sessions/record.d.ts +43 -0
  85. package/dist/sessions/record.d.ts.map +1 -0
  86. package/dist/sessions/record.js +85 -0
  87. package/dist/sessions/record.js.map +1 -0
  88. package/dist/types.d.ts +176 -0
  89. package/dist/types.d.ts.map +1 -1
  90. package/dist/types.js.map +1 -1
  91. package/dist/utils/endpoint.d.ts +38 -0
  92. package/dist/utils/endpoint.d.ts.map +1 -0
  93. package/dist/utils/endpoint.js +151 -0
  94. package/dist/utils/endpoint.js.map +1 -0
  95. package/dist/utils/env.d.ts.map +1 -1
  96. package/dist/utils/env.js +5 -1
  97. package/dist/utils/env.js.map +1 -1
  98. package/dist/utils/uuid.d.ts +7 -1
  99. package/dist/utils/uuid.d.ts.map +1 -1
  100. package/dist/utils/uuid.js +21 -1
  101. package/dist/utils/uuid.js.map +1 -1
  102. package/package.json +64 -7
  103. package/src/derived.ts +311 -0
  104. package/src/goals/controller.ts +442 -0
  105. package/src/goals/index.ts +21 -0
  106. package/src/goals/normalize.ts +173 -0
  107. package/src/goals/sentinel.ts +90 -0
  108. package/src/index.ts +270 -0
  109. package/src/providers/_shared/http-agent.ts +304 -0
  110. package/src/providers/acp/index.ts +103 -0
  111. package/src/providers/acp/parse.ts +131 -0
  112. package/src/providers/acp/session.ts +744 -0
  113. package/src/providers/claude/attach.ts +147 -0
  114. package/src/providers/claude/codec.ts +43 -0
  115. package/src/providers/claude/execute.ts +300 -0
  116. package/src/providers/claude/goal-capability.ts +21 -0
  117. package/src/providers/claude/index.ts +72 -0
  118. package/src/providers/claude/mcp.ts +82 -0
  119. package/src/providers/claude/parse.ts +824 -0
  120. package/src/providers/claude/session.ts +1192 -0
  121. package/src/providers/claude/transcript.ts +555 -0
  122. package/src/providers/codex/attach.ts +123 -0
  123. package/src/providers/codex/codec.ts +50 -0
  124. package/src/providers/codex/execute.ts +337 -0
  125. package/src/providers/codex/goal-capability.ts +19 -0
  126. package/src/providers/codex/index.ts +57 -0
  127. package/src/providers/codex/modes.ts +159 -0
  128. package/src/providers/codex/parse.ts +691 -0
  129. package/src/providers/codex/plan-mode.ts +49 -0
  130. package/src/providers/codex/session.ts +1287 -0
  131. package/src/providers/codex/transcript-normalize.ts +197 -0
  132. package/src/providers/codex/transcript.ts +487 -0
  133. package/src/providers/codex/usage-scanner.ts +178 -0
  134. package/src/providers/copilot/index.ts +19 -0
  135. package/src/providers/cursor/codec.ts +44 -0
  136. package/src/providers/cursor/execute.ts +271 -0
  137. package/src/providers/cursor/index.ts +25 -0
  138. package/src/providers/cursor/parse.ts +288 -0
  139. package/src/providers/gemini/index.ts +21 -0
  140. package/src/providers/openclaw/codec.ts +40 -0
  141. package/src/providers/openclaw/execute.ts +19 -0
  142. package/src/providers/openclaw/index.ts +29 -0
  143. package/src/providers/opencode/codec.ts +50 -0
  144. package/src/providers/opencode/event-parse.ts +141 -0
  145. package/src/providers/opencode/execute.ts +251 -0
  146. package/src/providers/opencode/http-session.ts +427 -0
  147. package/src/providers/opencode/index.ts +30 -0
  148. package/src/providers/opencode/parse.ts +203 -0
  149. package/src/providers/opencode/server.ts +0 -0
  150. package/src/providers/pi/codec.ts +44 -0
  151. package/src/providers/pi/execute.ts +297 -0
  152. package/src/providers/pi/index.ts +30 -0
  153. package/src/providers/pi/parse.ts +231 -0
  154. package/src/providers/pi/session.ts +381 -0
  155. package/src/providers/process/execute.ts +148 -0
  156. package/src/providers/process/index.ts +52 -0
  157. package/src/registry.ts +40 -0
  158. package/src/sessions/index.ts +8 -0
  159. package/src/sessions/record.ts +108 -0
  160. package/src/types.ts +1638 -0
  161. package/src/utils/ask-user-question.ts +57 -0
  162. package/src/utils/auth.ts +661 -0
  163. package/src/utils/binary.ts +179 -0
  164. package/src/utils/endpoint.ts +172 -0
  165. package/src/utils/env.ts +63 -0
  166. package/src/utils/execute-all.ts +68 -0
  167. package/src/utils/exit-plan-mode.ts +40 -0
  168. package/src/utils/instructions.ts +427 -0
  169. package/src/utils/process.ts +223 -0
  170. package/src/utils/runtime-config.ts +100 -0
  171. package/src/utils/runtime-homes.ts +49 -0
  172. package/src/utils/skill-commands.ts +493 -0
  173. package/src/utils/skills.ts +500 -0
  174. package/src/utils/template.ts +16 -0
  175. package/src/utils/tool-names.ts +51 -0
  176. package/src/utils/uuid.ts +21 -0
  177. package/src/utils/workspace.ts +156 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,338 @@
1
+ # Changelog
2
+
3
+ ## 0.0.26 — durable sessions: `describe` / `attachSession` / `catchUp`
4
+
5
+ Additive, **zero breaking changes**. Every addition is an optional interface
6
+ member or a new export; the existing `createSession`/resume flow is untouched
7
+ and remains the only spawn path. Upgrading requires no consumer changes.
8
+
9
+ The agents underneath agentex are disk-durable (Claude transcripts + `--resume`;
10
+ Codex SQLite threads + `thread/resume`), but the only session abstraction was a
11
+ live in-memory handle — every host had to assemble its own restart-recovery
12
+ layer from the raw parts (`sessionCodec`, `transcript` ops, `ctx.sessionParams`).
13
+ This release ships that composition as three optional additions.
14
+
15
+ ### Added
16
+
17
+ - **`SessionRecord`** — one blessed, JSON-serializable session identity a host
18
+ persists (`{version, providerType, params, cwd, displayId, updatedAt}`).
19
+ Produce it with `session.describe()` (new optional `AgentSession` member —
20
+ returns null until the provider assigns a session id) or `createSessionRecord(...)`.
21
+ Helpers `isSessionRecord` / `assertSessionRecord` (throws
22
+ `MalformedSessionRecordError` naming the offending field) validate one, and a
23
+ new `./sessions` subpath exports them all.
24
+ - **`provider.attachSession(record, opts?)`** — read-only reattachment (new
25
+ optional `ProviderModule` member; implemented for Claude + Codex). Locates the
26
+ on-disk transcript, classifies how the last turn ended
27
+ (`lastTurn: "completed" | "interrupted" | "unknown"`), and returns a
28
+ `SessionAttachment` with:
29
+ - **`catchUp(opts?)`** — replays normalized `StreamEvent`s from the transcript
30
+ with a byte `offset` per event to checkpoint and pass back as `fromOffset`.
31
+ Claude yields the stable wire `eventId`; Codex yields `null` (no wire id).
32
+ - **`resume(ctx?)`** — continue live. Exactly
33
+ `createSession({ ...ctx, sessionParams: record.params })` — one resume path,
34
+ **never auto-invoked** (a restart must not spontaneously re-run turns).
35
+ - **`codexLineToStreamEvents(line, ctx)`** — the library now normalizes Codex
36
+ on-disk rollout lines into `StreamEvent`s (the map/drop table Flow previously
37
+ hand-maintained in `codex-on-disk.ts`), so `catchUp` yields the same event
38
+ vocabulary for both providers. Exported from `@agentex/agent` and
39
+ `@agentex/agent/providers/codex`.
40
+ - **`capabilities.durableSessions`** — honest feature detection: `true` for
41
+ claude and codex (they implement `attachSession`), absent everywhere else.
42
+ - **`scripts/durable-session-demo.ts`** (`pnpm demo:durable`) — end-to-end
43
+ proof: start a session, crash the host mid-turn in a separate process,
44
+ reattach in a fresh one → `interrupted`, `catchUp` replays, `resume` continues.
45
+
46
+ ### Changed
47
+
48
+ - **`StreamEvent` union-growth policy documented.** The union grows in minor
49
+ versions (the `goal_status` precedent); consumers MUST keep a `default` branch
50
+ when switching on `type`. Stated in the `StreamEvent` JSDoc — not a code change.
51
+
52
+ ### Documented limitations (not future promises)
53
+
54
+ - **Pending user-input requests do not survive a restart** — the CLI process and
55
+ its stdio died. Attach reports `lastTurn: "interrupted"` so hosts can re-prompt.
56
+ - **Attach for other providers** (acp/gemini/copilot/cursor/opencode/pi/openclaw/
57
+ process) — no durable on-disk transcript contract today, so `durableSessions`
58
+ is simply absent for them.
59
+ - **Cross-machine records** — a record references local transcript state; moved
60
+ to another machine it yields `transcript: null, lastTurn: "unknown"` (attach
61
+ still works, `catchUp` yields nothing, `resume` may still succeed).
62
+
63
+ ## 0.0.25 — packaging perf: lazy providers + subpath exports
64
+
65
+ Non-breaking. **Zero API changes** — every exported signature, event shape, and
66
+ session semantic is identical to 0.0.24. This release makes importing the
67
+ package cheap: a consumer that only needs one util no longer pays for the whole
68
+ provider registry, and the registry no longer eagerly evaluates all nine
69
+ providers' heavy machinery.
70
+
71
+ The lever is that every `ProviderModule` method (`execute`, `createSession`,
72
+ `resolveAuth`, `listModels`, `listModes`, `checkQuota`) was already async, so the
73
+ laziness lives *inside* each provider's method bodies via dynamic `import()` —
74
+ invisible to callers. `getProvider` stays synchronous; only heavy modules
75
+ (`session.ts`, `execute.ts`, parsers, the ACP SDK) load on first use.
76
+
77
+ ### Added
78
+
79
+ - **Subpath exports.** Beyond `"."`, the package now exports `./registry`,
80
+ `./derived`, `./types`, `./goals`, `./utils/*` (wildcard), `./providers/*`
81
+ (wildcard → each light provider index), plus the three blessed deep modules
82
+ `./providers/claude/parse`, `./providers/claude/transcript`,
83
+ `./providers/codex/transcript`, and `./package.json`. This unlocks
84
+ browser-safe entry points — e.g. `@agentex/agent/providers/claude/parse` is
85
+ pure (type-only imports, no `node:*`), so consumers no longer need a
86
+ hand-written client-safe mirror. `_shared/` stays private by convention.
87
+ - **`"default"` export condition** on every entry (folds in the old TODO
88
+ "Package exports — CJS consumer ergonomics"): `require(esm)` now resolves on
89
+ Node ≥ 20.19, so a CJS/tsx consumer can `require("@agentex/agent")` without
90
+ the dynamic-`import()` dance. Conditions are ordered `"types"` → `"import"` →
91
+ `"default"` in every block.
92
+ - **`scripts/measure-import.ts`** — a tool (not a test) that prints import time
93
+ and dist-module count per entry point. Used to produce the table below.
94
+ - **`tests/packaging/`** — five checks that pin this design: `no-tdz`,
95
+ `lazy-graph` (a loader-hook module census proving no heavy module loads from
96
+ the barrel), `exports-map` (every subpath resolves at runtime + under TS
97
+ `bundler`/`node16`), `tree-shake` (esbuild proof), and `utils/uuid`.
98
+
99
+ ### Changed
100
+
101
+ - **`sideEffects: false`.** Truthful now that the only cross-module side effect
102
+ (the ACP factory registration) is gone (see Fixed). Bundlers can tree-shake
103
+ the package: a one-util import from the barrel bundles to **308 bytes** with
104
+ the entire provider registry shaken out.
105
+ - **`engines.node` → `>=20.19.0`** (was `>=18`). Support-matrix honesty for the
106
+ `"default"` / `require(esm)` condition — not a runtime break; the code already
107
+ targeted modern Node.
108
+ - **Dropped the `uuid` dependency.** `utils/uuid.ts` is now a local RFC 9562
109
+ UUIDv7 (48-bit ms timestamp + 74 random bits via `crypto.getRandomValues`),
110
+ removing 22 runtime modules and leaving `@agentclientprotocol/sdk` as the sole
111
+ runtime dependency. Callers need uniqueness + rough time-sortability, both
112
+ covered by `tests/utils/uuid.test.ts`.
113
+ - **Ship `src` in the package** (`files: ["dist", "src"]`) so the published
114
+ `*.js.map` / `*.d.ts.map` `sources` paths resolve — go-to-definition and
115
+ debugger stepping into the package now work (~0.5 MB larger tarball).
116
+ - **`registerAcpFactory` is no longer required before `loadProvidersFromConfig`.**
117
+ The loader defaults to the built-in `acpProvider`; `registerAcpFactory` stays
118
+ exported and honored as an override hook.
119
+
120
+ ### Fixed
121
+
122
+ - **TDZ crash on direct provider import.** `import("@agentex/agent/providers/gemini")`
123
+ (and `copilot`) threw `ReferenceError: Cannot access 'geminiProvider' before
124
+ initialization` via the cycle `gemini → acp → derived → registry → gemini`.
125
+ Masked previously because the barrel was the only entry point; a hard blocker
126
+ for subpath exports. The cycle is broken by making `derived.ts` import the ACP
127
+ provider directly and dropping the registry's bare ACP side-effect import. All
128
+ ten provider modules now import clean as an entry point.
129
+
130
+ ### Perf (measured via `scripts/measure-import.ts`, Node 24.2, warm FS cache)
131
+
132
+ | Metric | Before (0.0.24) | After (0.0.25) | Target |
133
+ | --- | --- | --- | --- |
134
+ | Runtime import, barrel (`.`) | ~80–100 ms | **~26 ms** (min of 5) | ≤ 40 ms |
135
+ | Runtime dist-module graph, barrel | ~90 modules | **46 modules** | — |
136
+ | Runtime import, `./utils/ask-user-question` | 7 ms (unreachable) | **~8 ms, 1 module, reachable** | ≤ 8 ms |
137
+ | esbuild inputs, one-util subpath import | 159 | **2** | ≤ 3 |
138
+ | esbuild one-util barrel import (tree-shaken output) | 881 KB | **308 bytes** | — |
139
+ | Bundler barrel import with code-splitting (initial chunk) | ~881 KB (one chunk) | **~22 KB** initial + lazy provider chunks | — |
140
+ | Direct import of each provider module | 2 crash | **0 crash** | 0 |
141
+ | Breaking API changes | — | **0** | 0 |
142
+
143
+ **Bundler note (per the design's risk analysis).** The runtime and subpath wins
144
+ are unconditional. For a bundler that ingests the *whole barrel*, the provider
145
+ bodies drop out of the initial load only when the bundler **code-splits**
146
+ dynamic `import()` (Next/webpack/turbopack do — see the ~22 KB initial chunk
147
+ above) or when the consumer marks the package external
148
+ (`serverExternalPackages` in Next). An esbuild bundle with splitting *disabled*
149
+ inlines dynamic imports, so its raw `metafile.inputs` count only drops by the
150
+ `uuid` modules (~141); split or external, the heavy bodies become lazy.
151
+
152
+ Additive. Point a provider at a custom, Anthropic/OpenAI-compatible endpoint (BYOK, self-hosted gateway, alternative model) per session, without registering a derived provider. One normalized `ProviderConfig.endpoint` is translated to each CLI's own dialect at spawn — Claude via env vars, Codex via a synthesized `[model_providers.custom]` block. Frozen for the process lifetime, so it is a per-`createSession`/per-`exec` property (resume re-applies it).
153
+
154
+ ### Added
155
+
156
+ - **`ProviderConfig.endpoint` (`ProviderEndpointConfig`).** `{ baseUrl?, authToken?, apiKey?, headers?, modelMap? }`. Claude maps to `ANTHROPIC_BASE_URL` + `ANTHROPIC_AUTH_TOKEN`/`ANTHROPIC_API_KEY` + `ANTHROPIC_CUSTOM_HEADERS`, with `modelMap` (tier alias → concrete id) → `ANTHROPIC_DEFAULT_{OPUS,SONNET,HAIKU,FABLE}_MODEL`. Codex synthesizes a `model_provider="custom"` block (`base_url`, `wire_api="responses"`, `env_key`); `modelMap` is ignored (no tier aliases — pass a concrete `model`). Providers without a custom-endpoint mechanism ignore it, like `allowedTools`.
157
+ - **`translateEndpoint(providerType, endpoint)` + `EndpointTranslation`,** exported, plus the `CODEX_CUSTOM_PROVIDER_ID` / `CODEX_CUSTOM_KEY_ENV` / `CODEX_CUSTOM_HEADER_ENV_PREFIX` constants for hosts that need the synthesized names.
158
+
159
+ ### Security
160
+
161
+ - **No ambient-credential leak to a third party.** When a custom `baseUrl` is set, only the auth declared in `endpoint` reaches it — ambient `ANTHROPIC_API_KEY`/`ANTHROPIC_AUTH_TOKEN` seeded from the host env are cleared, and so is alternate-routing config (`ANTHROPIC_BEDROCK_BASE_URL`, `CLAUDE_CODE_USE_BEDROCK`/`VERTEX`/`FOUNDRY`) so ambient Bedrock/Vertex can't steer Claude off the endpoint or rewrite the model id. General AWS creds are left intact for tool use.
162
+ - **Codex header values never hit argv.** `headers` route through Codex `env_http_headers` (header name in argv, value in env), so a secret header (`Authorization`, `X-API-Key`) doesn't leak via `ps` — mirroring how the Claude provider stages MCP headers off the command line.
163
+ - **`redactEnvForLogs` masks header carriers.** Added `HEADER` to the sensitive pattern so `ANTHROPIC_CUSTOM_HEADERS` and the generated `CODEX_CUSTOM_HEADER_*` vars are redacted in logs, not just the credential vars.
164
+
165
+ ### Notes for consumers
166
+
167
+ - **Codex speaks the OpenAI Responses API only.** The Chat Completions (`wire_api="chat"`) protocol was removed from Codex in Feb 2026, so a Codex custom endpoint must implement the Responses API, directly or via a translating gateway (e.g. LiteLLM). A pre-Feb-2026 Codex needing `chat` can override on the `exec` path with `extraArgs: ["-c", 'model_providers.custom.wire_api="chat"']`.
168
+ - **`endpoint` is per-spawn.** It's read once at `createSession`/`exec`; there is no per-turn override. Change it by starting a fresh session (resume re-applies it).
169
+ - Prefer a derived provider when the same endpoint is reused across many calls; prefer `config.endpoint` when it varies per session and the host owns storage.
170
+
171
+ ## 0.0.23 — Goals: cross-provider session objectives
172
+
173
+ A session-scoped **goal** primitive. Attach a durable objective and the library tracks it to a terminal state, normalizing Claude Code's Stop-hook sentinel and Codex's thread-goal state behind one event, one capability, and three session methods — with an emulation engine so it works on every provider. Verified end-to-end by driving the real CLIs (claude 2.1.191, codex 0.130.0) through the adapter.
174
+
175
+ ### Added
176
+
177
+ - **`AgentSession.setGoal(objective, options?)` / `clearGoal(options?)` / `getGoal()`.** Arm a session goal; the library uses native enforcement where the provider has it (Claude's `/goal` Stop-hook + Haiku sentinel; Codex's `thread/goal/*` thread state) and an **emulation loop** (pluggable sentinel + continuation turns + iteration cap) everywhere else. `setGoal` resolves on *arm*, not completion — watch `goal_status` events for that. `objective` is capped at 4,000 chars; `options.enforce` (`provider`/`emulate`/`advisory`) and `options.sentinel` let a host force the engine or supply a deterministic check (e.g. run tests).
178
+ - **`goal_status` StreamEvent.** One normalized transition per real change — `status` (`active|paused|met|blocked|cleared`), `met`, `enforced`, `source`, `blockedReason?`, and Codex telemetry (`tokensUsed`/`timeUsedSeconds`/`tokenBudget`). `raw` keeps the provider-native record. One emitter per mode (parser when native, controller when emulated), so no intra-stream double-emit.
179
+ - **`ProviderCapabilities.goals` descriptor** — `mechanism` (`sentinel`/`model-tools`/`emulated`), `enforced`, `statuses`, `clears`, `telemetry`. claude = sentinel, codex = model-tools, pi/opencode = emulated.
180
+ - **`GoalController` + reconstruction helpers**, exported for hosts: `goalStateFromEvent`, `latestGoalFromEvents`, `normalizeClaudeGoalAttachment`, `normalizeCodexGoalStatus`, `normalizeCodexGoalRecord`, `createDefaultSentinel`, `parseAssessment`, `isTerminalGoalStatus`, `EMULATED_GOAL_CAPABILITY`, `GOAL_OBJECTIVE_MAX`, `CODEX_GOAL_TOOLS`, plus the `GoalState` / `GoalStatus` / `GoalOptions` / `GoalSentinel` / `SetGoalResult` / `ClearGoalResult` types.
181
+ - **Native observability + resume.** Claude writes `goal_status` only to the on-disk transcript (never live stdout), so a native goal session tails its transcript to surface `active`→`met` and restores an unmet goal on `--resume`. Codex rehydrates a durable goal on resume via `thread/goal/get`. Both confirmed live.
182
+
183
+ ### Fixed
184
+
185
+ - **Codex failed turns are no longer reported as success.** codex 0.130 signals failure via `turn/completed` with `turn.status: "failed"` (carrying `turn.error.message`), not only `turn/failed` — agentex hardcoded `isError:false`, so a failed turn (e.g. a 4xx from the model API) looked `completed`. The parser + session now detect the failed status and the trailing `error` notification, reporting `status:"failed"` with the error text. Verified live.
186
+ - **Codex app-server turns no longer return a null summary.** v2 assistant items are `agentMessage` (camelCase) but the session only matched legacy `agent_message`, so every app-server turn left `TurnResult.summary` null. Both spellings are accepted now.
187
+
188
+ ### Notes for consumers
189
+
190
+ - **`AgentSession` gained three required methods** (`setGoal`/`clearGoal`/`getGoal`). Additive for *callers*; only an external *implementer* of `AgentSession` would need to add them — the built-in providers already do.
191
+ - **Every Codex session now declares `capabilities.experimentalApi: true`** in its `initialize` handshake. This is required to reach the `thread/goal/*` methods (the app-server rejects them with `-32600 requires experimentalApi capability` otherwise) and is the same capability the official VS Code client declares. It gates access to experimental RPC methods, **not** turn semantics — verified against codex 0.130.0 that a normal turn still streams assistant + result unchanged.
192
+ - **Native Codex goals are experimental + opt-in.** They function only when `[features] goals = true` is persisted in `~/.codex/config.toml` (the `thread_goals` SQLite table is migrated at startup); otherwise the arm falls back to emulation. The `thread/goal/*` RPCs are timeout-bounded so an older app-server that ignores them can't hang `setGoal`/`clearGoal`/resume.
193
+ - A consumer with an exhaustive `switch` over `StreamEvent.type` will get a TypeScript nudge to handle `goal_status`.
194
+
195
+ ## 0.0.21 — cross-runtime instruction files (`installInstructions`)
196
+
197
+ Additive. The instruction-file twin of `installSkills`: install an orientation brief into the right per-runtime file(s), with a managed-region merge that preserves user edits.
198
+
199
+ ### Added
200
+
201
+ - **`installInstructions(content, opts?)`.** Writes a brief into per-runtime instruction files. Every runtime except Claude reads `AGENTS.md`; Claude reads `CLAUDE.md`. Two locations mirror `installSkills`:
202
+ - `workspace` ({cwd}/) — deduped by filename, so the default writes `CLAUDE.md` + `AGENTS.md` once each. `includeNativeFiles: true` also writes Gemini's native `GEMINI.md` (Gemini reads `AGENTS.md` only when configured).
203
+ - `global` — per-runtime home files (`~/.claude/CLAUDE.md`, `~/.codex/AGENTS.md`, `~/.gemini/GEMINI.md`, `~/.config/opencode/AGENTS.md`, `~/.pi/AGENTS.md`). Cursor is omitted — its global config is app User Rules, not a file. There is no universal `~/AGENTS.md`, so global is inherently per-runtime.
204
+ - **Managed-region merge.** `content` is wrapped in `<!-- agentex:managed:start hash=… -->` / `…:end` markers; re-install replaces only that region and preserves everything the user wrote outside it. The embedded content hash makes re-installs byte-idempotent (reported `skipped`). `managed: false` overwrites the whole file (escape hatch for fully-owned files). Files are written mode 0644.
205
+ - **`removeInstructions(opts?)`.** Strips the managed region (deletes the file if nothing else remains); never touches user-owned files that have no managed region.
206
+ - **`resolveInstructionTargets(opts?)`.** Lists which files *would* be written, without touching disk.
207
+ - **`upsertManagedBlock` / `stripManagedBlock`.** The low-level merge/strip primitives, exported for hosts with custom layouts.
208
+ - **`getDefaultRuntimeHome(runtime, homeDir?)`** now accepts a base-directory override (defaults to `os.homedir()`) for sandboxed and `global` installs.
209
+
210
+ ## 0.0.20 — MCP attachment fix, session controls, typewriter deltas, Codex event identity
211
+
212
+ Driven by consumer feedback from an embedding host wiring an orchestrator onto agentex sessions. All additive — except the MCP fix, which replaces behavior that never worked in any published version.
213
+
214
+ ### Fixed
215
+
216
+ - **`config.mcpServers` actually attaches MCP servers now.** It previously emitted `--mcp-server <name> -- <command>…` — a flag that does not exist in Claude Code 2.x — so any run/session setting the field died instantly with `error: unknown option '--mcp-server'` (verified against claude 2.1.165; the field has never worked in any published version, so there is no behavior to migrate from). The config is now staged as a **mode-0600 JSON file** in a temp dir and passed via the real `--mcp-config <path>`, cleaned up with the run/session (including spawn-failure paths). Secrets never touch argv — http `headers` (bearer tokens) live only in the 0600 file; argv is world-readable via `ps`.
217
+
218
+ ### Added
219
+
220
+ - **`McpServerConfig` http/sse transports.** Now a discriminated union: the stdio shape (`{name, command, args?, env?}`) is unchanged (type defaults to `"stdio"`), plus `{name, type: "http"|"sse", url, headers?}` for hosts embedding a local MCP server.
221
+ - **`ProviderConfig.strictMcpConfig`** → `--strict-mcp-config`: the session's MCP surface is *exactly* what you attach — a stray `.mcp.json` in cwd or user-scope servers can't leak into a product-controlled session. Works with or without `mcpServers` (strict + none = no MCP at all).
222
+ - **`ProviderConfig.allowedTools` / `disallowedTools`** → `--allowed-tools` / `--disallowed-tools` (comma-joined; patterns like `Bash(rm *)` and `mcp__server__*` pass through verbatim; deny wins). Silently ignored by codex — documented on the fields (its mechanism is permission profiles, not argv).
223
+ - **`assistant_delta` + `thinking_delta` stream events (typewriter).** Opt-in via `config.includePartialMessages` (claude `--include-partial-messages`). Purely additive: the consolidated `assistant` event still fires when the block completes; `messageId` on deltas matches it so hosts can reconcile optimistic delta text against the durable event; the wrapper's per-line `uuid` becomes `eventId`. Flag off ⇒ parsing is bit-identical to 0.0.19. `thinking_delta` is best-effort — on current Claude versions it is the **only** place thinking prose appears (the consolidated thinking block is withheld, signature-only). Validated live against claude 2.1.165.
224
+ - **Stable Codex event identity.** Transcript reads stamp a replay-stable synthetic `eventId` — `codex:<rolloutSessionId>:<lineStartByteOffset>` — giving hosts an idempotency key for transcript replays. Live v2 session events get `codex:<threadId>:<turnId>:<itemId>:<eventType>` where the components exist (an **upsert** key: repeated updates to one item intentionally share an id). The live and on-disk schemes deliberately differ (different wire vocabularies — `command_execution` vs `exec_command`); cross-shape dedup remains a host concern.
225
+
226
+ ### Notes for consumers
227
+
228
+ - `extraArgs` remain appended **after** all generated flags (the host-override invariant), so existing `--mcp-config` / `--disallowed-tools` workarounds keep working — and can now be deleted in favor of the typed fields.
229
+
230
+ ## 0.0.19 — Three-tier provider architecture: ACP tier, config-extend, Codex parity, live sessions
231
+
232
+ > **Note for npm consumers:** 0.0.18 was never published — its changes ship in this release alongside 0.0.19's. The loudest of them: `ProviderConfig.timeoutSec` now also arms a **per-send deadline on sessions** (previously it applied only to `execute()`). Hosts that set `timeoutSec` for exec-style runs will see session turns interrupted at that deadline too — see the 0.0.18 section below.
233
+
234
+ A three-tier provider architecture (deep-native · ACP · bespoke). The ACP tier and gemini's migration are validated end-to-end against real agents. See [`internal-docs/spec-provider-architecture.md`](../../internal-docs/spec-provider-architecture.md). Nothing here breaks the existing public surface.
235
+
236
+ ### Added
237
+
238
+ - **Reusable `httpAgent` base for remote gateway agents.** Extracted OpenClaw's HTTP pattern into `runHttpAgent` / `httpAgentProvider({ providerType, defaultBaseUrl, runPath, … })`: gateway-URL resolution (per-call command → saved `sessionParams` → default), session-key round-trip, 401/403 → `auth_required` event, AbortController timeout, and customizable `buildBody`/`extractSummary`/`extractSessionKey` hooks. OpenClaw is refactored onto it with zero behavior change. The shape any "agent behind a URL" reuses.
239
+ - **Pi persistent sessions.** `pi` gains `createSession` backed by a long-lived `pi --mode rpc` process: each turn writes a JSONL `prompt` command and streams events (assistant deltas, tool start/end) → `StreamEvent`s, resolving the `TurnResult` on `agent_end`. Strict `\n` framing per Pi's RPC contract, ordered event dispatch, per-send timeout/abort (sends an `abort` command), and file-based resume via `sessionParams`. One-shot `execute()` is unchanged.
240
+ - **OpenCode live sessions (HTTP + SSE).** `opencode` gains `createSession` backed by the `opencode serve` daemon: a ref-counted server pool, session create/resume over HTTP, live token/tool streaming off the SSE `/global/event` feed mapped into `StreamEvent`s, and an authoritative `TurnResult` (summary, cost, token usage) from the `POST /message` response. One-shot `execute()` is unchanged. Validated end-to-end against the real `opencode` binary.
241
+ - **Gemini is now ACP-backed; Copilot added.** `gemini` moved from its one-shot `--output-format stream-json` stub to `gemini --acp` over the ACP base — it gains real sessions, streaming, tool-call correlation, permission bridging, and mode discovery (validated end-to-end against the real Gemini agent). `copilot` (`copilot --acp`) is a new provider — a handful of lines, because the ACP tier does the work. The bespoke gemini parser/codec/execute and their fixtures are deleted (net code reduction). **Cursor stays on its current transport for now** — the shipping `cursor-agent` exposes no ACP mode; it can move to ACP via `extends: "acp"` once it does.
242
+ - **ACP provider tier (Agent Client Protocol).** `acpProvider({ id, command, env, models, modeId, transformers })` builds a provider over the open [ACP](https://agentclientprotocol.com) standard (JSON-RPC over stdio) using `@agentclientprotocol/sdk` — one tested base for the long tail of agents (Gemini, Cursor, Copilot, and any ACP-compatible agent). It spawns the agent, runs the `initialize`/`newSession` handshake, streams `session/update` notifications into agentex `StreamEvent`s (assistant / thinking / tool_call / tool_result, with real tool-call correlation), bridges ACP `requestPermission` to `onUserInputRequest`, discovers modes via `listModes()`, and supports per-agent `transformers` (modes / modeId) to absorb quirks without forking. The SDK is dynamic-imported, so it's only loaded when an ACP session actually runs. Config-extend `extends: "acp"` builds these from a config file.
243
+ - **Config-extend / derived providers.** `defineDerivedProvider({ id, extends, env, command, models, modeId })` builds a new provider id that inherits a built-in's behavior with an env/command/model overlay — the canonical use is BYOK gateways (point `extends: "claude"` at `env.ANTHROPIC_BASE_URL` for z.ai / Qwen / a local proxy, no new code). `loadProvidersFromConfig(json)` registers a whole `{ providers: { … } }` map (also accepts Paseo's `agents.providers` nesting and `extends: "acp"`), validated with typed `MalformedProviderConfigError`s. `pnpm smoke --config <path>` loads and exercises them.
244
+ - **Operating-modes contract.** New `AgentMode` type and optional `ProviderModule.listModes(options?)`, plus `ProviderConfig.modeId` for selecting a mode and a `capabilities.modes` flag (with optional `capabilities.dynamicCapabilities` for runtime-negotiated providers). Additive — providers that don't support modes omit `listModes` and set `modes: false`.
245
+ - **Codex session resume.** `createSession` now honors `ctx.sessionParams` (a prior `sessionId` / `thread_id`) by issuing `thread/resume` to continue the *same* Codex thread with full context — previously every session cold-started a fresh `thread/start` and the saved session id was ignored. On an unknown thread it falls back to a fresh thread with a stderr notice rather than failing the session.
246
+ - **Codex collaboration modes.** `codexProvider.listModes()` discovers Codex's collaboration modes via `collaborationMode/list`; `config.modeId` applies a chosen mode to a fresh `thread/start` (a resumed thread keeps its original mode). `capabilities.modes` is now `true` for Codex.
247
+ - **Codex structured questions.** The app-server `requestUserInput` (and legacy `tool/requestUserInput`) server→client request is now bridged to `onUserInputRequest` as an `AskUserQuestion`, with answers mapped back into Codex's `{ answers: { [id]: { answers: [] } } }` shape — Codex sessions can answer questions headlessly.
248
+
249
+ ### Fixed
250
+
251
+ - **Codex tool-approval response shape.** Command/file approval requests are now answered with `{ decision: "accept" | "decline" }` (Codex's actual app-server contract) instead of `{ approved: boolean }`, which the app-server did not honor. Tool-permission gating in Codex sessions now works headlessly.
252
+
253
+ #### Hardening (from two independent adversarial reviews of the above)
254
+
255
+ - **ACP session resume.** The ACP provider returned `sessionParams` but never honored them — every turn started fresh while callers thought they were preserving context. `createSession` now reads `ctx.sessionParams` and resumes via ACP `session/load` when the agent advertises `loadSession`, falling back to a fresh session (with a stderr notice) otherwise.
256
+ - **Bounded ACP handshake.** `connect()` and `listAcpModes()` now time out (30s) around `initialize`/`newSession`/`loadSession`, so a hung agent binary can't hang session creation or mode discovery forever.
257
+ - **OpenCode daemon pooling key.** The server pool keyed only on binary + cwd; sessions with different auth/config (env or flags) could silently share one daemon. The key now includes a hash of the env + prefix args. Spawn failures (ENOENT) are also handled.
258
+ - **Config-extend command arrays.** A non-ACP derived provider given a multi-element `command` array silently dropped everything past the binary; it's now rejected with a clear `MalformedProviderConfigError` (use `extends: "acp"` for binary+args).
259
+
260
+ - **Turn isolation across all session providers (ACP, OpenCode, Pi).** A turn that timed out or was aborted while the agent kept emitting could let those late events bleed into the *next* turn's summary/event stream. Each provider now drains the interrupted turn (awaits the agent's cancel ack, bounded) and drops between-turn stragglers, so a timed-out turn can't contaminate the next. Regression-tested end-to-end.
261
+ - **Resource leaks on failed connect.** The OpenCode session leaked its pooled `opencode serve` process if session creation failed after acquiring the server; the ACP session leaked its child on a handshake failure; `listAcpModes` leaked its probe process if `initialize`/`newSession` threw. All now release/kill on every failure path.
262
+ - **ACP spawn-error crash.** A failed ACP agent spawn (ENOENT) emitted an unhandled `'error'` event that could crash the host. Now handled.
263
+ - **OpenCode error tool-results.** Error tool results read `state.output` (always absent on error) instead of `state.error`, losing the failure message. Fixed against the verified OpenAPI shape.
264
+ - **Codex session-state correctness.** A slow approval/question handler could clobber a finished turn's state back to `thinking`; questions now use `waiting_for_input` (vs `waiting_for_approval`), header-only questions are no longer dropped, and the modes-discovery RPC is bounded so it can't hang the handshake.
265
+ - **HTTP-agent abort vs timeout.** A caller-signal abort was misreported as a `timeout`; it now returns `aborted`. A transient network error no longer discards the caller's `sessionParams` (so resume survives a recoverable failure).
266
+ - **`tool_result.toolName` for ACP** is backfilled from the originating `tool_call` (agents often omit `title` on the terminal update).
267
+
268
+ ### Notes for consumers
269
+
270
+ - **`ProviderCapabilities` gains a required `modes: boolean` field.** Consumers only read capabilities, so this is additive in practice; only code that *constructs* a `ProviderCapabilities` literal (e.g. a custom provider via `registerProvider`) must add `modes`.
271
+
272
+ ## 0.0.18 — Per-send timeout, tool_result.toolName, drain()
273
+
274
+ Scheduled / fire-and-forget session runs needed three things the SDK pushed onto every consumer. They now live in the library.
275
+
276
+ ### Added
277
+
278
+ - **Per-send timeout & abort via `SendOptions`.** `session.send(message, { timeoutSec, signal })`. On `timeoutSec` expiry the library interrupts the active turn and resolves that send's `result` with `status: "timeout"` — no more consumer-side `Promise.race` + `interrupt()`. A per-send `AbortSignal` ends just that turn (resolves `"aborted"`), distinct from `SessionContext.signal` which closes the whole session. `ProviderConfig.timeoutSec` now also acts as the session-level default timeout for `send()` (previously it was read only by `execute()`). Honored by the Claude and Codex session providers.
279
+
280
+ - **`tool_result.toolName: string | null`** on stream events — mirrors the matching `tool_call.name`, correlated by the library so consumers no longer keep their own `toolCallId → name` cache. Populated on both the session and `execute()` paths for Claude and Codex; set directly by the Codex parser, correlated via a bounded tracker for Claude. Null when no preceding `tool_call` was observed, or on providers not yet enriched (cursor/gemini stubs).
281
+
282
+ - **`AgentSession.drain(): Promise<void>`** — graceful stop: refuse new `send()` calls, await the in-flight turn's `result`, then `close()`. The right tool for budget gates, `SIGTERM` handlers, and schedule pauses, where `interrupt()` (loses work) and `close()` (kills mid-tool) are both wrong. Idempotent.
283
+
284
+ - **`SendHandle`, `SendOptions`, `CancelResult`** are now exported from the package entry point (previously only the `AgentSession` interface was).
285
+
286
+ ### Fixed
287
+
288
+ - **Session `close()` now honors `ProviderConfig.graceSec`** for the SIGTERM → SIGKILL window (was hardcoded to 5s, ignoring the config field that `execute()` already respected). `drain()` uses the same configurable grace.
289
+
290
+ ### Notes for consumers narrowing on the literal types
291
+
292
+ - `TurnResult.status` gains `"timeout"`. Exhaustive `switch`/narrowing over the old literal set will get a typecheck nudge to handle the new case — the intended outcome.
293
+ - `tool_result` events gain a required `toolName`. Consumers only ever *read* events, so this is additive in practice; only code that *constructs* `tool_result` literals needs the field.
294
+ - `AgentSession` gains `drain()`. Additive for consumers; only matters if you implement the interface yourself.
295
+
296
+ ## 0.0.17 — Concurrent send + queue cancellation + Codex 0.130.0 compat
297
+
298
+ ### Codex CLI compatibility
299
+
300
+ This release **requires `codex-cli` 0.130.0 or newer**. The interactive JSON-RPC mode moved from a top-level `--json` flag to the `app-server` subcommand, the `thread/start` response now nests the thread under `params.thread`, `turn/start` now takes `input` as a content-block array (`[{type:"text", text:"…"}]`) instead of a plain string, and responses omit the `jsonrpc:"2.0"` discriminator. All four shifts are reflected in `providers/codex/session.ts`; the one-shot `execute()` path (which uses `codex exec --json`) is unaffected.
301
+
302
+ ### Breaking
303
+
304
+ - **`AgentSession.send()` return type changed** from `Promise<TurnResult>` to `Promise<SendHandle>`. `SendHandle` is `{ uuid: string; result: Promise<TurnResult> }`. Migrate by destructuring:
305
+
306
+ ```ts
307
+ // Before
308
+ const result = await session.send("hello");
309
+
310
+ // After
311
+ const { result: resultP } = await session.send("hello");
312
+ const result = await resultP;
313
+ // Or, if you don't need the UUID:
314
+ const { result } = await session.send("hello");
315
+ const turnResult = await result;
316
+ ```
317
+
318
+ - When multiple `send()` calls are coalesced into one turn by the CLI, the `result` Promises returned by each `send()` resolve with the **same** `TurnResult` object. Callers cannot assume 1:1 correspondence between `send()` calls and `TurnResult`s.
319
+
320
+ ### Added
321
+
322
+ - **`AgentSession.cancel(uuid): Promise<{cancelled: boolean}>`** — cancel a queued user message before it starts processing. Wired to Claude's `cancel_async_message` control_request; no-op (returns `{cancelled: false}`) on providers without per-message cancel support.
323
+
324
+ - **`provider.capabilities.concurrentSend: boolean`** — descriptive flag: true when the underlying CLI accepts user messages mid-turn (Claude, Codex). Apps may use this to gate "type while working" UI.
325
+
326
+ - **`provider.capabilities.cancelQueuedMessage: boolean`** — descriptive flag: true when `cancel(uuid)` is meaningful on this provider (Claude only).
327
+
328
+ ### Changed
329
+
330
+ - The internal `_state !== "idle"` guard in `ClaudeSessionImpl.send()` and `CodexSessionImpl.send()` is removed. Both providers' CLIs handle concurrent `send()` natively (Claude via its `messageQueueManager` queue + mid-turn drain; Codex via JSON-RPC message queueing). Apps wanting strict serialization can layer their own queue on top.
331
+
332
+ - `SessionState.state` is now strictly descriptive of the most recent observed lifecycle event. It does **not** gate `send()` callability for `concurrentSend` providers.
333
+
334
+ ### Internal
335
+
336
+ - `ClaudeSessionImpl` and `CodexSessionImpl` now maintain a list of pending result-resolvers instead of a single `_turnResolve` / `_turnReject` pair. On each `result` / `turn.completed` event, every pending resolver is drained with the same TurnResult.
337
+
338
+ - New `_pendingControlResponses` map in `ClaudeSessionImpl` correlates outgoing `control_request` writes (currently just `cancel_async_message`) with incoming `control_response` events by `request_id`. `interrupt()` remains fire-and-forget.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dynamism LLC
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
@@ -100,6 +100,64 @@ loadProvidersFromConfig({
100
100
  });
101
101
  ```
102
102
 
103
+ **Per-call endpoint (`config.endpoint`).** When the endpoint is chosen per
104
+ session rather than registered up front — e.g. an app that lets each user bring
105
+ their own model — set `endpoint` on `ProviderConfig`. The library keeps no state
106
+ and stores no config file; you pass the endpoint on the call and it is
107
+ translated into whatever the provider's CLI understands, at spawn:
108
+
109
+ ```ts
110
+ const session = await getProvider("claude").createSession({
111
+ cwd,
112
+ config: {
113
+ model: "sonnet", // tier alias still works — see modelMap
114
+ endpoint: {
115
+ baseUrl: "https://api.z.ai/api/anthropic",
116
+ authToken: "…", // → Authorization: Bearer (or `apiKey` → x-api-key)
117
+ modelMap: { sonnet: "glm-5.1" }, // alias → concrete id on the endpoint
118
+ },
119
+ },
120
+ });
121
+ ```
122
+
123
+ Translation is per provider (there is no shared wire format):
124
+
125
+ | Provider | `baseUrl` / auth | `modelMap` |
126
+ | --- | --- | --- |
127
+ | `claude` | `ANTHROPIC_BASE_URL` + `ANTHROPIC_AUTH_TOKEN`/`ANTHROPIC_API_KEY` (`headers` → `ANTHROPIC_CUSTOM_HEADERS`) | → `ANTHROPIC_DEFAULT_{OPUS,SONNET,HAIKU,FABLE}_MODEL` |
128
+ | `codex` | synthesized `[model_providers.custom]` block (`base_url`, `wire_api="responses"`, `env_key`) via `-c` overrides; key injected into env. Requires `baseUrl`. | ignored — Codex has no tier aliases; pass a concrete `model` |
129
+ | others | ignored (like `allowedTools` on unsupported providers) | — |
130
+
131
+ `endpoint` is applied once at spawn, so it is per-session / per-`exec`: change it
132
+ by starting a fresh `createSession`/`exec` (resume re-applies it), never
133
+ mid-session. Set exactly one of `authToken` / `apiKey`.
134
+
135
+ **Credential hygiene (claude).** When a custom `baseUrl` is set, only the auth in
136
+ `endpoint` reaches it — ambient `ANTHROPIC_API_KEY`/`ANTHROPIC_AUTH_TOKEN` from the
137
+ host env is not forwarded to the third party, and ambient alternate-routing config
138
+ (Bedrock/Vertex/Foundry) is cleared so it can't steer Claude off the endpoint.
139
+ Pass auth explicitly. One consequence: an observability-proxy pattern (Helicone /
140
+ LangSmith-style, where the proxy forwards using your *own* Anthropic key) no longer
141
+ picks up the ambient key — pass it deliberately, e.g.
142
+ `endpoint: { baseUrl, apiKey: process.env.ANTHROPIC_API_KEY }`.
143
+
144
+ **Codex header safety.** Codex header values are passed to the child via env
145
+ (`env_http_headers`), never argv, so a secret header (`Authorization`, `X-API-Key`)
146
+ doesn't leak through `ps`. Header *names* must be TOML bare keys.
147
+
148
+ **Codex speaks the Responses API.** Codex removed the Chat Completions
149
+ (`wire_api="chat"`) protocol in Feb 2026, so a custom endpoint must implement the
150
+ OpenAI Responses API, directly or via a translating gateway (e.g. LiteLLM). Pure
151
+ chat-completions endpoints won't work through Codex. If you're pinned to a
152
+ pre-Feb-2026 Codex that still needs `chat`, override it on the one-shot `exec`
153
+ path with `extraArgs: ["-c", 'model_providers.custom.wire_api="chat"']`.
154
+
155
+ Prefer derived providers when the same endpoint is reused across many calls (and
156
+ for heavy Codex config customization); prefer `config.endpoint` when it varies
157
+ per session and the host owns storage. To override the synthesized Codex config,
158
+ `extraArgs` is reliable on the one-shot `exec` path (it follows the endpoint
159
+ `-c` flags); for sessions, a derived provider is the robust path.
160
+
103
161
  **ACP agents.** Any agent speaking the [Agent Client Protocol](https://agentclientprotocol.com)
104
162
  is a few lines:
105
163
 
@@ -453,6 +511,58 @@ process.on("SIGTERM", async () => {
453
511
 
454
512
  `drain()` is idempotent. Bump `ProviderConfig.graceSec` for sessions running legitimately long tools (test suites, long Bash) so `close()`/`drain()` don't hard-kill them prematurely.
455
513
 
514
+ ### Reattach after a restart (durable sessions)
515
+
516
+ Claude and Codex sessions are disk-durable and resumable. Persist one blessed identity object — a `SessionRecord` from `session.describe()` — and after your host restarts, `provider.attachSession(record)` gets you back to it: it locates the on-disk transcript, tells you how the last turn ended, replays the events with checkpointable offsets, and (only when you ask) resumes the session live. Attach is **read-only** — it spawns nothing, and `resume()` is never called automatically. Check `provider.capabilities.durableSessions` first (`true` for `claude`/`codex`).
517
+
518
+ ```typescript
519
+ import { getProvider } from "@agentex/agent";
520
+ import type { SessionRecord } from "@agentex/agent";
521
+
522
+ // --- While the session runs: persist its identity once the id is known ---
523
+ const provider = getProvider("claude");
524
+ const session = await provider.createSession({ cwd, onEvent });
525
+ await session.send("start the task");
526
+ const record = session.describe(); // null until the session id arrives
527
+ if (record) await store.save(record); // your DB / JSON file — it's plain JSON
528
+
529
+ // ... host process restarts ...
530
+
531
+ // --- After restart: reattach from the stored record ---
532
+ const saved: SessionRecord = await store.load();
533
+ const attachment = await provider.attachSession(saved);
534
+
535
+ console.log(attachment.lastTurn); // "completed" | "interrupted" | "unknown"
536
+
537
+ // Replay what happened while you were gone, checkpointing the offset so the
538
+ // next catch-up resumes where this one stopped. The offset is LINE-granular: a
539
+ // single Claude line (assistant text + a `tool_use`) yields several events that
540
+ // share one offset, so checkpoint only at line boundaries — after a line is
541
+ // fully drained — else a crash mid-line would skip that line's remaining events
542
+ // on resume. (Codex currently emits one event per line, so today this only bites Claude.)
543
+ let checkpoint = store.lastOffset ?? 0;
544
+ let lineEnd: number | undefined; // offset of the line currently being drained
545
+ for await (const { event, offset } of attachment.catchUp({ fromOffset: checkpoint })) {
546
+ if (lineEnd !== undefined && offset !== lineEnd) {
547
+ checkpoint = lineEnd; // a new line started → prior line fully ingested
548
+ await store.saveOffset(checkpoint);
549
+ }
550
+ await ingest(event); // same normalized StreamEvent as live onEvent
551
+ lineEnd = offset;
552
+ }
553
+ if (lineEnd !== undefined) await store.saveOffset(lineEnd); // final line drained
554
+
555
+ // Continue live only when you decide to — this is exactly createSession + the
556
+ // record's params (one resume path). Pending user-input from before the crash
557
+ // is gone, so re-prompt when lastTurn === "interrupted".
558
+ if (attachment.lastTurn === "interrupted") {
559
+ const live = await attachment.resume({ cwd, onEvent });
560
+ await live.send("continue where we left off");
561
+ }
562
+ ```
563
+
564
+ Dedup replayed events against anything you saw live: Claude events carry a stable wire `eventId` (upsert on it); Codex has none (`eventId: null`), so gate replay on your own "not currently running" flag. A runnable end-to-end proof — start a session, crash the host mid-turn, reattach in a fresh process — lives in `scripts/durable-session-demo.ts` (`pnpm demo:durable`).
565
+
456
566
  ## Plan Mode
457
567
 
458
568
  Run an agent in read-only "plan" mode — it investigates and proposes a plan but cannot edit files or run mutating commands. Same goal in both providers, **different mechanism** in each. Check `provider.capabilities.planMode` before relying on it.
package/dist/derived.d.ts CHANGED
@@ -44,9 +44,11 @@ export type AcpFactory = (config: {
44
44
  modeId?: string;
45
45
  }) => ProviderModule;
46
46
  /**
47
- * Registered by `@agentex/agent`'s ACP provider module on import, so the
48
- * config-file loader can build `extends: "acp"` providers without a hard
49
- * dependency on the ACP SDK at the top of the module graph.
47
+ * Override the factory used to build `extends: "acp"` providers. Optional — the
48
+ * loader defaults to the built-in `acpProvider` (imported statically here, which
49
+ * is cheap: the ACP SDK is only loaded when a session/execute actually runs).
50
+ * Kept for tests/hosts that need to swap in a custom ACP factory; it is no
51
+ * longer required before `loadProvidersFromConfig`.
50
52
  */
51
53
  export declare function registerAcpFactory(factory: AcpFactory): void;
52
54
  /** @internal — for tests. */
@@ -1 +1 @@
1
- {"version":3,"file":"derived.d.ts","sourceRoot":"","sources":["../src/derived.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,aAAa,EACb,cAAc,EACf,MAAM,YAAY,CAAC;AAGpB;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,mFAAmF;IACnF,EAAE,EAAE,MAAM,CAAC;IACX;6EACyE;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,KAAK,CAAC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AG,IAAI,CAE5D;AAED,6BAA6B;AAC7B,wBAAgB,aAAa,IAAI,UAAU,GAAG,IAAI,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,qBAAqB,GAAG,cAAc,CAiEhF;AA+FD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,OAAO,EACZ,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAC/B,cAAc,EAAE,CA0DlB"}
package/dist/derived.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { getProvider, registerProvider } from "./registry.js";
2
+ import { acpProvider } from "./providers/acp/index.js";
2
3
  /** Thrown when a provider config object is malformed. Branch on it; don't parse. */
3
4
  export class MalformedProviderConfigError extends Error {
4
5
  path;
@@ -10,9 +11,11 @@ export class MalformedProviderConfigError extends Error {
10
11
  }
11
12
  let acpFactory = null;
12
13
  /**
13
- * Registered by `@agentex/agent`'s ACP provider module on import, so the
14
- * config-file loader can build `extends: "acp"` providers without a hard
15
- * dependency on the ACP SDK at the top of the module graph.
14
+ * Override the factory used to build `extends: "acp"` providers. Optional — the
15
+ * loader defaults to the built-in `acpProvider` (imported statically here, which
16
+ * is cheap: the ACP SDK is only loaded when a session/execute actually runs).
17
+ * Kept for tests/hosts that need to swap in a custom ACP factory; it is no
18
+ * longer required before `loadProvidersFromConfig`.
16
19
  */
17
20
  export function registerAcpFactory(factory) {
18
21
  acpFactory = factory;
@@ -180,10 +183,11 @@ export function loadProvidersFromConfig(raw, options) {
180
183
  const modeId = typeof entry.modeId === "string" ? entry.modeId : undefined;
181
184
  let provider;
182
185
  if (entry.extends === "acp") {
183
- if (!acpFactory) {
184
- throw new MalformedProviderConfigError(`${path}: ACP providers require the ACP module — import it (e.g. \`@agentex/agent\`'s acp provider) before loading ACP configs`, path);
185
- }
186
- provider = acpFactory({
186
+ // The ACP provider module is imported statically above, so `acpProvider`
187
+ // is always the default factory. `registerAcpFactory` stays supported as
188
+ // an override hook (tests/hosts can swap in a custom factory).
189
+ const factory = acpFactory ?? acpProvider;
190
+ provider = factory({
187
191
  id,
188
192
  command: toCommandArray(entry.command, path),
189
193
  ...(env ? { env } : {}),
@@ -1 +1 @@
1
- {"version":3,"file":"derived.js","sourceRoot":"","sources":["../src/derived.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAiC9D,oFAAoF;AACpF,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IAC5C,IAAI,CAAU;IACvB,YAAY,OAAe,EAAE,IAAa;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAYD,IAAI,UAAU,GAAsB,IAAI,CAAC;AAEzC;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAmB;IACpD,UAAU,GAAG,OAAO,CAAC;AACvB,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,aAAa;IAC3B,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAA0B;IAC9D,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,OAAO,GAAG,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC1C,MAAM,IAAI,4BAA4B,CAAC,iDAAiD,CAAC,CAAC;IAC5F,CAAC;IACD,IAAI,GAAG,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,4BAA4B,CACpC,aAAa,GAAG,CAAC,EAAE,6GAA6G,EAChI,GAAG,CAAC,EAAE,CACP,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,yBAAyB;IAEhE,MAAM,UAAU,GAAG,CAAC,GAA4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