mneme-ai 1.6.0 → 1.8.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/dist/commands/adapter.d.ts +46 -0
- package/dist/commands/adapter.d.ts.map +1 -0
- package/dist/commands/adapter.js +143 -0
- package/dist/commands/adapter.js.map +1 -0
- package/dist/commands/adapter.test.d.ts +8 -0
- package/dist/commands/adapter.test.d.ts.map +1 -0
- package/dist/commands/adapter.test.js +77 -0
- package/dist/commands/adapter.test.js.map +1 -0
- package/dist/commands/court.d.ts +50 -8
- package/dist/commands/court.d.ts.map +1 -1
- package/dist/commands/court.js +511 -31
- package/dist/commands/court.js.map +1 -1
- package/dist/commands/court.test.d.ts +9 -0
- package/dist/commands/court.test.d.ts.map +1 -0
- package/dist/commands/court.test.js +131 -0
- package/dist/commands/court.test.js.map +1 -0
- package/dist/commands/daemon.d.ts +17 -7
- package/dist/commands/daemon.d.ts.map +1 -1
- package/dist/commands/daemon.js +327 -21
- package/dist/commands/daemon.js.map +1 -1
- package/dist/commands/daemon.test.d.ts +13 -0
- package/dist/commands/daemon.test.d.ts.map +1 -0
- package/dist/commands/daemon.test.js +142 -0
- package/dist/commands/daemon.test.js.map +1 -0
- package/dist/commands/federation.d.ts +25 -10
- package/dist/commands/federation.d.ts.map +1 -1
- package/dist/commands/federation.js +299 -34
- package/dist/commands/federation.js.map +1 -1
- package/dist/commands/federation.test.d.ts +12 -0
- package/dist/commands/federation.test.d.ts.map +1 -0
- package/dist/commands/federation.test.js +175 -0
- package/dist/commands/federation.test.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -6
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mneme adapter <vendor>` — export Mneme's tool catalog as the AI vendor's
|
|
3
|
+
* native function-calling / tool-use format.
|
|
4
|
+
*
|
|
5
|
+
* Strategic role: **make Mneme universal across every AI in the world.**
|
|
6
|
+
* Even AI tools that don't speak MCP can use Mneme — the user (or their AI
|
|
7
|
+
* provider's tool-registration UI) imports the exported manifest and the
|
|
8
|
+
* AI immediately knows how to call all 94+ Mneme tools.
|
|
9
|
+
*
|
|
10
|
+
* Supported vendors (v1.8.0):
|
|
11
|
+
* • openai — function-calling JSON for GPT-4 / Codex / o-series
|
|
12
|
+
* • anthropic — tool-use JSON for Claude
|
|
13
|
+
* • gemini — Vertex AI tool definitions for Gemini
|
|
14
|
+
* • mcp — original MCP catalog (passthrough, for sanity check)
|
|
15
|
+
*
|
|
16
|
+
* Usage:
|
|
17
|
+
* mneme adapter openai > openai-tools.json
|
|
18
|
+
* mneme adapter anthropic > claude-tools.json
|
|
19
|
+
* mneme adapter gemini > gemini-tools.json
|
|
20
|
+
*
|
|
21
|
+
* Then the AI vendor's CLI/API loads the file and the AI gains access to
|
|
22
|
+
* Mneme. Each adapter format wraps Mneme tool descriptions, JSON schemas,
|
|
23
|
+
* and the universal calling convention (HTTP POST or local CLI invoke).
|
|
24
|
+
*/
|
|
25
|
+
export interface AdapterOptions {
|
|
26
|
+
cwd: string;
|
|
27
|
+
vendor: "openai" | "anthropic" | "gemini" | "mcp";
|
|
28
|
+
out?: string;
|
|
29
|
+
json?: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface MnemeToolForExport {
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
inputSchema: unknown;
|
|
35
|
+
category?: string;
|
|
36
|
+
triggers?: string[];
|
|
37
|
+
}
|
|
38
|
+
declare function exportOpenAI(catalog: MnemeToolForExport[]): unknown;
|
|
39
|
+
declare function exportAnthropic(catalog: MnemeToolForExport[]): unknown;
|
|
40
|
+
declare function exportGemini(catalog: MnemeToolForExport[]): unknown;
|
|
41
|
+
export declare function adapterCommand(opts: AdapterOptions): Promise<number>;
|
|
42
|
+
export declare const _exportOpenAIForTests: typeof exportOpenAI;
|
|
43
|
+
export declare const _exportAnthropicForTests: typeof exportAnthropic;
|
|
44
|
+
export declare const _exportGeminiForTests: typeof exportGemini;
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/commands/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAOH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,KAAK,CAAC;IAClD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AA0BD,iBAAS,YAAY,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAoB5D;AAKD,iBAAS,eAAe,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAgB/D;AAKD,iBAAS,YAAY,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAe5D;AAoBD,wBAAsB,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAsB1E;AAGD,eAAO,MAAM,qBAAqB,qBAAe,CAAC;AAClD,eAAO,MAAM,wBAAwB,wBAAkB,CAAC;AACxD,eAAO,MAAM,qBAAqB,qBAAe,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mneme adapter <vendor>` — export Mneme's tool catalog as the AI vendor's
|
|
3
|
+
* native function-calling / tool-use format.
|
|
4
|
+
*
|
|
5
|
+
* Strategic role: **make Mneme universal across every AI in the world.**
|
|
6
|
+
* Even AI tools that don't speak MCP can use Mneme — the user (or their AI
|
|
7
|
+
* provider's tool-registration UI) imports the exported manifest and the
|
|
8
|
+
* AI immediately knows how to call all 94+ Mneme tools.
|
|
9
|
+
*
|
|
10
|
+
* Supported vendors (v1.8.0):
|
|
11
|
+
* • openai — function-calling JSON for GPT-4 / Codex / o-series
|
|
12
|
+
* • anthropic — tool-use JSON for Claude
|
|
13
|
+
* • gemini — Vertex AI tool definitions for Gemini
|
|
14
|
+
* • mcp — original MCP catalog (passthrough, for sanity check)
|
|
15
|
+
*
|
|
16
|
+
* Usage:
|
|
17
|
+
* mneme adapter openai > openai-tools.json
|
|
18
|
+
* mneme adapter anthropic > claude-tools.json
|
|
19
|
+
* mneme adapter gemini > gemini-tools.json
|
|
20
|
+
*
|
|
21
|
+
* Then the AI vendor's CLI/API loads the file and the AI gains access to
|
|
22
|
+
* Mneme. Each adapter format wraps Mneme tool descriptions, JSON schemas,
|
|
23
|
+
* and the universal calling convention (HTTP POST or local CLI invoke).
|
|
24
|
+
*/
|
|
25
|
+
import { writeFileSync, existsSync, mkdirSync } from "node:fs";
|
|
26
|
+
import { dirname } from "node:path";
|
|
27
|
+
import { ui } from "../ui.js";
|
|
28
|
+
async function loadCatalog() {
|
|
29
|
+
// Import the registry from @mneme-ai/mcp at runtime so we don't drag
|
|
30
|
+
// its build into the CLI bundle.
|
|
31
|
+
const reg = (await import("@mneme-ai/mcp/tools/registry"));
|
|
32
|
+
return reg.buildAllTools().map((t) => ({
|
|
33
|
+
name: t.name,
|
|
34
|
+
description: t.description,
|
|
35
|
+
inputSchema: t.inputSchema,
|
|
36
|
+
category: t.category,
|
|
37
|
+
triggers: t.triggers,
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
41
|
+
// OpenAI function-calling format (works for GPT-4, GPT-4o, o-series, Codex)
|
|
42
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
43
|
+
function exportOpenAI(catalog) {
|
|
44
|
+
return {
|
|
45
|
+
schema: "openai/tools/v1",
|
|
46
|
+
description: "Mneme tool catalog in OpenAI function-calling format. Register these with the chat-completions or responses API; the model can then invoke any Mneme tool via the standard tool_calls protocol. The actual execution happens by spawning `mneme <command> --json` on the user's machine.",
|
|
47
|
+
invocation: {
|
|
48
|
+
protocol: "local-shell",
|
|
49
|
+
command: "mneme",
|
|
50
|
+
argTransform: "Tool name `mneme.<category>.<verb>` maps to CLI subcommand `mneme <verb>` (drop the prefix). For tools without a CLI counterpart, run `mneme mcp` to start the MCP server and connect via stdio.",
|
|
51
|
+
},
|
|
52
|
+
tools: catalog.map((t) => ({
|
|
53
|
+
type: "function",
|
|
54
|
+
function: {
|
|
55
|
+
name: t.name.replace(/\./g, "_"), // OpenAI requires alphanumeric+underscore
|
|
56
|
+
description: t.description,
|
|
57
|
+
parameters: t.inputSchema,
|
|
58
|
+
},
|
|
59
|
+
})),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
63
|
+
// Anthropic tool-use format (Claude API)
|
|
64
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
65
|
+
function exportAnthropic(catalog) {
|
|
66
|
+
return {
|
|
67
|
+
schema: "anthropic/tools/v1",
|
|
68
|
+
description: "Mneme tool catalog in Anthropic Claude tool-use format. Pass these as the `tools` array on Messages API requests. Claude will call them via the tool_use blocks; the host runtime invokes `mneme <command> --json` and feeds the result back.",
|
|
69
|
+
invocation: {
|
|
70
|
+
protocol: "local-shell",
|
|
71
|
+
command: "mneme",
|
|
72
|
+
preferredPath: "claude code with MCP",
|
|
73
|
+
},
|
|
74
|
+
tools: catalog.map((t) => ({
|
|
75
|
+
name: t.name.replace(/\./g, "_"),
|
|
76
|
+
description: t.description,
|
|
77
|
+
input_schema: t.inputSchema,
|
|
78
|
+
})),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
82
|
+
// Google Gemini / Vertex AI tool format
|
|
83
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
84
|
+
function exportGemini(catalog) {
|
|
85
|
+
return {
|
|
86
|
+
schema: "gemini/tools/v1",
|
|
87
|
+
description: "Mneme tool catalog in Gemini / Vertex AI function-declaration format. Wrap these in a `tools` parameter on generateContent calls; Gemini will return functionCall objects you execute by spawning `mneme <command> --json`.",
|
|
88
|
+
invocation: {
|
|
89
|
+
protocol: "local-shell",
|
|
90
|
+
command: "mneme",
|
|
91
|
+
},
|
|
92
|
+
function_declarations: catalog.map((t) => ({
|
|
93
|
+
name: t.name.replace(/\./g, "_"),
|
|
94
|
+
description: t.description,
|
|
95
|
+
parameters: t.inputSchema,
|
|
96
|
+
})),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
100
|
+
// Plain MCP catalog (sanity check / passthrough)
|
|
101
|
+
// ──────────────────────────────────────────────────────────────────────
|
|
102
|
+
function exportMcp(catalog) {
|
|
103
|
+
return {
|
|
104
|
+
schema: "mcp/tools/v1",
|
|
105
|
+
description: "Mneme MCP tool catalog — same format as ListToolsRequestSchema response.",
|
|
106
|
+
tools: catalog,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
const ADAPTERS = {
|
|
110
|
+
openai: exportOpenAI,
|
|
111
|
+
anthropic: exportAnthropic,
|
|
112
|
+
gemini: exportGemini,
|
|
113
|
+
mcp: exportMcp,
|
|
114
|
+
};
|
|
115
|
+
export async function adapterCommand(opts) {
|
|
116
|
+
const fn = ADAPTERS[opts.vendor];
|
|
117
|
+
if (!fn) {
|
|
118
|
+
ui.error(`Unknown vendor "${opts.vendor}". Try: ${Object.keys(ADAPTERS).join(" | ")}`);
|
|
119
|
+
return 1;
|
|
120
|
+
}
|
|
121
|
+
const catalog = await loadCatalog();
|
|
122
|
+
const exported = fn(catalog);
|
|
123
|
+
if (opts.out) {
|
|
124
|
+
if (!existsSync(dirname(opts.out)))
|
|
125
|
+
mkdirSync(dirname(opts.out), { recursive: true });
|
|
126
|
+
writeFileSync(opts.out, JSON.stringify(exported, null, 2), "utf8");
|
|
127
|
+
if (!opts.json) {
|
|
128
|
+
ui.success(`${opts.vendor} catalog written to ${opts.out} (${catalog.length} tools)`);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
process.stdout.write(JSON.stringify({ exported: opts.vendor, path: opts.out, toolCount: catalog.length }, null, 2) + "\n");
|
|
132
|
+
}
|
|
133
|
+
return 0;
|
|
134
|
+
}
|
|
135
|
+
// Default: print to stdout
|
|
136
|
+
process.stdout.write(JSON.stringify(exported, null, 2) + "\n");
|
|
137
|
+
return 0;
|
|
138
|
+
}
|
|
139
|
+
// Test exports
|
|
140
|
+
export const _exportOpenAIForTests = exportOpenAI;
|
|
141
|
+
export const _exportAnthropicForTests = exportAnthropic;
|
|
142
|
+
export const _exportGeminiForTests = exportGemini;
|
|
143
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/commands/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAiB9B,KAAK,UAAU,WAAW;IACxB,qEAAqE;IACrE,iCAAiC;IACjC,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,8BAA8B,CAAC,CAQxD,CAAC;IACF,OAAO,GAAG,CAAC,aAAa,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACrC,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,WAAW,EAAE,CAAC,CA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ts","sourceRoot":"","sources":["../../src/commands/adapter.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* adapter — unit tests for the cross-AI export format generators.
|
|
3
|
+
*
|
|
4
|
+
* Each format's structure is tested against expected schema fields so any
|
|
5
|
+
* future drift breaks the tests.
|
|
6
|
+
*/
|
|
7
|
+
import { describe, it, expect } from "vitest";
|
|
8
|
+
import { _exportOpenAIForTests, _exportAnthropicForTests, _exportGeminiForTests, } from "./adapter.js";
|
|
9
|
+
const SAMPLE_CATALOG = [
|
|
10
|
+
{
|
|
11
|
+
name: "mneme.memory.ask",
|
|
12
|
+
description: "Answer a Q&A question.",
|
|
13
|
+
inputSchema: { type: "object", properties: { question: { type: "string" } } },
|
|
14
|
+
category: "memory",
|
|
15
|
+
triggers: ["why does X exist"],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "mneme.people.atrophy",
|
|
19
|
+
description: "Knowledge atrophy clock.",
|
|
20
|
+
inputSchema: { type: "object", properties: { authorEmail: { type: "string" } } },
|
|
21
|
+
category: "people",
|
|
22
|
+
triggers: ["who is forgetting what"],
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
describe("adapter — OpenAI format", () => {
|
|
26
|
+
it("returns schema=openai/tools/v1 + tools array with type=function", () => {
|
|
27
|
+
const out = _exportOpenAIForTests(SAMPLE_CATALOG);
|
|
28
|
+
expect(out.schema).toBe("openai/tools/v1");
|
|
29
|
+
expect(Array.isArray(out.tools)).toBe(true);
|
|
30
|
+
expect(out.tools.length).toBe(2);
|
|
31
|
+
for (const t of out.tools) {
|
|
32
|
+
expect(t.type).toBe("function");
|
|
33
|
+
expect(t.function.name).toMatch(/^[a-z0-9_]+$/i); // alphanumeric+underscore
|
|
34
|
+
expect(t.function.name).not.toContain("."); // dots replaced
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
it("converts mneme.memory.ask → mneme_memory_ask in name", () => {
|
|
38
|
+
const out = _exportOpenAIForTests(SAMPLE_CATALOG);
|
|
39
|
+
const names = out.tools.map((t) => t.function.name);
|
|
40
|
+
expect(names).toContain("mneme_memory_ask");
|
|
41
|
+
expect(names).toContain("mneme_people_atrophy");
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
describe("adapter — Anthropic format", () => {
|
|
45
|
+
it("returns schema=anthropic/tools/v1 + tools array with input_schema", () => {
|
|
46
|
+
const out = _exportAnthropicForTests(SAMPLE_CATALOG);
|
|
47
|
+
expect(out.schema).toBe("anthropic/tools/v1");
|
|
48
|
+
expect(out.tools.length).toBe(2);
|
|
49
|
+
for (const t of out.tools) {
|
|
50
|
+
expect(t.name).not.toContain(".");
|
|
51
|
+
expect(t.input_schema).toBeDefined();
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe("adapter — Gemini format", () => {
|
|
56
|
+
it("returns schema=gemini/tools/v1 + function_declarations", () => {
|
|
57
|
+
const out = _exportGeminiForTests(SAMPLE_CATALOG);
|
|
58
|
+
expect(out.schema).toBe("gemini/tools/v1");
|
|
59
|
+
expect(out.function_declarations.length).toBe(2);
|
|
60
|
+
for (const t of out.function_declarations) {
|
|
61
|
+
expect(t.name).not.toContain(".");
|
|
62
|
+
expect(t.parameters).toBeDefined();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
describe("adapter — invocation metadata", () => {
|
|
67
|
+
it("OpenAI format declares local-shell protocol", () => {
|
|
68
|
+
const out = _exportOpenAIForTests(SAMPLE_CATALOG);
|
|
69
|
+
expect(out.invocation.protocol).toBe("local-shell");
|
|
70
|
+
expect(out.invocation.command).toBe("mneme");
|
|
71
|
+
});
|
|
72
|
+
it("Anthropic format declares local-shell + claude code MCP path", () => {
|
|
73
|
+
const out = _exportAnthropicForTests(SAMPLE_CATALOG);
|
|
74
|
+
expect(out.invocation.protocol).toBe("local-shell");
|
|
75
|
+
});
|
|
76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8DAA8D,EAAE,GAAG,EAAE;QACtE,MAAM,GAAG,GAAG,wBAAwB,CAAC,cAAc,CAAyC,CAAC;QAC7F,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/commands/court.d.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `mneme court` — Phase 4
|
|
2
|
+
* `mneme court` — Phase 4: 12-jury arbitration with Ed25519 signed ruling.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* For high-stakes commits (production deploy, security patch, contract
|
|
5
|
+
* code, EU AI Act compliance evidence), Mneme convenes a JURY OF 12
|
|
6
|
+
* specialized verifiers. Each votes; Mneme acts as foreman; outputs a
|
|
7
|
+
* cryptographically signed Markdown court ruling.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* v1.7.0 ships a 12-juror MVP:
|
|
10
|
+
* - 9 deterministic jurors (Bayesian, stylometric, entropy, citation,
|
|
11
|
+
* CWE, atrophy, incident, mutation, adversarial)
|
|
12
|
+
* - 3 "LLM judge" stubs that pass through to existing audit certify
|
|
13
|
+
* (will be wired to real Claude/GPT/Gemini in v1.8.0)
|
|
14
|
+
*
|
|
15
|
+
* The ruling output is a signed JSON envelope + a human-readable Markdown
|
|
16
|
+
* report. PDF rendering uses puppeteer-core if available (peer dep);
|
|
17
|
+
* otherwise the Markdown is the final artifact.
|
|
12
18
|
*/
|
|
13
19
|
export interface CourtOptions {
|
|
14
20
|
cwd: string;
|
|
@@ -17,5 +23,41 @@ export interface CourtOptions {
|
|
|
17
23
|
out?: string;
|
|
18
24
|
json?: boolean;
|
|
19
25
|
}
|
|
26
|
+
type Verdict = "GUILTY" | "ACQUITTED" | "MISTRIAL" | "ABSTAIN";
|
|
27
|
+
interface JurorVote {
|
|
28
|
+
jurorId: string;
|
|
29
|
+
jurorRole: string;
|
|
30
|
+
verdict: Verdict;
|
|
31
|
+
confidence: number;
|
|
32
|
+
reasoning: string;
|
|
33
|
+
}
|
|
34
|
+
interface CourtRuling {
|
|
35
|
+
rulingVersion: 1;
|
|
36
|
+
generatedAt: string;
|
|
37
|
+
generatedByMneme: string;
|
|
38
|
+
commit: string;
|
|
39
|
+
commitShortHash: string;
|
|
40
|
+
jurySize: number;
|
|
41
|
+
votes: JurorVote[];
|
|
42
|
+
consensus: number;
|
|
43
|
+
majorityVerdict: Verdict;
|
|
44
|
+
majorityOpinion: string;
|
|
45
|
+
dissent: string | null;
|
|
46
|
+
evidenceHashes: string[];
|
|
47
|
+
signature: string;
|
|
48
|
+
signatureAlgorithm: "ed25519";
|
|
49
|
+
signatureKeyId: string;
|
|
50
|
+
}
|
|
51
|
+
declare function tally(votes: JurorVote[]): {
|
|
52
|
+
majorityVerdict: Verdict;
|
|
53
|
+
consensus: number;
|
|
54
|
+
majorityOpinion: string;
|
|
55
|
+
dissent: string | null;
|
|
56
|
+
};
|
|
20
57
|
export declare function courtCommand(opts: CourtOptions): Promise<number>;
|
|
58
|
+
declare function renderRulingMarkdown(r: CourtRuling): string;
|
|
59
|
+
export declare const _tallyForTests: typeof tally;
|
|
60
|
+
export declare const _renderRulingMarkdownForTests: typeof renderRulingMarkdown;
|
|
61
|
+
export declare const _ALL_JURORS_COUNT_FOR_TESTS: number;
|
|
62
|
+
export {};
|
|
21
63
|
//# sourceMappingURL=court.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"court.d.ts","sourceRoot":"","sources":["../../src/commands/court.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"court.d.ts","sourceRoot":"","sources":["../../src/commands/court.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAWH,MAAM,WAA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