thumbgate 1.37.3 → 1.39.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/.agents/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
- package/.agents/skills/bolt-forge-opt-in-not-clone/SKILL.md +72 -0
- package/.agents/skills/decisive-step-evaluator/SKILL.md +47 -0
- package/.agents/skills/fiddler-control-plane-honesty/SKILL.md +61 -0
- package/.agents/skills/halo-trace-optimize-not-clone/SKILL.md +60 -0
- package/.agents/skills/harness-evolution-ceiling/SKILL.md +52 -0
- package/.agents/skills/infoq-architect-honesty-not-clone/SKILL.md +37 -0
- package/.agents/skills/meko-datapack-honesty-not-clone/SKILL.md +45 -0
- package/.agents/skills/mintlify-knowledge-honesty-not-clone/SKILL.md +49 -0
- package/.agents/skills/model-distress-governance/SKILL.md +56 -0
- package/.agents/skills/omp-coordination-honesty-not-clone/SKILL.md +94 -0
- package/.agents/skills/saas-moat-honesty-not-clone/SKILL.md +22 -0
- package/.agents/skills/salt-code-policy-honesty-not-clone/SKILL.md +76 -0
- package/.agents/skills/siren-mcp-governance/SKILL.md +50 -0
- package/.agents/skills/vs-coverage-gap-not-clone/SKILL.md +69 -0
- package/.agents/skills/wisdom-context-artifact-not-clone/SKILL.md +67 -0
- package/.claude-plugin/plugin.json +1 -1
- package/.well-known/mcp/server-card.json +1 -1
- package/adapters/claude/.mcp.json +2 -2
- 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/hotdata/hotdata-vector-store.js +575 -0
- package/adapters/mcp/server-stdio.js +1 -1
- package/adapters/opencode/opencode.json +1 -1
- package/adapters/strands/STRANDS.md +107 -0
- package/adapters/strands/strands-box-diode.js +344 -0
- package/adapters/strands/strands-decider-adapter.js +445 -0
- package/adapters/strands/strands-middleware.js +192 -0
- package/adapters/tailscale/.mcp.json +15 -0
- package/adapters/tailscale/TAILSCALE.md +117 -0
- package/adapters/tailscale/config.toml +16 -0
- package/bin/cli.js +602 -21
- package/config/gate-templates.json +109 -0
- package/config/gates/default.json +13 -0
- package/config/schemas/task-outcome-receipt.schema.json +12 -0
- package/package.json +150 -21
- package/public/blog/2026-09-28-pretool-secret-deny.html +83 -0
- package/public/blog/2026-10-01-aws-strands-harness-token-firewall.html +77 -0
- package/public/blog/2026-10-01-model-distress-relief-seeking-firewall.html +71 -0
- package/public/blog/2026-10-02-salt-code-honest-steal-40-guardrails.html +106 -0
- package/public/blog/2026-10-05-why-3-days-of-triage-wont-save-ai-speed-code.html +119 -0
- package/public/blog/2026-10-09-your-code-got-a-third-author-governance.html +141 -0
- package/public/connectors.html +329 -0
- package/public/enterprise-governance.html +311 -0
- package/public/gaming-playbook.html +732 -0
- package/public/index.html +77 -51
- package/public/install.html +7 -7
- package/public/learn.html +14 -0
- package/public/numbers.html +2 -2
- package/public/onboarding.html +794 -0
- package/public/operator-framework.html +385 -0
- package/public/pricing.html +14 -10
- package/scripts/activesaddler-curriculum-doctor.js +357 -0
- package/scripts/agent-context-artifact.js +325 -0
- package/scripts/agent-egress-policy.js +2 -2
- package/scripts/agent-operations-planner.js +1 -1
- package/scripts/agent-outcome-eval.js +1 -1
- package/scripts/agent-reliability-client.js +148 -0
- package/scripts/apple-minions-idle-compute-steal.js +428 -0
- package/scripts/autoresearch-runner.js +20 -1
- package/scripts/billing.js +0 -1
- package/scripts/cli-demo.js +505 -1
- package/scripts/cli-schema.js +36 -0
- package/scripts/colab-compute-honesty.js +93 -0
- package/scripts/corporate-email-isolation-diode.js +299 -0
- package/scripts/coverage-gap.js +396 -0
- package/scripts/dashboard-chat.js +3 -3
- package/scripts/dashboard.js +2 -2
- package/scripts/decisive-step-doctor.js +256 -0
- package/scripts/decisive-step-evaluator.js +390 -0
- package/scripts/entitlement.js +18 -7
- package/scripts/experiment-tracker.js +5 -3
- package/scripts/feedback-loop.js +26 -3
- package/scripts/fiddler-control-plane-honesty.js +303 -0
- package/scripts/financial-control-plane.js +10 -2
- package/scripts/gates-engine.js +3 -1
- package/scripts/github-license-compliance-diode.js +378 -0
- package/scripts/halo-trace-optimizer.js +631 -0
- package/scripts/harness-ceiling-doctor.js +326 -0
- package/scripts/hf-papers.js +1 -1
- package/scripts/human-escalation.js +7 -1
- package/scripts/hybrid-feedback-context.js +53 -7
- package/scripts/infoq-architect-honesty.js +362 -0
- package/scripts/lesson-graph.js +785 -0
- package/scripts/lesson-inference.js +1 -1
- package/scripts/lesson-retrieval.js +26 -18
- package/scripts/license.js +122 -21
- package/scripts/llm-behavior-monitor.js +1 -1
- package/scripts/llm-obs-honesty.js +52 -0
- package/scripts/local-model-profile.js +11 -7
- package/scripts/mailer/resend-mailer.js +6 -3
- package/scripts/mcp-transport-strategy.js +1 -1
- package/scripts/meko-datapack-honesty.js +414 -0
- package/scripts/migrate-lesson-graph.js +442 -0
- package/scripts/mintlify-knowledge-honesty.js +647 -0
- package/scripts/model-distress-detector.js +207 -0
- package/scripts/model-distress-doctor.js +368 -0
- package/scripts/multi-harness-invariants.js +305 -0
- package/scripts/omp-coordination-honesty.js +488 -0
- package/scripts/pro-local-dashboard.js +20 -3
- package/scripts/prompt-eval.js +1 -1
- package/scripts/prove-herdr-adapter.js +367 -3
- package/scripts/rag-embedding-identity.js +1 -1
- package/scripts/rrsi-regularizer.js +531 -0
- package/scripts/saas-moat-honesty.js +443 -0
- package/scripts/salt-code-policy-honesty.js +1204 -0
- package/scripts/secret-redaction.js +58 -0
- package/scripts/session-export-gate.js +368 -0
- package/scripts/siren-mcp-governance.js +539 -0
- package/scripts/strands-box-doctor.js +130 -0
- package/scripts/strands-harness-doctor.js +390 -0
- package/scripts/stripe-revenue-catalog-audit.js +12 -0
- package/scripts/stripe-revenue-catalog.js +40 -0
- package/scripts/switchyard-router.js +153 -0
- package/scripts/tailscale-p2p-doctor.js +252 -0
- package/scripts/task-outcomes.js +148 -3
- package/scripts/thumbgate-board-loop.js +4 -2
- package/scripts/thumbgate-daily-discoveries-publish.js +86 -38
- package/scripts/triage-savings-calculator.js +181 -0
- package/scripts/vector-store.js +41 -2
- package/scripts/vulnerability-pre-action-diode.js +319 -0
- package/scripts/windbg-evidence-diagnostics.js +241 -0
- package/scripts/workflow-intake-queue.js +1 -1
- package/scripts/workspace-agent-routines.js +534 -6
- package/scripts/workspace-evolver.js +143 -13
- package/server.json +2 -2
- package/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
- package/skills/siren-mcp-governance/SKILL.md +50 -0
- package/src/api/server.js +191 -5
- package/src/mcp-writeguard.js +1 -1
- package/src/session-interactivity.js +284 -0
|
@@ -182,7 +182,7 @@ function rejectDuplicateBusinessAgentIds(candidates) {
|
|
|
182
182
|
|
|
183
183
|
function rankBusinessFunctionAgents(candidates = []) {
|
|
184
184
|
const normalized = Array.isArray(candidates)
|
|
185
|
-
? rejectDuplicateBusinessAgentIds(candidates.map(normalizeBusinessFunctionCandidate))
|
|
185
|
+
? rejectDuplicateBusinessAgentIds(candidates.map((x) => normalizeBusinessFunctionCandidate(x)))
|
|
186
186
|
: [];
|
|
187
187
|
const eligible = normalized
|
|
188
188
|
.filter((candidate) => candidate.status === 'evidence_complete')
|
|
@@ -56,7 +56,7 @@ function runAgentOutcomeEval(options = {}) {
|
|
|
56
56
|
if (!Array.isArray(suite.cases) || suite.cases.length === 0) {
|
|
57
57
|
throw new Error('Agent outcome suite must contain non-empty cases');
|
|
58
58
|
}
|
|
59
|
-
const results = suite.cases.map(runCase);
|
|
59
|
+
const results = suite.cases.map((x) => runCase(x));
|
|
60
60
|
const passed = results.filter((result) => result.status === 'pass').length;
|
|
61
61
|
const score = Math.round((results.reduce((sum, result) => sum + result.score, 0) / results.length));
|
|
62
62
|
const minimumCases = Number(suite.successCriteria?.minimumCases || 1);
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Agent Reliability Client & Integration Adapter
|
|
6
|
+
*
|
|
7
|
+
* Integrates Gaetano Franco's Agent Reliability trial token with ThumbGate:
|
|
8
|
+
* - Secure credential resolution (env -> ~/.thumbgate/credentials -> local token file)
|
|
9
|
+
* - Automatic token masking to prevent credential leakage in logs or repos
|
|
10
|
+
* - Health diagnostics and telemetry dispatch
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const fs = require('node:fs');
|
|
14
|
+
const os = require('node:os');
|
|
15
|
+
const path = require('node:path');
|
|
16
|
+
|
|
17
|
+
const CREDENTIAL_PATH = path.join(os.homedir(), '.thumbgate', 'credentials', 'agent-reliability.json');
|
|
18
|
+
const DOWNLOADS_TOKEN_PATH = path.join(os.homedir(), 'Downloads', 'agent-reliability-token-igor-thumbgate.txt');
|
|
19
|
+
|
|
20
|
+
function maskToken(token) {
|
|
21
|
+
if (!token || typeof token !== 'string') return 'N/A';
|
|
22
|
+
if (token.length <= 12) return '***';
|
|
23
|
+
return `${token.slice(0, 8)}...${token.slice(-4)}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class AgentReliabilityClient {
|
|
27
|
+
constructor(options = {}) {
|
|
28
|
+
this.options = options;
|
|
29
|
+
this.token = options.token !== undefined ? options.token : this.resolveToken();
|
|
30
|
+
this.issuer = options.issuer || 'Gaetano Franco <gtnfrnc@gmail.com>';
|
|
31
|
+
this.target = options.target || 'ThumbGate';
|
|
32
|
+
this.tier = options.tier || 'private_trial';
|
|
33
|
+
this.expiresAt = options.expiresAt || '2027-12-31T23:59:59Z';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
resolveToken() {
|
|
37
|
+
// 1. Environment variable
|
|
38
|
+
if (process.env.AGENT_RELIABILITY_TOKEN) {
|
|
39
|
+
return String(process.env.AGENT_RELIABILITY_TOKEN).trim();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// 2. ~/.thumbgate/credentials/agent-reliability.json
|
|
43
|
+
if (fs.existsSync(CREDENTIAL_PATH)) {
|
|
44
|
+
try {
|
|
45
|
+
const data = JSON.parse(fs.readFileSync(CREDENTIAL_PATH, 'utf8'));
|
|
46
|
+
if (data.token) return String(data.token).trim();
|
|
47
|
+
} catch (_) {}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 3. Fallback: Downloads file
|
|
51
|
+
if (fs.existsSync(DOWNLOADS_TOKEN_PATH)) {
|
|
52
|
+
try {
|
|
53
|
+
return fs.readFileSync(DOWNLOADS_TOKEN_PATH, 'utf8').trim();
|
|
54
|
+
} catch (_) {}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
hasToken() {
|
|
61
|
+
return Boolean(this.token && this.token.startsWith('ar_'));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
getMaskedToken() {
|
|
65
|
+
return maskToken(this.token);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
isExpired() {
|
|
69
|
+
const expiryMs = Date.parse(this.expiresAt);
|
|
70
|
+
return Number.isFinite(expiryMs) && Date.now() > expiryMs;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
getStatus() {
|
|
74
|
+
const configured = this.hasToken();
|
|
75
|
+
const expired = this.isExpired();
|
|
76
|
+
let tokenSource = 'unconfigured';
|
|
77
|
+
if (this.options.token !== undefined) {
|
|
78
|
+
tokenSource = 'options:token';
|
|
79
|
+
} else if (process.env.AGENT_RELIABILITY_TOKEN) {
|
|
80
|
+
tokenSource = 'env:AGENT_RELIABILITY_TOKEN';
|
|
81
|
+
} else if (fs.existsSync(CREDENTIAL_PATH)) {
|
|
82
|
+
tokenSource = 'file:~/.thumbgate/credentials/agent-reliability.json';
|
|
83
|
+
} else if (fs.existsSync(DOWNLOADS_TOKEN_PATH)) {
|
|
84
|
+
tokenSource = 'file:downloads';
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
configured,
|
|
88
|
+
active: configured && !expired,
|
|
89
|
+
issuer: this.issuer,
|
|
90
|
+
target: this.target,
|
|
91
|
+
tier: this.tier,
|
|
92
|
+
expiresAt: this.expiresAt,
|
|
93
|
+
tokenMasked: this.getMaskedToken(),
|
|
94
|
+
tokenSource,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
recordTelemetry(event = {}) {
|
|
99
|
+
if (!this.hasToken()) {
|
|
100
|
+
return { ok: false, error: 'NO_TOKEN_CONFIGURED' };
|
|
101
|
+
}
|
|
102
|
+
const receipt = {
|
|
103
|
+
timestamp: new Date().toISOString(),
|
|
104
|
+
agent: event.agent || 'thumbgate-gateway',
|
|
105
|
+
action: event.action || 'pre_tool_validation',
|
|
106
|
+
status: event.status || 'PASS',
|
|
107
|
+
tokenMasked: this.getMaskedToken()
|
|
108
|
+
};
|
|
109
|
+
return { ok: true, receipt };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
diagnose() {
|
|
113
|
+
const status = this.getStatus();
|
|
114
|
+
return {
|
|
115
|
+
status: status.active ? 'HEALTHY' : (status.configured ? 'EXPIRED' : 'UNCONFIGURED'),
|
|
116
|
+
integration: 'Agent Reliability by Gaetano Franco',
|
|
117
|
+
details: status
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function run(argv = process.argv.slice(2)) {
|
|
123
|
+
const client = new AgentReliabilityClient();
|
|
124
|
+
const diagnosis = client.diagnose();
|
|
125
|
+
|
|
126
|
+
if (argv.includes('--json')) {
|
|
127
|
+
console.log(JSON.stringify(diagnosis, null, 2));
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
console.log('=== Agent Reliability Integration Status ===');
|
|
132
|
+
console.log(`Status: ${diagnosis.status}`);
|
|
133
|
+
console.log(`Integration: ${diagnosis.integration}`);
|
|
134
|
+
console.log(`Issuer: ${diagnosis.details.issuer}`);
|
|
135
|
+
console.log(`Tier: ${diagnosis.details.tier}`);
|
|
136
|
+
console.log(`Token: ${diagnosis.details.tokenMasked}`);
|
|
137
|
+
console.log(`Expires: ${diagnosis.details.expiresAt}`);
|
|
138
|
+
console.log(`Source: ${diagnosis.details.tokenSource}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (require.main === module) {
|
|
142
|
+
run();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
module.exports = {
|
|
146
|
+
AgentReliabilityClient,
|
|
147
|
+
maskToken
|
|
148
|
+
};
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* scripts/apple-minions-idle-compute-steal.js
|
|
6
|
+
*
|
|
7
|
+
* FORMAT & Architecture Steal combining:
|
|
8
|
+
* 1. Apple Machine Learning Research "Minions: A Dynamic and Distributed Virtual GPU Cloud
|
|
9
|
+
* Built on Idle Apple Silicon Devices" (arXiv:2610.12970, Jianhua Li et al., Oct 2026)
|
|
10
|
+
* - Pull-based Worker Executor (survives MacBook lid-close / sleep without breaking push schedulers)
|
|
11
|
+
* - Subtask Lease Watchdog (re-queues orphaned subtasks when an idle Mac disconnects mid-flight)
|
|
12
|
+
* - Tenant/Team-Scoped Metadata Isolation (prevents cross-team data leakage across shared nodes)
|
|
13
|
+
* - Thermal / Swap Thrash Preflight (`mac-thrash-guard` integration before claiming subtasks)
|
|
14
|
+
* 2. Apple Silicon Unified Memory Architecture (UMA) "System One" Single-Pass Decision Routing
|
|
15
|
+
* (`Laya-MLX` 13.4ms single-pass logit scoring, `jev-visual` multimodal logit scoring, and
|
|
16
|
+
* zero-allocation deterministic `route()` in code — never calling cloud `api.typesafe.ai`
|
|
17
|
+
* or letting an LLM emit `permissionDecision` per `typesafe-typed-questions-not-clone`).
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const os = require('node:os');
|
|
21
|
+
const crypto = require('node:crypto');
|
|
22
|
+
|
|
23
|
+
const MINIONS_STEAL_MAP = {
|
|
24
|
+
paper: {
|
|
25
|
+
title: 'Minions: A Dynamic and Distributed Virtual GPU Cloud Built on Idle Apple Silicon Devices',
|
|
26
|
+
arxiv: 'arXiv:2610.12970',
|
|
27
|
+
authors: ['Jianhua Li', 'Yun Xing', 'Girisha De Silva', 'Ryan Flint', 'Kai Yuan', 'Sean Suchter'],
|
|
28
|
+
published: '2026-10',
|
|
29
|
+
},
|
|
30
|
+
systemOneUmaIntersection: {
|
|
31
|
+
layaMlx: 'mizorewww/laya-mlx (Convai Laya ported to Apple MLX — single-pass logit scoring on UMA, zero cloud API tax)',
|
|
32
|
+
jevVisual: 'jev-visual (multimodal visual candidate scoring directly from logits on Apple Silicon UMA)',
|
|
33
|
+
zeroAllocRouter: 'Deterministic single-pass typed battery + code-owned route() in <0.1ms on Apple Silicon CPU/UMA',
|
|
34
|
+
},
|
|
35
|
+
decisions: {
|
|
36
|
+
adopt: [
|
|
37
|
+
'Pull-based idle-Mac subtask claiming (`claimNextIdleSubtask`) so laptop lid-close or sleep never stalls a push scheduler',
|
|
38
|
+
'Watchdog lease expiration & automatic re-queue (`reclaimExpiredSubtasks`) when a node disconnects mid-inference',
|
|
39
|
+
'Four-field tenant scope isolation (`entityId`, `projectId`, `processId`, `sessionId`) on every queued subtask so sensitive repo data never crosses trust boundaries',
|
|
40
|
+
'Single-pass System-One deterministic hazard battery (`evaluateSystemOneUmaBattery`) executing in <0.1ms with zero cloud token spend',
|
|
41
|
+
],
|
|
42
|
+
adapt: [
|
|
43
|
+
'Gate worker subtask pulls behind local Apple Silicon thermal & memory-pressure preflight (`checkAppleSiliconIdleHealth`) so background embedding/DPO jobs never freeze foreground coding sessions',
|
|
44
|
+
],
|
|
45
|
+
drop: [
|
|
46
|
+
'Centralized multi-tenant Postgres cluster requirement (we use local SQLite/JSONL or Hotdata DataFusion snapshots)',
|
|
47
|
+
'Cloud TypeSafe Jev API (`api.typesafe.ai` / `typesafe-sdk`) or model-emitted `permissionDecision` (code always owns `route()`)',
|
|
48
|
+
'Unverified distributed internet-wide training claims (Minions is strictly inference: Hugging Face embeddings + local Ollama completions)',
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Check whether the local Apple Silicon Mac is healthy and idle enough to pull a background Minion subtask.
|
|
55
|
+
*/
|
|
56
|
+
function checkAppleSiliconIdleHealth(metrics = {}) {
|
|
57
|
+
const cpuCount = metrics.cpuCount || os.cpus().length || 8;
|
|
58
|
+
const loadAvg1m = metrics.loadAvg1m !== undefined ? Number(metrics.loadAvg1m) : os.loadavg()[0];
|
|
59
|
+
const freeMemBytes = metrics.freeMemBytes !== undefined ? Number(metrics.freeMemBytes) : os.freemem();
|
|
60
|
+
const totalMemBytes = metrics.totalMemBytes !== undefined ? Number(metrics.totalMemBytes) : os.totalmem();
|
|
61
|
+
const thermalState = String(metrics.thermalState || 'nominal').toLowerCase();
|
|
62
|
+
|
|
63
|
+
const loadRatio = Number((loadAvg1m / cpuCount).toFixed(3));
|
|
64
|
+
const freeMemRatio = Number((freeMemBytes / Math.max(1, totalMemBytes)).toFixed(3));
|
|
65
|
+
|
|
66
|
+
const reasons = [];
|
|
67
|
+
if (thermalState === 'critical' || thermalState === 'serious') {
|
|
68
|
+
reasons.push(`thermal_throttling:${thermalState}`);
|
|
69
|
+
}
|
|
70
|
+
if (loadRatio > 0.85) {
|
|
71
|
+
reasons.push(`high_cpu_load:${loadRatio}`);
|
|
72
|
+
}
|
|
73
|
+
if (freeMemRatio < 0.05) {
|
|
74
|
+
reasons.push(`memory_pressure_low_free_ram:${freeMemRatio}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
eligibleForPull: reasons.length === 0,
|
|
79
|
+
arch: process.arch,
|
|
80
|
+
platform: process.platform,
|
|
81
|
+
cpuCount,
|
|
82
|
+
loadRatio,
|
|
83
|
+
freeMemRatio,
|
|
84
|
+
thermalState,
|
|
85
|
+
reasons,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* System-One Single-Pass Typed Decision Battery on Apple Silicon UMA (<0.1ms).
|
|
91
|
+
* Evaluates a set of atomic hazard predicates in one pass; code owns `route()`.
|
|
92
|
+
*/
|
|
93
|
+
function evaluateSystemOneUmaBattery({
|
|
94
|
+
toolName = '',
|
|
95
|
+
commandOrPayload = '',
|
|
96
|
+
visualContextConfidence = 1.0,
|
|
97
|
+
} = {}) {
|
|
98
|
+
const startNs = process.hrtime.bigint();
|
|
99
|
+
const raw = `${toolName} ${typeof commandOrPayload === 'string' ? commandOrPayload : JSON.stringify(commandOrPayload)}`;
|
|
100
|
+
|
|
101
|
+
const battery = {
|
|
102
|
+
destructiveGitOrFs: {
|
|
103
|
+
noul: /(?:\bgit\s+push\s+--force\b|\bgit\s+reset\s+--hard\b|\brm\s+-rf\s+(?:\/|~|\$HOME))/i.test(raw) ? 1.0 : 0.0,
|
|
104
|
+
source: 'deterministic_uma',
|
|
105
|
+
},
|
|
106
|
+
secretExfiltration: {
|
|
107
|
+
noul: /\b(?:sk-[a-zA-Z0-9]{20,}|AKIA[0-9A-Z]{16}|ghp_[a-zA-Z0-9]{36}|xoxb-[0-9A-Za-z-]+)\b/.test(raw) ? 1.0 : 0.0,
|
|
108
|
+
source: 'deterministic_uma',
|
|
109
|
+
},
|
|
110
|
+
unboundedSqlWrite: {
|
|
111
|
+
noul: /(?:\bDROP\s+TABLE\b|\bTRUNCATE\s+TABLE\b|\bDELETE\s+FROM\s+\w+\s*(?:;|$))/i.test(raw) ? 1.0 : 0.0,
|
|
112
|
+
source: 'deterministic_uma',
|
|
113
|
+
},
|
|
114
|
+
sharedCheckoutDirtyAdd: {
|
|
115
|
+
noul: /\bgit\s+add\s+(?:-A|--all|\.)\b/.test(raw) ? 0.65 : 0.0,
|
|
116
|
+
source: 'deterministic_uma',
|
|
117
|
+
},
|
|
118
|
+
visualUiDrift: {
|
|
119
|
+
noul: Number(visualContextConfidence) < 0.5 ? 0.7 : 0.0,
|
|
120
|
+
source: 'jev_visual_logit_uma',
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const maxNoul = Math.max(...Object.values(battery).map(b => b.noul));
|
|
125
|
+
let route = 'pass';
|
|
126
|
+
if (maxNoul >= 0.9) {
|
|
127
|
+
route = 'block';
|
|
128
|
+
} else if (maxNoul >= 0.5) {
|
|
129
|
+
route = 'review';
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const latencyMs = Number((Number(process.hrtime.bigint() - startNs) / 1e6).toFixed(3));
|
|
133
|
+
return {
|
|
134
|
+
codeOwnsRoute: true,
|
|
135
|
+
route,
|
|
136
|
+
allowed: route === 'pass',
|
|
137
|
+
maxNoul,
|
|
138
|
+
latencyMs,
|
|
139
|
+
battery,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Pull-based Minion Subtask Queue with Watchdog Lease Recovery and 4-Field Tenant Scope Isolation.
|
|
145
|
+
*/
|
|
146
|
+
class AppleMinionQueue {
|
|
147
|
+
constructor({ leaseTtlMs = 30000 } = {}) {
|
|
148
|
+
this.leaseTtlMs = leaseTtlMs;
|
|
149
|
+
this.subtasks = [];
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
enqueue({ id, workloadType = 'embedding', payload = {}, scope = {} }) {
|
|
153
|
+
if (!scope.entityId || !scope.projectId || !scope.processId || !scope.sessionId) {
|
|
154
|
+
throw new Error('Minion tenant isolation requires complete 4-field scope (entityId, projectId, processId, sessionId)');
|
|
155
|
+
}
|
|
156
|
+
if (!['embedding', 'ollama_completion', 'system_one_battery', 'dpo_distill'].includes(workloadType)) {
|
|
157
|
+
throw new Error(`Unsupported Minion workloadType '${workloadType}' (must be inference/distillation, not raw unverified training)`);
|
|
158
|
+
}
|
|
159
|
+
const subtask = {
|
|
160
|
+
id: id || `minion_${crypto.randomBytes(6).toString('hex')}`,
|
|
161
|
+
workloadType,
|
|
162
|
+
payload,
|
|
163
|
+
scope: { ...scope },
|
|
164
|
+
status: 'pending',
|
|
165
|
+
workerId: null,
|
|
166
|
+
leasedAtMs: null,
|
|
167
|
+
attempts: 0,
|
|
168
|
+
};
|
|
169
|
+
this.subtasks.push(subtask);
|
|
170
|
+
return subtask;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
reclaimExpiredSubtasks(nowMs = Date.now()) {
|
|
174
|
+
let reclaimed = 0;
|
|
175
|
+
for (const task of this.subtasks) {
|
|
176
|
+
if (task.status === 'leased' && task.leasedAtMs && (nowMs - task.leasedAtMs) > this.leaseTtlMs) {
|
|
177
|
+
task.status = 'pending';
|
|
178
|
+
task.workerId = null;
|
|
179
|
+
task.leasedAtMs = null;
|
|
180
|
+
reclaimed++;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return reclaimed;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
claimNextIdleSubtask({ workerId, workerScope, healthMetrics = {}, nowMs = Date.now() }) {
|
|
187
|
+
this.reclaimExpiredSubtasks(nowMs);
|
|
188
|
+
const health = checkAppleSiliconIdleHealth(healthMetrics);
|
|
189
|
+
if (!health.eligibleForPull) {
|
|
190
|
+
return { claimed: false, reason: `worker_not_idle:${health.reasons.join(',')}`, health };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const candidate = this.subtasks.find(
|
|
194
|
+
t =>
|
|
195
|
+
t.status === 'pending' &&
|
|
196
|
+
workerScope &&
|
|
197
|
+
t.scope.entityId === workerScope.entityId &&
|
|
198
|
+
t.scope.projectId === workerScope.projectId &&
|
|
199
|
+
t.scope.processId === workerScope.processId &&
|
|
200
|
+
t.scope.sessionId === workerScope.sessionId
|
|
201
|
+
);
|
|
202
|
+
if (!candidate) {
|
|
203
|
+
return { claimed: false, reason: 'no_matching_scoped_subtask', health };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
candidate.status = 'leased';
|
|
207
|
+
candidate.workerId = workerId;
|
|
208
|
+
candidate.leasedAtMs = nowMs;
|
|
209
|
+
candidate.attempts += 1;
|
|
210
|
+
return { claimed: true, subtask: candidate, health };
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
completeSubtask(subtaskId, workerId, result = {}) {
|
|
214
|
+
const task = this.subtasks.find(t => t.id === subtaskId && t.workerId === workerId);
|
|
215
|
+
if (!task) return { ok: false, reason: 'lease_not_owned' };
|
|
216
|
+
task.status = 'completed';
|
|
217
|
+
task.result = result;
|
|
218
|
+
return { ok: true, subtask: task };
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Pre-action Minion Data Diode: scrubs secrets and PII from payloads before distributed execution.
|
|
224
|
+
*/
|
|
225
|
+
function redactMinionPayload(payload = '') {
|
|
226
|
+
let text = typeof payload === 'string' ? payload : JSON.stringify(payload);
|
|
227
|
+
const secretPatterns = [
|
|
228
|
+
/\b(?:sk-[a-zA-Z0-9]{20,})\b/g,
|
|
229
|
+
/\b(?:ghp_[a-zA-Z0-9]{36})\b/g,
|
|
230
|
+
/\b(?:xoxb-[0-9A-Za-z-]+)\b/g,
|
|
231
|
+
/\b(?:AKIA[0-9A-Z]{16})\b/g,
|
|
232
|
+
/\bBearer\s+[a-zA-Z0-9_.-]{20,}\b/g,
|
|
233
|
+
];
|
|
234
|
+
for (const pat of secretPatterns) {
|
|
235
|
+
text = text.replace(pat, '[REDACTED_SECRET]');
|
|
236
|
+
}
|
|
237
|
+
return text;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Execute a local workload on Apple Silicon via local Ollama or deterministic battery.
|
|
242
|
+
*/
|
|
243
|
+
async function executeAppleMinionLocalWorkload({
|
|
244
|
+
workloadType = 'ollama_completion',
|
|
245
|
+
model = 'qwen2.5:0.5b',
|
|
246
|
+
prompt = '',
|
|
247
|
+
input = '',
|
|
248
|
+
endpoint = 'http://127.0.0.1:11434',
|
|
249
|
+
healthMetrics = {},
|
|
250
|
+
} = {}) {
|
|
251
|
+
const health = checkAppleSiliconIdleHealth(healthMetrics);
|
|
252
|
+
if (!health.eligibleForPull) {
|
|
253
|
+
return {
|
|
254
|
+
success: false,
|
|
255
|
+
reason: `apple_silicon_busy:${health.reasons.join(',')}`,
|
|
256
|
+
health,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const cleanPrompt = redactMinionPayload(prompt || input || '');
|
|
261
|
+
const startNs = process.hrtime.bigint();
|
|
262
|
+
|
|
263
|
+
if (workloadType === 'system_one_battery') {
|
|
264
|
+
const battery = evaluateSystemOneUmaBattery({ toolName: 'MinionTask', commandOrPayload: cleanPrompt });
|
|
265
|
+
return {
|
|
266
|
+
success: true,
|
|
267
|
+
workloadType,
|
|
268
|
+
model: 'uma_deterministic',
|
|
269
|
+
cloudCostDollars: 0.0,
|
|
270
|
+
output: battery,
|
|
271
|
+
receiptSha256: crypto.createHash('sha256').update(JSON.stringify(battery)).digest('hex'),
|
|
272
|
+
health,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Local Ollama execution via HTTP
|
|
277
|
+
const http = require('node:http');
|
|
278
|
+
const path = workloadType === 'embedding' ? '/api/embeddings' : '/api/generate';
|
|
279
|
+
const postData = JSON.stringify(
|
|
280
|
+
workloadType === 'embedding'
|
|
281
|
+
? { model, prompt: cleanPrompt }
|
|
282
|
+
: { model, prompt: cleanPrompt, stream: false }
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
return new Promise((resolve) => {
|
|
286
|
+
try {
|
|
287
|
+
const url = new URL(endpoint);
|
|
288
|
+
const req = http.request(
|
|
289
|
+
{
|
|
290
|
+
hostname: url.hostname,
|
|
291
|
+
port: url.port || 11434,
|
|
292
|
+
path,
|
|
293
|
+
method: 'POST',
|
|
294
|
+
headers: {
|
|
295
|
+
'Content-Type': 'application/json',
|
|
296
|
+
'Content-Length': Buffer.byteLength(postData),
|
|
297
|
+
},
|
|
298
|
+
timeout: 10000,
|
|
299
|
+
},
|
|
300
|
+
(res) => {
|
|
301
|
+
let data = '';
|
|
302
|
+
res.on('data', (chunk) => (data += chunk));
|
|
303
|
+
res.on('end', () => {
|
|
304
|
+
const elapsedMs = Number((Number(process.hrtime.bigint() - startNs) / 1e6).toFixed(2));
|
|
305
|
+
try {
|
|
306
|
+
const parsed = JSON.parse(data);
|
|
307
|
+
const receipt = {
|
|
308
|
+
timestamp: new Date().toISOString(),
|
|
309
|
+
workloadType,
|
|
310
|
+
model,
|
|
311
|
+
elapsedMs,
|
|
312
|
+
cloudCostDollars: 0.0,
|
|
313
|
+
tokenCost: 0,
|
|
314
|
+
status: 'pass',
|
|
315
|
+
};
|
|
316
|
+
const receiptSha256 = crypto.createHash('sha256').update(JSON.stringify(receipt)).digest('hex');
|
|
317
|
+
resolve({
|
|
318
|
+
success: true,
|
|
319
|
+
workloadType,
|
|
320
|
+
model,
|
|
321
|
+
elapsedMs,
|
|
322
|
+
cloudCostDollars: 0.0,
|
|
323
|
+
response: parsed.response || parsed.embedding,
|
|
324
|
+
receiptSha256,
|
|
325
|
+
health,
|
|
326
|
+
});
|
|
327
|
+
} catch (err) {
|
|
328
|
+
resolve({
|
|
329
|
+
success: false,
|
|
330
|
+
reason: `parse_error:${err.message}`,
|
|
331
|
+
raw: data.slice(0, 200),
|
|
332
|
+
health,
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
);
|
|
338
|
+
req.on('error', (err) => {
|
|
339
|
+
resolve({
|
|
340
|
+
success: false,
|
|
341
|
+
reason: `ollama_connect_error:${err.message}`,
|
|
342
|
+
health,
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
req.on('timeout', () => {
|
|
346
|
+
req.destroy();
|
|
347
|
+
resolve({
|
|
348
|
+
success: false,
|
|
349
|
+
reason: 'ollama_timeout',
|
|
350
|
+
health,
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
req.write(postData);
|
|
354
|
+
req.end();
|
|
355
|
+
} catch (e) {
|
|
356
|
+
resolve({
|
|
357
|
+
success: false,
|
|
358
|
+
reason: `dispatch_error:${e.message}`,
|
|
359
|
+
health,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
async function runCli() {
|
|
366
|
+
const args = process.argv.slice(2);
|
|
367
|
+
const isMapOnly = args.includes('--map-only');
|
|
368
|
+
const isJson = args.includes('--json');
|
|
369
|
+
const isRunLocal = args.includes('--run-local');
|
|
370
|
+
const promptArg = args.find((a) => a.startsWith('--prompt='));
|
|
371
|
+
const prompt = promptArg ? promptArg.split('=')[1] : 'ThumbGate Minions on Apple Silicon: confirm zero cloud cost';
|
|
372
|
+
const modelArg = args.find((a) => a.startsWith('--model='));
|
|
373
|
+
const model = modelArg ? modelArg.split('=')[1] : 'qwen2.5:0.5b';
|
|
374
|
+
|
|
375
|
+
const health = checkAppleSiliconIdleHealth();
|
|
376
|
+
|
|
377
|
+
if (isMapOnly) {
|
|
378
|
+
if (isJson) {
|
|
379
|
+
console.log(JSON.stringify({ map: MINIONS_STEAL_MAP, health }, null, 2));
|
|
380
|
+
} else {
|
|
381
|
+
console.log('=== Apple Minions & Apple Silicon UMA Steal Map ===');
|
|
382
|
+
console.log(`Paper: ${MINIONS_STEAL_MAP.paper.title} (${MINIONS_STEAL_MAP.paper.arxiv})`);
|
|
383
|
+
console.log('Adopt:', MINIONS_STEAL_MAP.decisions.adopt);
|
|
384
|
+
console.log('Health:', health);
|
|
385
|
+
}
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (isRunLocal) {
|
|
390
|
+
const result = await executeAppleMinionLocalWorkload({
|
|
391
|
+
workloadType: 'ollama_completion',
|
|
392
|
+
model,
|
|
393
|
+
prompt,
|
|
394
|
+
});
|
|
395
|
+
if (isJson) {
|
|
396
|
+
console.log(JSON.stringify(result, null, 2));
|
|
397
|
+
} else {
|
|
398
|
+
console.log('=== Apple Minion Local Workload Result ===');
|
|
399
|
+
console.log('Success:', result.success);
|
|
400
|
+
console.log('Model:', result.model);
|
|
401
|
+
console.log('Cloud Cost:', `$${result.cloudCostDollars}`);
|
|
402
|
+
console.log('Elapsed:', `${result.elapsedMs}ms`);
|
|
403
|
+
console.log('Receipt SHA-256:', result.receiptSha256);
|
|
404
|
+
if (result.response) console.log('Response:', result.response.trim());
|
|
405
|
+
}
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const battery = evaluateSystemOneUmaBattery({
|
|
410
|
+
toolName: 'Bash',
|
|
411
|
+
commandOrPayload: 'git push --force origin main',
|
|
412
|
+
});
|
|
413
|
+
console.log(JSON.stringify({ map: MINIONS_STEAL_MAP, health, sampleBattery: battery }, null, 2));
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
if (require.main === module) {
|
|
417
|
+
runCli();
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
module.exports = {
|
|
421
|
+
MINIONS_STEAL_MAP,
|
|
422
|
+
checkAppleSiliconIdleHealth,
|
|
423
|
+
evaluateSystemOneUmaBattery,
|
|
424
|
+
AppleMinionQueue,
|
|
425
|
+
redactMinionPayload,
|
|
426
|
+
executeAppleMinionLocalWorkload,
|
|
427
|
+
};
|
|
428
|
+
|
|
@@ -102,6 +102,12 @@ async function runIteration(opts = {}) {
|
|
|
102
102
|
holdoutCommands: options.holdoutCommands || [],
|
|
103
103
|
timeoutMs,
|
|
104
104
|
cwd: options.cwd,
|
|
105
|
+
iteration: options.iteration,
|
|
106
|
+
totalIterations: options.totalIterations,
|
|
107
|
+
history: options.history,
|
|
108
|
+
enableRRSI: options.enableRRSI,
|
|
109
|
+
lambda: options.lambda,
|
|
110
|
+
stabilityFloor: options.stabilityFloor,
|
|
105
111
|
hypothesisSuffix: research ? `Research query: ${research.query}` : null,
|
|
106
112
|
additionalMetrics: {
|
|
107
113
|
researchQuery: research ? research.query : null,
|
|
@@ -132,6 +138,9 @@ async function runIteration(opts = {}) {
|
|
|
132
138
|
* @param {number} [params.paperLimit] - Max papers to ingest for research context
|
|
133
139
|
* @param {Function} [params.fetchImpl] - Optional fetch implementation override
|
|
134
140
|
* @param {Function} [params.searchPapersImpl] - Optional paper search override
|
|
141
|
+
* @param {boolean} [params.enableRRSI=true] - Enable RRSI regularized proposal and selection
|
|
142
|
+
* @param {number} [params.lambda] - RRSI complexity penalty weight
|
|
143
|
+
* @param {number} [params.stabilityFloor] - RRSI stability floor
|
|
135
144
|
* @returns {Promise<object>} { results, progress }
|
|
136
145
|
*/
|
|
137
146
|
async function runLoop(params) {
|
|
@@ -152,10 +161,20 @@ async function runLoop(params) {
|
|
|
152
161
|
paperLimit: params.paperLimit,
|
|
153
162
|
fetchImpl: params.fetchImpl,
|
|
154
163
|
searchPapersImpl: params.searchPapersImpl,
|
|
164
|
+
iteration: i,
|
|
165
|
+
totalIterations: iterations,
|
|
166
|
+
history: results,
|
|
167
|
+
enableRRSI: params.enableRRSI,
|
|
168
|
+
lambda: params.lambda,
|
|
169
|
+
stabilityFloor: params.stabilityFloor,
|
|
155
170
|
});
|
|
156
171
|
results.push(result);
|
|
157
172
|
if (result.kept) {
|
|
158
|
-
|
|
173
|
+
const regDelta = result.metrics?.rrsi?.regularizedDelta;
|
|
174
|
+
const deltaStr = typeof regDelta === 'number'
|
|
175
|
+
? `reg delta: +${regDelta.toFixed(4)}`
|
|
176
|
+
: `delta: +${(result.delta || 0).toFixed(4)}`;
|
|
177
|
+
console.log(` ✓ KEPT: ${result.name} (${deltaStr})`);
|
|
159
178
|
} else if (result.skipped) {
|
|
160
179
|
console.log(` ⊘ SKIPPED: ${result.reason}`);
|
|
161
180
|
} else {
|
package/scripts/billing.js
CHANGED
|
@@ -3004,7 +3004,6 @@ function buildCheckoutSessionPayload({ successUrl, cancelUrl, customerEmail, che
|
|
|
3004
3004
|
const sessionPayload = {
|
|
3005
3005
|
success_url: successUrl,
|
|
3006
3006
|
cancel_url: cancelUrl,
|
|
3007
|
-
payment_method_types: ['card', 'link'],
|
|
3008
3007
|
mode: pack ? 'payment' : 'subscription',
|
|
3009
3008
|
line_items: lineItems,
|
|
3010
3009
|
allow_promotion_codes: true,
|