@atrib/attest 0.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/LICENSE +216 -0
- package/README.md +187 -0
- package/dist/annotate.d.ts +56 -0
- package/dist/annotate.js +135 -0
- package/dist/attest.d.ts +69 -0
- package/dist/attest.js +214 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +729 -0
- package/dist/index.d.ts +312 -0
- package/dist/index.js +1028 -0
- package/dist/keys.d.ts +21 -0
- package/dist/keys.js +134 -0
- package/dist/local-substrate-host.d.ts +93 -0
- package/dist/local-substrate-host.js +467 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +18 -0
- package/dist/reference-resolution.d.ts +12 -0
- package/dist/reference-resolution.js +31 -0
- package/dist/revise.d.ts +43 -0
- package/dist/revise.js +133 -0
- package/dist/session-checkpoint.d.ts +103 -0
- package/dist/session-checkpoint.js +285 -0
- package/dist/sign.d.ts +69 -0
- package/dist/sign.js +74 -0
- package/dist/storage.d.ts +27 -0
- package/dist/storage.js +59 -0
- package/package.json +72 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AtribRecord } from '@atrib/mcp';
|
|
2
|
+
import type { ProofBundle } from '@atrib/mcp';
|
|
3
|
+
/**
|
|
4
|
+
* Pre-sign payload preserved locally. For atrib-emit, this is the original
|
|
5
|
+
* `content: { what, why_noted, topics, ... }` object the caller passed.
|
|
6
|
+
* Free-form per event_type (the same way `content` is on the input schema).
|
|
7
|
+
*/
|
|
8
|
+
export type LocalSidecar = {
|
|
9
|
+
/** Original pre-sign content payload as supplied by the caller. */
|
|
10
|
+
content?: Record<string, unknown>;
|
|
11
|
+
/** Producer that emitted this record, for cross-source disambiguation. */
|
|
12
|
+
producer?: string;
|
|
13
|
+
};
|
|
14
|
+
export interface MirrorLine {
|
|
15
|
+
record: AtribRecord;
|
|
16
|
+
proof: ProofBundle | null;
|
|
17
|
+
written_at: number;
|
|
18
|
+
/** Optional local-only sidecar; absent on legacy entries. */
|
|
19
|
+
_local?: LocalSidecar;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Append one record + optional proof + optional local sidecar to the
|
|
23
|
+
* mirror file. Failures log with the atrib-emit prefix and otherwise
|
|
24
|
+
* no-op, per §5.8 the mirror is best-effort and never blocks the
|
|
25
|
+
* agent.
|
|
26
|
+
*/
|
|
27
|
+
export declare function mirrorRecord(record: AtribRecord, proof: ProofBundle | null, localSidecar?: LocalSidecar): Promise<void>;
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Local JSONL mirror, same convention as the wrapper, so atrib-recall
|
|
2
|
+
// surfaces emit-signed records identically to wrapper-signed ones. Each
|
|
3
|
+
// line is one envelope around a signed AtribRecord plus optional proof
|
|
4
|
+
// and an OPTIONAL `_local` sidecar carrying pre-sign payload content.
|
|
5
|
+
//
|
|
6
|
+
// The `_local` sidecar is the local-only complement to the public log.
|
|
7
|
+
// Public log gets only the signed AtribRecord. For explicit emits, args_hash
|
|
8
|
+
// commits to the original content by default, while the local mirror keeps
|
|
9
|
+
// the pre-sign content so consumers (recall, trace, summarize) can surface
|
|
10
|
+
// semantic context, `topics`, `what`, `why_noted`, alongside the
|
|
11
|
+
// cryptographic evidence. Without the sidecar, mirror readers see only
|
|
12
|
+
// event_type + hashes and must guess at semantics.
|
|
13
|
+
//
|
|
14
|
+
// Sidecar shape rules:
|
|
15
|
+
// - Lives at the ENVELOPE level (not inside `record`). Never affects
|
|
16
|
+
// the signature, the signed bytes only ever contain the canonical
|
|
17
|
+
// AtribRecord fields.
|
|
18
|
+
// - Marked with underscore prefix (`_local`) per Python/etc. convention
|
|
19
|
+
// for "private to this layer".
|
|
20
|
+
// - Stripped at submission time by construction: the submission queue
|
|
21
|
+
// only ever sees the bare AtribRecord, so the sidecar can never
|
|
22
|
+
// leak to the public log.
|
|
23
|
+
// - Backward-compatible: existing mirror entries with no `_local`
|
|
24
|
+
// parse identically; readers must tolerate its absence.
|
|
25
|
+
//
|
|
26
|
+
// v1 keeps this minimal: append-only, no rotation, no compression. Path
|
|
27
|
+
// defaults to ATRIB_MIRROR_FILE, then to a per-agent file under
|
|
28
|
+
// ~/.atrib/records.
|
|
29
|
+
import { appendFile, mkdir } from 'node:fs/promises';
|
|
30
|
+
import { homedir } from 'node:os';
|
|
31
|
+
import { dirname, join } from 'node:path';
|
|
32
|
+
let ensuredDirs = new Set();
|
|
33
|
+
function mirrorPath() {
|
|
34
|
+
return (process.env['ATRIB_MIRROR_FILE'] ??
|
|
35
|
+
join(homedir(), '.atrib', 'records', `atrib-emit-${process.env['ATRIB_AGENT'] ?? 'claude-code'}.jsonl`));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Append one record + optional proof + optional local sidecar to the
|
|
39
|
+
* mirror file. Failures log with the atrib-emit prefix and otherwise
|
|
40
|
+
* no-op, per §5.8 the mirror is best-effort and never blocks the
|
|
41
|
+
* agent.
|
|
42
|
+
*/
|
|
43
|
+
export async function mirrorRecord(record, proof, localSidecar) {
|
|
44
|
+
const path = mirrorPath();
|
|
45
|
+
const line = { record, proof, written_at: Date.now() };
|
|
46
|
+
if (localSidecar) {
|
|
47
|
+
line._local = localSidecar;
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
if (!ensuredDirs.has(path)) {
|
|
51
|
+
await mkdir(dirname(path), { recursive: true });
|
|
52
|
+
ensuredDirs.add(path);
|
|
53
|
+
}
|
|
54
|
+
await appendFile(path, JSON.stringify(line) + '\n', 'utf-8');
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
console.warn('atrib-emit: mirror append failed', e instanceof Error ? e.message : String(e));
|
|
58
|
+
}
|
|
59
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atrib/attest",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "MCP server for atrib's write verb. One attest tool signs observations, annotations, and revisions; the legacy emit, atrib-annotate, and atrib-revise tool names stay mounted as aliases over the same handler.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"atrib",
|
|
7
|
+
"mcp",
|
|
8
|
+
"model-context-protocol",
|
|
9
|
+
"attribution",
|
|
10
|
+
"verifiable",
|
|
11
|
+
"agent",
|
|
12
|
+
"cognitive-primitive",
|
|
13
|
+
"ed25519",
|
|
14
|
+
"signed-records",
|
|
15
|
+
"attest"
|
|
16
|
+
],
|
|
17
|
+
"author": "Nader Helmy",
|
|
18
|
+
"homepage": "https://github.com/creatornader/atrib/tree/main/services/atrib-attest",
|
|
19
|
+
"license": "Apache-2.0",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./cli": {
|
|
29
|
+
"types": "./dist/cli.d.ts",
|
|
30
|
+
"import": "./dist/cli.js"
|
|
31
|
+
},
|
|
32
|
+
"./local-substrate-host": {
|
|
33
|
+
"types": "./dist/local-substrate-host.d.ts",
|
|
34
|
+
"import": "./dist/local-substrate-host.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"bin": {
|
|
38
|
+
"atrib-attest": "./dist/main.js",
|
|
39
|
+
"atrib-attest-cli": "./dist/cli.js"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
43
|
+
"@noble/ed25519": "^3.1.0",
|
|
44
|
+
"@noble/hashes": "^2.2.0",
|
|
45
|
+
"canonicalize": "^3.0.0",
|
|
46
|
+
"zod": "^3.25.76",
|
|
47
|
+
"@atrib/mcp": "0.21.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^25.9.3",
|
|
51
|
+
"tsx": "^4.22.4",
|
|
52
|
+
"typescript": "^6.0.3",
|
|
53
|
+
"vitest": "^4.1.8"
|
|
54
|
+
},
|
|
55
|
+
"files": [
|
|
56
|
+
"dist"
|
|
57
|
+
],
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
60
|
+
},
|
|
61
|
+
"repository": {
|
|
62
|
+
"type": "git",
|
|
63
|
+
"url": "git+https://github.com/creatornader/atrib.git",
|
|
64
|
+
"directory": "services/atrib-attest"
|
|
65
|
+
},
|
|
66
|
+
"scripts": {
|
|
67
|
+
"build": "rm -rf dist && tsc && chmod +x dist/main.js dist/cli.js dist/local-substrate-host.js",
|
|
68
|
+
"start": "node dist/main.js",
|
|
69
|
+
"dev": "tsx src/main.ts",
|
|
70
|
+
"test": "vitest run"
|
|
71
|
+
}
|
|
72
|
+
}
|