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/cli/snapshot.mjs
CHANGED
|
@@ -6,18 +6,8 @@ import { clientConfigFromEnv } from './env.mjs';
|
|
|
6
6
|
import { CliError } from './errors.mjs';
|
|
7
7
|
import { parseDataArrayContains } from './data-array-contains.mjs';
|
|
8
8
|
import { writeLine } from './output.mjs';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
'path',
|
|
12
|
-
'cleanup-token',
|
|
13
|
-
'max-sessions',
|
|
14
|
-
'max-bytes',
|
|
15
|
-
'checksum',
|
|
16
|
-
'sessions',
|
|
17
|
-
'entries',
|
|
18
|
-
'records',
|
|
19
|
-
'bytes',
|
|
20
|
-
];
|
|
9
|
+
import { createRevisionNotifier } from './revision-notice.mjs';
|
|
10
|
+
import { PARTITION_FLAGS, partitionCounts, partitionFilters, } from './snapshot-partition-options.mjs';
|
|
21
11
|
function optionalString(flags, key, command = 'snapshot export') {
|
|
22
12
|
const value = stringFlag(flags, key);
|
|
23
13
|
if (Object.hasOwn(flags, key) && !value)
|
|
@@ -118,6 +108,7 @@ export async function runSnapshot(argv, ctx) {
|
|
|
118
108
|
const maxSessions = positiveInteger(flags, 'max-sessions');
|
|
119
109
|
const maxBytes = positiveInteger(flags, 'max-bytes');
|
|
120
110
|
const checksum = optionalString(flags, 'checksum');
|
|
111
|
+
const filters = partitionFilters(flags, optionalString);
|
|
121
112
|
const counts = partitionCounts(flags, optionalString);
|
|
122
113
|
if (checksum !== undefined && !/^[a-f0-9]{64}$/.test(checksum)) {
|
|
123
114
|
throw new CliError('snapshot partition --checksum must be a SHA-256 hex digest.');
|
|
@@ -130,6 +121,7 @@ export async function runSnapshot(argv, ctx) {
|
|
|
130
121
|
...(maxBytes === undefined ? {} : { maxBytes }),
|
|
131
122
|
...(checksum === undefined ? {} : { checksum: { algorithm: 'sha256', value: checksum } }),
|
|
132
123
|
...(counts === undefined ? {} : { counts }),
|
|
124
|
+
...filters,
|
|
133
125
|
});
|
|
134
126
|
writeLine(ctx.stdout, JSON.stringify(result));
|
|
135
127
|
return;
|
|
@@ -167,7 +159,7 @@ export async function runSnapshot(argv, ctx) {
|
|
|
167
159
|
throw new CliError('snapshot export accepts flags only.');
|
|
168
160
|
const path = optionalString(flags, 'path');
|
|
169
161
|
const selection = selectionFrom(flags);
|
|
170
|
-
const result = await new Snapshots(clientConfigFromEnv(ctx.env)).export({
|
|
162
|
+
const result = await new Snapshots(clientConfigFromEnv(ctx.env, createRevisionNotifier(ctx))).export({
|
|
171
163
|
...(path === undefined ? {} : { path }),
|
|
172
164
|
selection,
|
|
173
165
|
});
|
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\nOmitted session ids and agents resolve from the harness environment (CLAUDE_CODE_SESSION_ID,\nCODEX_THREAD_ID, CURSOR_SESSION_ID, GROK_SESSION_ID) or <worktree>/.local/<harness>-session-id.\nInteractive root Codex: --root-codex creates or reuses the worktree id; --new-root-codex-session rotates it.\n\nEnv:\n AGENT_BLACKBOARD_URL Server base URL\n AGENT_BLACKBOARD_TOKEN Client credential\n AGENT_BLACKBOARD_ADMIN_TOKEN Admin credential\n";
|
|
1
|
+
export declare const USAGE = "agent-blackboard \u2014 an entry stream for autonomous agents\n\nUsage:\n agent-blackboard sessions create [<id>] [--agent <name>] --version <version> [--parent-session-id <id>]\n agent-blackboard sessions ensure [<id>] [--agent <name>] --version <version> [--parent-session-id <id>]\n agent-blackboard sessions list [--archived true|false] [--inactive-for-hours <hours>]\n agent-blackboard sessions get <id>\n agent-blackboard sessions patch <id> --data <json>\n agent-blackboard sessions archive <id>\n agent-blackboard append [--session-id <id>] [--schema <id>[@<version>]] [--source-event-id <id>] <json>\n agent-blackboard append [--session-id <id>] [--schema <id>[@<version>]] [--source-event-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>] [--since <iso>] [--repository <owner/name>] [--digest] [--checksum <sha256>] [--sessions <count> --entries <count> --records <count> --bytes <count>]\n agent-blackboard snapshot cleanup [--path <generated-snapshot>] [--directory <generated-partition-directory>] --cleanup-token <token>\n agent-blackboard schemas pull [--dir <path>]\n agent-blackboard schemas put <id> <file> [--breaking] [--shadow]\n agent-blackboard schemas promote <id>@<version>\n agent-blackboard schemas report <id>[@<version>] [--limit <n>]\n agent-blackboard schemas remove <id>\n agent-blackboard schemas list\n agent-blackboard schemas get <id>[@<version>]\n agent-blackboard schemas validate <id>[@<version>] <file> [--dir <path>]\n agent-blackboard outbox status [--dir <path>]\n agent-blackboard outbox flush [--session-id <id>] [--dir <path>]\n agent-blackboard outbox prune [--id <id>] [--session-id <id>] [--dir <path>]\n agent-blackboard credentials <subcommand>\n agent-blackboard mcp\n\nOmitted session ids and agents resolve from the harness environment (CLAUDE_CODE_SESSION_ID,\nCODEX_THREAD_ID, CURSOR_SESSION_ID, GROK_SESSION_ID) or <worktree>/.local/<harness>-session-id.\nInteractive root Codex: --root-codex creates or reuses the worktree id; --new-root-codex-session rotates it.\n\nEnv:\n AGENT_BLACKBOARD_URL Server base URL\n AGENT_BLACKBOARD_TOKEN Client credential\n AGENT_BLACKBOARD_ADMIN_TOKEN Admin credential\n AGENT_BLACKBOARD_SCHEMAS_DIR Optional local schema cache directory\n AGENT_BLACKBOARD_OUTBOX_DIR Optional local entry outbox directory\n";
|
package/dist/cli/usage.mjs
CHANGED
|
@@ -7,14 +7,25 @@ Usage:
|
|
|
7
7
|
agent-blackboard sessions get <id>
|
|
8
8
|
agent-blackboard sessions patch <id> --data <json>
|
|
9
9
|
agent-blackboard sessions archive <id>
|
|
10
|
-
agent-blackboard append [--session-id <id>] <json>
|
|
11
|
-
agent-blackboard append [--session-id <id>] --file <json|markdown|text>
|
|
10
|
+
agent-blackboard append [--session-id <id>] [--schema <id>[@<version>]] [--source-event-id <id>] <json>
|
|
11
|
+
agent-blackboard append [--session-id <id>] [--schema <id>[@<version>]] [--source-event-id <id>] --file <json|markdown|text>
|
|
12
12
|
agent-blackboard get [--session-id <id>] [--format json|jsonl|markdown]
|
|
13
13
|
agent-blackboard snapshot export [--path <absolute-path>] [--agent <name>] [--version <version>]
|
|
14
14
|
[--parent-session-id <id>|--root-only] [--data <json>] [--inactive-for-hours <hours>]
|
|
15
15
|
agent-blackboard snapshot partition --path <generated-snapshot> --cleanup-token <token> [--max-sessions <count>]
|
|
16
|
-
[--max-bytes <bytes>] [--checksum <sha256>] [--sessions <count> --entries <count> --records <count> --bytes <count>]
|
|
16
|
+
[--max-bytes <bytes>] [--since <iso>] [--repository <owner/name>] [--digest] [--checksum <sha256>] [--sessions <count> --entries <count> --records <count> --bytes <count>]
|
|
17
17
|
agent-blackboard snapshot cleanup [--path <generated-snapshot>] [--directory <generated-partition-directory>] --cleanup-token <token>
|
|
18
|
+
agent-blackboard schemas pull [--dir <path>]
|
|
19
|
+
agent-blackboard schemas put <id> <file> [--breaking] [--shadow]
|
|
20
|
+
agent-blackboard schemas promote <id>@<version>
|
|
21
|
+
agent-blackboard schemas report <id>[@<version>] [--limit <n>]
|
|
22
|
+
agent-blackboard schemas remove <id>
|
|
23
|
+
agent-blackboard schemas list
|
|
24
|
+
agent-blackboard schemas get <id>[@<version>]
|
|
25
|
+
agent-blackboard schemas validate <id>[@<version>] <file> [--dir <path>]
|
|
26
|
+
agent-blackboard outbox status [--dir <path>]
|
|
27
|
+
agent-blackboard outbox flush [--session-id <id>] [--dir <path>]
|
|
28
|
+
agent-blackboard outbox prune [--id <id>] [--session-id <id>] [--dir <path>]
|
|
18
29
|
agent-blackboard credentials <subcommand>
|
|
19
30
|
agent-blackboard mcp
|
|
20
31
|
|
|
@@ -26,4 +37,6 @@ Env:
|
|
|
26
37
|
AGENT_BLACKBOARD_URL Server base URL
|
|
27
38
|
AGENT_BLACKBOARD_TOKEN Client credential
|
|
28
39
|
AGENT_BLACKBOARD_ADMIN_TOKEN Admin credential
|
|
40
|
+
AGENT_BLACKBOARD_SCHEMAS_DIR Optional local schema cache directory
|
|
41
|
+
AGENT_BLACKBOARD_OUTBOX_DIR Optional local entry outbox directory
|
|
29
42
|
`;
|
package/dist/client/append.d.mts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import type { AppendEntryInput, ClientConfig,
|
|
2
|
-
|
|
1
|
+
import type { AppendEntryInput, AppendEntryResult, ClientConfig, StoredEntryResult } from './types.mjs';
|
|
2
|
+
/** Sends `POST /sessions/:id/entries` directly without outbox fallback. */
|
|
3
|
+
export declare function sendAppendEntry(config: ClientConfig, input: AppendEntryInput): Promise<StoredEntryResult>;
|
|
4
|
+
export declare function appendEntry(config: ClientConfig, input: AppendEntryInput): Promise<AppendEntryResult>;
|
package/dist/client/append.mjs
CHANGED
|
@@ -1,9 +1,51 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { formatError } from '../format-error.mjs';
|
|
3
|
+
import { isRetryableAppendError } from '../outbox/classify.mjs';
|
|
4
|
+
import { enqueueOutboxEntry } from '../outbox/store.mjs';
|
|
5
|
+
import { outboxTargetFromConfig } from '../outbox/target.mjs';
|
|
1
6
|
import { requestJson } from './http.mjs';
|
|
2
7
|
const JSON_HEADERS = { 'content-type': 'application/json' };
|
|
3
|
-
|
|
8
|
+
/** Sends `POST /sessions/:id/entries` directly without outbox fallback. */
|
|
9
|
+
export async function sendAppendEntry(config, input) {
|
|
4
10
|
return requestJson(config, `/sessions/${encodeURIComponent(input.sessionId)}/entries`, {
|
|
5
11
|
method: 'POST',
|
|
6
12
|
headers: JSON_HEADERS,
|
|
7
|
-
body: JSON.stringify({
|
|
13
|
+
body: JSON.stringify({
|
|
14
|
+
data: input.data,
|
|
15
|
+
...(input.schemaId !== undefined ? { schemaId: input.schemaId } : {}),
|
|
16
|
+
...(input.schemaVersion !== undefined ? { schemaVersion: input.schemaVersion } : {}),
|
|
17
|
+
...(input.sourceEventId !== undefined ? { sourceEventId: input.sourceEventId } : {}),
|
|
18
|
+
}),
|
|
8
19
|
});
|
|
9
20
|
}
|
|
21
|
+
export async function appendEntry(config, input) {
|
|
22
|
+
// When outbox fallback is enabled, freeze the payload and bind a stable sourceEventId
|
|
23
|
+
// before the first POST so a stored-but-unacknowledged response deduplicates on flush.
|
|
24
|
+
const prepared = config.outboxDir !== undefined
|
|
25
|
+
? {
|
|
26
|
+
...input,
|
|
27
|
+
data: structuredClone(input.data),
|
|
28
|
+
sourceEventId: input.sourceEventId ?? `outbox-${randomUUID()}`,
|
|
29
|
+
}
|
|
30
|
+
: input;
|
|
31
|
+
try {
|
|
32
|
+
return await sendAppendEntry(config, prepared);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (config.outboxDir !== undefined && isRetryableAppendError(error)) {
|
|
36
|
+
const record = enqueueOutboxEntry(config.outboxDir, prepared, formatError(error), undefined, outboxTargetFromConfig(config));
|
|
37
|
+
return {
|
|
38
|
+
queued: true,
|
|
39
|
+
outboxId: record.id,
|
|
40
|
+
sessionId: record.sessionId,
|
|
41
|
+
data: record.data,
|
|
42
|
+
...(record.schemaId !== undefined ? { schemaId: record.schemaId } : {}),
|
|
43
|
+
...(record.schemaVersion !== undefined ? { schemaVersion: record.schemaVersion } : {}),
|
|
44
|
+
sourceEventId: record.sourceEventId,
|
|
45
|
+
queuedAt: record.queuedAt,
|
|
46
|
+
error: record.lastError,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AppendEntryInput, ClientConfig, GetEntriesQuery, SessionEntry } from './types.mjs';
|
|
1
|
+
import type { AppendEntryInput, AppendEntryResult, ClientConfig, GetEntriesQuery, SessionEntry } from './types.mjs';
|
|
2
2
|
export declare class Entries {
|
|
3
3
|
#private;
|
|
4
4
|
constructor(config: ClientConfig);
|
|
5
|
-
append(input: AppendEntryInput): Promise<
|
|
5
|
+
append(input: AppendEntryInput): Promise<AppendEntryResult>;
|
|
6
6
|
get(query: GetEntriesQuery): AsyncIterable<SessionEntry>;
|
|
7
7
|
}
|
package/dist/client/http.d.mts
CHANGED
|
@@ -17,6 +17,8 @@ interface RequestOptions {
|
|
|
17
17
|
* body streamed (not buffered) should read `response.body` directly.
|
|
18
18
|
*/
|
|
19
19
|
export declare function rawRequest(config: ClientConfig, path: string, options: RequestOptions): Promise<Response>;
|
|
20
|
+
/** Issues an authenticated GET that treats HTTP 304 Not Modified as a valid response. */
|
|
21
|
+
export declare function rawConditionalGet(config: ClientConfig, path: string, options: Omit<RequestOptions, 'method'>): Promise<Response>;
|
|
20
22
|
/** Issues an authenticated HTTP request and parses the response body as JSON. */
|
|
21
23
|
export declare function requestJson<T>(config: ClientConfig, path: string, options: RequestOptions): Promise<T>;
|
|
22
24
|
export {};
|
package/dist/client/http.mjs
CHANGED
|
@@ -74,12 +74,14 @@ async function errorFor(response, method, path) {
|
|
|
74
74
|
async function discard(response) {
|
|
75
75
|
await response.body?.cancel().catch(() => undefined);
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
const SCHEMA_REVISION_HEADER = 'x-schema-registry-revision';
|
|
78
|
+
function notifySchemaRevision(config, response) {
|
|
79
|
+
const raw = response.headers.get(SCHEMA_REVISION_HEADER);
|
|
80
|
+
if (raw === null || !/^[0-9]{1,15}$/.test(raw))
|
|
81
|
+
return;
|
|
82
|
+
config.onSchemaRevision?.(Number.parseInt(raw, 10));
|
|
83
|
+
}
|
|
84
|
+
async function fetchWithRetry(config, path, options, allowNotModified) {
|
|
83
85
|
const url = buildUrl(config.baseUrl, path, options.query ?? {});
|
|
84
86
|
assertSecureUrl(url);
|
|
85
87
|
const headers = new Headers(options.headers);
|
|
@@ -99,14 +101,30 @@ export async function rawRequest(config, path, options) {
|
|
|
99
101
|
await delay(retryDelay(retry, attempt));
|
|
100
102
|
continue;
|
|
101
103
|
}
|
|
102
|
-
if (response.ok)
|
|
104
|
+
if (response.ok || (allowNotModified && response.status === 304)) {
|
|
105
|
+
notifySchemaRevision(config, response);
|
|
103
106
|
return response;
|
|
104
|
-
|
|
107
|
+
}
|
|
108
|
+
if (!retry || attempt === retry.maxRetries || !RETRYABLE_READ_STATUSES.has(response.status)) {
|
|
109
|
+
notifySchemaRevision(config, response);
|
|
105
110
|
return errorFor(response, options.method, path);
|
|
111
|
+
}
|
|
106
112
|
await discard(response);
|
|
107
113
|
await delay(retryDelay(retry, attempt));
|
|
108
114
|
}
|
|
109
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Issues an authenticated HTTP request and returns the raw `Response`,
|
|
118
|
+
* throwing `AgentBlackboardError` on any non-2xx status. Callers that need the
|
|
119
|
+
* body streamed (not buffered) should read `response.body` directly.
|
|
120
|
+
*/
|
|
121
|
+
export async function rawRequest(config, path, options) {
|
|
122
|
+
return fetchWithRetry(config, path, options, false);
|
|
123
|
+
}
|
|
124
|
+
/** Issues an authenticated GET that treats HTTP 304 Not Modified as a valid response. */
|
|
125
|
+
export async function rawConditionalGet(config, path, options) {
|
|
126
|
+
return fetchWithRetry(config, path, { ...options, method: 'GET' }, true);
|
|
127
|
+
}
|
|
110
128
|
/** Issues an authenticated HTTP request and parses the response body as JSON. */
|
|
111
129
|
export async function requestJson(config, path, options) {
|
|
112
130
|
const response = await rawRequest(config, path, options);
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export interface SchemaSummary {
|
|
2
|
+
id: string;
|
|
3
|
+
latestVersion: number;
|
|
4
|
+
deprecatedAt: string | null;
|
|
5
|
+
deprecatedBy: string | null;
|
|
6
|
+
createdAt: string;
|
|
7
|
+
createdBy: string;
|
|
8
|
+
updatedAt: string;
|
|
9
|
+
updatedBy: string;
|
|
10
|
+
}
|
|
11
|
+
export type SchemaVersionMode = 'enforced' | 'shadow';
|
|
12
|
+
export interface SchemaVersionRecord {
|
|
13
|
+
id: string;
|
|
14
|
+
version: number;
|
|
15
|
+
ref: string;
|
|
16
|
+
schema: Record<string, unknown>;
|
|
17
|
+
mode?: SchemaVersionMode;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
createdBy: string;
|
|
20
|
+
promotedAt?: string | null;
|
|
21
|
+
promotedBy?: string | null;
|
|
22
|
+
}
|
|
23
|
+
export interface SchemaWithVersions extends SchemaSummary {
|
|
24
|
+
versions: SchemaVersionRecord[];
|
|
25
|
+
}
|
|
26
|
+
export interface SchemaBundle {
|
|
27
|
+
revision: number;
|
|
28
|
+
schemas: SchemaWithVersions[];
|
|
29
|
+
}
|
|
30
|
+
export interface ListSchemasResult {
|
|
31
|
+
revision: number;
|
|
32
|
+
schemas: SchemaSummary[];
|
|
33
|
+
}
|
|
34
|
+
export interface SchemaVersionDetail extends SchemaSummary {
|
|
35
|
+
version: number;
|
|
36
|
+
ref: string;
|
|
37
|
+
schema: Record<string, unknown>;
|
|
38
|
+
mode?: SchemaVersionMode;
|
|
39
|
+
versionCreatedAt: string;
|
|
40
|
+
versionCreatedBy: string;
|
|
41
|
+
promotedAt?: string | null;
|
|
42
|
+
promotedBy?: string | null;
|
|
43
|
+
revision: number;
|
|
44
|
+
}
|
|
45
|
+
export interface ListSchemaVersionsResult extends SchemaSummary {
|
|
46
|
+
versions: SchemaVersionRecord[];
|
|
47
|
+
revision: number;
|
|
48
|
+
}
|
|
49
|
+
interface BreakingChange {
|
|
50
|
+
path: string;
|
|
51
|
+
kind: string;
|
|
52
|
+
message: string;
|
|
53
|
+
}
|
|
54
|
+
export interface PutSchemaResult extends SchemaVersionRecord {
|
|
55
|
+
revision: number;
|
|
56
|
+
compatible: boolean;
|
|
57
|
+
breakingChanges: BreakingChange[];
|
|
58
|
+
}
|
|
59
|
+
export interface DeprecateSchemaResult {
|
|
60
|
+
id: string;
|
|
61
|
+
latestVersion: number;
|
|
62
|
+
deprecatedAt: string | null;
|
|
63
|
+
deprecatedBy: string | null;
|
|
64
|
+
revision: number;
|
|
65
|
+
}
|
|
66
|
+
export interface PullSchemasResult {
|
|
67
|
+
upToDate: boolean;
|
|
68
|
+
revision: number;
|
|
69
|
+
schemaCount: number;
|
|
70
|
+
versionCount: number;
|
|
71
|
+
dir: string;
|
|
72
|
+
}
|
|
73
|
+
export interface SchemaValidationIssue {
|
|
74
|
+
instancePath: string;
|
|
75
|
+
schemaPath: string;
|
|
76
|
+
keyword: string;
|
|
77
|
+
message: string;
|
|
78
|
+
}
|
|
79
|
+
export interface SchemaValidationResult {
|
|
80
|
+
valid: boolean;
|
|
81
|
+
schema: string;
|
|
82
|
+
revision: number;
|
|
83
|
+
errors: SchemaValidationIssue[];
|
|
84
|
+
}
|
|
85
|
+
export interface SchemaShadowWarning {
|
|
86
|
+
code: string;
|
|
87
|
+
message: string;
|
|
88
|
+
schema?: string;
|
|
89
|
+
details?: SchemaValidationIssue[];
|
|
90
|
+
}
|
|
91
|
+
export interface PromoteSchemaResult extends SchemaVersionRecord {
|
|
92
|
+
revision: number;
|
|
93
|
+
alreadyEnforced: boolean;
|
|
94
|
+
}
|
|
95
|
+
interface SchemaShadowFailureRecord {
|
|
96
|
+
schemaId: string;
|
|
97
|
+
schemaVersion: number;
|
|
98
|
+
sessionId: string;
|
|
99
|
+
occurredAt: string;
|
|
100
|
+
code: string;
|
|
101
|
+
message: string;
|
|
102
|
+
details: SchemaValidationIssue[];
|
|
103
|
+
}
|
|
104
|
+
interface SchemaShadowVersionCount {
|
|
105
|
+
version: number;
|
|
106
|
+
ref: string;
|
|
107
|
+
mode: SchemaVersionMode;
|
|
108
|
+
failureCount: number;
|
|
109
|
+
lastFailureAt: string | null;
|
|
110
|
+
}
|
|
111
|
+
export interface SchemaShadowReport {
|
|
112
|
+
id: string;
|
|
113
|
+
version: number | null;
|
|
114
|
+
totalFailures: number;
|
|
115
|
+
versions: SchemaShadowVersionCount[];
|
|
116
|
+
recentFailures: SchemaShadowFailureRecord[];
|
|
117
|
+
revision: number;
|
|
118
|
+
}
|
|
119
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DeprecateSchemaResult, ListSchemasResult, ListSchemaVersionsResult, PromoteSchemaResult, PutSchemaResult, SchemaBundle, SchemaShadowReport, SchemaVersionDetail } from './schema-types.mjs';
|
|
2
|
+
import type { ClientConfig } from './types.mjs';
|
|
3
|
+
export declare function listSchemasRequest(config: ClientConfig): Promise<ListSchemasResult>;
|
|
4
|
+
export declare function getSchemaRequest(config: ClientConfig, id: string, version?: number): Promise<SchemaVersionDetail>;
|
|
5
|
+
export declare function listSchemaVersionsRequest(config: ClientConfig, id: string): Promise<ListSchemaVersionsResult>;
|
|
6
|
+
export type FetchSchemaBundleResult = {
|
|
7
|
+
notModified: true;
|
|
8
|
+
revision: number;
|
|
9
|
+
} | {
|
|
10
|
+
notModified: false;
|
|
11
|
+
bundle: SchemaBundle;
|
|
12
|
+
};
|
|
13
|
+
export declare function fetchSchemaBundleRequest(config: ClientConfig, ifNoneMatchRevision?: number): Promise<FetchSchemaBundleResult>;
|
|
14
|
+
export declare function putSchemaRequest(config: ClientConfig, id: string, input: {
|
|
15
|
+
schema: Record<string, unknown>;
|
|
16
|
+
breaking?: boolean;
|
|
17
|
+
shadow?: boolean;
|
|
18
|
+
}): Promise<PutSchemaResult>;
|
|
19
|
+
export declare function promoteSchemaRequest(config: ClientConfig, id: string, version: number): Promise<PromoteSchemaResult>;
|
|
20
|
+
export declare function getSchemaReportRequest(config: ClientConfig, id: string, version?: number, limit?: number): Promise<SchemaShadowReport>;
|
|
21
|
+
export declare function deprecateSchemaRequest(config: ClientConfig, id: string): Promise<DeprecateSchemaResult>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { isValidSchemaId } from '../schemas/id.mjs';
|
|
2
|
+
import { rawConditionalGet, requestJson } from './http.mjs';
|
|
3
|
+
const JSON_HEADERS = { 'content-type': 'application/json' };
|
|
4
|
+
function requireValidSchemaId(id) {
|
|
5
|
+
if (!isValidSchemaId(id))
|
|
6
|
+
throw new TypeError(`Invalid schema id: ${id}`);
|
|
7
|
+
return encodeURIComponent(id);
|
|
8
|
+
}
|
|
9
|
+
export async function listSchemasRequest(config) {
|
|
10
|
+
return requestJson(config, '/schemas', { method: 'GET' });
|
|
11
|
+
}
|
|
12
|
+
export async function getSchemaRequest(config, id, version) {
|
|
13
|
+
const encodedId = requireValidSchemaId(id);
|
|
14
|
+
const path = version === undefined ? `/schemas/${encodedId}` : `/schemas/${encodedId}/versions/${version}`;
|
|
15
|
+
return requestJson(config, path, { method: 'GET' });
|
|
16
|
+
}
|
|
17
|
+
export async function listSchemaVersionsRequest(config, id) {
|
|
18
|
+
return requestJson(config, `/schemas/${requireValidSchemaId(id)}/versions`, { method: 'GET' });
|
|
19
|
+
}
|
|
20
|
+
export async function fetchSchemaBundleRequest(config, ifNoneMatchRevision) {
|
|
21
|
+
const headers = ifNoneMatchRevision === undefined
|
|
22
|
+
? undefined
|
|
23
|
+
: { 'if-none-match': `"rev-${ifNoneMatchRevision}"` };
|
|
24
|
+
const response = await rawConditionalGet(config, '/schemas', {
|
|
25
|
+
query: { include: 'versions' },
|
|
26
|
+
...(headers ? { headers } : {}),
|
|
27
|
+
});
|
|
28
|
+
if (response.status === 304) {
|
|
29
|
+
const rawRev = response.headers.get('x-schema-registry-revision');
|
|
30
|
+
const revision = rawRev !== null && /^[0-9]+$/.test(rawRev)
|
|
31
|
+
? Number.parseInt(rawRev, 10)
|
|
32
|
+
: (ifNoneMatchRevision ?? 0);
|
|
33
|
+
return { notModified: true, revision };
|
|
34
|
+
}
|
|
35
|
+
const bundle = (await response.json());
|
|
36
|
+
return { notModified: false, bundle };
|
|
37
|
+
}
|
|
38
|
+
export async function putSchemaRequest(config, id, input) {
|
|
39
|
+
return requestJson(config, `/schemas/${requireValidSchemaId(id)}`, {
|
|
40
|
+
method: 'PUT',
|
|
41
|
+
headers: JSON_HEADERS,
|
|
42
|
+
body: JSON.stringify(input),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
export async function promoteSchemaRequest(config, id, version) {
|
|
46
|
+
return requestJson(config, `/schemas/${requireValidSchemaId(id)}/versions/${version}/promote`, {
|
|
47
|
+
method: 'POST',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export async function getSchemaReportRequest(config, id, version, limit) {
|
|
51
|
+
const encodedId = requireValidSchemaId(id);
|
|
52
|
+
const path = version === undefined
|
|
53
|
+
? `/schemas/${encodedId}/report`
|
|
54
|
+
: `/schemas/${encodedId}/versions/${version}/report`;
|
|
55
|
+
return requestJson(config, path, {
|
|
56
|
+
method: 'GET',
|
|
57
|
+
...(limit !== undefined ? { query: { limit: String(limit) } } : {}),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
export async function deprecateSchemaRequest(config, id) {
|
|
61
|
+
return requestJson(config, `/schemas/${requireValidSchemaId(id)}`, { method: 'DELETE' });
|
|
62
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ListSchemasResult, ListSchemaVersionsResult, PullSchemasResult, SchemaValidationResult, SchemaVersionDetail } from './schema-types.mjs';
|
|
2
|
+
import type { ClientConfig } from './types.mjs';
|
|
3
|
+
export interface LocalSchemaOptions {
|
|
4
|
+
/** Explicit local schema directory; overrides `AGENT_BLACKBOARD_SCHEMAS_DIR` and worktree default. */
|
|
5
|
+
dir?: string;
|
|
6
|
+
/** Working directory for worktree-root discovery; defaults to `process.cwd()`. */
|
|
7
|
+
cwd?: string;
|
|
8
|
+
/** Environment map checked for `AGENT_BLACKBOARD_SCHEMAS_DIR`; defaults to `{}`. */
|
|
9
|
+
env?: NodeJS.ProcessEnv;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Read-only client for the Agent Blackboard JSON Schema registry plus local offline
|
|
13
|
+
* pull/validation helpers. Schema writes (`put`, `remove`) are CLI/admin-only.
|
|
14
|
+
*/
|
|
15
|
+
export declare class Schemas {
|
|
16
|
+
#private;
|
|
17
|
+
constructor(config: ClientConfig);
|
|
18
|
+
list(): Promise<ListSchemasResult>;
|
|
19
|
+
get(id: string, version?: number): Promise<SchemaVersionDetail>;
|
|
20
|
+
listVersions(id: string): Promise<ListSchemaVersionsResult>;
|
|
21
|
+
pull(options?: LocalSchemaOptions): Promise<PullSchemasResult>;
|
|
22
|
+
validateLocal(schemaRef: string, data: unknown, options?: LocalSchemaOptions): SchemaValidationResult;
|
|
23
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { normalizeRegistrySource, readLocalBundle, resolveSchemasDir, writeLocalBundle, } from '../schemas/local-store.mjs';
|
|
2
|
+
import { validateAgainstLocalSchemas } from '../schemas/validate.mjs';
|
|
3
|
+
import { fetchSchemaBundleRequest, getSchemaRequest, listSchemasRequest, listSchemaVersionsRequest, } from './schemas-client.mjs';
|
|
4
|
+
/**
|
|
5
|
+
* Read-only client for the Agent Blackboard JSON Schema registry plus local offline
|
|
6
|
+
* pull/validation helpers. Schema writes (`put`, `remove`) are CLI/admin-only.
|
|
7
|
+
*/
|
|
8
|
+
export class Schemas {
|
|
9
|
+
#config;
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.#config = config;
|
|
12
|
+
}
|
|
13
|
+
list() {
|
|
14
|
+
return listSchemasRequest(this.#config);
|
|
15
|
+
}
|
|
16
|
+
get(id, version) {
|
|
17
|
+
return getSchemaRequest(this.#config, id, version);
|
|
18
|
+
}
|
|
19
|
+
listVersions(id) {
|
|
20
|
+
return listSchemaVersionsRequest(this.#config, id);
|
|
21
|
+
}
|
|
22
|
+
async pull(options = {}) {
|
|
23
|
+
const dir = resolveSchemasDir(options.cwd ?? process.cwd(), options.env ?? {}, options.dir);
|
|
24
|
+
const source = normalizeRegistrySource(this.#config.baseUrl);
|
|
25
|
+
const local = readLocalBundle(dir, source);
|
|
26
|
+
let fetched = await fetchSchemaBundleRequest(this.#config, local?.revision);
|
|
27
|
+
if (fetched.notModified) {
|
|
28
|
+
const current = readLocalBundle(dir, source);
|
|
29
|
+
if (current) {
|
|
30
|
+
return {
|
|
31
|
+
upToDate: true,
|
|
32
|
+
revision: current.revision,
|
|
33
|
+
schemaCount: current.schemas.length,
|
|
34
|
+
versionCount: current.schemas.reduce((sum, item) => sum + item.versions.length, 0),
|
|
35
|
+
dir,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (local) {
|
|
39
|
+
fetched = await fetchSchemaBundleRequest(this.#config);
|
|
40
|
+
}
|
|
41
|
+
if (fetched.notModified) {
|
|
42
|
+
return { upToDate: true, revision: fetched.revision, schemaCount: 0, versionCount: 0, dir };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const current = readLocalBundle(dir, source);
|
|
46
|
+
if (current && current.revision > fetched.bundle.revision) {
|
|
47
|
+
return {
|
|
48
|
+
upToDate: true,
|
|
49
|
+
revision: current.revision,
|
|
50
|
+
schemaCount: current.schemas.length,
|
|
51
|
+
versionCount: current.schemas.reduce((sum, item) => sum + item.versions.length, 0),
|
|
52
|
+
dir,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const counts = writeLocalBundle(dir, fetched.bundle, undefined, source);
|
|
56
|
+
return {
|
|
57
|
+
upToDate: false,
|
|
58
|
+
revision: fetched.bundle.revision,
|
|
59
|
+
schemaCount: counts.schemaCount,
|
|
60
|
+
versionCount: counts.versionCount,
|
|
61
|
+
dir,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
validateLocal(schemaRef, data, options = {}) {
|
|
65
|
+
const dir = resolveSchemasDir(options.cwd ?? process.cwd(), options.env ?? {}, options.dir);
|
|
66
|
+
return validateAgainstLocalSchemas(dir, schemaRef, data);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClientConfig, CreateSessionInput, ListSessionsQuery, ListSessionsResult, PatchSessionInput, Session } from './types.mjs';
|
|
1
|
+
import type { ClientConfig, CreateSessionInput, ListSessionsQuery, ListSessionsResult, PatchSessionInput, PatchSessionResult, Session } from './types.mjs';
|
|
2
2
|
export interface EnsureSessionResult {
|
|
3
3
|
status: 'created' | 'exists';
|
|
4
4
|
session: Session;
|
|
@@ -15,6 +15,6 @@ export declare class Sessions {
|
|
|
15
15
|
ensure(input: CreateSessionInput): Promise<EnsureSessionResult>;
|
|
16
16
|
list(query?: ListSessionsQuery): Promise<ListSessionsResult>;
|
|
17
17
|
get(sessionId: string): Promise<Session>;
|
|
18
|
-
patch(input: PatchSessionInput): Promise<
|
|
18
|
+
patch(input: PatchSessionInput): Promise<PatchSessionResult>;
|
|
19
19
|
archive(sessionId: string): Promise<Session>;
|
|
20
20
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type SnapshotFilter } from './snapshot-digest.mjs';
|
|
2
|
+
import type { SnapshotBlock } from './snapshot-partition-format.mjs';
|
|
3
|
+
import { type Identity } from './snapshot-artifact-removal.mjs';
|
|
4
|
+
export interface PendingSession {
|
|
5
|
+
session: Record<string, unknown>;
|
|
6
|
+
entries: Record<string, unknown>[];
|
|
7
|
+
ordinal: number;
|
|
8
|
+
}
|
|
9
|
+
/** Stages one filtered session as a private block file, or returns undefined when nothing is left. */
|
|
10
|
+
export declare function stageFilteredSession(directory: string, directoryIdentity: Identity, pending: PendingSession, filter: SnapshotFilter): Promise<SnapshotBlock | undefined>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { open } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { renderSession } from './snapshot-digest.mjs';
|
|
4
|
+
import { writeAll } from './snapshot-partition-io.mjs';
|
|
5
|
+
import { assertDirectoryIdentity } from './snapshot-artifact-removal.mjs';
|
|
6
|
+
/** Stages one filtered session as a private block file, or returns undefined when nothing is left. */
|
|
7
|
+
export async function stageFilteredSession(directory, directoryIdentity, pending, filter) {
|
|
8
|
+
const rendered = renderSession(pending.session, pending.entries, filter);
|
|
9
|
+
if (!rendered)
|
|
10
|
+
return undefined;
|
|
11
|
+
const path = join(directory, `session-${pending.ordinal}.jsonl`);
|
|
12
|
+
const label = 'snapshot staging directory';
|
|
13
|
+
await assertDirectoryIdentity(directory, directoryIdentity, label);
|
|
14
|
+
const file = await open(path, 'wx', 0o600);
|
|
15
|
+
try {
|
|
16
|
+
await assertDirectoryIdentity(directory, directoryIdentity, label);
|
|
17
|
+
const bytes = Buffer.from(rendered.lines.join(''));
|
|
18
|
+
await writeAll(file, bytes);
|
|
19
|
+
await file.sync();
|
|
20
|
+
const identity = await file.stat({ bigint: true });
|
|
21
|
+
return {
|
|
22
|
+
sessionId: pending.session.id,
|
|
23
|
+
path,
|
|
24
|
+
identity: { dev: String(identity.dev), ino: String(identity.ino) },
|
|
25
|
+
bytes: bytes.byteLength,
|
|
26
|
+
sessions: 1,
|
|
27
|
+
entries: rendered.entries,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
await file.close();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { SnapshotPartitionOptions } from './snapshot-types.mjs';
|
|
2
|
+
/** Validated, normalized form of the opt-in `since`, `repository`, and `digest` options. */
|
|
3
|
+
export interface SnapshotFilter {
|
|
4
|
+
since?: {
|
|
5
|
+
raw: string;
|
|
6
|
+
time: number;
|
|
7
|
+
};
|
|
8
|
+
repository?: {
|
|
9
|
+
raw: string;
|
|
10
|
+
key: string;
|
|
11
|
+
};
|
|
12
|
+
digest: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** How one partition file is framed: its name prefix, optional header, and terminal line. */
|
|
15
|
+
export interface PartitionFormat {
|
|
16
|
+
prefix: string;
|
|
17
|
+
header: string;
|
|
18
|
+
trailer(counts: {
|
|
19
|
+
sessions: number;
|
|
20
|
+
entries: number;
|
|
21
|
+
}, manifestLine: string): string;
|
|
22
|
+
}
|
|
23
|
+
type Obj = Record<string, unknown>;
|
|
24
|
+
/** Returns undefined when no filtering option is set, so output stays byte-identical. */
|
|
25
|
+
export declare function filterFrom(options: Pick<SnapshotPartitionOptions, 'since' | 'repository' | 'digest'>): SnapshotFilter | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Renders one session as partition lines, or none when nothing is left to read. A session is
|
|
28
|
+
* kept only when `lastEntryAt ?? createdAt` is strictly after `since` (equal is dropped). An entry
|
|
29
|
+
* counts as tagged for `repository` when the entry or its session is tagged (case-insensitive);
|
|
30
|
+
* an untagged entry in an untagged session is dropped, and tags are never inferred. Sessions with
|
|
31
|
+
* no kept entries are dropped.
|
|
32
|
+
*/
|
|
33
|
+
export declare function renderSession(session: Obj, entries: Obj[], filter: SnapshotFilter): {
|
|
34
|
+
lines: string[];
|
|
35
|
+
entries: number;
|
|
36
|
+
} | undefined;
|
|
37
|
+
/** True when `since` drops this session, so its entries need not be kept while staging. */
|
|
38
|
+
export declare function sinceExcludes(session: Obj, filter: SnapshotFilter): boolean;
|
|
39
|
+
/** Frames digest files (`digest-N.jsonl`); raw or unfiltered output keeps today's framing. */
|
|
40
|
+
export declare function formatFor(filter: SnapshotFilter | undefined): PartitionFormat;
|
|
41
|
+
/** Bytes the digest lines of a parsed snapshot JSONL would occupy, before partition framing. */
|
|
42
|
+
export declare function digestBytes(jsonl: string, options?: Pick<SnapshotPartitionOptions, 'since' | 'repository'>): number;
|
|
43
|
+
export {};
|