agent-blackboard 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export declare function parseDataArrayContains(raw: string | undefined, command: string): Record<string, string> | undefined;
@@ -0,0 +1,19 @@
1
+ import { CliError } from './errors.mjs';
2
+ export function parseDataArrayContains(raw, command) {
3
+ if (raw === undefined)
4
+ return undefined;
5
+ try {
6
+ const parsed = JSON.parse(raw);
7
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
8
+ throw new Error();
9
+ const entries = Object.entries(parsed);
10
+ if (entries.length === 0 ||
11
+ entries.some(([key, value]) => key.length === 0 || typeof value !== 'string' || value.length === 0)) {
12
+ throw new Error();
13
+ }
14
+ return parsed;
15
+ }
16
+ catch {
17
+ throw new CliError(`${command} must be a JSON object with string values.`);
18
+ }
19
+ }
@@ -53,9 +53,30 @@ export async function runSessions(argv, ctx) {
53
53
  if (limit !== undefined && (!Number.isInteger(limit) || limit < 1)) {
54
54
  throw new CliError('sessions list --limit must be a positive integer.');
55
55
  }
56
+ const dataArrayContainsFlag = stringFlag(flags, 'data-array-contains');
57
+ let dataArrayContains;
58
+ if (Object.hasOwn(flags, 'data-array-contains') && dataArrayContainsFlag === undefined) {
59
+ throw new CliError('sessions list --data-array-contains requires JSON.');
60
+ }
61
+ if (dataArrayContainsFlag !== undefined) {
62
+ try {
63
+ const parsed = JSON.parse(dataArrayContainsFlag);
64
+ if (!parsed ||
65
+ typeof parsed !== 'object' ||
66
+ Array.isArray(parsed) ||
67
+ Object.keys(parsed).length === 0 ||
68
+ Object.entries(parsed).some(([key, value]) => key.length === 0 || typeof value !== 'string' || value.length === 0))
69
+ throw new Error();
70
+ dataArrayContains = parsed;
71
+ }
72
+ catch {
73
+ throw new CliError('sessions list --data-array-contains must be a JSON object with string values.');
74
+ }
75
+ }
56
76
  const query = {
57
77
  ...(archivedFlag === undefined ? {} : { archived: archivedFlag === 'true' }),
58
78
  ...(inactiveForHours === undefined ? {} : { inactiveForHours }),
79
+ ...(dataArrayContains === undefined ? {} : { dataArrayContains }),
59
80
  };
60
81
  if (limit !== undefined) {
61
82
  // `--limit` fetches a single bounded page instead of the full drain below —
@@ -4,6 +4,7 @@ import { partitionSnapshot } from '../client/snapshot-partitions.mjs';
4
4
  import { parseArgs, stringFlag } from './args.mjs';
5
5
  import { clientConfigFromEnv } from './env.mjs';
6
6
  import { CliError } from './errors.mjs';
7
+ import { parseDataArrayContains } from './data-array-contains.mjs';
7
8
  import { writeLine } from './output.mjs';
8
9
  import { partitionCounts } from './snapshot-partition-options.mjs';
9
10
  const PARTITION_FLAGS = [
@@ -72,12 +73,14 @@ function selectionFrom(flags) {
72
73
  const agent = optionalString(flags, 'agent');
73
74
  const version = optionalString(flags, 'version');
74
75
  const data = dataSelection(flags);
76
+ const dataArrayContains = parseDataArrayContains(optionalString(flags, 'data-array-contains'), 'snapshot export --data-array-contains');
75
77
  const inactiveForHours = inactivitySelection(flags);
76
78
  return {
77
79
  ...(agent === undefined ? {} : { agent }),
78
80
  ...(version === undefined ? {} : { version }),
79
81
  ...parentSelection(flags),
80
82
  ...(data === undefined ? {} : { data }),
83
+ ...(dataArrayContains === undefined ? {} : { dataArrayContains }),
81
84
  ...(inactiveForHours === undefined ? {} : { inactiveForHours }),
82
85
  };
83
86
  }
@@ -150,7 +153,16 @@ export async function runSnapshot(argv, ctx) {
150
153
  }
151
154
  if (subcommand !== 'export')
152
155
  throw new CliError('snapshot requires: export, partition, or cleanup.');
153
- only(flags, ['path', 'agent', 'version', 'parent-session-id', 'root-only', 'data', 'inactive-for-hours'], 'snapshot export');
156
+ only(flags, [
157
+ 'path',
158
+ 'agent',
159
+ 'version',
160
+ 'parent-session-id',
161
+ 'root-only',
162
+ 'data',
163
+ 'data-array-contains',
164
+ 'inactive-for-hours',
165
+ ], 'snapshot export');
154
166
  if (positional.length > 0)
155
167
  throw new CliError('snapshot export accepts flags only.');
156
168
  const path = optionalString(flags, 'path');
@@ -28,6 +28,8 @@ function buildListSessionsQuery(query) {
28
28
  }
29
29
  if (query.data !== undefined)
30
30
  wire.data = JSON.stringify(query.data);
31
+ if (query.dataArrayContains !== undefined)
32
+ wire.dataArrayContains = JSON.stringify(query.dataArrayContains);
31
33
  if (query.inactiveForHours !== undefined) {
32
34
  wire.inactiveForHours = String(query.inactiveForHours);
33
35
  }
@@ -21,6 +21,11 @@ function isSelection(value) {
21
21
  return false;
22
22
  if (value.data !== undefined && !isObject(value.data))
23
23
  return false;
24
+ if (value.dataArrayContains !== undefined &&
25
+ (!isObject(value.dataArrayContains) ||
26
+ Object.keys(value.dataArrayContains).length === 0 ||
27
+ Object.entries(value.dataArrayContains).some(([key, item]) => key.length === 0 || typeof item !== 'string' || item.length === 0)))
28
+ return false;
24
29
  return (value.inactiveForHours === undefined ||
25
30
  (typeof value.inactiveForHours === 'number' &&
26
31
  Number.isFinite(value.inactiveForHours) &&
@@ -18,6 +18,8 @@ function queryFor(selection = {}) {
18
18
  query.parentSessionId = selection.parentSessionId ?? '';
19
19
  if (selection.data !== undefined)
20
20
  query.data = JSON.stringify(selection.data);
21
+ if (selection.dataArrayContains !== undefined)
22
+ query.dataArrayContains = JSON.stringify(selection.dataArrayContains);
21
23
  if (selection.inactiveForHours !== undefined)
22
24
  query.inactiveForHours = String(selection.inactiveForHours);
23
25
  return query;
@@ -52,6 +52,7 @@ export interface ListSessionsQuery {
52
52
  version?: string;
53
53
  parentSessionId?: string | null;
54
54
  data?: Record<string, unknown>;
55
+ dataArrayContains?: Record<string, string>;
55
56
  inactiveForHours?: number;
56
57
  limit?: number;
57
58
  cursor?: string;
@@ -88,6 +89,7 @@ export interface SnapshotSelection {
88
89
  version?: string;
89
90
  parentSessionId?: string | null;
90
91
  data?: Record<string, unknown>;
92
+ dataArrayContains?: Record<string, string>;
91
93
  inactiveForHours?: number;
92
94
  }
93
95
  export interface SnapshotCounts {
@@ -2,6 +2,31 @@ const SESSION_ID = {
2
2
  type: 'string',
3
3
  description: 'Caller-supplied session id. Never inferred or generated.',
4
4
  };
5
+ // Keep all four hints explicit so clients do not rely on protocol defaults.
6
+ const READ_ONLY = {
7
+ readOnlyHint: true,
8
+ destructiveHint: false,
9
+ idempotentHint: true,
10
+ openWorldHint: false,
11
+ };
12
+ const ADDITIVE = {
13
+ readOnlyHint: false,
14
+ destructiveHint: false,
15
+ idempotentHint: false,
16
+ openWorldHint: false,
17
+ };
18
+ const IDEMPOTENT_ADDITIVE = {
19
+ readOnlyHint: false,
20
+ destructiveHint: false,
21
+ idempotentHint: true,
22
+ openWorldHint: false,
23
+ };
24
+ const MUTATING = {
25
+ readOnlyHint: false,
26
+ destructiveHint: true,
27
+ idempotentHint: true,
28
+ openWorldHint: false,
29
+ };
5
30
  export const ENTRY_TOOLS = [
6
31
  {
7
32
  name: 'snapshot_export',
@@ -18,13 +43,15 @@ export const ENTRY_TOOLS = [
18
43
  description: 'Exact parent id; null selects root sessions.',
19
44
  },
20
45
  data: { type: 'object', description: 'Top-level session data fields to match exactly.' },
46
+ dataArrayContains: { type: 'object', description: 'Exact string membership in arrays.' },
21
47
  inactiveForHours: {
22
48
  type: 'number',
23
49
  exclusiveMinimum: 0,
24
- description: 'Only sessions inactive for this many hours.',
50
+ description: 'Only sessions inactive for this many hours (createdAt if no entries).',
25
51
  },
26
52
  },
27
53
  },
54
+ annotations: ADDITIVE,
28
55
  },
29
56
  {
30
57
  name: 'session_create',
@@ -42,6 +69,7 @@ export const ENTRY_TOOLS = [
42
69
  },
43
70
  required: ['sessionId', 'parentSessionId', 'agent', 'version'],
44
71
  },
72
+ annotations: ADDITIVE,
45
73
  },
46
74
  {
47
75
  name: 'session_ensure',
@@ -60,6 +88,7 @@ export const ENTRY_TOOLS = [
60
88
  },
61
89
  required: ['sessionId', 'parentSessionId', 'agent', 'version'],
62
90
  },
91
+ annotations: IDEMPOTENT_ADDITIVE,
63
92
  },
64
93
  {
65
94
  name: 'session_search',
@@ -85,10 +114,11 @@ export const ENTRY_TOOLS = [
85
114
  type: 'object',
86
115
  description: 'Top-level data fields whose JSON values must match exactly.',
87
116
  },
117
+ dataArrayContains: { type: 'object', description: 'Exact string membership in arrays.' },
88
118
  inactiveForHours: {
89
119
  type: 'number',
90
120
  exclusiveMinimum: 0,
91
- description: 'Matches sessions whose last entry is strictly older than this many hours; sessions without entries do not match.',
121
+ description: 'Matches sessions whose last entry (or createdAt, without entries) is strictly older than this many hours.',
92
122
  },
93
123
  limit: {
94
124
  type: 'integer',
@@ -102,6 +132,7 @@ export const ENTRY_TOOLS = [
102
132
  },
103
133
  },
104
134
  },
135
+ annotations: READ_ONLY,
105
136
  },
106
137
  {
107
138
  name: 'session_patch',
@@ -114,6 +145,7 @@ export const ENTRY_TOOLS = [
114
145
  },
115
146
  required: ['sessionId', 'data'],
116
147
  },
148
+ annotations: MUTATING,
117
149
  },
118
150
  {
119
151
  name: 'session_archive',
@@ -123,6 +155,7 @@ export const ENTRY_TOOLS = [
123
155
  properties: { sessionId: SESSION_ID },
124
156
  required: ['sessionId'],
125
157
  },
158
+ annotations: MUTATING,
126
159
  },
127
160
  {
128
161
  name: 'entry_append',
@@ -135,6 +168,7 @@ export const ENTRY_TOOLS = [
135
168
  },
136
169
  required: ['sessionId', 'data'],
137
170
  },
171
+ annotations: ADDITIVE,
138
172
  },
139
173
  {
140
174
  name: 'entry_get',
@@ -147,5 +181,6 @@ export const ENTRY_TOOLS = [
147
181
  },
148
182
  required: ['sessionId'],
149
183
  },
184
+ annotations: READ_ONLY,
150
185
  },
151
186
  ];
@@ -18,21 +18,38 @@ function parseSessionSearchArgs(args) {
18
18
  agent: args.agent === undefined ? undefined : requiredString(args.agent, 'agent'),
19
19
  version: args.version === undefined ? undefined : requiredString(args.version, 'version'),
20
20
  data: args.data === undefined ? undefined : expectObject(args.data, 'data'),
21
+ dataArrayContains: args.dataArrayContains === undefined
22
+ ? undefined
23
+ : parseDataArrayContains(args.dataArrayContains),
21
24
  inactiveForHours: optionalPositiveNumber(args.inactiveForHours, 'inactiveForHours'),
22
25
  };
23
26
  }
27
+ function parseDataArrayContains(value) {
28
+ const object = expectObject(value, 'dataArrayContains');
29
+ if (Object.keys(object).length === 0 ||
30
+ Object.entries(object).some(([key, item]) => key.length === 0 || typeof item !== 'string' || item.length === 0)) {
31
+ throw new Error('"dataArrayContains" must contain only string values.');
32
+ }
33
+ return object;
34
+ }
24
35
  function matchesData(session, data) {
25
36
  if (data === undefined)
26
37
  return true;
27
38
  return Object.entries(data).every(([key, value]) => isDeepStrictEqual(session.data[key], value));
28
39
  }
40
+ function matchesDataArrayContains(session, data) {
41
+ if (data === undefined)
42
+ return true;
43
+ return Object.entries(data).every(([key, value]) => {
44
+ const candidate = session.data[key];
45
+ return Array.isArray(candidate) && candidate.includes(value);
46
+ });
47
+ }
29
48
  function isInactiveFor(session, hours, now) {
30
49
  if (hours === undefined)
31
50
  return true;
32
- if (session.lastEntryAt === null)
33
- return false;
34
51
  const cutoff = now.getTime() - hours * 60 * 60 * 1000;
35
- return Date.parse(session.lastEntryAt) < cutoff;
52
+ return Date.parse(session.lastEntryAt ?? session.createdAt) < cutoff;
36
53
  }
37
54
  /** Whether a single directly-fetched session satisfies every supplied `session_search` filter. */
38
55
  function matchesDirectSession(session, parsed, now) {
@@ -44,7 +61,9 @@ function matchesDirectSession(session, parsed, now) {
44
61
  return false;
45
62
  if (parsed.version !== undefined && session.version !== parsed.version)
46
63
  return false;
47
- return matchesData(session, parsed.data) && isInactiveFor(session, parsed.inactiveForHours, now);
64
+ return (matchesData(session, parsed.data) &&
65
+ matchesDataArrayContains(session, parsed.dataArrayContains) &&
66
+ isInactiveFor(session, parsed.inactiveForHours, now));
48
67
  }
49
68
  /**
50
69
  * `sessionId` is not a server-side `ListSessionsQuery` filter (on DynamoDB that would be a PK
@@ -80,6 +99,8 @@ export async function handleSessionSearch(args, config, now = new Date()) {
80
99
  query.version = parsed.version;
81
100
  if (parsed.data !== undefined)
82
101
  query.data = parsed.data;
102
+ if (parsed.dataArrayContains !== undefined)
103
+ query.dataArrayContains = parsed.dataArrayContains;
83
104
  if (parsed.inactiveForHours !== undefined)
84
105
  query.inactiveForHours = parsed.inactiveForHours;
85
106
  if (parsed.limit !== undefined)
@@ -7,6 +7,14 @@ function parentSessionId(value) {
7
7
  }
8
8
  return id;
9
9
  }
10
+ function dataArrayContains(value) {
11
+ const object = expectObject(value, 'dataArrayContains');
12
+ if (Object.keys(object).length === 0 ||
13
+ Object.entries(object).some(([key, item]) => key.length === 0 || typeof item !== 'string' || item.length === 0)) {
14
+ throw new Error('"dataArrayContains" must contain only string values.');
15
+ }
16
+ return object;
17
+ }
10
18
  function selectionFrom(args) {
11
19
  const hasParent = Object.hasOwn(args, 'parentSessionId');
12
20
  return {
@@ -14,6 +22,9 @@ function selectionFrom(args) {
14
22
  ...(args.version === undefined ? {} : { version: requiredString(args.version, 'version') }),
15
23
  ...(hasParent ? { parentSessionId: parentSessionId(args.parentSessionId) } : {}),
16
24
  ...(args.data === undefined ? {} : { data: expectObject(args.data, 'data') }),
25
+ ...(args.dataArrayContains === undefined
26
+ ? {}
27
+ : { dataArrayContains: dataArrayContains(args.dataArrayContains) }),
17
28
  ...(args.inactiveForHours === undefined
18
29
  ? {}
19
30
  : { inactiveForHours: optionalPositiveNumber(args.inactiveForHours, 'inactiveForHours') }),
@@ -2,7 +2,7 @@
2
2
  "mcpServers": {
3
3
  "agent-blackboard": {
4
4
  "command": "npx",
5
- "args": ["-y", "agent-blackboard@0.5.0", "mcp"],
5
+ "args": ["-y", "agent-blackboard@0.6.1", "mcp"],
6
6
  "env": {
7
7
  "AGENT_BLACKBOARD_URL": "${AGENT_BLACKBOARD_URL}",
8
8
  "AGENT_BLACKBOARD_TOKEN": "${AGENT_BLACKBOARD_TOKEN}"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-blackboard",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "A session-scoped entry stream for autonomous agents working unmonitored, for Codex.",
5
5
  "author": {
6
6
  "name": "Jonathan Ong",
@@ -12,6 +12,7 @@
12
12
  "license": "MIT",
13
13
  "keywords": ["entries", "agent", "mcp", "retrospective", "codex"],
14
14
  "skills": "./skills/",
15
+ "mcpServers": "./.mcp.json",
15
16
  "interface": {
16
17
  "displayName": "agent-blackboard",
17
18
  "shortDescription": "Session entries for autonomous agents",
@@ -1,7 +1,9 @@
1
1
  {
2
- "agent-blackboard": {
3
- "command": "npx",
4
- "args": ["-y", "agent-blackboard@0.5.0", "mcp"],
5
- "env_vars": ["AGENT_BLACKBOARD_URL", "AGENT_BLACKBOARD_TOKEN"]
2
+ "mcpServers": {
3
+ "agent-blackboard": {
4
+ "command": "npx",
5
+ "args": ["-y", "agent-blackboard@0.6.1", "mcp"],
6
+ "env_vars": ["AGENT_BLACKBOARD_URL", "AGENT_BLACKBOARD_TOKEN"]
7
+ }
6
8
  }
7
9
  }
@@ -18,6 +18,13 @@ skill explains how to use it; project instructions decide what is worth recordin
18
18
  - **Sessions can carry data.** Session patches shallow-merge a free-form `data` object.
19
19
  - **`data` is unstructured.** Every entry carries a free-form `data` object. Attach whatever is
20
20
  useful — a note, a branch name, a PR number, a decision and its rationale. There is no schema.
21
+ - **Repository context has a standard convention.** When recording repository work, use
22
+ `repositories` as a sorted, deduplicated array of lowercase GitHub `owner/name` strings. The
23
+ session's `data.repositories` is the cumulative union; an entry's `data.repositories` contains
24
+ only repositories relevant to that entry. Untagged historical data is unclassified, so do not
25
+ infer repositories from its text or path.
26
+ - **One writer owns each session.** Give subagents their own child sessions. Concurrent patches to
27
+ one session can replace its `repositories` array and lose a repository from the union.
21
28
  - **Entries are strictly append-only.** An entry's `data` cannot be changed after it is written; to
22
29
  enrich or correct an earlier observation, append a new entry rather than editing the original.
23
30
  Archival applies to the whole session.
@@ -29,7 +36,9 @@ If the `agent-blackboard` MCP server is connected, use its tools directly:
29
36
  - `session_create` — create a root or subagent session with explicit `sessionId` and
30
37
  `parentSessionId` (use `null` for a root), plus `agent` and `version`.
31
38
  - `session_search` — find undistilled or archived sessions with exact metadata, data, and optional
32
- `inactiveForHours` filters.
39
+ `inactiveForHours` filters (a session without entries counts as last active at its `createdAt`).
40
+ When supported, `dataArrayContains` matches exact array membership,
41
+ including repository tags.
33
42
  - `session_patch` — shallow-merge `data` into an unarchived session.
34
43
  - `session_archive` — mark a session as distilled; archival is one-time and metadata becomes
35
44
  immutable.
@@ -44,22 +53,30 @@ Without MCP, or from a shell/script, run the published CLI through `npx`. This d
44
53
  local clone of the agent-blackboard repository:
45
54
 
46
55
  ```bash
47
- npx -y agent-blackboard@0.5.0 sessions create root-123 --agent claude-code --version 1.0.13
48
- npx -y agent-blackboard@0.5.0 sessions create worker-456 --parent-session-id root-123 \
56
+ npx -y agent-blackboard@0.6.1 sessions create root-123 --agent claude-code --version 1.0.13
57
+ npx -y agent-blackboard@0.6.1 sessions create worker-456 --parent-session-id root-123 \
49
58
  --agent claude-code --version 1.0.13
50
- npx -y agent-blackboard@0.5.0 sessions patch worker-456 --data '{"branch":"fix/retry"}'
51
- npx -y agent-blackboard@0.5.0 append --session-id worker-456 '{"note":"found the failing edge case"}'
52
- npx -y agent-blackboard@0.5.0 get --session-id worker-456 --format markdown
53
- npx -y agent-blackboard@0.5.0 snapshot export --root-only --inactive-for-hours 8
54
- npx -y agent-blackboard@0.5.0 snapshot partition --path /tmp/agent-blackboard-snapshot-<uuid>.jsonl \
59
+ npx -y agent-blackboard@0.6.1 sessions patch worker-456 --data '{"branch":"fix/retry"}'
60
+ npx -y agent-blackboard@0.6.1 sessions patch worker-456 --data '{"repositories":["owner/name"]}'
61
+ npx -y agent-blackboard@0.6.1 append --session-id worker-456 '{"repositories":["owner/name"],"note":"found the failing edge case"}'
62
+ npx -y agent-blackboard@0.6.1 get --session-id worker-456 --format markdown
63
+ npx -y agent-blackboard@0.6.1 snapshot export --root-only --inactive-for-hours 8
64
+ npx -y agent-blackboard@0.6.1 snapshot partition --path /tmp/agent-blackboard-snapshot-<uuid>.jsonl \
55
65
  --cleanup-token <cleanup-token>
56
- npx -y agent-blackboard@0.5.0 snapshot cleanup --path /tmp/agent-blackboard-snapshot-<uuid>.jsonl \
66
+ npx -y agent-blackboard@0.6.1 snapshot cleanup --path /tmp/agent-blackboard-snapshot-<uuid>.jsonl \
57
67
  --directory /tmp/agent-blackboard-partitions-<suffix> --cleanup-token <cleanup-token>
58
68
  ```
59
69
 
60
70
  Output defaults to JSON; pass `--format jsonl` or `--format markdown` for streaming or
61
71
  human-readable reads.
62
72
 
73
+ Before appending a repository-tagged entry, merge its tags into the session's cumulative list,
74
+ normalize the list, and wait for `sessions patch` to succeed. If it fails, do not append; start a
75
+ new session after archival because archived metadata cannot be patched. The entry tag remains the
76
+ authority for repository-scoped evidence. A session can span repositories, so a repository-scoped
77
+ review includes only entries whose tag array contains the selected repository and does not archive
78
+ the shared session until all of its tagged repositories have been reviewed.
79
+
63
80
  `snapshot partition` accepts only a generated temporary export path plus the cleanup token printed by
64
81
  export, preserves whole sessions and their entry order, and creates private read-only partition
65
82
  files. It defaults to 25 sessions or 1 MiB per partition. `snapshot cleanup` requires the same token
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-blackboard",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
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": {