thumbgate 1.40.1 → 1.40.2
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/.claude-plugin/plugin.json +1 -1
- package/.well-known/mcp/server-card.json +1 -1
- package/adapters/claude/.mcp.json +3 -3
- package/adapters/forge/forge.yaml +3 -3
- package/adapters/future-agi/.mcp.json +1 -1
- package/adapters/future-agi/config.toml +1 -1
- package/adapters/future-agi/opencode.json +1 -1
- package/adapters/herdr/herdr-plugin.toml +2 -2
- package/adapters/mcp/server-stdio.js +1 -1
- package/adapters/opencode/opencode.json +1 -1
- package/config/github-about.json +1 -1
- package/package.json +38 -5
- package/public/index.html +38 -152
- package/public/install.html +8 -8
- package/public/numbers.html +2 -2
- package/public/pricing.html +54 -335
- package/scripts/analytics-report.js +363 -0
- package/scripts/auto-context-packs.js +249 -0
- package/scripts/billing-setup.js +137 -0
- package/scripts/check-update.js +236 -0
- package/scripts/conversion-rate-stats.js +442 -0
- package/scripts/cost-cli.js +147 -0
- package/scripts/creator-campaigns.js +239 -0
- package/scripts/cuda-gate-batch.js +560 -0
- package/scripts/daemon-manager.js +108 -0
- package/scripts/dashboard.js +2 -2
- package/scripts/delegation-runtime.js +1036 -0
- package/scripts/dispatch-brief.js +159 -0
- package/scripts/distribution-surfaces.js +110 -0
- package/scripts/egm-goldfish-packet.js +95 -0
- package/scripts/embeddinggemma-adapter.js +407 -0
- package/scripts/funnel-analytics.js +35 -0
- package/scripts/gate-semantic-layer.js +292 -0
- package/scripts/implementation-notes.js +241 -0
- package/scripts/intent-router.js +518 -0
- package/scripts/latency-budget.js +164 -0
- package/scripts/mcp-writeguard.js +158 -0
- package/scripts/model-candidates.js +414 -0
- package/scripts/openrouter-armor-partnership-diode.js +2419 -0
- package/scripts/operational-dashboard.js +172 -0
- package/scripts/operational-summary.js +190 -0
- package/scripts/operator-artifacts.js +622 -0
- package/scripts/optimize-context.js +17 -0
- package/scripts/predictive-insights.js +449 -0
- package/scripts/profound-aeo-citation-engine.js +583 -0
- package/scripts/pulse.js +80 -0
- package/scripts/rrsi-doctor.js +2698 -0
- package/scripts/session-report.js +120 -0
- package/scripts/subagent-profiles.js +79 -0
- package/scripts/third-author-cli.js +118 -0
- package/scripts/third-author-governance.js +437 -0
- package/scripts/thumbgate-dream.js +878 -0
- package/server.json +2 -2
- package/skills/thumbgate-daily-discoveries/SKILL.md +25 -41
- package/scripts/install-thumbgate-daily-publish-launchd.sh +0 -83
- package/scripts/thumbgate-daily-discoveries-publish.js +0 -461
- package/scripts/thumbgate-daily-discoveries-publish.sh +0 -18
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* billing-setup.js — Wire up hosted billing for the CFO dashboard
|
|
6
|
+
*
|
|
7
|
+
* Generates a THUMBGATE_OPERATOR_KEY and stores it locally so that
|
|
8
|
+
* `node bin/cli.js cfo --today` pulls live revenue from the production server.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* node scripts/billing-setup.js
|
|
12
|
+
*
|
|
13
|
+
* After running, set the saved key on Railway from a private terminal:
|
|
14
|
+
* THUMBGATE_PRINT_OPERATOR_KEY=1 node scripts/billing-setup.js
|
|
15
|
+
* Then redeploy (or let Railway auto-deploy).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const crypto = require('node:crypto');
|
|
19
|
+
const fs = require('node:fs');
|
|
20
|
+
const path = require('node:path');
|
|
21
|
+
const os = require('node:os');
|
|
22
|
+
|
|
23
|
+
const LOCAL_CONFIG_PATH = path.join(os.homedir(), '.config', 'thumbgate', 'operator.json');
|
|
24
|
+
const PROD_URL = 'https://thumbgate-production.up.railway.app';
|
|
25
|
+
|
|
26
|
+
function shouldRevealOperatorKey() {
|
|
27
|
+
return process.env.THUMBGATE_PRINT_OPERATOR_KEY === '1';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function generateOperatorKey() {
|
|
31
|
+
return `tg_op_${crypto.randomBytes(20).toString('hex')}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function redactOperatorKey(key) {
|
|
35
|
+
const raw = String(key || '');
|
|
36
|
+
if (!raw) return '<missing>';
|
|
37
|
+
if (shouldRevealOperatorKey()) return raw;
|
|
38
|
+
return `${raw.slice(0, 8)}...${raw.slice(-4)} (redacted)`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function railwaySetCommand(key) {
|
|
42
|
+
const value = shouldRevealOperatorKey() ? key : '<value-from-operator.json>';
|
|
43
|
+
return `railway variables set THUMBGATE_OPERATOR_KEY=${value}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function printRevealHint() {
|
|
47
|
+
if (shouldRevealOperatorKey()) return;
|
|
48
|
+
console.log('\nTo reveal the key in a private terminal only:');
|
|
49
|
+
console.log(' THUMBGATE_PRINT_OPERATOR_KEY=1 node bin/cli.js billing:setup');
|
|
50
|
+
console.log('\nDo not paste the operator key into chat, shell history shared with agents, or git.');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function loadExistingConfig() {
|
|
54
|
+
try {
|
|
55
|
+
const raw = fs.readFileSync(LOCAL_CONFIG_PATH, 'utf8');
|
|
56
|
+
return JSON.parse(raw);
|
|
57
|
+
} catch {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function saveConfig(config) {
|
|
63
|
+
const dir = path.dirname(LOCAL_CONFIG_PATH);
|
|
64
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
65
|
+
fs.writeFileSync(LOCAL_CONFIG_PATH, JSON.stringify(config, null, 2) + '\n', { mode: 0o600 });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function verifyEndpoint(baseUrl, key) {
|
|
69
|
+
try {
|
|
70
|
+
const url = new URL('/v1/billing/summary?window=today', baseUrl);
|
|
71
|
+
const res = await fetch(url, {
|
|
72
|
+
method: 'GET',
|
|
73
|
+
headers: { authorization: `Bearer ${key}`, accept: 'application/json' },
|
|
74
|
+
});
|
|
75
|
+
return { status: res.status, ok: res.ok };
|
|
76
|
+
} catch (err) {
|
|
77
|
+
return { status: null, ok: false, error: err.message };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function main() {
|
|
82
|
+
const existing = loadExistingConfig();
|
|
83
|
+
|
|
84
|
+
if (existing && existing.operatorKey && existing.baseUrl) {
|
|
85
|
+
console.log('\n✓ Operator config already exists at', LOCAL_CONFIG_PATH);
|
|
86
|
+
console.log(' Base URL :', existing.baseUrl);
|
|
87
|
+
console.log(' Operator key:', redactOperatorKey(existing.operatorKey));
|
|
88
|
+
console.log('\nTo regenerate, delete the file and re-run this script.');
|
|
89
|
+
|
|
90
|
+
// Set env for this process so the verify check works
|
|
91
|
+
process.env.THUMBGATE_OPERATOR_KEY = existing.operatorKey;
|
|
92
|
+
process.env.THUMBGATE_BILLING_API_BASE_URL = existing.baseUrl;
|
|
93
|
+
|
|
94
|
+
const check = await verifyEndpoint(existing.baseUrl, existing.operatorKey);
|
|
95
|
+
if (check.ok) {
|
|
96
|
+
console.log('\n✓ Production endpoint responds OK — hosted billing is active.');
|
|
97
|
+
} else if (check.status === 403) {
|
|
98
|
+
console.log('\n⚠ Production endpoint returned 403 — the operator key is not yet set on Railway.');
|
|
99
|
+
console.log('\nSet it now:\n');
|
|
100
|
+
console.log(` ${railwaySetCommand(existing.operatorKey)}`);
|
|
101
|
+
printRevealHint();
|
|
102
|
+
console.log('\nThen redeploy (Railway will pick it up automatically).');
|
|
103
|
+
} else {
|
|
104
|
+
console.log(`\n⚠ Endpoint check returned status ${check.status || 'error'}: ${check.error || ''}`);
|
|
105
|
+
console.log('\nIf this is an auth/config mismatch, verify Railway has the same operator key:\n');
|
|
106
|
+
console.log(` ${railwaySetCommand(existing.operatorKey)}`);
|
|
107
|
+
printRevealHint();
|
|
108
|
+
}
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const key = generateOperatorKey();
|
|
113
|
+
const config = {
|
|
114
|
+
operatorKey: key,
|
|
115
|
+
baseUrl: process.env.THUMBGATE_BILLING_API_BASE_URL || PROD_URL,
|
|
116
|
+
createdAt: new Date().toISOString(),
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
saveConfig(config);
|
|
120
|
+
|
|
121
|
+
console.log('\n✓ Operator key generated and saved to', LOCAL_CONFIG_PATH);
|
|
122
|
+
console.log('\n──────────────────────────────────────────────────────');
|
|
123
|
+
console.log(' THUMBGATE_OPERATOR_KEY =', redactOperatorKey(key));
|
|
124
|
+
console.log('──────────────────────────────────────────────────────');
|
|
125
|
+
console.log('\nSet this key on Railway (one-time):');
|
|
126
|
+
console.log('\n ' + railwaySetCommand(key));
|
|
127
|
+
printRevealHint();
|
|
128
|
+
console.log('\nOr paste it into the Railway dashboard under Variables.');
|
|
129
|
+
console.log('\nAfter Railway redeploys, run:\n');
|
|
130
|
+
console.log(' node bin/cli.js cfo --today\n');
|
|
131
|
+
console.log('The CFO dashboard will use live production billing data.');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
main().catch((err) => {
|
|
135
|
+
console.error('billing-setup error:', err.message);
|
|
136
|
+
process.exit(1);
|
|
137
|
+
});
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const https = require('https');
|
|
7
|
+
const { execSync } = require('child_process');
|
|
8
|
+
|
|
9
|
+
const PROJECT_ROOT = path.join(__dirname, '..');
|
|
10
|
+
const GITHUB_REPO = 'IgorGanapolsky/ThumbGate';
|
|
11
|
+
|
|
12
|
+
function getLocalVersion() {
|
|
13
|
+
try {
|
|
14
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(PROJECT_ROOT, 'package.json'), 'utf8'));
|
|
15
|
+
return pkg.version;
|
|
16
|
+
} catch (_) {
|
|
17
|
+
return '0.0.0';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function httpsGetJson(url) {
|
|
22
|
+
const headers = { 'User-Agent': 'thumbgate-updater' };
|
|
23
|
+
let parsedUrl;
|
|
24
|
+
try {
|
|
25
|
+
parsedUrl = new URL(url);
|
|
26
|
+
} catch (_) {}
|
|
27
|
+
if (parsedUrl && parsedUrl.hostname === 'api.github.com' && process.env.GITHUB_TOKEN) {
|
|
28
|
+
headers['Authorization'] = `token ${process.env.GITHUB_TOKEN}`;
|
|
29
|
+
}
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
https.get(url, { headers, timeout: 5000 }, (res) => {
|
|
32
|
+
let data = '';
|
|
33
|
+
res.on('data', (chunk) => { data += chunk; });
|
|
34
|
+
res.on('end', () => {
|
|
35
|
+
if (res.statusCode >= 400) {
|
|
36
|
+
reject(new Error(`HTTP ${res.statusCode} for ${url}`));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
resolve(JSON.parse(data));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}).on('error', reject).on('timeout', () => reject(new Error('Request timeout')));
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function parseVersion(v) {
|
|
50
|
+
return String(v || '').replace(/^v/, '').split('-')[0].split('.').map(Number);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function isNewer(current, latest) {
|
|
54
|
+
const cParts = parseVersion(current);
|
|
55
|
+
const lParts = parseVersion(latest);
|
|
56
|
+
for (let i = 0; i < 3; i++) {
|
|
57
|
+
const c = cParts[i] || 0;
|
|
58
|
+
const l = lParts[i] || 0;
|
|
59
|
+
if (l > c) return true;
|
|
60
|
+
if (c > l) return false;
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function isSourceCheckout() {
|
|
66
|
+
return fs.existsSync(path.join(PROJECT_ROOT, '.git'));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const HOME = process.env.HOME || process.env.USERPROFILE || '';
|
|
70
|
+
const CACHE_DIR = path.join(HOME, '.thumbgate');
|
|
71
|
+
const CACHE_FILE = path.join(CACHE_DIR, 'update-cache.json');
|
|
72
|
+
|
|
73
|
+
async function getLatestReleaseInfo(force = false) {
|
|
74
|
+
if (!force && fs.existsSync(CACHE_FILE)) {
|
|
75
|
+
try {
|
|
76
|
+
const cached = JSON.parse(fs.readFileSync(CACHE_FILE, 'utf8'));
|
|
77
|
+
if (Date.now() - cached.timestamp < 24 * 60 * 60 * 1000) {
|
|
78
|
+
return cached.data;
|
|
79
|
+
}
|
|
80
|
+
} catch (_) {
|
|
81
|
+
// Ignore cache read errors
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// First attempt: NPM Registry (very reliable, fast, no rate limits)
|
|
86
|
+
let npmVersion = null;
|
|
87
|
+
try {
|
|
88
|
+
const npmMeta = await httpsGetJson('https://registry.npmjs.org/thumbgate/latest');
|
|
89
|
+
npmVersion = npmMeta.version;
|
|
90
|
+
} catch (_) {
|
|
91
|
+
// Ignore and let GitHub releases handle it or fall back
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Second attempt: GitHub releases for changelog / backup version check
|
|
95
|
+
let githubVersion = null;
|
|
96
|
+
let changelog = null;
|
|
97
|
+
let htmlUrl = null;
|
|
98
|
+
try {
|
|
99
|
+
const ghRelease = await httpsGetJson(`https://api.github.com/repos/${GITHUB_REPO}/releases/latest`);
|
|
100
|
+
githubVersion = ghRelease.tag_name ? ghRelease.tag_name.replace(/^v/, '') : null;
|
|
101
|
+
changelog = ghRelease.body || null;
|
|
102
|
+
htmlUrl = ghRelease.html_url || null;
|
|
103
|
+
} catch (_) {
|
|
104
|
+
// Ignore GitHub API errors (e.g. offline, rate-limited)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const latestVersion = npmVersion || githubVersion;
|
|
108
|
+
const data = {
|
|
109
|
+
latestVersion,
|
|
110
|
+
changelog,
|
|
111
|
+
htmlUrl,
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
if (latestVersion) {
|
|
115
|
+
try {
|
|
116
|
+
if (!fs.existsSync(CACHE_DIR)) {
|
|
117
|
+
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
|
118
|
+
}
|
|
119
|
+
fs.writeFileSync(CACHE_FILE, JSON.stringify({
|
|
120
|
+
timestamp: Date.now(),
|
|
121
|
+
data,
|
|
122
|
+
}, null, 2), 'utf8');
|
|
123
|
+
} catch (_) {
|
|
124
|
+
// Ignore cache write errors
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return data;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function checkUpdate(options = {}) {
|
|
132
|
+
const current = getLocalVersion();
|
|
133
|
+
const verbose = options.verbose !== false;
|
|
134
|
+
const force = options.force || false;
|
|
135
|
+
|
|
136
|
+
if (verbose) {
|
|
137
|
+
console.log(`Checking for ThumbGate updates... (Current version: v${current})`);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
const { latestVersion, changelog, htmlUrl } = await getLatestReleaseInfo(force);
|
|
142
|
+
|
|
143
|
+
if (!latestVersion) {
|
|
144
|
+
if (verbose) {
|
|
145
|
+
console.log('⚠️ Unable to check for updates. Please check your internet connection.');
|
|
146
|
+
}
|
|
147
|
+
return { updateAvailable: false, current, error: 'Offline or API error' };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const updateAvailable = isNewer(current, latestVersion);
|
|
151
|
+
|
|
152
|
+
if (updateAvailable) {
|
|
153
|
+
if (verbose) {
|
|
154
|
+
console.log('\n┌────────────────────────────────────────────────────────┐');
|
|
155
|
+
console.log(`│ 🔔 A new version of ThumbGate is available: v${latestVersion.padEnd(8)} │`);
|
|
156
|
+
console.log(`│ Current version: v${current.padEnd(31)} │`);
|
|
157
|
+
console.log('├────────────────────────────────────────────────────────┤');
|
|
158
|
+
if (changelog) {
|
|
159
|
+
console.log('│ What\'s New: │');
|
|
160
|
+
const lines = changelog
|
|
161
|
+
.split('\n')
|
|
162
|
+
.map(line => line.trim())
|
|
163
|
+
.filter(line => line.startsWith('-') || line.startsWith('*'))
|
|
164
|
+
.slice(0, 5);
|
|
165
|
+
for (const line of lines) {
|
|
166
|
+
const truncated = line.length > 50 ? line.slice(0, 47) + '...' : line;
|
|
167
|
+
console.log(`│ ${truncated.padEnd(52)} │`);
|
|
168
|
+
}
|
|
169
|
+
if (lines.length > 0) {
|
|
170
|
+
console.log('├────────────────────────────────────────────────────────┤');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (isSourceCheckout()) {
|
|
174
|
+
console.log('│ 👉 You are running from a source checkout. │');
|
|
175
|
+
console.log('│ To update, run: git pull │');
|
|
176
|
+
} else {
|
|
177
|
+
console.log('│ 👉 To install this update, run: │');
|
|
178
|
+
console.log('│ npm install -g thumbgate@latest │');
|
|
179
|
+
console.log('│ 👉 Or update in-place with: │');
|
|
180
|
+
console.log('│ npx thumbgate self-update │');
|
|
181
|
+
}
|
|
182
|
+
console.log('└────────────────────────────────────────────────────────┘\n');
|
|
183
|
+
}
|
|
184
|
+
return { updateAvailable: true, current, latest: latestVersion, changelog, htmlUrl };
|
|
185
|
+
} else {
|
|
186
|
+
if (verbose) {
|
|
187
|
+
console.log(`✨ ThumbGate is up to date (v${current}).`);
|
|
188
|
+
}
|
|
189
|
+
return { updateAvailable: false, current, latest: latestVersion };
|
|
190
|
+
}
|
|
191
|
+
} catch (err) {
|
|
192
|
+
if (verbose) {
|
|
193
|
+
console.log(`⚠️ Error checking for updates: ${err.message}`);
|
|
194
|
+
}
|
|
195
|
+
return { updateAvailable: false, current, error: err.message };
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function selfUpdate() {
|
|
200
|
+
const current = getLocalVersion();
|
|
201
|
+
console.log(`Attempting self-update for ThumbGate...`);
|
|
202
|
+
|
|
203
|
+
if (isSourceCheckout()) {
|
|
204
|
+
console.log('❌ Cannot run self-update from a source checkout family.');
|
|
205
|
+
console.log('Please run `git pull` manually to update the repository.');
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
try {
|
|
210
|
+
console.log('Running: npm install -g thumbgate@latest');
|
|
211
|
+
execSync('npm install -g thumbgate@latest', { stdio: 'inherit' });
|
|
212
|
+
console.log('✨ Self-update complete! Run `thumbgate version` to verify.');
|
|
213
|
+
return true;
|
|
214
|
+
} catch (err) {
|
|
215
|
+
console.error(`❌ Self-update failed: ${err.message}`);
|
|
216
|
+
console.log('Please run: sudo npm install -g thumbgate@latest');
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
module.exports = {
|
|
222
|
+
checkUpdate,
|
|
223
|
+
selfUpdate,
|
|
224
|
+
getLocalVersion,
|
|
225
|
+
isNewer,
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
if (require.main === module) {
|
|
229
|
+
const args = process.argv.slice(2);
|
|
230
|
+
if (args.includes('--self-update') || args.includes('self-update')) {
|
|
231
|
+
selfUpdate();
|
|
232
|
+
} else {
|
|
233
|
+
const force = args.includes('--force');
|
|
234
|
+
checkUpdate({ verbose: true, force });
|
|
235
|
+
}
|
|
236
|
+
}
|