@atrib/annotate 0.2.40 → 1.0.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 +9 -0
- package/dist/index.d.ts +2 -48
- package/dist/index.js +8 -116
- package/dist/main.js +4 -4
- package/package.json +3 -5
package/README.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atrib/annotate
|
|
2
2
|
|
|
3
|
+
**Legacy home.** The write-verb implementation moved to
|
|
4
|
+
[`@atrib/attest`](../atrib-attest/README.md) per the attest/recall rename
|
|
5
|
+
([D164](../../DECISIONS.md#d164-attestrecall-verb-rename-and-primitive-surface-collapse)).
|
|
6
|
+
Annotation folds into `attest` with `ref: { kind: "annotates", target }`.
|
|
7
|
+
This package re-exports the same surface and forwards the `atrib-annotate`
|
|
8
|
+
binary to `@atrib/attest`'s handlers. Records are byte-identical. The
|
|
9
|
+
`atrib-annotate` tool name stays mounted as a permanent alias during the
|
|
10
|
+
alias window, alongside the new `attest` tool.
|
|
11
|
+
|
|
3
12
|
MCP server exposing the `atrib-annotate` tool for atrib's verifiable action layer. Marks a past signed record with importance, a one-line summary, and topics, so future recall can surface what mattered without re-scanning every record flat.
|
|
4
13
|
|
|
5
14
|
Closes the producer-side recall-fidelity gap: an agent reading back its own past loses enormous nuance compared to the agent that signed it. An annotation lets the agent at signing time say "future-self: this one is critical, and here's why in one line", and the graph carries that judgment forward.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,48 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { type EmitLocalSubstrateShadowOptions, type ResolvedKey } from '@atrib/emit';
|
|
4
|
-
export declare const Importance: z.ZodEnum<{
|
|
5
|
-
critical: "critical";
|
|
6
|
-
high: "high";
|
|
7
|
-
medium: "medium";
|
|
8
|
-
low: "low";
|
|
9
|
-
noise: "noise";
|
|
10
|
-
}>;
|
|
11
|
-
export declare const AnnotateInput: z.ZodObject<{
|
|
12
|
-
annotates: z.ZodString;
|
|
13
|
-
importance: z.ZodEnum<{
|
|
14
|
-
critical: "critical";
|
|
15
|
-
high: "high";
|
|
16
|
-
medium: "medium";
|
|
17
|
-
low: "low";
|
|
18
|
-
noise: "noise";
|
|
19
|
-
}>;
|
|
20
|
-
summary: z.ZodString;
|
|
21
|
-
topics: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
22
|
-
context_id: z.ZodOptional<z.ZodString>;
|
|
23
|
-
informed_by: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
24
|
-
}, z.core.$strip>;
|
|
25
|
-
export interface AtribAnnotateServer {
|
|
26
|
-
/** Underlying McpServer; expose for testing or composition. */
|
|
27
|
-
mcp: McpServer;
|
|
28
|
-
/** Drain pending submissions (for tests/shutdown). */
|
|
29
|
-
flush(): Promise<void>;
|
|
30
|
-
}
|
|
31
|
-
export interface CreateAtribAnnotateServerOptions {
|
|
32
|
-
/** Override the resolved key (primarily for testing). */
|
|
33
|
-
key?: ResolvedKey | null | undefined;
|
|
34
|
-
/** Override the log endpoint (defaults to env or @atrib/mcp default). */
|
|
35
|
-
logEndpoint?: string | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* Optional long-lived-agent local substrate shadow probe. `undefined` reads
|
|
38
|
-
* opt-in env config; `false` disables env config for this server.
|
|
39
|
-
*/
|
|
40
|
-
localSubstrate?: EmitLocalSubstrateShadowOptions | false | undefined;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Wire up the atrib-annotate MCP server with one `atrib-annotate` tool.
|
|
44
|
-
* Per D079: this is a specialized form of @atrib/emit; the underlying
|
|
45
|
-
* signing pipeline is shared via handleEmit so annotation records are
|
|
46
|
-
* byte-identical regardless of which tool produced them.
|
|
47
|
-
*/
|
|
48
|
-
export declare function createAtribAnnotateServer(options?: CreateAtribAnnotateServerOptions): Promise<AtribAnnotateServer>;
|
|
1
|
+
export { AnnotateInput, Importance, createAtribAnnotateServer, registerAnnotateTool, } from '@atrib/attest';
|
|
2
|
+
export type { AtribAnnotateServer, CreateAtribAnnotateServerOptions } from '@atrib/attest';
|
package/dist/index.js
CHANGED
|
@@ -1,116 +1,8 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
// annotation records signed via this tool from those signed via emit's
|
|
10
|
-
// polymorphic surface.
|
|
11
|
-
//
|
|
12
|
-
// Scope:
|
|
13
|
-
// - One tool: atrib-annotate
|
|
14
|
-
// - Narrow input schema: REQUIRES annotates (sha256:<64-hex>), importance, summary
|
|
15
|
-
// - One key per process (same identity as the wrapper + atrib-emit)
|
|
16
|
-
// - Persists to the same JSONL mirror convention as atrib-emit
|
|
17
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
18
|
-
import { z } from 'zod';
|
|
19
|
-
import { resolveEmitLocalSubstrateShadowFromEnv, handleEmit, resolveKey, } from '@atrib/emit';
|
|
20
|
-
import { createSubmissionQueue, EVENT_TYPE_ANNOTATION_URI, } from '@atrib/mcp';
|
|
21
|
-
const SHA256_REF_PATTERN = /^sha256:[0-9a-f]{64}$/;
|
|
22
|
-
const HEX_32_PATTERN = /^[0-9a-f]{32}$/;
|
|
23
|
-
export const Importance = z.enum(['critical', 'high', 'medium', 'low', 'noise']);
|
|
24
|
-
export const AnnotateInput = z.object({
|
|
25
|
-
annotates: z.string().regex(SHA256_REF_PATTERN).describe("'sha256:<64-hex>' record_hash this annotation describes per spec §1.2.7 / D058. " +
|
|
26
|
-
'REQUIRED. The target record can be any prior record (yours or another agent\'s).'),
|
|
27
|
-
importance: Importance.describe('Felt importance for future-self recall ranking. ' +
|
|
28
|
-
"'critical' (decisions that shape future recall, identity claims), " +
|
|
29
|
-
"'high' (worth surfacing in default recall), " +
|
|
30
|
-
"'medium' (general signal), " +
|
|
31
|
-
"'low' (background noting), " +
|
|
32
|
-
"'noise' (deliberately deprioritized for recall)."),
|
|
33
|
-
summary: z.string().min(1).max(2048).describe('One-line semantic gist of the annotation. The recall pipeline reads this verbatim ' +
|
|
34
|
-
'for snippet display; keep it under ~120 chars when possible. ' +
|
|
35
|
-
'Distinct from the annotated record\'s own content, this summary captures what ' +
|
|
36
|
-
'future-you should know about why this record matters.'),
|
|
37
|
-
topics: z.array(z.string().min(1).max(128)).max(16).optional().describe('Optional topic tags. Used by recall_my_attribution_history\'s topics filter. ' +
|
|
38
|
-
'Lowercase-hyphenated convention (e.g. "bug-fix", "design-decision").'),
|
|
39
|
-
context_id: z.string().regex(HEX_32_PATTERN).optional().describe('32-hex context_id. Defaults to process.env.ATRIB_CONTEXT_ID per D078 when omitted; ' +
|
|
40
|
-
'falls back to a fresh genesis context_id if neither is set.'),
|
|
41
|
-
informed_by: z.array(z.string().regex(SHA256_REF_PATTERN)).optional().describe("Array of 'sha256:<64-hex>' record_hashes that informed this annotation. " +
|
|
42
|
-
'Sorted lexicographically before signing per §1.2.5. The `annotates` reference ' +
|
|
43
|
-
'is separate from `informed_by` and need not be duplicated here.'),
|
|
44
|
-
});
|
|
45
|
-
/**
|
|
46
|
-
* Wire up the atrib-annotate MCP server with one `atrib-annotate` tool.
|
|
47
|
-
* Per D079: this is a specialized form of @atrib/emit; the underlying
|
|
48
|
-
* signing pipeline is shared via handleEmit so annotation records are
|
|
49
|
-
* byte-identical regardless of which tool produced them.
|
|
50
|
-
*/
|
|
51
|
-
export async function createAtribAnnotateServer(options = {}) {
|
|
52
|
-
const resolveServerKey = createServerKeyResolver(options);
|
|
53
|
-
const logEndpoint = options.logEndpoint ?? process.env['ATRIB_LOG_ENDPOINT'];
|
|
54
|
-
const queue = createSubmissionQueue(logEndpoint);
|
|
55
|
-
const localSubstrate = options.localSubstrate === false
|
|
56
|
-
? undefined
|
|
57
|
-
: (options.localSubstrate ??
|
|
58
|
-
resolveEmitLocalSubstrateShadowFromEnv({
|
|
59
|
-
producer: 'atrib-annotate',
|
|
60
|
-
transport: 'stdio-mcp-server',
|
|
61
|
-
}));
|
|
62
|
-
const mcp = new McpServer({ name: 'atrib-annotate', version: '0.1.0' });
|
|
63
|
-
mcp.registerTool('atrib-annotate', {
|
|
64
|
-
description: 'Mark a past record\'s importance and meaning without superseding it. ' +
|
|
65
|
-
'Cognitive primitive #2 of D079; produces a signed annotation event ' +
|
|
66
|
-
'(spec §1.2.7 / D058) that adds an ANNOTATES graph edge to the target. ' +
|
|
67
|
-
'Use when you want future-self or other agents to read back this past ' +
|
|
68
|
-
'record with weighted importance and a one-line gist.',
|
|
69
|
-
inputSchema: AnnotateInput.shape,
|
|
70
|
-
}, async (rawInput) => {
|
|
71
|
-
const input = AnnotateInput.parse(rawInput);
|
|
72
|
-
const result = await handleEmit({
|
|
73
|
-
input: {
|
|
74
|
-
event_type: EVENT_TYPE_ANNOTATION_URI,
|
|
75
|
-
content: {
|
|
76
|
-
annotates: input.annotates,
|
|
77
|
-
importance: input.importance,
|
|
78
|
-
summary: input.summary,
|
|
79
|
-
...(input.topics ? { topics: input.topics } : {}),
|
|
80
|
-
},
|
|
81
|
-
annotates: input.annotates,
|
|
82
|
-
...(input.context_id ? { context_id: input.context_id } : {}),
|
|
83
|
-
...(input.informed_by ? { informed_by: input.informed_by } : {}),
|
|
84
|
-
},
|
|
85
|
-
key: await resolveServerKey(),
|
|
86
|
-
queue,
|
|
87
|
-
producer: 'atrib-annotate',
|
|
88
|
-
localSubstrate,
|
|
89
|
-
});
|
|
90
|
-
const out = {
|
|
91
|
-
record_hash: result.record_hash,
|
|
92
|
-
log_index: result.log_index,
|
|
93
|
-
inclusion_proof: result.inclusion_proof,
|
|
94
|
-
context_id: result.context_id,
|
|
95
|
-
warnings: result.warnings,
|
|
96
|
-
};
|
|
97
|
-
return {
|
|
98
|
-
content: [{ type: 'text', text: JSON.stringify(out, null, 2) }],
|
|
99
|
-
};
|
|
100
|
-
});
|
|
101
|
-
return {
|
|
102
|
-
mcp,
|
|
103
|
-
flush: () => queue.flush(),
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function createServerKeyResolver(options) {
|
|
107
|
-
if (Object.prototype.hasOwnProperty.call(options, 'key')) {
|
|
108
|
-
const fixed = options.key ?? null;
|
|
109
|
-
return async () => fixed;
|
|
110
|
-
}
|
|
111
|
-
let resolved = null;
|
|
112
|
-
return async () => {
|
|
113
|
-
resolved ??= resolveKey();
|
|
114
|
-
return resolved;
|
|
115
|
-
};
|
|
116
|
-
}
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// @atrib/annotate is the legacy home of the atrib-annotate write primitive
|
|
3
|
+
// (cognitive primitive #2 of D079). The implementation lives in
|
|
4
|
+
// @atrib/attest: annotation folds into the write verb as
|
|
5
|
+
// attest ref.kind='annotates', and the atrib-annotate tool name stays
|
|
6
|
+
// mounted as a permanent alias over the same handler. Records signed
|
|
7
|
+
// through either surface are byte-identical in canonical form.
|
|
8
|
+
export { AnnotateInput, Importance, createAtribAnnotateServer, registerAnnotateTool, } from '@atrib/attest';
|
package/dist/main.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// atrib-annotate standalone binary.
|
|
3
|
-
//
|
|
4
|
-
//
|
|
2
|
+
// atrib-annotate standalone binary (forwarding shim). Serves the legacy
|
|
3
|
+
// atrib-annotate server, which mounts `atrib-annotate` plus `attest` per
|
|
4
|
+
// the alias-window rule W1.
|
|
5
5
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
6
|
-
import { createAtribAnnotateServer } from '
|
|
6
|
+
import { createAtribAnnotateServer } from '@atrib/attest';
|
|
7
7
|
async function main() {
|
|
8
8
|
const { mcp } = await createAtribAnnotateServer();
|
|
9
9
|
const transport = new StdioServerTransport();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atrib/annotate",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Legacy home of atrib's annotate write primitive. Superseded by @atrib/attest (the write verb, ref.kind=\"annotates\"); this package re-exports the same surface and forwards the atrib-annotate binary.",
|
|
5
5
|
"author": "atrib <hello@atrib.dev>",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"atrib",
|
|
@@ -24,9 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
27
|
-
"
|
|
28
|
-
"@atrib/mcp": "0.20.0",
|
|
29
|
-
"@atrib/emit": "0.17.2"
|
|
27
|
+
"@atrib/attest": "0.1.0"
|
|
30
28
|
},
|
|
31
29
|
"devDependencies": {
|
|
32
30
|
"@types/node": "^25.9.3",
|