agent-blackboard 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/cli/append.mjs +3 -4
- package/dist/cli/args.d.mts +3 -2
- package/dist/cli/args.mjs +4 -3
- package/dist/cli/context.d.mts +2 -0
- package/dist/cli/get.mjs +4 -5
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.mjs +5 -1
- package/dist/cli/session-resolution.d.mts +19 -0
- package/dist/cli/session-resolution.mjs +63 -0
- package/dist/cli/sessions.mjs +21 -14
- package/dist/cli/usage.d.mts +1 -1
- package/dist/cli/usage.mjs +9 -5
- package/dist/index.d.mts +13 -0
- package/dist/index.mjs +8 -0
- package/dist/mcp/dispatch.d.mts +2 -1
- package/dist/mcp/dispatch.mjs +5 -5
- package/dist/mcp/schema-fields.d.mts +37 -0
- package/dist/mcp/schema-fields.mjs +41 -0
- package/dist/mcp/schemas.mjs +12 -41
- package/dist/mcp/server.d.mts +3 -2
- package/dist/mcp/server.mjs +4 -4
- package/dist/mcp/session-resolution.d.mts +16 -0
- package/dist/mcp/session-resolution.mjs +27 -0
- package/dist/mcp/tool-append.d.mts +2 -1
- package/dist/mcp/tool-append.mjs +4 -3
- package/dist/mcp/tool-get.d.mts +2 -1
- package/dist/mcp/tool-get.mjs +4 -3
- package/dist/mcp/tool-sessions.d.mts +3 -2
- package/dist/mcp/tool-sessions.mjs +11 -14
- package/dist/plugin/.claude-mcp.json +1 -1
- package/dist/plugin/.codex-plugin/plugin.json +1 -1
- package/dist/plugin/.mcp.json +2 -2
- package/dist/plugin/skills/agent-blackboard/SKILL.md +14 -12
- package/dist/session-id/harness.d.mts +44 -0
- package/dist/session-id/harness.mjs +61 -0
- package/dist/session-id/hook-payload.d.mts +19 -0
- package/dist/session-id/hook-payload.mjs +52 -0
- package/dist/session-id/persist.d.mts +53 -0
- package/dist/session-id/persist.mjs +114 -0
- package/dist/session-id/resolve.d.mts +46 -0
- package/dist/session-id/resolve.mjs +131 -0
- package/dist/session-id/root-codex-options.d.mts +9 -0
- package/dist/session-id/root-codex-options.mjs +13 -0
- package/dist/session-id/valid-id.d.mts +8 -0
- package/dist/session-id/valid-id.mjs +16 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -63,7 +63,9 @@ const auth = new Auth({ baseUrl, adminToken })
|
|
|
63
63
|
await auth.createCredentials({ name: 'ci-bot' })
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
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)
|
|
68
|
+
(`resolveSessionIdentity`, or omitting them in the CLI/MCP). `parentSessionId` is required and
|
|
67
69
|
nullable. The service generates `createdAt`/`lastEntryAt`/`archivedAt` timestamps.
|
|
68
70
|
`Entries.get()` returns an `AsyncIterable<SessionEntry>` and uses incremental JSONL by default.
|
|
69
71
|
Non-2xx responses throw `AgentBlackboardError`. Use the root `formatError(error)` export when
|
package/dist/cli/append.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { parseArgs, stringFlag } from './args.mjs';
|
|
|
5
5
|
import { clientConfigFromEnv } from './env.mjs';
|
|
6
6
|
import { CliError } from './errors.mjs';
|
|
7
7
|
import { writeLine } from './output.mjs';
|
|
8
|
+
import { cliSessionId, SESSION_BOOLEAN_FLAGS } from './session-resolution.mjs';
|
|
8
9
|
async function readStdin(stdin) {
|
|
9
10
|
const chunks = [];
|
|
10
11
|
for await (const chunk of stdin)
|
|
@@ -45,10 +46,8 @@ async function readFileData(path) {
|
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
export async function runAppend(argv, ctx) {
|
|
48
|
-
const { positional, flags } = parseArgs(argv);
|
|
49
|
-
const sessionId =
|
|
50
|
-
if (!sessionId)
|
|
51
|
-
throw new CliError('append requires --session-id <id>.');
|
|
49
|
+
const { positional, flags } = parseArgs(argv, SESSION_BOOLEAN_FLAGS);
|
|
50
|
+
const sessionId = cliSessionId('append', flags, ctx);
|
|
52
51
|
const file = stringFlag(flags, 'file');
|
|
53
52
|
if (flags.file !== undefined && !file)
|
|
54
53
|
throw new CliError('append requires a path after --file.');
|
package/dist/cli/args.d.mts
CHANGED
|
@@ -5,8 +5,9 @@ export interface ParsedArgs {
|
|
|
5
5
|
/**
|
|
6
6
|
* A minimal, zero-dependency `argv` parser. Supports `--flag value`,
|
|
7
7
|
* `--flag=value`, and bare boolean flags (`--flag` with no following
|
|
8
|
-
* value, or immediately followed by another `--flag`).
|
|
8
|
+
* value, or immediately followed by another `--flag`). Names in `booleanFlags` never consume
|
|
9
|
+
* the following token, so `--root-codex '{"a":1}'` keeps the JSON positional.
|
|
9
10
|
*/
|
|
10
|
-
export declare function parseArgs(argv: string[]): ParsedArgs;
|
|
11
|
+
export declare function parseArgs(argv: string[], booleanFlags?: ReadonlySet<string>): ParsedArgs;
|
|
11
12
|
/** Reads a flag expected to be a string; `undefined` if unset or given as a bare boolean. */
|
|
12
13
|
export declare function stringFlag(flags: ParsedArgs['flags'], key: string): string | undefined;
|
package/dist/cli/args.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A minimal, zero-dependency `argv` parser. Supports `--flag value`,
|
|
3
3
|
* `--flag=value`, and bare boolean flags (`--flag` with no following
|
|
4
|
-
* value, or immediately followed by another `--flag`).
|
|
4
|
+
* value, or immediately followed by another `--flag`). Names in `booleanFlags` never consume
|
|
5
|
+
* the following token, so `--root-codex '{"a":1}'` keeps the JSON positional.
|
|
5
6
|
*/
|
|
6
|
-
export function parseArgs(argv) {
|
|
7
|
+
export function parseArgs(argv, booleanFlags = new Set()) {
|
|
7
8
|
const positional = [];
|
|
8
9
|
const flags = {};
|
|
9
10
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -19,7 +20,7 @@ export function parseArgs(argv) {
|
|
|
19
20
|
continue;
|
|
20
21
|
}
|
|
21
22
|
const next = argv[i + 1];
|
|
22
|
-
if (next !== undefined && !next.startsWith('--')) {
|
|
23
|
+
if (next !== undefined && !next.startsWith('--') && !booleanFlags.has(body)) {
|
|
23
24
|
flags[body] = next;
|
|
24
25
|
i += 1;
|
|
25
26
|
}
|
package/dist/cli/context.d.mts
CHANGED
package/dist/cli/get.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { getEntriesRaw } from '../client/stream.mjs';
|
|
2
|
-
import { parseArgs
|
|
2
|
+
import { parseArgs } from './args.mjs';
|
|
3
3
|
import { clientConfigFromEnv } from './env.mjs';
|
|
4
4
|
import { CliError } from './errors.mjs';
|
|
5
|
+
import { cliSessionId, SESSION_BOOLEAN_FLAGS } from './session-resolution.mjs';
|
|
5
6
|
const VALID_FORMATS = ['json', 'jsonl', 'markdown'];
|
|
6
7
|
function parseFormat(value) {
|
|
7
8
|
if (value === undefined)
|
|
@@ -12,10 +13,8 @@ function parseFormat(value) {
|
|
|
12
13
|
throw new CliError(`--format must be one of: ${VALID_FORMATS.join(', ')}`);
|
|
13
14
|
}
|
|
14
15
|
export async function runGet(argv, ctx) {
|
|
15
|
-
const { flags } = parseArgs(argv);
|
|
16
|
-
const sessionId =
|
|
17
|
-
if (!sessionId)
|
|
18
|
-
throw new CliError('get requires --session-id <id>.');
|
|
16
|
+
const { flags } = parseArgs(argv, SESSION_BOOLEAN_FLAGS);
|
|
17
|
+
const sessionId = cliSessionId('get', flags, ctx);
|
|
19
18
|
const response = await getEntriesRaw(clientConfigFromEnv(ctx.env), {
|
|
20
19
|
sessionId,
|
|
21
20
|
format: parseFormat(flags.format),
|
package/dist/cli/index.d.mts
CHANGED
package/dist/cli/index.mjs
CHANGED
|
@@ -20,6 +20,7 @@ const HELP_COMMANDS = new Set(['help', '--help', '-h']);
|
|
|
20
20
|
export async function runCli(argv, options = {}) {
|
|
21
21
|
const ctx = {
|
|
22
22
|
env: options.env ?? process.env,
|
|
23
|
+
cwd: options.cwd ?? process.cwd(),
|
|
23
24
|
stdin: options.stdin ?? process.stdin,
|
|
24
25
|
stdout: options.stdout ?? process.stdout,
|
|
25
26
|
stderr: options.stderr ?? process.stderr,
|
|
@@ -47,7 +48,10 @@ export async function runCli(argv, options = {}) {
|
|
|
47
48
|
await runSnapshot(rest, ctx);
|
|
48
49
|
break;
|
|
49
50
|
case 'mcp':
|
|
50
|
-
await (options.startMcpServer ?? startMcpServer)(clientConfigFromEnv(ctx.env)
|
|
51
|
+
await (options.startMcpServer ?? startMcpServer)(clientConfigFromEnv(ctx.env), {
|
|
52
|
+
env: ctx.env,
|
|
53
|
+
cwd: ctx.cwd,
|
|
54
|
+
});
|
|
51
55
|
break;
|
|
52
56
|
default:
|
|
53
57
|
throw new CliError(`Unknown command: ${command}. Expected one of: sessions, append, get, snapshot, credentials, mcp.`);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ResolveSessionIdentityOptions } from '../session-id/resolve.mjs';
|
|
2
|
+
import type { ParsedArgs } from './args.mjs';
|
|
3
|
+
import type { CliContext } from './context.mjs';
|
|
4
|
+
/** Flags that never take a value, so `parseArgs` must not let them swallow a positional. */
|
|
5
|
+
export declare const SESSION_BOOLEAN_FLAGS: ReadonlySet<string>;
|
|
6
|
+
/**
|
|
7
|
+
* `--session-id` for `append`/`get`. An explicit id is passed through untouched (the server
|
|
8
|
+
* validates it); without one, the id is resolved from the harness environment or the
|
|
9
|
+
* per-worktree persisted file.
|
|
10
|
+
*/
|
|
11
|
+
export declare function cliSessionId(command: string, flags: ParsedArgs['flags'], ctx: CliContext): string;
|
|
12
|
+
/**
|
|
13
|
+
* `<session-id>` and `--agent` for `sessions create|ensure`. Explicit values always win and are
|
|
14
|
+
* never re-validated here; whichever is missing is resolved, paired with the same harness.
|
|
15
|
+
*/
|
|
16
|
+
export declare function cliSessionIdentity(command: string, flags: ParsedArgs['flags'], ctx: CliContext, explicit: Pick<ResolveSessionIdentityOptions, 'agentArg' | 'parentSessionId' | 'sessionIdArg'>): {
|
|
17
|
+
sessionId: string;
|
|
18
|
+
agent: string;
|
|
19
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { validateRootCodexOptions } from '../session-id/root-codex-options.mjs';
|
|
2
|
+
import { requireSessionAgent, requireSessionId, requireSessionIdentity, } from '../session-id/resolve.mjs';
|
|
3
|
+
import { CliError } from './errors.mjs';
|
|
4
|
+
/** Flags that never take a value, so `parseArgs` must not let them swallow a positional. */
|
|
5
|
+
export const SESSION_BOOLEAN_FLAGS = new Set([
|
|
6
|
+
'root-codex',
|
|
7
|
+
'new-root-codex-session',
|
|
8
|
+
]);
|
|
9
|
+
function bareFlag(flags, key, command) {
|
|
10
|
+
const value = flags[key];
|
|
11
|
+
if (value === undefined)
|
|
12
|
+
return false;
|
|
13
|
+
if (value !== true)
|
|
14
|
+
throw new CliError(`${command} --${key} does not accept a value.`);
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
function resolutionOptions(command, flags, ctx, explicit) {
|
|
18
|
+
return {
|
|
19
|
+
env: ctx.env,
|
|
20
|
+
cwd: ctx.cwd,
|
|
21
|
+
...explicit,
|
|
22
|
+
rootCodex: bareFlag(flags, 'root-codex', command),
|
|
23
|
+
newRootCodexSession: bareFlag(flags, 'new-root-codex-session', command),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function cliError(fn) {
|
|
27
|
+
try {
|
|
28
|
+
return fn();
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
// The resolver throws plain errors; surface them as usage errors like any other bad flag.
|
|
32
|
+
throw new CliError(err.message, { cause: err });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* `--session-id` for `append`/`get`. An explicit id is passed through untouched (the server
|
|
37
|
+
* validates it); without one, the id is resolved from the harness environment or the
|
|
38
|
+
* per-worktree persisted file.
|
|
39
|
+
*/
|
|
40
|
+
export function cliSessionId(command, flags, ctx) {
|
|
41
|
+
if (flags['session-id'] === true)
|
|
42
|
+
throw new CliError(`${command} --session-id requires <id>.`);
|
|
43
|
+
const sessionIdArg = typeof flags['session-id'] === 'string' ? flags['session-id'] : undefined;
|
|
44
|
+
const options = resolutionOptions(command, flags, ctx, { sessionIdArg });
|
|
45
|
+
return cliError(() => {
|
|
46
|
+
validateRootCodexOptions(options);
|
|
47
|
+
return sessionIdArg ?? requireSessionId(options);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* `<session-id>` and `--agent` for `sessions create|ensure`. Explicit values always win and are
|
|
52
|
+
* never re-validated here; whichever is missing is resolved, paired with the same harness.
|
|
53
|
+
*/
|
|
54
|
+
export function cliSessionIdentity(command, flags, ctx, explicit) {
|
|
55
|
+
const options = resolutionOptions(command, flags, ctx, explicit);
|
|
56
|
+
return cliError(() => {
|
|
57
|
+
validateRootCodexOptions(options);
|
|
58
|
+
const { sessionIdArg, agentArg } = explicit;
|
|
59
|
+
if (sessionIdArg === undefined)
|
|
60
|
+
return requireSessionIdentity(options);
|
|
61
|
+
return { sessionId: sessionIdArg, agent: agentArg ?? requireSessionAgent(options) };
|
|
62
|
+
});
|
|
63
|
+
}
|
package/dist/cli/sessions.mjs
CHANGED
|
@@ -3,34 +3,41 @@ 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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
import { cliSessionIdentity, SESSION_BOOLEAN_FLAGS } from './session-resolution.mjs';
|
|
7
|
+
/**
|
|
8
|
+
* Shared by `create` and `ensure`, which take identical flags. A missing `<session-id>` or
|
|
9
|
+
* `--agent` is resolved from the harness environment (see `session-resolution.mts`).
|
|
10
|
+
*/
|
|
11
|
+
function parseCreateSessionInput(subcommand, positional, flags, ctx) {
|
|
12
|
+
const command = `sessions ${subcommand}`;
|
|
11
13
|
const parentFlag = stringFlag(flags, 'parent-session-id');
|
|
12
14
|
if (Object.hasOwn(flags, 'parent-session-id') && !parentFlag) {
|
|
13
|
-
throw new CliError(
|
|
15
|
+
throw new CliError(`${command} --parent-session-id requires <session-id>.`);
|
|
16
|
+
}
|
|
17
|
+
if (Object.hasOwn(flags, 'agent') && !stringFlag(flags, 'agent')) {
|
|
18
|
+
throw new CliError(`${command} --agent requires <name>.`);
|
|
14
19
|
}
|
|
15
|
-
const agent = stringFlag(flags, 'agent');
|
|
16
20
|
const version = stringFlag(flags, 'version');
|
|
17
|
-
if (!agent)
|
|
18
|
-
throw new CliError(`sessions ${subcommand} requires --agent <name>.`);
|
|
19
21
|
if (!version)
|
|
20
|
-
throw new CliError(
|
|
21
|
-
|
|
22
|
+
throw new CliError(`${command} requires --version <version>.`);
|
|
23
|
+
const { sessionId, agent } = cliSessionIdentity(command, flags, ctx, {
|
|
24
|
+
sessionIdArg: positional[0],
|
|
25
|
+
agentArg: stringFlag(flags, 'agent'),
|
|
26
|
+
parentSessionId: parentFlag,
|
|
27
|
+
});
|
|
28
|
+
return { id: sessionId, parentSessionId: parentFlag ?? null, agent, version };
|
|
22
29
|
}
|
|
23
30
|
export async function runSessions(argv, ctx) {
|
|
24
31
|
const [subcommand, ...rest] = argv;
|
|
25
|
-
const { positional, flags } = parseArgs(rest);
|
|
32
|
+
const { positional, flags } = parseArgs(rest, SESSION_BOOLEAN_FLAGS);
|
|
26
33
|
const sessions = new Sessions(clientConfigFromEnv(ctx.env));
|
|
27
34
|
if (subcommand === 'create') {
|
|
28
|
-
const input = parseCreateSessionInput('create', positional, flags);
|
|
35
|
+
const input = parseCreateSessionInput('create', positional, flags, ctx);
|
|
29
36
|
writeLine(ctx.stdout, JSON.stringify(await sessions.create(input)));
|
|
30
37
|
return;
|
|
31
38
|
}
|
|
32
39
|
if (subcommand === 'ensure') {
|
|
33
|
-
const input = parseCreateSessionInput('ensure', positional, flags);
|
|
40
|
+
const input = parseCreateSessionInput('ensure', positional, flags, ctx);
|
|
34
41
|
writeLine(ctx.stdout, JSON.stringify(await sessions.ensure(input)));
|
|
35
42
|
return;
|
|
36
43
|
}
|
package/dist/cli/usage.d.mts
CHANGED
|
@@ -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\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>] <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";
|
package/dist/cli/usage.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export const USAGE = `agent-blackboard — an entry stream for autonomous agents
|
|
2
2
|
|
|
3
3
|
Usage:
|
|
4
|
-
agent-blackboard sessions create <id> --agent <name> --version <version> [--parent-session-id <id>]
|
|
5
|
-
agent-blackboard sessions ensure <id> --agent <name> --version <version> [--parent-session-id <id>]
|
|
4
|
+
agent-blackboard sessions create [<id>] [--agent <name>] --version <version> [--parent-session-id <id>]
|
|
5
|
+
agent-blackboard sessions ensure [<id>] [--agent <name>] --version <version> [--parent-session-id <id>]
|
|
6
6
|
agent-blackboard sessions list [--archived true|false] [--inactive-for-hours <hours>]
|
|
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>
|
|
12
|
-
agent-blackboard get --session-id <id> [--format json|jsonl|markdown]
|
|
10
|
+
agent-blackboard append [--session-id <id>] <json>
|
|
11
|
+
agent-blackboard append [--session-id <id>] --file <json|markdown|text>
|
|
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>]
|
|
@@ -18,6 +18,10 @@ Usage:
|
|
|
18
18
|
agent-blackboard credentials <subcommand>
|
|
19
19
|
agent-blackboard mcp
|
|
20
20
|
|
|
21
|
+
Omitted session ids and agents resolve from the harness environment (CLAUDE_CODE_SESSION_ID,
|
|
22
|
+
CODEX_THREAD_ID, CURSOR_SESSION_ID, GROK_SESSION_ID) or <worktree>/.local/<harness>-session-id.
|
|
23
|
+
Interactive root Codex: --root-codex creates or reuses the worktree id; --new-root-codex-session rotates it.
|
|
24
|
+
|
|
21
25
|
Env:
|
|
22
26
|
AGENT_BLACKBOARD_URL Server base URL
|
|
23
27
|
AGENT_BLACKBOARD_TOKEN Client credential
|
package/dist/index.d.mts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* - `Entries` — append/read entries using caller-supplied session ids.
|
|
7
7
|
* - `Snapshots` — file-backed bulk export with compact verified metadata.
|
|
8
8
|
* - `Auth` — admin-only credential management.
|
|
9
|
+
* - Session-id resolution — harness detection, per-worktree persistence, and root Codex ids for
|
|
10
|
+
* callers that omit an explicit session id. Every function takes `env`/`cwd` explicitly.
|
|
9
11
|
*
|
|
10
12
|
* This module must never import `@aws-sdk/*` or anything from
|
|
11
13
|
* `packages/server` (enforced by `.dependency-cruiser.cjs`).
|
|
@@ -19,4 +21,15 @@ export { Sessions } from './client/sessions.mjs';
|
|
|
19
21
|
export { Snapshots } from './client/snapshots.mjs';
|
|
20
22
|
export { cleanupSnapshotPartitions } from './client/snapshot-partition-cleanup.mjs';
|
|
21
23
|
export { partitionSnapshot } from './client/snapshot-partitions.mjs';
|
|
24
|
+
export { HARNESS_IDS, HARNESS_SESSION_PRECEDENCE, inspectHarnessEnvironment, selectHarnessSession, transcriptPathHarness, } from './session-id/harness.mjs';
|
|
25
|
+
export type { HarnessEnvironment, HarnessId, HarnessSessionIdentity, } from './session-id/harness.mjs';
|
|
26
|
+
export { cursorPayloadSessionId, grokHookSessionId, hookPayloadSessionId, persistHookRealSessionId, persistHookSessionStart, } from './session-id/hook-payload.mjs';
|
|
27
|
+
export type { HookPayload } from './session-id/hook-payload.mjs';
|
|
28
|
+
export { SESSION_PERSIST_RELATIVE, enclosingWorktreeRoot, persistRealSessionId, readPersistedSessionId, resolveAndPersistRootCodexSessionId, resolveAndPersistSessionStartId, sessionPersistPath, } from './session-id/persist.mjs';
|
|
29
|
+
export type { PersistedHarness } from './session-id/persist.mjs';
|
|
30
|
+
export { agentForHarness, requireSessionAgent, requireSessionId, requireSessionIdentity, resolveSessionId, resolveSessionIdentity, } from './session-id/resolve.mjs';
|
|
31
|
+
export type { ResolveSessionIdentityOptions, SessionAgent, SessionIdentity, } from './session-id/resolve.mjs';
|
|
32
|
+
export { validateRootCodexOptions } from './session-id/root-codex-options.mjs';
|
|
33
|
+
export type { RootCodexOptions } from './session-id/root-codex-options.mjs';
|
|
34
|
+
export { isValidSessionId, sanitizeSessionId } from './session-id/valid-id.mjs';
|
|
22
35
|
export type { AppendEntryInput, ClientConfig, CreateSessionInput, CredentialCreated, CredentialSummary, EntryWireFormat, GetEntriesQuery, GetRawEntriesQuery, ListSessionsQuery, PatchSessionInput, ReadRetryOptions, Session, SessionEntry, StructuredEntryFormat, SnapshotCounts, SnapshotExportOptions, SnapshotExportResult, SnapshotChecksum, SnapshotCleanupOptions, SnapshotManifest, SnapshotPartition, SnapshotPartitionOptions, SnapshotPartitionResult, SnapshotSelection, SnapshotVerification, } from './client/types.mjs';
|
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* - `Entries` — append/read entries using caller-supplied session ids.
|
|
7
7
|
* - `Snapshots` — file-backed bulk export with compact verified metadata.
|
|
8
8
|
* - `Auth` — admin-only credential management.
|
|
9
|
+
* - Session-id resolution — harness detection, per-worktree persistence, and root Codex ids for
|
|
10
|
+
* callers that omit an explicit session id. Every function takes `env`/`cwd` explicitly.
|
|
9
11
|
*
|
|
10
12
|
* This module must never import `@aws-sdk/*` or anything from
|
|
11
13
|
* `packages/server` (enforced by `.dependency-cruiser.cjs`).
|
|
@@ -18,3 +20,9 @@ export { Sessions } from './client/sessions.mjs';
|
|
|
18
20
|
export { Snapshots } from './client/snapshots.mjs';
|
|
19
21
|
export { cleanupSnapshotPartitions } from './client/snapshot-partition-cleanup.mjs';
|
|
20
22
|
export { partitionSnapshot } from './client/snapshot-partitions.mjs';
|
|
23
|
+
export { HARNESS_IDS, HARNESS_SESSION_PRECEDENCE, inspectHarnessEnvironment, selectHarnessSession, transcriptPathHarness, } from './session-id/harness.mjs';
|
|
24
|
+
export { cursorPayloadSessionId, grokHookSessionId, hookPayloadSessionId, persistHookRealSessionId, persistHookSessionStart, } from './session-id/hook-payload.mjs';
|
|
25
|
+
export { SESSION_PERSIST_RELATIVE, enclosingWorktreeRoot, persistRealSessionId, readPersistedSessionId, resolveAndPersistRootCodexSessionId, resolveAndPersistSessionStartId, sessionPersistPath, } from './session-id/persist.mjs';
|
|
26
|
+
export { agentForHarness, requireSessionAgent, requireSessionId, requireSessionIdentity, resolveSessionId, resolveSessionIdentity, } from './session-id/resolve.mjs';
|
|
27
|
+
export { validateRootCodexOptions } from './session-id/root-codex-options.mjs';
|
|
28
|
+
export { isValidSessionId, sanitizeSessionId } from './session-id/valid-id.mjs';
|
package/dist/mcp/dispatch.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { ClientConfig } from '../client/types.mjs';
|
|
2
|
-
|
|
2
|
+
import type { SessionResolutionContext } from './session-resolution.mjs';
|
|
3
|
+
export declare function dispatchTool(name: string, args: Record<string, unknown>, config: ClientConfig, resolution?: SessionResolutionContext): Promise<unknown>;
|
package/dist/mcp/dispatch.mjs
CHANGED
|
@@ -2,12 +2,12 @@ import { handleEntryAppend } from './tool-append.mjs';
|
|
|
2
2
|
import { handleEntryGet } from './tool-get.mjs';
|
|
3
3
|
import { handleSnapshotExport } from './tool-snapshot.mjs';
|
|
4
4
|
import { handleSessionArchive, handleSessionCreate, handleSessionEnsure, handleSessionPatch, handleSessionSearch, } from './tool-sessions.mjs';
|
|
5
|
-
export function dispatchTool(name, args, config) {
|
|
5
|
+
export function dispatchTool(name, args, config, resolution) {
|
|
6
6
|
switch (name) {
|
|
7
7
|
case 'session_create':
|
|
8
|
-
return handleSessionCreate(args, config);
|
|
8
|
+
return handleSessionCreate(args, config, resolution);
|
|
9
9
|
case 'session_ensure':
|
|
10
|
-
return handleSessionEnsure(args, config);
|
|
10
|
+
return handleSessionEnsure(args, config, resolution);
|
|
11
11
|
case 'session_archive':
|
|
12
12
|
return handleSessionArchive(args, config);
|
|
13
13
|
case 'session_search':
|
|
@@ -15,9 +15,9 @@ export function dispatchTool(name, args, config) {
|
|
|
15
15
|
case 'session_patch':
|
|
16
16
|
return handleSessionPatch(args, config);
|
|
17
17
|
case 'entry_append':
|
|
18
|
-
return handleEntryAppend(args, config);
|
|
18
|
+
return handleEntryAppend(args, config, resolution);
|
|
19
19
|
case 'entry_get':
|
|
20
|
-
return handleEntryGet(args, config);
|
|
20
|
+
return handleEntryGet(args, config, resolution);
|
|
21
21
|
case 'snapshot_export':
|
|
22
22
|
return handleSnapshotExport(args, config);
|
|
23
23
|
default:
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Shared property schemas and annotation sets for `schemas.mts`. */
|
|
2
|
+
export declare const SESSION_ID: {
|
|
3
|
+
type: 'string';
|
|
4
|
+
description: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const RESOLVABLE_SESSION_ID: {
|
|
7
|
+
type: 'string';
|
|
8
|
+
description: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const AGENT: {
|
|
11
|
+
type: 'string';
|
|
12
|
+
description: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const READ_ONLY: {
|
|
15
|
+
readonly readOnlyHint: true;
|
|
16
|
+
readonly destructiveHint: false;
|
|
17
|
+
readonly idempotentHint: true;
|
|
18
|
+
readonly openWorldHint: false;
|
|
19
|
+
};
|
|
20
|
+
export declare const ADDITIVE: {
|
|
21
|
+
readonly readOnlyHint: false;
|
|
22
|
+
readonly destructiveHint: false;
|
|
23
|
+
readonly idempotentHint: false;
|
|
24
|
+
readonly openWorldHint: false;
|
|
25
|
+
};
|
|
26
|
+
export declare const IDEMPOTENT_ADDITIVE: {
|
|
27
|
+
readonly readOnlyHint: false;
|
|
28
|
+
readonly destructiveHint: false;
|
|
29
|
+
readonly idempotentHint: true;
|
|
30
|
+
readonly openWorldHint: false;
|
|
31
|
+
};
|
|
32
|
+
export declare const MUTATING: {
|
|
33
|
+
readonly readOnlyHint: false;
|
|
34
|
+
readonly destructiveHint: true;
|
|
35
|
+
readonly idempotentHint: true;
|
|
36
|
+
readonly openWorldHint: false;
|
|
37
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Shared property schemas and annotation sets for `schemas.mts`. */
|
|
2
|
+
export const SESSION_ID = {
|
|
3
|
+
type: 'string',
|
|
4
|
+
description: 'Caller-supplied session id.',
|
|
5
|
+
};
|
|
6
|
+
export const RESOLVABLE_SESSION_ID = {
|
|
7
|
+
type: 'string',
|
|
8
|
+
description: 'Session id. An explicit value always wins; when omitted, it is resolved from the MCP ' +
|
|
9
|
+
"server's harness environment (CLAUDE_CODE_SESSION_ID, CODEX_THREAD_ID, ...) or the " +
|
|
10
|
+
'per-worktree .local/<harness>-session-id file, and the call fails if none resolves.',
|
|
11
|
+
};
|
|
12
|
+
export const AGENT = {
|
|
13
|
+
type: 'string',
|
|
14
|
+
description: 'Agent name, for example claude-code. When omitted, derived from the same harness ' +
|
|
15
|
+
'environment that resolves sessionId.',
|
|
16
|
+
};
|
|
17
|
+
// Keep all four hints explicit so clients do not rely on protocol defaults.
|
|
18
|
+
export const READ_ONLY = {
|
|
19
|
+
readOnlyHint: true,
|
|
20
|
+
destructiveHint: false,
|
|
21
|
+
idempotentHint: true,
|
|
22
|
+
openWorldHint: false,
|
|
23
|
+
};
|
|
24
|
+
export const ADDITIVE = {
|
|
25
|
+
readOnlyHint: false,
|
|
26
|
+
destructiveHint: false,
|
|
27
|
+
idempotentHint: false,
|
|
28
|
+
openWorldHint: false,
|
|
29
|
+
};
|
|
30
|
+
export const IDEMPOTENT_ADDITIVE = {
|
|
31
|
+
readOnlyHint: false,
|
|
32
|
+
destructiveHint: false,
|
|
33
|
+
idempotentHint: true,
|
|
34
|
+
openWorldHint: false,
|
|
35
|
+
};
|
|
36
|
+
export const MUTATING = {
|
|
37
|
+
readOnlyHint: false,
|
|
38
|
+
destructiveHint: true,
|
|
39
|
+
idempotentHint: true,
|
|
40
|
+
openWorldHint: false,
|
|
41
|
+
};
|
package/dist/mcp/schemas.mjs
CHANGED
|
@@ -1,32 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
type: 'string',
|
|
3
|
-
description: 'Caller-supplied session id. Never inferred or generated.',
|
|
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
|
-
};
|
|
1
|
+
import { ADDITIVE, AGENT, IDEMPOTENT_ADDITIVE, MUTATING, READ_ONLY, RESOLVABLE_SESSION_ID, SESSION_ID, } from './schema-fields.mjs';
|
|
30
2
|
export const ENTRY_TOOLS = [
|
|
31
3
|
{
|
|
32
4
|
name: 'snapshot_export',
|
|
@@ -47,7 +19,7 @@ export const ENTRY_TOOLS = [
|
|
|
47
19
|
inactiveForHours: {
|
|
48
20
|
type: 'number',
|
|
49
21
|
exclusiveMinimum: 0,
|
|
50
|
-
description: 'Only sessions inactive for this many hours.',
|
|
22
|
+
description: 'Only sessions inactive for this many hours (createdAt if no entries).',
|
|
51
23
|
},
|
|
52
24
|
},
|
|
53
25
|
},
|
|
@@ -59,15 +31,15 @@ export const ENTRY_TOOLS = [
|
|
|
59
31
|
inputSchema: {
|
|
60
32
|
type: 'object',
|
|
61
33
|
properties: {
|
|
62
|
-
sessionId:
|
|
34
|
+
sessionId: RESOLVABLE_SESSION_ID,
|
|
63
35
|
parentSessionId: {
|
|
64
36
|
type: ['string', 'null'],
|
|
65
37
|
description: 'Null for a root session; the direct parent session id for a subagent.',
|
|
66
38
|
},
|
|
67
|
-
agent:
|
|
39
|
+
agent: AGENT,
|
|
68
40
|
version: { type: 'string', description: 'Agent version, for example 1.0.13.' },
|
|
69
41
|
},
|
|
70
|
-
required: ['
|
|
42
|
+
required: ['parentSessionId', 'version'],
|
|
71
43
|
},
|
|
72
44
|
annotations: ADDITIVE,
|
|
73
45
|
},
|
|
@@ -78,15 +50,15 @@ export const ENTRY_TOOLS = [
|
|
|
78
50
|
inputSchema: {
|
|
79
51
|
type: 'object',
|
|
80
52
|
properties: {
|
|
81
|
-
sessionId:
|
|
53
|
+
sessionId: RESOLVABLE_SESSION_ID,
|
|
82
54
|
parentSessionId: {
|
|
83
55
|
type: ['string', 'null'],
|
|
84
56
|
description: 'Null for a root session; the direct parent session id for a subagent.',
|
|
85
57
|
},
|
|
86
|
-
agent:
|
|
58
|
+
agent: AGENT,
|
|
87
59
|
version: { type: 'string', description: 'Agent version, for example 1.0.13.' },
|
|
88
60
|
},
|
|
89
|
-
required: ['
|
|
61
|
+
required: ['parentSessionId', 'version'],
|
|
90
62
|
},
|
|
91
63
|
annotations: IDEMPOTENT_ADDITIVE,
|
|
92
64
|
},
|
|
@@ -118,7 +90,7 @@ export const ENTRY_TOOLS = [
|
|
|
118
90
|
inactiveForHours: {
|
|
119
91
|
type: 'number',
|
|
120
92
|
exclusiveMinimum: 0,
|
|
121
|
-
description: 'Matches sessions whose last entry is strictly older than this many hours
|
|
93
|
+
description: 'Matches sessions whose last entry (or createdAt, without entries) is strictly older than this many hours.',
|
|
122
94
|
},
|
|
123
95
|
limit: {
|
|
124
96
|
type: 'integer',
|
|
@@ -163,10 +135,10 @@ export const ENTRY_TOOLS = [
|
|
|
163
135
|
inputSchema: {
|
|
164
136
|
type: 'object',
|
|
165
137
|
properties: {
|
|
166
|
-
sessionId:
|
|
138
|
+
sessionId: RESOLVABLE_SESSION_ID,
|
|
167
139
|
data: { type: 'object', description: 'Unstructured JSON payload.' },
|
|
168
140
|
},
|
|
169
|
-
required: ['
|
|
141
|
+
required: ['data'],
|
|
170
142
|
},
|
|
171
143
|
annotations: ADDITIVE,
|
|
172
144
|
},
|
|
@@ -176,10 +148,9 @@ export const ENTRY_TOOLS = [
|
|
|
176
148
|
inputSchema: {
|
|
177
149
|
type: 'object',
|
|
178
150
|
properties: {
|
|
179
|
-
sessionId:
|
|
151
|
+
sessionId: RESOLVABLE_SESSION_ID,
|
|
180
152
|
format: { type: 'string', enum: ['json', 'jsonl'] },
|
|
181
153
|
},
|
|
182
|
-
required: ['sessionId'],
|
|
183
154
|
},
|
|
184
155
|
annotations: READ_ONLY,
|
|
185
156
|
},
|
package/dist/mcp/server.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
2
|
import type { ClientConfig } from '../client/types.mjs';
|
|
3
|
+
import type { SessionResolutionContext } from './session-resolution.mjs';
|
|
3
4
|
/**
|
|
4
5
|
* Builds the MCP server with the session and entry tools registered, but does
|
|
5
6
|
* not connect a transport — kept separate so tests can drive it over an
|
|
6
7
|
* `InMemoryTransport` instead of real stdio.
|
|
7
8
|
*/
|
|
8
|
-
export declare function createMcpServer(config: ClientConfig): Server;
|
|
9
|
+
export declare function createMcpServer(config: ClientConfig, resolution?: SessionResolutionContext): Server;
|
|
9
10
|
/** Starts the MCP stdio server — the `agent-blackboard mcp` entrypoint. */
|
|
10
|
-
export declare function startMcpServer(config: ClientConfig): Promise<void>;
|
|
11
|
+
export declare function startMcpServer(config: ClientConfig, resolution: SessionResolutionContext): Promise<void>;
|
package/dist/mcp/server.mjs
CHANGED
|
@@ -10,12 +10,12 @@ const SERVER_INFO = { name: 'agent-blackboard', version: '0.0.0' };
|
|
|
10
10
|
* not connect a transport — kept separate so tests can drive it over an
|
|
11
11
|
* `InMemoryTransport` instead of real stdio.
|
|
12
12
|
*/
|
|
13
|
-
export function createMcpServer(config) {
|
|
13
|
+
export function createMcpServer(config, resolution) {
|
|
14
14
|
const server = new Server(SERVER_INFO, { capabilities: { tools: {} } });
|
|
15
15
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: ENTRY_TOOLS }));
|
|
16
16
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
17
17
|
try {
|
|
18
|
-
const result = await dispatchTool(request.params.name, request.params.arguments ?? {}, config);
|
|
18
|
+
const result = await dispatchTool(request.params.name, request.params.arguments ?? {}, config, resolution);
|
|
19
19
|
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
20
20
|
}
|
|
21
21
|
catch (err) {
|
|
@@ -28,8 +28,8 @@ export function createMcpServer(config) {
|
|
|
28
28
|
stdin/stdout, which vitest can't drive. `createMcpServer` above (the tested logic) is exercised
|
|
29
29
|
directly via InMemoryTransport in server.test.mts. */
|
|
30
30
|
/** Starts the MCP stdio server — the `agent-blackboard mcp` entrypoint. */
|
|
31
|
-
export async function startMcpServer(config) {
|
|
32
|
-
const server = createMcpServer(config);
|
|
31
|
+
export async function startMcpServer(config, resolution) {
|
|
32
|
+
const server = createMcpServer(config, resolution);
|
|
33
33
|
await server.connect(new StdioServerTransport());
|
|
34
34
|
}
|
|
35
35
|
/* v8 ignore stop */
|