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
|
@@ -432,6 +432,393 @@ function reconstructModelVisibleFacts(actionId, options = {}) {
|
|
|
432
432
|
};
|
|
433
433
|
}
|
|
434
434
|
|
|
435
|
+
/**
|
|
436
|
+
* OneShot FORMAT (oneshotagent.com/thesis, 2026-10-04): the model is not the
|
|
437
|
+
* control. These functions quote and reserve before a side effect, and they
|
|
438
|
+
* refuse a worker's own "done". They do not move money and they do not open
|
|
439
|
+
* ThumbGate's $0 agent spend wall. An omitted cash cap is $0.
|
|
440
|
+
*/
|
|
441
|
+
function canonicalOneShotValue(value, seen = new Set()) {
|
|
442
|
+
if (value === null || typeof value !== 'object') {
|
|
443
|
+
if (typeof value === 'bigint' || typeof value === 'function' || typeof value === 'symbol') {
|
|
444
|
+
throw new TypeError('unhashable');
|
|
445
|
+
}
|
|
446
|
+
const encoded = JSON.stringify(value === undefined ? null : value);
|
|
447
|
+
if (typeof encoded !== 'string') throw new TypeError('unhashable');
|
|
448
|
+
return encoded;
|
|
449
|
+
}
|
|
450
|
+
if (seen.has(value)) throw new TypeError('cycle');
|
|
451
|
+
seen.add(value);
|
|
452
|
+
try {
|
|
453
|
+
if (Array.isArray(value)) {
|
|
454
|
+
return `[${value.map((entry) => canonicalOneShotValue(entry, seen)).join(',')}]`;
|
|
455
|
+
}
|
|
456
|
+
const proto = Object.getPrototypeOf(value);
|
|
457
|
+
if (proto !== Object.prototype && proto !== null) throw new TypeError('unhashable');
|
|
458
|
+
const keys = Object.keys(value).sort();
|
|
459
|
+
return `{${keys.map((key) => `${JSON.stringify(key)}:${canonicalOneShotValue(value[key], seen)}`).join(',')}}`;
|
|
460
|
+
} finally {
|
|
461
|
+
seen.delete(value);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
function oneShotFlag(value) {
|
|
466
|
+
return value === true || value === 1 || value === 'true';
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
function oneShotId(value) {
|
|
470
|
+
return typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function oneShotCents(usd, mode = 'ceil') {
|
|
474
|
+
if (typeof usd !== 'number' || !Number.isFinite(usd) || usd < 0) return null;
|
|
475
|
+
const scaled = Math.round(usd * 10000);
|
|
476
|
+
const cents = mode === 'floor' ? Math.floor(scaled / 100) : Math.ceil(scaled / 100);
|
|
477
|
+
if (usd > 0 && cents <= 0) return 1;
|
|
478
|
+
return cents;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function hashOneShotAction({ toolName, toolInput, quotedUsd, idempotencyKey } = {}) {
|
|
482
|
+
const quoteField = typeof quotedUsd === 'number' && Number.isFinite(quotedUsd)
|
|
483
|
+
? String(quotedUsd)
|
|
484
|
+
: '';
|
|
485
|
+
const payload = [
|
|
486
|
+
encodeCanonicalField(toolName),
|
|
487
|
+
encodeCanonicalField(canonicalOneShotValue(toolInput)),
|
|
488
|
+
encodeCanonicalField(quoteField),
|
|
489
|
+
encodeCanonicalField(idempotencyKey),
|
|
490
|
+
].join('|');
|
|
491
|
+
return crypto.createHash('sha256').update(payload).digest('hex');
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function oneShotDecision(verdict, reason, extra = {}) {
|
|
495
|
+
return {
|
|
496
|
+
actionHash: '',
|
|
497
|
+
reservedUsd: 0,
|
|
498
|
+
...extra,
|
|
499
|
+
verdict,
|
|
500
|
+
reason,
|
|
501
|
+
charged: false,
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function clampCapToCeiling(value, ceiling) {
|
|
506
|
+
if (value == null) return ceiling;
|
|
507
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || value < 0) return null;
|
|
508
|
+
return Math.min(value, ceiling);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
function nonNegativeUsd(value) {
|
|
512
|
+
if (value == null) return 0;
|
|
513
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || value < 0) return null;
|
|
514
|
+
return value;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function evaluateOneShotControl(input = {}) {
|
|
518
|
+
let actionHash = '';
|
|
519
|
+
try {
|
|
520
|
+
actionHash = hashOneShotAction(input);
|
|
521
|
+
} catch {
|
|
522
|
+
return oneShotDecision('hold', 'action_unreadable', { actionHash: '' });
|
|
523
|
+
}
|
|
524
|
+
const base = { actionHash };
|
|
525
|
+
|
|
526
|
+
if (oneShotFlag(input.uncapped)) {
|
|
527
|
+
return oneShotDecision('deny', 'uncapped_refused', base);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
const rawCap = input.cashCapUsd;
|
|
531
|
+
if (rawCap != null && (typeof rawCap !== 'number' || !Number.isFinite(rawCap) || rawCap < 0)) {
|
|
532
|
+
return oneShotDecision('hold', 'cap_unreadable', base);
|
|
533
|
+
}
|
|
534
|
+
const agentCeilingUsd = rawCap == null ? 0 : rawCap;
|
|
535
|
+
|
|
536
|
+
if (input.ledgerReadable !== true) {
|
|
537
|
+
return oneShotDecision('hold', 'ledger_unreadable', base);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
const quote = input.quotedUsd;
|
|
541
|
+
if (typeof quote !== 'number' || !Number.isFinite(quote) || quote < 0) {
|
|
542
|
+
return oneShotDecision('hold', 'quote_required', base);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
if (input.idempotencyKey != null && input.idempotencyKey !== '' && typeof input.idempotencyKey !== 'string') {
|
|
546
|
+
return oneShotDecision('hold', 'idempotency_unreadable', base);
|
|
547
|
+
}
|
|
548
|
+
const key = typeof input.idempotencyKey === 'string' ? input.idempotencyKey.trim() : '';
|
|
549
|
+
if (typeof input.idempotencyKey === 'string' && input.idempotencyKey !== '' && key === '') {
|
|
550
|
+
return oneShotDecision('hold', 'idempotency_unreadable', base);
|
|
551
|
+
}
|
|
552
|
+
if (input.chargedKeys != null && !Array.isArray(input.chargedKeys)) {
|
|
553
|
+
return oneShotDecision('hold', 'ledger_unreadable', base);
|
|
554
|
+
}
|
|
555
|
+
if (input.inFlightKeys != null && !Array.isArray(input.inFlightKeys)) {
|
|
556
|
+
return oneShotDecision('hold', 'ledger_unreadable', base);
|
|
557
|
+
}
|
|
558
|
+
const sameKey = (list) => Array.isArray(list) && list.some((entry) => typeof entry === 'string' && entry.trim() === key);
|
|
559
|
+
if (key && sameKey(input.chargedKeys)) {
|
|
560
|
+
return oneShotDecision('deny', 'idempotent_replay', base);
|
|
561
|
+
}
|
|
562
|
+
if (key && sameKey(input.inFlightKeys)) {
|
|
563
|
+
return oneShotDecision('hold', 'idempotency_in_flight', base);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
const perCallUsd = clampCapToCeiling(input.perCallCapUsd, agentCeilingUsd);
|
|
567
|
+
const dailyUsd = clampCapToCeiling(input.dailyCapUsd, agentCeilingUsd);
|
|
568
|
+
const spentUsd = nonNegativeUsd(input.spentTodayUsd);
|
|
569
|
+
const inFlightUsd = nonNegativeUsd(input.inFlightUsd);
|
|
570
|
+
if (spentUsd == null || inFlightUsd == null) {
|
|
571
|
+
return oneShotDecision('hold', 'ledger_unreadable', base);
|
|
572
|
+
}
|
|
573
|
+
if (perCallUsd == null || dailyUsd == null) {
|
|
574
|
+
return oneShotDecision('hold', 'cap_unreadable', base);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
const quoteCents = oneShotCents(quote, 'ceil');
|
|
578
|
+
const perCallCents = oneShotCents(perCallUsd, 'floor');
|
|
579
|
+
const dailyCents = oneShotCents(dailyUsd, 'floor');
|
|
580
|
+
const spentCents = oneShotCents(spentUsd, 'ceil');
|
|
581
|
+
const inFlightCents = oneShotCents(inFlightUsd, 'ceil');
|
|
582
|
+
if ([quoteCents, perCallCents, dailyCents, spentCents, inFlightCents].some((cents) => cents == null)) {
|
|
583
|
+
return oneShotDecision('hold', 'cap_unreadable', base);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
if (quoteCents > perCallCents) {
|
|
587
|
+
return oneShotDecision('deny', 'over_per_call_cap', base);
|
|
588
|
+
}
|
|
589
|
+
if (spentCents + inFlightCents + quoteCents > dailyCents) {
|
|
590
|
+
return oneShotDecision('deny', 'over_daily_cap', base);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
if (oneShotFlag(input.irreversible) || oneShotFlag(input.approvalRequired)) {
|
|
594
|
+
const approval = input.approval;
|
|
595
|
+
if (!approval || typeof approval !== 'object') {
|
|
596
|
+
return oneShotDecision('hold', 'approval_required', base);
|
|
597
|
+
}
|
|
598
|
+
if (oneShotFlag(approval.used)) {
|
|
599
|
+
return oneShotDecision('deny', 'approval_replay', base);
|
|
600
|
+
}
|
|
601
|
+
if (approval.expiresAt != null) {
|
|
602
|
+
const expiresAt = Number(approval.expiresAt);
|
|
603
|
+
const now = Number(input.now != null ? input.now : Date.now());
|
|
604
|
+
if (!Number.isFinite(expiresAt) || !Number.isFinite(now) || expiresAt <= now) {
|
|
605
|
+
return oneShotDecision('deny', 'approval_expired', base);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
if (approval.actionHash !== actionHash) {
|
|
609
|
+
return oneShotDecision('deny', 'approval_action_mismatch', base);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
return oneShotDecision('allow', 'within_cap', { ...base, reservedUsd: quote });
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
function evaluateOneShotGoalDone(input = {}) {
|
|
617
|
+
if (oneShotFlag(input.budgetExhausted)) {
|
|
618
|
+
return { status: 'out_of_budget', done: false, reason: 'budget_exhausted', missing: [] };
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
const runStartedAt = input.runStartedAt;
|
|
622
|
+
const check = input.check;
|
|
623
|
+
const checkObject = Boolean(check) && typeof check === 'object';
|
|
624
|
+
if (checkObject && check.passed === false) {
|
|
625
|
+
const missing = Array.isArray(check.missing) && check.missing.length > 0
|
|
626
|
+
? check.missing.slice()
|
|
627
|
+
: ['check_failed'];
|
|
628
|
+
return { status: 'failed', done: false, reason: 'check_failed', missing };
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
const checkWrittenBeforeRun = checkObject
|
|
632
|
+
&& typeof check.writtenAt === 'number'
|
|
633
|
+
&& Number.isFinite(check.writtenAt)
|
|
634
|
+
&& typeof runStartedAt === 'number'
|
|
635
|
+
&& Number.isFinite(runStartedAt)
|
|
636
|
+
&& check.writtenAt < runStartedAt;
|
|
637
|
+
|
|
638
|
+
if (checkWrittenBeforeRun && check.passed === true) {
|
|
639
|
+
if (!oneShotEvidenceBacked(input)) {
|
|
640
|
+
return {
|
|
641
|
+
status: 'waiting_owner',
|
|
642
|
+
done: false,
|
|
643
|
+
reason: 'evidence_missing',
|
|
644
|
+
missing: ['verification_evidence'],
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
return { status: 'done', done: true, reason: 'check_confirmed', missing: [] };
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
const workerId = oneShotId(input.workerId);
|
|
651
|
+
const confirmerId = oneShotId(input.confirmerId);
|
|
652
|
+
if (workerId && confirmerId && confirmerId === workerId) {
|
|
653
|
+
return { status: 'waiting_owner', done: false, reason: 'worker_cannot_confirm', missing: [] };
|
|
654
|
+
}
|
|
655
|
+
if (workerId && confirmerId && confirmerId !== workerId) {
|
|
656
|
+
if (!oneShotEvidenceBacked(input)) {
|
|
657
|
+
return {
|
|
658
|
+
status: 'waiting_owner',
|
|
659
|
+
done: false,
|
|
660
|
+
reason: 'evidence_missing',
|
|
661
|
+
missing: ['verification_evidence'],
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
return { status: 'done', done: true, reason: 'owner_confirmed', missing: [] };
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
return {
|
|
668
|
+
status: 'waiting_owner',
|
|
669
|
+
done: false,
|
|
670
|
+
reason: input.modelSaysDone === true ? 'model_done_ignored' : 'check_missing',
|
|
671
|
+
missing: [],
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
function oneShotPayloadNeedsControl(toolName, toolInput) {
|
|
676
|
+
if (!toolInput || typeof toolInput !== 'object' || Array.isArray(toolInput)) return false;
|
|
677
|
+
const name = String(toolName || '');
|
|
678
|
+
const status = typeof toolInput.status === 'string' ? toolInput.status.trim().toLowerCase() : '';
|
|
679
|
+
if ((name === 'record_task_outcome' || name === 'verify_claim') && (status === 'completed' || status === 'done')) {
|
|
680
|
+
return true;
|
|
681
|
+
}
|
|
682
|
+
if (toolInput.modelSaysDone === true || toolInput.goalDone === true) return true;
|
|
683
|
+
if (oneShotFlag(toolInput.budgetExhausted)) return true;
|
|
684
|
+
if (Object.prototype.hasOwnProperty.call(toolInput, 'quotedUsd')) return true;
|
|
685
|
+
return oneShotFlag(toolInput.uncapped)
|
|
686
|
+
|| oneShotFlag(toolInput.irreversible)
|
|
687
|
+
|| oneShotFlag(toolInput.approvalRequired);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
function oneShotIsDoneClaim(toolName, input) {
|
|
691
|
+
const name = String(toolName || '');
|
|
692
|
+
const status = typeof input.status === 'string' ? input.status.trim().toLowerCase() : '';
|
|
693
|
+
if ((name === 'record_task_outcome' || name === 'verify_claim') && (status === 'completed' || status === 'done')) {
|
|
694
|
+
return true;
|
|
695
|
+
}
|
|
696
|
+
return input.modelSaysDone === true || input.goalDone === true || oneShotFlag(input.budgetExhausted);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
function oneShotEvidenceBacked(input) {
|
|
700
|
+
const verification = input && input.verification;
|
|
701
|
+
if (!verification || typeof verification !== 'object' || Array.isArray(verification)) return false;
|
|
702
|
+
const evidence = verification.evidence;
|
|
703
|
+
const worker = oneShotId(input.workerId) || 'worker';
|
|
704
|
+
const verifier = oneShotId(verification.verifier);
|
|
705
|
+
return verification.performed === true
|
|
706
|
+
&& verification.passed === true
|
|
707
|
+
&& Array.isArray(evidence)
|
|
708
|
+
&& evidence.length > 0
|
|
709
|
+
&& verifier !== worker;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
function oneShotLiveGoalInput(input = {}) {
|
|
713
|
+
const status = typeof input.status === 'string' ? input.status.trim().toLowerCase() : '';
|
|
714
|
+
const goalInput = {
|
|
715
|
+
budgetExhausted: input.budgetExhausted,
|
|
716
|
+
modelSaysDone: input.modelSaysDone === true
|
|
717
|
+
|| input.goalDone === true
|
|
718
|
+
|| status === 'completed'
|
|
719
|
+
|| status === 'done',
|
|
720
|
+
workerId: oneShotId(input.workerId) || 'worker',
|
|
721
|
+
confirmerId: '',
|
|
722
|
+
verification: input.verification,
|
|
723
|
+
};
|
|
724
|
+
const verification = input.verification;
|
|
725
|
+
const verificationFailed = Boolean(verification)
|
|
726
|
+
&& typeof verification === 'object'
|
|
727
|
+
&& !Array.isArray(verification)
|
|
728
|
+
&& verification.passed === false;
|
|
729
|
+
const checkFailed = Boolean(input.check) && typeof input.check === 'object' && input.check.passed === false;
|
|
730
|
+
if (verificationFailed || checkFailed) {
|
|
731
|
+
const missing = checkFailed && Array.isArray(input.check.missing) ? input.check.missing : undefined;
|
|
732
|
+
goalInput.check = missing ? { passed: false, missing } : { passed: false };
|
|
733
|
+
return goalInput;
|
|
734
|
+
}
|
|
735
|
+
if (oneShotEvidenceBacked(input)) {
|
|
736
|
+
goalInput.check = { writtenAt: 0, passed: true };
|
|
737
|
+
goalInput.runStartedAt = 1;
|
|
738
|
+
return goalInput;
|
|
739
|
+
}
|
|
740
|
+
return goalInput;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
const ONESHOT_CONTROL_KEYS = new Set([
|
|
744
|
+
'toolName',
|
|
745
|
+
'toolInput',
|
|
746
|
+
'quotedUsd',
|
|
747
|
+
'idempotencyKey',
|
|
748
|
+
'cashCapUsd',
|
|
749
|
+
'ledgerReadable',
|
|
750
|
+
'uncapped',
|
|
751
|
+
'irreversible',
|
|
752
|
+
'approvalRequired',
|
|
753
|
+
'approval',
|
|
754
|
+
'perCallCapUsd',
|
|
755
|
+
'dailyCapUsd',
|
|
756
|
+
'spentTodayUsd',
|
|
757
|
+
'inFlightUsd',
|
|
758
|
+
'chargedKeys',
|
|
759
|
+
'inFlightKeys',
|
|
760
|
+
'now',
|
|
761
|
+
'budgetExhausted',
|
|
762
|
+
'modelSaysDone',
|
|
763
|
+
'goalDone',
|
|
764
|
+
'status',
|
|
765
|
+
'workerId',
|
|
766
|
+
'confirmerId',
|
|
767
|
+
'runStartedAt',
|
|
768
|
+
'check',
|
|
769
|
+
'verification',
|
|
770
|
+
]);
|
|
771
|
+
|
|
772
|
+
function oneShotActionBody(input) {
|
|
773
|
+
if (!input || typeof input !== 'object' || Array.isArray(input)) return input;
|
|
774
|
+
if (input.toolInput && typeof input.toolInput === 'object') return input.toolInput;
|
|
775
|
+
const body = {};
|
|
776
|
+
for (const key of Object.keys(input)) {
|
|
777
|
+
if (ONESHOT_CONTROL_KEYS.has(key)) continue;
|
|
778
|
+
body[key] = input[key];
|
|
779
|
+
}
|
|
780
|
+
return body;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
function oneShotHookDeny(gate, detail) {
|
|
784
|
+
const ruleId = detail && detail.reason ? detail.reason : 'held';
|
|
785
|
+
const message = gate === 'oneshot-goal-done'
|
|
786
|
+
? `ThumbGate refused this done-claim (${ruleId}) [oneshot-goal-done]. The worker cannot mark its own goal done.`
|
|
787
|
+
: `ThumbGate refused this quoted action (${ruleId}) [oneshot-control]. The agent cash cap stays $0.`;
|
|
788
|
+
return {
|
|
789
|
+
decision: 'deny',
|
|
790
|
+
gate,
|
|
791
|
+
ruleId,
|
|
792
|
+
reason: message,
|
|
793
|
+
message,
|
|
794
|
+
severity: 'high',
|
|
795
|
+
oneShot: detail,
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
function evaluateOneShotPretool(toolName, toolInput) {
|
|
800
|
+
if (!oneShotPayloadNeedsControl(toolName, toolInput)) return null;
|
|
801
|
+
const input = toolInput;
|
|
802
|
+
const quoted = Object.prototype.hasOwnProperty.call(input, 'quotedUsd')
|
|
803
|
+
|| oneShotFlag(input.uncapped)
|
|
804
|
+
|| oneShotFlag(input.irreversible)
|
|
805
|
+
|| oneShotFlag(input.approvalRequired);
|
|
806
|
+
if (quoted) {
|
|
807
|
+
const control = evaluateOneShotControl({
|
|
808
|
+
...input,
|
|
809
|
+
toolName: typeof input.toolName === 'string' && input.toolName ? input.toolName : toolName,
|
|
810
|
+
toolInput: oneShotActionBody(input),
|
|
811
|
+
cashCapUsd: 0,
|
|
812
|
+
});
|
|
813
|
+
if (control.verdict !== 'allow') return oneShotHookDeny('oneshot-control', control);
|
|
814
|
+
}
|
|
815
|
+
if (oneShotIsDoneClaim(toolName, input)) {
|
|
816
|
+
const goal = evaluateOneShotGoalDone(oneShotLiveGoalInput(input));
|
|
817
|
+
if (!goal.done) return oneShotHookDeny('oneshot-goal-done', goal);
|
|
818
|
+
}
|
|
819
|
+
return null;
|
|
820
|
+
}
|
|
821
|
+
|
|
435
822
|
module.exports = {
|
|
436
823
|
RECEIPTS_FILE,
|
|
437
824
|
getReceiptsPath,
|
|
@@ -447,6 +834,12 @@ module.exports = {
|
|
|
447
834
|
resolveReceiptSigningKey,
|
|
448
835
|
signReceiptDigest,
|
|
449
836
|
verifyReceiptSignature,
|
|
837
|
+
hashOneShotAction,
|
|
838
|
+
evaluateOneShotControl,
|
|
839
|
+
evaluateOneShotGoalDone,
|
|
840
|
+
evaluateOneShotPretool,
|
|
841
|
+
oneShotPayloadNeedsControl,
|
|
842
|
+
oneShotLiveGoalInput,
|
|
450
843
|
// exposed for testing / reuse
|
|
451
844
|
summarizeInput,
|
|
452
845
|
summarizeOutcome,
|
|
@@ -45,6 +45,14 @@ function pkgVersion() {
|
|
|
45
45
|
// deps.runGate(input) -> Promise<rawJsonString>
|
|
46
46
|
// deps.captureFeedback(params)
|
|
47
47
|
// deps.trackEvent(name, props)
|
|
48
|
+
function loadFirstBlockRecorder() {
|
|
49
|
+
try {
|
|
50
|
+
return require(path.join(PKG_ROOT, 'scripts', 'activation-tracker')).recordFirstBlockedToolCall;
|
|
51
|
+
} catch { /* optional in stripped shell */
|
|
52
|
+
return () => {};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
48
56
|
async function runActivationFlow({ ask, out, isTTY, deps = {} }) {
|
|
49
57
|
// Hard safety gate: never prompt or hang in non-interactive contexts.
|
|
50
58
|
if (!isTTY) {
|
|
@@ -67,7 +75,7 @@ async function runActivationFlow({ ask, out, isTTY, deps = {} }) {
|
|
|
67
75
|
}
|
|
68
76
|
}
|
|
69
77
|
const trackEvent = deps.trackEvent || (() => {});
|
|
70
|
-
|
|
78
|
+
const recordFirstBlock = deps.recordFirstBlock ?? loadFirstBlockRecorder();
|
|
71
79
|
out('');
|
|
72
80
|
out(`thumbgate quickstart v${pkgVersion()}`);
|
|
73
81
|
out('');
|
|
@@ -146,6 +154,9 @@ async function runActivationFlow({ ask, out, isTTY, deps = {} }) {
|
|
|
146
154
|
out('');
|
|
147
155
|
|
|
148
156
|
try { trackEvent('cli_quickstart_activated', { command: 'quickstart', blocked }); } catch { /* telemetry best-effort */ }
|
|
157
|
+
if (blocked && typeof recordFirstBlock === 'function') {
|
|
158
|
+
try { recordFirstBlock({ gateId: promotion.gateId, source: 'cli_quickstart' }); } catch { /* best-effort */ }
|
|
159
|
+
}
|
|
149
160
|
|
|
150
161
|
return {
|
|
151
162
|
interactive: true,
|
|
@@ -166,18 +177,19 @@ function quickstart() {
|
|
|
166
177
|
const trackEvent = (() => {
|
|
167
178
|
try { return require(path.join(PKG_ROOT, 'scripts', 'cli-telemetry')).trackEvent; } catch { return () => {}; }
|
|
168
179
|
})();
|
|
180
|
+
const recordFirstBlock = loadFirstBlockRecorder();
|
|
169
181
|
|
|
170
182
|
if (!isTTY) {
|
|
171
183
|
// Mirror the non-interactive branch without opening readline (which would
|
|
172
184
|
// otherwise keep the process alive waiting for input that never comes).
|
|
173
|
-
return runActivationFlow({ ask: async () => '', out, isTTY: false, deps: { trackEvent } });
|
|
185
|
+
return runActivationFlow({ ask: async () => '', out, isTTY: false, deps: { trackEvent, recordFirstBlock } });
|
|
174
186
|
}
|
|
175
187
|
|
|
176
188
|
const readline = require('node:readline');
|
|
177
189
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
178
190
|
const ask = (q) => new Promise((resolve) => rl.question(q, resolve));
|
|
179
191
|
|
|
180
|
-
return runActivationFlow({ ask, out, isTTY: true, deps: { trackEvent } })
|
|
192
|
+
return runActivationFlow({ ask, out, isTTY: true, deps: { trackEvent, recordFirstBlock } })
|
|
181
193
|
.catch((err) => {
|
|
182
194
|
console.error(`quickstart error: ${err?.message ?? err}`);
|
|
183
195
|
process.exitCode = 1;
|