couchloop-eq-mcp 1.4.2 → 2.0.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.
- package/README.md +31 -4
- package/dist/clients/shrinkChatClient.d.ts +4 -4
- package/dist/developer/managers/context-manager.d.ts +24 -45
- package/dist/developer/managers/context-manager.d.ts.map +1 -1
- package/dist/developer/managers/context-manager.js +177 -244
- package/dist/developer/managers/context-manager.js.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/tools/check-versions.d.ts +4 -4
- package/dist/tools/couchloop-v2.d.ts +52 -0
- package/dist/tools/couchloop-v2.d.ts.map +1 -0
- package/dist/tools/couchloop-v2.js +425 -0
- package/dist/tools/couchloop-v2.js.map +1 -0
- package/dist/tools/detect-build-context.d.ts +2 -2
- package/dist/tools/prevent-ai-errors.d.ts +3 -3
- package/dist/tools/primary-tools.d.ts +1 -85
- package/dist/tools/primary-tools.d.ts.map +1 -1
- package/dist/tools/primary-tools.js +36 -13
- package/dist/tools/primary-tools.js.map +1 -1
- package/dist/tools/smart-context.d.ts +1 -1
- package/dist/tools/status.d.ts +2 -2
- package/dist/tools/status.d.ts.map +1 -1
- package/dist/tools/status.js +2 -3
- package/dist/tools/status.js.map +1 -1
- package/dist/tools/verify.d.ts +4 -4
- package/dist/types/context.d.ts +4 -4
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/context.js +1 -1
- package/dist/types/context.js.map +1 -1
- package/dist/types/session.d.ts +2 -2
- package/package.json +15 -2
|
@@ -13,11 +13,11 @@ declare const CheckVersionsInputSchema: z.ZodObject<{
|
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
14
|
name: string;
|
|
15
15
|
version?: string | undefined;
|
|
16
|
-
registry?: "npm" | "
|
|
16
|
+
registry?: "npm" | "pypi" | "maven" | "cargo" | "gem" | "nuget" | "go" | undefined;
|
|
17
17
|
}, {
|
|
18
18
|
name: string;
|
|
19
19
|
version?: string | undefined;
|
|
20
|
-
registry?: "npm" | "
|
|
20
|
+
registry?: "npm" | "pypi" | "maven" | "cargo" | "gem" | "nuget" | "go" | undefined;
|
|
21
21
|
}>, "many">>;
|
|
22
22
|
code: z.ZodOptional<z.ZodString>;
|
|
23
23
|
language: z.ZodOptional<z.ZodString>;
|
|
@@ -34,7 +34,7 @@ declare const CheckVersionsInputSchema: z.ZodObject<{
|
|
|
34
34
|
packages?: {
|
|
35
35
|
name: string;
|
|
36
36
|
version?: string | undefined;
|
|
37
|
-
registry?: "npm" | "
|
|
37
|
+
registry?: "npm" | "pypi" | "maven" | "cargo" | "gem" | "nuget" | "go" | undefined;
|
|
38
38
|
}[] | undefined;
|
|
39
39
|
language?: string | undefined;
|
|
40
40
|
}, {
|
|
@@ -42,7 +42,7 @@ declare const CheckVersionsInputSchema: z.ZodObject<{
|
|
|
42
42
|
packages?: {
|
|
43
43
|
name: string;
|
|
44
44
|
version?: string | undefined;
|
|
45
|
-
registry?: "npm" | "
|
|
45
|
+
registry?: "npm" | "pypi" | "maven" | "cargo" | "gem" | "nuget" | "go" | undefined;
|
|
46
46
|
}[] | undefined;
|
|
47
47
|
language?: string | undefined;
|
|
48
48
|
format?: "json" | "summary" | "markdown" | undefined;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CouchLoop V2 - Refactored Intent Router
|
|
3
|
+
*
|
|
4
|
+
* This is the new implementation of couchloop that uses the modular
|
|
5
|
+
* orchestration system instead of the monolithic god-object pattern.
|
|
6
|
+
*
|
|
7
|
+
* It integrates:
|
|
8
|
+
* - Intent classification with confidence scoring
|
|
9
|
+
* - Policy-based routing decisions
|
|
10
|
+
* - Execution planning with DAGs
|
|
11
|
+
* - OpenTelemetry tracing
|
|
12
|
+
* - Tool registry with health tracking
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Main couchloop v2 handler - backward compatible interface
|
|
16
|
+
*/
|
|
17
|
+
export declare function couchloopV2Handler(args: Record<string, unknown>): Promise<unknown>;
|
|
18
|
+
/**
|
|
19
|
+
* Export the new couchloop tool definition
|
|
20
|
+
*/
|
|
21
|
+
export declare const couchloopV2Tool: {
|
|
22
|
+
definition: {
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
annotations: {
|
|
26
|
+
readOnlyHint: boolean;
|
|
27
|
+
destructiveHint: boolean;
|
|
28
|
+
idempotentHint: boolean;
|
|
29
|
+
openWorldHint: boolean;
|
|
30
|
+
};
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: string;
|
|
33
|
+
properties: {
|
|
34
|
+
intent: {
|
|
35
|
+
type: string;
|
|
36
|
+
description: string;
|
|
37
|
+
};
|
|
38
|
+
context: {
|
|
39
|
+
type: string;
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
session_id: {
|
|
43
|
+
type: string;
|
|
44
|
+
description: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
required: string[];
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
handler: typeof couchloopV2Handler;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=couchloop-v2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"couchloop-v2.d.ts","sourceRoot":"","sources":["../../src/tools/couchloop-v2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAiDH;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAkUxF;AA6FD;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyC3B,CAAC"}
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CouchLoop V2 - Refactored Intent Router
|
|
3
|
+
*
|
|
4
|
+
* This is the new implementation of couchloop that uses the modular
|
|
5
|
+
* orchestration system instead of the monolithic god-object pattern.
|
|
6
|
+
*
|
|
7
|
+
* It integrates:
|
|
8
|
+
* - Intent classification with confidence scoring
|
|
9
|
+
* - Policy-based routing decisions
|
|
10
|
+
* - Execution planning with DAGs
|
|
11
|
+
* - OpenTelemetry tracing
|
|
12
|
+
* - Tool registry with health tracking
|
|
13
|
+
*/
|
|
14
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
15
|
+
import { logger } from '../utils/logger.js';
|
|
16
|
+
import { classifyIntent } from '../core/intent/classifier.js';
|
|
17
|
+
import { intentRouterTool } from './intent-router.js';
|
|
18
|
+
import { PolicyEngine } from '../core/policy/engine.js';
|
|
19
|
+
import { ExecutionPlanner } from '../core/planning/planner.js';
|
|
20
|
+
import { ToolRegistry } from '../core/registry/registry.js';
|
|
21
|
+
import { createStandardError, } from '../core/envelopes.js';
|
|
22
|
+
import { startRequestSpan, traceAsync, TracingStages, addSpanEvent, } from '../core/telemetry/tracing.js';
|
|
23
|
+
// Default feature flags (can be overridden by environment variables)
|
|
24
|
+
const FEATURE_FLAGS = {
|
|
25
|
+
useV2Classifier: process.env.USE_V2_CLASSIFIER !== 'false',
|
|
26
|
+
useV2PolicyEngine: process.env.USE_V2_POLICY !== 'false',
|
|
27
|
+
useV2Planner: process.env.USE_V2_PLANNER !== 'false',
|
|
28
|
+
useV2Telemetry: process.env.USE_V2_TELEMETRY !== 'false',
|
|
29
|
+
directRouteEnabled: process.env.DIRECT_ROUTE_ENABLED !== 'false',
|
|
30
|
+
parallelExecutionEnabled: process.env.PARALLEL_EXECUTION === 'true',
|
|
31
|
+
cachingEnabled: process.env.CACHING_ENABLED === 'true',
|
|
32
|
+
};
|
|
33
|
+
// Initialize components
|
|
34
|
+
const policyEngine = new PolicyEngine();
|
|
35
|
+
const executionPlanner = new ExecutionPlanner();
|
|
36
|
+
const toolRegistry = ToolRegistry.getInstance();
|
|
37
|
+
/**
|
|
38
|
+
* Main couchloop v2 handler - backward compatible interface
|
|
39
|
+
*/
|
|
40
|
+
export async function couchloopV2Handler(args) {
|
|
41
|
+
const requestId = uuidv4();
|
|
42
|
+
const traceId = args.trace_id || uuidv4();
|
|
43
|
+
const startTime = Date.now();
|
|
44
|
+
// Start tracing if enabled
|
|
45
|
+
const span = FEATURE_FLAGS.useV2Telemetry ?
|
|
46
|
+
startRequestSpan('couchloop_v2', { requestId, traceId }) : null;
|
|
47
|
+
try {
|
|
48
|
+
// Extract input from legacy format
|
|
49
|
+
const intent = args.intent;
|
|
50
|
+
const context = args.context;
|
|
51
|
+
const sessionId = args.session_id;
|
|
52
|
+
const tenantId = args.tenant_id;
|
|
53
|
+
const userId = args.user_id;
|
|
54
|
+
if (!intent) {
|
|
55
|
+
throw createStandardError('MISSING_INTENT', 'Intent parameter is required');
|
|
56
|
+
}
|
|
57
|
+
// Log incoming request
|
|
58
|
+
logger.info('CouchLoop V2 request', {
|
|
59
|
+
requestId,
|
|
60
|
+
traceId,
|
|
61
|
+
intent: intent.substring(0, 100),
|
|
62
|
+
hasContext: !!context,
|
|
63
|
+
sessionId,
|
|
64
|
+
});
|
|
65
|
+
// Phase 1: Normalize input (minimal for now)
|
|
66
|
+
const normalizedInput = await traceAsync(TracingStages.NORMALIZE, async (normalizeSpan) => {
|
|
67
|
+
normalizeSpan.setAttributes({
|
|
68
|
+
'input.length': intent.length,
|
|
69
|
+
'has.context': !!context,
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
intent: intent.trim(),
|
|
73
|
+
context: context?.trim(),
|
|
74
|
+
metadata: { sessionId, tenantId, userId },
|
|
75
|
+
};
|
|
76
|
+
}, { attributes: { requestId, stage: 'normalize' } });
|
|
77
|
+
// Phase 2: Classify intent
|
|
78
|
+
const classification = await traceAsync(TracingStages.CLASSIFY, async (classifySpan) => {
|
|
79
|
+
if (!FEATURE_FLAGS.useV2Classifier) {
|
|
80
|
+
// Fallback to simple classification for gradual rollout
|
|
81
|
+
return {
|
|
82
|
+
primaryIntent: 'unknown',
|
|
83
|
+
confidence: 0.5,
|
|
84
|
+
ambiguous: true,
|
|
85
|
+
multiIntent: false,
|
|
86
|
+
alternatives: [],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const result = classifyIntent(normalizedInput.intent);
|
|
90
|
+
classifySpan.setAttributes({
|
|
91
|
+
'intent.primary': result.primaryIntent,
|
|
92
|
+
'intent.confidence': result.confidence,
|
|
93
|
+
'intent.ambiguous': result.ambiguous,
|
|
94
|
+
'intent.multi': result.multiIntent,
|
|
95
|
+
});
|
|
96
|
+
return result;
|
|
97
|
+
}, { attributes: { requestId, stage: 'classify' } });
|
|
98
|
+
// Phase 3: Apply policy engine
|
|
99
|
+
const policyDecision = await traceAsync(TracingStages.POLICY, async (policySpan) => {
|
|
100
|
+
if (!FEATURE_FLAGS.useV2PolicyEngine) {
|
|
101
|
+
// Simple policy for gradual rollout
|
|
102
|
+
return {
|
|
103
|
+
action: 'router',
|
|
104
|
+
reason: 'V2 policy engine disabled',
|
|
105
|
+
confidence: classification.confidence,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const policyContext = {
|
|
109
|
+
requestId,
|
|
110
|
+
traceId,
|
|
111
|
+
tenantId,
|
|
112
|
+
userId,
|
|
113
|
+
sessionId,
|
|
114
|
+
latencyBudgetMs: 5000,
|
|
115
|
+
priority: 'normal',
|
|
116
|
+
};
|
|
117
|
+
const decision = policyEngine.evaluate(policyContext, classification, toolRegistry.getHealthMap());
|
|
118
|
+
policySpan.setAttributes({
|
|
119
|
+
'policy.action': decision.action,
|
|
120
|
+
'policy.target': decision.targetTool,
|
|
121
|
+
'policy.reason': decision.reason,
|
|
122
|
+
});
|
|
123
|
+
return decision;
|
|
124
|
+
}, { attributes: { requestId, stage: 'policy' } });
|
|
125
|
+
// Phase 4: Create execution plan
|
|
126
|
+
const executionPlan = await traceAsync(TracingStages.PLAN, async (planSpan) => {
|
|
127
|
+
if (!FEATURE_FLAGS.useV2Planner) {
|
|
128
|
+
// Simple single-node plan for gradual rollout
|
|
129
|
+
return {
|
|
130
|
+
planId: uuidv4(),
|
|
131
|
+
planType: 'single',
|
|
132
|
+
nodes: [{
|
|
133
|
+
nodeId: 'n1',
|
|
134
|
+
tool: policyDecision.targetTool || 'couchloop_router',
|
|
135
|
+
dependsOn: [],
|
|
136
|
+
deadlineMs: 5000,
|
|
137
|
+
retryPolicy: 'standard',
|
|
138
|
+
}],
|
|
139
|
+
globalDeadlineMs: 5000,
|
|
140
|
+
fallbacks: {},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
const plan = executionPlanner.createPlan(classification, policyDecision, 5000 // Default deadline
|
|
144
|
+
);
|
|
145
|
+
planSpan.setAttributes({
|
|
146
|
+
'plan.id': plan.planId,
|
|
147
|
+
'plan.type': plan.planType,
|
|
148
|
+
'plan.nodes': plan.nodes.length,
|
|
149
|
+
});
|
|
150
|
+
return plan;
|
|
151
|
+
}, { attributes: { requestId, stage: 'plan' } });
|
|
152
|
+
// Phase 5: Execute plan
|
|
153
|
+
const executionResult = await traceAsync(TracingStages.EXECUTE, async (executeSpan) => {
|
|
154
|
+
executeSpan.setAttributes({
|
|
155
|
+
'execution.plan': executionPlan.planId,
|
|
156
|
+
'execution.nodes': executionPlan.nodes.length,
|
|
157
|
+
});
|
|
158
|
+
// For now, execute the first node only (full parallel execution coming later)
|
|
159
|
+
if (executionPlan.nodes.length === 0) {
|
|
160
|
+
return {
|
|
161
|
+
success: false,
|
|
162
|
+
error: 'No execution nodes in plan',
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
const primaryNode = executionPlan.nodes[0];
|
|
166
|
+
if (!primaryNode) {
|
|
167
|
+
return {
|
|
168
|
+
success: false,
|
|
169
|
+
error: 'Primary node not found in plan',
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const tool = toolRegistry.getTool(primaryNode.tool);
|
|
173
|
+
if (!tool) {
|
|
174
|
+
// Fallback to legacy router if tool not found
|
|
175
|
+
addSpanEvent('tool_not_found', { tool: primaryNode.tool });
|
|
176
|
+
return executeLegacyRouter(normalizedInput);
|
|
177
|
+
}
|
|
178
|
+
// Execute the tool with timeout
|
|
179
|
+
const toolStartTime = Date.now();
|
|
180
|
+
try {
|
|
181
|
+
const result = await Promise.race([
|
|
182
|
+
tool.handler({
|
|
183
|
+
...normalizedInput.metadata,
|
|
184
|
+
intent: normalizedInput.intent,
|
|
185
|
+
context: normalizedInput.context,
|
|
186
|
+
action: mapIntentToAction(classification.primaryIntent),
|
|
187
|
+
// Tool-specific required parameter defaults.
|
|
188
|
+
// The V2 direct-execution path bypasses the legacy intent router's
|
|
189
|
+
// per-tool arg mapping, so we supply sensible defaults here.
|
|
190
|
+
...mapToolArgs(primaryNode.tool, normalizedInput.intent),
|
|
191
|
+
}),
|
|
192
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error('Tool execution timeout')), primaryNode.deadlineMs)),
|
|
193
|
+
]);
|
|
194
|
+
const toolLatency = Date.now() - toolStartTime;
|
|
195
|
+
toolRegistry.recordToolExecution(primaryNode.tool, 'success', toolLatency);
|
|
196
|
+
executeSpan.setAttributes({
|
|
197
|
+
'execution.success': true,
|
|
198
|
+
'execution.latency': toolLatency,
|
|
199
|
+
});
|
|
200
|
+
return {
|
|
201
|
+
success: true,
|
|
202
|
+
result,
|
|
203
|
+
tool: primaryNode.tool,
|
|
204
|
+
latency: toolLatency,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
const toolLatency = Date.now() - toolStartTime;
|
|
209
|
+
const isTimeout = error instanceof Error && error.message === 'Tool execution timeout';
|
|
210
|
+
toolRegistry.recordToolExecution(primaryNode.tool, isTimeout ? 'timeout' : 'error', toolLatency);
|
|
211
|
+
executeSpan.setAttributes({
|
|
212
|
+
'execution.success': false,
|
|
213
|
+
'execution.error': error instanceof Error ? error.message : 'Unknown error',
|
|
214
|
+
});
|
|
215
|
+
// Try fallback if available
|
|
216
|
+
const fallbacks = executionPlan.fallbacks[primaryNode.nodeId];
|
|
217
|
+
if (fallbacks && fallbacks.length > 0 && fallbacks[0]) {
|
|
218
|
+
addSpanEvent('executing_fallback');
|
|
219
|
+
return executeFallback(fallbacks[0], normalizedInput);
|
|
220
|
+
}
|
|
221
|
+
throw error;
|
|
222
|
+
}
|
|
223
|
+
}, { attributes: { requestId, stage: 'execute' } });
|
|
224
|
+
// Phase 6: Compose response
|
|
225
|
+
const response = await traceAsync(TracingStages.COMPOSE, async (composeSpan) => {
|
|
226
|
+
const totalLatency = Date.now() - startTime;
|
|
227
|
+
composeSpan.setAttributes({
|
|
228
|
+
'response.latency': totalLatency,
|
|
229
|
+
'response.success': executionResult.success,
|
|
230
|
+
});
|
|
231
|
+
// Return legacy format for backward compatibility
|
|
232
|
+
return {
|
|
233
|
+
...executionResult.result,
|
|
234
|
+
_metadata: {
|
|
235
|
+
requestId,
|
|
236
|
+
traceId,
|
|
237
|
+
classification: {
|
|
238
|
+
intent: classification.primaryIntent,
|
|
239
|
+
confidence: classification.confidence,
|
|
240
|
+
ambiguous: classification.ambiguous,
|
|
241
|
+
},
|
|
242
|
+
routing: {
|
|
243
|
+
action: policyDecision.action,
|
|
244
|
+
reason: policyDecision.reason,
|
|
245
|
+
},
|
|
246
|
+
execution: {
|
|
247
|
+
planType: executionPlan.planType,
|
|
248
|
+
tool: executionResult.tool,
|
|
249
|
+
latencyMs: totalLatency,
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
}, { attributes: { requestId, stage: 'compose' } });
|
|
254
|
+
// Log completion
|
|
255
|
+
logger.info('CouchLoop V2 request completed', {
|
|
256
|
+
requestId,
|
|
257
|
+
traceId,
|
|
258
|
+
totalLatency: Date.now() - startTime,
|
|
259
|
+
intent: classification.primaryIntent,
|
|
260
|
+
confidence: classification.confidence,
|
|
261
|
+
routingAction: policyDecision.action,
|
|
262
|
+
tool: executionResult.tool,
|
|
263
|
+
});
|
|
264
|
+
return response;
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
logger.error('CouchLoop V2 request failed', {
|
|
268
|
+
requestId,
|
|
269
|
+
traceId,
|
|
270
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
271
|
+
});
|
|
272
|
+
span?.setStatus({
|
|
273
|
+
code: 2, // ERROR
|
|
274
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
275
|
+
});
|
|
276
|
+
// Return error in legacy format
|
|
277
|
+
return {
|
|
278
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
279
|
+
requestId,
|
|
280
|
+
traceId,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
finally {
|
|
284
|
+
span?.end();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Execute legacy router for backward compatibility.
|
|
289
|
+
* Delegates to the real intent router (intent-router.ts) which has its own
|
|
290
|
+
* populated tool registry from registerTools(). This bridges the gap between
|
|
291
|
+
* the V2 ToolRegistry and the legacy tool Map until they are fully unified.
|
|
292
|
+
*/
|
|
293
|
+
async function executeLegacyRouter(input) {
|
|
294
|
+
try {
|
|
295
|
+
const result = await intentRouterTool.handler({
|
|
296
|
+
intent: input.intent,
|
|
297
|
+
context: input.context,
|
|
298
|
+
session_id: input.metadata?.sessionId,
|
|
299
|
+
});
|
|
300
|
+
return result;
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
logger.error('[couchloop-v2] Legacy router fallback failed:', error);
|
|
304
|
+
return {
|
|
305
|
+
success: false,
|
|
306
|
+
routed_to: 'legacy_router',
|
|
307
|
+
error: error instanceof Error ? error.message : 'Legacy router failed',
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Execute fallback tool
|
|
313
|
+
*/
|
|
314
|
+
async function executeFallback(toolName, input) {
|
|
315
|
+
const tool = toolRegistry.getTool(toolName);
|
|
316
|
+
if (!tool) {
|
|
317
|
+
return {
|
|
318
|
+
success: false,
|
|
319
|
+
error: `Fallback tool ${toolName} not found`,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
try {
|
|
323
|
+
const result = await tool.handler(input);
|
|
324
|
+
return {
|
|
325
|
+
success: true,
|
|
326
|
+
result,
|
|
327
|
+
tool: toolName,
|
|
328
|
+
fallback: true,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
return {
|
|
333
|
+
success: false,
|
|
334
|
+
error: error instanceof Error ? error.message : 'Fallback failed',
|
|
335
|
+
tool: toolName,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Map tool name to the required args it needs beyond intent/context/action.
|
|
341
|
+
* Prevents "Required" validation errors when the V2 executor calls tools directly
|
|
342
|
+
* without going through the legacy intent router's per-tool arg mapping.
|
|
343
|
+
*/
|
|
344
|
+
function mapToolArgs(toolName, intent) {
|
|
345
|
+
switch (toolName) {
|
|
346
|
+
case 'status': {
|
|
347
|
+
// Infer check type from intent, default to 'all'
|
|
348
|
+
if (/session|progress/i.test(intent))
|
|
349
|
+
return { check: 'session' };
|
|
350
|
+
if (/history|insight|pattern/i.test(intent))
|
|
351
|
+
return { check: 'history' };
|
|
352
|
+
if (/context|window|stored|decision/i.test(intent))
|
|
353
|
+
return { check: 'context' };
|
|
354
|
+
if (/backup|protection|freeze/i.test(intent))
|
|
355
|
+
return { check: 'protection' };
|
|
356
|
+
if (/preference|setting|timezone/i.test(intent))
|
|
357
|
+
return { check: 'preferences' };
|
|
358
|
+
return { check: 'all' };
|
|
359
|
+
}
|
|
360
|
+
case 'conversation':
|
|
361
|
+
return { message: intent };
|
|
362
|
+
case 'brainstorm':
|
|
363
|
+
return { message: intent };
|
|
364
|
+
case 'remember':
|
|
365
|
+
return { content: intent };
|
|
366
|
+
default:
|
|
367
|
+
return {};
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Map intent to action for backward compatibility
|
|
372
|
+
*/
|
|
373
|
+
function mapIntentToAction(intent) {
|
|
374
|
+
const actionMap = {
|
|
375
|
+
'session_control': 'send',
|
|
376
|
+
'memory_control': 'save',
|
|
377
|
+
};
|
|
378
|
+
return actionMap[intent];
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Export the new couchloop tool definition
|
|
382
|
+
*/
|
|
383
|
+
export const couchloopV2Tool = {
|
|
384
|
+
definition: {
|
|
385
|
+
name: 'couchloop',
|
|
386
|
+
description: `Universal entry point for CouchLoop. Routes ANY command to the right tool automatically. ALWAYS use for ambiguous or loose commands. Handles:
|
|
387
|
+
- Sessions: "end session", "start", "done", "wrap up", "goodbye", "resume", "where should I start", "hi", "hey"
|
|
388
|
+
- Status: "how am I doing", "what do you know about me", "show my progress", "my settings", "dashboard"
|
|
389
|
+
- Memory: "save", "remember", "checkpoint", "recall", "don't forget", "keep track"
|
|
390
|
+
- Code: "review code", "check this", "find bugs", "is this safe", "analyze"
|
|
391
|
+
- Packages: "audit dependencies", "outdated", "npm audit", "upgrade packages", "security scan"
|
|
392
|
+
- Protection: "backup", "freeze code", "rollback", "undo", "restore"
|
|
393
|
+
- Brainstorm: "brainstorm", "think through", "map out feature", "help me design", "I have an idea", "trade-offs"
|
|
394
|
+
- Journeys: "I'm stressed", "feeling anxious", "help me", "need to talk"
|
|
395
|
+
- Verification: "verify this", "check my response", "is this correct", "does this package exist"
|
|
396
|
+
|
|
397
|
+
Invoke for ANY ambiguous, loose, or multi-intent command. High-confidence single-intent commands can also call specific tools directly.`,
|
|
398
|
+
annotations: {
|
|
399
|
+
readOnlyHint: false,
|
|
400
|
+
destructiveHint: false,
|
|
401
|
+
idempotentHint: false,
|
|
402
|
+
openWorldHint: true,
|
|
403
|
+
},
|
|
404
|
+
inputSchema: {
|
|
405
|
+
type: 'object',
|
|
406
|
+
properties: {
|
|
407
|
+
intent: {
|
|
408
|
+
type: 'string',
|
|
409
|
+
description: 'What the user wants to do. Can be a loose natural-language phrase like "end session", "review this code", "I have an idea", or "where should I start".',
|
|
410
|
+
},
|
|
411
|
+
context: {
|
|
412
|
+
type: 'string',
|
|
413
|
+
description: 'Additional content relevant to the intent — code to review, a message body, package names, or any supporting detail that helps route and execute the command.',
|
|
414
|
+
},
|
|
415
|
+
session_id: {
|
|
416
|
+
type: 'string',
|
|
417
|
+
description: 'Active session ID if known. Omit to let the server resolve the current session automatically.',
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
required: ['intent'],
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
handler: couchloopV2Handler,
|
|
424
|
+
};
|
|
425
|
+
//# sourceMappingURL=couchloop-v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"couchloop-v2.js","sourceRoot":"","sources":["../../src/tools/couchloop-v2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACL,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,YAAY,GACb,MAAM,8BAA8B,CAAC;AAgBtC,qEAAqE;AACrE,MAAM,aAAa,GAAiB;IAClC,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,OAAO;IAC1D,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,OAA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9 @@ export declare const detectBuildContextTool: {
|
|
|
26
26
|
export declare function handleDetectBuildContext(args: unknown): Promise<{
|
|
27
27
|
success: boolean;
|
|
28
28
|
context: {
|
|
29
|
-
language: "
|
|
29
|
+
language: "unknown" | "javascript" | "typescript" | "python" | "java";
|
|
30
30
|
module_system: "commonjs" | "esm" | "umd" | "amd" | undefined;
|
|
31
|
-
package_manager: "npm" | "
|
|
31
|
+
package_manager: "npm" | "maven" | "yarn" | "pnpm" | "pip" | "gradle" | undefined;
|
|
32
32
|
build_tool: string | undefined;
|
|
33
33
|
typescript_config: {
|
|
34
34
|
moduleResolution?: string;
|
|
@@ -49,7 +49,7 @@ export declare function handlePreventAIErrors(args: unknown): Promise<{
|
|
|
49
49
|
id: string;
|
|
50
50
|
name: string;
|
|
51
51
|
impact: "medium" | "critical" | "high" | "low";
|
|
52
|
-
category: "
|
|
52
|
+
category: "architecture" | "security" | "build" | "syntax" | "logic" | "performance";
|
|
53
53
|
description: string;
|
|
54
54
|
locations: {
|
|
55
55
|
line: number;
|
|
@@ -62,9 +62,9 @@ export declare function handlePreventAIErrors(args: unknown): Promise<{
|
|
|
62
62
|
warnings: string[];
|
|
63
63
|
prevented_errors: string[];
|
|
64
64
|
build_context: {
|
|
65
|
-
language: "
|
|
65
|
+
language: "unknown" | "javascript" | "typescript" | "python" | "java";
|
|
66
66
|
module_system: "commonjs" | "esm" | "umd" | "amd" | undefined;
|
|
67
|
-
package_manager: "npm" | "
|
|
67
|
+
package_manager: "npm" | "maven" | "yarn" | "pnpm" | "pip" | "gradle" | undefined;
|
|
68
68
|
requires_js_extensions: boolean;
|
|
69
69
|
ai_guidance: string[];
|
|
70
70
|
} | null;
|
|
@@ -49,91 +49,7 @@ export declare function setupTools(): Promise<({
|
|
|
49
49
|
required: string[];
|
|
50
50
|
};
|
|
51
51
|
};
|
|
52
|
-
handler: (
|
|
53
|
-
error: string;
|
|
54
|
-
hint: string;
|
|
55
|
-
routed_to?: undefined;
|
|
56
|
-
message?: undefined;
|
|
57
|
-
tools?: undefined;
|
|
58
|
-
examples?: undefined;
|
|
59
|
-
classification?: undefined;
|
|
60
|
-
registeredTools?: undefined;
|
|
61
|
-
success?: undefined;
|
|
62
|
-
routing_confidence?: undefined;
|
|
63
|
-
} | {
|
|
64
|
-
routed_to: string;
|
|
65
|
-
message: string;
|
|
66
|
-
tools: {
|
|
67
|
-
couchloop: string;
|
|
68
|
-
verify: string;
|
|
69
|
-
status: string;
|
|
70
|
-
conversation: string;
|
|
71
|
-
brainstorm: string;
|
|
72
|
-
remember: string;
|
|
73
|
-
code_review: string;
|
|
74
|
-
package_audit: string;
|
|
75
|
-
protect: string;
|
|
76
|
-
};
|
|
77
|
-
examples: string[];
|
|
78
|
-
hint: string;
|
|
79
|
-
error?: undefined;
|
|
80
|
-
classification?: undefined;
|
|
81
|
-
registeredTools?: undefined;
|
|
82
|
-
success?: undefined;
|
|
83
|
-
routing_confidence?: undefined;
|
|
84
|
-
} | {
|
|
85
|
-
error: string;
|
|
86
|
-
classification: import("./intent-router.js").ClassificationResult;
|
|
87
|
-
registeredTools: string[];
|
|
88
|
-
hint?: undefined;
|
|
89
|
-
routed_to?: undefined;
|
|
90
|
-
message?: undefined;
|
|
91
|
-
tools?: undefined;
|
|
92
|
-
examples?: undefined;
|
|
93
|
-
success?: undefined;
|
|
94
|
-
routing_confidence?: undefined;
|
|
95
|
-
} | {
|
|
96
|
-
routed_to: string;
|
|
97
|
-
message: string;
|
|
98
|
-
hint: string;
|
|
99
|
-
error?: undefined;
|
|
100
|
-
tools?: undefined;
|
|
101
|
-
examples?: undefined;
|
|
102
|
-
classification?: undefined;
|
|
103
|
-
registeredTools?: undefined;
|
|
104
|
-
success?: undefined;
|
|
105
|
-
routing_confidence?: undefined;
|
|
106
|
-
} | {
|
|
107
|
-
policy_trace: import("../policy/types.js").PolicyDecisionTrace;
|
|
108
|
-
error?: string | undefined;
|
|
109
|
-
verify_result?: {} | null | undefined;
|
|
110
|
-
requires_approval?: boolean | undefined;
|
|
111
|
-
blocked?: boolean | undefined;
|
|
112
|
-
partial?: boolean | undefined;
|
|
113
|
-
routed_to: string;
|
|
114
|
-
action: string | undefined;
|
|
115
|
-
routing_confidence: number;
|
|
116
|
-
success: boolean;
|
|
117
|
-
tool: import("../policy/types.js").PublicToolName;
|
|
118
|
-
result: unknown;
|
|
119
|
-
hint?: undefined;
|
|
120
|
-
message?: undefined;
|
|
121
|
-
tools?: undefined;
|
|
122
|
-
examples?: undefined;
|
|
123
|
-
classification?: undefined;
|
|
124
|
-
registeredTools?: undefined;
|
|
125
|
-
} | {
|
|
126
|
-
success: boolean;
|
|
127
|
-
routed_to: string;
|
|
128
|
-
error: string;
|
|
129
|
-
routing_confidence: number;
|
|
130
|
-
hint?: undefined;
|
|
131
|
-
message?: undefined;
|
|
132
|
-
tools?: undefined;
|
|
133
|
-
examples?: undefined;
|
|
134
|
-
classification?: undefined;
|
|
135
|
-
registeredTools?: undefined;
|
|
136
|
-
}>;
|
|
52
|
+
handler: typeof import("./couchloop-v2.js").couchloopV2Handler;
|
|
137
53
|
} | {
|
|
138
54
|
handler: (args: Record<string, unknown>, _routedVia?: PolicyContext["routedVia"]) => Promise<import("../policy/types.js").NormalizedToolResponse<unknown>>;
|
|
139
55
|
definition: {
|