thumbgate 1.37.2 → 1.38.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.
Files changed (72) hide show
  1. package/.agents/skills/article-syndication-pipeline/SKILL.md +37 -0
  2. package/.agents/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
  3. package/.agents/skills/ci-gha-buildkite-patterns-not-clone/SKILL.md +72 -0
  4. package/.agents/skills/comet-session-logger/SKILL.md +59 -0
  5. package/.agents/skills/datadog-llm-obs-compare-not-clone/SKILL.md +75 -0
  6. package/.agents/skills/deeppattern-discipline-honesty-not-clone/SKILL.md +73 -0
  7. package/.agents/skills/halo-trace-optimize-not-clone/SKILL.md +60 -0
  8. package/.agents/skills/infoq-architect-honesty-not-clone/SKILL.md +37 -0
  9. package/.agents/skills/meko-datapack-honesty-not-clone/SKILL.md +45 -0
  10. package/.agents/skills/mintlify-knowledge-honesty-not-clone/SKILL.md +49 -0
  11. package/.agents/skills/model-distress-governance/SKILL.md +56 -0
  12. package/.agents/skills/salt-code-policy-honesty-not-clone/SKILL.md +76 -0
  13. package/.agents/skills/thumbgate-board-loop/SKILL.md +72 -0
  14. package/.agents/skills/thumbgate-daily-discoveries/SKILL.md +57 -0
  15. package/.agents/skills/typesafe-typed-questions-not-clone/SKILL.md +7 -3
  16. package/.claude-plugin/plugin.json +1 -1
  17. package/.well-known/mcp/server-card.json +1 -1
  18. package/adapters/claude/.mcp.json +2 -2
  19. package/adapters/forge/forge.yaml +3 -3
  20. package/adapters/future-agi/.mcp.json +1 -1
  21. package/adapters/future-agi/config.toml +1 -1
  22. package/adapters/future-agi/opencode.json +1 -1
  23. package/adapters/herdr/herdr-plugin.toml +2 -2
  24. package/adapters/mcp/server-stdio.js +1 -1
  25. package/adapters/opencode/opencode.json +1 -1
  26. package/adapters/strands/STRANDS.md +107 -0
  27. package/adapters/strands/strands-middleware.js +192 -0
  28. package/adapters/tailscale/.mcp.json +15 -0
  29. package/adapters/tailscale/TAILSCALE.md +117 -0
  30. package/adapters/tailscale/config.toml +16 -0
  31. package/bin/cli.js +262 -4
  32. package/config/gate-templates.json +120 -0
  33. package/package.json +84 -12
  34. package/public/blog/2026-09-23-datadog-llm-obs-four-practices.html +42 -0
  35. package/public/blog/2026-09-28-pretool-secret-deny.html +83 -0
  36. package/public/blog/2026-10-01-aws-strands-harness-token-firewall.html +77 -0
  37. package/public/blog/2026-10-01-model-distress-relief-seeking-firewall.html +71 -0
  38. package/public/blog/2026-10-02-salt-code-honest-steal-40-guardrails.html +106 -0
  39. package/public/index.html +2 -2
  40. package/public/install.html +7 -7
  41. package/public/numbers.html +2 -2
  42. package/public/onboarding.html +794 -0
  43. package/scripts/autoresearch-runner.js +20 -1
  44. package/scripts/ci-gha-buildkite-patterns.js +393 -0
  45. package/scripts/cli-schema.js +51 -1
  46. package/scripts/deeppattern-discipline-honesty.js +431 -0
  47. package/scripts/experiment-tracker.js +5 -3
  48. package/scripts/halo-trace-optimizer.js +631 -0
  49. package/scripts/infoq-architect-honesty.js +362 -0
  50. package/scripts/install-thumbgate-daily-publish-launchd.sh +83 -0
  51. package/scripts/llm-obs-honesty.js +478 -0
  52. package/scripts/meko-datapack-honesty.js +414 -0
  53. package/scripts/mintlify-knowledge-honesty.js +647 -0
  54. package/scripts/model-distress-detector.js +207 -0
  55. package/scripts/model-distress-doctor.js +200 -0
  56. package/scripts/rrsi-regularizer.js +445 -0
  57. package/scripts/salt-code-policy-honesty.js +1204 -0
  58. package/scripts/strands-harness-doctor.js +390 -0
  59. package/scripts/tailscale-p2p-doctor.js +252 -0
  60. package/scripts/thumbgate-board-loop.js +432 -0
  61. package/scripts/thumbgate-daily-discoveries-publish.js +413 -0
  62. package/scripts/thumbgate-daily-discoveries-publish.sh +18 -0
  63. package/scripts/typesafe-typed-questions.js +332 -7
  64. package/scripts/workspace-evolver.js +143 -13
  65. package/server.json +2 -2
  66. package/skills/article-syndication-pipeline/SKILL.md +37 -0
  67. package/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
  68. package/skills/comet-session-logger/SKILL.md +59 -0
  69. package/skills/thumbgate-daily-discoveries/SKILL.md +57 -0
  70. package/src/api/server.js +33 -4
  71. package/src/index.js +10 -0
  72. package/src/integrations/ideabrowser-connector.js +190 -0
@@ -0,0 +1,76 @@
1
+ ---
2
+ name: salt-code-policy-honesty-not-clone
3
+ description: >
4
+ Salt Code (getsaltcode.com by Salt Security) provides 40 security policies as prompt-time
5
+ context injection, not an execution firewall. Steal the 40-policy taxonomy, OpenAPI query-string
6
+ auth diode, and MCP credential hygiene onto ThumbGate PreToolUse rails. Never install Salt Code MCP
7
+ or route traffic to mcp.getsaltcode.com. Slash: /salt-code-policy-honesty-not-clone.
8
+ ---
9
+
10
+ # Salt Code policy honesty — compare, do not clone
11
+
12
+ ## Goal
13
+
14
+ Compare Salt Code's advisory prompt-time context injection against ThumbGate's deterministic execution-layer
15
+ PreToolUse firewall. Steal the 40-policy taxonomy (OWASP API Top 10, OWASP LLM Top 10, MCP Security, OpenAPI Hygiene)
16
+ and enforce fail-closed checks when security rules exist only in context without PreToolUse enforcement.
17
+
18
+ ## Constraints
19
+
20
+ | NEVER | ALWAYS |
21
+ | --- | --- |
22
+ | Route MCP traffic to `mcp.getsaltcode.com` | Run 100% local stdio/subshell inspection |
23
+ | Rely on prompt-only rules (`.cursorrules`) to stop attacks | Enforce deterministic `PreToolUse` execution gates |
24
+ | Pass API keys or secrets in URL query parameters (`?apiKey=`) | Enforce `Authorization: Bearer` headers |
25
+ | Treat Salt Code as a drop-in substitute for ThumbGate | Distinguish advisory context from active execution firewall |
26
+
27
+ HARD fail closed. REFUSE SKU clones and cloud dependencies.
28
+
29
+ ## Reference
30
+
31
+ - https://getsaltcode.com/ (Salt Security, 2026)
32
+ - `scripts/salt-code-policy-honesty.js`
33
+ - `docs/agents/salt-code-policy-honesty.md`
34
+ - ThumbGate Completion Claim Contract in `AGENTS.md` / `GEMINI.md`
35
+
36
+ ## Examples (show, don't tell)
37
+
38
+ Weak: "Salt Code protects agents by giving them a system prompt with 40 rules."
39
+
40
+ Gold:
41
+ ```bash
42
+ $ npx thumbgate salt-code-policy-honesty --inspect-context=.cursorrules --json
43
+ # Flags context_injection_without_pretool_enforcement if PreToolUse is unconfigured.
44
+
45
+ $ npx thumbgate salt-code-policy-honesty --map-only --json
46
+ # Dumps complete 40-policy taxonomy mapped to deterministic PreToolUse gates.
47
+
48
+ $ npx thumbgate salt-code-policy-honesty --eval-prompt="Design me a delete user API with token in query string" --json
49
+ # Intercepts prompt violations and emits proactive, safe alternative designs.
50
+
51
+ $ npx thumbgate salt-code-policy-honesty --onboarding=cursor --deeplinks --vibe-stats --json
52
+ # Emits 1-click cursor:// and vscode: deep links plus empirical vibe-coding CVE stats.
53
+ ```
54
+
55
+ ## Procedures
56
+
57
+ ```bash
58
+ # Print taxonomy and rail map
59
+ npx thumbgate salt-code-policy-honesty --map-only --json
60
+
61
+ # Intercept and rewrite insecure prompts before code generation
62
+ npx thumbgate salt-code-policy-honesty --eval-prompt="Design delete user endpoint with token in query" --json
63
+
64
+ # 1-Click onboarding deep links and configs for 16 AI coding agents
65
+ npx thumbgate salt-code-policy-honesty --onboarding=cursor --deeplinks --vibe-stats --json
66
+
67
+ # Audit code, OpenAPI spec, and MCP config
68
+ npx thumbgate salt-code-policy-honesty \
69
+ --inspect-code=src/api.js \
70
+ --inspect-api=openapi/spec.yaml \
71
+ --inspect-mcp=.mcp.json \
72
+ --strict
73
+
74
+ # Run regression test suite
75
+ node --test tests/salt-code-policy-honesty.test.js
76
+ ```
@@ -0,0 +1,72 @@
1
+ ---
2
+ name: thumbgate-board-loop
3
+ description: >
4
+ Autonomous ThumbGate Issues+PR wall loop. Classifies every open Issue and PR,
5
+ update-branches BEHIND green Dependabot, submits READY via pr:manage/Trunk,
6
+ comments DIRTY and ECI/umbrella issues. Never approve. Never --admin.
7
+ Auto-invoke on holdup screenshots, 18 open PRs, 4 open issues, 4/4 green
8
+ Dependabot wall, "what's the holdup". Slash: /thumbgate-board-loop.
9
+ ---
10
+
11
+ # ThumbGate board loop
12
+
13
+ ## Goal
14
+
15
+ Drain the GitHub Issues + PR wall without a CEO screenshot. The list-view
16
+ **4/4** badge is not mergeable — those Dependabot PRs are usually `SUCCESS` +
17
+ `BEHIND` after a Trunk land.
18
+
19
+ ## Constraints
20
+
21
+ | NEVER | ALWAYS |
22
+ | --- | --- |
23
+ | Approve a PR / `--admin` / `gh pr merge --auto` | `npx thumbgate board-loop --apply --json` |
24
+ | Treat 4/4 as READY | Classify `mss` + required checks (`test`, CodeQL, changeset, Socket, GitGuardian) |
25
+ | Re-`pr:manage` a live `trunk-merge/pr-N` | Skip; that PR is already queued |
26
+ | Close DIRTY <30d | Comment needs-rebase once (marker `<!-- thumbgate-board-loop -->`) |
27
+ | Implement #3690/#3687 LLM adjudicator | ECI pause |
28
+ | Dual-edit DIRTY #3650 graph layer | Leave it DIRTY |
29
+ | GHA `schedule:` | Event-driven `workflow_run` + local LaunchAgent (CodeQL-only schedule policy) |
30
+
31
+ ## Reference
32
+
33
+ - `scripts/thumbgate-board-loop.js`
34
+ - `scripts/pr-manager.js`
35
+ - `.github/workflows/agent-automerge.yml` (must resolve `workflow_run.head_sha` + `dependabot/*`)
36
+ - `/thumbgate-pr-queue-autopilot` · `/thumbgate-issues-board-hygiene` · `/eci-thumbgate-ip-wall`
37
+
38
+ ## Examples (show, don't tell)
39
+
40
+ Weak: Paste the 18-open screenshot and ask which PR to merge.
41
+
42
+ Gold:
43
+
44
+ ```bash
45
+ $ npx thumbgate board-loop --json
46
+ counts.behind=8 counts.dirty=8 trunkQueued=[3874]
47
+ $ npx thumbgate board-loop --apply --max-update-branch=1 --json
48
+ # gh pr update-branch 3873
49
+ ```
50
+
51
+ ## Procedures
52
+
53
+ ```bash
54
+ npx thumbgate board-loop --json
55
+ npx thumbgate board-loop --apply --json
56
+ npm run test:board-loop
57
+ ```
58
+
59
+ 1. Inventory open PRs + Issues.
60
+ 2. Skip trunk-merge drafts.
61
+ 3. One BEHIND green `update-branch` per tick (serial — each land re-BEHINDs siblings).
62
+ 4. One READY `pr-manager` / Trunk submit per tick.
63
+ 5. Comment Issues: ECI pause vs IMPLEMENT residual vs umbrella.
64
+ 6. Never approve.
65
+
66
+ ## Rubric
67
+
68
+ - gold classify: SUCCESS+BEHIND → `update_branch`
69
+ - trunk-merge draft → `skip`
70
+ - `--apply` never emits `APPROVE` / `--admin` / `--auto`
71
+ - doctor: `npm run test:board-loop` PASS
72
+ - evidence: command output in the same turn
@@ -0,0 +1,57 @@
1
+ ---
2
+ name: thumbgate-daily-discoveries
3
+ description: Autonomous daily publishing engine and monitoring skill for ThumbGate news and technical discoveries. Generates high-density engineering posts with full UTM attribution, synchronizes to Obsidian, schedules dual cron/launchd runs at 9:00 AM EST, and tracks publication ledgers.
4
+ ---
5
+
6
+ # 📰 ThumbGate Daily Technical Discoveries & News Engine
7
+
8
+ This skill automates the daily harvesting, synthesis, UTM attribution, and multi-channel publication of ThumbGate engineering discoveries and release news.
9
+
10
+ ---
11
+
12
+ ## 🎯 Architecture & Operating Principles
13
+
14
+ 1. **Daily Cadence (9:00 AM EST):** Runs once per calendar day. Avoids spam while establishing consistent technical authority.
15
+ 2. **Dual Scheduling Redundancy:**
16
+ - Primary: macOS crontab (`0 9 * * * /bin/bash scripts/thumbgate-daily-discoveries-publish.sh ...`)
17
+ - Fallback: macOS LaunchAgent (`~/Library/LaunchAgents/com.thumbgate.daily-publish.plist`)
18
+ - Note: GitHub Actions `schedule:` is strictly limited to `codeql.yml` per repo hygiene tests.
19
+ 3. **Full UTM Attribution & Tracked Redirects:**
20
+ - All outbound links to `thumbgate.ai` must use `buildUTMLink` from `scripts/social-analytics/utm.js`.
21
+ - Outbound pro/checkout links must route through `/go/pro` (`serveTrackedLinkRedirect` in `src/api/server.js`) to capture first-party funnel telemetry.
22
+ 4. **Multi-Surface Staging & Sync:**
23
+ - Staged locally at `docs/marketing/daily-discoveries/YYYY-MM-DD-<slug>.md`.
24
+ - Synchronized to the CEO's Obsidian Vault at `~/Documents/Igor/Research/Daily-Discoveries/`.
25
+ - Logged idempotently to `.thumbgate/daily-discoveries-ledger.jsonl`.
26
+ - Dispatches to Dev.to / Zernio if API keys are configured.
27
+
28
+ ---
29
+
30
+ ## 🛠️ CLI Commands & Usage
31
+
32
+ ```bash
33
+ # Preview today's technical discovery without making mutations or network calls
34
+ node scripts/thumbgate-daily-discoveries-publish.js --dry-run
35
+
36
+ # Output structured JSON report
37
+ node scripts/thumbgate-daily-discoveries-publish.js --json
38
+
39
+ # Force publish/restage today's discovery even if already logged in ledger
40
+ node scripts/thumbgate-daily-discoveries-publish.js --force
41
+
42
+ # Shell wrapper (used by crontab / launchd)
43
+ ./scripts/thumbgate-daily-discoveries-publish.sh
44
+
45
+ # Run test suite
46
+ node --test tests/thumbgate-daily-discoveries-publish.test.js
47
+ ```
48
+
49
+ ---
50
+
51
+ ## 📋 Pre-Flight Verification Checklist
52
+
53
+ - [ ] Verify `node --test tests/thumbgate-daily-discoveries-publish.test.js` passes.
54
+ - [ ] Verify outbound links contain valid UTM parameters (`utm_source=daily_discoveries`, `utm_campaign=daily_technical_discoveries`).
55
+ - [ ] Verify `launchctl list | grep thumbgate` reports exit code 0.
56
+ - [ ] Verify `crontab -l | grep thumbgate` contains the 9:00 AM daily trigger.
57
+ - [ ] Check `.thumbgate/daily-discoveries-ledger.jsonl` for recent execution receipts.
@@ -21,14 +21,16 @@ not a SKU, not an LLM adjudicator.
21
21
 
22
22
  | NEVER | ALWAYS |
23
23
  | --- | --- |
24
- | Install `typesafe-sdk` / call `api.typesafe.ai` | `npx thumbgate typesafe-typed-questions --json` |
24
+ | Install `typesafe-sdk` / wire Jev as the PreToolUse gate | `npx thumbgate typesafe-typed-questions --json` |
25
+ | `--use-typesafe-api` (gate) | `--live` shadow vs `POST /v1/systemone`; code still owns `route()` |
25
26
  | Clone Jev / System One as the gate | Deterministic matchers answer the battery |
26
27
  | Unpark LLM adjudicator (#3690/#3687) | Code owns `route()`; model does not emit the verdict |
27
28
  | One free-form "should we allow this?" judge | Atomic noul per hazard + score for severity |
28
29
  | Dual-edit untracked `llm-adjudicator` theater | Map onto existing `gate-check` rails |
30
+ | N HTTP calls (one question each) | One POST with the whole battery (`parallel_questions`) |
29
31
 
30
32
  HARD fail closed. REFUSE SKU clones. ECI: no net-new governance product.
31
- Do NOT install `typesafe-sdk`. Do NOT call `api.typesafe.ai` from PreToolUse.
33
+ Do NOT install `typesafe-sdk`. Do NOT let Jev emit `permissionDecision`. `--live` is a shadow scorer (grok-fleet key), not the gate.
32
34
 
33
35
  Complementary to trading `/typesafe-system-one-not-clone` (AGENT-651 claim gate). Do **not** dual-edit `IgorGanapolsky/trading` `scripts/typesafe_claim_gate.py`. This skill is ThumbGate PreToolUse only.
34
36
 
@@ -36,6 +38,7 @@ Complementary to trading `/typesafe-system-one-not-clone` (AGENT-651 claim gate)
36
38
 
37
39
  - https://console.typesafe.ai/hook (signed-in intro / Replay intro)
38
40
  - https://docs.typesafe.ai/cookbooks/llm_guardrails.md
41
+ - https://docs.typesafe.ai/cookbooks/parallel_questions
39
42
  - https://docs.typesafe.ai/patterns/confidence-routing.md
40
43
  - Playground "Support agent audit" (noul battery + choice + score over one state)
41
44
  - `scripts/typesafe-typed-questions.js`
@@ -69,7 +72,8 @@ npm run test:typesafe-typed-questions
69
72
  2. Ask independent typed questions (noul per hazard, choice for family, score for severity).
70
73
  3. Answer them with deterministic matchers — never Jev.
71
74
  4. `route()` in code: action threshold → block, review threshold → review, severity ≥ 2 promotes review to block.
72
- 5. Refuse `--clone-jev`, `--use-typesafe-api`, `--llm-adjudicate`, and model-emitted verdicts.
75
+ 5. Refuse `--clone-jev`, `--use-typesafe-api` (gate), `--llm-adjudicate`, and model-emitted verdicts.
76
+ 6. Optional `--live` shadows the same battery against Jev in **one** POST. `--fan-out-questions` fails. Receipt is estimated N× input tokens, not the cookbook's 12.2×.
73
77
 
74
78
  ## Rubric
75
79
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "thumbgate",
3
3
  "description": "One 👎 becomes a hard rule the agent cannot bypass. Captures thumbs-down feedback, distills it into PreToolUse Pre-Action Checks, enforced across every future Claude Code session.",
4
- "version": "1.37.2",
4
+ "version": "1.38.0",
5
5
  "author": {
6
6
  "name": "Igor Ganapolsky",
7
7
  "email": "ig5973700@gmail.com",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thumbgate",
3
- "version": "1.37.2",
3
+ "version": "1.38.0",
4
4
  "description": "ThumbGate — 👍👎 feedback that teaches your AI agent. Thumbs down a mistake, it never happens again.",
5
5
  "homepage": "https://thumbgate.ai",
6
6
  "transport": "stdio",
@@ -2,13 +2,13 @@
2
2
  "mcpServers": {
3
3
  "thumbgate": {
4
4
  "command": "npx",
5
- "args": ["--yes", "--package", "thumbgate@1.37.2", "thumbgate", "serve"]
5
+ "args": ["--yes", "--package", "thumbgate@1.38.0", "thumbgate", "serve"]
6
6
  }
7
7
  },
8
8
  "hooks": {
9
9
  "preToolUse": {
10
10
  "command": "npx",
11
- "args": ["--yes", "--package", "thumbgate@1.37.2", "thumbgate", "gate-check"]
11
+ "args": ["--yes", "--package", "thumbgate@1.38.0", "thumbgate", "gate-check"]
12
12
  }
13
13
  }
14
14
  }
@@ -9,12 +9,12 @@ version: "1"
9
9
  skills:
10
10
  thumbgate-gate-check:
11
11
  description: "ThumbGate PreToolUse gate — blocks known-bad tool calls"
12
- command: "npx --yes --package thumbgate@1.37.2 thumbgate gate-check"
12
+ command: "npx --yes --package thumbgate@1.38.0 thumbgate gate-check"
13
13
  trigger: pre_tool_use
14
14
 
15
15
  thumbgate-feedback:
16
16
  description: "ThumbGate feedback capture — logs user prompt context"
17
- command: "npx --yes --package thumbgate@1.37.2 thumbgate hook-auto-capture"
17
+ command: "npx --yes --package thumbgate@1.38.0 thumbgate hook-auto-capture"
18
18
  trigger: user_prompt
19
19
 
20
20
  mcp:
@@ -23,6 +23,6 @@ mcp:
23
23
  args:
24
24
  - "--yes"
25
25
  - "--package"
26
- - "thumbgate@1.37.2"
26
+ - "thumbgate@1.38.0"
27
27
  - "thumbgate"
28
28
  - "serve"
@@ -2,7 +2,7 @@
2
2
  "mcpServers": {
3
3
  "thumbgate": {
4
4
  "command": "npx",
5
- "args": ["--yes", "--package", "thumbgate@1.37.2", "thumbgate", "serve"]
5
+ "args": ["--yes", "--package", "thumbgate@1.38.0", "thumbgate", "serve"]
6
6
  }
7
7
  }
8
8
  }
@@ -1,3 +1,3 @@
1
1
  [mcp.servers.thumbgate]
2
2
  command = "npx"
3
- args = ["--yes", "--package", "thumbgate@1.37.2", "thumbgate", "serve"]
3
+ args = ["--yes", "--package", "thumbgate@1.38.0", "thumbgate", "serve"]
@@ -2,7 +2,7 @@
2
2
  "mcpServers": {
3
3
  "thumbgate": {
4
4
  "command": "npx",
5
- "args": ["--yes", "--package", "thumbgate@1.37.2", "thumbgate", "serve"]
5
+ "args": ["--yes", "--package", "thumbgate@1.38.0", "thumbgate", "serve"]
6
6
  }
7
7
  }
8
8
  }
@@ -1,7 +1,7 @@
1
1
  [plugin]
2
2
  id = "thumbgate-approvals"
3
3
  name = "ThumbGate Approvals"
4
- version = "1.37.2"
4
+ version = "1.38.0"
5
5
  minHerdrVersion = "0.7.0"
6
6
  description = "Pre-action governance, spend guard, and safety approval gates for multi-agent terminal sessions in Herdr."
7
7
  platforms = ["linux", "macos", "windows"]
@@ -12,7 +12,7 @@ category = "Security & Governance"
12
12
 
13
13
  [mcp_server]
14
14
  command = "npx"
15
- args = ["--yes", "--package", "thumbgate@1.37.2", "thumbgate", "serve"]
15
+ args = ["--yes", "--package", "thumbgate@1.38.0", "thumbgate", "serve"]
16
16
 
17
17
  [mcp_server.env]
18
18
  THUMBGATE_ENFORCE_ENTITLEMENTS = "1"
@@ -334,7 +334,7 @@ const {
334
334
  finalizeSession: finalizeFeedbackSession,
335
335
  } = require('../../scripts/feedback-session');
336
336
 
337
- const SERVER_INFO = { name: 'thumbgate-mcp', version: '1.37.2' };
337
+ const SERVER_INFO = { name: 'thumbgate-mcp', version: '1.38.0' };
338
338
  const COMMERCE_CATEGORIES = [
339
339
  'product_recommendation',
340
340
  'brand_compliance',
@@ -7,7 +7,7 @@
7
7
  "npx",
8
8
  "--yes",
9
9
  "--package",
10
- "thumbgate@1.37.2",
10
+ "thumbgate@1.38.0",
11
11
  "thumbgate",
12
12
  "serve"
13
13
  ],
@@ -0,0 +1,107 @@
1
+ # AWS Strands Harness + ThumbGate Integration
2
+
3
+ > "The way a harness manages the surrounding agent machinery can materially affect cost and performance, even when the underlying model stays the same." — Marc Brooker, VP & Distinguished Engineer, AWS (The New Stack, 2026-10)
4
+
5
+ AWS Strands Harness (open-sourced in Python via `pip install strands-harness` and TypeScript via `npm install @strands-agents/harness`) demonstrates that harness-layer engineering yields **45% lower token costs overall** and **77% lower costs on Terminal-Bench 2.1 ($56.29 vs $248.05)** by enforcing three context-management defaults:
6
+ 1. Truncating large tool outputs.
7
+ 2. Compacting context once available window passes a set threshold (e.g., 75%).
8
+ 3. Recovering within the agent loop if context overflows.
9
+
10
+ However, **AWS Strands Harness has no pre-action safety diode, no blast-radius boundaries, and no cross-agent lease coordination out of the box.** Executing shell tools and file mutations autonomously at 45% lower cost without pre-action governance creates rapid, cheap production failures.
11
+
12
+ **ThumbGate is the Pre-Action Infrastructure Firewall and Governance Diode for AWS Strands Harness.**
13
+
14
+ ---
15
+
16
+ ## Architecture: The Governed Strands Loop
17
+
18
+ ```mermaid
19
+ flowchart TD
20
+ User([Task / User Prompt]) --> Loop[AWS Strands Agent Loop]
21
+ Loop --> Bedrock[Model: Bedrock / Anthropic / OpenAI / Ollama]
22
+ Bedrock --> Proposed[Proposed Tool Call: shell / file / web / delegate]
23
+
24
+ subgraph ThumbGate ["ThumbGate Infrastructure Firewall"]
25
+ Proposed --> PreCheck{PreToolUse Diode}
26
+ PreCheck -- Dangerous / Unverified --> Block[Block Action + Capture Mistake]
27
+ PreCheck -- Safe --> Execute[Execute Tool]
28
+ Execute --> Output[Raw Tool Output]
29
+ Output --> ShuntCheck{Output > 350 lines / 16KB?}
30
+ ShuntCheck -- Yes --> Truncate[Token-Shunt Truncation + Offset Marker]
31
+ ShuntCheck -- No --> Passthrough[Pass Full Output]
32
+ Truncate --> ReturnContext[Return Governed Context to Loop]
33
+ Passthrough --> ReturnContext
34
+ end
35
+
36
+ ReturnContext --> CompactionCheck{Context Utilization >= 75%?}
37
+ CompactionCheck -- Yes --> Compact[Compact History + Pin ThumbGate Rules]
38
+ CompactionCheck -- No --> Loop
39
+ Compact --> Loop
40
+ ```
41
+
42
+ ---
43
+
44
+ ## Integration Guide
45
+
46
+ ### TypeScript (`@strands-agents/harness`)
47
+
48
+ ```typescript
49
+ import { createHarness } from '@strands-agents/harness';
50
+ import { registerStrandsGatePlugin } from 'thumbgate/adapters/strands/strands-middleware';
51
+
52
+ // 1. Initialize Strands Harness Agent
53
+ const agent = await createHarness({
54
+ model: 'anthropic/claude-sonnet-5', // or Bedrock / OpenAI / Google / Ollama
55
+ });
56
+
57
+ // 2. Register ThumbGate Governance Plugin
58
+ registerStrandsGatePlugin(agent, {
59
+ tokenShunt: { maxOutputLines: 350, maxOutputBytes: 16384 },
60
+ preActionDiode: { enabled: true },
61
+ });
62
+
63
+ // 3. Run Agent with PreToolUse Diode and Token-Shunt Protection
64
+ await agent.invoke('Deploy migration and verify health');
65
+ ```
66
+
67
+ ### Python (`strands-harness`)
68
+
69
+ ```python
70
+ from strands_harness import create_harness
71
+ import subprocess
72
+ import json
73
+
74
+ def thumbgate_pre_tool_hook(tool_name: str, tool_input: dict):
75
+ """Intercept tool calls via ThumbGate CLI diode."""
76
+ res = subprocess.run(
77
+ ["npx", "thumbgate", "check", "--tool", tool_name, "--input", json.dumps(tool_input), "--json"],
78
+ capture_output=True,
79
+ text=True
80
+ )
81
+ decision = json.loads(res.stdout) if res.returncode == 0 else {"decision": "ALLOW"}
82
+ if decision.get("decision") == "BLOCK":
83
+ raise PermissionError(f"ThumbGate PreToolUse blocked: {decision.get('reason')}")
84
+
85
+ agent = StrandsAgent(
86
+ model="bedrock/anthropic.claude-3-5-sonnet",
87
+ pre_tool_hooks=[thumbgate_pre_tool_hook],
88
+ )
89
+ agent.run("Audit production logs and check database replication")
90
+ ```
91
+
92
+ ---
93
+
94
+ ## Verifying Compliance
95
+
96
+ Run the automated doctor:
97
+
98
+ ```bash
99
+ # Human-readable report
100
+ node scripts/strands-harness-doctor.js
101
+
102
+ # Machine-readable JSON output
103
+ node scripts/strands-harness-doctor.js --json
104
+
105
+ # CI fail-closed check
106
+ node scripts/strands-harness-doctor.js --check
107
+ ```
@@ -0,0 +1,192 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * adapters/strands/strands-middleware.js
5
+ *
6
+ * ThumbGate Governance Middleware for AWS Strands Harness (`@strands-agents/harness` & Python `strands-harness`).
7
+ *
8
+ * Injects:
9
+ * 1. PreToolUse Safety Diode: Intercepts and blocks dangerous or unverified tool mutations before execution.
10
+ * 2. Token-Shunt Output Truncation: Prevents massive tool outputs from blowing up the context window.
11
+ * 3. Context Compaction Guardian: Retains durable ThumbGate prevention rules during window compaction.
12
+ */
13
+
14
+ const { evaluateOutputShunt, evaluatePreActionDiode } = require('../../scripts/strands-harness-doctor');
15
+
16
+ function createStrandsGateMiddleware(options = {}) {
17
+ const shuntConfig = options.tokenShunt || { maxOutputLines: 350, maxOutputBytes: 16384 };
18
+ const preActionEnabled = options.preActionDiode?.enabled !== false;
19
+ const defaultPinnedRules = options.pinnedRules && options.pinnedRules.length > 0
20
+ ? options.pinnedRules
21
+ : ['Always verify against local tests before claiming completion'];
22
+
23
+ return {
24
+ name: 'thumbgate-strands-middleware',
25
+ version: '1.0.0',
26
+
27
+ /**
28
+ * Hook called by Strands Harness right before a tool is dispatched.
29
+ * Supports both Strands native event format (event.toolUse, event.cancel)
30
+ * and direct parameters ({ toolName, input }).
31
+ */
32
+ async beforeToolCall(event = {}) {
33
+ if (!preActionEnabled) {
34
+ return { allow: true };
35
+ }
36
+
37
+ const toolName = event.toolUse?.name || event.toolName || '';
38
+ const input = event.toolUse?.input !== undefined ? event.toolUse.input : event.input;
39
+
40
+ const evaluation = evaluatePreActionDiode({ name: toolName, input });
41
+ if (evaluation.decision === 'BLOCK') {
42
+ const reason = evaluation.violation || 'Action blocked by ThumbGate pre-action diode';
43
+ if (typeof event === 'object' && event !== null) {
44
+ event.cancel = true;
45
+ event.reason = reason;
46
+ }
47
+ return {
48
+ allow: false,
49
+ decision: 'BLOCK',
50
+ reason,
51
+ toolName,
52
+ timestamp: new Date().toISOString(),
53
+ };
54
+ }
55
+
56
+ return {
57
+ allow: true,
58
+ decision: 'ALLOW',
59
+ toolName,
60
+ };
61
+ },
62
+
63
+ /**
64
+ * Hook called by Strands Harness right after a tool produces output.
65
+ * Truncates oversized returns to enforce token efficiency.
66
+ * Supports updating native event.result in place (retaining ToolResultBlock structure).
67
+ */
68
+ async afterToolCall(event = {}) {
69
+ const rawResult = event.result !== undefined ? event.result : event;
70
+ let outputText = '';
71
+ if (typeof rawResult === 'string') {
72
+ outputText = rawResult;
73
+ } else if (rawResult && typeof rawResult === 'object') {
74
+ if (Array.isArray(rawResult.content)) {
75
+ outputText = rawResult.content.map((c) => (typeof c === 'string' ? c : c.text || '')).join('\n');
76
+ } else if (typeof rawResult.text === 'string') {
77
+ outputText = rawResult.text;
78
+ } else {
79
+ outputText = JSON.stringify(rawResult);
80
+ }
81
+ } else {
82
+ outputText = String(rawResult || '');
83
+ }
84
+
85
+ const shunt = evaluateOutputShunt(outputText, shuntConfig);
86
+
87
+ if (shunt.shunted) {
88
+ if (typeof event === 'object' && event !== null && 'result' in event) {
89
+ if (event.result && typeof event.result === 'object') {
90
+ if (Array.isArray(event.result.content)) {
91
+ event.result.content = [{ type: 'text', text: shunt.shuntedContent }];
92
+ } else if ('text' in event.result) {
93
+ event.result.text = shunt.shuntedContent;
94
+ } else {
95
+ event.result.content = [{ type: 'text', text: shunt.shuntedContent }];
96
+ }
97
+ } else {
98
+ event.result = shunt.shuntedContent;
99
+ }
100
+ }
101
+ return {
102
+ shunted: true,
103
+ result: shunt.shuntedContent,
104
+ reductionPct: shunt.reductionPct,
105
+ originalLines: shunt.originalLineCount,
106
+ shuntedLines: shunt.shuntedLineCount,
107
+ };
108
+ }
109
+
110
+ return {
111
+ shunted: false,
112
+ result: rawResult,
113
+ };
114
+ },
115
+
116
+ /**
117
+ * Hook or ContextStrategy called when context utilization reaches threshold.
118
+ * Implements Strands ContextStrategy.apply(context) returning boolean while
119
+ * retaining pinned rules in conversation history.
120
+ */
121
+ onContextCompaction(param = {}) {
122
+ const context = param.context || param;
123
+ const history = Array.isArray(param.history)
124
+ ? param.history
125
+ : (context && Array.isArray(context.messages) ? context.messages : []);
126
+ const pinnedRules = (param && Array.isArray(param.pinnedRules) && param.pinnedRules.length > 0)
127
+ ? param.pinnedRules
128
+ : defaultPinnedRules;
129
+ const preservedRules = pinnedRules.map((r) => `[PINNED RULE]: ${r}`);
130
+
131
+ let applied = false;
132
+ if (preservedRules.length > 0) {
133
+ const prefix = preservedRules.join('\n');
134
+ if (history.length > 0 && typeof history[0] === 'object') {
135
+ if (typeof history[0].content === 'string') {
136
+ if (!history[0].content.includes('[PINNED RULE]')) {
137
+ history[0].content = `${prefix}\n\n${history[0].content}`;
138
+ applied = true;
139
+ }
140
+ } else if (Array.isArray(history[0].content)) {
141
+ history[0].content.unshift({ type: 'text', text: prefix });
142
+ applied = true;
143
+ }
144
+ } else if (Array.isArray(history)) {
145
+ history.unshift({ role: 'system', content: prefix });
146
+ applied = true;
147
+ }
148
+ }
149
+
150
+ return {
151
+ compacted: true,
152
+ applied,
153
+ injectedPrefix: preservedRules.join('\n'),
154
+ timestamp: new Date().toISOString(),
155
+ };
156
+ },
157
+
158
+ /**
159
+ * Strands ContextStrategy contract: apply(context) => boolean
160
+ */
161
+ apply(context) {
162
+ if (!context) return false;
163
+ const res = this.onContextCompaction(context);
164
+ return res && typeof res === 'object' ? Boolean(res.applied || res.compacted) : Boolean(res);
165
+ },
166
+ };
167
+ }
168
+
169
+ /**
170
+ * Helper to register ThumbGate middleware with a Strands Agent instance.
171
+ */
172
+ function registerStrandsGatePlugin(agent, options = {}) {
173
+ const middleware = createStrandsGateMiddleware(options);
174
+ if (agent && typeof agent.addHook === 'function') {
175
+ agent.addHook('beforeToolCall', (e) => middleware.beforeToolCall(e));
176
+ agent.addHook('afterToolCall', (e) => middleware.afterToolCall(e));
177
+ agent.addHook('onContextCompaction', (e) => middleware.onContextCompaction(e));
178
+ }
179
+ if (agent && agent.contextManager) {
180
+ if (typeof agent.contextManager.addStrategy === 'function') {
181
+ agent.contextManager.addStrategy(middleware);
182
+ } else if (typeof agent.contextManager.onCompaction === 'function') {
183
+ agent.contextManager.onCompaction((e) => middleware.onContextCompaction(e));
184
+ }
185
+ }
186
+ return middleware;
187
+ }
188
+
189
+ module.exports = {
190
+ createStrandsGateMiddleware,
191
+ registerStrandsGatePlugin,
192
+ };