@4da/mcp-server 3.2.0 → 4.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.
Files changed (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +160 -63
  3. package/dist/db.d.ts +27 -2
  4. package/dist/db.d.ts.map +1 -1
  5. package/dist/db.js +104 -1
  6. package/dist/db.js.map +1 -1
  7. package/dist/doctor.d.ts +15 -0
  8. package/dist/doctor.d.ts.map +1 -0
  9. package/dist/doctor.js +98 -0
  10. package/dist/doctor.js.map +1 -0
  11. package/dist/http-transport.d.ts +25 -0
  12. package/dist/http-transport.d.ts.map +1 -0
  13. package/dist/http-transport.js +126 -0
  14. package/dist/http-transport.js.map +1 -0
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +130 -10
  17. package/dist/index.js.map +1 -1
  18. package/dist/llm.d.ts +20 -2
  19. package/dist/llm.d.ts.map +1 -1
  20. package/dist/llm.js +77 -20
  21. package/dist/llm.js.map +1 -1
  22. package/dist/schema-registry.d.ts.map +1 -1
  23. package/dist/schema-registry.js +44 -0
  24. package/dist/schema-registry.js.map +1 -1
  25. package/dist/schemas/agent-memory.json +49 -0
  26. package/dist/schemas/agent-session-brief.json +25 -0
  27. package/dist/schemas/attention-report.json +13 -0
  28. package/dist/schemas/autophagy-status.json +13 -0
  29. package/dist/schemas/compound-advantage.json +14 -0
  30. package/dist/schemas/decision-enforcement.json +22 -0
  31. package/dist/schemas/decision-memory.json +54 -0
  32. package/dist/schemas/decision-windows.json +22 -0
  33. package/dist/schemas/delegation-score.json +18 -0
  34. package/dist/schemas/developer-dna.json +219 -0
  35. package/dist/schemas/export-context.json +17 -0
  36. package/dist/schemas/knowledge-gaps.json +14 -0
  37. package/dist/schemas/project-health.json +13 -0
  38. package/dist/schemas/reverse-mentions.json +13 -0
  39. package/dist/schemas/semantic-shifts.json +17 -0
  40. package/dist/schemas/signal-chains.json +19 -0
  41. package/dist/schemas/tech-radar.json +23 -0
  42. package/dist/setup.d.ts +17 -0
  43. package/dist/setup.d.ts.map +1 -0
  44. package/dist/setup.js +137 -0
  45. package/dist/setup.js.map +1 -0
  46. package/dist/tools/agent-memory.d.ts +94 -0
  47. package/dist/tools/agent-memory.d.ts.map +1 -0
  48. package/dist/tools/agent-memory.js +229 -0
  49. package/dist/tools/agent-memory.js.map +1 -0
  50. package/dist/tools/agent-session-brief.d.ts +44 -0
  51. package/dist/tools/agent-session-brief.d.ts.map +1 -0
  52. package/dist/tools/agent-session-brief.js +178 -0
  53. package/dist/tools/agent-session-brief.js.map +1 -0
  54. package/dist/tools/attention-report.d.ts +6 -5
  55. package/dist/tools/attention-report.d.ts.map +1 -1
  56. package/dist/tools/attention-report.js.map +1 -1
  57. package/dist/tools/autophagy-status.d.ts +25 -0
  58. package/dist/tools/autophagy-status.d.ts.map +1 -0
  59. package/dist/tools/autophagy-status.js +56 -0
  60. package/dist/tools/autophagy-status.js.map +1 -0
  61. package/dist/tools/compound-advantage.d.ts +27 -0
  62. package/dist/tools/compound-advantage.d.ts.map +1 -0
  63. package/dist/tools/compound-advantage.js +76 -0
  64. package/dist/tools/compound-advantage.js.map +1 -0
  65. package/dist/tools/decision-enforcement.d.ts +59 -0
  66. package/dist/tools/decision-enforcement.d.ts.map +1 -0
  67. package/dist/tools/decision-enforcement.js +184 -0
  68. package/dist/tools/decision-enforcement.js.map +1 -0
  69. package/dist/tools/decision-memory.d.ts +130 -0
  70. package/dist/tools/decision-memory.d.ts.map +1 -0
  71. package/dist/tools/decision-memory.js +265 -0
  72. package/dist/tools/decision-memory.js.map +1 -0
  73. package/dist/tools/decision-windows.d.ts +37 -0
  74. package/dist/tools/decision-windows.d.ts.map +1 -0
  75. package/dist/tools/decision-windows.js +67 -0
  76. package/dist/tools/decision-windows.js.map +1 -0
  77. package/dist/tools/delegation-score.d.ts +34 -0
  78. package/dist/tools/delegation-score.d.ts.map +1 -0
  79. package/dist/tools/delegation-score.js +250 -0
  80. package/dist/tools/delegation-score.js.map +1 -0
  81. package/dist/tools/developer-dna.d.ts +79 -0
  82. package/dist/tools/developer-dna.d.ts.map +1 -0
  83. package/dist/tools/developer-dna.js +377 -0
  84. package/dist/tools/developer-dna.js.map +1 -0
  85. package/dist/tools/export-context.d.ts +14 -6
  86. package/dist/tools/export-context.d.ts.map +1 -1
  87. package/dist/tools/export-context.js +13 -13
  88. package/dist/tools/export-context.js.map +1 -1
  89. package/dist/tools/index.d.ts +10 -0
  90. package/dist/tools/index.d.ts.map +1 -1
  91. package/dist/tools/index.js +14 -0
  92. package/dist/tools/index.js.map +1 -1
  93. package/dist/tools/knowledge-gaps.d.ts +11 -1
  94. package/dist/tools/knowledge-gaps.d.ts.map +1 -1
  95. package/dist/tools/knowledge-gaps.js.map +1 -1
  96. package/dist/tools/project-health.d.ts +6 -6
  97. package/dist/tools/project-health.d.ts.map +1 -1
  98. package/dist/tools/project-health.js +1 -1
  99. package/dist/tools/project-health.js.map +1 -1
  100. package/dist/tools/reverse-mentions.d.ts +8 -8
  101. package/dist/tools/reverse-mentions.d.ts.map +1 -1
  102. package/dist/tools/reverse-mentions.js.map +1 -1
  103. package/dist/tools/semantic-shifts.d.ts +17 -1
  104. package/dist/tools/semantic-shifts.d.ts.map +1 -1
  105. package/dist/tools/semantic-shifts.js.map +1 -1
  106. package/dist/tools/signal-chains.d.ts +14 -7
  107. package/dist/tools/signal-chains.d.ts.map +1 -1
  108. package/dist/tools/signal-chains.js.map +1 -1
  109. package/dist/tools/tech-radar.d.ts +38 -0
  110. package/dist/tools/tech-radar.d.ts.map +1 -0
  111. package/dist/tools/tech-radar.js +248 -0
  112. package/dist/tools/tech-radar.js.map +1 -0
  113. package/dist/types.d.ts +109 -0
  114. package/dist/types.d.ts.map +1 -1
  115. package/package.json +26 -14
@@ -0,0 +1,265 @@
1
+ /**
2
+ * decision_memory tool
3
+ *
4
+ * Manage developer decisions - record, list, check alignment, update, and supersede.
5
+ * Decisions persist and inform signal classification, tech radar, and agent context.
6
+ */
7
+ // ============================================================================
8
+ // Tool Definition
9
+ // ============================================================================
10
+ export const decisionMemoryTool = {
11
+ name: "decision_memory",
12
+ description: "Manage developer decisions. Actions: record (create new decision), list (query decisions), check_alignment (check if tech/pattern conflicts with decisions), update (modify a decision), supersede (replace old decision with new one).",
13
+ inputSchema: {
14
+ type: "object",
15
+ properties: {
16
+ action: {
17
+ type: "string",
18
+ enum: ["record", "list", "check_alignment", "update", "supersede"],
19
+ description: "Action to perform",
20
+ },
21
+ decision_type: {
22
+ type: "string",
23
+ enum: [
24
+ "tech_choice",
25
+ "architecture",
26
+ "workflow",
27
+ "pattern",
28
+ "dependency",
29
+ ],
30
+ description: "Type of decision (for record)",
31
+ },
32
+ subject: {
33
+ type: "string",
34
+ description: "Subject of the decision (for record, check_alignment)",
35
+ },
36
+ decision: {
37
+ type: "string",
38
+ description: "The decision text (for record)",
39
+ },
40
+ rationale: {
41
+ type: "string",
42
+ description: "Why this decision was made (for record)",
43
+ },
44
+ alternatives_rejected: {
45
+ type: "array",
46
+ items: { type: "string" },
47
+ description: "Alternatives that were considered and rejected (for record)",
48
+ },
49
+ context_tags: {
50
+ type: "array",
51
+ items: { type: "string" },
52
+ description: "Tags for categorization (for record)",
53
+ },
54
+ confidence: {
55
+ type: "number",
56
+ description: "Confidence level 0-1 (for record)",
57
+ },
58
+ filter_type: {
59
+ type: "string",
60
+ description: "Filter by decision type (for list)",
61
+ },
62
+ filter_status: {
63
+ type: "string",
64
+ description: "Filter by status: active, superseded, reconsidering (for list)",
65
+ },
66
+ limit: {
67
+ type: "number",
68
+ description: "Max results to return (for list)",
69
+ },
70
+ technology: {
71
+ type: "string",
72
+ description: "Technology to check alignment for",
73
+ },
74
+ pattern: {
75
+ type: "string",
76
+ description: "Pattern to check alignment for",
77
+ },
78
+ id: {
79
+ type: "number",
80
+ description: "Decision ID (for update)",
81
+ },
82
+ new_decision: {
83
+ type: "string",
84
+ description: "Updated decision text (for update)",
85
+ },
86
+ new_rationale: {
87
+ type: "string",
88
+ description: "Updated rationale (for update)",
89
+ },
90
+ new_status: {
91
+ type: "string",
92
+ enum: ["active", "superseded", "reconsidering"],
93
+ description: "Updated status (for update)",
94
+ },
95
+ new_confidence: {
96
+ type: "number",
97
+ description: "Updated confidence (for update)",
98
+ },
99
+ old_id: {
100
+ type: "number",
101
+ description: "ID of decision to supersede (for supersede)",
102
+ },
103
+ new_id: {
104
+ type: "number",
105
+ description: "ID of new decision that replaces old (for supersede)",
106
+ },
107
+ },
108
+ required: ["action"],
109
+ },
110
+ };
111
+ // ============================================================================
112
+ // Helpers
113
+ // ============================================================================
114
+ function parseDecisionRow(row) {
115
+ return {
116
+ ...row,
117
+ alternatives_rejected: JSON.parse(row.alternatives_rejected || "[]"),
118
+ context_tags: JSON.parse(row.context_tags || "[]"),
119
+ };
120
+ }
121
+ // ============================================================================
122
+ // Execute
123
+ // ============================================================================
124
+ export function executeDecisionMemory(db, params) {
125
+ const rawDb = db.getRawDb();
126
+ switch (params.action) {
127
+ case "record": {
128
+ if (!params.subject || !params.decision) {
129
+ return {
130
+ error: "subject and decision are required for record action",
131
+ };
132
+ }
133
+ const stmt = rawDb.prepare(`INSERT INTO developer_decisions
134
+ (decision_type, subject, decision, rationale,
135
+ alternatives_rejected, context_tags, confidence, status)
136
+ VALUES (?, ?, ?, ?, ?, ?, ?, 'active')`);
137
+ const result = stmt.run(params.decision_type || "tech_choice", params.subject, params.decision, params.rationale || null, JSON.stringify(params.alternatives_rejected || []), JSON.stringify(params.context_tags || []), params.confidence ?? 0.8);
138
+ return {
139
+ success: true,
140
+ id: result.lastInsertRowid,
141
+ message: `Decision recorded: ${params.subject}`,
142
+ };
143
+ }
144
+ case "list": {
145
+ let sql = `SELECT id, decision_type, subject, decision, rationale,
146
+ alternatives_rejected, context_tags, confidence,
147
+ status, superseded_by, created_at, updated_at
148
+ FROM developer_decisions WHERE 1=1`;
149
+ const sqlParams = [];
150
+ if (params.filter_type) {
151
+ sql += ` AND decision_type = ?`;
152
+ sqlParams.push(params.filter_type);
153
+ }
154
+ if (params.filter_status) {
155
+ sql += ` AND status = ?`;
156
+ sqlParams.push(params.filter_status);
157
+ }
158
+ sql += ` ORDER BY updated_at DESC LIMIT ?`;
159
+ sqlParams.push(params.limit || 20);
160
+ const rows = rawDb
161
+ .prepare(sql)
162
+ .all(...sqlParams);
163
+ return {
164
+ decisions: rows.map(parseDecisionRow),
165
+ count: rows.length,
166
+ };
167
+ }
168
+ case "check_alignment": {
169
+ if (!params.technology) {
170
+ return {
171
+ error: "technology is required for check_alignment action",
172
+ };
173
+ }
174
+ const search = `%${params.technology.toLowerCase()}%`;
175
+ const rows = rawDb
176
+ .prepare(`SELECT id, decision_type, subject, decision, rationale,
177
+ alternatives_rejected, context_tags, confidence,
178
+ status, created_at
179
+ FROM developer_decisions
180
+ WHERE status = 'active'
181
+ AND (LOWER(subject) LIKE ?
182
+ OR LOWER(context_tags) LIKE ?
183
+ OR LOWER(alternatives_rejected) LIKE ?)`)
184
+ .all(search, search, search);
185
+ const conflicts = [];
186
+ const relevant = [];
187
+ for (const row of rows) {
188
+ const alts = JSON.parse(row.alternatives_rejected || "[]");
189
+ const isRejected = alts.some((alt) => alt.toLowerCase().includes(params.technology.toLowerCase()));
190
+ if (isRejected) {
191
+ conflicts.push({
192
+ decision_id: row.id,
193
+ subject: row.subject,
194
+ reason: `'${params.technology}' was rejected in favor of '${row.decision}' (rationale: ${row.rationale || "none"})`,
195
+ });
196
+ }
197
+ relevant.push(parseDecisionRow(row));
198
+ }
199
+ return {
200
+ aligned: conflicts.length === 0,
201
+ relevant_decisions: relevant,
202
+ conflicts,
203
+ confidence: relevant.length > 0
204
+ ? Math.max(...relevant.map((r) => r.confidence))
205
+ : 0.5,
206
+ };
207
+ }
208
+ case "update": {
209
+ if (!params.id) {
210
+ return { error: "id is required for update action" };
211
+ }
212
+ const sets = [];
213
+ const values = [];
214
+ if (params.new_decision) {
215
+ sets.push("decision = ?");
216
+ values.push(params.new_decision);
217
+ }
218
+ if (params.new_rationale) {
219
+ sets.push("rationale = ?");
220
+ values.push(params.new_rationale);
221
+ }
222
+ if (params.new_status) {
223
+ sets.push("status = ?");
224
+ values.push(params.new_status);
225
+ }
226
+ if (params.new_confidence !== undefined) {
227
+ sets.push("confidence = ?");
228
+ values.push(params.new_confidence);
229
+ }
230
+ if (sets.length === 0) {
231
+ return { error: "No fields to update" };
232
+ }
233
+ sets.push("updated_at = datetime('now')");
234
+ values.push(params.id);
235
+ rawDb
236
+ .prepare(`UPDATE developer_decisions SET ${sets.join(", ")} WHERE id = ?`)
237
+ .run(...values);
238
+ return {
239
+ success: true,
240
+ message: `Decision ${params.id} updated`,
241
+ };
242
+ }
243
+ case "supersede": {
244
+ if (!params.old_id || !params.new_id) {
245
+ return {
246
+ error: "old_id and new_id are required for supersede action",
247
+ };
248
+ }
249
+ rawDb
250
+ .prepare(`UPDATE developer_decisions
251
+ SET status = 'superseded',
252
+ superseded_by = ?,
253
+ updated_at = datetime('now')
254
+ WHERE id = ?`)
255
+ .run(params.new_id, params.old_id);
256
+ return {
257
+ success: true,
258
+ message: `Decision ${params.old_id} superseded by ${params.new_id}`,
259
+ };
260
+ }
261
+ default:
262
+ return { error: `Unknown action: ${params.action}` };
263
+ }
264
+ }
265
+ //# sourceMappingURL=decision-memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision-memory.js","sourceRoot":"","sources":["../../src/tools/decision-memory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwDH,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACT,yOAAyO;IAC3O,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,WAA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C;gBACtB,OAAO,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC;YAC1C,CAAC;YAED,IAAI,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;YAC1C,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAEvB,KAAK;iBACF,OAAO,CACN,kCAAkC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CACjE;iBACA,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;YAElB,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,YAAY,MAAM,CAAC,EAAE,UAAU;aACzC,CAAC;QACJ,CAAC;QAED,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACrC,OAAO;oBACL,KAAK,EAAE,qDAAqD;iBAC7D,CAAC;YACJ,CAAC;YAED,KAAK;iBACF,OAAO,CACN;;;;wBAIc,CACf;iBACA,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;YAErC,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,YAAY,MAAM,CAAC,MAAM,kBAAkB,MAAM,CAAC,MAAM,EAAE;aACpE,CAAC;QACJ,CAAC;QAED;YACE,OAAO,EAAE,KAAK,EAAE,mBAAmB,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;IACzD,CAAC;AACH,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * decision_windows tool
3
+ *
4
+ * View and manage decision windows — time-bounded opportunities
5
+ * detected from content intelligence requiring attention.
6
+ */
7
+ import type { FourDADatabase } from "../db.js";
8
+ export interface DecisionWindowsParams {
9
+ action?: string;
10
+ window_id?: number;
11
+ outcome?: string;
12
+ }
13
+ export declare const decisionWindowsTool: {
14
+ name: string;
15
+ description: string;
16
+ inputSchema: {
17
+ type: "object";
18
+ properties: {
19
+ action: {
20
+ type: string;
21
+ enum: string[];
22
+ description: string;
23
+ default: string;
24
+ };
25
+ window_id: {
26
+ type: string;
27
+ description: string;
28
+ };
29
+ outcome: {
30
+ type: string;
31
+ description: string;
32
+ };
33
+ };
34
+ };
35
+ };
36
+ export declare function executeDecisionWindows(db: FourDADatabase, params: DecisionWindowsParams): object;
37
+ //# sourceMappingURL=decision-windows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision-windows.d.ts","sourceRoot":"","sources":["../../src/tools/decision-windows.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAiBD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;CAuB/B,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,qBAAqB,GAAG,MAAM,CA8ChG"}
@@ -0,0 +1,67 @@
1
+ export const decisionWindowsTool = {
2
+ name: "decision_windows",
3
+ description: "View and manage decision windows — time-bounded opportunities detected from content intelligence. List open windows, mark as acted on, or close.",
4
+ inputSchema: {
5
+ type: "object",
6
+ properties: {
7
+ action: {
8
+ type: "string",
9
+ enum: ["list", "act", "close"],
10
+ description: "Action to perform. Default: list",
11
+ default: "list",
12
+ },
13
+ window_id: {
14
+ type: "number",
15
+ description: "Window ID (required for 'act' or 'close' actions)",
16
+ },
17
+ outcome: {
18
+ type: "string",
19
+ description: "Outcome description when acting on a window",
20
+ },
21
+ },
22
+ },
23
+ };
24
+ export function executeDecisionWindows(db, params) {
25
+ const rawDb = db.getRawDb();
26
+ const action = params.action ?? "list";
27
+ if (action === "act") {
28
+ if (!params.window_id)
29
+ return { error: "window_id is required for 'act' action" };
30
+ try {
31
+ rawDb.prepare(`UPDATE decision_windows SET status = 'acted', acted_at = datetime('now'), outcome = ? WHERE id = ?`).run(params.outcome ?? null, params.window_id);
32
+ }
33
+ catch (err) {
34
+ return { error: `Failed to act on window: ${err instanceof Error ? err.message : String(err)}` };
35
+ }
36
+ }
37
+ else if (action === "close") {
38
+ if (!params.window_id)
39
+ return { error: "window_id is required for 'close' action" };
40
+ try {
41
+ rawDb.prepare(`UPDATE decision_windows SET status = 'closed', closed_at = datetime('now') WHERE id = ?`).run(params.window_id);
42
+ }
43
+ catch (err) {
44
+ return { error: `Failed to close window: ${err instanceof Error ? err.message : String(err)}` };
45
+ }
46
+ }
47
+ // Always return open windows after any action
48
+ let openWindows = [];
49
+ try {
50
+ openWindows = rawDb.prepare(`SELECT id, title, description, urgency, source_item_id, status,
51
+ opens_at, closes_at, acted_at, closed_at, outcome, created_at
52
+ FROM decision_windows WHERE status = 'open'
53
+ ORDER BY urgency DESC, created_at DESC`).all();
54
+ }
55
+ catch { /* Table may not exist yet */ }
56
+ const actionMsg = action === "act" ? `Window ${params.window_id} marked as acted`
57
+ : action === "close" ? `Window ${params.window_id} closed` : null;
58
+ return {
59
+ ...(actionMsg ? { action_result: actionMsg } : {}),
60
+ open_windows: openWindows,
61
+ count: openWindows.length,
62
+ summary: openWindows.length === 0
63
+ ? "No open decision windows. The system will surface time-sensitive opportunities as they are detected."
64
+ : `${openWindows.length} open decision window${openWindows.length !== 1 ? "s" : ""} requiring attention`,
65
+ };
66
+ }
67
+ //# sourceMappingURL=decision-windows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision-windows.js","sourceRoot":"","sources":["../../src/tools/decision-windows.ts"],"names":[],"mappings":"AA6BA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACT,kJAAkJ;IACpJ,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,M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1B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,EAAE,KAAK,EAAE,2BAA2B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QAClG,CAAC;IACH,CAAC;IAED,8CAA8C;IAC9C,IAAI,WAAW,GAAgB,EAAE,CAAC;IAClC,IAAI,CAAC;QACH,WAAW,GAAG,KAAK,CAAC,OAAO,CACzB;;;8CAGwC,CACzC,CAAC,GAAG,EAAiB,CAAC;IACzB,CAAC;IAAC,MAAM,CAAC,CAAC,6BAA6B,CAAC,CAAC;IAEzC,MAAM,SAAS,GAAG,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU,MAAM,CAAC,SAAS,kBAAkB;QAC/E,CAAC,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,MAAM,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IAEpE,OAAO;QACL,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,YAAY,EAAE,WAAW;QACzB,KAAK,EAAE,WAAW,CAAC,MAAM;QACzB,OAAO,EAAE,WAAW,CAAC,MAAM,KAAK,CAAC;YAC/B,CAAC,CAAC,sGAAsG;YACxG,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,wBAAwB,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,sBAAsB;KAC3G,CAAC;AACJ,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * delegation_score tool
3
+ *
4
+ * AI-delegatability assessment. AI agents use this to self-assess:
5
+ * "Should I proceed autonomously or ask the human?"
6
+ *
7
+ * Computes a composite score from pattern stability, security sensitivity,
8
+ * decision density, and AI track record to produce a delegation recommendation.
9
+ */
10
+ import type { FourDADatabase } from "../db.js";
11
+ export interface DelegationScoreParams {
12
+ subject: string;
13
+ task_description?: string;
14
+ }
15
+ export declare const delegationScoreTool: {
16
+ name: string;
17
+ description: string;
18
+ inputSchema: {
19
+ type: "object";
20
+ properties: {
21
+ subject: {
22
+ type: string;
23
+ description: string;
24
+ };
25
+ task_description: {
26
+ type: string;
27
+ description: string;
28
+ };
29
+ };
30
+ required: string[];
31
+ };
32
+ };
33
+ export declare function executeDelegationScore(db: FourDADatabase, params: DelegationScoreParams): object;
34
+ //# sourceMappingURL=delegation-score.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delegation-score.d.ts","sourceRoot":"","sources":["../../src/tools/delegation-score.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAM/C,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAkCD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;CAoB/B,CAAC;AAiLF,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,cAAc,EAClB,MAAM,EAAE,qBAAqB,GAC5B,MAAM,CAgFR"}