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.
- package/.agents/skills/article-syndication-pipeline/SKILL.md +37 -0
- package/.agents/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
- package/.agents/skills/ci-gha-buildkite-patterns-not-clone/SKILL.md +72 -0
- package/.agents/skills/comet-session-logger/SKILL.md +59 -0
- package/.agents/skills/datadog-llm-obs-compare-not-clone/SKILL.md +75 -0
- package/.agents/skills/deeppattern-discipline-honesty-not-clone/SKILL.md +73 -0
- package/.agents/skills/halo-trace-optimize-not-clone/SKILL.md +60 -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/salt-code-policy-honesty-not-clone/SKILL.md +76 -0
- package/.agents/skills/thumbgate-board-loop/SKILL.md +72 -0
- package/.agents/skills/thumbgate-daily-discoveries/SKILL.md +57 -0
- package/.agents/skills/typesafe-typed-questions-not-clone/SKILL.md +7 -3
- 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/mcp/server-stdio.js +1 -1
- package/adapters/opencode/opencode.json +1 -1
- package/adapters/strands/STRANDS.md +107 -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 +262 -4
- package/config/gate-templates.json +120 -0
- package/package.json +84 -12
- package/public/blog/2026-09-23-datadog-llm-obs-four-practices.html +42 -0
- 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/index.html +2 -2
- package/public/install.html +7 -7
- package/public/numbers.html +2 -2
- package/public/onboarding.html +794 -0
- package/scripts/autoresearch-runner.js +20 -1
- package/scripts/ci-gha-buildkite-patterns.js +393 -0
- package/scripts/cli-schema.js +51 -1
- package/scripts/deeppattern-discipline-honesty.js +431 -0
- package/scripts/experiment-tracker.js +5 -3
- package/scripts/halo-trace-optimizer.js +631 -0
- package/scripts/infoq-architect-honesty.js +362 -0
- package/scripts/install-thumbgate-daily-publish-launchd.sh +83 -0
- package/scripts/llm-obs-honesty.js +478 -0
- package/scripts/meko-datapack-honesty.js +414 -0
- package/scripts/mintlify-knowledge-honesty.js +647 -0
- package/scripts/model-distress-detector.js +207 -0
- package/scripts/model-distress-doctor.js +200 -0
- package/scripts/rrsi-regularizer.js +445 -0
- package/scripts/salt-code-policy-honesty.js +1204 -0
- package/scripts/strands-harness-doctor.js +390 -0
- package/scripts/tailscale-p2p-doctor.js +252 -0
- package/scripts/thumbgate-board-loop.js +432 -0
- package/scripts/thumbgate-daily-discoveries-publish.js +413 -0
- package/scripts/thumbgate-daily-discoveries-publish.sh +18 -0
- package/scripts/typesafe-typed-questions.js +332 -7
- package/scripts/workspace-evolver.js +143 -13
- package/server.json +2 -2
- package/skills/article-syndication-pipeline/SKILL.md +37 -0
- package/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
- package/skills/comet-session-logger/SKILL.md +59 -0
- package/skills/thumbgate-daily-discoveries/SKILL.md +57 -0
- package/src/api/server.js +33 -4
- package/src/index.js +10 -0
- package/src/integrations/ideabrowser-connector.js +190 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: article-syndication-pipeline
|
|
3
|
+
description: Technical article syndication pipeline for cross-posting Dev.to articles to CoderLegion and other developer platforms with canonical URL preservation, UTM parameter attribution, and contributor onboarding compliance.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ✍️ Article Syndication & Contributor Pipeline
|
|
7
|
+
|
|
8
|
+
This skill guides the autonomous syndication of ThumbGate technical discoveries, security postmortems, and engineering deep dives across developer platforms (Dev.to, CoderLegion, Hashnode, Medium).
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🎯 Architecture & Operating Directives
|
|
13
|
+
|
|
14
|
+
1. **Canonical SEO Integrity:**
|
|
15
|
+
- Always preserve the primary origin as the canonical URL (e.g. `https://dev.to/igorganapolsky/...`).
|
|
16
|
+
- Syndicated copies on CoderLegion or elsewhere must link back to avoid search engine duplicate-content penalties.
|
|
17
|
+
2. **First-Party Revenue Attribution:**
|
|
18
|
+
- All inbound links to `thumbgate.ai` must include UTM campaign tags (`utm_source=coderlegion`, `utm_medium=community`, `utm_campaign=guest-post`).
|
|
19
|
+
- Conversion links (Pro license checkout) must route through `/go/pro` (`https://thumbgate.ai/go/pro?utm_source=...`) to ensure server-side redirect logging.
|
|
20
|
+
3. **CoderLegion Contributor Compliance:**
|
|
21
|
+
- URL import endpoint: `https://coderlegion.com/import-post`.
|
|
22
|
+
- Supports 2 imported Dev.to articles with full attribution.
|
|
23
|
+
- Contributor checklist: `https://coderlegion.com/guest-blog-checklists`.
|
|
24
|
+
- All imported posts undergo editorial review before appearing on the main feed.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 🛠️ Step-by-Step Workflow
|
|
29
|
+
|
|
30
|
+
1. **Verify Original Article:**
|
|
31
|
+
Verify original URL exists, returns HTTP 200, and has correct canonical tags.
|
|
32
|
+
2. **Fetch via Platform Parser:**
|
|
33
|
+
Submit `import_url` to `https://coderlegion.com/import-post`.
|
|
34
|
+
3. **Review & Confirm Metadata:**
|
|
35
|
+
Confirm title, tags (`ai`, `security`, `architecture`, `opensource`), and backlink to canonical source.
|
|
36
|
+
4. **Publish & Track:**
|
|
37
|
+
Submit publication step and record post URL in session log and Comet browser tab.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: aws-strands-harness-not-clone
|
|
3
|
+
description: >
|
|
4
|
+
AWS Strands Harness (The New Stack 2026-10 / Marc Brooker) is an agent
|
|
5
|
+
runtime architecture, not a ThumbGate clone. Steal the three context-management
|
|
6
|
+
defaults (output shunting <= 350 lines, 75% compaction threshold, in-loop
|
|
7
|
+
recovery) and inject ThumbGate's PreToolUse diode. Never vendor Bedrock-only
|
|
8
|
+
dependencies. Slash: /aws-strands-harness-not-clone.
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# AWS Strands Harness — FORMAT Steal, Not Clone
|
|
12
|
+
|
|
13
|
+
## Goal
|
|
14
|
+
|
|
15
|
+
Provide fail-closed pre-action governance and token-shunted output bounds for agents running on AWS Strands Harness (`@strands-agents/harness` or `strands-harness`), capturing the 45% (and 77% Terminal-Bench 2.1) token savings while preventing destructive tool actions.
|
|
16
|
+
|
|
17
|
+
## Constraints
|
|
18
|
+
|
|
19
|
+
| NEVER | ALWAYS |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| Clone or install Bedrock-only proprietary packages | Use decoupled providers (Bedrock, Anthropic, OpenAI, Ollama) |
|
|
22
|
+
| Allow un-shunted raw tool returns (> 350 lines / 16KB) | Truncate with `evaluateOutputShunt` offset markers |
|
|
23
|
+
| Drop durable prevention rules during context compaction | Pin ThumbGate rules across 75% compaction threshold |
|
|
24
|
+
| Crash the agent loop on context overflow | Recover in-loop by pruning non-pinned conversational history |
|
|
25
|
+
| Execute mutating shell/file tools without governance | Run ThumbGate `PreToolUse` diode before dispatch |
|
|
26
|
+
| Claim 77% savings without citing Terminal-Bench 2.1 | Ground benchmarks in measured tool-output reduction |
|
|
27
|
+
|
|
28
|
+
HARD fail closed. REFUSE un-gated autonomous execution.
|
|
29
|
+
|
|
30
|
+
## Reference
|
|
31
|
+
|
|
32
|
+
- The New Stack (2026-10): *AWS open-sources an AI agent it says is 45% cheaper than Claude Code and Codex*
|
|
33
|
+
- `scripts/strands-harness-doctor.js`
|
|
34
|
+
- `adapters/strands/strands-middleware.js`
|
|
35
|
+
- `adapters/strands/config.json`
|
|
36
|
+
- `adapters/strands/STRANDS.md`
|
|
37
|
+
- `docs/agents/aws-strands-harness.md`
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Audit Strands Harness compliance
|
|
43
|
+
node scripts/strands-harness-doctor.js
|
|
44
|
+
|
|
45
|
+
# Machine-readable output
|
|
46
|
+
node scripts/strands-harness-doctor.js --json
|
|
47
|
+
|
|
48
|
+
# Architectural map
|
|
49
|
+
node scripts/strands-harness-doctor.js --map-only
|
|
50
|
+
|
|
51
|
+
# CI Gate check
|
|
52
|
+
node scripts/strands-harness-doctor.js --check
|
|
53
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: comet-session-logger
|
|
3
|
+
description: Live session logger and observability dashboard driver for Comet browser. Ensures every PR, deployment status check, CoderLegion/Dev.to publication, and Railway production health metric is actively logged and visualized in Comet tabs.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ☄️ Comet Session Logger & Visual HUD
|
|
7
|
+
|
|
8
|
+
This skill governs the automated logging, tab orchestration, and visual tracking of all ThumbGate agentic tasks inside the **Comet** browser on macOS.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🎯 Purpose & Directives
|
|
13
|
+
|
|
14
|
+
1. **CEO Visual Observability:** The CEO monitors agent progress via open tabs in Comet. Every major milestone must be reflected in Comet tabs without disrupting existing work.
|
|
15
|
+
2. **Deterministic Tab Management:** Uses macOS AppleScript (`osascript`) to inspect, activate, create, or update Comet tabs.
|
|
16
|
+
3. **Fail-Safe & Non-Destructive:** Never closes existing tabs; always reuses matching URLs or opens clean dedicated monitoring tabs.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 🧭 Standard Tab Targets
|
|
21
|
+
|
|
22
|
+
| Surface | Target URL | Trigger Milestone |
|
|
23
|
+
|---------|------------|-------------------|
|
|
24
|
+
| **Pull Requests** | `https://github.com/IgorGanapolsky/ThumbGate/pull/<NUM>` | After creating or advancing a PR |
|
|
25
|
+
| **CI / Checks** | `https://github.com/IgorGanapolsky/ThumbGate/actions` | During workflow verification |
|
|
26
|
+
| **Production Health** | `https://thumbgate-production.up.railway.app/health` | After deployment gate verification |
|
|
27
|
+
| **Railway Console** | `https://railway.com/project/thumbgate-production` | When inspecting infrastructure |
|
|
28
|
+
| **CoderLegion** | `https://coderlegion.com/import-post` | When onboarding or syndicating articles |
|
|
29
|
+
| **Dev.to Dashboard** | `https://dev.to/dashboard` | When tracking article reach & analytics |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 🛠️ AppleScript Orchestration Helpers
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Check existing Comet tabs
|
|
37
|
+
osascript -e '
|
|
38
|
+
tell application "Comet"
|
|
39
|
+
set outList to ""
|
|
40
|
+
repeat with w in windows
|
|
41
|
+
repeat with t in tabs of w
|
|
42
|
+
set outList to outList & (URL of t) & " | " & (title of t) & linefeed
|
|
43
|
+
end repeat
|
|
44
|
+
end repeat
|
|
45
|
+
return outList
|
|
46
|
+
end tell'
|
|
47
|
+
|
|
48
|
+
# Open or focus a specific URL in Comet
|
|
49
|
+
open_comet_url() {
|
|
50
|
+
local target_url="$1"
|
|
51
|
+
osascript -e "
|
|
52
|
+
tell application \"Comet\"
|
|
53
|
+
activate
|
|
54
|
+
tell front window
|
|
55
|
+
make new tab with properties {URL:\"${target_url}\"}
|
|
56
|
+
end tell
|
|
57
|
+
end tell"
|
|
58
|
+
}
|
|
59
|
+
```
|
|
@@ -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.
|
package/src/api/server.js
CHANGED
|
@@ -338,6 +338,7 @@ const FOUNDERS_PAGE_PATH = path.resolve(__dirname, '../../public/founders.html')
|
|
|
338
338
|
const PARTNER_INTAKE_PAGE_PATH = path.resolve(__dirname, '../../public/partner-intake.html');
|
|
339
339
|
const PETER_PAGE_PATH = path.resolve(__dirname, '../../public/peter.html');
|
|
340
340
|
const INSTALL_PAGE_PATH = path.resolve(__dirname, '../../public/install.html');
|
|
341
|
+
const ONBOARDING_PAGE_PATH = path.resolve(__dirname, '../../public/onboarding.html');
|
|
341
342
|
const LEARN_DIR = path.resolve(__dirname, '../../public/learn');
|
|
342
343
|
const GUIDES_DIR = path.resolve(__dirname, '../../public/guides');
|
|
343
344
|
const COMPARE_DIR = path.resolve(__dirname, '../../public/compare');
|
|
@@ -3575,6 +3576,10 @@ function loadLearnPageHtml(runtimeConfig, pageContext = {}) {
|
|
|
3575
3576
|
return loadPublicMarketingTemplateHtml(LEARN_PAGE_PATH, runtimeConfig, pageContext);
|
|
3576
3577
|
}
|
|
3577
3578
|
|
|
3579
|
+
function loadOnboardingPageHtml(runtimeConfig, pageContext = {}) {
|
|
3580
|
+
return loadPublicMarketingTemplateHtml(ONBOARDING_PAGE_PATH, runtimeConfig, pageContext);
|
|
3581
|
+
}
|
|
3582
|
+
|
|
3578
3583
|
function readOptionalPublicTemplate(filePath) {
|
|
3579
3584
|
try {
|
|
3580
3585
|
return fs.readFileSync(filePath, 'utf-8');
|
|
@@ -5788,7 +5793,7 @@ function createApiServer() {
|
|
|
5788
5793
|
return;
|
|
5789
5794
|
}
|
|
5790
5795
|
}
|
|
5791
|
-
(async () => {
|
|
5796
|
+
void (async () => {
|
|
5792
5797
|
try {
|
|
5793
5798
|
const { callTool } = require('../../adapters/mcp/server-stdio');
|
|
5794
5799
|
const name = msg.params?.name;
|
|
@@ -6671,6 +6676,25 @@ async function addContext(){
|
|
|
6671
6676
|
return;
|
|
6672
6677
|
}
|
|
6673
6678
|
|
|
6679
|
+
if (isGetLikeRequest && (pathname === '/onboarding' || pathname === '/onboarding.html')) {
|
|
6680
|
+
try {
|
|
6681
|
+
servePublicMarketingPage({
|
|
6682
|
+
req,
|
|
6683
|
+
res,
|
|
6684
|
+
parsed,
|
|
6685
|
+
hostedConfig,
|
|
6686
|
+
isHeadRequest,
|
|
6687
|
+
renderHtml: loadOnboardingPageHtml,
|
|
6688
|
+
extraTelemetry: {
|
|
6689
|
+
pageType: 'onboarding',
|
|
6690
|
+
},
|
|
6691
|
+
});
|
|
6692
|
+
} catch (err) {
|
|
6693
|
+
sendText(res, 500, err.message || 'Onboarding page unavailable');
|
|
6694
|
+
}
|
|
6695
|
+
return;
|
|
6696
|
+
}
|
|
6697
|
+
|
|
6674
6698
|
|
|
6675
6699
|
// Partner co-branded case study (Peter Yang / high-ROI acquisition landing).
|
|
6676
6700
|
if (isGetLikeRequest && (pathname === '/peter' || pathname === '/peter.html')) {
|
|
@@ -11444,7 +11468,12 @@ module.exports = {
|
|
|
11444
11468
|
};
|
|
11445
11469
|
|
|
11446
11470
|
if (require.main === module) {
|
|
11447
|
-
startServer()
|
|
11448
|
-
|
|
11449
|
-
|
|
11471
|
+
startServer()
|
|
11472
|
+
.then(({ host, port }) => {
|
|
11473
|
+
console.log(`ThumbGate API listening on http://${host}:${port}`);
|
|
11474
|
+
})
|
|
11475
|
+
.catch((err) => {
|
|
11476
|
+
console.error('Failed to start ThumbGate server:', err);
|
|
11477
|
+
process.exit(1);
|
|
11478
|
+
});
|
|
11450
11479
|
}
|
package/src/index.js
CHANGED
|
@@ -12,6 +12,12 @@ const {
|
|
|
12
12
|
isNamedIdentity,
|
|
13
13
|
} = require('./hermes-platform-protocol');
|
|
14
14
|
const { HermesSyncPlane } = require('./hermes-sync-plane');
|
|
15
|
+
const {
|
|
16
|
+
IdeaBrowserConnector,
|
|
17
|
+
ToolTier,
|
|
18
|
+
DEFAULT_READ_ONLY_TOOLS,
|
|
19
|
+
DEFAULT_MUTATING_TOOLS,
|
|
20
|
+
} = require('./integrations/ideabrowser-connector');
|
|
15
21
|
|
|
16
22
|
// The package entry point is the production surface for `thumbgate`.
|
|
17
23
|
// The hosted-Hermes identity/lifecycle/approval gates are exported here so
|
|
@@ -29,4 +35,8 @@ module.exports = Object.assign({}, feedbackLoop, {
|
|
|
29
35
|
THREAD_MODES,
|
|
30
36
|
FORBIDDEN_IDENTITIES,
|
|
31
37
|
isNamedIdentity,
|
|
38
|
+
IdeaBrowserConnector,
|
|
39
|
+
ToolTier,
|
|
40
|
+
DEFAULT_READ_ONLY_TOOLS,
|
|
41
|
+
DEFAULT_MUTATING_TOOLS,
|
|
32
42
|
});
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ideabrowser-connector.js — IdeaBrowser Agent Connector & Governance Diode.
|
|
5
|
+
*
|
|
6
|
+
* Implements a hardened IdeaBrowser connector for ThumbGate without credential
|
|
7
|
+
* leakage, classifying all actions into read-only or mutating tiers. Closes #3823.
|
|
8
|
+
*
|
|
9
|
+
* Security & Governance Invariants:
|
|
10
|
+
* 1. Zero Plaintext Credentials:
|
|
11
|
+
* - Connector tokens/secrets must never be stored in tracked repository files.
|
|
12
|
+
* - Resolve credentials via authenticated environment variables (IDEABROWSER_API_KEY)
|
|
13
|
+
* or macOS Keychain lookup.
|
|
14
|
+
* 2. Strict Tool Classification:
|
|
15
|
+
* - read-only: Information gathering, DOM inspection, status query, screenshot, URL retrieval. Allowed by default.
|
|
16
|
+
* - mutating: Form submission, button click, file upload, state mutation, purchasing, external navigation.
|
|
17
|
+
* - Fail-Closed on Provider Drift: Unknown tools default immediately to mutating.
|
|
18
|
+
* 3. Pre-Action Interdiction:
|
|
19
|
+
* - Emits an interdiction event before executing any mutating tool.
|
|
20
|
+
* - Hard-blocks unauthorized mutating operations when fail-closed mode is set.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const { EventEmitter } = require('node:events');
|
|
24
|
+
const { redactSecrets, redactSecretsDeep } = require('../../scripts/secret-redaction');
|
|
25
|
+
|
|
26
|
+
const ToolTier = Object.freeze({
|
|
27
|
+
READ_ONLY: 'read-only',
|
|
28
|
+
MUTATING: 'mutating',
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const DEFAULT_READ_ONLY_TOOLS = new Set([
|
|
32
|
+
'get_page_content',
|
|
33
|
+
'get_dom_tree',
|
|
34
|
+
'get_url',
|
|
35
|
+
'inspect_element',
|
|
36
|
+
'take_screenshot',
|
|
37
|
+
'get_status',
|
|
38
|
+
'search_page',
|
|
39
|
+
'list_tabs',
|
|
40
|
+
'read_console_logs',
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
const DEFAULT_MUTATING_TOOLS = new Set([
|
|
44
|
+
'click_element',
|
|
45
|
+
'fill_form',
|
|
46
|
+
'submit_form',
|
|
47
|
+
'navigate_url',
|
|
48
|
+
'upload_file',
|
|
49
|
+
'execute_script',
|
|
50
|
+
'purchase_item',
|
|
51
|
+
'close_tab',
|
|
52
|
+
'press_key',
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
class IdeaBrowserConnector extends EventEmitter {
|
|
56
|
+
constructor(options = {}) {
|
|
57
|
+
super();
|
|
58
|
+
this.apiKey = options.apiKey || process.env.IDEABROWSER_API_KEY || null;
|
|
59
|
+
this.baseUrl = options.baseUrl || 'https://api.ideabrowser.com/v1';
|
|
60
|
+
this.failClosed = options.failClosed !== false;
|
|
61
|
+
this.allowedDomains = Array.isArray(options.allowedDomains)
|
|
62
|
+
? new Set(options.allowedDomains)
|
|
63
|
+
: null;
|
|
64
|
+
this.toolRegistry = new Map();
|
|
65
|
+
|
|
66
|
+
// Seed default known tools
|
|
67
|
+
for (const tool of DEFAULT_READ_ONLY_TOOLS) {
|
|
68
|
+
this.toolRegistry.set(tool, {
|
|
69
|
+
tier: ToolTier.READ_ONLY,
|
|
70
|
+
handler: options.handlers?.[tool] || (async (params) => ({ tool, params, status: 'ok' })),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
for (const tool of DEFAULT_MUTATING_TOOLS) {
|
|
75
|
+
this.toolRegistry.set(tool, {
|
|
76
|
+
tier: ToolTier.MUTATING,
|
|
77
|
+
handler: options.handlers?.[tool] || (async (params) => ({ tool, params, status: 'ok' })),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
getCredentials() {
|
|
83
|
+
if (this.apiKey) {
|
|
84
|
+
return {
|
|
85
|
+
hasKey: true,
|
|
86
|
+
source: 'env_or_options',
|
|
87
|
+
maskedKey: redactSecrets(this.apiKey),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
hasKey: false,
|
|
92
|
+
source: 'none',
|
|
93
|
+
maskedKey: null,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
registerTool(name, handler, tier = ToolTier.MUTATING) {
|
|
98
|
+
if (!name || typeof name !== 'string') {
|
|
99
|
+
throw new Error('Tool name must be a non-empty string.');
|
|
100
|
+
}
|
|
101
|
+
if (typeof handler !== 'function') {
|
|
102
|
+
throw new Error('Tool handler must be a function.');
|
|
103
|
+
}
|
|
104
|
+
const resolvedTier = tier === ToolTier.READ_ONLY ? ToolTier.READ_ONLY : ToolTier.MUTATING;
|
|
105
|
+
this.toolRegistry.set(name, { handler, tier: resolvedTier });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
classifyTool(name) {
|
|
109
|
+
const entry = this.toolRegistry.get(name);
|
|
110
|
+
if (entry) {
|
|
111
|
+
return entry.tier;
|
|
112
|
+
}
|
|
113
|
+
// Fail closed on drift: Unknown tools are classified as mutating
|
|
114
|
+
return this.failClosed ? ToolTier.MUTATING : ToolTier.READ_ONLY;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
isAllowedDomain(urlOrDomain) {
|
|
118
|
+
if (!this.allowedDomains) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
if (this.allowedDomains.size === 0) return false;
|
|
122
|
+
if (!urlOrDomain) return false;
|
|
123
|
+
try {
|
|
124
|
+
const parsed = urlOrDomain.startsWith('http')
|
|
125
|
+
? new URL(urlOrDomain)
|
|
126
|
+
: new URL(`https://${urlOrDomain}`);
|
|
127
|
+
return this.allowedDomains.has(parsed.hostname);
|
|
128
|
+
} catch {
|
|
129
|
+
return this.allowedDomains.has(urlOrDomain);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async executeTool(name, params = {}, context = {}) {
|
|
134
|
+
const tier = this.classifyTool(name);
|
|
135
|
+
const entry = this.toolRegistry.get(name);
|
|
136
|
+
|
|
137
|
+
if (tier === ToolTier.MUTATING) {
|
|
138
|
+
const targetUrl = params.url || params.target || context.url;
|
|
139
|
+
if (targetUrl && !this.isAllowedDomain(targetUrl)) {
|
|
140
|
+
let domainOnly = targetUrl;
|
|
141
|
+
try {
|
|
142
|
+
const parsed = targetUrl.startsWith('http')
|
|
143
|
+
? new URL(targetUrl)
|
|
144
|
+
: new URL(`https://${targetUrl}`);
|
|
145
|
+
domainOnly = parsed.origin;
|
|
146
|
+
} catch {
|
|
147
|
+
domainOnly = redactSecrets(targetUrl);
|
|
148
|
+
}
|
|
149
|
+
const error = new Error(`Domain not allowed for mutating tool "${name}": ${domainOnly}`);
|
|
150
|
+
error.code = 'DOMAIN_INTERDICTED';
|
|
151
|
+
this.emit('interdict', {
|
|
152
|
+
name,
|
|
153
|
+
params: redactSecretsDeep(params),
|
|
154
|
+
context: redactSecretsDeep(context),
|
|
155
|
+
reason: redactSecrets(error.message),
|
|
156
|
+
});
|
|
157
|
+
if (this.failClosed) {
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
this.emit('interdict', {
|
|
163
|
+
name,
|
|
164
|
+
params: redactSecretsDeep(params),
|
|
165
|
+
context: redactSecretsDeep(context),
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
if (context.blocked === true) {
|
|
169
|
+
if (this.failClosed) {
|
|
170
|
+
const error = new Error(`Execution of mutating tool "${name}" blocked by pre-action gate.`);
|
|
171
|
+
error.code = 'GATE_INTERDICTED';
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (!entry) {
|
|
178
|
+
throw new Error(`IdeaBrowser tool "${name}" not found.`);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return await entry.handler(params);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
module.exports = {
|
|
186
|
+
ToolTier,
|
|
187
|
+
IdeaBrowserConnector,
|
|
188
|
+
DEFAULT_READ_ONLY_TOOLS,
|
|
189
|
+
DEFAULT_MUTATING_TOOLS,
|
|
190
|
+
};
|