agent-blackboard 0.1.1 → 0.2.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
@@ -51,7 +51,10 @@ await auth.createCredentials({ name: 'ci-bot' })
51
51
  All session ids, agent names, and versions are caller-provided. `parentSessionId` is required and
52
52
  nullable. The service generates `createdAt`/`lastEntryAt`/`archivedAt` timestamps.
53
53
  `Entries.get()` returns an `AsyncIterable<SessionEntry>` and uses incremental JSONL by default.
54
- Non-2xx responses throw `AgentBlackboardError`.
54
+ Non-2xx responses throw `AgentBlackboardError`. Use the root `formatError(error)` export when
55
+ rendering a caught value for users; it includes an `AgentBlackboardError` response body when present
56
+ and safely handles any value JavaScript can throw. Unserializable response bodies and unprintable
57
+ thrown values use deterministic fallback text instead of throwing while reporting the error.
55
58
 
56
59
  ## CLI
57
60
 
@@ -1,15 +1,31 @@
1
1
  import { AgentBlackboardError } from './client/errors.mjs';
2
+ const UNPRINTABLE_ERROR = '[unprintable error]';
3
+ const UNSERIALIZABLE_ERROR_BODY = '[unserializable error body]';
2
4
  /**
3
5
  * Formats any thrown value as a single-line, human-readable message — never
4
6
  * a raw stack trace. Shared by the CLI (stderr) and the MCP server (tool
5
7
  * error content), since a caller can throw anything in JS, not just `Error`.
6
8
  */
7
9
  export function formatError(err) {
8
- if (err instanceof AgentBlackboardError) {
9
- const bodyText = err.body === undefined ? '' : ` ${JSON.stringify(err.body)}`;
10
- return `${err.message}${bodyText}`;
10
+ try {
11
+ if (err instanceof AgentBlackboardError) {
12
+ const body = err.body;
13
+ const bodyText = body === undefined ? '' : ` ${formatErrorBody(body)}`;
14
+ return `${String(err.message)}${bodyText}`;
15
+ }
16
+ if (err instanceof Error)
17
+ return String(err.message);
18
+ return String(err);
19
+ }
20
+ catch {
21
+ return UNPRINTABLE_ERROR;
22
+ }
23
+ }
24
+ function formatErrorBody(body) {
25
+ try {
26
+ return JSON.stringify(body) ?? UNSERIALIZABLE_ERROR_BODY;
27
+ }
28
+ catch {
29
+ return UNSERIALIZABLE_ERROR_BODY;
11
30
  }
12
- if (err instanceof Error)
13
- return err.message;
14
- return String(err);
15
31
  }
package/dist/index.d.mts CHANGED
@@ -13,5 +13,6 @@ export { Auth } from './client/auth.mjs';
13
13
  export type { AuthOptions } from './client/auth.mjs';
14
14
  export { AgentBlackboardError } from './client/errors.mjs';
15
15
  export { Entries } from './client/entries.mjs';
16
+ export { formatError } from './format-error.mjs';
16
17
  export { Sessions } from './client/sessions.mjs';
17
18
  export type { AppendEntryInput, ClientConfig, CreateSessionInput, CredentialCreated, CredentialSummary, EntryWireFormat, GetEntriesQuery, GetRawEntriesQuery, ListSessionsQuery, PatchSessionInput, Session, SessionEntry, StructuredEntryFormat, } from './client/types.mjs';
package/dist/index.mjs CHANGED
@@ -12,4 +12,5 @@
12
12
  export { Auth } from './client/auth.mjs';
13
13
  export { AgentBlackboardError } from './client/errors.mjs';
14
14
  export { Entries } from './client/entries.mjs';
15
+ export { formatError } from './format-error.mjs';
15
16
  export { Sessions } from './client/sessions.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-blackboard",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Client library, CLI, and MCP server for Agent Blackboard session entries.",
5
5
  "homepage": "https://github.com/jonathanong/agent-blackboard#readme",
6
6
  "bugs": {