thumbgate 1.39.0 → 1.40.1
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/craft-playbook-gate/SKILL.md +51 -0
- package/.agents/skills/qwenwork-policy-group-honesty-not-clone/SKILL.md +36 -0
- package/.claude-plugin/plugin.json +1 -1
- package/.well-known/llms.txt +2 -2
- package/.well-known/mcp/server-card.json +1 -1
- package/README.md +11 -5
- package/adapters/claude/.mcp.json +6 -2
- package/adapters/codex/config.toml +5 -0
- package/adapters/forge/forge.yaml +4 -4
- 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 +104 -7
- package/adapters/opencode/opencode.json +1 -1
- package/adapters/strands/strands-middleware.js +31 -4
- package/bin/cli.js +191 -54
- package/config/brand-standards.json +131 -0
- package/config/gates/default.json +18 -1
- package/config/github-about.json +1 -1
- package/config/mcp-allowlists.json +16 -3
- package/config/merge-quality-checks.json +3 -1
- package/config/post-deploy-marketing-pages.json +4 -4
- package/config/schemas/task-outcome-receipt.schema.json +9 -0
- package/hooks/hooks.json +24 -0
- package/openapi/openapi.yaml +7 -3
- package/package.json +87 -33
- package/public/about.html +2 -2
- package/public/admin.html +771 -0
- package/public/agent-manager.html +3 -3
- package/public/agents-cost-savings.html +1 -1
- package/public/ai-malpractice-prevention.html +12 -12
- package/public/architecture.html +0 -1
- package/public/assets/diagrams/decision.svg +3 -3
- package/public/assets/diagrams/hero-thumbs.svg +2 -4
- package/public/blog/2026-10-05-why-3-days-of-triage-wont-save-ai-speed-code.html +1 -1
- package/public/blog/2026-10-09-your-code-got-a-third-author-governance.html +1 -1
- package/public/blog/git-at-agent-scale.html +2 -2
- package/public/blog/inside-your-boundary.html +1 -1
- package/public/blog/process-over-outcome-gates.html +1 -1
- package/public/case-studies.html +5 -6
- package/public/codex-enterprise.html +1 -1
- package/public/codex-plugin.html +1 -1
- package/public/dashboard.html +775 -483
- package/public/diagnostic.html +15 -10
- package/public/enterprise-governance.html +26 -174
- package/public/eval-scorecard.html +3 -4
- package/public/eval-scorecard.json +2 -2
- package/public/evaluations.html +0 -1
- package/public/founders.html +3 -3
- package/public/gaming-playbook.html +4 -4
- package/public/guide.html +3 -5
- package/public/index.html +302 -97
- package/public/install.html +16 -10
- package/public/js/buyer-intent.js +49 -8
- package/public/lessons.html +246 -83
- package/public/numbers.html +32 -33
- package/public/operator-framework.html +44 -72
- package/public/peter.html +3 -3
- package/public/platform-partners.html +1 -1
- package/public/pricing.html +163 -66
- package/public/pro.html +3 -1
- package/public/project-switcher.js +76 -0
- package/public/whitepaper.html +1 -2
- package/scripts/action-receipts.js +393 -0
- package/scripts/activation-quickstart.js +15 -3
- package/scripts/activation-tracker.js +280 -3
- package/scripts/agent-action-inventory.js +235 -143
- package/scripts/agent-operations-planner.js +1 -1
- package/scripts/agent-readiness.js +36 -6
- package/scripts/agentic-prompt-pipelines.js +901 -0
- package/scripts/analytics-window.js +7 -1
- package/scripts/async-job-runner.js +66 -11
- package/scripts/audit-trail.js +37 -24
- package/scripts/auto-promote-gates.js +37 -27
- package/scripts/auto-wire-hooks.js +64 -25
- package/scripts/backfill-lesson-scopes.js +122 -0
- package/scripts/billing.js +889 -132
- package/scripts/bot-detection.js +112 -0
- package/scripts/brand-standards-gate.js +571 -0
- package/scripts/chatgpt-ads-readiness-pack.js +1 -1
- package/scripts/cli-demo.js +5 -27
- package/scripts/cli-schema.js +25 -1
- package/scripts/commercial-offer.js +2 -2
- package/scripts/contextfs.js +9 -3
- package/scripts/craft-playbook-gate.js +550 -0
- package/scripts/cross-encoder-reranker.js +4 -0
- package/scripts/dashboard-chat.js +11 -0
- package/scripts/dashboard.js +574 -167
- package/scripts/decision-journal.js +7 -4
- package/scripts/docker-sandbox-planner.js +3 -3
- package/scripts/export-dpo-pairs.js +12 -7
- package/scripts/failure-diagnostics.js +11 -0
- package/scripts/feedback-aggregate.js +4 -0
- package/scripts/feedback-attribution.js +6 -4
- package/scripts/feedback-history-distiller.js +18 -6
- package/scripts/feedback-loop.js +255 -89
- package/scripts/feedback-paths.js +8 -1
- package/scripts/feedback-sanitizer.js +5 -0
- package/scripts/feedback-scope.js +106 -0
- package/scripts/feedback-session.js +8 -2
- package/scripts/filesystem-search.js +13 -8
- package/scripts/financial-control-plane.js +707 -45
- package/scripts/gate-stats.js +38 -5
- package/scripts/gates-engine.js +1326 -240
- package/scripts/generate-eval-scorecard.js +0 -1
- package/scripts/gitlab-sdlc-prompts.js +397 -0
- package/scripts/harness-tool-names.js +31 -5
- package/scripts/hook-runtime.js +10 -0
- package/scripts/hybrid-feedback-context.js +7 -2
- package/scripts/intervention-policy.js +2 -1
- package/scripts/lesson-canonical.js +2 -2
- package/scripts/lesson-db.js +55 -14
- package/scripts/lesson-graph.js +2 -1
- package/scripts/lesson-retrieval.js +95 -9
- package/scripts/lesson-search.js +86 -22
- package/scripts/lesson-synthesis.js +21 -5
- package/scripts/mabl-failure-honesty.js +273 -0
- package/scripts/mailer/index.js +17 -1
- package/scripts/mailer/resend-mailer.js +213 -179
- package/scripts/migrate-project-scope.js +209 -0
- package/scripts/model-distress-detector.js +3 -3
- package/scripts/operational-integrity.js +436 -3
- package/scripts/override-audit.js +2 -0
- package/scripts/owner-admin.js +338 -0
- package/scripts/pr-manager.js +194 -1
- package/scripts/product-feedback.js +35 -0
- package/scripts/progressive-signoff.js +260 -0
- package/scripts/project-catalog.js +243 -0
- package/scripts/project-dashboard.js +61 -0
- package/scripts/project-evidence.js +172 -0
- package/scripts/project-identity.js +182 -0
- package/scripts/project-scope.js +381 -0
- package/scripts/prompt-eval.js +1 -1
- package/scripts/prompt-guard.js +446 -52
- package/scripts/proof-report.js +232 -0
- package/scripts/provider-action-normalizer.js +14 -6
- package/scripts/qwenwork-policy-group.js +413 -0
- package/scripts/rate-limiter.js +41 -0
- package/scripts/secret-redaction.js +171 -25
- package/scripts/secret-scanner.js +101 -42
- package/scripts/self-protection.js +2 -2
- package/scripts/seo-gsd.js +14 -14
- package/scripts/session-context-dedupe.js +66 -0
- package/scripts/settings-hierarchy.js +4 -2
- package/scripts/statusline-meta.js +34 -23
- package/scripts/tailscale-october-access.js +416 -0
- package/scripts/task-outcomes.js +58 -2
- package/scripts/telemetry-analytics.js +260 -16
- package/scripts/thumbgate-search.js +23 -9
- package/scripts/tool-kpi-tracker.js +5 -2
- package/scripts/tool-registry.js +42 -1
- package/scripts/triage-savings-calculator.js +1 -1
- package/scripts/vector-store.js +4 -1
- package/scripts/verified-lessons.js +270 -0
- package/scripts/verify-marketing-pages-deployed.js +2 -2
- package/scripts/workflow-sentinel.js +29 -10
- package/server.json +2 -2
- package/src/api/server.js +2478 -470
- package/src/feedback.js +21 -0
- package/src/hermes-sync-plane.js +2 -1
- package/src/index.js +2 -0
- package/src/lesson-search.js +9 -0
- package/src/mckinsey-top-company-ai-coding.js +493 -0
- package/src/mcp/email-triage-server/index.js +973 -0
- package/src/mcp/email-triage-server/package.json +12 -0
- package/src/mcp/server.js +3 -0
- package/src/mcp-writeguard.js +772 -11
- package/src/openshell-lovable-engine.js +1475 -0
- package/src/task-outcome.js +3 -0
- package/config/evals/agent-safety-eval.json +0 -447
- package/config/evals/retrieval-ranking-golden.json +0 -522
- package/config/progressive/01-wire-only.json +0 -11
- package/config/progressive/02-dashboard-empty-ok.json +0 -10
- package/config/progressive/03-one-lesson.json +0 -10
- package/config/progressive/04-warn-fires.json +0 -11
- package/config/progressive/05-strict-optional.json +0 -11
- package/config/progressive/README.md +0 -15
- package/public/assets/diagrams/agent-integration.png +0 -0
- package/public/assets/diagrams/thumbgate-architecture.png +0 -0
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// October 2026 Tailscale newsletter, as a ThumbGate deny.
|
|
4
|
+
// An agent node does not face the open web, does not open Tailscale SSH,
|
|
5
|
+
// and does not leave a database password in the command. A temporary
|
|
6
|
+
// accept in a Tailscale policy file carries a name and an expiry so it
|
|
7
|
+
// can be removed without rewriting the rest of the file.
|
|
8
|
+
|
|
9
|
+
const GATE = 'tailscale-october-access';
|
|
10
|
+
const EDIT_TOOLS = new Set([
|
|
11
|
+
'edit',
|
|
12
|
+
'search_replace',
|
|
13
|
+
'multiedit',
|
|
14
|
+
'strreplace',
|
|
15
|
+
'str_replace',
|
|
16
|
+
]);
|
|
17
|
+
const ACCEPT_RE = /"action"\s*:\s*"accept"/;
|
|
18
|
+
const NAMED_GRANT_RE = /"name"\s*:/;
|
|
19
|
+
const EXPIRY_RE = /"expiry"\s*:/;
|
|
20
|
+
const DB_PASSWORD_RE = new RegExp([
|
|
21
|
+
String.raw`\bPGPASSWORD\s*=\s*\S+`,
|
|
22
|
+
String.raw`\bMYSQL_PWD\s*=\s*\S+`,
|
|
23
|
+
String.raw`\b(?:DATABASE_URL|MONGO_URL)\s*=\s*\S+:\/\/[^\s:@]+:[^\s@]+@`,
|
|
24
|
+
String.raw`--password(?:=|\s+)\S+`,
|
|
25
|
+
String.raw`(?:postgres|postgresql|mysql|mariadb|mongodb(?:\+srv)?|rediss?):\/\/[^\s:@]+:[^\s@]+@`,
|
|
26
|
+
].join('|'), 'i');
|
|
27
|
+
const ATTACHED_MYSQL_PASSWORD_RE = /(?:^|\s)-p(?!\s)\S+/;
|
|
28
|
+
|
|
29
|
+
function deny(failureReason, message) {
|
|
30
|
+
return {
|
|
31
|
+
decision: 'deny',
|
|
32
|
+
gate: GATE,
|
|
33
|
+
severity: 'critical',
|
|
34
|
+
failureReason,
|
|
35
|
+
message,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const WRAPPERS = new Set(['sudo', 'command', 'exec', 'nohup', 'nice', 'time', 'env']);
|
|
40
|
+
const SHELLS = new Set(['bash', 'sh', 'zsh', 'dash', 'ash']);
|
|
41
|
+
const FLAG_TAKES_VALUE = new Set([
|
|
42
|
+
'-u', '-g', '-h', '-p', '-C', '-T', '-D', '-n',
|
|
43
|
+
'--user', '--group', '--host', '--prompt', '--chdir', '--role', '--adjustment',
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
function commentStartsHere(out) {
|
|
47
|
+
if (!out) return true;
|
|
48
|
+
return /[\s;|&()<>]/.test(out[out.length - 1]);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function stripShellComments(command) {
|
|
52
|
+
const src = String(command || '');
|
|
53
|
+
let out = '';
|
|
54
|
+
let quote = '';
|
|
55
|
+
for (let i = 0; i < src.length; i += 1) {
|
|
56
|
+
const ch = src[i];
|
|
57
|
+
if (quote) {
|
|
58
|
+
out += ch;
|
|
59
|
+
if (ch === '\\' && quote === '"' && i + 1 < src.length) {
|
|
60
|
+
out += src[i + 1];
|
|
61
|
+
i += 1;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (ch === quote) quote = '';
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (ch === '\\' && i + 1 < src.length) {
|
|
68
|
+
out += ch + src[i + 1];
|
|
69
|
+
i += 1;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (ch === '\'' || ch === '"') {
|
|
73
|
+
quote = ch;
|
|
74
|
+
out += ch;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (ch === '#' && commentStartsHere(out)) {
|
|
78
|
+
while (i < src.length && src[i] !== '\n') i += 1;
|
|
79
|
+
out += ' ';
|
|
80
|
+
i -= 1;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
out += ch;
|
|
84
|
+
}
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function simpleCommands(command) {
|
|
89
|
+
const parts = [];
|
|
90
|
+
let buf = '';
|
|
91
|
+
let quote = '';
|
|
92
|
+
const push = () => {
|
|
93
|
+
if (buf.trim()) parts.push(buf.trim());
|
|
94
|
+
buf = '';
|
|
95
|
+
};
|
|
96
|
+
for (let i = 0; i < command.length; i += 1) {
|
|
97
|
+
const ch = command[i];
|
|
98
|
+
if (quote) {
|
|
99
|
+
buf += ch;
|
|
100
|
+
if (ch === '\\' && quote === '"' && i + 1 < command.length) {
|
|
101
|
+
buf += command[i + 1];
|
|
102
|
+
i += 1;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (ch === quote) quote = '';
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (ch === '\\' && i + 1 < command.length) {
|
|
109
|
+
buf += ch + command[i + 1];
|
|
110
|
+
i += 1;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (ch === '\'' || ch === '"') {
|
|
114
|
+
quote = ch;
|
|
115
|
+
buf += ch;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (ch === '\n' || ch === ';' || ch === '|' || ch === '&') {
|
|
119
|
+
push();
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
buf += ch;
|
|
123
|
+
}
|
|
124
|
+
push();
|
|
125
|
+
return parts;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function shellWords(segment) {
|
|
129
|
+
const words = [];
|
|
130
|
+
let buf = '';
|
|
131
|
+
let quote = '';
|
|
132
|
+
const push = () => {
|
|
133
|
+
if (buf.length) words.push(buf);
|
|
134
|
+
buf = '';
|
|
135
|
+
};
|
|
136
|
+
for (let i = 0; i < segment.length; i += 1) {
|
|
137
|
+
const ch = segment[i];
|
|
138
|
+
if (quote) {
|
|
139
|
+
if (ch === '\\' && quote === '"' && i + 1 < segment.length) {
|
|
140
|
+
buf += segment[i + 1];
|
|
141
|
+
i += 1;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (ch === quote) {
|
|
145
|
+
quote = '';
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
buf += ch;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (ch === '\\' && i + 1 < segment.length) {
|
|
152
|
+
buf += segment[i + 1];
|
|
153
|
+
i += 1;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (ch === '\'' || ch === '"') {
|
|
157
|
+
quote = ch;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
if (/\s/.test(ch)) {
|
|
161
|
+
push();
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
buf += ch;
|
|
165
|
+
}
|
|
166
|
+
push();
|
|
167
|
+
return words;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function commandBasename(word) {
|
|
171
|
+
const text = String(word || '');
|
|
172
|
+
const slash = Math.max(text.lastIndexOf('/'), text.lastIndexOf('\\'));
|
|
173
|
+
return slash >= 0 ? text.slice(slash + 1) : text;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function commandArgv(words) {
|
|
177
|
+
let i = 0;
|
|
178
|
+
const skipAssignments = () => {
|
|
179
|
+
while (i < words.length && /^[A-Za-z_][A-Za-z0-9_]*=/.test(words[i])) i += 1;
|
|
180
|
+
};
|
|
181
|
+
skipAssignments();
|
|
182
|
+
while (i < words.length && WRAPPERS.has(commandBasename(words[i]).toLowerCase())) {
|
|
183
|
+
i += 1;
|
|
184
|
+
while (i < words.length && words[i].startsWith('-')) {
|
|
185
|
+
const flag = words[i];
|
|
186
|
+
i += 1;
|
|
187
|
+
if (!flag.includes('=') && FLAG_TAKES_VALUE.has(flag) && i < words.length && !words[i].startsWith('-')) {
|
|
188
|
+
i += 1;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
skipAssignments();
|
|
192
|
+
}
|
|
193
|
+
return words.slice(i);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function nestedCommandText(argv) {
|
|
197
|
+
const base = commandBasename(argv[0] || '').toLowerCase();
|
|
198
|
+
if (base === 'eval') return argv.slice(1).join(' ');
|
|
199
|
+
if (!SHELLS.has(base)) return '';
|
|
200
|
+
for (let i = 1; i < argv.length; i += 1) {
|
|
201
|
+
const arg = argv[i];
|
|
202
|
+
if (arg === '-c' || arg === '--command' || /^-[^-]*c/.test(arg)) return argv[i + 1] || '';
|
|
203
|
+
}
|
|
204
|
+
return '';
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function matchingParen(segment, openAt) {
|
|
208
|
+
let depth = 0;
|
|
209
|
+
let quote = '';
|
|
210
|
+
for (let i = openAt; i < segment.length; i += 1) {
|
|
211
|
+
const ch = segment[i];
|
|
212
|
+
if (quote) {
|
|
213
|
+
if (ch === '\\' && quote === '"' && i + 1 < segment.length) {
|
|
214
|
+
i += 1;
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (ch === quote) quote = '';
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
if (ch === '\\' && i + 1 < segment.length) {
|
|
221
|
+
i += 1;
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if (ch === '\'' || ch === '"') {
|
|
225
|
+
quote = ch;
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (ch === '(') depth += 1;
|
|
229
|
+
if (ch === ')') {
|
|
230
|
+
depth -= 1;
|
|
231
|
+
if (depth === 0) return i;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return -1;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function takeSubstitution(segment, i, found) {
|
|
238
|
+
const ch = segment[i];
|
|
239
|
+
if (ch === '`') {
|
|
240
|
+
const end = segment.indexOf('`', i + 1);
|
|
241
|
+
if (end < 0) return segment.length;
|
|
242
|
+
found.push(segment.slice(i + 1, end));
|
|
243
|
+
return end;
|
|
244
|
+
}
|
|
245
|
+
if (ch === '$' && segment[i + 1] === '(') {
|
|
246
|
+
const end = matchingParen(segment, i + 1);
|
|
247
|
+
if (end < 0) return segment.length;
|
|
248
|
+
found.push(segment.slice(i + 2, end));
|
|
249
|
+
return end;
|
|
250
|
+
}
|
|
251
|
+
return i;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function commandSubstitutions(segment) {
|
|
255
|
+
const found = [];
|
|
256
|
+
let quote = '';
|
|
257
|
+
for (let i = 0; i < segment.length; i += 1) {
|
|
258
|
+
const ch = segment[i];
|
|
259
|
+
if (quote === '\'') {
|
|
260
|
+
if (ch === '\'') quote = '';
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (ch === '\\' && i + 1 < segment.length && quote !== '\'') {
|
|
264
|
+
i += 1;
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
if (quote === '"') {
|
|
268
|
+
if (ch === '"') quote = '';
|
|
269
|
+
else i = takeSubstitution(segment, i, found);
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (ch === '\'' || ch === '"') {
|
|
273
|
+
quote = ch;
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
i = takeSubstitution(segment, i, found);
|
|
277
|
+
}
|
|
278
|
+
return found;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function isPolicyPath(filePath) {
|
|
282
|
+
const normalized = String(filePath || '').replace(/\\/g, '/');
|
|
283
|
+
return /(?:^|\/)(?:acl|policy)\.hujson$/i.test(normalized)
|
|
284
|
+
|| /(?:^|\/)tailscale\/[^/]+\.(?:json|hujson)$/i.test(normalized);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function editedPath(source) {
|
|
288
|
+
if (!source || typeof source !== 'object') return '';
|
|
289
|
+
return source.file_path || source.path || source.filePath || '';
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function editPairs(toolInput) {
|
|
293
|
+
const file = editedPath(toolInput);
|
|
294
|
+
const edits = Array.isArray(toolInput.edits) ? toolInput.edits : null;
|
|
295
|
+
if (edits) {
|
|
296
|
+
return edits.map((edit) => ({
|
|
297
|
+
file: editedPath(edit) || file,
|
|
298
|
+
oldText: edit.old_string || edit.oldString || '',
|
|
299
|
+
newText: edit.new_string || edit.newString || '',
|
|
300
|
+
}));
|
|
301
|
+
}
|
|
302
|
+
return [{
|
|
303
|
+
file,
|
|
304
|
+
oldText: toolInput.old_string || toolInput.oldString || '',
|
|
305
|
+
newText: toolInput.new_string || toolInput.newString || '',
|
|
306
|
+
}];
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function grantDeny(pair) {
|
|
310
|
+
if (!isPolicyPath(pair.file)) return null;
|
|
311
|
+
const newText = String(pair.newText || '');
|
|
312
|
+
if (!ACCEPT_RE.test(newText)) return null;
|
|
313
|
+
if (NAMED_GRANT_RE.test(newText) && EXPIRY_RE.test(newText)) return null;
|
|
314
|
+
return deny(
|
|
315
|
+
'grant_not_removable',
|
|
316
|
+
`Denied edit of ${pair.file}: an accept grant needs a name and an expiry so it can be removed without rewriting the rest of the file.`,
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function tailscaleSshEnabled(args) {
|
|
321
|
+
const rest = args.slice(1);
|
|
322
|
+
const sub = tailscaleSubcommand(args);
|
|
323
|
+
if (sub.toLowerCase() === 'ssh') return true;
|
|
324
|
+
if (!/^(up|set)$/i.test(sub)) return false;
|
|
325
|
+
for (let i = 0; i < rest.length; i += 1) {
|
|
326
|
+
const arg = rest[i];
|
|
327
|
+
if (arg.toLowerCase() !== '--ssh' && !/^--ssh=/i.test(arg)) continue;
|
|
328
|
+
if (/^--ssh=false$/i.test(arg)) return false;
|
|
329
|
+
if (arg.toLowerCase() === '--ssh' && String(rest[i + 1] || '').toLowerCase() === 'false') return false;
|
|
330
|
+
return true;
|
|
331
|
+
}
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function tailscaleSubcommand(argv) {
|
|
336
|
+
const rest = argv.slice(1);
|
|
337
|
+
let cursor = 0;
|
|
338
|
+
while (cursor < rest.length && rest[cursor].startsWith('-')) cursor += 1;
|
|
339
|
+
return rest[cursor] || '';
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function tailscaleInvocationDeny(argv) {
|
|
343
|
+
if (commandBasename(argv[0] || '').toLowerCase() !== 'tailscale') return null;
|
|
344
|
+
if (tailscaleSubcommand(argv).toLowerCase() === 'funnel') {
|
|
345
|
+
return deny(
|
|
346
|
+
'public_agent_node',
|
|
347
|
+
'Denied tailscale funnel: an agent node does not face the open web.',
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
if (tailscaleSshEnabled(argv)) {
|
|
351
|
+
return deny(
|
|
352
|
+
'tailscale_ssh',
|
|
353
|
+
'Denied Tailscale SSH: the agent does not open that session. A normal ssh binary is a different command.',
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function shellInvocationDeny(command, depth) {
|
|
360
|
+
if (depth > 4 || !String(command || '').trim()) return null;
|
|
361
|
+
const body = stripShellComments(command);
|
|
362
|
+
for (const segment of simpleCommands(body)) {
|
|
363
|
+
for (const nested of commandSubstitutions(segment)) {
|
|
364
|
+
const inner = shellInvocationDeny(nested, depth + 1);
|
|
365
|
+
if (inner) return inner;
|
|
366
|
+
}
|
|
367
|
+
const argv = commandArgv(shellWords(segment));
|
|
368
|
+
const direct = tailscaleInvocationDeny(argv);
|
|
369
|
+
if (direct) return direct;
|
|
370
|
+
const nested = nestedCommandText(argv);
|
|
371
|
+
if (nested) {
|
|
372
|
+
const inner = shellInvocationDeny(nested, depth + 1);
|
|
373
|
+
if (inner) return inner;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return null;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function shellCommand(view) {
|
|
380
|
+
if (view && typeof view.command === 'string' && view.command.trim()) return view.command;
|
|
381
|
+
const input = view && view.toolInput;
|
|
382
|
+
if (!input || typeof input !== 'object') return '';
|
|
383
|
+
if (typeof input.command === 'string') return input.command;
|
|
384
|
+
if (typeof input.cmd === 'string') return input.cmd;
|
|
385
|
+
return '';
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function evaluateTailscaleOctoberAccess(view = {}) {
|
|
389
|
+
const tool = String(view.toolName || '').toLowerCase();
|
|
390
|
+
if (EDIT_TOOLS.has(tool)) {
|
|
391
|
+
const toolInput = view.toolInput && typeof view.toolInput === 'object' ? view.toolInput : {};
|
|
392
|
+
for (const pair of editPairs(toolInput)) {
|
|
393
|
+
const result = grantDeny(pair);
|
|
394
|
+
if (result) return result;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
const command = shellCommand(view);
|
|
398
|
+
const body = stripShellComments(command);
|
|
399
|
+
if (!body.trim()) return null;
|
|
400
|
+
const invocation = shellInvocationDeny(command, 0);
|
|
401
|
+
if (invocation) return invocation;
|
|
402
|
+
const attachedMysqlPassword = /\b(?:mysql|mariadb)\b/i.test(body)
|
|
403
|
+
&& ATTACHED_MYSQL_PASSWORD_RE.test(body);
|
|
404
|
+
if (DB_PASSWORD_RE.test(body) || attachedMysqlPassword) {
|
|
405
|
+
return deny(
|
|
406
|
+
'shared_db_password',
|
|
407
|
+
'Denied database credential in the command: a password does not belong on the laptop. Use an identity that is not pasted into the shell.',
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
module.exports = {
|
|
414
|
+
GATE,
|
|
415
|
+
evaluateTailscaleOctoberAccess,
|
|
416
|
+
};
|
package/scripts/task-outcomes.js
CHANGED
|
@@ -13,6 +13,7 @@ const crypto = require('node:crypto');
|
|
|
13
13
|
const fs = require('node:fs');
|
|
14
14
|
const path = require('node:path');
|
|
15
15
|
const { getFeedbackPaths } = require('./feedback-paths');
|
|
16
|
+
const { projectForCapture, projectForRecord, matchesProject } = require('./project-identity');
|
|
16
17
|
const { validateToolContract } = require('./tool-contract-validator');
|
|
17
18
|
|
|
18
19
|
const OUTCOMES_FILE = 'task-outcome-receipts.jsonl';
|
|
@@ -64,6 +65,7 @@ function normalizeTaskOutcome(input = {}, now = new Date()) {
|
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
removeUndefined(receipt);
|
|
68
|
+
downgradeUnconfirmedCompletion(input, receipt);
|
|
67
69
|
const verdict = evaluateWorkingVerdict(receipt);
|
|
68
70
|
receipt.working = verdict.working;
|
|
69
71
|
receipt.workingReasons = verdict.reasons;
|
|
@@ -88,6 +90,34 @@ function normalizeTaskOutcome(input = {}, now = new Date()) {
|
|
|
88
90
|
return receipt;
|
|
89
91
|
}
|
|
90
92
|
|
|
93
|
+
function downgradeUnconfirmedCompletion(input, receipt) {
|
|
94
|
+
const exhausted = input.budgetExhausted === true
|
|
95
|
+
|| input.budgetExhausted === 1
|
|
96
|
+
|| input.budgetExhausted === 'true';
|
|
97
|
+
if (input.status !== 'completed' && !exhausted) return;
|
|
98
|
+
let goal;
|
|
99
|
+
try {
|
|
100
|
+
const { evaluateOneShotGoalDone, oneShotLiveGoalInput } = require('./action-receipts');
|
|
101
|
+
goal = evaluateOneShotGoalDone(oneShotLiveGoalInput(input));
|
|
102
|
+
} catch {
|
|
103
|
+
goal = { status: 'failed', done: false, reason: 'control_unreadable' };
|
|
104
|
+
}
|
|
105
|
+
if (!goal || goal.done) return;
|
|
106
|
+
// A receipt that is already not working keeps its status. Flipping it
|
|
107
|
+
// to failed turns verification_failed into status_failed. A completion
|
|
108
|
+
// that would otherwise count, or one whose budget is gone, does not.
|
|
109
|
+
if (!exhausted && goal.reason !== 'control_unreadable' && !evaluateWorkingVerdict(receipt).working) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
receipt.status = 'failed';
|
|
113
|
+
if (!isPlainObject(receipt.metadata)) receipt.metadata = {};
|
|
114
|
+
receipt.metadata.oneShotGoal = {
|
|
115
|
+
status: goal.status,
|
|
116
|
+
reason: goal.reason,
|
|
117
|
+
done: false,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
91
121
|
function evaluateWorkingVerdict(receipt = {}) {
|
|
92
122
|
const reasons = [];
|
|
93
123
|
if (receipt.status !== 'completed') reasons.push(`status_${receipt.status || 'unknown'}`);
|
|
@@ -116,8 +146,9 @@ function recordTaskOutcome(input = {}, options = {}) {
|
|
|
116
146
|
throw error;
|
|
117
147
|
}
|
|
118
148
|
|
|
149
|
+
Object.assign(receipt, projectForCapture({ ...input, ...options }, { hosted: Boolean(options.projectKey || options.hosted || require('./feedback-scope').tenantDataScope() || process.env.RAILWAY_PROJECT_ID || process.env.RAILWAY_ENVIRONMENT) }));
|
|
119
150
|
const outcomesPath = getTaskOutcomesPath(options);
|
|
120
|
-
const existing = readTaskOutcomes(options);
|
|
151
|
+
const existing = readTaskOutcomes({ ...options, projectKey: receipt.projectKey });
|
|
121
152
|
const duplicate = existing.find((entry) => entry.idempotencyKey === receipt.idempotencyKey);
|
|
122
153
|
if (duplicate) {
|
|
123
154
|
if (duplicate.receiptHash !== receipt.receiptHash) {
|
|
@@ -131,6 +162,30 @@ function recordTaskOutcome(input = {}, options = {}) {
|
|
|
131
162
|
fs.mkdirSync(path.dirname(outcomesPath), { recursive: true });
|
|
132
163
|
fs.appendFileSync(outcomesPath, `${JSON.stringify(receipt)}\n`, 'utf8');
|
|
133
164
|
recordOutcomeTrace(receipt, options);
|
|
165
|
+
|
|
166
|
+
// If task outcome succeeded and verified, verify any applied lessons
|
|
167
|
+
try {
|
|
168
|
+
const isSuccess = receipt.status === 'completed' && receipt.verification?.passed === true;
|
|
169
|
+
const lessonsToVerify = Array.isArray(input.appliedLessons)
|
|
170
|
+
? input.appliedLessons
|
|
171
|
+
: Array.isArray(input.lessonIds)
|
|
172
|
+
? input.lessonIds
|
|
173
|
+
: Array.isArray(input.metadata?.appliedLessons)
|
|
174
|
+
? input.metadata.appliedLessons
|
|
175
|
+
: [];
|
|
176
|
+
if (isSuccess && lessonsToVerify.length > 0) {
|
|
177
|
+
const { verifyLesson } = require('./verified-lessons');
|
|
178
|
+
const checkCmd = receipt.verification?.verifier
|
|
179
|
+
|| receipt.verification?.method
|
|
180
|
+
|| (receipt.verification?.evidence && receipt.verification.evidence[0])
|
|
181
|
+
|| 'task outcome verification passed';
|
|
182
|
+
for (const lessonId of lessonsToVerify) {
|
|
183
|
+
verifyLesson(lessonId, checkCmd, options);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
} catch (_verErr) {
|
|
187
|
+
/* lesson verification on task outcome is non-blocking */
|
|
188
|
+
}
|
|
134
189
|
return { recorded: true, duplicate: false, receipt };
|
|
135
190
|
}
|
|
136
191
|
|
|
@@ -149,7 +204,8 @@ function readTaskOutcomes(options = {}) {
|
|
|
149
204
|
.filter(Boolean)
|
|
150
205
|
.flatMap((line) => {
|
|
151
206
|
try {
|
|
152
|
-
|
|
207
|
+
const row = JSON.parse(line);
|
|
208
|
+
return matchesProject(projectForRecord(row), options.projectKey) ? [row] : [];
|
|
153
209
|
} catch {
|
|
154
210
|
return [];
|
|
155
211
|
}
|