@qlairoslabs/acp-client 0.3.4 → 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 +54 -20
- package/package.json +1 -1
- package/src/agent-session.ts +447 -29
- package/src/cli/index.ts +2 -2
- package/src/client.ts +128 -15
- package/src/controller.ts +60 -6
- package/src/index.ts +16 -2
- package/src/repl/agent-session-commands.ts +153 -0
- package/src/repl/commands.ts +18 -16
- package/src/repl/index.ts +14 -6
- package/src/repl/repl.ts +115 -27
- package/src/session-manager.ts +3 -0
- package/src/session-store.ts +2 -1
- package/src/transcript.ts +32 -1
- package/src/types.ts +15 -7
- package/src/updates.ts +23 -8
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
|
-
|
|
393
|
-
|
|
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 {
|
|
397
|
-
import {
|
|
434
|
+
import { runAgentSessionRepl } from "@qlairoslabs/acp-client/repl";
|
|
435
|
+
import { AgentSession, ADAPTERS } from "@qlairoslabs/acp-client";
|
|
398
436
|
|
|
399
|
-
const
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
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
|
|
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
|
|
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` | `
|
|
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. |
|