agent-blackboard 0.7.0 → 0.8.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 (53) hide show
  1. package/README.md +30 -13
  2. package/dist/cli/append.mjs +13 -1
  3. package/dist/cli/env.d.mts +4 -4
  4. package/dist/cli/env.mjs +6 -6
  5. package/dist/cli/get.mjs +2 -1
  6. package/dist/cli/index.mjs +5 -1
  7. package/dist/cli/revision-notice.d.mts +6 -0
  8. package/dist/cli/revision-notice.mjs +19 -0
  9. package/dist/cli/schemas-shadow.d.mts +3 -0
  10. package/dist/cli/schemas-shadow.mjs +47 -0
  11. package/dist/cli/schemas.d.mts +2 -0
  12. package/dist/cli/schemas.mjs +168 -0
  13. package/dist/cli/sessions.mjs +2 -1
  14. package/dist/cli/snapshot.mjs +2 -1
  15. package/dist/cli/usage.d.mts +1 -1
  16. package/dist/cli/usage.mjs +11 -2
  17. package/dist/client/append.d.mts +2 -2
  18. package/dist/client/append.mjs +5 -1
  19. package/dist/client/entries.d.mts +2 -2
  20. package/dist/client/http.d.mts +2 -0
  21. package/dist/client/http.mjs +26 -8
  22. package/dist/client/schema-types.d.mts +119 -0
  23. package/dist/client/schema-types.mjs +1 -0
  24. package/dist/client/schemas-client.d.mts +21 -0
  25. package/dist/client/schemas-client.mjs +62 -0
  26. package/dist/client/schemas.d.mts +23 -0
  27. package/dist/client/schemas.mjs +68 -0
  28. package/dist/client/types.d.mts +10 -0
  29. package/dist/index.d.mts +6 -1
  30. package/dist/index.mjs +3 -0
  31. package/dist/mcp/dispatch.mjs +9 -0
  32. package/dist/mcp/schemas-registry-tools.d.mts +2 -0
  33. package/dist/mcp/schemas-registry-tools.mjs +63 -0
  34. package/dist/mcp/schemas.mjs +10 -2
  35. package/dist/mcp/server.mjs +2 -1
  36. package/dist/mcp/session-resolution.d.mts +7 -0
  37. package/dist/mcp/session-resolution.mjs +13 -0
  38. package/dist/mcp/tool-append.d.mts +2 -2
  39. package/dist/mcp/tool-append.mjs +8 -1
  40. package/dist/mcp/tool-schemas.d.mts +7 -0
  41. package/dist/mcp/tool-schemas.mjs +26 -0
  42. package/dist/plugin/.claude-mcp.json +1 -1
  43. package/dist/plugin/.codex-plugin/plugin.json +6 -6
  44. package/dist/plugin/.mcp.json +1 -1
  45. package/dist/plugin/skills/agent-blackboard/SKILL.md +20 -12
  46. package/dist/schemas/id.d.mts +8 -0
  47. package/dist/schemas/id.mjs +32 -0
  48. package/dist/schemas/local-store.d.mts +22 -0
  49. package/dist/schemas/local-store.mjs +159 -0
  50. package/dist/schemas/validate.d.mts +3 -0
  51. package/dist/schemas/validate.mjs +70 -0
  52. package/dist/session-id/persist.mjs +15 -2
  53. package/package.json +7 -5
@@ -0,0 +1,26 @@
1
+ import { Schemas } from '../client/schemas.mjs';
2
+ import { expectObject, optionalPositiveInt, requiredString } from './validate.mjs';
3
+ function localOptions(args, resolution) {
4
+ const dir = args.dir === undefined ? undefined : requiredString(args.dir, 'dir');
5
+ return {
6
+ ...(dir !== undefined ? { dir } : {}),
7
+ ...(resolution?.cwd !== undefined ? { cwd: resolution.cwd } : {}),
8
+ ...(resolution?.env !== undefined ? { env: resolution.env } : {}),
9
+ };
10
+ }
11
+ export function handleSchemaList(config) {
12
+ return new Schemas(config).list();
13
+ }
14
+ export function handleSchemaGet(args, config) {
15
+ const id = requiredString(args.id, 'id');
16
+ const version = optionalPositiveInt(args.version, 'version');
17
+ return new Schemas(config).get(id, version);
18
+ }
19
+ export function handleSchemaPull(args, config, resolution) {
20
+ return new Schemas(config).pull(localOptions(args, resolution));
21
+ }
22
+ export async function handleSchemaValidate(args, config, resolution) {
23
+ const schema = requiredString(args.schema, 'schema');
24
+ const data = expectObject(args.data, 'data');
25
+ return new Schemas(config).validateLocal(schema, data, localOptions(args, resolution));
26
+ }
@@ -2,7 +2,7 @@
2
2
  "mcpServers": {
3
3
  "agent-blackboard": {
4
4
  "command": "npx",
5
- "args": ["-y", "agent-blackboard@0.7.0", "mcp"],
5
+ "args": ["-y", "agent-blackboard@0.8.0", "mcp"],
6
6
  "env": {
7
7
  "AGENT_BLACKBOARD_URL": "${AGENT_BLACKBOARD_URL}",
8
8
  "AGENT_BLACKBOARD_TOKEN": "${AGENT_BLACKBOARD_TOKEN}"
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "agent-blackboard",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "A session-scoped entry stream for autonomous agents working unmonitored, for Codex.",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",
7
7
  "email": "jonathanrichardong@gmail.com",
8
8
  "url": "https://github.com/jonathanong"
9
9
  },
10
- "homepage": "https://github.com/jonathanong/agent-blackboard",
11
- "repository": "https://github.com/jonathanong/agent-blackboard",
10
+ "homepage": "https://github.com/jongleberry/agent-blackboard",
11
+ "repository": "https://github.com/jongleberry/agent-blackboard",
12
12
  "license": "MIT",
13
13
  "keywords": ["entries", "agent", "mcp", "retrospective", "codex"],
14
14
  "skills": "./skills/",
@@ -20,9 +20,9 @@
20
20
  "developerName": "Jonathan Ong",
21
21
  "category": "Coding",
22
22
  "capabilities": ["Interactive", "Write"],
23
- "websiteURL": "https://github.com/jonathanong/agent-blackboard",
24
- "privacyPolicyURL": "https://github.com/jonathanong/agent-blackboard",
25
- "termsOfServiceURL": "https://github.com/jonathanong/agent-blackboard",
23
+ "websiteURL": "https://github.com/jongleberry/agent-blackboard",
24
+ "privacyPolicyURL": "https://github.com/jongleberry/agent-blackboard",
25
+ "termsOfServiceURL": "https://github.com/jongleberry/agent-blackboard",
26
26
  "defaultPrompt": [
27
27
  "Record a note about what I just did",
28
28
  "Get my entries for this session",
@@ -2,7 +2,7 @@
2
2
  "mcpServers": {
3
3
  "agent-blackboard": {
4
4
  "command": "npx",
5
- "args": ["-y", "agent-blackboard@0.7.0", "mcp"],
5
+ "args": ["-y", "agent-blackboard@0.8.0", "mcp"],
6
6
  "env_vars": ["AGENT_BLACKBOARD_URL", "AGENT_BLACKBOARD_TOKEN", "CODEX_THREAD_ID"]
7
7
  }
8
8
  }
@@ -17,8 +17,11 @@ skill explains how to use it; project instructions decide what is worth recordin
17
17
  `parentSessionId`. Root sessions use `parentSessionId: null`.
18
18
  - **Agent identity is explicit.** Every session creation includes the actual agent name and version.
19
19
  - **Sessions can carry data.** Session patches shallow-merge a free-form `data` object.
20
- - **`data` is unstructured.** Every entry carries a free-form `data` object. Attach whatever is
21
- useful — a note, a branch name, a PR number, a decision and its rationale. There is no schema.
20
+ - **`data` is JSON with optional schema validation.** Every entry carries a JSON `data` object.
21
+ Unschematized entries remain allowed when the server runs in `optional` (default) or `shadow`
22
+ mode; when a deployment registers JSON Schema 2020-12 entry schemas, pass `schemaId` (and optional
23
+ `schemaVersion`) on `entry_append` (or `--schema <id>[@<version>]` in the CLI) so the server
24
+ validates and records the schema version on the entry.
22
25
  - **Repository context has a standard convention.** When recording repository work, use
23
26
  `repositories` as a sorted, deduplicated array of lowercase GitHub `owner/name` strings. The
24
27
  session's `data.repositories` is the cumulative union; an entry's `data.repositories` contains
@@ -43,10 +46,15 @@ If the `agent-blackboard` MCP server is connected, use its tools directly:
43
46
  - `session_patch` — shallow-merge `data` into an unarchived session.
44
47
  - `session_archive` — mark a session as distilled; archival is one-time and metadata becomes
45
48
  immutable.
46
- - `entry_append` — append `data` to any existing session, including an archived one.
49
+ - `entry_append` — append `data` to any existing session, including an archived one. Optionally
50
+ supply `schemaId` (and `schemaVersion`) for server-side JSON Schema validation.
47
51
  - `entry_get` — read entries from one explicit session.
48
52
  - `snapshot_export` — stream all selected active sessions and entries to a private read-only JSONL
49
53
  file, returning only its path, counts, checksum, and manifest.
54
+ - `schema_list` — list registered JSON Schemas and the current schema registry revision.
55
+ - `schema_get` — inspect one registered schema (latest version or an explicit `version`).
56
+ - `schema_pull` — sync the full schema registry into the local cache (`If-None-Match`).
57
+ - `schema_validate` — validate an entry payload offline against a locally pulled schema.
50
58
 
51
59
  ## Using it via the CLI
52
60
 
@@ -54,17 +62,17 @@ Without MCP, or from a shell/script, run the published CLI through `npx`. This d
54
62
  local clone of the agent-blackboard repository:
55
63
 
56
64
  ```bash
57
- npx -y agent-blackboard@0.7.0 sessions create root-123 --agent claude-code --version 1.0.13
58
- npx -y agent-blackboard@0.7.0 sessions create worker-456 --parent-session-id root-123 \
65
+ npx -y agent-blackboard@0.8.0 sessions create root-123 --agent claude-code --version 1.0.13
66
+ npx -y agent-blackboard@0.8.0 sessions create worker-456 --parent-session-id root-123 \
59
67
  --agent claude-code --version 1.0.13
60
- npx -y agent-blackboard@0.7.0 sessions patch worker-456 --data '{"branch":"fix/retry"}'
61
- npx -y agent-blackboard@0.7.0 sessions patch worker-456 --data '{"repositories":["owner/name"]}'
62
- npx -y agent-blackboard@0.7.0 append --session-id worker-456 '{"repositories":["owner/name"],"note":"found the failing edge case"}'
63
- npx -y agent-blackboard@0.7.0 get --session-id worker-456 --format markdown
64
- npx -y agent-blackboard@0.7.0 snapshot export --root-only --inactive-for-hours 8
65
- npx -y agent-blackboard@0.7.0 snapshot partition --path /tmp/agent-blackboard-snapshot-<uuid>.jsonl \
68
+ npx -y agent-blackboard@0.8.0 sessions patch worker-456 --data '{"branch":"fix/retry"}'
69
+ npx -y agent-blackboard@0.8.0 sessions patch worker-456 --data '{"repositories":["owner/name"]}'
70
+ npx -y agent-blackboard@0.8.0 append --session-id worker-456 '{"repositories":["owner/name"],"note":"found the failing edge case"}'
71
+ npx -y agent-blackboard@0.8.0 get --session-id worker-456 --format markdown
72
+ npx -y agent-blackboard@0.8.0 snapshot export --root-only --inactive-for-hours 8
73
+ npx -y agent-blackboard@0.8.0 snapshot partition --path /tmp/agent-blackboard-snapshot-<uuid>.jsonl \
66
74
  --cleanup-token <cleanup-token>
67
- npx -y agent-blackboard@0.7.0 snapshot cleanup --path /tmp/agent-blackboard-snapshot-<uuid>.jsonl \
75
+ npx -y agent-blackboard@0.8.0 snapshot cleanup --path /tmp/agent-blackboard-snapshot-<uuid>.jsonl \
68
76
  --directory /tmp/agent-blackboard-partitions-<suffix> --cleanup-token <cleanup-token>
69
77
  ```
70
78
 
@@ -0,0 +1,8 @@
1
+ export interface ParsedSchemaRef {
2
+ id: string;
3
+ version?: number;
4
+ }
5
+ export declare function isValidSchemaId(value: string): boolean;
6
+ export declare function parseSchemaVersion(raw: string): number | undefined;
7
+ export declare function parseSchemaRef(raw: string): ParsedSchemaRef | undefined;
8
+ export declare function formatSchemaRef(id: string, version: number): string;
@@ -0,0 +1,32 @@
1
+ const SCHEMA_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
2
+ const MAX_SCHEMA_ID_LENGTH = 128;
3
+ const POSITIVE_INT_PATTERN = /^[1-9][0-9]*$/;
4
+ export function isValidSchemaId(value) {
5
+ return (value.length > 0 &&
6
+ value.length <= MAX_SCHEMA_ID_LENGTH &&
7
+ !value.includes('..') &&
8
+ value !== '__proto__' &&
9
+ !Object.hasOwn(Object.prototype, value) &&
10
+ SCHEMA_ID_PATTERN.test(value));
11
+ }
12
+ export function parseSchemaVersion(raw) {
13
+ if (!POSITIVE_INT_PATTERN.test(raw))
14
+ return undefined;
15
+ const value = Number.parseInt(raw, 10);
16
+ return Number.isSafeInteger(value) ? value : undefined;
17
+ }
18
+ export function parseSchemaRef(raw) {
19
+ const atIndex = raw.indexOf('@');
20
+ if (atIndex === -1) {
21
+ return isValidSchemaId(raw) ? { id: raw } : undefined;
22
+ }
23
+ const id = raw.slice(0, atIndex);
24
+ const versionRaw = raw.slice(atIndex + 1);
25
+ if (!isValidSchemaId(id))
26
+ return undefined;
27
+ const version = parseSchemaVersion(versionRaw);
28
+ return version === undefined ? undefined : { id, version };
29
+ }
30
+ export function formatSchemaRef(id, version) {
31
+ return `${id}@${version}`;
32
+ }
@@ -0,0 +1,22 @@
1
+ import type { SchemaBundle, SchemaSummary } from '../client/schema-types.mjs';
2
+ export declare const DEFAULT_SCHEMAS_RELATIVE = ".local/agent-blackboard/schemas";
3
+ export interface LocalSchemaManifest {
4
+ revision: number;
5
+ pulledAt: string;
6
+ /** Normalized server base URL this cache was pulled from. */
7
+ source?: string;
8
+ /** SHA-256 digest of all version files so torn writes fail verification on read. */
9
+ bundleHash?: string;
10
+ schemas: Array<SchemaSummary & {
11
+ versions: number[];
12
+ }>;
13
+ }
14
+ /** Normalizes a server `baseUrl` into a canonical cache-origin key. */
15
+ export declare function normalizeRegistrySource(baseUrl: string): string;
16
+ export declare function resolveSchemasDir(cwd: string, env: NodeJS.ProcessEnv, explicitDir?: string): string;
17
+ export declare function readLocalManifest(dir: string): LocalSchemaManifest | undefined;
18
+ export declare function writeLocalBundle(dir: string, bundle: SchemaBundle, now?: () => Date, source?: string): {
19
+ schemaCount: number;
20
+ versionCount: number;
21
+ };
22
+ export declare function readLocalBundle(dir: string, expectedSource?: string): SchemaBundle | undefined;
@@ -0,0 +1,159 @@
1
+ import { createHash, randomUUID } from 'node:crypto';
2
+ import { mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
3
+ import { dirname, join, resolve } from 'node:path';
4
+ import { enclosingWorktreeRoot } from '../session-id/persist.mjs';
5
+ import { formatSchemaRef, isValidSchemaId } from './id.mjs';
6
+ export const DEFAULT_SCHEMAS_RELATIVE = '.local/agent-blackboard/schemas';
7
+ const MANIFEST_FILE = 'manifest.json';
8
+ const VERSIONS_DIR = 'versions';
9
+ const LATEST_DIR = 'latest';
10
+ /** Normalizes a server `baseUrl` into a canonical cache-origin key. */
11
+ export function normalizeRegistrySource(baseUrl) {
12
+ try {
13
+ const url = new URL(baseUrl);
14
+ return `${url.origin}${url.pathname.replace(/\/+$/, '')}`;
15
+ }
16
+ catch {
17
+ return baseUrl.replace(/\/+$/, '');
18
+ }
19
+ }
20
+ export function resolveSchemasDir(cwd, env, explicitDir) {
21
+ if (explicitDir)
22
+ return resolve(cwd, explicitDir);
23
+ const envDir = env.AGENT_BLACKBOARD_SCHEMAS_DIR?.trim();
24
+ if (envDir)
25
+ return resolve(cwd, envDir);
26
+ return join(enclosingWorktreeRoot(cwd), DEFAULT_SCHEMAS_RELATIVE);
27
+ }
28
+ function writeFileAtomic(targetPath, content) {
29
+ mkdirSync(dirname(targetPath), { recursive: true });
30
+ const temp = `${targetPath}.${process.pid}.${randomUUID()}.tmp`;
31
+ try {
32
+ writeFileSync(temp, content, { encoding: 'utf8', flag: 'wx', mode: 0o600 });
33
+ renameSync(temp, targetPath);
34
+ }
35
+ catch (error) {
36
+ rmSync(temp, { force: true });
37
+ throw error;
38
+ }
39
+ }
40
+ export function readLocalManifest(dir) {
41
+ try {
42
+ const raw = readFileSync(join(dir, MANIFEST_FILE), 'utf8');
43
+ const parsed = JSON.parse(raw);
44
+ if (typeof parsed === 'object' &&
45
+ parsed !== null &&
46
+ typeof parsed.revision === 'number' &&
47
+ Array.isArray(parsed.schemas)) {
48
+ return parsed;
49
+ }
50
+ return undefined;
51
+ }
52
+ catch {
53
+ return undefined;
54
+ }
55
+ }
56
+ function removeStaleJsonFiles(dir, keep) {
57
+ for (const name of readdirSync(dir)) {
58
+ if (name.endsWith('.json') && !keep.has(name)) {
59
+ rmSync(join(dir, name), { force: true });
60
+ }
61
+ }
62
+ }
63
+ export function writeLocalBundle(dir, bundle, now = () => new Date(), source) {
64
+ // Validate all ids and version numbers before writing any file so a bad bundle never leaves torn state.
65
+ for (const entry of bundle.schemas) {
66
+ if (!isValidSchemaId(entry.id)) {
67
+ throw new Error(`refusing to write unsafe schema id: ${entry.id}`);
68
+ }
69
+ for (const versionRecord of entry.versions) {
70
+ if (!Number.isSafeInteger(versionRecord.version) || versionRecord.version < 1) {
71
+ throw new Error(`refusing to write invalid schema version for ${entry.id}`);
72
+ }
73
+ }
74
+ }
75
+ const versionsDir = join(dir, VERSIONS_DIR);
76
+ const latestDir = join(dir, LATEST_DIR);
77
+ mkdirSync(versionsDir, { recursive: true });
78
+ mkdirSync(latestDir, { recursive: true });
79
+ const keepLatest = new Set();
80
+ const keepVersions = new Set();
81
+ let versionCount = 0;
82
+ const manifestSchemas = [];
83
+ const hash = createHash('sha256');
84
+ for (const entry of bundle.schemas) {
85
+ const versionNumbers = [];
86
+ for (const versionRecord of entry.versions) {
87
+ const fileName = `${formatSchemaRef(entry.id, versionRecord.version)}.json`;
88
+ const serialized = `${JSON.stringify(versionRecord, null, 2)}\n`;
89
+ keepVersions.add(fileName);
90
+ hash.update(`${fileName}\0${serialized}\0`);
91
+ writeFileAtomic(join(versionsDir, fileName), serialized);
92
+ versionNumbers.push(versionRecord.version);
93
+ versionCount += 1;
94
+ }
95
+ const latestRecord = entry.versions.find((v) => v.version === entry.latestVersion);
96
+ if (latestRecord) {
97
+ const latestFile = `${entry.id}.json`;
98
+ keepLatest.add(latestFile);
99
+ writeFileAtomic(join(latestDir, latestFile), `${JSON.stringify(latestRecord.schema, null, 2)}\n`);
100
+ }
101
+ const { versions: _omit, ...summary } = entry;
102
+ manifestSchemas.push({ ...summary, versions: versionNumbers });
103
+ }
104
+ removeStaleJsonFiles(versionsDir, keepVersions);
105
+ removeStaleJsonFiles(latestDir, keepLatest);
106
+ const manifest = {
107
+ revision: bundle.revision,
108
+ pulledAt: now().toISOString(),
109
+ ...(source === undefined ? {} : { source }),
110
+ bundleHash: hash.digest('hex'),
111
+ schemas: manifestSchemas,
112
+ };
113
+ writeFileAtomic(join(dir, MANIFEST_FILE), `${JSON.stringify(manifest, null, 2)}\n`);
114
+ return { schemaCount: bundle.schemas.length, versionCount };
115
+ }
116
+ function isPlainObject(value) {
117
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
118
+ }
119
+ function isValidVersionRecord(value, expectedId, expectedVersion) {
120
+ return (isPlainObject(value) &&
121
+ value.id === expectedId &&
122
+ value.version === expectedVersion &&
123
+ typeof value.ref === 'string' &&
124
+ isPlainObject(value.schema));
125
+ }
126
+ export function readLocalBundle(dir, expectedSource) {
127
+ const manifest = readLocalManifest(dir);
128
+ if (!manifest)
129
+ return undefined;
130
+ if (expectedSource !== undefined && manifest.source !== expectedSource)
131
+ return undefined;
132
+ const versionsDir = join(dir, VERSIONS_DIR);
133
+ const schemas = [];
134
+ const hash = createHash('sha256');
135
+ try {
136
+ for (const entry of manifest.schemas) {
137
+ if (!isValidSchemaId(entry.id) || !Array.isArray(entry.versions))
138
+ return undefined;
139
+ const versions = [];
140
+ for (const versionNum of entry.versions) {
141
+ const fileName = `${formatSchemaRef(entry.id, versionNum)}.json`;
142
+ const raw = readFileSync(join(versionsDir, fileName), 'utf8');
143
+ const parsed = JSON.parse(raw);
144
+ if (!isValidVersionRecord(parsed, entry.id, versionNum))
145
+ return undefined;
146
+ hash.update(`${fileName}\0${raw}\0`);
147
+ versions.push(parsed);
148
+ }
149
+ const { versions: _v, ...summary } = entry;
150
+ schemas.push({ ...summary, versions });
151
+ }
152
+ }
153
+ catch {
154
+ return undefined;
155
+ }
156
+ if (manifest.bundleHash !== hash.digest('hex'))
157
+ return undefined;
158
+ return { revision: manifest.revision, schemas };
159
+ }
@@ -0,0 +1,3 @@
1
+ import type { SchemaBundle, SchemaValidationResult } from '../client/schema-types.mjs';
2
+ export declare function validateAgainstBundle(bundle: SchemaBundle, schemaRefRaw: string, data: unknown): SchemaValidationResult;
3
+ export declare function validateAgainstLocalSchemas(dir: string, schemaRefRaw: string, data: unknown): SchemaValidationResult;
@@ -0,0 +1,70 @@
1
+ import { Ajv2020 } from 'ajv/dist/2020.js';
2
+ import addFormats from 'ajv-formats';
3
+ import { formatSchemaRef, parseSchemaRef } from './id.mjs';
4
+ import { readLocalBundle } from './local-store.mjs';
5
+ const registerFormats = addFormats;
6
+ export function validateAgainstBundle(bundle, schemaRefRaw, data) {
7
+ const parsed = parseSchemaRef(schemaRefRaw);
8
+ if (!parsed) {
9
+ throw new Error(`Invalid schema reference: ${schemaRefRaw}`);
10
+ }
11
+ const entry = bundle.schemas.find((s) => s.id === parsed.id);
12
+ if (!entry) {
13
+ throw new Error(`Schema not found in local copy: ${parsed.id}`);
14
+ }
15
+ if (entry.deprecatedAt !== null) {
16
+ throw new Error(`Schema is deprecated: ${entry.id}`);
17
+ }
18
+ const targetVersion = parsed.version ?? entry.latestVersion;
19
+ const targetRecord = entry.versions.find((v) => v.version === targetVersion);
20
+ if (!targetRecord) {
21
+ throw new Error(`Schema version not found in local copy: ${formatSchemaRef(parsed.id, targetVersion)}`);
22
+ }
23
+ const ajv = new Ajv2020({
24
+ strictSchema: true,
25
+ strictTypes: false,
26
+ strictRequired: false,
27
+ allErrors: true,
28
+ });
29
+ ajv.addKeyword('$anchor');
30
+ registerFormats(ajv);
31
+ const ref = formatSchemaRef(entry.id, targetRecord.version);
32
+ let validate;
33
+ try {
34
+ for (const schemaEntry of bundle.schemas) {
35
+ for (const ver of schemaEntry.versions) {
36
+ ajv.addSchema(structuredClone(ver.schema), formatSchemaRef(schemaEntry.id, ver.version));
37
+ }
38
+ const latest = schemaEntry.versions.find((v) => v.version === schemaEntry.latestVersion);
39
+ if (latest) {
40
+ ajv.addSchema(structuredClone(latest.schema), schemaEntry.id);
41
+ }
42
+ }
43
+ validate = ajv.getSchema(ref);
44
+ }
45
+ catch (error) {
46
+ throw new Error(`Local schema ${ref} failed to compile: ${error.message}`, {
47
+ cause: error,
48
+ });
49
+ }
50
+ if (validate.$async) {
51
+ throw new Error(`Local schema ${ref} uses unsupported $async validation`);
52
+ }
53
+ const valid = Boolean(validate(data));
54
+ const errors = valid
55
+ ? []
56
+ : validate.errors.map((err) => ({
57
+ instancePath: err.instancePath,
58
+ schemaPath: err.schemaPath,
59
+ keyword: err.keyword,
60
+ message: String(err.message),
61
+ }));
62
+ return { valid, schema: ref, revision: bundle.revision, errors };
63
+ }
64
+ export function validateAgainstLocalSchemas(dir, schemaRefRaw, data) {
65
+ const bundle = readLocalBundle(dir);
66
+ if (!bundle) {
67
+ throw new Error(`No valid local schema registry copy found in ${dir}. Run: agent-blackboard schemas pull`);
68
+ }
69
+ return validateAgainstBundle(bundle, schemaRefRaw, data);
70
+ }
@@ -1,5 +1,5 @@
1
1
  import { randomUUID } from 'node:crypto';
2
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
3
3
  import { dirname, join, resolve } from 'node:path';
4
4
  import { isValidSessionId, sanitizeSessionId } from './valid-id.mjs';
5
5
  /** Persisted-file locations, relative to a worktree root. Each holds one id and a newline. */
@@ -47,10 +47,23 @@ export function readPersistedSessionId(root, harness, options = {}) {
47
47
  return undefined;
48
48
  }
49
49
  }
50
+ /**
51
+ * Writes to a unique temp file beside the target and renames it into place, so a concurrent reader
52
+ * sees either the old or the new id, never a truncated file. `rename` replaces a symlink at the
53
+ * target instead of following it, and the `wx` flag refuses to follow one at the temp path.
54
+ */
50
55
  function writePersistFile(root, harness, sessionId) {
51
56
  const path = sessionPersistPath(root, harness);
52
57
  mkdirSync(dirname(path), { recursive: true });
53
- writeFileSync(path, `${sessionId}\n`, { encoding: 'utf8' });
58
+ const temp = `${path}.${process.pid}.${randomUUID()}.tmp`;
59
+ try {
60
+ writeFileSync(temp, `${sessionId}\n`, { encoding: 'utf8', flag: 'wx', mode: 0o600 });
61
+ renameSync(temp, path);
62
+ }
63
+ catch (err) {
64
+ rmSync(temp, { force: true });
65
+ throw err;
66
+ }
54
67
  }
55
68
  function tryWritePersistFile(root, harness, sessionId) {
56
69
  try {
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "agent-blackboard",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Client library, CLI, and MCP server for Agent Blackboard session entries.",
5
- "homepage": "https://github.com/jonathanong/agent-blackboard#readme",
5
+ "homepage": "https://github.com/jongleberry/agent-blackboard#readme",
6
6
  "bugs": {
7
- "url": "https://github.com/jonathanong/agent-blackboard/issues"
7
+ "url": "https://github.com/jongleberry/agent-blackboard/issues"
8
8
  },
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "git+https://github.com/jonathanong/agent-blackboard.git",
12
+ "url": "git+https://github.com/jongleberry/agent-blackboard.git",
13
13
  "directory": "packages/agent-blackboard"
14
14
  },
15
15
  "bin": {
@@ -33,7 +33,9 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "@modelcontextprotocol/sdk": "^1.32.1"
36
+ "@modelcontextprotocol/sdk": "^1.32.2",
37
+ "ajv": "8.20.0",
38
+ "ajv-formats": "3.0.1"
37
39
  },
38
40
  "engines": {
39
41
  "node": ">=24.0.0"