agent-blackboard 0.0.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.
Files changed (66) hide show
  1. package/README.md +80 -0
  2. package/dist/cli/append.d.mts +2 -0
  3. package/dist/cli/append.mjs +33 -0
  4. package/dist/cli/args.d.mts +12 -0
  5. package/dist/cli/args.mjs +36 -0
  6. package/dist/cli/context.d.mts +15 -0
  7. package/dist/cli/context.mjs +1 -0
  8. package/dist/cli/credentials.d.mts +6 -0
  9. package/dist/cli/credentials.mjs +45 -0
  10. package/dist/cli/env.d.mts +5 -0
  11. package/dist/cli/env.mjs +21 -0
  12. package/dist/cli/errors.d.mts +3 -0
  13. package/dist/cli/errors.mjs +3 -0
  14. package/dist/cli/get.d.mts +2 -0
  15. package/dist/cli/get.mjs +39 -0
  16. package/dist/cli/index.d.mts +18 -0
  17. package/dist/cli/index.mjs +73 -0
  18. package/dist/cli/output.d.mts +4 -0
  19. package/dist/cli/output.mjs +4 -0
  20. package/dist/cli/patch.d.mts +2 -0
  21. package/dist/cli/patch.mjs +33 -0
  22. package/dist/cli/sessions.d.mts +2 -0
  23. package/dist/cli/sessions.mjs +34 -0
  24. package/dist/cli/usage.d.mts +1 -0
  25. package/dist/cli/usage.mjs +18 -0
  26. package/dist/client/append.d.mts +2 -0
  27. package/dist/client/append.mjs +9 -0
  28. package/dist/client/auth.d.mts +26 -0
  29. package/dist/client/auth.mjs +23 -0
  30. package/dist/client/credentials.d.mts +13 -0
  31. package/dist/client/credentials.mjs +19 -0
  32. package/dist/client/entries.d.mts +8 -0
  33. package/dist/client/entries.mjs +18 -0
  34. package/dist/client/errors.d.mts +8 -0
  35. package/dist/client/errors.mjs +13 -0
  36. package/dist/client/http.d.mts +22 -0
  37. package/dist/client/http.mjs +60 -0
  38. package/dist/client/patch.d.mts +2 -0
  39. package/dist/client/patch.mjs +8 -0
  40. package/dist/client/sessions.d.mts +9 -0
  41. package/dist/client/sessions.mjs +30 -0
  42. package/dist/client/stream.d.mts +5 -0
  43. package/dist/client/stream.mjs +46 -0
  44. package/dist/client/types.d.mts +46 -0
  45. package/dist/client/types.mjs +1 -0
  46. package/dist/format-error.d.mts +6 -0
  47. package/dist/format-error.mjs +15 -0
  48. package/dist/index.d.mts +17 -0
  49. package/dist/index.mjs +15 -0
  50. package/dist/mcp/dispatch.d.mts +2 -0
  51. package/dist/mcp/dispatch.mjs +20 -0
  52. package/dist/mcp/schemas.d.mts +2 -0
  53. package/dist/mcp/schemas.mjs +67 -0
  54. package/dist/mcp/server.d.mts +10 -0
  55. package/dist/mcp/server.mjs +35 -0
  56. package/dist/mcp/tool-append.d.mts +2 -0
  57. package/dist/mcp/tool-append.mjs +8 -0
  58. package/dist/mcp/tool-get.d.mts +4 -0
  59. package/dist/mcp/tool-get.mjs +14 -0
  60. package/dist/mcp/tool-patch.d.mts +2 -0
  61. package/dist/mcp/tool-patch.mjs +9 -0
  62. package/dist/mcp/tool-sessions.d.mts +3 -0
  63. package/dist/mcp/tool-sessions.mjs +11 -0
  64. package/dist/mcp/validate.d.mts +5 -0
  65. package/dist/mcp/validate.mjs +24 -0
  66. package/package.json +46 -0
@@ -0,0 +1,18 @@
1
+ import { appendEntry } from './append.mjs';
2
+ import { patchEntry } from './patch.mjs';
3
+ import { streamEntries } from './stream.mjs';
4
+ export class Entries {
5
+ #config;
6
+ constructor(config) {
7
+ this.#config = config;
8
+ }
9
+ append(input) {
10
+ return appendEntry(this.#config, input);
11
+ }
12
+ get(query) {
13
+ return streamEntries(this.#config, query);
14
+ }
15
+ patch(input) {
16
+ return patchEntry(this.#config, input);
17
+ }
18
+ }
@@ -0,0 +1,8 @@
1
+ /** Thrown for any non-2xx response from the agent-blackboard HTTP API. */
2
+ export declare class AgentBlackboardError extends Error {
3
+ /** HTTP status code of the failed response. */
4
+ readonly status: number;
5
+ /** Parsed error body — JSON if the response was JSON, raw text otherwise. */
6
+ readonly body: unknown;
7
+ constructor(message: string, status: number, body: unknown);
8
+ }
@@ -0,0 +1,13 @@
1
+ /** Thrown for any non-2xx response from the agent-blackboard HTTP API. */
2
+ export class AgentBlackboardError extends Error {
3
+ /** HTTP status code of the failed response. */
4
+ status;
5
+ /** Parsed error body — JSON if the response was JSON, raw text otherwise. */
6
+ body;
7
+ constructor(message, status, body) {
8
+ super(message);
9
+ this.name = 'AgentBlackboardError';
10
+ this.status = status;
11
+ this.body = body;
12
+ }
13
+ }
@@ -0,0 +1,22 @@
1
+ import type { ClientConfig, EntryWireFormat } from './types.mjs';
2
+ /** Query params as they go on the wire — every value is a string. */
3
+ type WireQuery = Record<string, string>;
4
+ /** Converts a typed entry query into wire-format string params. */
5
+ export declare function buildEntriesQuery(format?: EntryWireFormat): WireQuery;
6
+ /** The `Accept` header that matches a given wire format. */
7
+ export declare function acceptHeaderFor(format: EntryWireFormat): string;
8
+ interface RequestOptions {
9
+ method: string;
10
+ headers?: Record<string, string>;
11
+ body?: string;
12
+ query?: WireQuery;
13
+ }
14
+ /**
15
+ * Issues an authenticated HTTP request and returns the raw `Response`,
16
+ * throwing `AgentBlackboardError` on any non-2xx status. Callers that need the
17
+ * body streamed (not buffered) should read `response.body` directly.
18
+ */
19
+ export declare function rawRequest(config: ClientConfig, path: string, options: RequestOptions): Promise<Response>;
20
+ /** Issues an authenticated HTTP request and parses the response body as JSON. */
21
+ export declare function requestJson<T>(config: ClientConfig, path: string, options: RequestOptions): Promise<T>;
22
+ export {};
@@ -0,0 +1,60 @@
1
+ import { AgentBlackboardError } from './errors.mjs';
2
+ /** Converts a typed entry query into wire-format string params. */
3
+ export function buildEntriesQuery(format) {
4
+ const wire = {};
5
+ if (format !== undefined)
6
+ wire.format = format;
7
+ return wire;
8
+ }
9
+ const ACCEPT_HEADERS = {
10
+ json: 'application/json',
11
+ jsonl: 'application/x-ndjson',
12
+ markdown: 'text/markdown',
13
+ };
14
+ /** The `Accept` header that matches a given wire format. */
15
+ export function acceptHeaderFor(format) {
16
+ return ACCEPT_HEADERS[format];
17
+ }
18
+ function buildUrl(baseUrl, path, query) {
19
+ const base = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
20
+ const url = new URL(path.replace(/^\//, ''), base);
21
+ for (const [key, value] of Object.entries(query)) {
22
+ url.searchParams.set(key, value);
23
+ }
24
+ return url;
25
+ }
26
+ async function parseErrorBody(response) {
27
+ const text = await response.text();
28
+ if (!text)
29
+ return undefined;
30
+ try {
31
+ return JSON.parse(text);
32
+ }
33
+ catch {
34
+ return text;
35
+ }
36
+ }
37
+ /**
38
+ * Issues an authenticated HTTP request and returns the raw `Response`,
39
+ * throwing `AgentBlackboardError` on any non-2xx status. Callers that need the
40
+ * body streamed (not buffered) should read `response.body` directly.
41
+ */
42
+ export async function rawRequest(config, path, options) {
43
+ const url = buildUrl(config.baseUrl, path, options.query ?? {});
44
+ const headers = new Headers(options.headers);
45
+ headers.set('authorization', `Bearer ${config.token}`);
46
+ const init = { method: options.method, headers };
47
+ if (options.body !== undefined)
48
+ init.body = options.body;
49
+ const response = await fetch(url, init);
50
+ if (!response.ok) {
51
+ const body = await parseErrorBody(response);
52
+ throw new AgentBlackboardError(`agent-blackboard request failed: ${options.method} ${path} -> ${response.status}`, response.status, body);
53
+ }
54
+ return response;
55
+ }
56
+ /** Issues an authenticated HTTP request and parses the response body as JSON. */
57
+ export async function requestJson(config, path, options) {
58
+ const response = await rawRequest(config, path, options);
59
+ return (await response.json());
60
+ }
@@ -0,0 +1,2 @@
1
+ import type { ClientConfig, PatchEntryInput, SessionEntry } from './types.mjs';
2
+ export declare function patchEntry(config: ClientConfig, input: PatchEntryInput): Promise<SessionEntry>;
@@ -0,0 +1,8 @@
1
+ import { requestJson } from './http.mjs';
2
+ export async function patchEntry(config, input) {
3
+ return requestJson(config, `/sessions/${encodeURIComponent(input.sessionId)}/entries`, {
4
+ method: 'PATCH',
5
+ headers: { 'content-type': 'application/json' },
6
+ body: JSON.stringify({ createdAt: input.createdAt, data: input.data }),
7
+ });
8
+ }
@@ -0,0 +1,9 @@
1
+ import type { ClientConfig, CreateSessionInput, Session } from './types.mjs';
2
+ export declare class Sessions {
3
+ #private;
4
+ constructor(config: ClientConfig);
5
+ create(input: CreateSessionInput): Promise<Session>;
6
+ list(): Promise<Session[]>;
7
+ get(sessionId: string): Promise<Session>;
8
+ archive(sessionId: string): Promise<Session>;
9
+ }
@@ -0,0 +1,30 @@
1
+ import { requestJson } from './http.mjs';
2
+ const JSON_HEADERS = { 'content-type': 'application/json' };
3
+ export class Sessions {
4
+ #config;
5
+ constructor(config) {
6
+ this.#config = config;
7
+ }
8
+ create(input) {
9
+ return requestJson(this.#config, '/sessions', {
10
+ method: 'POST',
11
+ headers: JSON_HEADERS,
12
+ body: JSON.stringify(input),
13
+ });
14
+ }
15
+ list() {
16
+ return requestJson(this.#config, '/sessions', { method: 'GET' });
17
+ }
18
+ get(sessionId) {
19
+ return requestJson(this.#config, `/sessions/${encodeURIComponent(sessionId)}`, {
20
+ method: 'GET',
21
+ });
22
+ }
23
+ archive(sessionId) {
24
+ return requestJson(this.#config, `/sessions/${encodeURIComponent(sessionId)}`, {
25
+ method: 'PATCH',
26
+ headers: JSON_HEADERS,
27
+ body: JSON.stringify({ archived: true }),
28
+ });
29
+ }
30
+ }
@@ -0,0 +1,5 @@
1
+ import type { ClientConfig, GetEntriesQuery, GetRawEntriesQuery, SessionEntry } from './types.mjs';
2
+ export declare function getEntriesRaw(config: ClientConfig, query: GetRawEntriesQuery): Promise<Response>;
3
+ export declare function parseNdjsonStream(response: Response): AsyncGenerator<SessionEntry>;
4
+ export declare function parseJsonArrayBuffered(response: Response): AsyncGenerator<SessionEntry>;
5
+ export declare function streamEntries(config: ClientConfig, query: GetEntriesQuery): AsyncGenerator<SessionEntry>;
@@ -0,0 +1,46 @@
1
+ import { acceptHeaderFor, buildEntriesQuery, rawRequest } from './http.mjs';
2
+ export function getEntriesRaw(config, query) {
3
+ const format = query.format ?? 'json';
4
+ return rawRequest(config, `/sessions/${encodeURIComponent(query.sessionId)}/entries`, {
5
+ method: 'GET',
6
+ headers: { accept: acceptHeaderFor(format) },
7
+ query: buildEntriesQuery(query.format),
8
+ });
9
+ }
10
+ export async function* parseNdjsonStream(response) {
11
+ if (!response.body)
12
+ return;
13
+ const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
14
+ let buffered = '';
15
+ try {
16
+ for (;;) {
17
+ const { done, value } = await reader.read();
18
+ if (done)
19
+ break;
20
+ buffered += value;
21
+ const lines = buffered.split('\n');
22
+ buffered = lines.pop();
23
+ for (const line of lines)
24
+ if (line.length > 0)
25
+ yield JSON.parse(line);
26
+ }
27
+ if (buffered.length > 0)
28
+ yield JSON.parse(buffered);
29
+ }
30
+ finally {
31
+ reader.releaseLock();
32
+ }
33
+ }
34
+ export async function* parseJsonArrayBuffered(response) {
35
+ const text = await response.text();
36
+ if (text.length === 0)
37
+ return;
38
+ const entries = JSON.parse(text);
39
+ for (const entry of entries)
40
+ yield entry;
41
+ }
42
+ export async function* streamEntries(config, query) {
43
+ const format = query.format ?? 'jsonl';
44
+ const response = await getEntriesRaw(config, { ...query, format });
45
+ yield* format === 'jsonl' ? parseNdjsonStream(response) : parseJsonArrayBuffered(response);
46
+ }
@@ -0,0 +1,46 @@
1
+ export interface ClientConfig {
2
+ baseUrl: string;
3
+ token: string;
4
+ }
5
+ export interface Session {
6
+ id: string;
7
+ parentSessionId: string | null;
8
+ createdAt: string;
9
+ archivedAt: string | null;
10
+ }
11
+ export interface SessionEntry {
12
+ sessionId: string;
13
+ createdAt: string;
14
+ data: Record<string, unknown>;
15
+ }
16
+ export interface CreateSessionInput {
17
+ id: string;
18
+ parentSessionId: string | null;
19
+ }
20
+ export interface AppendEntryInput {
21
+ sessionId: string;
22
+ data: Record<string, unknown>;
23
+ }
24
+ export interface PatchEntryInput {
25
+ sessionId: string;
26
+ createdAt: string;
27
+ data: Record<string, unknown>;
28
+ }
29
+ export type EntryWireFormat = 'json' | 'jsonl' | 'markdown';
30
+ export type StructuredEntryFormat = Extract<EntryWireFormat, 'json' | 'jsonl'>;
31
+ export interface GetEntriesQuery {
32
+ sessionId: string;
33
+ format?: StructuredEntryFormat;
34
+ }
35
+ export interface GetRawEntriesQuery {
36
+ sessionId: string;
37
+ format?: EntryWireFormat;
38
+ }
39
+ export interface CredentialSummary {
40
+ id: string;
41
+ name: string;
42
+ createdAt: string;
43
+ }
44
+ export interface CredentialCreated extends CredentialSummary {
45
+ token: string;
46
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Formats any thrown value as a single-line, human-readable message — never
3
+ * a raw stack trace. Shared by the CLI (stderr) and the MCP server (tool
4
+ * error content), since a caller can throw anything in JS, not just `Error`.
5
+ */
6
+ export declare function formatError(err: unknown): string;
@@ -0,0 +1,15 @@
1
+ import { AgentBlackboardError } from './client/errors.mjs';
2
+ /**
3
+ * Formats any thrown value as a single-line, human-readable message — never
4
+ * a raw stack trace. Shared by the CLI (stderr) and the MCP server (tool
5
+ * error content), since a caller can throw anything in JS, not just `Error`.
6
+ */
7
+ export function formatError(err) {
8
+ if (err instanceof AgentBlackboardError) {
9
+ const bodyText = err.body === undefined ? '' : ` ${JSON.stringify(err.body)}`;
10
+ return `${err.message}${bodyText}`;
11
+ }
12
+ if (err instanceof Error)
13
+ return err.message;
14
+ return String(err);
15
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Public API of `agent-blackboard`: a thin `fetch`-based client for the
3
+ * agent-blackboard HTTP service.
4
+ *
5
+ * - `Sessions` — explicit session lifecycle and parent relationships.
6
+ * - `Entries` — append/read/patch entries using caller-supplied session ids.
7
+ * - `Auth` — admin-only credential management.
8
+ *
9
+ * This module must never import `@aws-sdk/*` or anything from
10
+ * `packages/server` (enforced by `.dependency-cruiser.cjs`).
11
+ */
12
+ export { Auth } from './client/auth.mjs';
13
+ export type { AuthOptions } from './client/auth.mjs';
14
+ export { AgentBlackboardError } from './client/errors.mjs';
15
+ export { Entries } from './client/entries.mjs';
16
+ export { Sessions } from './client/sessions.mjs';
17
+ export type { AppendEntryInput, ClientConfig, CreateSessionInput, CredentialCreated, CredentialSummary, EntryWireFormat, GetEntriesQuery, GetRawEntriesQuery, PatchEntryInput, Session, SessionEntry, StructuredEntryFormat, } from './client/types.mjs';
package/dist/index.mjs ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Public API of `agent-blackboard`: a thin `fetch`-based client for the
3
+ * agent-blackboard HTTP service.
4
+ *
5
+ * - `Sessions` — explicit session lifecycle and parent relationships.
6
+ * - `Entries` — append/read/patch entries using caller-supplied session ids.
7
+ * - `Auth` — admin-only credential management.
8
+ *
9
+ * This module must never import `@aws-sdk/*` or anything from
10
+ * `packages/server` (enforced by `.dependency-cruiser.cjs`).
11
+ */
12
+ export { Auth } from './client/auth.mjs';
13
+ export { AgentBlackboardError } from './client/errors.mjs';
14
+ export { Entries } from './client/entries.mjs';
15
+ export { Sessions } from './client/sessions.mjs';
@@ -0,0 +1,2 @@
1
+ import type { ClientConfig } from '../client/types.mjs';
2
+ export declare function dispatchTool(name: string, args: Record<string, unknown>, config: ClientConfig): Promise<unknown>;
@@ -0,0 +1,20 @@
1
+ import { handleEntryAppend } from './tool-append.mjs';
2
+ import { handleEntryGet } from './tool-get.mjs';
3
+ import { handleEntryPatch } from './tool-patch.mjs';
4
+ import { handleSessionArchive, handleSessionCreate } from './tool-sessions.mjs';
5
+ export function dispatchTool(name, args, config) {
6
+ switch (name) {
7
+ case 'session_create':
8
+ return handleSessionCreate(args, config);
9
+ case 'session_archive':
10
+ return handleSessionArchive(args, config);
11
+ case 'entry_append':
12
+ return handleEntryAppend(args, config);
13
+ case 'entry_get':
14
+ return handleEntryGet(args, config);
15
+ case 'entry_patch':
16
+ return handleEntryPatch(args, config);
17
+ default:
18
+ throw new Error(`Unknown tool: ${name}`);
19
+ }
20
+ }
@@ -0,0 +1,2 @@
1
+ import type { Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ export declare const ENTRY_TOOLS: Tool[];
@@ -0,0 +1,67 @@
1
+ const SESSION_ID = {
2
+ type: 'string',
3
+ description: 'Caller-supplied session id. Never inferred or generated.',
4
+ };
5
+ export const ENTRY_TOOLS = [
6
+ {
7
+ name: 'session_create',
8
+ description: 'Creates a root or subagent session before entries are appended.',
9
+ inputSchema: {
10
+ type: 'object',
11
+ properties: {
12
+ sessionId: SESSION_ID,
13
+ parentSessionId: {
14
+ type: ['string', 'null'],
15
+ description: 'Null for a root session; the direct parent session id for a subagent.',
16
+ },
17
+ },
18
+ required: ['sessionId', 'parentSessionId'],
19
+ },
20
+ },
21
+ {
22
+ name: 'session_archive',
23
+ description: 'Archives a session, preventing further entry reads and writes.',
24
+ inputSchema: {
25
+ type: 'object',
26
+ properties: { sessionId: SESSION_ID },
27
+ required: ['sessionId'],
28
+ },
29
+ },
30
+ {
31
+ name: 'entry_append',
32
+ description: 'Appends unstructured data to an existing active session.',
33
+ inputSchema: {
34
+ type: 'object',
35
+ properties: {
36
+ sessionId: SESSION_ID,
37
+ data: { type: 'object', description: 'Unstructured JSON payload.' },
38
+ },
39
+ required: ['sessionId', 'data'],
40
+ },
41
+ },
42
+ {
43
+ name: 'entry_get',
44
+ description: 'Reads entries from one existing active session.',
45
+ inputSchema: {
46
+ type: 'object',
47
+ properties: {
48
+ sessionId: SESSION_ID,
49
+ format: { type: 'string', enum: ['json', 'jsonl'] },
50
+ },
51
+ required: ['sessionId'],
52
+ },
53
+ },
54
+ {
55
+ name: 'entry_patch',
56
+ description: 'Shallow-merges data into one timestamp-addressed session entry.',
57
+ inputSchema: {
58
+ type: 'object',
59
+ properties: {
60
+ sessionId: SESSION_ID,
61
+ createdAt: { type: 'string', description: 'The entry timestamp returned by entry_append.' },
62
+ data: { type: 'object', description: 'Non-empty data to shallow-merge.' },
63
+ },
64
+ required: ['sessionId', 'createdAt', 'data'],
65
+ },
66
+ },
67
+ ];
@@ -0,0 +1,10 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import type { ClientConfig } from '../client/types.mjs';
3
+ /**
4
+ * Builds the MCP server with the session and entry tools registered, but does
5
+ * not connect a transport — kept separate so tests can drive it over an
6
+ * `InMemoryTransport` instead of real stdio.
7
+ */
8
+ export declare function createMcpServer(config: ClientConfig): Server;
9
+ /** Starts the MCP stdio server — the `agent-blackboard mcp` entrypoint. */
10
+ export declare function startMcpServer(config: ClientConfig): Promise<void>;
@@ -0,0 +1,35 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
4
+ import { formatError } from '../format-error.mjs';
5
+ import { dispatchTool } from './dispatch.mjs';
6
+ import { ENTRY_TOOLS } from './schemas.mjs';
7
+ const SERVER_INFO = { name: 'agent-blackboard', version: '0.0.0' };
8
+ /**
9
+ * Builds the MCP server with the session and entry tools registered, but does
10
+ * not connect a transport — kept separate so tests can drive it over an
11
+ * `InMemoryTransport` instead of real stdio.
12
+ */
13
+ export function createMcpServer(config) {
14
+ const server = new Server(SERVER_INFO, { capabilities: { tools: {} } });
15
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: ENTRY_TOOLS }));
16
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
17
+ try {
18
+ const result = await dispatchTool(request.params.name, request.params.arguments ?? {}, config);
19
+ return { content: [{ type: 'text', text: JSON.stringify(result) }] };
20
+ }
21
+ catch (err) {
22
+ return { content: [{ type: 'text', text: formatError(err) }], isError: true };
23
+ }
24
+ });
25
+ return server;
26
+ }
27
+ /* v8 ignore start -- real stdio transport; requires an actual MCP client process attached to
28
+ stdin/stdout, which vitest can't drive. `createMcpServer` above (the tested logic) is exercised
29
+ directly via InMemoryTransport in server.test.mts. */
30
+ /** Starts the MCP stdio server — the `agent-blackboard mcp` entrypoint. */
31
+ export async function startMcpServer(config) {
32
+ const server = createMcpServer(config);
33
+ await server.connect(new StdioServerTransport());
34
+ }
35
+ /* v8 ignore stop */
@@ -0,0 +1,2 @@
1
+ import type { ClientConfig, SessionEntry } from '../client/types.mjs';
2
+ export declare function handleEntryAppend(args: Record<string, unknown>, config: ClientConfig): Promise<SessionEntry>;
@@ -0,0 +1,8 @@
1
+ import { appendEntry } from '../client/append.mjs';
2
+ import { expectObject, requiredString } from './validate.mjs';
3
+ export function handleEntryAppend(args, config) {
4
+ return appendEntry(config, {
5
+ sessionId: requiredString(args.sessionId, 'sessionId'),
6
+ data: expectObject(args.data, 'data'),
7
+ });
8
+ }
@@ -0,0 +1,4 @@
1
+ import type { ClientConfig, SessionEntry } from '../client/types.mjs';
2
+ export declare function handleEntryGet(args: Record<string, unknown>, config: ClientConfig): Promise<{
3
+ entries: SessionEntry[];
4
+ }>;
@@ -0,0 +1,14 @@
1
+ import { streamEntries } from '../client/stream.mjs';
2
+ import { optionalEntryFormat, requiredString } from './validate.mjs';
3
+ export async function handleEntryGet(args, config) {
4
+ const entries = [];
5
+ const format = optionalEntryFormat(args.format);
6
+ const query = {
7
+ sessionId: requiredString(args.sessionId, 'sessionId'),
8
+ ...(format === undefined ? {} : { format }),
9
+ };
10
+ for await (const entry of streamEntries(config, query)) {
11
+ entries.push(entry);
12
+ }
13
+ return { entries };
14
+ }
@@ -0,0 +1,2 @@
1
+ import type { ClientConfig, SessionEntry } from '../client/types.mjs';
2
+ export declare function handleEntryPatch(args: Record<string, unknown>, config: ClientConfig): Promise<SessionEntry>;
@@ -0,0 +1,9 @@
1
+ import { patchEntry } from '../client/patch.mjs';
2
+ import { expectObject, requiredString } from './validate.mjs';
3
+ export function handleEntryPatch(args, config) {
4
+ return patchEntry(config, {
5
+ sessionId: requiredString(args.sessionId, 'sessionId'),
6
+ createdAt: requiredString(args.createdAt, 'createdAt'),
7
+ data: expectObject(args.data, 'data'),
8
+ });
9
+ }
@@ -0,0 +1,3 @@
1
+ import type { ClientConfig, Session } from '../client/types.mjs';
2
+ export declare function handleSessionCreate(args: Record<string, unknown>, config: ClientConfig): Promise<Session>;
3
+ export declare function handleSessionArchive(args: Record<string, unknown>, config: ClientConfig): Promise<Session>;
@@ -0,0 +1,11 @@
1
+ import { Sessions } from '../client/sessions.mjs';
2
+ import { nullableString, requiredString } from './validate.mjs';
3
+ export function handleSessionCreate(args, config) {
4
+ return new Sessions(config).create({
5
+ id: requiredString(args.sessionId, 'sessionId'),
6
+ parentSessionId: nullableString(args.parentSessionId, 'parentSessionId'),
7
+ });
8
+ }
9
+ export function handleSessionArchive(args, config) {
10
+ return new Sessions(config).archive(requiredString(args.sessionId, 'sessionId'));
11
+ }
@@ -0,0 +1,5 @@
1
+ import type { StructuredEntryFormat } from '../client/types.mjs';
2
+ export declare function expectObject(value: unknown, field: string): Record<string, unknown>;
3
+ export declare function requiredString(value: unknown, field: string): string;
4
+ export declare function nullableString(value: unknown, field: string): string | null;
5
+ export declare function optionalEntryFormat(value: unknown): StructuredEntryFormat | undefined;
@@ -0,0 +1,24 @@
1
+ export function expectObject(value, field) {
2
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
3
+ throw new Error(`"${field}" must be an object.`);
4
+ }
5
+ return value;
6
+ }
7
+ export function requiredString(value, field) {
8
+ if (typeof value !== 'string' || value.length === 0) {
9
+ throw new Error(`"${field}" must be a non-empty string.`);
10
+ }
11
+ return value;
12
+ }
13
+ export function nullableString(value, field) {
14
+ if (value === null)
15
+ return null;
16
+ return requiredString(value, field);
17
+ }
18
+ export function optionalEntryFormat(value) {
19
+ if (value === undefined)
20
+ return undefined;
21
+ if (value === 'json' || value === 'jsonl')
22
+ return value;
23
+ throw new Error('"format" must be "json" or "jsonl".');
24
+ }
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "agent-blackboard",
3
+ "version": "0.0.0",
4
+ "description": "Client library, CLI, and MCP server for Agent Blackboard session entries.",
5
+ "homepage": "https://github.com/jonathanong/agent-blackboard#readme",
6
+ "bugs": {
7
+ "url": "https://github.com/jonathanong/agent-blackboard/issues"
8
+ },
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/jonathanong/agent-blackboard.git",
13
+ "directory": "packages/agent-blackboard"
14
+ },
15
+ "bin": {
16
+ "agent-blackboard": "dist/cli/index.mjs"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
22
+ "type": "module",
23
+ "main": "./dist/index.mjs",
24
+ "types": "./dist/index.d.mts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.mts",
28
+ "import": "./dist/index.mjs",
29
+ "default": "./dist/index.mjs"
30
+ }
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "scripts": {
36
+ "build": "node scripts/build.mjs",
37
+ "prepack": "pnpm run build",
38
+ "typecheck": "tsc --noEmit --project tsconfig.json"
39
+ },
40
+ "dependencies": {
41
+ "@modelcontextprotocol/sdk": "^1.29.0"
42
+ },
43
+ "engines": {
44
+ "node": ">=24.0.0"
45
+ }
46
+ }