@qlairoslabs/acp-client 0.3.3 → 0.4.0

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.
package/README.md CHANGED
@@ -297,6 +297,7 @@ const sessions = new SessionManager(new FileSessionStore()); // ~/.acp-lib/sessi
297
297
  const session = await AgentSession.create({
298
298
  adapter: ADAPTERS.codex,
299
299
  adapterId: "codex",
300
+ providerSession: { kind: "new" },
300
301
  sessions, // ← records itself to the catalog on start & each prompt
301
302
  });
302
303
 
@@ -310,12 +311,48 @@ for (const s of await session.listSessions()) {
310
311
  await session.stop();
311
312
  ```
312
313
 
314
+ Logical identity and provider-thread selection are independent. `agentSessionId` is the
315
+ stable consumer handle (a UUID is minted when omitted); `providerSession` explicitly
316
+ chooses a fresh ACP thread or loads an existing one:
317
+
318
+ ```ts
319
+ const record = await sessions.get(agentSessionId); // metadata only; starts nothing
320
+ if (!record) throw new Error("unknown logical session");
321
+
322
+ const reopened = await AgentSession.create({
323
+ adapter: await resolveAdapter(record.adapter),
324
+ adapterId: record.adapter,
325
+ agentSessionId: record.agentSessionId,
326
+ providerSession: record.internalSessionId
327
+ ? { kind: "load", internalSessionId: record.internalSessionId } // fails closed
328
+ : { kind: "new" },
329
+ mode: record.mode,
330
+ cwd: record.cwd,
331
+ title: record.title,
332
+ sessions,
333
+ ...(record.transcriptPath ? { transcriptPath: record.transcriptPath } : {}),
334
+ });
335
+ ```
336
+
337
+ Loading defaults to `onFailure: "error"`. Use `onFailure: "new"` only when silently
338
+ replacing a missing provider thread is the intended policy. The legacy flat
339
+ `internalSessionId` option remains as a deprecated compatibility shorthand and retains
340
+ its historical fallback-to-new behavior.
341
+
313
342
  ### Optional chat transcript
314
343
 
315
344
  Pass `transcriptPath` or `transcriptDir` to `AgentSession` to append a lightweight JSONL
316
345
  chat transcript that can be read later without starting the agent. `transcriptPath` is an
317
346
  exact file path chosen by the caller; `transcriptDir` lets the library write
318
347
  `<agentSessionId>.jsonl` inside that directory. Supplying both is a config error.
348
+ The resolved location is available as `session.transcriptPath` and is recorded in the
349
+ session catalog when one is attached.
350
+
351
+ Transcript configuration controls history storage only. Existing transcript contents,
352
+ filenames, and directories never decide whether ACP creates or loads a provider thread.
353
+ An existing file is appended to; a missing directory/file is created on first write; and
354
+ malformed lines are skipped by readers. Omit both options to disable transcript writes—
355
+ prompting, handoff, notifications, harness commands, and catalog metadata still work.
319
356
 
320
357
  The transcript stores user messages and final assistant replies. Set
321
358
  `transcriptActivity: true` to also record tool calls, thinking and plans as `t:"activity"`
@@ -389,35 +426,32 @@ const messages = await readTranscript("/absolute/path/to/chats/conv-123.jsonl");
389
426
 
390
427
  ### Interactive REPL
391
428
 
392
- The REPL and its slash-commands (`/help`, `/new`, `/sessions`, `/load`, `/config`,
393
- `/degrade`, …) are reusable. Wire them to your own UI, or just run them.
429
+ For one stable `AgentSession`, use the opinionated session REPL. Local `/...` commands
430
+ control that logical session; explicit `//...` commands go to its active internal session;
431
+ an unknown `/...` command is reported locally and is never silently sent to the harness.
394
432
 
395
433
  ```ts
396
- import { runRepl, createAgentCommands } from "@qlairoslabs/acp-client/repl";
397
- import { AgentController, ADAPTERS } from "@qlairoslabs/acp-client";
434
+ import { runAgentSessionRepl } from "@qlairoslabs/acp-client/repl";
435
+ import { AgentSession, ADAPTERS } from "@qlairoslabs/acp-client";
398
436
 
399
- const agent = new AgentController({ adapter: ADAPTERS.codex, adapterId: "codex" });
400
- const { sessionId, resumed } = await agent.start();
401
-
402
- const commands = createAgentCommands({
403
- client: agent,
404
- note: (msg) => process.stderr.write(msg + "\n"),
405
- color: true,
406
- // sessionManager + adapterId here to persist /new, /load, /fork to a catalog
437
+ const session = await AgentSession.create({
438
+ adapter: ADAPTERS.codex,
439
+ adapterId: "codex",
440
+ providerSession: { kind: "new" },
407
441
  });
408
442
 
409
443
  try {
410
- await runRepl(agent, {
411
- intro: `${resumed ? "resumed" : "new"} session ${sessionId}`,
412
- activity: true,
413
- spinner: true,
414
- onSlashCommand: commands.onSlashCommand,
415
- });
444
+ await runAgentSessionRepl(session, { activity: true, spinner: true });
416
445
  } finally {
417
- await agent.stop();
446
+ await session.stop();
418
447
  }
419
448
  ```
420
449
 
450
+ The older low-level controller REPL remains available as `runRepl()` plus
451
+ `createControllerCommands()`. Its `/new`, `/load`, `/resume`, and `/fork` commands replace
452
+ the `AgentController`'s ACP provider session directly; they do not manage multiple stable
453
+ `AgentSession` objects. A consumer-owned managed CLI belongs above both command sets.
454
+
421
455
  ### CLI
422
456
 
423
457
  A thin wrapper over the library is exposed as `acp-client`:
@@ -446,7 +480,7 @@ opt-in subpaths.
446
480
  |---|---|
447
481
  | `@qlairoslabs/acp-client` | Core: `AgentController`, `AgentSession`, `AcpClient`, `SessionManager`, `FileSessionStore`, `ADAPTERS`, loggers, types. |
448
482
  | `@qlairoslabs/acp-client/activity` | `ActivityAggregator`, `foldRecords`, `foldFrame`, `wireFrames` — the delta→full-state fold. No runtime imports, so it is safe to compile for a browser. |
449
- | `@qlairoslabs/acp-client/repl` | `runRepl`, `createAgentCommands` (interactive layer). |
483
+ | `@qlairoslabs/acp-client/repl` | `runAgentSessionRepl`, `createAgentSessionCommands`, plus low-level `runRepl` and `createControllerCommands`. |
450
484
  | `@qlairoslabs/acp-client/degraded` | The PTY fallback transport (`Bun.spawn({ terminal })` + xterm parsing). |
451
485
  | `@qlairoslabs/acp-client/parser` | Terminal-output parsers used by degraded mode. |
452
486
  | `@qlairoslabs/acp-client/cli` | The CLI entry point. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qlairoslabs/acp-client",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "Embeddable Agent Client Protocol (ACP) client library with degraded PTY fallback.",
5
5
  "type": "module",
6
6
  "module": "src/index.ts",
package/src/adapters.ts CHANGED
@@ -21,15 +21,35 @@ export interface Adapter {
21
21
  * nothing about what the agent supports.
22
22
  *
23
23
  * A wrong command here surfaces as a connect timeout, which reads like a library fault, so
24
- * the marked entries are the ones actually spawned and verified. `claude` was
25
- * `claude-agent-acp` until it wasn't: the ACP bridge for Claude Code ships as
26
- * `@zed-industries/claude-code-acp`, and the `claude` CLI itself speaks no ACP. Check
27
- * `which <command>` before assuming the library is at fault.
24
+ * the marked entries are the ones actually spawned and verified. Check `which <command>`
25
+ * before assuming the library is at fault.
28
26
  */
29
27
  export const ADAPTERS = {
30
28
  kimi: { command: ["kimi", "acp"], ptyCommand: ["kimi"], displayName: "Kimi" }, // verified
31
- // verified — @zed-industries/claude-code-acp. NOT `claude-agent-acp`, and not the `claude` CLI.
32
- claude: { command: ["claude-code-acp"], ptyCommand: ["claude"], displayName: "Claude" },
29
+ // verified — @agentclientprotocol/claude-agent-acp. Not the `claude` CLI, which speaks no
30
+ // ACP. If the binary isn't on PATH: `npm i -g @agentclientprotocol/claude-agent-acp`, or
31
+ // pass `{ command: ["bunx", "@agentclientprotocol/claude-agent-acp"] }` and skip installing.
32
+ claude: { command: ["claude-agent-acp"], ptyCommand: ["claude"], displayName: "Claude" },
33
+ /**
34
+ * @deprecated The same bridge under its old name. npm marks it renamed to
35
+ * `@agentclientprotocol/claude-agent-acp`, and it has been left far behind (0.16.x against
36
+ * 0.64.x), so it is frozen rather than merely older. Use `claude` above.
37
+ *
38
+ * Kept, and NOT quietly redirected, because a preset names a program to spawn: silently
39
+ * launching a different binary than the key says would be the harder failure to diagnose
40
+ * of the two. It is here so an existing install keeps working while it is migrated.
41
+ *
42
+ * The versions behave differently in ways that reach the caller. Most sharply, the ORDER
43
+ * of the permission options they offer is reversed — `allow_always` first here,
44
+ * `reject_once` first in the current package — so a client that picked an option by
45
+ * POSITION granted standing permission against one and refused everything against the
46
+ * other. Both are covered by smoke-tests/test4-permission.
47
+ */
48
+ claudeCode: {
49
+ command: ["claude-code-acp"],
50
+ ptyCommand: ["claude"],
51
+ displayName: "Claude (deprecated bridge)",
52
+ },
33
53
  // verified — @agentclientprotocol/codex-acp. The `codex` CLI has no `acp` subcommand.
34
54
  codex: { command: ["codex-acp"], ptyCommand: ["codex"], displayName: "Codex" },
35
55
  // Below: from each project's docs, not spawned here. Correct at time of writing, unverified.