idiolect-mcp 0.4.0 → 0.5.1

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.
@@ -0,0 +1,85 @@
1
+ // Generated from lib/mcp/public-contract.js by `npm run mcp:generate-public-artifacts`. Do not edit.
2
+ export const PUBLIC_MCP_TOOL_NAMES = Object.freeze([
3
+ "get_my_voice",
4
+ "create_my_voice",
5
+ "draft_in_voice",
6
+ "rewrite_in_voice",
7
+ "score_voice",
8
+ "record_voice_feedback",
9
+ "learn_writing_style",
10
+ "list_writing_profiles",
11
+ "list_writing_profile_samples",
12
+ "create_writing_profile",
13
+ "add_samples_to_writing_profile",
14
+ "replace_samples_in_writing_profile",
15
+ "remove_sample_from_writing_profile",
16
+ "set_current_writing_profile",
17
+ "delete_writing_profile",
18
+ ]);
19
+
20
+ // Decision for the 2026-08-10 high-arrival review: keep measurement available,
21
+ // but tell hosts to invoke it only when the user explicitly asks for a check.
22
+ // Unmeasured results must continue to say why and expose scorer provenance.
23
+ export const SCORE_VOICE_ADVERTISING_DECISION = Object.freeze({
24
+ advertised: true,
25
+ invocation: "explicit_request_only",
26
+ });
27
+
28
+ const PUBLIC_STATES = new Set([
29
+ "ready",
30
+ "missing",
31
+ "thin",
32
+ "stale",
33
+ "complete",
34
+ "failed",
35
+ ]);
36
+ const NEXT_ACTIONS = new Set([
37
+ "collect_evidence",
38
+ "reload_voice",
39
+ "continue_writing",
40
+ "ask_feedback",
41
+ "retry",
42
+ "done",
43
+ ]);
44
+ const NEXT_TOOLS = new Set([
45
+ "create_my_voice",
46
+ "get_my_voice",
47
+ "record_voice_feedback",
48
+ null,
49
+ ]);
50
+ const SERVER_ONLY_KEYS = new Set([
51
+ "workflowId",
52
+ "baseVersion",
53
+ "idempotencyKey",
54
+ "onboardingIdempotencyKey",
55
+ "leaseToken",
56
+ "fencingToken",
57
+ "attemptToken",
58
+ "buildBindingId",
59
+ ]);
60
+
61
+ function stripServerOnly(value) {
62
+ if (Array.isArray(value)) return value.map(stripServerOnly);
63
+ if (!value || typeof value !== "object") return value;
64
+ return Object.fromEntries(
65
+ Object.entries(value)
66
+ .filter(([key]) => !SERVER_ONLY_KEYS.has(key))
67
+ .map(([key, nested]) => [key, stripServerOnly(nested)]),
68
+ );
69
+ }
70
+
71
+ /**
72
+ * Build the only model-visible state/continuation envelope. Details are copied
73
+ * through a denylist so internal coordination receipts cannot leak by spread.
74
+ */
75
+ export function publicMcpState(state, message, next, details = {}) {
76
+ if (!PUBLIC_STATES.has(state)) throw new TypeError(`Unknown public MCP state: ${state}`);
77
+ if (!next || !NEXT_ACTIONS.has(next.action) || !NEXT_TOOLS.has(next.tool)) {
78
+ throw new TypeError("Invalid public MCP next action");
79
+ }
80
+ const safeDetails = stripServerOnly(details);
81
+ delete safeDetails.state;
82
+ delete safeDetails.message;
83
+ delete safeDetails.next;
84
+ return { state, message, ...safeDetails, next: { action: next.action, tool: next.tool } };
85
+ }