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
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # agent-blackboard
2
2
 
3
- Client library, CLI, and MCP server for [agent-blackboard](https://github.com/jonathanong/agent-blackboard).
3
+ Client library, CLI, and MCP server for [agent-blackboard](https://github.com/jongleberry/agent-blackboard).
4
4
  Requires Node 24+ and talks to a separately deployed HTTP service over `fetch`.
5
5
 
6
- See the complete [TypeScript API reference](https://github.com/jonathanong/agent-blackboard/blob/master/docs/typescript-api.md)
6
+ See the complete [TypeScript API reference](https://github.com/jongleberry/agent-blackboard/blob/master/docs/typescript-api.md)
7
7
  for the supported public surface and tooling integration details.
8
8
 
9
9
  ```sh
@@ -13,11 +13,12 @@ pnpm add agent-blackboard
13
13
  ## Library
14
14
 
15
15
  ```ts
16
- import { Auth, Entries, Sessions, Snapshots } from 'agent-blackboard'
16
+ import { Auth, Entries, Schemas, Sessions, Snapshots } from 'agent-blackboard'
17
17
 
18
18
  const config = { baseUrl, token }
19
19
  const sessions = new Sessions(config)
20
20
  const entries = new Entries(config)
21
+ const schemas = new Schemas(config)
21
22
  const snapshots = new Snapshots(config)
22
23
 
23
24
  await sessions.create({
@@ -36,9 +37,13 @@ await sessions.patch({ sessionId: 'worker-456', data: { branch: 'fix/retry' } })
36
37
 
37
38
  await entries.append({
38
39
  sessionId: 'worker-456',
40
+ schemaId: 'finding',
39
41
  data: { note: 'found a flaky retry' },
40
42
  })
41
43
 
44
+ const pull = await schemas.pull()
45
+ schemas.validateLocal('finding', { note: 'found a flaky retry' }, { dir: pull.dir })
46
+
42
47
  for await (const current of entries.get({ sessionId: 'worker-456' })) {
43
48
  console.log(current)
44
49
  }
@@ -64,7 +69,7 @@ await auth.createCredentials({ name: 'ci-bot' })
64
69
  ```
65
70
 
66
71
  Versions are caller-provided. Session ids and agent names are too, unless the caller opts into
67
- [session-id resolution](https://github.com/jonathanong/agent-blackboard/blob/main/docs/session-id-resolution.md)
72
+ [session-id resolution](https://github.com/jongleberry/agent-blackboard/blob/main/docs/session-id-resolution.md)
68
73
  (`resolveSessionIdentity`, or omitting them in the CLI/MCP). `parentSessionId` is required and
69
74
  nullable. The service generates `createdAt`/`lastEntryAt`/`archivedAt` timestamps.
70
75
  `Entries.get()` returns an `AsyncIterable<SessionEntry>` and uses incremental JSONL by default.
@@ -84,9 +89,18 @@ agent-blackboard sessions list
84
89
  agent-blackboard sessions list --inactive-for-hours 8
85
90
  agent-blackboard sessions get worker-456
86
91
  agent-blackboard append --session-id worker-456 '{"note":"investigating"}'
92
+ agent-blackboard append --session-id worker-456 --schema finding '{"title":"flaky retry"}'
87
93
  agent-blackboard append --session-id worker-456 --file findings.md
88
94
  agent-blackboard get --session-id worker-456 --format jsonl
89
95
  agent-blackboard sessions archive worker-456
96
+ agent-blackboard schemas pull
97
+ agent-blackboard schemas list
98
+ agent-blackboard schemas get finding
99
+ agent-blackboard schemas validate finding entry.json
100
+ agent-blackboard schemas put finding finding.schema.json --shadow
101
+ agent-blackboard schemas report finding@1
102
+ agent-blackboard schemas promote finding@1
103
+ agent-blackboard schemas remove finding
90
104
  agent-blackboard snapshot export --root-only --inactive-for-hours 8
91
105
  agent-blackboard snapshot partition --path /tmp/agent-blackboard-snapshot-<uuid>.jsonl \
92
106
  --cleanup-token <cleanup-token>
@@ -115,18 +129,21 @@ skill copy can drift.
115
129
  ## MCP
116
130
 
117
131
  The stdio MCP server exposes `session_create`, `session_ensure`, `session_search`, `session_patch`,
118
- `session_archive`, `entry_append`, `entry_get`, and `snapshot_export`. `snapshot_export` writes a
119
- private, read-only JSONL file and returns only its path, counts, checksum, and terminal manifest;
120
- it never puts snapshot records on the MCP connection. Every session and entry operation requires
121
- explicit session ids where applicable. Credential management remains CLI/admin-only.
132
+ `session_archive`, `entry_append` (with optional `schemaId`/`schemaVersion`), `entry_get`,
133
+ `snapshot_export`, `schema_list`, `schema_get`, `schema_pull`, and offline `schema_validate`.
134
+ `snapshot_export` writes a private, read-only JSONL file and returns only its path, counts,
135
+ checksum, and terminal manifest; it never puts snapshot records on the MCP connection. Every session
136
+ and entry operation requires explicit session ids where applicable. Credential management and schema
137
+ admin operations (`put`, `promote`, `report`, `remove`) remain CLI/admin-only.
122
138
 
123
139
  ## Configuration
124
140
 
125
- | Variable | Used by | Meaning |
126
- | ------------------------------ | --------------- | ---------------------------------- |
127
- | `AGENT_BLACKBOARD_URL` | CLI/MCP | Service base URL |
128
- | `AGENT_BLACKBOARD_TOKEN` | CLI/MCP | Client credential (`abb_sk_...`) |
129
- | `AGENT_BLACKBOARD_ADMIN_TOKEN` | CLI credentials | Admin credential (`abb_admin_...`) |
141
+ | Variable | Used by | Meaning |
142
+ | ------------------------------ | ------------------ | ---------------------------------------------- |
143
+ | `AGENT_BLACKBOARD_URL` | CLI/MCP | Service base URL |
144
+ | `AGENT_BLACKBOARD_TOKEN` | CLI/MCP | Client credential (`abb_sk_...`) |
145
+ | `AGENT_BLACKBOARD_ADMIN_TOKEN` | CLI admin commands | Admin credential (`abb_admin_...`) |
146
+ | `AGENT_BLACKBOARD_SCHEMAS_DIR` | client/CLI/MCP | Optional local schema cache directory override |
130
147
 
131
148
  Client and admin tokens are never interchangeable.
132
149
 
@@ -1,10 +1,12 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { extname } from 'node:path';
3
3
  import { appendEntry } from '../client/append.mjs';
4
+ import { parseSchemaRef } from '../schemas/id.mjs';
4
5
  import { parseArgs, stringFlag } from './args.mjs';
5
6
  import { clientConfigFromEnv } from './env.mjs';
6
7
  import { CliError } from './errors.mjs';
7
8
  import { writeLine } from './output.mjs';
9
+ import { createRevisionNotifier } from './revision-notice.mjs';
8
10
  import { cliSessionId, SESSION_BOOLEAN_FLAGS } from './session-resolution.mjs';
9
11
  async function readStdin(stdin) {
10
12
  const chunks = [];
@@ -53,12 +55,22 @@ export async function runAppend(argv, ctx) {
53
55
  throw new CliError('append requires a path after --file.');
54
56
  if (file && positional.length > 0)
55
57
  throw new CliError('append accepts either --file or positional JSON, not both.');
58
+ const schemaFlag = stringFlag(flags, 'schema');
59
+ if (flags.schema !== undefined && !schemaFlag) {
60
+ throw new CliError('append requires <id>[@<version>] after --schema.');
61
+ }
62
+ const parsedSchema = schemaFlag === undefined ? undefined : parseSchemaRef(schemaFlag);
63
+ if (schemaFlag !== undefined && !parsedSchema) {
64
+ throw new CliError(`Invalid --schema reference: ${schemaFlag}`);
65
+ }
56
66
  const data = file
57
67
  ? await readFileData(file)
58
68
  : parseJsonObject(positional[0] ?? (await readStdin(ctx.stdin)));
59
- const entry = await appendEntry(clientConfigFromEnv(ctx.env), {
69
+ const entry = await appendEntry(clientConfigFromEnv(ctx.env, createRevisionNotifier(ctx)), {
60
70
  sessionId,
61
71
  data,
72
+ ...(parsedSchema ? { schemaId: parsedSchema.id } : {}),
73
+ ...(parsedSchema?.version !== undefined ? { schemaVersion: parsedSchema.version } : {}),
62
74
  });
63
75
  writeLine(ctx.stdout, JSON.stringify(entry));
64
76
  }
@@ -1,5 +1,5 @@
1
1
  import type { ClientConfig } from '../client/types.mjs';
2
- /** Client config from env — used by session and entry commands. Never the admin token. */
3
- export declare function clientConfigFromEnv(env: NodeJS.ProcessEnv): ClientConfig;
4
- /** Admin config from env — used only by `credentials`. Never the client token. */
5
- export declare function adminConfigFromEnv(env: NodeJS.ProcessEnv): ClientConfig;
2
+ /** Client config from env — used by session, entry, and schema-read commands. Never the admin token. */
3
+ export declare function clientConfigFromEnv(env: NodeJS.ProcessEnv, onSchemaRevision?: (revision: number) => void): ClientConfig;
4
+ /** Admin config from env — used only by `credentials` and schema write commands. Never the client token. */
5
+ export declare function adminConfigFromEnv(env: NodeJS.ProcessEnv, onSchemaRevision?: (revision: number) => void): ClientConfig;
package/dist/cli/env.mjs CHANGED
@@ -1,21 +1,21 @@
1
1
  import { CliError } from './errors.mjs';
2
- /** Client config from env — used by session and entry commands. Never the admin token. */
3
- export function clientConfigFromEnv(env) {
2
+ /** Client config from env — used by session, entry, and schema-read commands. Never the admin token. */
3
+ export function clientConfigFromEnv(env, onSchemaRevision) {
4
4
  const baseUrl = env.AGENT_BLACKBOARD_URL;
5
5
  if (!baseUrl)
6
6
  throw new CliError('AGENT_BLACKBOARD_URL is not set.');
7
7
  const token = env.AGENT_BLACKBOARD_TOKEN;
8
8
  if (!token)
9
9
  throw new CliError('AGENT_BLACKBOARD_TOKEN is not set.');
10
- return { baseUrl, token };
10
+ return onSchemaRevision === undefined ? { baseUrl, token } : { baseUrl, token, onSchemaRevision };
11
11
  }
12
- /** Admin config from env — used only by `credentials`. Never the client token. */
13
- export function adminConfigFromEnv(env) {
12
+ /** Admin config from env — used only by `credentials` and schema write commands. Never the client token. */
13
+ export function adminConfigFromEnv(env, onSchemaRevision) {
14
14
  const baseUrl = env.AGENT_BLACKBOARD_URL;
15
15
  if (!baseUrl)
16
16
  throw new CliError('AGENT_BLACKBOARD_URL is not set.');
17
17
  const token = env.AGENT_BLACKBOARD_ADMIN_TOKEN;
18
18
  if (!token)
19
19
  throw new CliError('AGENT_BLACKBOARD_ADMIN_TOKEN is not set.');
20
- return { baseUrl, token };
20
+ return onSchemaRevision === undefined ? { baseUrl, token } : { baseUrl, token, onSchemaRevision };
21
21
  }
package/dist/cli/get.mjs CHANGED
@@ -2,6 +2,7 @@ import { getEntriesRaw } from '../client/stream.mjs';
2
2
  import { parseArgs } from './args.mjs';
3
3
  import { clientConfigFromEnv } from './env.mjs';
4
4
  import { CliError } from './errors.mjs';
5
+ import { createRevisionNotifier } from './revision-notice.mjs';
5
6
  import { cliSessionId, SESSION_BOOLEAN_FLAGS } from './session-resolution.mjs';
6
7
  const VALID_FORMATS = ['json', 'jsonl', 'markdown'];
7
8
  function parseFormat(value) {
@@ -15,7 +16,7 @@ function parseFormat(value) {
15
16
  export async function runGet(argv, ctx) {
16
17
  const { flags } = parseArgs(argv, SESSION_BOOLEAN_FLAGS);
17
18
  const sessionId = cliSessionId('get', flags, ctx);
18
- const response = await getEntriesRaw(clientConfigFromEnv(ctx.env), {
19
+ const response = await getEntriesRaw(clientConfigFromEnv(ctx.env, createRevisionNotifier(ctx)), {
19
20
  sessionId,
20
21
  format: parseFormat(flags.format),
21
22
  });
@@ -9,6 +9,7 @@ import { CliError } from './errors.mjs';
9
9
  import { clientConfigFromEnv } from './env.mjs';
10
10
  import { runGet } from './get.mjs';
11
11
  import { writeLine } from './output.mjs';
12
+ import { runSchemas } from './schemas.mjs';
12
13
  import { runSessions } from './sessions.mjs';
13
14
  import { runSnapshot } from './snapshot.mjs';
14
15
  import { USAGE } from './usage.mjs';
@@ -47,6 +48,9 @@ export async function runCli(argv, options = {}) {
47
48
  case 'snapshot':
48
49
  await runSnapshot(rest, ctx);
49
50
  break;
51
+ case 'schemas':
52
+ await runSchemas(rest, ctx);
53
+ break;
50
54
  case 'mcp':
51
55
  await (options.startMcpServer ?? startMcpServer)(clientConfigFromEnv(ctx.env), {
52
56
  env: ctx.env,
@@ -54,7 +58,7 @@ export async function runCli(argv, options = {}) {
54
58
  });
55
59
  break;
56
60
  default:
57
- throw new CliError(`Unknown command: ${command}. Expected one of: sessions, append, get, snapshot, credentials, mcp.`);
61
+ throw new CliError(`Unknown command: ${command}. Expected one of: sessions, append, get, snapshot, schemas, credentials, mcp.`);
58
62
  }
59
63
  return 0;
60
64
  }
@@ -0,0 +1,6 @@
1
+ import type { CliContext } from './context.mjs';
2
+ /**
3
+ * Returns an `onSchemaRevision` callback that warns once on `stderr` whenever
4
+ * the server advertises a schema registry revision newer than the local copy.
5
+ */
6
+ export declare function createRevisionNotifier(ctx: CliContext): (serverRevision: number) => void;
@@ -0,0 +1,19 @@
1
+ import { readLocalManifest, resolveSchemasDir } from '../schemas/local-store.mjs';
2
+ import { writeLine } from './output.mjs';
3
+ /**
4
+ * Returns an `onSchemaRevision` callback that warns once on `stderr` whenever
5
+ * the server advertises a schema registry revision newer than the local copy.
6
+ */
7
+ export function createRevisionNotifier(ctx) {
8
+ let warned = false;
9
+ return (serverRevision) => {
10
+ if (warned || serverRevision <= 0)
11
+ return;
12
+ const dir = resolveSchemasDir(ctx.cwd, ctx.env);
13
+ const localRevision = readLocalManifest(dir)?.revision ?? 0;
14
+ if (serverRevision > localRevision) {
15
+ warned = true;
16
+ writeLine(ctx.stderr, `Schema registry is out of date (local rev ${localRevision}, server rev ${serverRevision}). Run: agent-blackboard schemas pull`);
17
+ }
18
+ };
19
+ }
@@ -0,0 +1,3 @@
1
+ import type { CliContext } from './context.mjs';
2
+ export declare function runPromote(args: string[], ctx: CliContext): Promise<void>;
3
+ export declare function runReport(args: string[], ctx: CliContext): Promise<void>;
@@ -0,0 +1,47 @@
1
+ import { getSchemaReportRequest, promoteSchemaRequest } from '../client/schemas-client.mjs';
2
+ import { parseSchemaRef } from '../schemas/id.mjs';
3
+ import { parseArgs, stringFlag } from './args.mjs';
4
+ import { adminConfigFromEnv } from './env.mjs';
5
+ import { CliError } from './errors.mjs';
6
+ import { writeLine } from './output.mjs';
7
+ import { createRevisionNotifier } from './revision-notice.mjs';
8
+ const MAX_REPORT_LIMIT = 100;
9
+ function parseLimitFlag(flags) {
10
+ if (!Object.hasOwn(flags, 'limit'))
11
+ return undefined;
12
+ const raw = stringFlag(flags, 'limit');
13
+ if (!raw || !/^[1-9][0-9]*$/.test(raw)) {
14
+ throw new CliError(`schemas report --limit must be an integer between 1 and ${MAX_REPORT_LIMIT}.`);
15
+ }
16
+ const parsed = Number.parseInt(raw, 10);
17
+ if (!Number.isSafeInteger(parsed) || parsed > MAX_REPORT_LIMIT) {
18
+ throw new CliError(`schemas report --limit must be an integer between 1 and ${MAX_REPORT_LIMIT}.`);
19
+ }
20
+ return parsed;
21
+ }
22
+ export async function runPromote(args, ctx) {
23
+ const { positional } = parseArgs(args);
24
+ const [refRaw] = positional;
25
+ if (!refRaw)
26
+ throw new CliError('schemas promote requires <id>@<version>.');
27
+ const parsed = parseSchemaRef(refRaw);
28
+ if (!parsed || parsed.version === undefined) {
29
+ throw new CliError(`schemas promote requires an explicit version (<id>@<version>): ${refRaw}`);
30
+ }
31
+ const config = adminConfigFromEnv(ctx.env, createRevisionNotifier(ctx));
32
+ const result = await promoteSchemaRequest(config, parsed.id, parsed.version);
33
+ writeLine(ctx.stdout, JSON.stringify(result));
34
+ }
35
+ export async function runReport(args, ctx) {
36
+ const { positional, flags } = parseArgs(args);
37
+ const [refRaw] = positional;
38
+ if (!refRaw)
39
+ throw new CliError('schemas report requires <id>[@<version>].');
40
+ const parsed = parseSchemaRef(refRaw);
41
+ if (!parsed)
42
+ throw new CliError(`Invalid schema reference: ${refRaw}`);
43
+ const limit = parseLimitFlag(flags);
44
+ const config = adminConfigFromEnv(ctx.env, createRevisionNotifier(ctx));
45
+ const result = await getSchemaReportRequest(config, parsed.id, parsed.version, limit);
46
+ writeLine(ctx.stdout, JSON.stringify(result));
47
+ }
@@ -0,0 +1,2 @@
1
+ import type { CliContext } from './context.mjs';
2
+ export declare function runSchemas(argv: string[], ctx: CliContext): Promise<void>;
@@ -0,0 +1,168 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { deprecateSchemaRequest, fetchSchemaBundleRequest, getSchemaRequest, listSchemasRequest, putSchemaRequest, } from '../client/schemas-client.mjs';
3
+ import { isValidSchemaId, parseSchemaRef } from '../schemas/id.mjs';
4
+ import { normalizeRegistrySource, readLocalBundle, resolveSchemasDir, writeLocalBundle, } from '../schemas/local-store.mjs';
5
+ import { validateAgainstLocalSchemas } from '../schemas/validate.mjs';
6
+ import { parseArgs, stringFlag } from './args.mjs';
7
+ import { adminConfigFromEnv, clientConfigFromEnv } from './env.mjs';
8
+ import { CliError } from './errors.mjs';
9
+ import { writeLine } from './output.mjs';
10
+ import { createRevisionNotifier } from './revision-notice.mjs';
11
+ import { runPromote, runReport } from './schemas-shadow.mjs';
12
+ const PUT_BOOLEAN_FLAGS = new Set(['breaking', 'shadow']);
13
+ function optionalDirFlag(flags, subcommand) {
14
+ const dir = stringFlag(flags, 'dir');
15
+ if (Object.hasOwn(flags, 'dir') && !dir) {
16
+ throw new CliError(`schemas ${subcommand} requires a path after --dir.`);
17
+ }
18
+ return dir;
19
+ }
20
+ function parseBooleanFlag(flags, name) {
21
+ const raw = flags[name];
22
+ if (raw === undefined || raw === false || raw === 'false')
23
+ return false;
24
+ if (raw === true || raw === 'true')
25
+ return true;
26
+ throw new CliError(`schemas put --${name} must be a boolean flag.`);
27
+ }
28
+ async function readJsonObjectFile(filePath, label) {
29
+ let raw;
30
+ try {
31
+ raw = await readFile(filePath, 'utf8');
32
+ }
33
+ catch (error) {
34
+ throw new CliError(`could not read ${label} ${filePath}: ${String(error)}`);
35
+ }
36
+ let parsed;
37
+ try {
38
+ parsed = JSON.parse(raw);
39
+ }
40
+ catch {
41
+ throw new CliError(`${label} ${filePath} must contain valid JSON.`);
42
+ }
43
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
44
+ throw new CliError(`${label} ${filePath} must contain a JSON object.`);
45
+ }
46
+ return parsed;
47
+ }
48
+ async function runPull(args, ctx) {
49
+ const { flags } = parseArgs(args);
50
+ const dir = resolveSchemasDir(ctx.cwd, ctx.env, optionalDirFlag(flags, 'pull'));
51
+ const config = clientConfigFromEnv(ctx.env);
52
+ const source = normalizeRegistrySource(config.baseUrl);
53
+ // Validate the full local bundle and server origin before sending If-None-Match so corrupt or cross-server caches heal.
54
+ const local = readLocalBundle(dir, source);
55
+ const fetched = await fetchSchemaBundleRequest(config, local?.revision);
56
+ if (fetched.notModified) {
57
+ const versionCount = local
58
+ ? local.schemas.reduce((sum, item) => sum + item.versions.length, 0)
59
+ : 0;
60
+ const result = {
61
+ upToDate: true,
62
+ revision: fetched.revision,
63
+ schemaCount: local?.schemas.length ?? 0,
64
+ versionCount,
65
+ dir,
66
+ };
67
+ writeLine(ctx.stdout, JSON.stringify(result));
68
+ return;
69
+ }
70
+ const counts = writeLocalBundle(dir, fetched.bundle, undefined, source);
71
+ const result = {
72
+ upToDate: false,
73
+ revision: fetched.bundle.revision,
74
+ schemaCount: counts.schemaCount,
75
+ versionCount: counts.versionCount,
76
+ dir,
77
+ };
78
+ writeLine(ctx.stdout, JSON.stringify(result));
79
+ }
80
+ async function runPut(args, ctx) {
81
+ const { positional, flags } = parseArgs(args, PUT_BOOLEAN_FLAGS);
82
+ const [id, filePath] = positional;
83
+ if (!id || !filePath)
84
+ throw new CliError('schemas put requires <id> <file>.');
85
+ if (!isValidSchemaId(id))
86
+ throw new CliError(`Invalid schema id: ${id}`);
87
+ const breaking = parseBooleanFlag(flags, 'breaking');
88
+ const shadow = parseBooleanFlag(flags, 'shadow');
89
+ const schema = await readJsonObjectFile(filePath, 'schema file');
90
+ const config = adminConfigFromEnv(ctx.env, createRevisionNotifier(ctx));
91
+ const result = await putSchemaRequest(config, id, {
92
+ schema,
93
+ ...(breaking ? { breaking: true } : {}),
94
+ ...(shadow ? { shadow: true } : {}),
95
+ });
96
+ writeLine(ctx.stdout, JSON.stringify(result));
97
+ }
98
+ async function runRemove(args, ctx) {
99
+ const { positional } = parseArgs(args);
100
+ const [id] = positional;
101
+ if (!id)
102
+ throw new CliError('schemas remove requires <id>.');
103
+ if (!isValidSchemaId(id))
104
+ throw new CliError(`Invalid schema id: ${id}`);
105
+ const config = adminConfigFromEnv(ctx.env, createRevisionNotifier(ctx));
106
+ const result = await deprecateSchemaRequest(config, id);
107
+ writeLine(ctx.stdout, JSON.stringify(result));
108
+ }
109
+ async function runList(ctx) {
110
+ const config = clientConfigFromEnv(ctx.env, createRevisionNotifier(ctx));
111
+ writeLine(ctx.stdout, JSON.stringify(await listSchemasRequest(config)));
112
+ }
113
+ async function runGet(args, ctx) {
114
+ const { positional } = parseArgs(args);
115
+ const [refRaw] = positional;
116
+ if (!refRaw)
117
+ throw new CliError('schemas get requires <id>[@<version>].');
118
+ const parsed = parseSchemaRef(refRaw);
119
+ if (!parsed)
120
+ throw new CliError(`Invalid schema reference: ${refRaw}`);
121
+ const config = clientConfigFromEnv(ctx.env, createRevisionNotifier(ctx));
122
+ writeLine(ctx.stdout, JSON.stringify(await getSchemaRequest(config, parsed.id, parsed.version)));
123
+ }
124
+ async function runValidate(args, ctx) {
125
+ const { positional, flags } = parseArgs(args);
126
+ const [schemaRef, filePath] = positional;
127
+ if (!schemaRef || !filePath) {
128
+ throw new CliError('schemas validate requires <schema-id>[@<version>] <file>.');
129
+ }
130
+ const dir = resolveSchemasDir(ctx.cwd, ctx.env, optionalDirFlag(flags, 'validate'));
131
+ const payload = await readJsonObjectFile(filePath, 'entry file');
132
+ const result = validateAgainstLocalSchemas(dir, schemaRef, payload);
133
+ writeLine(ctx.stdout, JSON.stringify(result));
134
+ if (!result.valid) {
135
+ throw new CliError(`entry failed validation against ${result.schema}`);
136
+ }
137
+ }
138
+ export async function runSchemas(argv, ctx) {
139
+ const [sub, ...rest] = argv;
140
+ switch (sub) {
141
+ case 'pull':
142
+ await runPull(rest, ctx);
143
+ return;
144
+ case 'put':
145
+ await runPut(rest, ctx);
146
+ return;
147
+ case 'remove':
148
+ await runRemove(rest, ctx);
149
+ return;
150
+ case 'list':
151
+ await runList(ctx);
152
+ return;
153
+ case 'get':
154
+ await runGet(rest, ctx);
155
+ return;
156
+ case 'validate':
157
+ await runValidate(rest, ctx);
158
+ return;
159
+ case 'promote':
160
+ await runPromote(rest, ctx);
161
+ return;
162
+ case 'report':
163
+ await runReport(rest, ctx);
164
+ return;
165
+ default:
166
+ throw new CliError(`Unknown schemas subcommand: ${sub ?? '(none)'}. Expected one of: pull, put, promote, report, remove, list, get, validate.`);
167
+ }
168
+ }
@@ -3,6 +3,7 @@ import { parseArgs, stringFlag } from './args.mjs';
3
3
  import { clientConfigFromEnv } from './env.mjs';
4
4
  import { CliError } from './errors.mjs';
5
5
  import { writeLine } from './output.mjs';
6
+ import { createRevisionNotifier } from './revision-notice.mjs';
6
7
  import { cliSessionIdentity, SESSION_BOOLEAN_FLAGS } from './session-resolution.mjs';
7
8
  /**
8
9
  * Shared by `create` and `ensure`, which take identical flags. A missing `<session-id>` or
@@ -30,7 +31,7 @@ function parseCreateSessionInput(subcommand, positional, flags, ctx) {
30
31
  export async function runSessions(argv, ctx) {
31
32
  const [subcommand, ...rest] = argv;
32
33
  const { positional, flags } = parseArgs(rest, SESSION_BOOLEAN_FLAGS);
33
- const sessions = new Sessions(clientConfigFromEnv(ctx.env));
34
+ const sessions = new Sessions(clientConfigFromEnv(ctx.env, createRevisionNotifier(ctx)));
34
35
  if (subcommand === 'create') {
35
36
  const input = parseCreateSessionInput('create', positional, flags, ctx);
36
37
  writeLine(ctx.stdout, JSON.stringify(await sessions.create(input)));
@@ -6,6 +6,7 @@ import { clientConfigFromEnv } from './env.mjs';
6
6
  import { CliError } from './errors.mjs';
7
7
  import { parseDataArrayContains } from './data-array-contains.mjs';
8
8
  import { writeLine } from './output.mjs';
9
+ import { createRevisionNotifier } from './revision-notice.mjs';
9
10
  import { partitionCounts } from './snapshot-partition-options.mjs';
10
11
  const PARTITION_FLAGS = [
11
12
  'path',
@@ -167,7 +168,7 @@ export async function runSnapshot(argv, ctx) {
167
168
  throw new CliError('snapshot export accepts flags only.');
168
169
  const path = optionalString(flags, 'path');
169
170
  const selection = selectionFrom(flags);
170
- const result = await new Snapshots(clientConfigFromEnv(ctx.env)).export({
171
+ const result = await new Snapshots(clientConfigFromEnv(ctx.env, createRevisionNotifier(ctx))).export({
171
172
  ...(path === undefined ? {} : { path }),
172
173
  selection,
173
174
  });
@@ -1 +1 @@
1
- export declare const USAGE = "agent-blackboard \u2014 an entry stream for autonomous agents\n\nUsage:\n agent-blackboard sessions create [<id>] [--agent <name>] --version <version> [--parent-session-id <id>]\n agent-blackboard sessions ensure [<id>] [--agent <name>] --version <version> [--parent-session-id <id>]\n agent-blackboard sessions list [--archived true|false] [--inactive-for-hours <hours>]\n agent-blackboard sessions get <id>\n agent-blackboard sessions patch <id> --data <json>\n agent-blackboard sessions archive <id>\n agent-blackboard append [--session-id <id>] <json>\n agent-blackboard append [--session-id <id>] --file <json|markdown|text>\n agent-blackboard get [--session-id <id>] [--format json|jsonl|markdown]\n agent-blackboard snapshot export [--path <absolute-path>] [--agent <name>] [--version <version>]\n [--parent-session-id <id>|--root-only] [--data <json>] [--inactive-for-hours <hours>]\n agent-blackboard snapshot partition --path <generated-snapshot> --cleanup-token <token> [--max-sessions <count>]\n [--max-bytes <bytes>] [--checksum <sha256>] [--sessions <count> --entries <count> --records <count> --bytes <count>]\n agent-blackboard snapshot cleanup [--path <generated-snapshot>] [--directory <generated-partition-directory>] --cleanup-token <token>\n agent-blackboard credentials <subcommand>\n agent-blackboard mcp\n\nOmitted session ids and agents resolve from the harness environment (CLAUDE_CODE_SESSION_ID,\nCODEX_THREAD_ID, CURSOR_SESSION_ID, GROK_SESSION_ID) or <worktree>/.local/<harness>-session-id.\nInteractive root Codex: --root-codex creates or reuses the worktree id; --new-root-codex-session rotates it.\n\nEnv:\n AGENT_BLACKBOARD_URL Server base URL\n AGENT_BLACKBOARD_TOKEN Client credential\n AGENT_BLACKBOARD_ADMIN_TOKEN Admin credential\n";
1
+ export declare const USAGE = "agent-blackboard \u2014 an entry stream for autonomous agents\n\nUsage:\n agent-blackboard sessions create [<id>] [--agent <name>] --version <version> [--parent-session-id <id>]\n agent-blackboard sessions ensure [<id>] [--agent <name>] --version <version> [--parent-session-id <id>]\n agent-blackboard sessions list [--archived true|false] [--inactive-for-hours <hours>]\n agent-blackboard sessions get <id>\n agent-blackboard sessions patch <id> --data <json>\n agent-blackboard sessions archive <id>\n agent-blackboard append [--session-id <id>] [--schema <id>[@<version>]] <json>\n agent-blackboard append [--session-id <id>] [--schema <id>[@<version>]] --file <json|markdown|text>\n agent-blackboard get [--session-id <id>] [--format json|jsonl|markdown]\n agent-blackboard snapshot export [--path <absolute-path>] [--agent <name>] [--version <version>]\n [--parent-session-id <id>|--root-only] [--data <json>] [--inactive-for-hours <hours>]\n agent-blackboard snapshot partition --path <generated-snapshot> --cleanup-token <token> [--max-sessions <count>]\n [--max-bytes <bytes>] [--checksum <sha256>] [--sessions <count> --entries <count> --records <count> --bytes <count>]\n agent-blackboard snapshot cleanup [--path <generated-snapshot>] [--directory <generated-partition-directory>] --cleanup-token <token>\n agent-blackboard schemas pull [--dir <path>]\n agent-blackboard schemas put <id> <file> [--breaking] [--shadow]\n agent-blackboard schemas promote <id>@<version>\n agent-blackboard schemas report <id>[@<version>] [--limit <n>]\n agent-blackboard schemas remove <id>\n agent-blackboard schemas list\n agent-blackboard schemas get <id>[@<version>]\n agent-blackboard schemas validate <id>[@<version>] <file> [--dir <path>]\n agent-blackboard credentials <subcommand>\n agent-blackboard mcp\n\nOmitted session ids and agents resolve from the harness environment (CLAUDE_CODE_SESSION_ID,\nCODEX_THREAD_ID, CURSOR_SESSION_ID, GROK_SESSION_ID) or <worktree>/.local/<harness>-session-id.\nInteractive root Codex: --root-codex creates or reuses the worktree id; --new-root-codex-session rotates it.\n\nEnv:\n AGENT_BLACKBOARD_URL Server base URL\n AGENT_BLACKBOARD_TOKEN Client credential\n AGENT_BLACKBOARD_ADMIN_TOKEN Admin credential\n AGENT_BLACKBOARD_SCHEMAS_DIR Optional local schema cache directory\n";
@@ -7,14 +7,22 @@ Usage:
7
7
  agent-blackboard sessions get <id>
8
8
  agent-blackboard sessions patch <id> --data <json>
9
9
  agent-blackboard sessions archive <id>
10
- agent-blackboard append [--session-id <id>] <json>
11
- agent-blackboard append [--session-id <id>] --file <json|markdown|text>
10
+ agent-blackboard append [--session-id <id>] [--schema <id>[@<version>]] <json>
11
+ agent-blackboard append [--session-id <id>] [--schema <id>[@<version>]] --file <json|markdown|text>
12
12
  agent-blackboard get [--session-id <id>] [--format json|jsonl|markdown]
13
13
  agent-blackboard snapshot export [--path <absolute-path>] [--agent <name>] [--version <version>]
14
14
  [--parent-session-id <id>|--root-only] [--data <json>] [--inactive-for-hours <hours>]
15
15
  agent-blackboard snapshot partition --path <generated-snapshot> --cleanup-token <token> [--max-sessions <count>]
16
16
  [--max-bytes <bytes>] [--checksum <sha256>] [--sessions <count> --entries <count> --records <count> --bytes <count>]
17
17
  agent-blackboard snapshot cleanup [--path <generated-snapshot>] [--directory <generated-partition-directory>] --cleanup-token <token>
18
+ agent-blackboard schemas pull [--dir <path>]
19
+ agent-blackboard schemas put <id> <file> [--breaking] [--shadow]
20
+ agent-blackboard schemas promote <id>@<version>
21
+ agent-blackboard schemas report <id>[@<version>] [--limit <n>]
22
+ agent-blackboard schemas remove <id>
23
+ agent-blackboard schemas list
24
+ agent-blackboard schemas get <id>[@<version>]
25
+ agent-blackboard schemas validate <id>[@<version>] <file> [--dir <path>]
18
26
  agent-blackboard credentials <subcommand>
19
27
  agent-blackboard mcp
20
28
 
@@ -26,4 +34,5 @@ Env:
26
34
  AGENT_BLACKBOARD_URL Server base URL
27
35
  AGENT_BLACKBOARD_TOKEN Client credential
28
36
  AGENT_BLACKBOARD_ADMIN_TOKEN Admin credential
37
+ AGENT_BLACKBOARD_SCHEMAS_DIR Optional local schema cache directory
29
38
  `;
@@ -1,2 +1,2 @@
1
- import type { AppendEntryInput, ClientConfig, SessionEntry } from './types.mjs';
2
- export declare function appendEntry(config: ClientConfig, input: AppendEntryInput): Promise<SessionEntry>;
1
+ import type { AppendEntryInput, AppendEntryResult, ClientConfig } from './types.mjs';
2
+ export declare function appendEntry(config: ClientConfig, input: AppendEntryInput): Promise<AppendEntryResult>;
@@ -4,6 +4,10 @@ export async function appendEntry(config, input) {
4
4
  return requestJson(config, `/sessions/${encodeURIComponent(input.sessionId)}/entries`, {
5
5
  method: 'POST',
6
6
  headers: JSON_HEADERS,
7
- body: JSON.stringify({ data: input.data }),
7
+ body: JSON.stringify({
8
+ data: input.data,
9
+ ...(input.schemaId !== undefined ? { schemaId: input.schemaId } : {}),
10
+ ...(input.schemaVersion !== undefined ? { schemaVersion: input.schemaVersion } : {}),
11
+ }),
8
12
  });
9
13
  }
@@ -1,7 +1,7 @@
1
- import type { AppendEntryInput, ClientConfig, GetEntriesQuery, SessionEntry } from './types.mjs';
1
+ import type { AppendEntryInput, AppendEntryResult, ClientConfig, GetEntriesQuery, SessionEntry } from './types.mjs';
2
2
  export declare class Entries {
3
3
  #private;
4
4
  constructor(config: ClientConfig);
5
- append(input: AppendEntryInput): Promise<SessionEntry>;
5
+ append(input: AppendEntryInput): Promise<AppendEntryResult>;
6
6
  get(query: GetEntriesQuery): AsyncIterable<SessionEntry>;
7
7
  }
@@ -17,6 +17,8 @@ interface RequestOptions {
17
17
  * body streamed (not buffered) should read `response.body` directly.
18
18
  */
19
19
  export declare function rawRequest(config: ClientConfig, path: string, options: RequestOptions): Promise<Response>;
20
+ /** Issues an authenticated GET that treats HTTP 304 Not Modified as a valid response. */
21
+ export declare function rawConditionalGet(config: ClientConfig, path: string, options: Omit<RequestOptions, 'method'>): Promise<Response>;
20
22
  /** Issues an authenticated HTTP request and parses the response body as JSON. */
21
23
  export declare function requestJson<T>(config: ClientConfig, path: string, options: RequestOptions): Promise<T>;
22
24
  export {};