@causyne/agent 1.20.38 → 1.20.39
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/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 +250 -0
- package/src/pluginsFactory/pluginsFactory.ts +302 -0
- package/src/pluginsFactory/strategy.js +93 -0
- package/src/pluginsFactory/strategy.ts +106 -0
- package/src/pluginsFactory/templates.js +592 -0
- package/src/pluginsFactory/templates.ts +631 -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 +1 -0
- package/src/toolPacks.ts +1 -0
- package/src/tools/pluginsFactory.js +202 -0
- package/src/tools/pluginsFactory.ts +246 -0
- package/src/tools/registry.js +2 -1
- package/src/toolsList.js +1 -0
- package/src/toolsList.ts +1 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types and interfaces for PluginsFactory.
|
|
3
|
+
*
|
|
4
|
+
* PluginsFactory empowers Causyne Agent to generate custom plugins, Python bridges,
|
|
5
|
+
* or MCP servers when a requested service/integration does not yet exist.
|
|
6
|
+
*
|
|
7
|
+
* Route Strategy:
|
|
8
|
+
* 1. Native Plugin (HTTP/CLI): Leanest token footprint, lowest cost.
|
|
9
|
+
* 2. Python Bridge: Spawns Python subprocess with JSON protocol for Python-only SDKs.
|
|
10
|
+
* 3. MCP Server: Used when a service strictly permits only MCP or the user explicitly asks for it.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export type RouteKind = 'native_plugin' | 'python_bridge' | 'mcp_server';
|
|
14
|
+
|
|
15
|
+
export type ServiceKind = 'http_api' | 'cli' | 'python_sdk' | 'mcp_only' | 'custom';
|
|
16
|
+
|
|
17
|
+
export type CapabilityName = 'workspace:read' | 'workspace:write' | 'network' | 'subprocess';
|
|
18
|
+
|
|
19
|
+
export interface ToolParameterSchema {
|
|
20
|
+
type: 'object';
|
|
21
|
+
properties?: Record<string, {
|
|
22
|
+
type?: string | undefined;
|
|
23
|
+
description?: string | undefined;
|
|
24
|
+
enum?: string[] | undefined;
|
|
25
|
+
default?: unknown;
|
|
26
|
+
items?: Record<string, unknown> | undefined;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}> | undefined;
|
|
29
|
+
required?: string[] | undefined;
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface ServiceToolDescriptor {
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
parameters: ToolParameterSchema;
|
|
37
|
+
httpMethod?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | undefined;
|
|
38
|
+
httpPath?: string | undefined;
|
|
39
|
+
cliSubcommand?: string | undefined;
|
|
40
|
+
pythonMethod?: string | undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ServiceDescriptor {
|
|
44
|
+
name: string;
|
|
45
|
+
description: string;
|
|
46
|
+
serviceKind: ServiceKind;
|
|
47
|
+
endpoint?: string | undefined;
|
|
48
|
+
authType?: 'none' | 'bearer' | 'apiKey' | 'basic' | 'env' | undefined;
|
|
49
|
+
authEnvVar?: string | undefined;
|
|
50
|
+
cliBinary?: string | undefined;
|
|
51
|
+
pythonModule?: string | undefined;
|
|
52
|
+
tools: ServiceToolDescriptor[];
|
|
53
|
+
capabilities?: CapabilityName[] | undefined;
|
|
54
|
+
userPreferredRoute?: RouteKind | undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface CostEstimate {
|
|
58
|
+
route: RouteKind;
|
|
59
|
+
estimatedSchemaTokens: number;
|
|
60
|
+
estimatedPerCallTokens: number;
|
|
61
|
+
isLongRunningProcess: boolean;
|
|
62
|
+
relativeCostMultiplier: number;
|
|
63
|
+
explanation: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface RouteCostComparison {
|
|
67
|
+
nativePlugin: CostEstimate;
|
|
68
|
+
pythonBridge: CostEstimate;
|
|
69
|
+
mcpServer: CostEstimate;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface FactoryRouteProposal {
|
|
73
|
+
service: ServiceDescriptor;
|
|
74
|
+
recommendedRoute: RouteKind;
|
|
75
|
+
reason: string;
|
|
76
|
+
costComparison: RouteCostComparison;
|
|
77
|
+
mcpDisclosure?: string | undefined;
|
|
78
|
+
userConsentRequired: boolean;
|
|
79
|
+
userConfirmedRoute?: RouteKind | undefined;
|
|
80
|
+
existingCapability?: {
|
|
81
|
+
covered: boolean;
|
|
82
|
+
source?: 'native_tool' | 'plugin' | 'mcp' | undefined;
|
|
83
|
+
matchName?: string | undefined;
|
|
84
|
+
details?: string | undefined;
|
|
85
|
+
} | undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface ScaffoldOptions {
|
|
89
|
+
force?: boolean | undefined;
|
|
90
|
+
baseDir?: string | undefined;
|
|
91
|
+
dryRun?: boolean | undefined;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface ScaffoldResult {
|
|
95
|
+
success: boolean;
|
|
96
|
+
route: RouteKind;
|
|
97
|
+
targetDirectory: string;
|
|
98
|
+
createdFiles: string[];
|
|
99
|
+
digest?: string | undefined;
|
|
100
|
+
instructions: string;
|
|
101
|
+
error?: string | undefined;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface PluginFactoryOptions {
|
|
105
|
+
pluginsDir?: string | undefined;
|
|
106
|
+
mcpServersDir?: string | undefined;
|
|
107
|
+
}
|
package/src/stallGuard.js
CHANGED
package/src/stallGuard.ts
CHANGED
package/src/toolPacks.js
CHANGED
package/src/toolPacks.ts
CHANGED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* plugins_factory Tool for Causyne Agent.
|
|
3
|
+
*
|
|
4
|
+
* Implements autonomous custom integration evaluation and scaffolding.
|
|
5
|
+
* Recommends token-lean native plugins or Python bridges, while fully respecting
|
|
6
|
+
* user choices if MCP is preferred.
|
|
7
|
+
*/
|
|
8
|
+
import { PluginsFactory } from '../pluginsFactory/index.js';
|
|
9
|
+
function normalizeServiceDescriptor(args) {
|
|
10
|
+
const tools = (args.tools || []).map((t, idx) => {
|
|
11
|
+
const tool = {
|
|
12
|
+
name: t.name || `tool_${idx + 1}`,
|
|
13
|
+
description: t.description || `Tool ${t.name || idx + 1}`,
|
|
14
|
+
parameters: (t.parameters && typeof t.parameters === 'object' && t.parameters.type === 'object')
|
|
15
|
+
? t.parameters
|
|
16
|
+
: { type: 'object', properties: {} }
|
|
17
|
+
};
|
|
18
|
+
if (t.httpMethod !== undefined)
|
|
19
|
+
tool.httpMethod = t.httpMethod;
|
|
20
|
+
if (t.httpPath !== undefined)
|
|
21
|
+
tool.httpPath = t.httpPath;
|
|
22
|
+
if (t.cliSubcommand !== undefined)
|
|
23
|
+
tool.cliSubcommand = t.cliSubcommand;
|
|
24
|
+
if (t.pythonMethod !== undefined)
|
|
25
|
+
tool.pythonMethod = t.pythonMethod;
|
|
26
|
+
return tool;
|
|
27
|
+
});
|
|
28
|
+
if (tools.length === 0) {
|
|
29
|
+
tools.push({
|
|
30
|
+
name: 'execute',
|
|
31
|
+
description: `Default execution method for ${args.serviceName}`,
|
|
32
|
+
parameters: { type: 'object', properties: {} }
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const desc = {
|
|
36
|
+
name: args.serviceName,
|
|
37
|
+
description: args.serviceDescription || `Custom integration for ${args.serviceName}`,
|
|
38
|
+
serviceKind: args.serviceKind || 'custom',
|
|
39
|
+
tools
|
|
40
|
+
};
|
|
41
|
+
if (args.endpoint !== undefined)
|
|
42
|
+
desc.endpoint = args.endpoint;
|
|
43
|
+
if (args.authType !== undefined)
|
|
44
|
+
desc.authType = args.authType;
|
|
45
|
+
if (args.authEnvVar !== undefined)
|
|
46
|
+
desc.authEnvVar = args.authEnvVar;
|
|
47
|
+
if (args.cliBinary !== undefined)
|
|
48
|
+
desc.cliBinary = args.cliBinary;
|
|
49
|
+
if (args.pythonModule !== undefined)
|
|
50
|
+
desc.pythonModule = args.pythonModule;
|
|
51
|
+
if (args.capabilities !== undefined)
|
|
52
|
+
desc.capabilities = args.capabilities;
|
|
53
|
+
if (args.userPreferredRoute !== undefined)
|
|
54
|
+
desc.userPreferredRoute = args.userPreferredRoute;
|
|
55
|
+
return desc;
|
|
56
|
+
}
|
|
57
|
+
export const pluginsFactoryTool = {
|
|
58
|
+
schema: {
|
|
59
|
+
name: 'plugins_factory',
|
|
60
|
+
description: 'Assess, compare token costs, and scaffold custom plugins, Python bridges, or MCP servers for external services or APIs that are not yet integrated into Causyne. Recommends the leanest, most economical route (Native Plugin or Python Bridge) while honoring user choice if MCP is preferred.',
|
|
61
|
+
parameters: {
|
|
62
|
+
type: 'object',
|
|
63
|
+
properties: {
|
|
64
|
+
action: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
enum: ['assess', 'estimate_cost', 'scaffold'],
|
|
67
|
+
description: 'Action: "assess" evaluates routes and returns proposal with token costs; "estimate_cost" returns detailed token footprint; "scaffold" creates the files in ~/.causyne/.'
|
|
68
|
+
},
|
|
69
|
+
serviceName: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
description: 'Name of the service or plugin (lowercase alphanumeric and hyphens, e.g. "notion-api", "blender-cycles").'
|
|
72
|
+
},
|
|
73
|
+
serviceDescription: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
description: 'Overview of what the external service does and why the integration is needed.'
|
|
76
|
+
},
|
|
77
|
+
serviceKind: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
enum: ['http_api', 'cli', 'python_sdk', 'mcp_only', 'custom'],
|
|
80
|
+
description: 'Nature of the target service.'
|
|
81
|
+
},
|
|
82
|
+
endpoint: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
description: 'Base URL for HTTP APIs (e.g. "https://api.github.com").'
|
|
85
|
+
},
|
|
86
|
+
authType: {
|
|
87
|
+
type: 'string',
|
|
88
|
+
enum: ['none', 'bearer', 'apiKey', 'basic', 'env'],
|
|
89
|
+
description: 'Authentication scheme.'
|
|
90
|
+
},
|
|
91
|
+
authEnvVar: {
|
|
92
|
+
type: 'string',
|
|
93
|
+
description: 'Environment variable name holding the API token (e.g. "NOTION_API_KEY").'
|
|
94
|
+
},
|
|
95
|
+
cliBinary: {
|
|
96
|
+
type: 'string',
|
|
97
|
+
description: 'Binary executable name for CLI plugins (e.g. "ffmpeg", "yt-dlp").'
|
|
98
|
+
},
|
|
99
|
+
pythonModule: {
|
|
100
|
+
type: 'string',
|
|
101
|
+
description: 'Python package/module name for Python bridges (e.g. "bpy", "torch").'
|
|
102
|
+
},
|
|
103
|
+
tools: {
|
|
104
|
+
type: 'array',
|
|
105
|
+
items: {
|
|
106
|
+
type: 'object',
|
|
107
|
+
properties: {
|
|
108
|
+
name: { type: 'string', description: 'Tool name' },
|
|
109
|
+
description: { type: 'string', description: 'What the tool does' },
|
|
110
|
+
parameters: { type: 'object', description: 'JSON schema for tool parameters' },
|
|
111
|
+
httpMethod: { type: 'string', enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'] },
|
|
112
|
+
httpPath: { type: 'string', description: 'HTTP relative path' },
|
|
113
|
+
cliSubcommand: { type: 'string', description: 'Subcommand for CLI tools' },
|
|
114
|
+
pythonMethod: { type: 'string', description: 'Method name in Python bridge' }
|
|
115
|
+
},
|
|
116
|
+
required: ['name', 'description']
|
|
117
|
+
},
|
|
118
|
+
description: 'List of tools to expose to the agent.'
|
|
119
|
+
},
|
|
120
|
+
capabilities: {
|
|
121
|
+
type: 'array',
|
|
122
|
+
items: {
|
|
123
|
+
type: 'string',
|
|
124
|
+
enum: ['workspace:read', 'workspace:write', 'network', 'subprocess']
|
|
125
|
+
},
|
|
126
|
+
description: 'Host sandbox permissions required.'
|
|
127
|
+
},
|
|
128
|
+
userPreferredRoute: {
|
|
129
|
+
type: 'string',
|
|
130
|
+
enum: ['native_plugin', 'python_bridge', 'mcp_server'],
|
|
131
|
+
description: 'Explicit user route preference (e.g. user insists on MCP).'
|
|
132
|
+
},
|
|
133
|
+
force: {
|
|
134
|
+
type: 'boolean',
|
|
135
|
+
description: 'Overwrite existing directory if present.'
|
|
136
|
+
},
|
|
137
|
+
dryRun: {
|
|
138
|
+
type: 'boolean',
|
|
139
|
+
description: 'Simulate scaffolding without writing files.'
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
required: ['action', 'serviceName']
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
async execute(args) {
|
|
146
|
+
try {
|
|
147
|
+
if (!args || !args.action || !args.serviceName) {
|
|
148
|
+
return {
|
|
149
|
+
success: false,
|
|
150
|
+
action: args?.action || 'unknown',
|
|
151
|
+
error: 'Missing required arguments: "action" and "serviceName" are required.'
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const factory = new PluginsFactory();
|
|
155
|
+
const service = normalizeServiceDescriptor(args);
|
|
156
|
+
const proposal = factory.assess(service, args.userPreferredRoute);
|
|
157
|
+
if (args.action === 'assess' || args.action === 'estimate_cost') {
|
|
158
|
+
const res = {
|
|
159
|
+
success: true,
|
|
160
|
+
action: args.action,
|
|
161
|
+
proposal,
|
|
162
|
+
message: [
|
|
163
|
+
`Assessment complete for service '${service.name}'.`,
|
|
164
|
+
`Recommended Route: ${proposal.recommendedRoute} (${proposal.reason})`,
|
|
165
|
+
proposal.mcpDisclosure ? `\n${proposal.mcpDisclosure}` : ''
|
|
166
|
+
].filter(Boolean).join('\n')
|
|
167
|
+
};
|
|
168
|
+
return res;
|
|
169
|
+
}
|
|
170
|
+
if (args.action === 'scaffold') {
|
|
171
|
+
const scaffoldOpts = {};
|
|
172
|
+
if (args.force !== undefined)
|
|
173
|
+
scaffoldOpts.force = args.force;
|
|
174
|
+
if (args.dryRun !== undefined)
|
|
175
|
+
scaffoldOpts.dryRun = args.dryRun;
|
|
176
|
+
const scaffoldResult = await factory.scaffold(proposal, scaffoldOpts);
|
|
177
|
+
const res = {
|
|
178
|
+
success: scaffoldResult.success,
|
|
179
|
+
action: 'scaffold',
|
|
180
|
+
proposal,
|
|
181
|
+
scaffoldResult,
|
|
182
|
+
message: scaffoldResult.instructions
|
|
183
|
+
};
|
|
184
|
+
if (scaffoldResult.error !== undefined)
|
|
185
|
+
res.error = scaffoldResult.error;
|
|
186
|
+
return res;
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
success: false,
|
|
190
|
+
action: args.action,
|
|
191
|
+
error: `Unrecognized action: "${args.action}". Allowed: assess, estimate_cost, scaffold`
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
catch (err) {
|
|
195
|
+
return {
|
|
196
|
+
success: false,
|
|
197
|
+
action: args?.action || 'execute',
|
|
198
|
+
error: err instanceof Error ? err.message : String(err)
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
};
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* plugins_factory Tool for Causyne Agent.
|
|
3
|
+
*
|
|
4
|
+
* Implements autonomous custom integration evaluation and scaffolding.
|
|
5
|
+
* Recommends token-lean native plugins or Python bridges, while fully respecting
|
|
6
|
+
* user choices if MCP is preferred.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
PluginsFactory,
|
|
11
|
+
type FactoryRouteProposal,
|
|
12
|
+
type RouteKind,
|
|
13
|
+
type ScaffoldOptions,
|
|
14
|
+
type ScaffoldResult,
|
|
15
|
+
type ServiceDescriptor,
|
|
16
|
+
type ServiceKind,
|
|
17
|
+
type ServiceToolDescriptor
|
|
18
|
+
} from '../pluginsFactory/index.js';
|
|
19
|
+
|
|
20
|
+
export interface PluginsFactoryArgs {
|
|
21
|
+
action: 'assess' | 'estimate_cost' | 'scaffold';
|
|
22
|
+
serviceName: string;
|
|
23
|
+
serviceDescription?: string | undefined;
|
|
24
|
+
serviceKind?: ServiceKind | undefined;
|
|
25
|
+
endpoint?: string | undefined;
|
|
26
|
+
authType?: 'none' | 'bearer' | 'apiKey' | 'basic' | 'env' | undefined;
|
|
27
|
+
authEnvVar?: string | undefined;
|
|
28
|
+
cliBinary?: string | undefined;
|
|
29
|
+
pythonModule?: string | undefined;
|
|
30
|
+
tools?: Array<{
|
|
31
|
+
name: string;
|
|
32
|
+
description: string;
|
|
33
|
+
parameters?: Record<string, unknown> | undefined;
|
|
34
|
+
httpMethod?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | undefined;
|
|
35
|
+
httpPath?: string | undefined;
|
|
36
|
+
cliSubcommand?: string | undefined;
|
|
37
|
+
pythonMethod?: string | undefined;
|
|
38
|
+
}> | undefined;
|
|
39
|
+
capabilities?: Array<'workspace:read' | 'workspace:write' | 'network' | 'subprocess'> | undefined;
|
|
40
|
+
userPreferredRoute?: RouteKind | undefined;
|
|
41
|
+
force?: boolean | undefined;
|
|
42
|
+
dryRun?: boolean | undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface PluginsFactoryToolResult {
|
|
46
|
+
success: boolean;
|
|
47
|
+
action: string;
|
|
48
|
+
proposal?: FactoryRouteProposal | undefined;
|
|
49
|
+
scaffoldResult?: ScaffoldResult | undefined;
|
|
50
|
+
message?: string | undefined;
|
|
51
|
+
error?: string | undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function normalizeServiceDescriptor(args: PluginsFactoryArgs): ServiceDescriptor {
|
|
55
|
+
const tools: ServiceToolDescriptor[] = (args.tools || []).map((t, idx) => {
|
|
56
|
+
const tool: ServiceToolDescriptor = {
|
|
57
|
+
name: t.name || `tool_${idx + 1}`,
|
|
58
|
+
description: t.description || `Tool ${t.name || idx + 1}`,
|
|
59
|
+
parameters: (t.parameters && typeof t.parameters === 'object' && t.parameters.type === 'object')
|
|
60
|
+
? (t.parameters as ServiceToolDescriptor['parameters'])
|
|
61
|
+
: { type: 'object', properties: {} }
|
|
62
|
+
};
|
|
63
|
+
if (t.httpMethod !== undefined) tool.httpMethod = t.httpMethod;
|
|
64
|
+
if (t.httpPath !== undefined) tool.httpPath = t.httpPath;
|
|
65
|
+
if (t.cliSubcommand !== undefined) tool.cliSubcommand = t.cliSubcommand;
|
|
66
|
+
if (t.pythonMethod !== undefined) tool.pythonMethod = t.pythonMethod;
|
|
67
|
+
return tool;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (tools.length === 0) {
|
|
71
|
+
tools.push({
|
|
72
|
+
name: 'execute',
|
|
73
|
+
description: `Default execution method for ${args.serviceName}`,
|
|
74
|
+
parameters: { type: 'object', properties: {} }
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const desc: ServiceDescriptor = {
|
|
79
|
+
name: args.serviceName,
|
|
80
|
+
description: args.serviceDescription || `Custom integration for ${args.serviceName}`,
|
|
81
|
+
serviceKind: args.serviceKind || 'custom',
|
|
82
|
+
tools
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
if (args.endpoint !== undefined) desc.endpoint = args.endpoint;
|
|
86
|
+
if (args.authType !== undefined) desc.authType = args.authType;
|
|
87
|
+
if (args.authEnvVar !== undefined) desc.authEnvVar = args.authEnvVar;
|
|
88
|
+
if (args.cliBinary !== undefined) desc.cliBinary = args.cliBinary;
|
|
89
|
+
if (args.pythonModule !== undefined) desc.pythonModule = args.pythonModule;
|
|
90
|
+
if (args.capabilities !== undefined) desc.capabilities = args.capabilities;
|
|
91
|
+
if (args.userPreferredRoute !== undefined) desc.userPreferredRoute = args.userPreferredRoute;
|
|
92
|
+
|
|
93
|
+
return desc;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export const pluginsFactoryTool = {
|
|
97
|
+
schema: {
|
|
98
|
+
name: 'plugins_factory',
|
|
99
|
+
description:
|
|
100
|
+
'Assess, compare token costs, and scaffold custom plugins, Python bridges, or MCP servers for external services or APIs that are not yet integrated into Causyne. Recommends the leanest, most economical route (Native Plugin or Python Bridge) while honoring user choice if MCP is preferred.',
|
|
101
|
+
parameters: {
|
|
102
|
+
type: 'object',
|
|
103
|
+
properties: {
|
|
104
|
+
action: {
|
|
105
|
+
type: 'string',
|
|
106
|
+
enum: ['assess', 'estimate_cost', 'scaffold'],
|
|
107
|
+
description:
|
|
108
|
+
'Action: "assess" evaluates routes and returns proposal with token costs; "estimate_cost" returns detailed token footprint; "scaffold" creates the files in ~/.causyne/.'
|
|
109
|
+
},
|
|
110
|
+
serviceName: {
|
|
111
|
+
type: 'string',
|
|
112
|
+
description: 'Name of the service or plugin (lowercase alphanumeric and hyphens, e.g. "notion-api", "blender-cycles").'
|
|
113
|
+
},
|
|
114
|
+
serviceDescription: {
|
|
115
|
+
type: 'string',
|
|
116
|
+
description: 'Overview of what the external service does and why the integration is needed.'
|
|
117
|
+
},
|
|
118
|
+
serviceKind: {
|
|
119
|
+
type: 'string',
|
|
120
|
+
enum: ['http_api', 'cli', 'python_sdk', 'mcp_only', 'custom'],
|
|
121
|
+
description: 'Nature of the target service.'
|
|
122
|
+
},
|
|
123
|
+
endpoint: {
|
|
124
|
+
type: 'string',
|
|
125
|
+
description: 'Base URL for HTTP APIs (e.g. "https://api.github.com").'
|
|
126
|
+
},
|
|
127
|
+
authType: {
|
|
128
|
+
type: 'string',
|
|
129
|
+
enum: ['none', 'bearer', 'apiKey', 'basic', 'env'],
|
|
130
|
+
description: 'Authentication scheme.'
|
|
131
|
+
},
|
|
132
|
+
authEnvVar: {
|
|
133
|
+
type: 'string',
|
|
134
|
+
description: 'Environment variable name holding the API token (e.g. "NOTION_API_KEY").'
|
|
135
|
+
},
|
|
136
|
+
cliBinary: {
|
|
137
|
+
type: 'string',
|
|
138
|
+
description: 'Binary executable name for CLI plugins (e.g. "ffmpeg", "yt-dlp").'
|
|
139
|
+
},
|
|
140
|
+
pythonModule: {
|
|
141
|
+
type: 'string',
|
|
142
|
+
description: 'Python package/module name for Python bridges (e.g. "bpy", "torch").'
|
|
143
|
+
},
|
|
144
|
+
tools: {
|
|
145
|
+
type: 'array',
|
|
146
|
+
items: {
|
|
147
|
+
type: 'object',
|
|
148
|
+
properties: {
|
|
149
|
+
name: { type: 'string', description: 'Tool name' },
|
|
150
|
+
description: { type: 'string', description: 'What the tool does' },
|
|
151
|
+
parameters: { type: 'object', description: 'JSON schema for tool parameters' },
|
|
152
|
+
httpMethod: { type: 'string', enum: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'] },
|
|
153
|
+
httpPath: { type: 'string', description: 'HTTP relative path' },
|
|
154
|
+
cliSubcommand: { type: 'string', description: 'Subcommand for CLI tools' },
|
|
155
|
+
pythonMethod: { type: 'string', description: 'Method name in Python bridge' }
|
|
156
|
+
},
|
|
157
|
+
required: ['name', 'description']
|
|
158
|
+
},
|
|
159
|
+
description: 'List of tools to expose to the agent.'
|
|
160
|
+
},
|
|
161
|
+
capabilities: {
|
|
162
|
+
type: 'array',
|
|
163
|
+
items: {
|
|
164
|
+
type: 'string',
|
|
165
|
+
enum: ['workspace:read', 'workspace:write', 'network', 'subprocess']
|
|
166
|
+
},
|
|
167
|
+
description: 'Host sandbox permissions required.'
|
|
168
|
+
},
|
|
169
|
+
userPreferredRoute: {
|
|
170
|
+
type: 'string',
|
|
171
|
+
enum: ['native_plugin', 'python_bridge', 'mcp_server'],
|
|
172
|
+
description: 'Explicit user route preference (e.g. user insists on MCP).'
|
|
173
|
+
},
|
|
174
|
+
force: {
|
|
175
|
+
type: 'boolean',
|
|
176
|
+
description: 'Overwrite existing directory if present.'
|
|
177
|
+
},
|
|
178
|
+
dryRun: {
|
|
179
|
+
type: 'boolean',
|
|
180
|
+
description: 'Simulate scaffolding without writing files.'
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
required: ['action', 'serviceName']
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
async execute(args: PluginsFactoryArgs): Promise<PluginsFactoryToolResult> {
|
|
188
|
+
try {
|
|
189
|
+
if (!args || !args.action || !args.serviceName) {
|
|
190
|
+
return {
|
|
191
|
+
success: false,
|
|
192
|
+
action: args?.action || 'unknown',
|
|
193
|
+
error: 'Missing required arguments: "action" and "serviceName" are required.'
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const factory = new PluginsFactory();
|
|
198
|
+
const service = normalizeServiceDescriptor(args);
|
|
199
|
+
const proposal = factory.assess(service, args.userPreferredRoute);
|
|
200
|
+
|
|
201
|
+
if (args.action === 'assess' || args.action === 'estimate_cost') {
|
|
202
|
+
const res: PluginsFactoryToolResult = {
|
|
203
|
+
success: true,
|
|
204
|
+
action: args.action,
|
|
205
|
+
proposal,
|
|
206
|
+
message: [
|
|
207
|
+
`Assessment complete for service '${service.name}'.`,
|
|
208
|
+
`Recommended Route: ${proposal.recommendedRoute} (${proposal.reason})`,
|
|
209
|
+
proposal.mcpDisclosure ? `\n${proposal.mcpDisclosure}` : ''
|
|
210
|
+
].filter(Boolean).join('\n')
|
|
211
|
+
};
|
|
212
|
+
return res;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (args.action === 'scaffold') {
|
|
216
|
+
const scaffoldOpts: ScaffoldOptions = {};
|
|
217
|
+
if (args.force !== undefined) scaffoldOpts.force = args.force;
|
|
218
|
+
if (args.dryRun !== undefined) scaffoldOpts.dryRun = args.dryRun;
|
|
219
|
+
|
|
220
|
+
const scaffoldResult = await factory.scaffold(proposal, scaffoldOpts);
|
|
221
|
+
|
|
222
|
+
const res: PluginsFactoryToolResult = {
|
|
223
|
+
success: scaffoldResult.success,
|
|
224
|
+
action: 'scaffold',
|
|
225
|
+
proposal,
|
|
226
|
+
scaffoldResult,
|
|
227
|
+
message: scaffoldResult.instructions
|
|
228
|
+
};
|
|
229
|
+
if (scaffoldResult.error !== undefined) res.error = scaffoldResult.error;
|
|
230
|
+
return res;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return {
|
|
234
|
+
success: false,
|
|
235
|
+
action: args.action,
|
|
236
|
+
error: `Unrecognized action: "${args.action}". Allowed: assess, estimate_cost, scaffold`
|
|
237
|
+
};
|
|
238
|
+
} catch (err) {
|
|
239
|
+
return {
|
|
240
|
+
success: false,
|
|
241
|
+
action: args?.action || 'execute',
|
|
242
|
+
error: err instanceof Error ? err.message : String(err)
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
};
|
package/src/tools/registry.js
CHANGED
|
@@ -44,6 +44,7 @@ import { memoryRecall } from './memoryRecall.js';
|
|
|
44
44
|
import { printerPrint, printerList, printerStatus } from './printer.js';
|
|
45
45
|
import { toolForgeTool } from './toolForge.js';
|
|
46
46
|
import { pluginManagerTool } from './pluginManager.js';
|
|
47
|
+
import { pluginsFactoryTool } from './pluginsFactory.js';
|
|
47
48
|
import { astryxOracle } from './astryxOracle.js';
|
|
48
49
|
import { pdfRead } from './pdfReader.js';
|
|
49
50
|
import { codeVerifySyntax, codeListSymbols } from './codeTools.js';
|
|
@@ -120,7 +121,7 @@ const TOOL_MODULES = [
|
|
|
120
121
|
codebaseSearch, browserAct, viewImage, webSearch,
|
|
121
122
|
updatePlan, requestDecision, clipboard, screenshot, axSnapshot, desktopAct, archive,
|
|
122
123
|
checkSystemSpecs, executeProceduralMedia, manageLocalAiDependencies,
|
|
123
|
-
generateMediaViaApi, memoryWrite, memoryRecall, printerPrint, printerList, printerStatus, toolForgeTool, pluginManagerTool,
|
|
124
|
+
generateMediaViaApi, memoryWrite, memoryRecall, printerPrint, printerList, printerStatus, toolForgeTool, pluginManagerTool, pluginsFactoryTool,
|
|
124
125
|
astryxOracle, pdfRead, codeVerifySyntax, codeListSymbols, blenderAct, resolveAutomator, palmierAutomator,
|
|
125
126
|
codeSearchAst, codeSearcher, persistentShell, subagentOrchestrator, deferredMcpSearch, visionInspector,
|
|
126
127
|
godotAutomator, gameBuilder, gameAssetFetcher,
|
package/src/toolsList.js
CHANGED
|
@@ -84,6 +84,7 @@ const CATALOGUE = {
|
|
|
84
84
|
advanced: {
|
|
85
85
|
tool_forge: 'create a custom tool',
|
|
86
86
|
plugin_manager: 'manage plugins',
|
|
87
|
+
plugins_factory: 'assess and scaffold custom plugins or Python bridges',
|
|
87
88
|
pdf_read: 'read PDF text',
|
|
88
89
|
code_list_symbols: 'list symbols in a file',
|
|
89
90
|
code_search_ast: 'AST definition search',
|
package/src/toolsList.ts
CHANGED
|
@@ -98,6 +98,7 @@ const CATALOGUE: Readonly<Record<Exclude<ToolGroup, 'custom'>, Readonly<Record<s
|
|
|
98
98
|
advanced: {
|
|
99
99
|
tool_forge: 'create a custom tool',
|
|
100
100
|
plugin_manager: 'manage plugins',
|
|
101
|
+
plugins_factory: 'assess and scaffold custom plugins or Python bridges',
|
|
101
102
|
pdf_read: 'read PDF text',
|
|
102
103
|
code_list_symbols: 'list symbols in a file',
|
|
103
104
|
code_search_ast: 'AST definition search',
|