@causyne/agent 1.20.38 → 1.20.41
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/LICENSE +1 -1
- package/package.json +1 -1
- package/src/commands.js +41 -0
- package/src/decisionPolicy.js +1 -1
- package/src/decisionPolicy.ts +1 -1
- package/src/plugins/pluginsFactory.js +4 -0
- package/src/plugins/pluginsFactory.ts +6 -0
- package/src/pluginsFactory/costEstimate.js +89 -0
- package/src/pluginsFactory/costEstimate.ts +110 -0
- package/src/pluginsFactory/discovery.js +97 -0
- package/src/pluginsFactory/discovery.ts +114 -0
- package/src/pluginsFactory/index.js +9 -0
- package/src/pluginsFactory/index.ts +11 -0
- package/src/pluginsFactory/pluginsFactory.js +255 -0
- package/src/pluginsFactory/pluginsFactory.ts +307 -0
- package/src/pluginsFactory/strategy.js +93 -0
- package/src/pluginsFactory/strategy.ts +106 -0
- package/src/pluginsFactory/templates.js +624 -0
- package/src/pluginsFactory/templates.ts +662 -0
- package/src/pluginsFactory/types.js +12 -0
- package/src/pluginsFactory/types.ts +107 -0
- package/src/stallGuard.js +1 -0
- package/src/stallGuard.ts +1 -0
- package/src/toolPacks.js +2 -1
- package/src/toolPacks.ts +2 -1
- package/src/tools/pluginsFactory.js +209 -0
- package/src/tools/pluginsFactory.ts +254 -0
- package/src/tools/registry.js +2 -1
- package/src/toolsList.js +1 -0
- package/src/toolsList.ts +1 -0
- package/src/tui/chatRenderer.d.ts +1 -0
- package/src/tui/chatRenderer.js +60 -37
- package/src/tui/messageInteraction.js +26 -3
- package/src/tui/messageInteraction.ts +39 -4
- package/src/tui/thinkingBox.js +141 -0
- package/src/tui/thinkingBox.ts +190 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route Selection Strategy for PluginsFactory.
|
|
3
|
+
*
|
|
4
|
+
* Implements deterministic route assessment prioritizing token efficiency and cost:
|
|
5
|
+
* 1. Check existing coverage: Built-in tools, installed plugins, configured MCP servers.
|
|
6
|
+
* 2. Honor explicit user preference immediately without unnecessary friction.
|
|
7
|
+
* 3. Route 1: Native Plugin (HTTP/CLI) - Leanest token footprint, lowest cost.
|
|
8
|
+
* 4. Route 2: Python Bridge - Lightweight on-demand buffer for Python-only libraries.
|
|
9
|
+
* 5. Route 3: MCP Server - Used when service is MCP-only or user explicitly requests it.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { estimateServiceCosts, formatMcpDisclosure } from './costEstimate.js';
|
|
13
|
+
import { findExistingCapability } from './discovery.js';
|
|
14
|
+
import type { FactoryRouteProposal, RouteKind, ServiceDescriptor } from './types.js';
|
|
15
|
+
|
|
16
|
+
const PYTHON_KEYWORDS = [
|
|
17
|
+
'python',
|
|
18
|
+
'scipy',
|
|
19
|
+
'numpy',
|
|
20
|
+
'pandas',
|
|
21
|
+
'torch',
|
|
22
|
+
'pytorch',
|
|
23
|
+
'tensorflow',
|
|
24
|
+
'keras',
|
|
25
|
+
'blender',
|
|
26
|
+
'resolve',
|
|
27
|
+
'bpy',
|
|
28
|
+
'da_vinci',
|
|
29
|
+
'sympy',
|
|
30
|
+
'nltk',
|
|
31
|
+
'spacy',
|
|
32
|
+
'huggingface'
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
function isPythonSpecific(service: ServiceDescriptor): boolean {
|
|
36
|
+
if (service.serviceKind === 'python_sdk') return true;
|
|
37
|
+
if (service.pythonModule && service.pythonModule.trim()) return true;
|
|
38
|
+
const nameLower = service.name.toLowerCase();
|
|
39
|
+
const descLower = (service.description || '').toLowerCase();
|
|
40
|
+
return PYTHON_KEYWORDS.some(kw => nameLower.includes(kw) || descLower.includes(kw));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function assessRoute(
|
|
44
|
+
service: ServiceDescriptor,
|
|
45
|
+
userPreference?: RouteKind
|
|
46
|
+
): FactoryRouteProposal {
|
|
47
|
+
const costComparison = estimateServiceCosts(service);
|
|
48
|
+
const existingCapability = findExistingCapability(service.name);
|
|
49
|
+
|
|
50
|
+
// 1. User Preference Override
|
|
51
|
+
const chosenRoute = userPreference ?? service.userPreferredRoute;
|
|
52
|
+
if (chosenRoute) {
|
|
53
|
+
const isMcp = chosenRoute === 'mcp_server';
|
|
54
|
+
const proposal: FactoryRouteProposal = {
|
|
55
|
+
service,
|
|
56
|
+
recommendedRoute: chosenRoute,
|
|
57
|
+
reason: `Honoring user explicit preference for route '${chosenRoute}'.`,
|
|
58
|
+
costComparison,
|
|
59
|
+
userConsentRequired: false,
|
|
60
|
+
userConfirmedRoute: chosenRoute,
|
|
61
|
+
existingCapability: existingCapability.covered ? existingCapability : undefined
|
|
62
|
+
};
|
|
63
|
+
if (isMcp) {
|
|
64
|
+
proposal.mcpDisclosure = formatMcpDisclosure(service.name, costComparison);
|
|
65
|
+
}
|
|
66
|
+
return proposal;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 2. Python SDK Route (Bridge Buffer)
|
|
70
|
+
if (isPythonSpecific(service)) {
|
|
71
|
+
return {
|
|
72
|
+
service,
|
|
73
|
+
recommendedRoute: 'python_bridge',
|
|
74
|
+
reason:
|
|
75
|
+
'Service depends on Python SDK or specialized scientific/creative modules. A Python bridge provides an on-demand subprocess buffer without full MCP overhead.',
|
|
76
|
+
costComparison,
|
|
77
|
+
userConsentRequired: false,
|
|
78
|
+
existingCapability: existingCapability.covered ? existingCapability : undefined
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 3. MCP-Only Service Route
|
|
83
|
+
if (service.serviceKind === 'mcp_only') {
|
|
84
|
+
return {
|
|
85
|
+
service,
|
|
86
|
+
recommendedRoute: 'mcp_server',
|
|
87
|
+
reason:
|
|
88
|
+
'Service exclusively exposes an MCP endpoint or protocol. Recommending MCP server scaffold with token overhead disclosure.',
|
|
89
|
+
costComparison,
|
|
90
|
+
mcpDisclosure: formatMcpDisclosure(service.name, costComparison),
|
|
91
|
+
userConsentRequired: true,
|
|
92
|
+
existingCapability: existingCapability.covered ? existingCapability : undefined
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 4. Default / Native Plugin Route (HTTP API or CLI)
|
|
97
|
+
return {
|
|
98
|
+
service,
|
|
99
|
+
recommendedRoute: 'native_plugin',
|
|
100
|
+
reason:
|
|
101
|
+
'Service supports HTTP/REST API or CLI interface. Native plugin is selected as the most token-lean and cost-effective route.',
|
|
102
|
+
costComparison,
|
|
103
|
+
userConsentRequired: false,
|
|
104
|
+
existingCapability: existingCapability.covered ? existingCapability : undefined
|
|
105
|
+
};
|
|
106
|
+
}
|