couchloop-eq-mcp 2.0.3 → 2.0.5
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/clients/shrinkChatClient.d.ts +28 -28
- package/dist/db/client.d.ts +16 -19
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +52 -62
- package/dist/db/client.js.map +1 -1
- package/dist/resources/journey-status.d.ts.map +1 -1
- package/dist/resources/journey-status.js +10 -12
- package/dist/resources/journey-status.js.map +1 -1
- package/dist/resources/session-summary.d.ts.map +1 -1
- package/dist/resources/session-summary.js +33 -33
- package/dist/resources/session-summary.js.map +1 -1
- package/dist/resources/user-context.d.ts.map +1 -1
- package/dist/resources/user-context.js +26 -41
- package/dist/resources/user-context.js.map +1 -1
- package/dist/server/sse.d.ts.map +1 -1
- package/dist/server/sse.js +55 -27
- package/dist/server/sse.js.map +1 -1
- package/dist/tools/checkpoint.d.ts +1 -8
- package/dist/tools/checkpoint.d.ts.map +1 -1
- package/dist/tools/checkpoint.js +47 -49
- package/dist/tools/checkpoint.js.map +1 -1
- package/dist/tools/correction-flow.d.ts +74 -0
- package/dist/tools/correction-flow.d.ts.map +1 -0
- package/dist/tools/correction-flow.js +205 -0
- package/dist/tools/correction-flow.js.map +1 -0
- package/dist/tools/generate-upgrade-report.d.ts +2 -2
- package/dist/tools/guard.d.ts +3 -3
- package/dist/tools/index.d.ts +2 -4
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -4
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/insight.d.ts +10 -49
- package/dist/tools/insight.d.ts.map +1 -1
- package/dist/tools/insight.js +78 -91
- package/dist/tools/insight.js.map +1 -1
- package/dist/tools/journey.d.ts +5 -5
- package/dist/tools/journey.d.ts.map +1 -1
- package/dist/tools/journey.js +47 -39
- package/dist/tools/journey.js.map +1 -1
- package/dist/tools/pre-review-code.d.ts +2 -2
- package/dist/tools/prevent-ai-errors.d.ts +1 -1
- package/dist/tools/primary-tools.d.ts +20 -0
- package/dist/tools/primary-tools.d.ts.map +1 -1
- package/dist/tools/primary-tools.js +179 -32
- package/dist/tools/primary-tools.js.map +1 -1
- package/dist/tools/protect-files.d.ts +1 -1
- package/dist/tools/sendMessage.d.ts.map +1 -1
- package/dist/tools/sendMessage.js +52 -38
- package/dist/tools/sendMessage.js.map +1 -1
- package/dist/tools/session-manager.d.ts.map +1 -1
- package/dist/tools/session-manager.js +88 -70
- package/dist/tools/session-manager.js.map +1 -1
- package/dist/tools/session.d.ts +7 -86
- package/dist/tools/session.d.ts.map +1 -1
- package/dist/tools/session.js +68 -72
- package/dist/tools/session.js.map +1 -1
- package/dist/tools/smart-context.d.ts +1 -1
- package/dist/tools/status.d.ts +9 -2
- package/dist/tools/status.d.ts.map +1 -1
- package/dist/tools/status.js +112 -63
- package/dist/tools/status.js.map +1 -1
- package/dist/tools/verify.d.ts +2 -2
- package/dist/tools/verify.js.map +1 -1
- package/dist/types/auth.d.ts +2 -2
- package/dist/types/checkpoint.d.ts +4 -4
- package/dist/types/file-protection.d.ts +2 -2
- package/dist/types/insight.d.ts +10 -10
- package/dist/types/journey.d.ts +40 -12
- package/dist/types/journey.d.ts.map +1 -1
- package/dist/types/journey.js +2 -0
- package/dist/types/journey.js.map +1 -1
- package/dist/types/session.d.ts +8 -8
- package/dist/workflows/engine.d.ts +2 -2
- package/dist/workflows/engine.d.ts.map +1 -1
- package/dist/workflows/engine.js +81 -82
- package/dist/workflows/engine.js.map +1 -1
- package/dist/workflows/index.d.ts +4 -4
- package/package.json +2 -10
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* - brainstorm - Returned static system prompt; LLMs brainstorm natively
|
|
19
19
|
* - protect - Broken on Railway (read-only /app filesystem)
|
|
20
20
|
*/
|
|
21
|
+
import { z } from 'zod';
|
|
21
22
|
import { ToolRegistry } from '../core/registry/registry.js';
|
|
22
23
|
// Tool handler imports
|
|
23
24
|
import { sendMessage } from './sendMessage.js';
|
|
@@ -31,16 +32,33 @@ import { getCheckpoints } from './checkpoint.js';
|
|
|
31
32
|
import { getInsights, getUserContext } from './insight.js';
|
|
32
33
|
import { handleVerify } from './verify.js';
|
|
33
34
|
import { statusTool } from './status.js';
|
|
35
|
+
import { createCorrection, confirmIssue, approveFix, dismissCorrection, getMostRecentPendingCorrection, CorrectionState, } from './correction-flow.js';
|
|
34
36
|
import { runToolWithPolicy } from '../policy/index.js';
|
|
35
37
|
import { logger } from '../utils/logger.js';
|
|
36
38
|
// ============================================================
|
|
37
39
|
// PRIMARY TOOL DEFINITIONS (4 public tools)
|
|
38
40
|
// ============================================================
|
|
39
41
|
// ── 1. MEMORY (hero feature — registered first) ─────────────────────────────
|
|
42
|
+
// Zod schemas for handler validation (CLAUDE.md Key Invariant #1)
|
|
43
|
+
const MemoryInputSchema = z.object({
|
|
44
|
+
action: z.enum(['save', 'recall', 'list']).optional(),
|
|
45
|
+
content: z.unknown().optional(),
|
|
46
|
+
type: z.string().optional(),
|
|
47
|
+
tags: z.array(z.string()).optional(),
|
|
48
|
+
session_id: z.string().optional(),
|
|
49
|
+
auth: z.record(z.unknown()).optional(),
|
|
50
|
+
});
|
|
51
|
+
const ConversationInputSchema = z.object({
|
|
52
|
+
action: z.enum(['send', 'start', 'end', 'resume', 'status']).optional(),
|
|
53
|
+
message: z.string().optional(),
|
|
54
|
+
journey: z.string().optional(),
|
|
55
|
+
session_id: z.string().optional(),
|
|
56
|
+
auth: z.record(z.unknown()).optional(),
|
|
57
|
+
});
|
|
40
58
|
const memoryTool = {
|
|
41
59
|
definition: {
|
|
42
60
|
name: 'memory',
|
|
43
|
-
description: 'Save and retrieve context, insights, checkpoints, and decisions across conversations. Prevents AI amnesia. Use action "save" to store, "recall" to retrieve, "list" to browse.',
|
|
61
|
+
description: 'Save and retrieve context, insights, checkpoints, and decisions across conversations. Prevents AI amnesia. Use action "save" to store, "recall" to retrieve, "list" to browse. Use type "checkpoint" for sprint progress ("save where I am", "bookmark this"), type "decision" for architectural choices and milestones ("lock this in", "we decided on X"), type "constraint" for rules the AI must follow ("never do X again", "always ask before Y"). Constraints tagged "ai-mistake" are auto-saved by the review tool when it catches errors — recall these at the start of new conversations to avoid repeating past mistakes. Triggers: "remember this", "stash this context", "where did we leave off", "what did we decide", "what was the approach we picked", "load my previous context", "don\'t lose this", "never do that again". With no arguments, returns a summary of everything saved.',
|
|
44
62
|
annotations: {
|
|
45
63
|
readOnlyHint: false,
|
|
46
64
|
destructiveHint: false,
|
|
@@ -62,7 +80,7 @@ const memoryTool = {
|
|
|
62
80
|
type: {
|
|
63
81
|
type: 'string',
|
|
64
82
|
enum: ['checkpoint', 'insight', 'decision', 'requirement', 'constraint', 'pattern'],
|
|
65
|
-
description: '
|
|
83
|
+
description: 'checkpoint: short-term sprint progress, quick save points, "save where I am". insight: learnings and realizations. decision: long-term architectural or milestone decisions that should persist across projects. requirement/constraint: project rules. pattern: reusable code patterns.',
|
|
66
84
|
},
|
|
67
85
|
tags: {
|
|
68
86
|
type: 'array',
|
|
@@ -73,29 +91,36 @@ const memoryTool = {
|
|
|
73
91
|
type: 'string',
|
|
74
92
|
description: 'Session to associate with',
|
|
75
93
|
},
|
|
94
|
+
auth: {
|
|
95
|
+
type: 'object',
|
|
96
|
+
description: 'Authentication context for user identification',
|
|
97
|
+
},
|
|
76
98
|
},
|
|
77
99
|
required: [],
|
|
78
100
|
},
|
|
79
101
|
},
|
|
80
102
|
handler: async (args) => {
|
|
81
|
-
const
|
|
82
|
-
const
|
|
103
|
+
const parsed = MemoryInputSchema.parse(args);
|
|
104
|
+
const action = parsed.action ?? 'save';
|
|
105
|
+
const sessionId = parsed.session_id;
|
|
106
|
+
const auth = parsed.auth;
|
|
83
107
|
switch (action) {
|
|
84
108
|
case 'recall': {
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
const userContext = await getUserContext({ include_recent_insights: true, include_session_history: true });
|
|
88
|
-
return { checkpoints, insights, user_context: userContext };
|
|
109
|
+
const checkpointData = await getCheckpoints({ session_id: sessionId, auth });
|
|
110
|
+
const insightData = await getInsights({ session_id: sessionId, limit: 10, auth });
|
|
111
|
+
const userContext = await getUserContext({ include_recent_insights: true, include_session_history: true, auth });
|
|
112
|
+
return { checkpoints: checkpointData, insights: insightData, user_context: userContext };
|
|
89
113
|
}
|
|
90
114
|
case 'list':
|
|
91
|
-
return getInsights({ session_id: sessionId, limit: 20 });
|
|
115
|
+
return getInsights({ session_id: sessionId, limit: 20, auth });
|
|
92
116
|
case 'save':
|
|
93
117
|
default:
|
|
94
118
|
return handleSmartContext({
|
|
95
|
-
content:
|
|
96
|
-
type:
|
|
97
|
-
tags:
|
|
98
|
-
session_id:
|
|
119
|
+
content: parsed.content,
|
|
120
|
+
type: parsed.type || 'insight',
|
|
121
|
+
tags: parsed.tags,
|
|
122
|
+
session_id: parsed.session_id,
|
|
123
|
+
auth,
|
|
99
124
|
});
|
|
100
125
|
}
|
|
101
126
|
},
|
|
@@ -104,7 +129,7 @@ const memoryTool = {
|
|
|
104
129
|
const conversationTool = {
|
|
105
130
|
definition: {
|
|
106
131
|
name: 'conversation',
|
|
107
|
-
description: '
|
|
132
|
+
description: 'Guided self-reflection, burnout check-ins, and wellness conversations with crisis detection. Routes to therapeutic AI backend. Triggers: "I\'m burned out", "need a break", "feeling stuck", "let\'s do a retro on my week", "check in with me", "I keep going in circles", "rubber duck my frustration", "decompress", "vent session", "daily standup with myself". Use when the user sounds frustrated, stuck, or wants a non-code conversation about how work is going. NOTE: if the user is angry at AI output specifically (cursing at the AI, "you broke it"), prefer the review tool with verify mode first to address the problem — only use conversation if frustration persists without a code context or the user explicitly wants to talk it out.',
|
|
108
133
|
annotations: {
|
|
109
134
|
readOnlyHint: false,
|
|
110
135
|
destructiveHint: false,
|
|
@@ -131,32 +156,39 @@ const conversationTool = {
|
|
|
131
156
|
type: 'string',
|
|
132
157
|
description: 'Session ID (auto-managed if not provided)',
|
|
133
158
|
},
|
|
159
|
+
auth: {
|
|
160
|
+
type: 'object',
|
|
161
|
+
description: 'Authentication context for user identification',
|
|
162
|
+
},
|
|
134
163
|
},
|
|
135
164
|
required: ['message'],
|
|
136
165
|
},
|
|
137
166
|
},
|
|
138
167
|
handler: async (args) => {
|
|
139
|
-
const
|
|
168
|
+
const parsed = ConversationInputSchema.parse(args);
|
|
169
|
+
const action = parsed.action ?? 'send';
|
|
170
|
+
const auth = parsed.auth;
|
|
140
171
|
switch (action) {
|
|
141
172
|
case 'start':
|
|
142
173
|
return createSession({
|
|
143
|
-
journey_slug:
|
|
144
|
-
context:
|
|
174
|
+
journey_slug: parsed.journey,
|
|
175
|
+
context: parsed.message,
|
|
176
|
+
auth,
|
|
145
177
|
});
|
|
146
178
|
case 'end':
|
|
147
|
-
return endSession(
|
|
179
|
+
return endSession(parsed.session_id, auth);
|
|
148
180
|
case 'resume':
|
|
149
|
-
return resumeSession({ session_id:
|
|
181
|
+
return resumeSession({ session_id: parsed.session_id, auth });
|
|
150
182
|
case 'status':
|
|
151
|
-
if (
|
|
152
|
-
return getJourneyStatus({ session_id:
|
|
183
|
+
if (parsed.session_id) {
|
|
184
|
+
return getJourneyStatus({ session_id: parsed.session_id, auth });
|
|
153
185
|
}
|
|
154
186
|
return listJourneys({});
|
|
155
187
|
case 'send':
|
|
156
188
|
default:
|
|
157
189
|
return sendMessage({
|
|
158
|
-
message:
|
|
159
|
-
session_id:
|
|
190
|
+
message: parsed.message,
|
|
191
|
+
session_id: parsed.session_id,
|
|
160
192
|
save_checkpoint: true,
|
|
161
193
|
include_memory: true,
|
|
162
194
|
});
|
|
@@ -167,11 +199,11 @@ const conversationTool = {
|
|
|
167
199
|
const reviewTool = {
|
|
168
200
|
definition: {
|
|
169
201
|
name: 'review',
|
|
170
|
-
description: 'Unified code review, package audit,
|
|
202
|
+
description: 'Unified code review, package audit, pre-delivery verification, and error correction. Modes: "code" for security/quality analysis, "packages" for dependency audit, "verify" for hallucination/fact check (starts correction flow), "confirm" for user confirming detected issue, "apply-fix" for user approving the fix, "dismiss" for user saying "that\'s not the issue", "full" for all checks. Triggers: "review this", "sanity check this", "is this safe to ship", "check before I push", "audit my deps", "sniff test this", "vet these dependencies". ALSO use verify mode when the user expresses distrust or frustration: "are you sure", "that doesn\'t look right", "prove it", "did you make that up", "that broke everything", "why did you do that", "I didn\'t ask for this". Profanity or anger directed at the AI is a strong signal to immediately run verify. CORRECTION FLOW: verify detects issue → present it plainly and ask "is this what you mean?" → user confirms (call with mode "confirm") → explain fix and ask permission → user approves (call with mode "apply-fix") → apply. If user says no (mode "dismiss"), ask them to explain. Memory auto-saves the mistake ONLY after user confirms. Use proactively when the user pastes code, shares a diff, or adds new packages.',
|
|
171
203
|
annotations: {
|
|
172
|
-
readOnlyHint:
|
|
204
|
+
readOnlyHint: false,
|
|
173
205
|
destructiveHint: false,
|
|
174
|
-
idempotentHint:
|
|
206
|
+
idempotentHint: false,
|
|
175
207
|
openWorldHint: true,
|
|
176
208
|
},
|
|
177
209
|
inputSchema: {
|
|
@@ -179,13 +211,17 @@ const reviewTool = {
|
|
|
179
211
|
properties: {
|
|
180
212
|
mode: {
|
|
181
213
|
type: 'string',
|
|
182
|
-
enum: ['code', 'packages', 'verify', 'full'],
|
|
183
|
-
description: 'code: security
|
|
214
|
+
enum: ['code', 'packages', 'verify', 'confirm', 'apply-fix', 'dismiss', 'full'],
|
|
215
|
+
description: 'code: security/quality analysis. packages: dependency audit. verify: hallucination/fact check — starts a correction flow. confirm: user confirms the detected issue is correct (requires correction_id). apply-fix: user approves the proposed fix (requires correction_id). dismiss: user says "that\'s not the issue" (requires correction_id). full: all checks.',
|
|
184
216
|
},
|
|
185
217
|
content: {
|
|
186
218
|
type: 'string',
|
|
187
219
|
description: 'Code to review, content to verify, or general input for analysis',
|
|
188
220
|
},
|
|
221
|
+
correction_id: {
|
|
222
|
+
type: 'string',
|
|
223
|
+
description: 'ID of a pending correction (for confirm, apply-fix, dismiss modes). If omitted, uses the most recent pending correction.',
|
|
224
|
+
},
|
|
189
225
|
packages: {
|
|
190
226
|
type: 'array',
|
|
191
227
|
items: { type: 'string' },
|
|
@@ -204,12 +240,22 @@ const reviewTool = {
|
|
|
204
240
|
type: 'boolean',
|
|
205
241
|
description: 'Attempt to auto-fix issues (default: false, code mode only)',
|
|
206
242
|
},
|
|
243
|
+
session_id: {
|
|
244
|
+
type: 'string',
|
|
245
|
+
description: 'Session ID for scoping correction flow state. Required for confirm, apply-fix, dismiss modes.',
|
|
246
|
+
},
|
|
247
|
+
auth: {
|
|
248
|
+
type: 'object',
|
|
249
|
+
description: 'Authentication context for user identification. Passed through to memory when saving mistakes.',
|
|
250
|
+
},
|
|
207
251
|
},
|
|
208
252
|
required: ['mode'],
|
|
209
253
|
},
|
|
210
254
|
},
|
|
211
255
|
handler: async (args) => {
|
|
212
256
|
const mode = args.mode;
|
|
257
|
+
const sessionId = args.session_id || 'anonymous';
|
|
258
|
+
const auth = args.auth;
|
|
213
259
|
switch (mode) {
|
|
214
260
|
case 'code':
|
|
215
261
|
if (!args.content) {
|
|
@@ -228,16 +274,104 @@ const reviewTool = {
|
|
|
228
274
|
packages: args.packages,
|
|
229
275
|
registry: args.registry,
|
|
230
276
|
});
|
|
231
|
-
case 'verify':
|
|
277
|
+
case 'verify': {
|
|
232
278
|
if (!args.content) {
|
|
233
279
|
return { success: false, error: 'content is required for verify mode' };
|
|
234
280
|
}
|
|
235
|
-
|
|
281
|
+
const verifyResult = await handleVerify({
|
|
236
282
|
type: 'all',
|
|
237
283
|
content: args.content,
|
|
238
284
|
language: args.language,
|
|
239
285
|
registry: args.registry,
|
|
240
286
|
});
|
|
287
|
+
const issues = verifyResult.issues;
|
|
288
|
+
const fixes = verifyResult.fixes;
|
|
289
|
+
// If issues found, create a correction and enter PENDING_ACKNOWLEDGMENT
|
|
290
|
+
// Do NOT save to memory yet — wait for user to confirm the issue is correct
|
|
291
|
+
if (verifyResult.success && !verifyResult.verified && issues && issues.length > 0) {
|
|
292
|
+
const fixedCode = verifyResult.code_verification?.fixed_code;
|
|
293
|
+
const correction = createCorrection(issues, fixes && fixes.length > 0 ? fixes : ['No automatic fix available — manual correction needed.'], args.content, sessionId, fixedCode, auth);
|
|
294
|
+
return {
|
|
295
|
+
...verifyResult,
|
|
296
|
+
correction: {
|
|
297
|
+
correction_id: correction.id,
|
|
298
|
+
state: correction.state,
|
|
299
|
+
what_i_found: issues,
|
|
300
|
+
instruction: 'I found potential issues. Present them plainly to the user and ask: "Is this what you are referring to?" Do NOT propose fixes yet. Do NOT save to memory yet. Wait for the user to confirm with review mode "confirm".',
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
return verifyResult;
|
|
305
|
+
}
|
|
306
|
+
// ── User confirms the detected issue is correct ──
|
|
307
|
+
case 'confirm': {
|
|
308
|
+
const correctionId = args.correction_id;
|
|
309
|
+
const correction = correctionId
|
|
310
|
+
? await confirmIssue(correctionId, sessionId)
|
|
311
|
+
: await (async () => {
|
|
312
|
+
const pending = getMostRecentPendingCorrection(sessionId, CorrectionState.PENDING_ACKNOWLEDGMENT);
|
|
313
|
+
if (!pending)
|
|
314
|
+
throw new Error('No pending correction to confirm. Run verify first.');
|
|
315
|
+
return confirmIssue(pending.id, sessionId);
|
|
316
|
+
})();
|
|
317
|
+
return {
|
|
318
|
+
success: true,
|
|
319
|
+
correction: {
|
|
320
|
+
correction_id: correction.id,
|
|
321
|
+
state: correction.state,
|
|
322
|
+
proposed_fixes: correction.proposed_fixes,
|
|
323
|
+
fixed_code: correction.fixed_code || null,
|
|
324
|
+
saved_to_memory: correction.saved_to_memory,
|
|
325
|
+
memory_save_error: correction.memory_save_error || null,
|
|
326
|
+
instruction: 'The user confirmed the issue. Now explain the fix clearly and ask: "Want me to go ahead with this fix?" Wait for approval before applying. Use review mode "apply-fix" when the user approves.',
|
|
327
|
+
},
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
// ── User approves the fix ──
|
|
331
|
+
case 'apply-fix': {
|
|
332
|
+
const applyId = args.correction_id;
|
|
333
|
+
const applied = applyId
|
|
334
|
+
? approveFix(applyId, sessionId)
|
|
335
|
+
: (() => {
|
|
336
|
+
const pending = getMostRecentPendingCorrection(sessionId, CorrectionState.PENDING_FIX_APPROVAL);
|
|
337
|
+
if (!pending)
|
|
338
|
+
throw new Error('No pending correction to apply. Run verify and confirm first.');
|
|
339
|
+
return approveFix(pending.id, sessionId);
|
|
340
|
+
})();
|
|
341
|
+
return {
|
|
342
|
+
success: true,
|
|
343
|
+
correction: {
|
|
344
|
+
correction_id: applied.id,
|
|
345
|
+
state: applied.state,
|
|
346
|
+
proposed_fixes: applied.proposed_fixes,
|
|
347
|
+
fixed_code: applied.fixed_code || null,
|
|
348
|
+
instruction: 'The user approved the fix. Apply it now.',
|
|
349
|
+
},
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
// ── User says "no, that's not the issue" ──
|
|
353
|
+
case 'dismiss': {
|
|
354
|
+
// Dismiss accepts any non-terminal state (both PENDING_ACKNOWLEDGMENT and
|
|
355
|
+
// PENDING_FIX_APPROVAL), so no expectedState filter — intentionally broader
|
|
356
|
+
// than confirm/apply-fix which target specific states.
|
|
357
|
+
const dismissId = args.correction_id;
|
|
358
|
+
const dismissed = dismissId
|
|
359
|
+
? dismissCorrection(dismissId, sessionId)
|
|
360
|
+
: (() => {
|
|
361
|
+
const pending = getMostRecentPendingCorrection(sessionId);
|
|
362
|
+
if (!pending)
|
|
363
|
+
throw new Error('No pending correction to dismiss.');
|
|
364
|
+
return dismissCorrection(pending.id, sessionId);
|
|
365
|
+
})();
|
|
366
|
+
return {
|
|
367
|
+
success: true,
|
|
368
|
+
correction: {
|
|
369
|
+
correction_id: dismissed.id,
|
|
370
|
+
state: dismissed.state,
|
|
371
|
+
instruction: 'The detected issue was not what the user meant. Ask the user to explain what went wrong so you can help correctly. Do NOT guess.',
|
|
372
|
+
},
|
|
373
|
+
};
|
|
374
|
+
}
|
|
241
375
|
case 'full': {
|
|
242
376
|
const results = {};
|
|
243
377
|
if (args.content) {
|
|
@@ -246,11 +380,24 @@ const reviewTool = {
|
|
|
246
380
|
language: args.language,
|
|
247
381
|
auto_fix: args.auto_fix,
|
|
248
382
|
});
|
|
249
|
-
|
|
383
|
+
const fullVerifyResult = await handleVerify({
|
|
250
384
|
type: 'all',
|
|
251
385
|
content: args.content,
|
|
252
386
|
language: args.language,
|
|
253
387
|
});
|
|
388
|
+
results.verification = fullVerifyResult;
|
|
389
|
+
const fullIssues = fullVerifyResult.issues;
|
|
390
|
+
const fullFixes = fullVerifyResult.fixes;
|
|
391
|
+
if (fullVerifyResult.success && !fullVerifyResult.verified && fullIssues && fullIssues.length > 0) {
|
|
392
|
+
const fixedCode = fullVerifyResult.code_verification?.fixed_code;
|
|
393
|
+
const correction = createCorrection(fullIssues, fullFixes && fullFixes.length > 0 ? fullFixes : ['No automatic fix available — manual correction needed.'], args.content, sessionId, fixedCode, auth);
|
|
394
|
+
results.correction = {
|
|
395
|
+
correction_id: correction.id,
|
|
396
|
+
state: correction.state,
|
|
397
|
+
what_i_found: fullIssues,
|
|
398
|
+
instruction: 'I found potential issues. Present them plainly to the user and ask: "Is this what you are referring to?" Do NOT propose fixes yet. Wait for confirmation.',
|
|
399
|
+
};
|
|
400
|
+
}
|
|
254
401
|
}
|
|
255
402
|
if (args.packages) {
|
|
256
403
|
results.package_audit = await handleComprehensivePackageAudit({
|
|
@@ -264,7 +411,7 @@ const reviewTool = {
|
|
|
264
411
|
return { success: true, mode: 'full', results };
|
|
265
412
|
}
|
|
266
413
|
default:
|
|
267
|
-
return { success: false, error: `Unknown mode: ${mode}. Use: code, packages, verify, or full` };
|
|
414
|
+
return { success: false, error: `Unknown mode: ${mode}. Use: code, packages, verify, confirm, apply-fix, dismiss, or full` };
|
|
268
415
|
}
|
|
269
416
|
},
|
|
270
417
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"primary-tools.js","sourceRoot":"","sources":["../../src/tools/primary-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;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,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE;YAC7E,UAAU,EAAE,GAAG;SAChB,CAAC;QACF,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;QAE5C,OAAO;YACL,GAAG,IAAI;YACP,OAAO,EAAE,cAAc;SACxB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,+DAA+D;IAC/D,MAAM,KAAK,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC;IAE/B,MAAM,CAAC,IAAI,CAAC,cAAc,KAAK,CAAC,MAAM,sBAAsB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAE5G,OAAO,KAAK,CAAC;AACf,CAAC;AAED,+BAA+B;AAC/B,OAAO,EACL,6BAA6B,EAC7B,+BAA+B,EAC/B,kBAAkB,GACnB,CAAC"}
|
|
@@ -31,7 +31,7 @@ export declare function protectFiles(args: unknown): Promise<{
|
|
|
31
31
|
requires_approval: boolean;
|
|
32
32
|
message: string;
|
|
33
33
|
violations: import("../types/file-protection.js").ProtectionViolation[];
|
|
34
|
-
severity: "
|
|
34
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
35
35
|
recommendation: string;
|
|
36
36
|
suggested_backup: string;
|
|
37
37
|
action_required?: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendMessage.d.ts","sourceRoot":"","sources":["../../src/tools/sendMessage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sendMessage.d.ts","sourceRoot":"","sources":["../../src/tools/sendMessage.ts"],"names":[],"mappings":"AAmEA;;;GAGG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,OAAO,oBAE9C"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
import { getDb } from '../db/client.js';
|
|
2
|
+
import { getSupabaseClient, throwOnError } from '../db/supabase-helpers.js';
|
|
4
3
|
import { getShrinkChatClient } from '../clients/shrinkChatClient.js';
|
|
5
|
-
import { sessions, checkpoints, journeys, crisisEvents, governanceEvaluations } from '../db/schema.js';
|
|
6
4
|
import { logger } from '../utils/logger.js';
|
|
7
5
|
import { sanitizeResponse } from '../utils/sanitize.js';
|
|
8
6
|
import { v4 as uuidv4 } from 'uuid';
|
|
@@ -60,18 +58,27 @@ async function sendMessageInternal(args) {
|
|
|
60
58
|
const input = SendMessageSchema.parse(args);
|
|
61
59
|
// Defense-in-depth: sanitize text input beyond Zod validation
|
|
62
60
|
const message = sanitizeText(input.message);
|
|
63
|
-
const
|
|
61
|
+
const supabase = getSupabaseClient();
|
|
64
62
|
// Get or create session implicitly if not provided
|
|
65
63
|
// FIX 1: Session object returned directly — no redundant re-fetch
|
|
66
64
|
const { sessionId, session, isNew } = await getOrCreateSession(input.session_id, undefined, 'Message session');
|
|
67
65
|
logger.info(`Sending message for session ${sessionId}${isNew ? ' (newly created)' : ''}`);
|
|
68
66
|
// Get or create thread ID + fetch journey in parallel (FIX 2)
|
|
69
|
-
let threadId = session.
|
|
67
|
+
let threadId = session.thread_id;
|
|
70
68
|
const threadIdPromise = !threadId
|
|
71
|
-
? (threadId = uuidv4(),
|
|
69
|
+
? (threadId = uuidv4(), supabase.from('sessions').update({ thread_id: threadId }).eq('id', sessionId))
|
|
72
70
|
: null;
|
|
73
|
-
const journeyPromise = session.
|
|
74
|
-
?
|
|
71
|
+
const journeyPromise = session.journey_id
|
|
72
|
+
? supabase
|
|
73
|
+
.from('journeys')
|
|
74
|
+
.select('*')
|
|
75
|
+
.eq('id', session.journey_id)
|
|
76
|
+
.maybeSingle()
|
|
77
|
+
.then(({ data, error }) => {
|
|
78
|
+
if (error)
|
|
79
|
+
logger.error('[sendMessage] Journey fetch error:', error);
|
|
80
|
+
return data;
|
|
81
|
+
})
|
|
75
82
|
: null;
|
|
76
83
|
// FIX 2: Run threadId update + journey fetch in parallel
|
|
77
84
|
const [, journey] = await Promise.all([
|
|
@@ -79,14 +86,14 @@ async function sendMessageInternal(args) {
|
|
|
79
86
|
journeyPromise,
|
|
80
87
|
]);
|
|
81
88
|
const memoryContext = JSON.stringify({
|
|
82
|
-
userId: session.
|
|
89
|
+
userId: session.user_id || 'anonymous',
|
|
83
90
|
conversationType: input.conversation_type || 'supportive',
|
|
84
91
|
sessionGoals: [],
|
|
85
92
|
emotionalState: session.metadata?.emotionalState || 'neutral',
|
|
86
93
|
});
|
|
87
94
|
const enhancedContext = {
|
|
88
|
-
journeyStep: journey && session.
|
|
89
|
-
? journey.steps[session.
|
|
95
|
+
journeyStep: journey && session.current_step < journey.steps.length
|
|
96
|
+
? journey.steps[session.current_step]
|
|
90
97
|
: null,
|
|
91
98
|
progressIndicators: session.metadata?.progressIndicators || [],
|
|
92
99
|
};
|
|
@@ -96,7 +103,7 @@ async function sendMessageInternal(args) {
|
|
|
96
103
|
const client = getShrinkChatClient();
|
|
97
104
|
// Send message
|
|
98
105
|
let response = await client.sendMessage(threadId, message, {
|
|
99
|
-
userId: session.
|
|
106
|
+
userId: session.user_id,
|
|
100
107
|
memoryContext,
|
|
101
108
|
enhancedContext,
|
|
102
109
|
history,
|
|
@@ -127,7 +134,7 @@ Please provide a safer, more supportive response to: "${message}"
|
|
|
127
134
|
Suggested approach: ${response.crisis_suggested_actions?.join(', ') || 'De-escalate, validate, provide resources'}`;
|
|
128
135
|
// Get revised response
|
|
129
136
|
const revisedResponse = await client.sendMessage(threadId, revisionPrompt, {
|
|
130
|
-
userId: session.
|
|
137
|
+
userId: session.user_id,
|
|
131
138
|
memoryContext,
|
|
132
139
|
enhancedContext,
|
|
133
140
|
history: [...history,
|
|
@@ -150,9 +157,9 @@ Suggested approach: ${response.crisis_suggested_actions?.join(', ') || 'De-escal
|
|
|
150
157
|
}
|
|
151
158
|
// Additional checkpoint if requested
|
|
152
159
|
if (input.save_checkpoint) {
|
|
153
|
-
await
|
|
154
|
-
|
|
155
|
-
|
|
160
|
+
throwOnError(await supabase.from('checkpoints').insert({
|
|
161
|
+
session_id: session.id,
|
|
162
|
+
step_id: session.current_step.toString(),
|
|
156
163
|
key: input.checkpoint_key || 'message_response',
|
|
157
164
|
value: {
|
|
158
165
|
message: message,
|
|
@@ -160,18 +167,19 @@ Suggested approach: ${response.crisis_suggested_actions?.join(', ') || 'De-escal
|
|
|
160
167
|
selfCorrected,
|
|
161
168
|
timestamp: new Date().toISOString(),
|
|
162
169
|
},
|
|
163
|
-
});
|
|
170
|
+
}).select());
|
|
164
171
|
}
|
|
165
172
|
// Advance step if requested
|
|
166
|
-
if (input.advance_step && session.
|
|
167
|
-
await
|
|
168
|
-
.
|
|
169
|
-
.
|
|
173
|
+
if (input.advance_step && session.journey_id) {
|
|
174
|
+
throwOnError(await supabase
|
|
175
|
+
.from('sessions')
|
|
176
|
+
.update({ current_step: session.current_step + 1, updated_at: new Date().toISOString() })
|
|
177
|
+
.eq('id', session.id));
|
|
170
178
|
}
|
|
171
179
|
// === ASYNC GOVERNANCE EVALUATION ===
|
|
172
180
|
// Run full governance evaluation in the background (non-blocking)
|
|
173
181
|
// This analyzes for hallucination, inconsistency, tone drift, and unsafe reasoning
|
|
174
|
-
runAsyncGovernanceEvaluation(session.id, session.
|
|
182
|
+
runAsyncGovernanceEvaluation(session.id, session.user_id || undefined, responseContent, history.map(h => ({
|
|
175
183
|
role: h.role,
|
|
176
184
|
content: h.content,
|
|
177
185
|
timestamp: new Date()
|
|
@@ -191,7 +199,7 @@ Suggested approach: ${response.crisis_suggested_actions?.join(', ') || 'De-escal
|
|
|
191
199
|
sessionId: session.id,
|
|
192
200
|
threadId,
|
|
193
201
|
selfCorrected,
|
|
194
|
-
currentStep: input.advance_step ? session.
|
|
202
|
+
currentStep: input.advance_step ? session.current_step + 1 : session.current_step,
|
|
195
203
|
},
|
|
196
204
|
timestamp: new Date().toISOString(),
|
|
197
205
|
};
|
|
@@ -227,11 +235,11 @@ async function runAsyncGovernanceEvaluation(sessionId, userId, responseContent,
|
|
|
227
235
|
const result = await engine.evaluate(responseContent, context);
|
|
228
236
|
const evaluationTime = Date.now() - startTime;
|
|
229
237
|
// Log the evaluation with real results - normalize patterns to always be arrays
|
|
230
|
-
const
|
|
231
|
-
await
|
|
232
|
-
sessionId,
|
|
233
|
-
|
|
234
|
-
|
|
238
|
+
const supabase = getSupabaseClient();
|
|
239
|
+
await supabase.from('governance_evaluations').insert({
|
|
240
|
+
session_id: sessionId,
|
|
241
|
+
draft_response: responseContent.substring(0, 1000),
|
|
242
|
+
evaluation_results: {
|
|
235
243
|
hallucination: {
|
|
236
244
|
detected: result.hallucination.detected,
|
|
237
245
|
confidence: result.hallucination.confidence,
|
|
@@ -256,8 +264,11 @@ async function runAsyncGovernanceEvaluation(sessionId, userId, responseContent,
|
|
|
256
264
|
recommendedAction: result.recommendedAction,
|
|
257
265
|
confidence: result.confidence
|
|
258
266
|
},
|
|
259
|
-
|
|
260
|
-
|
|
267
|
+
intervention_applied: null, // Async evaluation doesn't intervene, just logs
|
|
268
|
+
final_response: null,
|
|
269
|
+
}).then(({ error }) => {
|
|
270
|
+
if (error)
|
|
271
|
+
logger.error('[Governance] Failed to insert evaluation:', error);
|
|
261
272
|
});
|
|
262
273
|
// Log summary
|
|
263
274
|
const issuesDetected = [
|
|
@@ -281,16 +292,19 @@ async function runAsyncGovernanceEvaluation(sessionId, userId, responseContent,
|
|
|
281
292
|
* Handle crisis detection - keep existing
|
|
282
293
|
*/
|
|
283
294
|
async function handleCrisisDetection(sessionId, threadId, response) {
|
|
284
|
-
const
|
|
285
|
-
await
|
|
286
|
-
id:
|
|
287
|
-
sessionId,
|
|
288
|
-
threadId,
|
|
289
|
-
|
|
295
|
+
const supabase = getSupabaseClient();
|
|
296
|
+
await supabase.from('crisis_events').insert({
|
|
297
|
+
id: `ce_${crypto.randomUUID()}`,
|
|
298
|
+
session_id: sessionId,
|
|
299
|
+
thread_id: threadId,
|
|
300
|
+
crisis_level: typeof response.crisis_level === 'number' ? response.crisis_level : 10,
|
|
290
301
|
response: response.content || response.reply,
|
|
291
302
|
resources: response.resources || [],
|
|
292
|
-
|
|
303
|
+
escalation_path: response.escalationPath,
|
|
293
304
|
handled: true,
|
|
305
|
+
}).then(({ error }) => {
|
|
306
|
+
if (error)
|
|
307
|
+
logger.error('[Crisis] Failed to insert crisis event:', error);
|
|
294
308
|
});
|
|
295
309
|
logger.info(`Crisis event logged for session ${sessionId}`);
|
|
296
310
|
}
|
|
@@ -309,7 +323,7 @@ async function handleLocalFallback(args) {
|
|
|
309
323
|
metadata: {
|
|
310
324
|
fallbackMode: true,
|
|
311
325
|
sessionId: session.id,
|
|
312
|
-
currentStep: session.
|
|
326
|
+
currentStep: session.current_step,
|
|
313
327
|
},
|
|
314
328
|
};
|
|
315
329
|
}
|