@qlairoslabs/acp-client 0.10.0 → 0.10.1
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/CONSUMER_GUIDE.md +85 -0
- package/package.json +4 -2
- package/src/agent-session.ts +2 -0
- package/src/agent.ts +380 -86
- package/src/audit/config.ts +4 -0
- package/src/audit/projection.ts +11 -0
- package/src/checkpointing/recovery.ts +23 -1
- package/src/index.ts +23 -0
- package/src/out-of-band-messages.ts +187 -0
- package/src/persistence/backend.ts +46 -1
- package/src/persistence/error-records.ts +104 -0
- package/src/persistence/sqlite-conversation-records.ts +38 -0
- package/src/persistence/sqlite-schema.ts +128 -47
package/CONSUMER_GUIDE.md
CHANGED
|
@@ -293,6 +293,91 @@ first streams provisionally, then arrives as a committed `tool_call`. Detached
|
|
|
293
293
|
`AgentConversation` instances without an owning `Agent` are outside this bus, and a
|
|
294
294
|
consumer-direct `persistence.records.append()` is not observed.
|
|
295
295
|
|
|
296
|
+
### Conversation error records
|
|
297
|
+
|
|
298
|
+
Important runtime failures are stored as an immutable `error` record in the same ordered
|
|
299
|
+
timeline as messages, activities, and metering references — and delivered live through
|
|
300
|
+
`agent.events`. An error is a system timeline item, not a message:
|
|
301
|
+
|
|
302
|
+
```ts
|
|
303
|
+
const errors = (await agent.persistence.records.list(conversation.id, {
|
|
304
|
+
kinds: ["error"],
|
|
305
|
+
})).records;
|
|
306
|
+
|
|
307
|
+
for (const record of errors) {
|
|
308
|
+
if (record.kind !== "error") continue;
|
|
309
|
+
// record.source, record.code, record.recoverability, record.message
|
|
310
|
+
// record.operationId / transitionId / internalSessionId correlate it with the failure
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
`source` is one of `provider_session`, `transport`, `operation`, `recovery`. `code` is an
|
|
315
|
+
open string; the library exports `CONVERSATION_ERROR_CODES` for the codes it owns and
|
|
316
|
+
readers must tolerate unknown future values. `recoverability` describes the failed
|
|
317
|
+
operation, not a promise:
|
|
318
|
+
|
|
319
|
+
- `retryable` — repeating the same action may succeed.
|
|
320
|
+
- `recoverable` — another action (checkpoint recovery, a fresh provider session) may
|
|
321
|
+
continue the logical conversation.
|
|
322
|
+
- `terminal` — the library knows of no supported continuation.
|
|
323
|
+
- `unknown` — evidence is insufficient to choose.
|
|
324
|
+
|
|
325
|
+
`message` is a sanitized display fallback; it never carries a stack trace, credentials, a
|
|
326
|
+
prompt, environment values, or a raw provider payload. At raw capture, allow-listed
|
|
327
|
+
provider detail is available in `details`. Canonical capture defaults to
|
|
328
|
+
`capture.error = "content"` (metadata drops the message; `none` stores nothing); the audit
|
|
329
|
+
destination has its own independent `auditLog.capture.error`.
|
|
330
|
+
|
|
331
|
+
A failed `conversations.open()` throws `ProviderSessionError` instead of returning a
|
|
332
|
+
conversation. It carries the same `code`, `attemptId`, `recoverability`, and — when
|
|
333
|
+
canonical capture accepted it — `recordId` as the durable row, plus
|
|
334
|
+
`agentConversationId` (always, even for a generated id) so the caller can find the
|
|
335
|
+
conversation. If writing the record also fails, that failure is attached as
|
|
336
|
+
`recordingError` and the provider diagnosis stays primary. The failed provider mapping is
|
|
337
|
+
kept as evidence and is not deleted; recovery or a future fresh-session operation
|
|
338
|
+
supersedes it. A `session/load` failure that is recoverable and has a usable checkpoint
|
|
339
|
+
still recovers, with the error recorded before the recovery action.
|
|
340
|
+
|
|
341
|
+
### Append an assistant message without a turn
|
|
342
|
+
|
|
343
|
+
`conversations.appendAssistantMessage()` adds a completed assistant message the provider
|
|
344
|
+
did not produce — for example, a notification the agent sends from another channel. It
|
|
345
|
+
runs no turn and needs no live provider session:
|
|
346
|
+
|
|
347
|
+
```ts
|
|
348
|
+
const record = await agent.conversations.appendAssistantMessage(conversation.id, {
|
|
349
|
+
text: "Your build finished; 3 tests failed.",
|
|
350
|
+
consumerMetadata: { kind: "send_message_to_user" },
|
|
351
|
+
});
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
The record is an ordinary `message` with `role: "assistant"` and `status: "completed"`,
|
|
355
|
+
published on `agent.events` and returned by history reads like any other message. Its
|
|
356
|
+
envelope `metadata` carries `origin: "out_of_band"` (exported as
|
|
357
|
+
`OUT_OF_BAND_MESSAGE_ORIGIN`; `isOutOfBandMessage(record)` tests it), so readers and
|
|
358
|
+
audits can tell it apart from provider output.
|
|
359
|
+
|
|
360
|
+
The provider learns about it on the conversation's next turn. That turn's provider text
|
|
361
|
+
carries every out-of-band message appended since the user message of the last completed
|
|
362
|
+
turn, in a `<messages-you-sent>` block between any identity preamble and
|
|
363
|
+
`<current-message>`. Only the user's own text is persisted as the user message. Rules:
|
|
364
|
+
|
|
365
|
+
- A failed turn does not count as delivery; the next turn carries the messages again.
|
|
366
|
+
- A message appended while a turn is running reaches the provider on the following turn.
|
|
367
|
+
- A recovery seed covers messages through `recoveredThroughSequence`, so they are not
|
|
368
|
+
repeated after recovery. A loaded provider session is treated like one that never
|
|
369
|
+
closed.
|
|
370
|
+
- A turn that completes without an assistant message does not advance delivery, so its
|
|
371
|
+
pending messages are repeated once more.
|
|
372
|
+
- The block is capped at `OUT_OF_BAND_PROMPT_MAX_CHARS`; the oldest messages are dropped
|
|
373
|
+
first with an omission note. The transcript always keeps all of them.
|
|
374
|
+
|
|
375
|
+
Other conversations of the same agent see the message through identity like any other
|
|
376
|
+
canonical message. Appending requires `capture.message` of `"content"` or `"raw"`, since
|
|
377
|
+
the provider could not be told otherwise; it rejects blank text and unknown or deleted
|
|
378
|
+
conversations. Backends without `records.listRecent` scan the conversation's messages
|
|
379
|
+
forward to find the last completed turn.
|
|
380
|
+
|
|
296
381
|
### Agent audit log
|
|
297
382
|
|
|
298
383
|
An SQLite-backed `Agent` can copy selected observations into an independently located,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qlairoslabs/acp-client",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Embeddable Agent Client Protocol (ACP) client library with degraded PTY fallback.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "src/index.ts",
|
|
@@ -58,7 +58,9 @@
|
|
|
58
58
|
"check": "bun run typecheck && bun test",
|
|
59
59
|
"pack:dry": "bun pm pack --dry-run",
|
|
60
60
|
"generate:pricing": "bun run scripts/generate-pricing-catalog.ts",
|
|
61
|
-
"pricing:list": "bun run scripts/list-pricing.ts"
|
|
61
|
+
"pricing:list": "bun run scripts/list-pricing.ts",
|
|
62
|
+
"adapters:check": "bun run scripts/adapters.ts",
|
|
63
|
+
"adapters:update": "bun run scripts/adapters.ts --update"
|
|
62
64
|
},
|
|
63
65
|
"engines": {
|
|
64
66
|
"bun": ">=1.3.5"
|
package/src/agent-session.ts
CHANGED
|
@@ -178,7 +178,9 @@ export {
|
|
|
178
178
|
AgentSessionPromptBlockedError,
|
|
179
179
|
ContinuationUnavailableError,
|
|
180
180
|
DirectAuditPersistenceUnsupportedError,
|
|
181
|
+
ProviderSessionError,
|
|
181
182
|
} from "./agent-conversation-errors.ts";
|
|
183
|
+
export type { ProviderSessionErrorDetails } from "./agent-conversation-errors.ts";
|
|
182
184
|
export type {
|
|
183
185
|
AgentConversationEvent,
|
|
184
186
|
AgentConversationListener,
|