agent-blackboard 0.7.0 → 0.9.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 +30 -13
- package/dist/cli/append.mjs +23 -1
- package/dist/cli/env.d.mts +4 -4
- package/dist/cli/env.mjs +6 -6
- package/dist/cli/get.mjs +2 -1
- package/dist/cli/index.mjs +9 -1
- package/dist/cli/outbox.d.mts +2 -0
- package/dist/cli/outbox.mjs +60 -0
- package/dist/cli/revision-notice.d.mts +6 -0
- package/dist/cli/revision-notice.mjs +19 -0
- package/dist/cli/schemas-shadow.d.mts +3 -0
- package/dist/cli/schemas-shadow.mjs +47 -0
- package/dist/cli/schemas.d.mts +2 -0
- package/dist/cli/schemas.mjs +168 -0
- package/dist/cli/sessions.mjs +2 -1
- package/dist/cli/snapshot-partition-options.d.mts +6 -0
- package/dist/cli/snapshot-partition-options.mjs +25 -0
- package/dist/cli/snapshot.mjs +5 -13
- package/dist/cli/usage.d.mts +1 -1
- package/dist/cli/usage.mjs +16 -3
- package/dist/client/append.d.mts +4 -2
- package/dist/client/append.mjs +44 -2
- package/dist/client/entries.d.mts +2 -2
- package/dist/client/http.d.mts +2 -0
- package/dist/client/http.mjs +26 -8
- package/dist/client/schema-types.d.mts +119 -0
- package/dist/client/schema-types.mjs +1 -0
- package/dist/client/schemas-client.d.mts +21 -0
- package/dist/client/schemas-client.mjs +62 -0
- package/dist/client/schemas.d.mts +23 -0
- package/dist/client/schemas.mjs +68 -0
- package/dist/client/sessions.d.mts +2 -2
- package/dist/client/snapshot-digest-stage.d.mts +10 -0
- package/dist/client/snapshot-digest-stage.mjs +33 -0
- package/dist/client/snapshot-digest.d.mts +43 -0
- package/dist/client/snapshot-digest.mjs +130 -0
- package/dist/client/snapshot-partition-cleanup.d.mts +1 -1
- package/dist/client/snapshot-partition-copy.d.mts +1 -0
- package/dist/client/snapshot-partition-copy.mjs +8 -0
- package/dist/client/snapshot-partition-format.d.mts +1 -1
- package/dist/client/snapshot-partition-read.d.mts +3 -2
- package/dist/client/snapshot-partition-read.mjs +23 -1
- package/dist/client/snapshot-partition-write.d.mts +3 -2
- package/dist/client/snapshot-partition-write.mjs +16 -15
- package/dist/client/snapshot-partitions.d.mts +1 -1
- package/dist/client/snapshot-partitions.mjs +4 -2
- package/dist/client/snapshot-response.d.mts +1 -1
- package/dist/client/snapshot-types.d.mts +104 -0
- package/dist/client/snapshot-types.mjs +1 -0
- package/dist/client/snapshots.d.mts +2 -1
- package/dist/client/types.d.mts +33 -83
- package/dist/index.d.mts +10 -1
- package/dist/index.mjs +5 -0
- package/dist/mcp/dispatch.mjs +21 -1
- package/dist/mcp/schemas-outbox-tools.d.mts +2 -0
- package/dist/mcp/schemas-outbox-tools.mjs +45 -0
- package/dist/mcp/schemas-registry-tools.d.mts +2 -0
- package/dist/mcp/schemas-registry-tools.mjs +63 -0
- package/dist/mcp/schemas-snapshot-tools.d.mts +2 -0
- package/dist/mcp/schemas-snapshot-tools.mjs +109 -0
- package/dist/mcp/schemas.mjs +18 -27
- package/dist/mcp/server.mjs +2 -1
- package/dist/mcp/session-resolution.d.mts +7 -0
- package/dist/mcp/session-resolution.mjs +13 -0
- package/dist/mcp/tool-append.d.mts +2 -2
- package/dist/mcp/tool-append.mjs +15 -2
- package/dist/mcp/tool-outbox.d.mts +6 -0
- package/dist/mcp/tool-outbox.mjs +29 -0
- package/dist/mcp/tool-schemas.d.mts +7 -0
- package/dist/mcp/tool-schemas.mjs +26 -0
- package/dist/mcp/tool-snapshot.d.mts +7 -0
- package/dist/mcp/tool-snapshot.mjs +62 -1
- package/dist/outbox/classify.d.mts +9 -0
- package/dist/outbox/classify.mjs +48 -0
- package/dist/outbox/client.d.mts +11 -0
- package/dist/outbox/client.mjs +90 -0
- package/dist/outbox/fs.d.mts +9 -0
- package/dist/outbox/fs.mjs +51 -0
- package/dist/outbox/store.d.mts +22 -0
- package/dist/outbox/store.mjs +128 -0
- package/dist/outbox/target.d.mts +10 -0
- package/dist/outbox/target.mjs +21 -0
- package/dist/outbox/types.d.mts +72 -0
- package/dist/outbox/types.mjs +1 -0
- package/dist/plugin/.claude-mcp.json +1 -1
- package/dist/plugin/.codex-plugin/plugin.json +6 -6
- package/dist/plugin/.mcp.json +1 -1
- package/dist/plugin/skills/agent-blackboard/SKILL.md +37 -18
- package/dist/plugin/skills/distill/SKILL.md +120 -0
- package/dist/plugin/skills/distill/references/output-schema.md +64 -0
- package/dist/schemas/id.d.mts +8 -0
- package/dist/schemas/id.mjs +32 -0
- package/dist/schemas/local-store.d.mts +22 -0
- package/dist/schemas/local-store.mjs +159 -0
- package/dist/schemas/validate.d.mts +3 -0
- package/dist/schemas/validate.mjs +70 -0
- package/dist/session-id/persist.mjs +15 -2
- package/package.json +7 -5
package/dist/index.d.mts
CHANGED
|
@@ -17,8 +17,16 @@ export type { AuthOptions } from './client/auth.mjs';
|
|
|
17
17
|
export { AgentBlackboardError } from './client/errors.mjs';
|
|
18
18
|
export { Entries } from './client/entries.mjs';
|
|
19
19
|
export { formatError } from './format-error.mjs';
|
|
20
|
+
export { Outbox } from './outbox/client.mjs';
|
|
21
|
+
export { resolveOutboxDir } from './outbox/store.mjs';
|
|
22
|
+
export type { OutboxFlushOptions, OutboxFlushResult, OutboxLocationOptions, OutboxPendingRecord, OutboxPruneOptions, OutboxPruneResult, OutboxRejectedRecord, OutboxSessionCounts, OutboxStatus, OutboxTarget, } from './outbox/types.mjs';
|
|
23
|
+
export { Schemas } from './client/schemas.mjs';
|
|
24
|
+
export type { LocalSchemaOptions } from './client/schemas.mjs';
|
|
20
25
|
export { Sessions } from './client/sessions.mjs';
|
|
21
26
|
export { Snapshots } from './client/snapshots.mjs';
|
|
27
|
+
export { resolveSchemasDir } from './schemas/local-store.mjs';
|
|
28
|
+
export { validateAgainstBundle, validateAgainstLocalSchemas } from './schemas/validate.mjs';
|
|
29
|
+
export type { ListSchemasResult, ListSchemaVersionsResult, PullSchemasResult, SchemaBundle, SchemaShadowWarning, SchemaSummary, SchemaValidationIssue, SchemaValidationResult, SchemaVersionDetail, SchemaVersionMode, SchemaVersionRecord, SchemaWithVersions, } from './client/schema-types.mjs';
|
|
22
30
|
export { cleanupSnapshotPartitions } from './client/snapshot-partition-cleanup.mjs';
|
|
23
31
|
export { partitionSnapshot } from './client/snapshot-partitions.mjs';
|
|
24
32
|
export { HARNESS_IDS, HARNESS_SESSION_PRECEDENCE, inspectHarnessEnvironment, selectHarnessSession, transcriptPathHarness, } from './session-id/harness.mjs';
|
|
@@ -32,4 +40,5 @@ export type { ResolveSessionIdentityOptions, SessionAgent, SessionIdentity, } fr
|
|
|
32
40
|
export { validateRootCodexOptions } from './session-id/root-codex-options.mjs';
|
|
33
41
|
export type { RootCodexOptions } from './session-id/root-codex-options.mjs';
|
|
34
42
|
export { isValidSessionId, sanitizeSessionId } from './session-id/valid-id.mjs';
|
|
35
|
-
export type { AppendEntryInput, ClientConfig, CreateSessionInput, CredentialCreated, CredentialSummary, EntryWireFormat, GetEntriesQuery, GetRawEntriesQuery, ListSessionsQuery, PatchSessionInput,
|
|
43
|
+
export type { AppendEntryInput, AppendEntryResult, ClientConfig, CreateSessionInput, CredentialCreated, CredentialSummary, EntryWireFormat, GetEntriesQuery, GetRawEntriesQuery, ListSessionsQuery, PatchSessionInput, PatchSessionResult, QueuedEntryResult, ReadRetryOptions, Session, SessionEntry, StoredEntryResult, StructuredEntryFormat, } from './client/types.mjs';
|
|
44
|
+
export type { SnapshotChecksum, SnapshotCleanupOptions, SnapshotCounts, SnapshotExportOptions, SnapshotExportResult, SnapshotManifest, SnapshotPartition, SnapshotPartitionOptions, SnapshotPartitionResult, SnapshotSelection, SnapshotVerification, } from './client/snapshot-types.mjs';
|
package/dist/index.mjs
CHANGED
|
@@ -16,8 +16,13 @@ export { Auth } from './client/auth.mjs';
|
|
|
16
16
|
export { AgentBlackboardError } from './client/errors.mjs';
|
|
17
17
|
export { Entries } from './client/entries.mjs';
|
|
18
18
|
export { formatError } from './format-error.mjs';
|
|
19
|
+
export { Outbox } from './outbox/client.mjs';
|
|
20
|
+
export { resolveOutboxDir } from './outbox/store.mjs';
|
|
21
|
+
export { Schemas } from './client/schemas.mjs';
|
|
19
22
|
export { Sessions } from './client/sessions.mjs';
|
|
20
23
|
export { Snapshots } from './client/snapshots.mjs';
|
|
24
|
+
export { resolveSchemasDir } from './schemas/local-store.mjs';
|
|
25
|
+
export { validateAgainstBundle, validateAgainstLocalSchemas } from './schemas/validate.mjs';
|
|
21
26
|
export { cleanupSnapshotPartitions } from './client/snapshot-partition-cleanup.mjs';
|
|
22
27
|
export { partitionSnapshot } from './client/snapshot-partitions.mjs';
|
|
23
28
|
export { HARNESS_IDS, HARNESS_SESSION_PRECEDENCE, inspectHarnessEnvironment, selectHarnessSession, transcriptPathHarness, } from './session-id/harness.mjs';
|
package/dist/mcp/dispatch.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { handleEntryAppend } from './tool-append.mjs';
|
|
2
2
|
import { handleEntryGet } from './tool-get.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { handleOutboxFlush, handleOutboxPruneRejected, handleOutboxStatus } from './tool-outbox.mjs';
|
|
4
|
+
import { handleSchemaGet, handleSchemaList, handleSchemaPull, handleSchemaValidate, } from './tool-schemas.mjs';
|
|
5
|
+
import { handleSnapshotCleanup, handleSnapshotExport, handleSnapshotPartition, } from './tool-snapshot.mjs';
|
|
4
6
|
import { handleSessionArchive, handleSessionCreate, handleSessionEnsure, handleSessionPatch, handleSessionSearch, } from './tool-sessions.mjs';
|
|
5
7
|
export function dispatchTool(name, args, config, resolution) {
|
|
6
8
|
switch (name) {
|
|
@@ -20,6 +22,24 @@ export function dispatchTool(name, args, config, resolution) {
|
|
|
20
22
|
return handleEntryGet(args, config, resolution);
|
|
21
23
|
case 'snapshot_export':
|
|
22
24
|
return handleSnapshotExport(args, config);
|
|
25
|
+
case 'snapshot_partition':
|
|
26
|
+
return handleSnapshotPartition(args);
|
|
27
|
+
case 'snapshot_cleanup':
|
|
28
|
+
return handleSnapshotCleanup(args);
|
|
29
|
+
case 'schema_list':
|
|
30
|
+
return handleSchemaList(config);
|
|
31
|
+
case 'schema_get':
|
|
32
|
+
return handleSchemaGet(args, config);
|
|
33
|
+
case 'schema_pull':
|
|
34
|
+
return handleSchemaPull(args, config, resolution);
|
|
35
|
+
case 'schema_validate':
|
|
36
|
+
return handleSchemaValidate(args, config, resolution);
|
|
37
|
+
case 'outbox_status':
|
|
38
|
+
return handleOutboxStatus(args, config, resolution);
|
|
39
|
+
case 'outbox_flush':
|
|
40
|
+
return handleOutboxFlush(args, config, resolution);
|
|
41
|
+
case 'outbox_prune_rejected':
|
|
42
|
+
return handleOutboxPruneRejected(args, config, resolution);
|
|
23
43
|
default:
|
|
24
44
|
throw new Error(`Unknown tool: ${name}`);
|
|
25
45
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { MUTATING, READ_ONLY, SESSION_ID } from './schema-fields.mjs';
|
|
2
|
+
export const OUTBOX_TOOLS = [
|
|
3
|
+
{
|
|
4
|
+
name: 'outbox_status',
|
|
5
|
+
description: 'Reports pending and rejected entry counts per session in the local worktree outbox, including saved server errors for rejected records.',
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
dir: { type: 'string', description: 'Optional local outbox directory override.' },
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
annotations: READ_ONLY,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'outbox_flush',
|
|
16
|
+
description: 'Delivers queued entries from the local outbox to the server. Permanent 4xx rejections are moved to rejected/ with their server error so they do not block the queue.',
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
sessionId: {
|
|
21
|
+
...SESSION_ID,
|
|
22
|
+
description: 'Optional session id to flush; omit to flush all sessions.',
|
|
23
|
+
},
|
|
24
|
+
dir: { type: 'string', description: 'Optional local outbox directory override.' },
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
annotations: MUTATING,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'outbox_prune_rejected',
|
|
31
|
+
description: 'Removes permanently rejected records from the local outbox (all, or filtered by id and/or sessionId).',
|
|
32
|
+
inputSchema: {
|
|
33
|
+
type: 'object',
|
|
34
|
+
properties: {
|
|
35
|
+
id: { type: 'string', description: 'Optional specific rejected outbox record id.' },
|
|
36
|
+
sessionId: {
|
|
37
|
+
...SESSION_ID,
|
|
38
|
+
description: 'Optional session id whose rejected records should be removed.',
|
|
39
|
+
},
|
|
40
|
+
dir: { type: 'string', description: 'Optional local outbox directory override.' },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
annotations: MUTATING,
|
|
44
|
+
},
|
|
45
|
+
];
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { MUTATING, READ_ONLY } from './schema-fields.mjs';
|
|
2
|
+
export const SCHEMA_REGISTRY_TOOLS = [
|
|
3
|
+
{
|
|
4
|
+
name: 'schema_list',
|
|
5
|
+
description: 'Lists all registered JSON Schemas and the current schema registry revision.',
|
|
6
|
+
inputSchema: { type: 'object', properties: {} },
|
|
7
|
+
annotations: READ_ONLY,
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
name: 'schema_get',
|
|
11
|
+
description: 'Fetches one registered JSON Schema by id (latest version by default, or a pinned positive integer version).',
|
|
12
|
+
inputSchema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
id: { type: 'string', description: 'Registered schema id, for example "finding".' },
|
|
16
|
+
version: {
|
|
17
|
+
type: 'integer',
|
|
18
|
+
minimum: 1,
|
|
19
|
+
description: 'Optional pinned schema version number.',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
required: ['id'],
|
|
23
|
+
},
|
|
24
|
+
annotations: READ_ONLY,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'schema_pull',
|
|
28
|
+
description: 'Pulls the full JSON Schema registry into the local cache using If-None-Match so offline validation stays current.',
|
|
29
|
+
inputSchema: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: {
|
|
32
|
+
dir: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
description: 'Optional local schema cache directory override.',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
annotations: MUTATING,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'schema_validate',
|
|
42
|
+
description: 'Validates an entry payload offline against a locally pulled schema (<id> or <id>@<version>).',
|
|
43
|
+
inputSchema: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
schema: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
description: 'Schema reference (<id> or <id>@<version>), for example "finding" or "finding@1".',
|
|
49
|
+
},
|
|
50
|
+
data: {
|
|
51
|
+
type: 'object',
|
|
52
|
+
description: 'Entry JSON payload to validate.',
|
|
53
|
+
},
|
|
54
|
+
dir: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
description: 'Optional local schema cache directory override.',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
required: ['schema', 'data'],
|
|
60
|
+
},
|
|
61
|
+
annotations: READ_ONLY,
|
|
62
|
+
},
|
|
63
|
+
];
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ADDITIVE, MUTATING } from './schema-fields.mjs';
|
|
2
|
+
export const SNAPSHOT_TOOLS = [
|
|
3
|
+
{
|
|
4
|
+
name: 'snapshot_export',
|
|
5
|
+
description: 'Streams an immutable non-archived snapshot into a local private JSONL file and returns its path, counts, checksum, manifest, and (when path is omitted) cleanupToken.',
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
path: { type: 'string', description: 'Optional new absolute destination path.' },
|
|
10
|
+
agent: { type: 'string', description: 'Exact agent name to include.' },
|
|
11
|
+
version: { type: 'string', description: 'Exact agent version to include.' },
|
|
12
|
+
parentSessionId: {
|
|
13
|
+
type: ['string', 'null'],
|
|
14
|
+
pattern: '^[A-Za-z0-9._:-]+$',
|
|
15
|
+
description: 'Exact parent id; null selects root sessions.',
|
|
16
|
+
},
|
|
17
|
+
data: { type: 'object', description: 'Top-level session data fields to match exactly.' },
|
|
18
|
+
dataArrayContains: { type: 'object', description: 'Exact string membership in arrays.' },
|
|
19
|
+
inactiveForHours: {
|
|
20
|
+
type: 'number',
|
|
21
|
+
exclusiveMinimum: 0,
|
|
22
|
+
description: 'Only sessions inactive for this many hours (createdAt if no entries).',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
annotations: ADDITIVE,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'snapshot_partition',
|
|
30
|
+
description: 'Splits a generated temporary snapshot JSONL file into bounded session-preserving read-only partitions using the cleanupToken from snapshot_export.',
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: {
|
|
34
|
+
path: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
description: 'Generated temporary snapshot path returned by snapshot_export.',
|
|
37
|
+
},
|
|
38
|
+
cleanupToken: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
description: 'Ownership capability returned by snapshot_export.',
|
|
41
|
+
},
|
|
42
|
+
maxSessions: {
|
|
43
|
+
type: 'integer',
|
|
44
|
+
minimum: 1,
|
|
45
|
+
description: 'Maximum whole sessions per partition (default 25).',
|
|
46
|
+
},
|
|
47
|
+
maxBytes: {
|
|
48
|
+
type: 'integer',
|
|
49
|
+
minimum: 1,
|
|
50
|
+
description: 'Maximum bytes per partition (default 1048576).',
|
|
51
|
+
},
|
|
52
|
+
since: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'ISO-8601 cursor: keep only sessions whose lastEntryAt (or createdAt) is strictly after it.',
|
|
55
|
+
},
|
|
56
|
+
repository: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
pattern: '^[A-Za-z0-9._-]+/[A-Za-z0-9._-]+$',
|
|
59
|
+
description: 'owner/name: keep only entries tagged for it (entry or session data.repositories / data.repository, case-insensitive); untagged entries are dropped.',
|
|
60
|
+
},
|
|
61
|
+
digest: {
|
|
62
|
+
type: 'boolean',
|
|
63
|
+
description: 'Write compact digest-N.jsonl files (session lines each followed by their entries) instead of raw records.',
|
|
64
|
+
},
|
|
65
|
+
checksum: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
pattern: '^[a-f0-9]{64}$',
|
|
68
|
+
description: 'Optional SHA-256 hex digest to verify against the snapshot file.',
|
|
69
|
+
},
|
|
70
|
+
counts: {
|
|
71
|
+
type: 'object',
|
|
72
|
+
description: 'Optional exact snapshot counts to verify before partitioning.',
|
|
73
|
+
properties: {
|
|
74
|
+
sessions: { type: 'integer', minimum: 0 },
|
|
75
|
+
entries: { type: 'integer', minimum: 0 },
|
|
76
|
+
records: { type: 'integer', minimum: 0 },
|
|
77
|
+
bytes: { type: 'integer', minimum: 0 },
|
|
78
|
+
},
|
|
79
|
+
required: ['sessions', 'entries', 'records', 'bytes'],
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
required: ['path', 'cleanupToken'],
|
|
83
|
+
},
|
|
84
|
+
annotations: ADDITIVE,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'snapshot_cleanup',
|
|
88
|
+
description: 'Removes a generated temporary snapshot file and/or partition directory using the cleanupToken from snapshot_export or snapshot_partition. Pass path, directory, or both: the token alone removes nothing and is rejected.',
|
|
89
|
+
inputSchema: {
|
|
90
|
+
type: 'object',
|
|
91
|
+
properties: {
|
|
92
|
+
path: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
description: 'Generated temporary snapshot path to remove.',
|
|
95
|
+
},
|
|
96
|
+
directory: {
|
|
97
|
+
type: 'string',
|
|
98
|
+
description: 'Generated temporary partition directory to remove.',
|
|
99
|
+
},
|
|
100
|
+
cleanupToken: {
|
|
101
|
+
type: 'string',
|
|
102
|
+
description: 'Ownership capability returned by snapshot_export or snapshot_partition.',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
required: ['cleanupToken'],
|
|
106
|
+
},
|
|
107
|
+
annotations: MUTATING,
|
|
108
|
+
},
|
|
109
|
+
];
|
package/dist/mcp/schemas.mjs
CHANGED
|
@@ -1,30 +1,9 @@
|
|
|
1
1
|
import { ADDITIVE, AGENT, IDEMPOTENT_ADDITIVE, MUTATING, READ_ONLY, RESOLVABLE_SESSION_ID, SESSION_ID, } from './schema-fields.mjs';
|
|
2
|
+
import { OUTBOX_TOOLS } from './schemas-outbox-tools.mjs';
|
|
3
|
+
import { SCHEMA_REGISTRY_TOOLS } from './schemas-registry-tools.mjs';
|
|
4
|
+
import { SNAPSHOT_TOOLS } from './schemas-snapshot-tools.mjs';
|
|
2
5
|
export const ENTRY_TOOLS = [
|
|
3
|
-
|
|
4
|
-
name: 'snapshot_export',
|
|
5
|
-
description: 'Streams an immutable non-archived snapshot into a local private JSONL file and returns only its path, counts, checksum, and manifest.',
|
|
6
|
-
inputSchema: {
|
|
7
|
-
type: 'object',
|
|
8
|
-
properties: {
|
|
9
|
-
path: { type: 'string', description: 'Optional new absolute destination path.' },
|
|
10
|
-
agent: { type: 'string', description: 'Exact agent name to include.' },
|
|
11
|
-
version: { type: 'string', description: 'Exact agent version to include.' },
|
|
12
|
-
parentSessionId: {
|
|
13
|
-
type: ['string', 'null'],
|
|
14
|
-
pattern: '^[A-Za-z0-9._:-]+$',
|
|
15
|
-
description: 'Exact parent id; null selects root sessions.',
|
|
16
|
-
},
|
|
17
|
-
data: { type: 'object', description: 'Top-level session data fields to match exactly.' },
|
|
18
|
-
dataArrayContains: { type: 'object', description: 'Exact string membership in arrays.' },
|
|
19
|
-
inactiveForHours: {
|
|
20
|
-
type: 'number',
|
|
21
|
-
exclusiveMinimum: 0,
|
|
22
|
-
description: 'Only sessions inactive for this many hours (createdAt if no entries).',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
annotations: ADDITIVE,
|
|
27
|
-
},
|
|
6
|
+
...SNAPSHOT_TOOLS,
|
|
28
7
|
{
|
|
29
8
|
name: 'session_create',
|
|
30
9
|
description: 'Creates a root or subagent session before entries are appended.',
|
|
@@ -131,12 +110,22 @@ export const ENTRY_TOOLS = [
|
|
|
131
110
|
},
|
|
132
111
|
{
|
|
133
112
|
name: 'entry_append',
|
|
134
|
-
description: 'Appends
|
|
113
|
+
description: 'Appends an entry to an existing session, including an archived one. Optionally names a registered schemaId (and schemaVersion) for server-side validation and a per-session sourceEventId for idempotent retries.',
|
|
135
114
|
inputSchema: {
|
|
136
115
|
type: 'object',
|
|
137
116
|
properties: {
|
|
138
117
|
sessionId: RESOLVABLE_SESSION_ID,
|
|
139
|
-
data: { type: 'object', description: '
|
|
118
|
+
data: { type: 'object', description: 'Entry JSON payload.' },
|
|
119
|
+
schemaId: { type: 'string', description: 'Optional registered JSON Schema id.' },
|
|
120
|
+
schemaVersion: {
|
|
121
|
+
type: 'integer',
|
|
122
|
+
minimum: 1,
|
|
123
|
+
description: 'Optional pinned schema version number (requires schemaId).',
|
|
124
|
+
},
|
|
125
|
+
sourceEventId: {
|
|
126
|
+
type: 'string',
|
|
127
|
+
description: 'Optional per-session event id for idempotent writes: identical content returns the stored entry with duplicate: true; different content fails with 409.',
|
|
128
|
+
},
|
|
140
129
|
},
|
|
141
130
|
required: ['data'],
|
|
142
131
|
},
|
|
@@ -154,4 +143,6 @@ export const ENTRY_TOOLS = [
|
|
|
154
143
|
},
|
|
155
144
|
annotations: READ_ONLY,
|
|
156
145
|
},
|
|
146
|
+
...OUTBOX_TOOLS,
|
|
147
|
+
...SCHEMA_REGISTRY_TOOLS,
|
|
157
148
|
];
|
package/dist/mcp/server.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprot
|
|
|
4
4
|
import { formatError } from '../format-error.mjs';
|
|
5
5
|
import { dispatchTool } from './dispatch.mjs';
|
|
6
6
|
import { ENTRY_TOOLS } from './schemas.mjs';
|
|
7
|
+
import { withClientHarnessMarker } from './session-resolution.mjs';
|
|
7
8
|
const SERVER_INFO = { name: 'agent-blackboard', version: '0.0.0' };
|
|
8
9
|
/**
|
|
9
10
|
* Builds the MCP server with the session and entry tools registered, but does
|
|
@@ -15,7 +16,7 @@ export function createMcpServer(config, resolution) {
|
|
|
15
16
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: ENTRY_TOOLS }));
|
|
16
17
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
17
18
|
try {
|
|
18
|
-
const result = await dispatchTool(request.params.name, request.params.arguments ?? {}, config, resolution);
|
|
19
|
+
const result = await dispatchTool(request.params.name, request.params.arguments ?? {}, config, withClientHarnessMarker(resolution, server.getClientVersion()?.name));
|
|
19
20
|
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
20
21
|
}
|
|
21
22
|
catch (err) {
|
|
@@ -3,6 +3,13 @@ export interface SessionResolutionContext {
|
|
|
3
3
|
env: Readonly<Record<string, string | undefined>>;
|
|
4
4
|
cwd: string;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* A Cursor-launched MCP server usually gets only the URL and token from `mcp.json`, not
|
|
8
|
+
* `CURSOR_AGENT`. When the MCP client identifies itself as Cursor, mark the resolution env as
|
|
9
|
+
* Cursor so an omitted `sessionId` can fall back to the persisted Cursor id. Only the marker is
|
|
10
|
+
* set, never a runtime hint, so explicit harness env still takes precedence as usual.
|
|
11
|
+
*/
|
|
12
|
+
export declare function withClientHarnessMarker(resolution: SessionResolutionContext | undefined, clientName: string | undefined): SessionResolutionContext | undefined;
|
|
6
13
|
/**
|
|
7
14
|
* An explicit `sessionId` wins and is passed through (the server validates it). When omitted and
|
|
8
15
|
* a resolution context is available, the id is resolved from the harness environment or the
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { requireSessionAgent, requireSessionId, requireSessionIdentity, } from '../session-id/resolve.mjs';
|
|
2
2
|
import { requiredString } from './validate.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* A Cursor-launched MCP server usually gets only the URL and token from `mcp.json`, not
|
|
5
|
+
* `CURSOR_AGENT`. When the MCP client identifies itself as Cursor, mark the resolution env as
|
|
6
|
+
* Cursor so an omitted `sessionId` can fall back to the persisted Cursor id. Only the marker is
|
|
7
|
+
* set, never a runtime hint, so explicit harness env still takes precedence as usual.
|
|
8
|
+
*/
|
|
9
|
+
export function withClientHarnessMarker(resolution, clientName) {
|
|
10
|
+
if (resolution === undefined || resolution.env.CURSOR_AGENT)
|
|
11
|
+
return resolution;
|
|
12
|
+
if (!clientName?.toLowerCase().includes('cursor'))
|
|
13
|
+
return resolution;
|
|
14
|
+
return { ...resolution, env: { ...resolution.env, CURSOR_AGENT: '1' } };
|
|
15
|
+
}
|
|
3
16
|
/**
|
|
4
17
|
* An explicit `sessionId` wins and is passed through (the server validates it). When omitted and
|
|
5
18
|
* a resolution context is available, the id is resolved from the harness environment or the
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type SessionResolutionContext } from './session-resolution.mjs';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function handleEntryAppend(args: Record<string, unknown>, config: ClientConfig, resolution?: SessionResolutionContext): Promise<
|
|
2
|
+
import type { AppendEntryResult, ClientConfig } from '../client/types.mjs';
|
|
3
|
+
export declare function handleEntryAppend(args: Record<string, unknown>, config: ClientConfig, resolution?: SessionResolutionContext): Promise<AppendEntryResult>;
|
package/dist/mcp/tool-append.mjs
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import { appendEntry } from '../client/append.mjs';
|
|
2
|
+
import { resolveOutboxDir } from '../outbox/store.mjs';
|
|
2
3
|
import { toolSessionId } from './session-resolution.mjs';
|
|
3
|
-
import { expectObject } from './validate.mjs';
|
|
4
|
+
import { expectObject, optionalPositiveInt, requiredString } from './validate.mjs';
|
|
4
5
|
export function handleEntryAppend(args, config, resolution) {
|
|
5
|
-
|
|
6
|
+
const schemaId = args.schemaId === undefined ? undefined : requiredString(args.schemaId, 'schemaId');
|
|
7
|
+
const schemaVersion = optionalPositiveInt(args.schemaVersion, 'schemaVersion');
|
|
8
|
+
if (schemaVersion !== undefined && schemaId === undefined) {
|
|
9
|
+
throw new Error('"schemaVersion" requires "schemaId".');
|
|
10
|
+
}
|
|
11
|
+
const sourceEventId = args.sourceEventId === undefined
|
|
12
|
+
? undefined
|
|
13
|
+
: requiredString(args.sourceEventId, 'sourceEventId');
|
|
14
|
+
const outboxDir = config.outboxDir ?? (resolution ? resolveOutboxDir(resolution.cwd, resolution.env) : undefined);
|
|
15
|
+
return appendEntry(outboxDir === undefined ? config : { ...config, outboxDir }, {
|
|
6
16
|
sessionId: toolSessionId(args, resolution),
|
|
7
17
|
data: expectObject(args.data, 'data'),
|
|
18
|
+
...(schemaId !== undefined ? { schemaId } : {}),
|
|
19
|
+
...(schemaVersion !== undefined ? { schemaVersion } : {}),
|
|
20
|
+
...(sourceEventId !== undefined ? { sourceEventId } : {}),
|
|
8
21
|
});
|
|
9
22
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ClientConfig } from '../client/types.mjs';
|
|
2
|
+
import type { OutboxFlushResult, OutboxPruneResult, OutboxStatus } from '../outbox/types.mjs';
|
|
3
|
+
import type { SessionResolutionContext } from './session-resolution.mjs';
|
|
4
|
+
export declare function handleOutboxStatus(args: Record<string, unknown>, config: ClientConfig, resolution?: SessionResolutionContext): Promise<OutboxStatus>;
|
|
5
|
+
export declare function handleOutboxFlush(args: Record<string, unknown>, config: ClientConfig, resolution?: SessionResolutionContext): Promise<OutboxFlushResult>;
|
|
6
|
+
export declare function handleOutboxPruneRejected(args: Record<string, unknown>, config: ClientConfig, resolution?: SessionResolutionContext): Promise<OutboxPruneResult>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Outbox } from '../outbox/client.mjs';
|
|
2
|
+
import { requiredString } from './validate.mjs';
|
|
3
|
+
function locationOptions(args, resolution) {
|
|
4
|
+
const dir = args.dir === undefined ? undefined : requiredString(args.dir, 'dir');
|
|
5
|
+
return {
|
|
6
|
+
...(dir !== undefined ? { dir } : {}),
|
|
7
|
+
...(resolution?.cwd !== undefined ? { cwd: resolution.cwd } : {}),
|
|
8
|
+
...(resolution?.env !== undefined ? { env: resolution.env } : {}),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export async function handleOutboxStatus(args, config, resolution) {
|
|
12
|
+
return new Outbox(config).status(locationOptions(args, resolution));
|
|
13
|
+
}
|
|
14
|
+
export function handleOutboxFlush(args, config, resolution) {
|
|
15
|
+
const sessionId = args.sessionId === undefined ? undefined : requiredString(args.sessionId, 'sessionId');
|
|
16
|
+
return new Outbox(config).flush({
|
|
17
|
+
...locationOptions(args, resolution),
|
|
18
|
+
...(sessionId !== undefined ? { sessionId } : {}),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export async function handleOutboxPruneRejected(args, config, resolution) {
|
|
22
|
+
const id = args.id === undefined ? undefined : requiredString(args.id, 'id');
|
|
23
|
+
const sessionId = args.sessionId === undefined ? undefined : requiredString(args.sessionId, 'sessionId');
|
|
24
|
+
return new Outbox(config).pruneRejected({
|
|
25
|
+
...locationOptions(args, resolution),
|
|
26
|
+
...(id !== undefined ? { id } : {}),
|
|
27
|
+
...(sessionId !== undefined ? { sessionId } : {}),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ListSchemasResult, PullSchemasResult, SchemaValidationResult, SchemaVersionDetail } from '../client/schema-types.mjs';
|
|
2
|
+
import type { ClientConfig } from '../client/types.mjs';
|
|
3
|
+
import type { SessionResolutionContext } from './session-resolution.mjs';
|
|
4
|
+
export declare function handleSchemaList(config: ClientConfig): Promise<ListSchemasResult>;
|
|
5
|
+
export declare function handleSchemaGet(args: Record<string, unknown>, config: ClientConfig): Promise<SchemaVersionDetail>;
|
|
6
|
+
export declare function handleSchemaPull(args: Record<string, unknown>, config: ClientConfig, resolution?: SessionResolutionContext): Promise<PullSchemasResult>;
|
|
7
|
+
export declare function handleSchemaValidate(args: Record<string, unknown>, config: ClientConfig, resolution?: SessionResolutionContext): Promise<SchemaValidationResult>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Schemas } from '../client/schemas.mjs';
|
|
2
|
+
import { expectObject, optionalPositiveInt, requiredString } from './validate.mjs';
|
|
3
|
+
function localOptions(args, resolution) {
|
|
4
|
+
const dir = args.dir === undefined ? undefined : requiredString(args.dir, 'dir');
|
|
5
|
+
return {
|
|
6
|
+
...(dir !== undefined ? { dir } : {}),
|
|
7
|
+
...(resolution?.cwd !== undefined ? { cwd: resolution.cwd } : {}),
|
|
8
|
+
...(resolution?.env !== undefined ? { env: resolution.env } : {}),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export function handleSchemaList(config) {
|
|
12
|
+
return new Schemas(config).list();
|
|
13
|
+
}
|
|
14
|
+
export function handleSchemaGet(args, config) {
|
|
15
|
+
const id = requiredString(args.id, 'id');
|
|
16
|
+
const version = optionalPositiveInt(args.version, 'version');
|
|
17
|
+
return new Schemas(config).get(id, version);
|
|
18
|
+
}
|
|
19
|
+
export function handleSchemaPull(args, config, resolution) {
|
|
20
|
+
return new Schemas(config).pull(localOptions(args, resolution));
|
|
21
|
+
}
|
|
22
|
+
export async function handleSchemaValidate(args, config, resolution) {
|
|
23
|
+
const schema = requiredString(args.schema, 'schema');
|
|
24
|
+
const data = expectObject(args.data, 'data');
|
|
25
|
+
return new Schemas(config).validateLocal(schema, data, localOptions(args, resolution));
|
|
26
|
+
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { Snapshots } from '../client/snapshots.mjs';
|
|
2
|
+
import type { SnapshotPartitionResult } from '../client/snapshot-types.mjs';
|
|
2
3
|
import type { ClientConfig } from '../client/types.mjs';
|
|
3
4
|
/** Exports a local JSONL evidence file; never returns the snapshot records through MCP. */
|
|
4
5
|
export declare function handleSnapshotExport(args: Record<string, unknown>, config: ClientConfig): ReturnType<Snapshots['export']>;
|
|
6
|
+
/** Splits a generated temporary snapshot into bounded read-only partitions with ownership checks. */
|
|
7
|
+
export declare function handleSnapshotPartition(args: Record<string, unknown>): Promise<SnapshotPartitionResult>;
|
|
8
|
+
/** Cleans up generated temporary snapshot files and/or partition directories with ownership checks. */
|
|
9
|
+
export declare function handleSnapshotCleanup(args: Record<string, unknown>): Promise<{
|
|
10
|
+
removed: true;
|
|
11
|
+
}>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { cleanupSnapshotPartitions } from '../client/snapshot-partition-cleanup.mjs';
|
|
2
|
+
import { partitionSnapshot } from '../client/snapshot-partitions.mjs';
|
|
1
3
|
import { Snapshots } from '../client/snapshots.mjs';
|
|
2
|
-
import { expectObject, nullableString, optionalPositiveNumber, requiredString, } from './validate.mjs';
|
|
4
|
+
import { expectObject, nullableString, optionalPositiveInt, optionalPositiveNumber, requiredString, } from './validate.mjs';
|
|
3
5
|
function parentSessionId(value) {
|
|
4
6
|
const id = nullableString(value, 'parentSessionId');
|
|
5
7
|
if (id !== null && !/^[A-Za-z0-9._:-]+$/.test(id)) {
|
|
@@ -30,6 +32,23 @@ function selectionFrom(args) {
|
|
|
30
32
|
: { inactiveForHours: optionalPositiveNumber(args.inactiveForHours, 'inactiveForHours') }),
|
|
31
33
|
};
|
|
32
34
|
}
|
|
35
|
+
function nonNegativeInt(value, field) {
|
|
36
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0) {
|
|
37
|
+
throw new Error(`"${field}" must be a non-negative integer.`);
|
|
38
|
+
}
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
function optionalCounts(value) {
|
|
42
|
+
if (value === undefined)
|
|
43
|
+
return undefined;
|
|
44
|
+
const counts = expectObject(value, 'counts');
|
|
45
|
+
return {
|
|
46
|
+
sessions: nonNegativeInt(counts.sessions, 'counts.sessions'),
|
|
47
|
+
entries: nonNegativeInt(counts.entries, 'counts.entries'),
|
|
48
|
+
records: nonNegativeInt(counts.records, 'counts.records'),
|
|
49
|
+
bytes: nonNegativeInt(counts.bytes, 'counts.bytes'),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
33
52
|
/** Exports a local JSONL evidence file; never returns the snapshot records through MCP. */
|
|
34
53
|
export function handleSnapshotExport(args, config) {
|
|
35
54
|
const path = args.path === undefined ? undefined : requiredString(args.path, 'path');
|
|
@@ -38,3 +57,45 @@ export function handleSnapshotExport(args, config) {
|
|
|
38
57
|
selection: selectionFrom(args),
|
|
39
58
|
});
|
|
40
59
|
}
|
|
60
|
+
/** Splits a generated temporary snapshot into bounded read-only partitions with ownership checks. */
|
|
61
|
+
export function handleSnapshotPartition(args) {
|
|
62
|
+
const path = requiredString(args.path, 'path');
|
|
63
|
+
const cleanupToken = requiredString(args.cleanupToken, 'cleanupToken');
|
|
64
|
+
const maxSessions = optionalPositiveInt(args.maxSessions, 'maxSessions');
|
|
65
|
+
const maxBytes = optionalPositiveInt(args.maxBytes, 'maxBytes');
|
|
66
|
+
const checksum = args.checksum === undefined ? undefined : requiredString(args.checksum, 'checksum');
|
|
67
|
+
if (checksum !== undefined && !/^[a-f0-9]{64}$/.test(checksum)) {
|
|
68
|
+
throw new Error('"checksum" must be a SHA-256 hex digest.');
|
|
69
|
+
}
|
|
70
|
+
const counts = optionalCounts(args.counts);
|
|
71
|
+
const since = args.since === undefined ? undefined : requiredString(args.since, 'since');
|
|
72
|
+
const repository = args.repository === undefined ? undefined : requiredString(args.repository, 'repository');
|
|
73
|
+
if (args.digest !== undefined && typeof args.digest !== 'boolean')
|
|
74
|
+
throw new Error('"digest" must be a boolean.');
|
|
75
|
+
return partitionSnapshot({
|
|
76
|
+
path,
|
|
77
|
+
cleanupToken,
|
|
78
|
+
...(maxSessions === undefined ? {} : { maxSessions }),
|
|
79
|
+
...(maxBytes === undefined ? {} : { maxBytes }),
|
|
80
|
+
...(checksum === undefined ? {} : { checksum: { algorithm: 'sha256', value: checksum } }),
|
|
81
|
+
...(counts === undefined ? {} : { counts }),
|
|
82
|
+
...(since === undefined ? {} : { since }),
|
|
83
|
+
...(repository === undefined ? {} : { repository }),
|
|
84
|
+
...(args.digest === undefined ? {} : { digest: args.digest }),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/** Cleans up generated temporary snapshot files and/or partition directories with ownership checks. */
|
|
88
|
+
export async function handleSnapshotCleanup(args) {
|
|
89
|
+
const path = args.path === undefined ? undefined : requiredString(args.path, 'path');
|
|
90
|
+
const directory = args.directory === undefined ? undefined : requiredString(args.directory, 'directory');
|
|
91
|
+
if (!path && !directory) {
|
|
92
|
+
throw new Error('"snapshot_cleanup" requires "path" or "directory".');
|
|
93
|
+
}
|
|
94
|
+
const cleanupToken = requiredString(args.cleanupToken, 'cleanupToken');
|
|
95
|
+
await cleanupSnapshotPartitions({
|
|
96
|
+
...(path === undefined ? {} : { path }),
|
|
97
|
+
...(directory === undefined ? {} : { directory }),
|
|
98
|
+
cleanupToken,
|
|
99
|
+
});
|
|
100
|
+
return { removed: true };
|
|
101
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AgentBlackboardError } from '../client/errors.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true when an `entry_append` failure is a transport/network failure or a retryable
|
|
4
|
+
* HTTP status (`401`, `408`, `429`, `5xx`), meaning the entry should be buffered in the outbox.
|
|
5
|
+
* Configuration and serialization errors (such as invalid URLs) return false and throw immediately.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isRetryableAppendError(error: unknown): boolean;
|
|
8
|
+
/** Returns true when the server permanently rejected the entry (non-retryable 4xx). */
|
|
9
|
+
export declare function isPermanentRejection(error: unknown): error is AgentBlackboardError;
|