50c 1.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -235
- package/bin/50c.js +210 -258
- package/lib/config.js +185 -0
- package/lib/core/tools.js +107 -0
- package/lib/index.js +166 -0
- package/lib/packs/beacon.js +224 -0
- package/lib/packs/cf.js +156 -0
- package/lib/packs/labs.js +188 -0
- package/lib/packs/labs_plus.js +246 -0
- package/lib/packs/ux.js +76 -0
- package/lib/packs/whm.js +228 -0
- package/lib/packs/wp.js +82 -0
- package/lib/packs.js +406 -0
- package/lib/vault.js +354 -0
- package/package.json +25 -11
- package/LICENSE +0 -31
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 50c Core Tools - Always Free
|
|
3
|
+
* search, fetch, domain_check, balance
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const https = require('https');
|
|
7
|
+
const http = require('http');
|
|
8
|
+
const { apiRequest } = require('../config');
|
|
9
|
+
|
|
10
|
+
// Web Search
|
|
11
|
+
async function webSearch(query, options = {}) {
|
|
12
|
+
return apiRequest('POST', '/tools/web_search', {
|
|
13
|
+
query,
|
|
14
|
+
max_results: options.max_results || 5
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Page Fetch
|
|
19
|
+
async function pageFetch(url, query = '') {
|
|
20
|
+
return apiRequest('POST', '/tools/page_fetch', { url, query });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Domain Check
|
|
24
|
+
async function domainCheck(domain) {
|
|
25
|
+
return apiRequest('POST', '/tools/domain_check', { domain });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Check Balance
|
|
29
|
+
async function checkBalance() {
|
|
30
|
+
return apiRequest('GET', '/user/balance');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Tool definitions
|
|
34
|
+
const CORE_TOOLS = [
|
|
35
|
+
{
|
|
36
|
+
name: 'web_search',
|
|
37
|
+
description: 'Search the internet. FREE.',
|
|
38
|
+
inputSchema: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {
|
|
41
|
+
query: { type: 'string', description: 'Search query' },
|
|
42
|
+
max_results: { type: 'number', default: 5 }
|
|
43
|
+
},
|
|
44
|
+
required: ['query']
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'page_fetch',
|
|
49
|
+
description: 'Fetch and extract content from URL. FREE.',
|
|
50
|
+
inputSchema: {
|
|
51
|
+
type: 'object',
|
|
52
|
+
properties: {
|
|
53
|
+
url: { type: 'string', description: 'URL to fetch' },
|
|
54
|
+
query: { type: 'string', description: 'Optional: question about the page' }
|
|
55
|
+
},
|
|
56
|
+
required: ['url']
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'domain_check',
|
|
61
|
+
description: 'Check domain availability. FREE.',
|
|
62
|
+
inputSchema: {
|
|
63
|
+
type: 'object',
|
|
64
|
+
properties: {
|
|
65
|
+
domain: { type: 'string', description: 'Domain to check (e.g., example.com)' }
|
|
66
|
+
},
|
|
67
|
+
required: ['domain']
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'check_balance',
|
|
72
|
+
description: 'Check your credit balance. FREE.',
|
|
73
|
+
inputSchema: {
|
|
74
|
+
type: 'object',
|
|
75
|
+
properties: {}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
// Handle core tool calls
|
|
81
|
+
async function handleTool(name, args) {
|
|
82
|
+
try {
|
|
83
|
+
switch (name) {
|
|
84
|
+
case 'web_search':
|
|
85
|
+
return await webSearch(args.query, args);
|
|
86
|
+
case 'page_fetch':
|
|
87
|
+
return await pageFetch(args.url, args.query);
|
|
88
|
+
case 'domain_check':
|
|
89
|
+
return await domainCheck(args.domain);
|
|
90
|
+
case 'check_balance':
|
|
91
|
+
return await checkBalance();
|
|
92
|
+
default:
|
|
93
|
+
return { error: `Unknown core tool: ${name}` };
|
|
94
|
+
}
|
|
95
|
+
} catch (e) {
|
|
96
|
+
return { error: e.message };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
module.exports = {
|
|
101
|
+
CORE_TOOLS,
|
|
102
|
+
handleTool,
|
|
103
|
+
webSearch,
|
|
104
|
+
pageFetch,
|
|
105
|
+
domainCheck,
|
|
106
|
+
checkBalance
|
|
107
|
+
};
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 50c - The AI Toolkit
|
|
3
|
+
* One package, all tools, works everywhere
|
|
4
|
+
*
|
|
5
|
+
* TIER ACCESS:
|
|
6
|
+
* FREE ($0) - core, vault
|
|
7
|
+
* STARTER ($29) - beacon (hints, roast, vibe, naming)
|
|
8
|
+
* PRO ($99) - labs (genius, bcalc, context), cf, wp, ux
|
|
9
|
+
* ENTERPRISE ($499) - labs_plus (genius_plus, CVI, chaos), whm
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const { MODE, loadConfig } = require('./config');
|
|
13
|
+
const vault = require('./vault');
|
|
14
|
+
const core = require('./core/tools');
|
|
15
|
+
const packs = require('./packs');
|
|
16
|
+
|
|
17
|
+
// Import pack tools
|
|
18
|
+
const beacon = require('./packs/beacon');
|
|
19
|
+
const labs = require('./packs/labs');
|
|
20
|
+
const labsPlus = require('./packs/labs_plus');
|
|
21
|
+
const whm = require('./packs/whm');
|
|
22
|
+
const cf = require('./packs/cf');
|
|
23
|
+
const wp = require('./packs/wp');
|
|
24
|
+
const ux = require('./packs/ux');
|
|
25
|
+
|
|
26
|
+
// Tool name mappings by pack
|
|
27
|
+
const TOOL_PACKS = {
|
|
28
|
+
beacon: ['hints', 'hints_plus', 'roast', 'quick_vibe', 'one_liner', 'name_it', 'price_it', 'compute', 'ide_conversation', 'learning_stats'],
|
|
29
|
+
labs: ['genius', 'mind_opener', 'idea_fold', 'bcalc', 'context_health', 'context_compress', 'context_extract', 'context_reposition'],
|
|
30
|
+
labs_plus: ['genius_plus', 'bcalc_why', 'discovery_collision', 'cvi_loop', 'cvi_verify', 'chaos_fingerprint', 'resonance', 'prime_residue', 'echo_sequence', 'conversation_diagnostic', 'handoff']
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Get all available tools based on enabled packs
|
|
34
|
+
async function getTools() {
|
|
35
|
+
const config = await loadConfig();
|
|
36
|
+
|
|
37
|
+
const tools = [
|
|
38
|
+
// Always available (FREE tier)
|
|
39
|
+
...core.CORE_TOOLS,
|
|
40
|
+
...vault.VAULT_TOOLS,
|
|
41
|
+
...packs.PACK_TOOLS,
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
// STARTER tier
|
|
45
|
+
if (config.packs.beacon) tools.push(...beacon.BEACON_TOOLS);
|
|
46
|
+
|
|
47
|
+
// PRO tier
|
|
48
|
+
if (config.packs.labs) tools.push(...labs.LABS_TOOLS);
|
|
49
|
+
if (config.packs.cf) tools.push(...cf.CF_TOOLS);
|
|
50
|
+
if (config.packs.wp) tools.push(...wp.WP_TOOLS);
|
|
51
|
+
if (config.packs.ux) tools.push(...ux.UX_TOOLS);
|
|
52
|
+
|
|
53
|
+
// ENTERPRISE tier
|
|
54
|
+
if (config.packs.labs_plus) tools.push(...labsPlus.LABS_PLUS_TOOLS);
|
|
55
|
+
if (config.packs.whm) tools.push(...whm.WHM_TOOLS);
|
|
56
|
+
|
|
57
|
+
return tools;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Route tool calls to appropriate handler
|
|
61
|
+
async function handleTool(name, args = {}) {
|
|
62
|
+
const config = await loadConfig();
|
|
63
|
+
|
|
64
|
+
// Core tools (FREE)
|
|
65
|
+
if (['web_search', 'page_fetch', 'domain_check', 'check_balance'].includes(name)) {
|
|
66
|
+
return core.handleTool(name, args);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Vault tools (FREE)
|
|
70
|
+
if (name.startsWith('vault_')) {
|
|
71
|
+
return vault.handleTool(name, args);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Pack management tools (FREE)
|
|
75
|
+
if (name.startsWith('50c_')) {
|
|
76
|
+
return packs.handleTool(name, args);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Beacon tools (STARTER)
|
|
80
|
+
if (TOOL_PACKS.beacon.includes(name)) {
|
|
81
|
+
if (!config.packs.beacon) {
|
|
82
|
+
return { error: 'Requires Starter tier ($29/mo). Enable beacon pack or upgrade at sales.50c.ai/50c-starter/' };
|
|
83
|
+
}
|
|
84
|
+
return beacon.handleTool(name, args);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Labs tools (PRO)
|
|
88
|
+
if (TOOL_PACKS.labs.includes(name)) {
|
|
89
|
+
if (!config.packs.labs) {
|
|
90
|
+
return { error: 'Requires Pro tier ($99/mo). Enable labs pack or upgrade at sales.50c.ai/50c-pro/' };
|
|
91
|
+
}
|
|
92
|
+
return labs.handleTool(name, args);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Labs+ tools (ENTERPRISE)
|
|
96
|
+
if (TOOL_PACKS.labs_plus.includes(name)) {
|
|
97
|
+
if (!config.packs.labs_plus) {
|
|
98
|
+
return { error: 'Requires Enterprise tier ($499/mo). Upgrade at sales.50c.ai/50c-enterprise/' };
|
|
99
|
+
}
|
|
100
|
+
return labsPlus.handleTool(name, args);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// WHM tools (ENTERPRISE)
|
|
104
|
+
if (name.startsWith('whm_') || name.startsWith('cp_') || name.startsWith('ssh_')) {
|
|
105
|
+
if (!config.packs.whm) {
|
|
106
|
+
return { error: 'Requires Enterprise tier ($499/mo). Upgrade at sales.50c.ai/50c-enterprise/' };
|
|
107
|
+
}
|
|
108
|
+
return whm.handleTool(name, args);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Cloudflare tools (PRO)
|
|
112
|
+
if (name.startsWith('cf_')) {
|
|
113
|
+
if (!config.packs.cf) {
|
|
114
|
+
return { error: 'Requires Pro tier ($99/mo). Enable cf pack or upgrade at sales.50c.ai/50c-pro/' };
|
|
115
|
+
}
|
|
116
|
+
return cf.handleTool(name, args);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// WordPress tools (PRO)
|
|
120
|
+
if (name.startsWith('wp_')) {
|
|
121
|
+
if (!config.packs.wp) {
|
|
122
|
+
return { error: 'Requires Pro tier ($99/mo). Enable wp pack or upgrade at sales.50c.ai/50c-pro/' };
|
|
123
|
+
}
|
|
124
|
+
return wp.handleTool(name, args);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// UX tools (PRO)
|
|
128
|
+
if (name.startsWith('ux_')) {
|
|
129
|
+
if (!config.packs.ux) {
|
|
130
|
+
return { error: 'Requires Pro tier ($99/mo). Enable ux pack or upgrade at sales.50c.ai/50c-pro/' };
|
|
131
|
+
}
|
|
132
|
+
return ux.handleTool(name, args);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return { error: `Unknown tool: ${name}` };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Get status with tier info
|
|
139
|
+
async function getStatus() {
|
|
140
|
+
const config = await loadConfig();
|
|
141
|
+
const tools = await getTools();
|
|
142
|
+
const userTier = config.tier || 'free';
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
mode: MODE,
|
|
146
|
+
tier: userTier,
|
|
147
|
+
api_key_set: !!process.env.FIFTY_CENT_API_KEY,
|
|
148
|
+
packs: config.packs,
|
|
149
|
+
total_tools: tools.length,
|
|
150
|
+
vault: await vault.status(),
|
|
151
|
+
tiers: packs.TIERS
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
module.exports = {
|
|
156
|
+
MODE,
|
|
157
|
+
getTools,
|
|
158
|
+
handleTool,
|
|
159
|
+
getStatus,
|
|
160
|
+
loadConfig,
|
|
161
|
+
vault,
|
|
162
|
+
packs,
|
|
163
|
+
beacon,
|
|
164
|
+
labs,
|
|
165
|
+
labsPlus
|
|
166
|
+
};
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 50c Beacon Pack - Consumer Tier Tools
|
|
3
|
+
* hints, roast, vibe, name_it, price_it, one_liner, compute
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const { apiRequest } = require('../config');
|
|
7
|
+
|
|
8
|
+
// Tool implementations
|
|
9
|
+
async function hints(query) {
|
|
10
|
+
return apiRequest('POST', '/tools/hints', { query });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function hintsPlus(query) {
|
|
14
|
+
return apiRequest('POST', '/tools/hints_plus', { query });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function roast(code) {
|
|
18
|
+
return apiRequest('POST', '/tools/roast', { code });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function quickVibe(working_on) {
|
|
22
|
+
return apiRequest('POST', '/tools/quick_vibe', { working_on });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function oneLiner(product) {
|
|
26
|
+
return apiRequest('POST', '/tools/one_liner', { product });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function nameIt(does) {
|
|
30
|
+
return apiRequest('POST', '/tools/name_it', { does });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function priceIt(product) {
|
|
34
|
+
return apiRequest('POST', '/tools/price_it', { product });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function compute(code) {
|
|
38
|
+
return apiRequest('POST', '/tools/compute', { code });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function ideConversation(session_id, message, mode = 'chat') {
|
|
42
|
+
return apiRequest('POST', '/tools/ide_conversation', { session_id, message, mode });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function learningStats() {
|
|
46
|
+
return apiRequest('GET', '/tools/learning_stats');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Tool definitions - STARTER tier ($29/mo)
|
|
50
|
+
const BEACON_TOOLS = [
|
|
51
|
+
{
|
|
52
|
+
name: 'hints',
|
|
53
|
+
description: '5 brutal hints, 2 words each. $0.05',
|
|
54
|
+
inputSchema: {
|
|
55
|
+
type: 'object',
|
|
56
|
+
properties: {
|
|
57
|
+
query: { type: 'string', description: 'What you need hints about' }
|
|
58
|
+
},
|
|
59
|
+
required: ['query']
|
|
60
|
+
},
|
|
61
|
+
cost: 0.05,
|
|
62
|
+
tier: 'starter'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'hints_plus',
|
|
66
|
+
description: '10 brutal hints, 4 words each. $0.10',
|
|
67
|
+
inputSchema: {
|
|
68
|
+
type: 'object',
|
|
69
|
+
properties: {
|
|
70
|
+
query: { type: 'string', description: 'What you need hints about' }
|
|
71
|
+
},
|
|
72
|
+
required: ['query']
|
|
73
|
+
},
|
|
74
|
+
cost: 0.10,
|
|
75
|
+
tier: 'starter'
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'roast',
|
|
79
|
+
description: 'Brutal code review. 3 flaws + fixes. $0.05',
|
|
80
|
+
inputSchema: {
|
|
81
|
+
type: 'object',
|
|
82
|
+
properties: {
|
|
83
|
+
code: { type: 'string', description: 'Code to roast' }
|
|
84
|
+
},
|
|
85
|
+
required: ['code']
|
|
86
|
+
},
|
|
87
|
+
cost: 0.05,
|
|
88
|
+
tier: 'starter'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'quick_vibe',
|
|
92
|
+
description: '3 unconventional ideas. $0.05',
|
|
93
|
+
inputSchema: {
|
|
94
|
+
type: 'object',
|
|
95
|
+
properties: {
|
|
96
|
+
working_on: { type: 'string', description: 'What you\'re working on' }
|
|
97
|
+
},
|
|
98
|
+
required: ['working_on']
|
|
99
|
+
},
|
|
100
|
+
cost: 0.05,
|
|
101
|
+
tier: 'starter'
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: 'one_liner',
|
|
105
|
+
description: 'Elevator pitch in 8 words. $0.02',
|
|
106
|
+
inputSchema: {
|
|
107
|
+
type: 'object',
|
|
108
|
+
properties: {
|
|
109
|
+
product: { type: 'string', description: 'Product to pitch' }
|
|
110
|
+
},
|
|
111
|
+
required: ['product']
|
|
112
|
+
},
|
|
113
|
+
cost: 0.02,
|
|
114
|
+
tier: 'starter'
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'name_it',
|
|
118
|
+
description: '5 names + domain availability. $0.03',
|
|
119
|
+
inputSchema: {
|
|
120
|
+
type: 'object',
|
|
121
|
+
properties: {
|
|
122
|
+
does: { type: 'string', description: 'What your product does' }
|
|
123
|
+
},
|
|
124
|
+
required: ['does']
|
|
125
|
+
},
|
|
126
|
+
cost: 0.03,
|
|
127
|
+
tier: 'starter'
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'price_it',
|
|
131
|
+
description: 'SaaS pricing strategy. $0.05',
|
|
132
|
+
inputSchema: {
|
|
133
|
+
type: 'object',
|
|
134
|
+
properties: {
|
|
135
|
+
product: { type: 'string', description: 'Product to price' }
|
|
136
|
+
},
|
|
137
|
+
required: ['product']
|
|
138
|
+
},
|
|
139
|
+
cost: 0.05,
|
|
140
|
+
tier: 'starter'
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'compute',
|
|
144
|
+
description: 'Execute Python code. $0.02. Sandboxed, 10s timeout.',
|
|
145
|
+
inputSchema: {
|
|
146
|
+
type: 'object',
|
|
147
|
+
properties: {
|
|
148
|
+
code: { type: 'string', description: 'Python code to execute' }
|
|
149
|
+
},
|
|
150
|
+
required: ['code']
|
|
151
|
+
},
|
|
152
|
+
cost: 0.02,
|
|
153
|
+
tier: 'starter'
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: 'ide_conversation',
|
|
157
|
+
description: 'Multi-turn IDE chat. $0.20',
|
|
158
|
+
inputSchema: {
|
|
159
|
+
type: 'object',
|
|
160
|
+
properties: {
|
|
161
|
+
session_id: { type: 'string', description: 'Session ID for continuity' },
|
|
162
|
+
message: { type: 'string', description: 'Your message' },
|
|
163
|
+
mode: { type: 'string', enum: ['chat', 'pair_deep', 'pair_research'], default: 'chat' }
|
|
164
|
+
},
|
|
165
|
+
required: ['session_id', 'message']
|
|
166
|
+
},
|
|
167
|
+
cost: 0.20,
|
|
168
|
+
tier: 'starter'
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: 'learning_stats',
|
|
172
|
+
description: 'View AI learning progress. FREE.',
|
|
173
|
+
inputSchema: { type: 'object', properties: {} },
|
|
174
|
+
cost: 0,
|
|
175
|
+
tier: 'free'
|
|
176
|
+
}
|
|
177
|
+
];
|
|
178
|
+
|
|
179
|
+
// Handle tool calls
|
|
180
|
+
async function handleTool(name, args) {
|
|
181
|
+
try {
|
|
182
|
+
switch (name) {
|
|
183
|
+
case 'hints':
|
|
184
|
+
return await hints(args.query);
|
|
185
|
+
case 'hints_plus':
|
|
186
|
+
return await hintsPlus(args.query);
|
|
187
|
+
case 'roast':
|
|
188
|
+
return await roast(args.code);
|
|
189
|
+
case 'quick_vibe':
|
|
190
|
+
return await quickVibe(args.working_on);
|
|
191
|
+
case 'one_liner':
|
|
192
|
+
return await oneLiner(args.product);
|
|
193
|
+
case 'name_it':
|
|
194
|
+
return await nameIt(args.does);
|
|
195
|
+
case 'price_it':
|
|
196
|
+
return await priceIt(args.product);
|
|
197
|
+
case 'compute':
|
|
198
|
+
return await compute(args.code);
|
|
199
|
+
case 'ide_conversation':
|
|
200
|
+
return await ideConversation(args.session_id, args.message, args.mode);
|
|
201
|
+
case 'learning_stats':
|
|
202
|
+
return await learningStats();
|
|
203
|
+
default:
|
|
204
|
+
return { error: `Unknown beacon tool: ${name}` };
|
|
205
|
+
}
|
|
206
|
+
} catch (e) {
|
|
207
|
+
return { error: e.message };
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
module.exports = {
|
|
212
|
+
BEACON_TOOLS,
|
|
213
|
+
handleTool,
|
|
214
|
+
hints,
|
|
215
|
+
hintsPlus,
|
|
216
|
+
roast,
|
|
217
|
+
quickVibe,
|
|
218
|
+
oneLiner,
|
|
219
|
+
nameIt,
|
|
220
|
+
priceIt,
|
|
221
|
+
compute,
|
|
222
|
+
ideConversation,
|
|
223
|
+
learningStats
|
|
224
|
+
};
|
package/lib/packs/cf.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 50c CF Pack - Cloudflare Automation
|
|
3
|
+
* 34 tools for edge to origin control
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const https = require('https');
|
|
7
|
+
const vault = require('../vault');
|
|
8
|
+
|
|
9
|
+
// Get credentials from vault or env
|
|
10
|
+
async function getCFToken() {
|
|
11
|
+
try {
|
|
12
|
+
if (await vault.isUnlocked()) {
|
|
13
|
+
const token = await vault.get('cf/default');
|
|
14
|
+
if (token) return token;
|
|
15
|
+
}
|
|
16
|
+
} catch {}
|
|
17
|
+
return process.env.CF_API_TOKEN || process.env.CF_API_KEY || '';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Cloudflare API Request
|
|
21
|
+
async function cfRequest(method, path, body = null) {
|
|
22
|
+
const token = await getCFToken();
|
|
23
|
+
if (!token) {
|
|
24
|
+
return { error: 'Cloudflare not configured. Add: vault_add cf/default "your-api-token"' };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return new Promise((resolve) => {
|
|
28
|
+
const options = {
|
|
29
|
+
hostname: 'api.cloudflare.com',
|
|
30
|
+
port: 443,
|
|
31
|
+
path: `/client/v4${path}`,
|
|
32
|
+
method: method,
|
|
33
|
+
headers: {
|
|
34
|
+
'Authorization': `Bearer ${token}`,
|
|
35
|
+
'Content-Type': 'application/json'
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const req = https.request(options, (res) => {
|
|
40
|
+
let data = '';
|
|
41
|
+
res.on('data', chunk => data += chunk);
|
|
42
|
+
res.on('end', () => {
|
|
43
|
+
try {
|
|
44
|
+
const json = JSON.parse(data);
|
|
45
|
+
if (json.success) resolve(json.result);
|
|
46
|
+
else resolve({ error: json.errors?.[0]?.message || 'API error', errors: json.errors });
|
|
47
|
+
} catch { resolve({ raw: data }); }
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
req.on('error', (e) => resolve({ error: e.message }));
|
|
52
|
+
if (body) req.write(JSON.stringify(body));
|
|
53
|
+
req.end();
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Tool definitions - PRO tier ($99/mo)
|
|
58
|
+
const CF_TOOLS = [
|
|
59
|
+
// Zones
|
|
60
|
+
{ name: 'cf_list_zones', description: 'List zones. FREE.', inputSchema: { type: 'object', properties: { name: { type: 'string' } } }, tier: 'pro' },
|
|
61
|
+
{ name: 'cf_get_zone', description: 'Get zone details. FREE.', inputSchema: { type: 'object', properties: { zone_id: { type: 'string' } }, required: ['zone_id'] }, tier: 'pro' },
|
|
62
|
+
{ name: 'cf_create_zone', description: 'Add domain to Cloudflare. 3 credits.', inputSchema: { type: 'object', properties: { name: { type: 'string' } }, required: ['name'] }, cost: 3, tier: 'pro' },
|
|
63
|
+
{ name: 'cf_find_zone', description: 'Find zone ID by domain. FREE.', inputSchema: { type: 'object', properties: { domain: { type: 'string' } }, required: ['domain'] }, tier: 'pro' },
|
|
64
|
+
|
|
65
|
+
// DNS
|
|
66
|
+
{ name: 'cf_list_dns', description: 'List DNS records. FREE.', inputSchema: { type: 'object', properties: { zone_id: { type: 'string' }, type: { type: 'string' } }, required: ['zone_id'] }, tier: 'pro' },
|
|
67
|
+
{ name: 'cf_create_dns', description: 'Create DNS record. 2 credits.', inputSchema: { type: 'object', properties: { zone_id: { type: 'string' }, type: { type: 'string' }, name: { type: 'string' }, content: { type: 'string' }, proxied: { type: 'boolean' } }, required: ['zone_id', 'type', 'name', 'content'] }, cost: 2, tier: 'pro' },
|
|
68
|
+
{ name: 'cf_update_dns', description: 'Update DNS record. 2 credits.', inputSchema: { type: 'object', properties: { zone_id: { type: 'string' }, record_id: { type: 'string' }, content: { type: 'string' }, proxied: { type: 'boolean' } }, required: ['zone_id', 'record_id'] }, cost: 2, tier: 'pro' },
|
|
69
|
+
{ name: 'cf_delete_dns', description: 'Delete DNS record. 2 credits.', inputSchema: { type: 'object', properties: { zone_id: { type: 'string' }, record_id: { type: 'string' } }, required: ['zone_id', 'record_id'] }, cost: 2, tier: 'pro' },
|
|
70
|
+
|
|
71
|
+
// SSL
|
|
72
|
+
{ name: 'cf_ssl_status', description: 'Get SSL status. FREE.', inputSchema: { type: 'object', properties: { zone_id: { type: 'string' } }, required: ['zone_id'] }, tier: 'pro' },
|
|
73
|
+
{ name: 'cf_ssl_mode', description: 'Set SSL mode. 2 credits.', inputSchema: { type: 'object', properties: { zone_id: { type: 'string' }, mode: { type: 'string', enum: ['off', 'flexible', 'full', 'strict'] } }, required: ['zone_id', 'mode'] }, cost: 2, tier: 'pro' },
|
|
74
|
+
|
|
75
|
+
// Caching
|
|
76
|
+
{ name: 'cf_purge_cache', description: 'Purge cache. 2 credits.', inputSchema: { type: 'object', properties: { zone_id: { type: 'string' }, files: { type: 'array', items: { type: 'string' } }, purge_everything: { type: 'boolean' } }, required: ['zone_id'] }, cost: 2, tier: 'pro' },
|
|
77
|
+
{ name: 'cf_dev_mode', description: 'Toggle dev mode. FREE.', inputSchema: { type: 'object', properties: { zone_id: { type: 'string' }, enabled: { type: 'boolean' } }, required: ['zone_id', 'enabled'] }, tier: 'pro' },
|
|
78
|
+
|
|
79
|
+
// Security
|
|
80
|
+
{ name: 'cf_under_attack', description: 'Toggle Under Attack mode. FREE.', inputSchema: { type: 'object', properties: { zone_id: { type: 'string' }, enabled: { type: 'boolean' } }, required: ['zone_id', 'enabled'] }, tier: 'pro' },
|
|
81
|
+
{ name: 'cf_block_ip', description: 'Block IP. 2 credits.', inputSchema: { type: 'object', properties: { zone_id: { type: 'string' }, ip: { type: 'string' } }, required: ['zone_id', 'ip'] }, cost: 2, tier: 'pro' },
|
|
82
|
+
|
|
83
|
+
// Smart Integrations
|
|
84
|
+
{ name: 'cf_point_to_server', description: 'Point domain to server IP. 3 credits.', inputSchema: { type: 'object', properties: { zone_id: { type: 'string' }, ip: { type: 'string' }, proxied: { type: 'boolean' } }, required: ['zone_id', 'ip'] }, cost: 3, tier: 'pro' },
|
|
85
|
+
{ name: 'cf_setup_email', description: 'Add MX records. 3 credits.', inputSchema: { type: 'object', properties: { zone_id: { type: 'string' }, mail_server: { type: 'string' } }, required: ['zone_id', 'mail_server'] }, cost: 3, tier: 'pro' }
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
// Handle CF tool calls
|
|
89
|
+
async function handleTool(name, args) {
|
|
90
|
+
try {
|
|
91
|
+
// Zones
|
|
92
|
+
if (name === 'cf_list_zones') {
|
|
93
|
+
const query = args.name ? `?name=${args.name}` : '';
|
|
94
|
+
const result = await cfRequest('GET', `/zones${query}`);
|
|
95
|
+
if (Array.isArray(result)) return result.map(z => ({ id: z.id, name: z.name, status: z.status }));
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
if (name === 'cf_get_zone') return cfRequest('GET', `/zones/${args.zone_id}`);
|
|
99
|
+
if (name === 'cf_create_zone') return cfRequest('POST', '/zones', { name: args.name, jump_start: true });
|
|
100
|
+
if (name === 'cf_find_zone') {
|
|
101
|
+
const zones = await cfRequest('GET', `/zones?name=${args.domain}`);
|
|
102
|
+
if (Array.isArray(zones) && zones.length > 0) return { zone_id: zones[0].id, name: zones[0].name };
|
|
103
|
+
return { error: `Zone not found: ${args.domain}` };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// DNS
|
|
107
|
+
if (name === 'cf_list_dns') {
|
|
108
|
+
const query = args.type ? `?type=${args.type}` : '';
|
|
109
|
+
return cfRequest('GET', `/zones/${args.zone_id}/dns_records${query}`);
|
|
110
|
+
}
|
|
111
|
+
if (name === 'cf_create_dns') {
|
|
112
|
+
return cfRequest('POST', `/zones/${args.zone_id}/dns_records`, {
|
|
113
|
+
type: args.type, name: args.name, content: args.content, proxied: args.proxied !== false, ttl: 1
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
if (name === 'cf_update_dns') {
|
|
117
|
+
const body = {};
|
|
118
|
+
if (args.content) body.content = args.content;
|
|
119
|
+
if (args.proxied !== undefined) body.proxied = args.proxied;
|
|
120
|
+
return cfRequest('PATCH', `/zones/${args.zone_id}/dns_records/${args.record_id}`, body);
|
|
121
|
+
}
|
|
122
|
+
if (name === 'cf_delete_dns') return cfRequest('DELETE', `/zones/${args.zone_id}/dns_records/${args.record_id}`);
|
|
123
|
+
|
|
124
|
+
// SSL
|
|
125
|
+
if (name === 'cf_ssl_status') return cfRequest('GET', `/zones/${args.zone_id}/settings/ssl`);
|
|
126
|
+
if (name === 'cf_ssl_mode') return cfRequest('PATCH', `/zones/${args.zone_id}/settings/ssl`, { value: args.mode });
|
|
127
|
+
|
|
128
|
+
// Caching
|
|
129
|
+
if (name === 'cf_purge_cache') {
|
|
130
|
+
const body = args.purge_everything ? { purge_everything: true } : { files: args.files };
|
|
131
|
+
return cfRequest('POST', `/zones/${args.zone_id}/purge_cache`, body);
|
|
132
|
+
}
|
|
133
|
+
if (name === 'cf_dev_mode') return cfRequest('PATCH', `/zones/${args.zone_id}/settings/development_mode`, { value: args.enabled ? 'on' : 'off' });
|
|
134
|
+
|
|
135
|
+
// Security
|
|
136
|
+
if (name === 'cf_under_attack') return cfRequest('PATCH', `/zones/${args.zone_id}/settings/security_level`, { value: args.enabled ? 'under_attack' : 'medium' });
|
|
137
|
+
if (name === 'cf_block_ip') return cfRequest('POST', `/zones/${args.zone_id}/firewall/access_rules/rules`, { mode: 'block', configuration: { target: 'ip', value: args.ip } });
|
|
138
|
+
|
|
139
|
+
// Smart Integrations
|
|
140
|
+
if (name === 'cf_point_to_server') {
|
|
141
|
+
const results = [];
|
|
142
|
+
results.push(await cfRequest('POST', `/zones/${args.zone_id}/dns_records`, { type: 'A', name: '@', content: args.ip, proxied: args.proxied !== false, ttl: 1 }));
|
|
143
|
+
results.push(await cfRequest('POST', `/zones/${args.zone_id}/dns_records`, { type: 'A', name: 'www', content: args.ip, proxied: args.proxied !== false, ttl: 1 }));
|
|
144
|
+
return { records_created: results };
|
|
145
|
+
}
|
|
146
|
+
if (name === 'cf_setup_email') {
|
|
147
|
+
return cfRequest('POST', `/zones/${args.zone_id}/dns_records`, { type: 'MX', name: '@', content: args.mail_server, priority: 10, proxied: false, ttl: 1 });
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return { error: `Unknown CF tool: ${name}` };
|
|
151
|
+
} catch (e) {
|
|
152
|
+
return { error: e.message };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
module.exports = { CF_TOOLS, handleTool };
|