thumbgate 1.37.3 → 1.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
- package/.agents/skills/bolt-forge-opt-in-not-clone/SKILL.md +72 -0
- package/.agents/skills/decisive-step-evaluator/SKILL.md +47 -0
- package/.agents/skills/fiddler-control-plane-honesty/SKILL.md +61 -0
- package/.agents/skills/halo-trace-optimize-not-clone/SKILL.md +60 -0
- package/.agents/skills/harness-evolution-ceiling/SKILL.md +52 -0
- package/.agents/skills/infoq-architect-honesty-not-clone/SKILL.md +37 -0
- package/.agents/skills/meko-datapack-honesty-not-clone/SKILL.md +45 -0
- package/.agents/skills/mintlify-knowledge-honesty-not-clone/SKILL.md +49 -0
- package/.agents/skills/model-distress-governance/SKILL.md +56 -0
- package/.agents/skills/omp-coordination-honesty-not-clone/SKILL.md +94 -0
- package/.agents/skills/saas-moat-honesty-not-clone/SKILL.md +22 -0
- package/.agents/skills/salt-code-policy-honesty-not-clone/SKILL.md +76 -0
- package/.agents/skills/siren-mcp-governance/SKILL.md +50 -0
- package/.agents/skills/vs-coverage-gap-not-clone/SKILL.md +69 -0
- package/.agents/skills/wisdom-context-artifact-not-clone/SKILL.md +67 -0
- package/.claude-plugin/plugin.json +1 -1
- package/.well-known/mcp/server-card.json +1 -1
- package/adapters/claude/.mcp.json +2 -2
- package/adapters/forge/forge.yaml +3 -3
- package/adapters/future-agi/.mcp.json +1 -1
- package/adapters/future-agi/config.toml +1 -1
- package/adapters/future-agi/opencode.json +1 -1
- package/adapters/herdr/herdr-plugin.toml +2 -2
- package/adapters/hotdata/hotdata-vector-store.js +575 -0
- package/adapters/mcp/server-stdio.js +1 -1
- package/adapters/opencode/opencode.json +1 -1
- package/adapters/strands/STRANDS.md +107 -0
- package/adapters/strands/strands-box-diode.js +344 -0
- package/adapters/strands/strands-decider-adapter.js +445 -0
- package/adapters/strands/strands-middleware.js +192 -0
- package/adapters/tailscale/.mcp.json +15 -0
- package/adapters/tailscale/TAILSCALE.md +117 -0
- package/adapters/tailscale/config.toml +16 -0
- package/bin/cli.js +602 -21
- package/config/gate-templates.json +109 -0
- package/config/gates/default.json +13 -0
- package/config/schemas/task-outcome-receipt.schema.json +12 -0
- package/package.json +150 -21
- package/public/blog/2026-09-28-pretool-secret-deny.html +83 -0
- package/public/blog/2026-10-01-aws-strands-harness-token-firewall.html +77 -0
- package/public/blog/2026-10-01-model-distress-relief-seeking-firewall.html +71 -0
- package/public/blog/2026-10-02-salt-code-honest-steal-40-guardrails.html +106 -0
- package/public/blog/2026-10-05-why-3-days-of-triage-wont-save-ai-speed-code.html +119 -0
- package/public/blog/2026-10-09-your-code-got-a-third-author-governance.html +141 -0
- package/public/connectors.html +329 -0
- package/public/enterprise-governance.html +311 -0
- package/public/gaming-playbook.html +732 -0
- package/public/index.html +77 -51
- package/public/install.html +7 -7
- package/public/learn.html +14 -0
- package/public/numbers.html +2 -2
- package/public/onboarding.html +794 -0
- package/public/operator-framework.html +385 -0
- package/public/pricing.html +14 -10
- package/scripts/activesaddler-curriculum-doctor.js +357 -0
- package/scripts/agent-context-artifact.js +325 -0
- package/scripts/agent-egress-policy.js +2 -2
- package/scripts/agent-operations-planner.js +1 -1
- package/scripts/agent-outcome-eval.js +1 -1
- package/scripts/agent-reliability-client.js +148 -0
- package/scripts/apple-minions-idle-compute-steal.js +428 -0
- package/scripts/autoresearch-runner.js +20 -1
- package/scripts/billing.js +0 -1
- package/scripts/cli-demo.js +505 -1
- package/scripts/cli-schema.js +36 -0
- package/scripts/colab-compute-honesty.js +93 -0
- package/scripts/corporate-email-isolation-diode.js +299 -0
- package/scripts/coverage-gap.js +396 -0
- package/scripts/dashboard-chat.js +3 -3
- package/scripts/dashboard.js +2 -2
- package/scripts/decisive-step-doctor.js +256 -0
- package/scripts/decisive-step-evaluator.js +390 -0
- package/scripts/entitlement.js +18 -7
- package/scripts/experiment-tracker.js +5 -3
- package/scripts/feedback-loop.js +26 -3
- package/scripts/fiddler-control-plane-honesty.js +303 -0
- package/scripts/financial-control-plane.js +10 -2
- package/scripts/gates-engine.js +3 -1
- package/scripts/github-license-compliance-diode.js +378 -0
- package/scripts/halo-trace-optimizer.js +631 -0
- package/scripts/harness-ceiling-doctor.js +326 -0
- package/scripts/hf-papers.js +1 -1
- package/scripts/human-escalation.js +7 -1
- package/scripts/hybrid-feedback-context.js +53 -7
- package/scripts/infoq-architect-honesty.js +362 -0
- package/scripts/lesson-graph.js +785 -0
- package/scripts/lesson-inference.js +1 -1
- package/scripts/lesson-retrieval.js +26 -18
- package/scripts/license.js +122 -21
- package/scripts/llm-behavior-monitor.js +1 -1
- package/scripts/llm-obs-honesty.js +52 -0
- package/scripts/local-model-profile.js +11 -7
- package/scripts/mailer/resend-mailer.js +6 -3
- package/scripts/mcp-transport-strategy.js +1 -1
- package/scripts/meko-datapack-honesty.js +414 -0
- package/scripts/migrate-lesson-graph.js +442 -0
- package/scripts/mintlify-knowledge-honesty.js +647 -0
- package/scripts/model-distress-detector.js +207 -0
- package/scripts/model-distress-doctor.js +368 -0
- package/scripts/multi-harness-invariants.js +305 -0
- package/scripts/omp-coordination-honesty.js +488 -0
- package/scripts/pro-local-dashboard.js +20 -3
- package/scripts/prompt-eval.js +1 -1
- package/scripts/prove-herdr-adapter.js +367 -3
- package/scripts/rag-embedding-identity.js +1 -1
- package/scripts/rrsi-regularizer.js +531 -0
- package/scripts/saas-moat-honesty.js +443 -0
- package/scripts/salt-code-policy-honesty.js +1204 -0
- package/scripts/secret-redaction.js +58 -0
- package/scripts/session-export-gate.js +368 -0
- package/scripts/siren-mcp-governance.js +539 -0
- package/scripts/strands-box-doctor.js +130 -0
- package/scripts/strands-harness-doctor.js +390 -0
- package/scripts/stripe-revenue-catalog-audit.js +12 -0
- package/scripts/stripe-revenue-catalog.js +40 -0
- package/scripts/switchyard-router.js +153 -0
- package/scripts/tailscale-p2p-doctor.js +252 -0
- package/scripts/task-outcomes.js +148 -3
- package/scripts/thumbgate-board-loop.js +4 -2
- package/scripts/thumbgate-daily-discoveries-publish.js +86 -38
- package/scripts/triage-savings-calculator.js +181 -0
- package/scripts/vector-store.js +41 -2
- package/scripts/vulnerability-pre-action-diode.js +319 -0
- package/scripts/windbg-evidence-diagnostics.js +241 -0
- package/scripts/workflow-intake-queue.js +1 -1
- package/scripts/workspace-agent-routines.js +534 -6
- package/scripts/workspace-evolver.js +143 -13
- package/server.json +2 -2
- package/skills/aws-strands-harness-not-clone/SKILL.md +53 -0
- package/skills/siren-mcp-governance/SKILL.md +50 -0
- package/src/api/server.js +191 -5
- package/src/mcp-writeguard.js +1 -1
- package/src/session-interactivity.js +284 -0
|
@@ -0,0 +1,539 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Siren MCP Marketing Diode & Autonomous Campaign Governance.
|
|
6
|
+
*
|
|
7
|
+
* Source: Hexahedral Inc. / Siren
|
|
8
|
+
* - MCP Server: https://github.com/Hexahedral-Inc/siren-mcp
|
|
9
|
+
* - MCP Documentation: https://mcp.mysiren.ai/skill.md
|
|
10
|
+
* - Platform: https://mysiren.ai
|
|
11
|
+
*
|
|
12
|
+
* Purpose:
|
|
13
|
+
* Autonomous marketing and social media agents running Siren MCP tools
|
|
14
|
+
* (`post_run`, `schedule_post`, `create_campaign`) have direct outbound write access
|
|
15
|
+
* to brand social channels (X/Twitter, LinkedIn, TikTok, Instagram, YouTube).
|
|
16
|
+
*
|
|
17
|
+
* Unchecked, autonomous marketing agents introduce high-severity risks:
|
|
18
|
+
* 1. Brand Safety: Hallucinated discounts, defamatory claims, or unapproved commitments.
|
|
19
|
+
* 2. Compliance & Attribution: Violating attribution contracts ("Video made with Siren" -> https://mysiren.ai).
|
|
20
|
+
* 3. Immediate Dispatch Accidents: Posting half-baked drafts directly to live production audiences.
|
|
21
|
+
* 4. Runaway Spend: Generating unbudgeted ad campaigns or exceeding daily marketing limits.
|
|
22
|
+
* 5. Scheduling Stampedes: Scheduling hundreds of posts in tiny windows triggering spam bans.
|
|
23
|
+
*
|
|
24
|
+
* Transfers (Process only):
|
|
25
|
+
* 1. PreToolUse Marketing Diode:
|
|
26
|
+
* Interdicts calls to Siren tools before execution.
|
|
27
|
+
* 2. Attribution Verification:
|
|
28
|
+
* Enforces mandatory backlink attribution ("Video made with Siren" / https://mysiren.ai)
|
|
29
|
+
* on generated video content.
|
|
30
|
+
* 3. Scheduling Safety Buffer:
|
|
31
|
+
* `schedule_post` requires `scheduled_at` to be at least 5 minutes in the future to allow
|
|
32
|
+
* human review and emergency cancellation.
|
|
33
|
+
* 4. Immediate Dispatch Review Diode:
|
|
34
|
+
* `post_run` requires verified human review approval or dry-run validation.
|
|
35
|
+
* 5. Campaign Budget & Brand Safety Guardrails:
|
|
36
|
+
* Ceilings on campaign budgets ($500 ceiling without executive override) and
|
|
37
|
+
* regex filtering of deceptive or predatory claims.
|
|
38
|
+
*
|
|
39
|
+
* Maps onto existing ThumbGate rails:
|
|
40
|
+
* - PreToolUse gate: Evaluates Siren MCP calls before dispatch.
|
|
41
|
+
* - Gate template: gate-siren-mcp-marketing-diode.
|
|
42
|
+
* - Verification evidence: Cryptographic attestation of reviewed campaign payloads.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
const fs = require('node:fs');
|
|
46
|
+
const path = require('node:path');
|
|
47
|
+
|
|
48
|
+
const REPORT_SOURCE_URL = 'https://github.com/Hexahedral-Inc/siren-mcp';
|
|
49
|
+
|
|
50
|
+
const SIREN_MCP_TOOLS = Object.freeze({
|
|
51
|
+
post_run: {
|
|
52
|
+
name: 'post_run',
|
|
53
|
+
description: 'Immediately publishes a marketing post to live social channels',
|
|
54
|
+
mutating: true,
|
|
55
|
+
requiresApproval: true,
|
|
56
|
+
},
|
|
57
|
+
schedule_post: {
|
|
58
|
+
name: 'schedule_post',
|
|
59
|
+
description: 'Schedules a marketing post for future publication at scheduled_at',
|
|
60
|
+
mutating: true,
|
|
61
|
+
requiresApproval: false,
|
|
62
|
+
minBufferSeconds: 300, // 5 minutes
|
|
63
|
+
},
|
|
64
|
+
create_campaign: {
|
|
65
|
+
name: 'create_campaign',
|
|
66
|
+
description: 'Creates a multi-channel autonomous marketing campaign',
|
|
67
|
+
mutating: true,
|
|
68
|
+
requiresApproval: true,
|
|
69
|
+
maxDailyBudgetUsd: 500,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const BRAND_SAFETY_PATTERNS = Object.freeze([
|
|
74
|
+
{
|
|
75
|
+
id: 'guaranteed_returns',
|
|
76
|
+
regex: /(?:100%|guaranteed|risk-?free)\s+(?:profit|returns|gains|roi)/i,
|
|
77
|
+
severity: 'critical',
|
|
78
|
+
description: 'Deceptive investment or profit claims prohibited by FTC/SEC regulations.',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'unlimited_free_bait',
|
|
82
|
+
regex: /unlimited\s+free\s+(?:credits|tokens|cash|money)/i,
|
|
83
|
+
severity: 'high',
|
|
84
|
+
description: 'Deceptive promotional claims offering unlimited free compute/tokens.',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 'competitor_defamation',
|
|
88
|
+
regex: /(?:scam|fraud|illegal|crooks)\s+like\s+[a-z0-9_-]+/i,
|
|
89
|
+
severity: 'critical',
|
|
90
|
+
description: 'Defamatory attacks against competitor platforms or individuals.',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: 'credential_leak_sample',
|
|
94
|
+
regex: /(?:ghp_[a-z0-9]{30,}|sk-[a-z0-9]{32,}|siren_[a-z0-9]{24,})/i,
|
|
95
|
+
severity: 'critical',
|
|
96
|
+
description: 'Accidental inclusion of API keys or access tokens in public marketing copy.',
|
|
97
|
+
},
|
|
98
|
+
]);
|
|
99
|
+
|
|
100
|
+
const FORMAT_MAPPING = Object.freeze([
|
|
101
|
+
{
|
|
102
|
+
sirenFeature: 'post_run tool call',
|
|
103
|
+
thumbgateRail: 'PreToolUse Diode & Human-in-the-Loop review floor',
|
|
104
|
+
action: 'Requires dry_run:true or humanReviewApproval token before live broadcast',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
sirenFeature: 'schedule_post tool call',
|
|
108
|
+
thumbgateRail: 'Scheduling window buffer guard',
|
|
109
|
+
action: 'Enforces >= 300s window buffer from current timestamp',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
sirenFeature: 'create_campaign tool call',
|
|
113
|
+
thumbgateRail: 'Budget ceiling & multi-asset safety validation',
|
|
114
|
+
action: 'Restricts campaign budget to <= $500 without executive override',
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
sirenFeature: 'Video asset publication',
|
|
118
|
+
thumbgateRail: 'Attribution diode',
|
|
119
|
+
action: 'Verifies presence of "Video made with Siren" or https://mysiren.ai link',
|
|
120
|
+
},
|
|
121
|
+
]);
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Checks whether content contains valid Siren attribution.
|
|
125
|
+
*/
|
|
126
|
+
function verifySirenAttribution(content) {
|
|
127
|
+
if (!content || typeof content !== 'string') {
|
|
128
|
+
return { hasAttribution: false, reason: 'missing_content' };
|
|
129
|
+
}
|
|
130
|
+
const hasTextAttribution = /video\s+made\s+with\s+siren/i.test(content);
|
|
131
|
+
const hasUrlAttribution = /https?:\/\/(?:www\.)?mysiren\.ai/i.test(content);
|
|
132
|
+
const hasAttribution = hasTextAttribution || hasUrlAttribution;
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
hasAttribution,
|
|
136
|
+
hasTextAttribution,
|
|
137
|
+
hasUrlAttribution,
|
|
138
|
+
reason: hasAttribution ? 'valid' : 'missing_siren_attribution',
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Evaluates scheduling window for schedule_post tool call.
|
|
144
|
+
*/
|
|
145
|
+
function evaluateSchedulingWindow(scheduledAt, options = {}) {
|
|
146
|
+
const now = options.now ? new Date(options.now) : new Date();
|
|
147
|
+
const minBufferSeconds = options.minBufferSeconds || 300;
|
|
148
|
+
|
|
149
|
+
if (!scheduledAt) {
|
|
150
|
+
return {
|
|
151
|
+
valid: false,
|
|
152
|
+
reason: 'missing_scheduled_at',
|
|
153
|
+
message: 'schedule_post requires a valid ISO-8601 scheduled_at timestamp.',
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const targetDate = new Date(scheduledAt);
|
|
158
|
+
if (Number.isNaN(targetDate.getTime())) {
|
|
159
|
+
return {
|
|
160
|
+
valid: false,
|
|
161
|
+
reason: 'invalid_timestamp_format',
|
|
162
|
+
message: `Invalid timestamp format for scheduled_at: "${scheduledAt}".`,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const deltaMs = targetDate.getTime() - now.getTime();
|
|
167
|
+
const deltaSeconds = Math.floor(deltaMs / 1000);
|
|
168
|
+
|
|
169
|
+
if (deltaSeconds < 0) {
|
|
170
|
+
return {
|
|
171
|
+
valid: false,
|
|
172
|
+
reason: 'timestamp_in_past',
|
|
173
|
+
deltaSeconds,
|
|
174
|
+
message: `scheduled_at is in the past (${Math.abs(deltaSeconds)}s ago).`,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (deltaSeconds < minBufferSeconds) {
|
|
179
|
+
return {
|
|
180
|
+
valid: false,
|
|
181
|
+
reason: 'buffer_too_small',
|
|
182
|
+
deltaSeconds,
|
|
183
|
+
minBufferSeconds,
|
|
184
|
+
message: `scheduled_at buffer (${deltaSeconds}s) is smaller than required safety window (${minBufferSeconds}s).`,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
valid: true,
|
|
190
|
+
deltaSeconds,
|
|
191
|
+
reason: 'valid_window',
|
|
192
|
+
message: `Scheduled ${deltaSeconds}s in the future (meets >= ${minBufferSeconds}s buffer requirement).`,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Scans marketing content for brand safety violations.
|
|
198
|
+
*/
|
|
199
|
+
function scanBrandSafety(text) {
|
|
200
|
+
if (!text || typeof text !== 'string') {
|
|
201
|
+
return { safe: true, violations: [] };
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const violations = [];
|
|
205
|
+
for (const pattern of BRAND_SAFETY_PATTERNS) {
|
|
206
|
+
if (pattern.regex.test(text)) {
|
|
207
|
+
violations.push({
|
|
208
|
+
id: pattern.id,
|
|
209
|
+
severity: pattern.severity,
|
|
210
|
+
description: pattern.description,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
safe: violations.length === 0,
|
|
217
|
+
violations,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Evaluates budget for campaign creation.
|
|
223
|
+
*/
|
|
224
|
+
function evaluateCampaignBudget(budgetUsd, options = {}) {
|
|
225
|
+
const maxBudget = options.maxDailyBudgetUsd || SIREN_MCP_TOOLS.create_campaign.maxDailyBudgetUsd;
|
|
226
|
+
const executiveOverride = Boolean(options.executiveOverride);
|
|
227
|
+
|
|
228
|
+
if (budgetUsd === undefined || budgetUsd === null) {
|
|
229
|
+
return {
|
|
230
|
+
valid: true,
|
|
231
|
+
budgetUsd: 0,
|
|
232
|
+
reason: 'zero_or_unspecified_budget',
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (Array.isArray(budgetUsd) || typeof budgetUsd === 'boolean') {
|
|
237
|
+
return {
|
|
238
|
+
valid: false,
|
|
239
|
+
reason: 'invalid_budget_value',
|
|
240
|
+
message: `Campaign budget must be a positive number: "${budgetUsd}".`,
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const numBudget = Number(budgetUsd);
|
|
245
|
+
if (!Number.isFinite(numBudget) || numBudget < 0) {
|
|
246
|
+
return {
|
|
247
|
+
valid: false,
|
|
248
|
+
reason: 'invalid_budget_value',
|
|
249
|
+
message: `Campaign budget must be a positive number: "${budgetUsd}".`,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (numBudget > maxBudget && !executiveOverride) {
|
|
254
|
+
return {
|
|
255
|
+
valid: false,
|
|
256
|
+
budgetUsd: numBudget,
|
|
257
|
+
maxBudget,
|
|
258
|
+
reason: 'budget_limit_exceeded',
|
|
259
|
+
message: `Campaign budget ($${numBudget}) exceeds standard ceiling ($${maxBudget}) without executive override.`,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return {
|
|
264
|
+
valid: true,
|
|
265
|
+
budgetUsd: numBudget,
|
|
266
|
+
maxBudget,
|
|
267
|
+
reason: 'within_budget',
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Evaluates a proposed Siren MCP tool call against ThumbGate governance rules.
|
|
273
|
+
*
|
|
274
|
+
* @param {string} toolName - One of post_run, schedule_post, create_campaign
|
|
275
|
+
* @param {object} args - Tool arguments payload
|
|
276
|
+
* @param {object} [options] - Configuration & context options
|
|
277
|
+
* @returns {object} Evaluation verdict: { allowed, action, reasons, details }
|
|
278
|
+
*/
|
|
279
|
+
function evaluateSirenToolCall(toolName, args = {}, options = {}) {
|
|
280
|
+
const strict = Boolean(options.strict);
|
|
281
|
+
const tool = SIREN_MCP_TOOLS[toolName];
|
|
282
|
+
|
|
283
|
+
if (!tool) {
|
|
284
|
+
return {
|
|
285
|
+
allowed: false,
|
|
286
|
+
action: 'block',
|
|
287
|
+
reasons: [`unknown_siren_tool: "${toolName}" is not an allowlisted Siren MCP tool.`],
|
|
288
|
+
details: {
|
|
289
|
+
toolName,
|
|
290
|
+
allowlistedTools: Object.keys(SIREN_MCP_TOOLS),
|
|
291
|
+
},
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const reasons = [];
|
|
296
|
+
let requiresReview = false;
|
|
297
|
+
let blocked = false;
|
|
298
|
+
|
|
299
|
+
// 1. Content Brand Safety Scan
|
|
300
|
+
const textContent = [
|
|
301
|
+
args.content,
|
|
302
|
+
args.caption,
|
|
303
|
+
args.description,
|
|
304
|
+
args.text,
|
|
305
|
+
args.title,
|
|
306
|
+
args.campaign_name,
|
|
307
|
+
].filter(Boolean).join(' ');
|
|
308
|
+
|
|
309
|
+
const safetyResult = scanBrandSafety(textContent);
|
|
310
|
+
if (!safetyResult.safe) {
|
|
311
|
+
blocked = true;
|
|
312
|
+
for (const v of safetyResult.violations) {
|
|
313
|
+
reasons.push(`brand_safety_violation (${v.id}): ${v.description}`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// 2. Attribution Diode Check
|
|
318
|
+
// Enforced if video is present or if content explicitly describes generated video
|
|
319
|
+
const hasVideoPayload = Boolean(
|
|
320
|
+
args.video_url ||
|
|
321
|
+
args.video ||
|
|
322
|
+
args.media_url ||
|
|
323
|
+
(args.media_type && args.media_type.includes('video')) ||
|
|
324
|
+
/video|clip|reel|short|mp4/i.test(textContent)
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
const attributionResult = verifySirenAttribution(textContent);
|
|
328
|
+
if (hasVideoPayload && !attributionResult.hasAttribution) {
|
|
329
|
+
if (strict) {
|
|
330
|
+
blocked = true;
|
|
331
|
+
reasons.push('missing_siren_attribution: Video marketing content requires "Video made with Siren" or https://mysiren.ai link attribution.');
|
|
332
|
+
} else {
|
|
333
|
+
requiresReview = true;
|
|
334
|
+
reasons.push('missing_siren_attribution: Video marketing content lacks "Video made with Siren" or https://mysiren.ai link attribution.');
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// 3. Tool-Specific Diodes
|
|
339
|
+
if (toolName === 'post_run') {
|
|
340
|
+
const isDryRun = Boolean(args.dry_run || options.dryRun);
|
|
341
|
+
const hasHumanApproval = Boolean(options.humanApproval || options.reviewed || options.approval_id);
|
|
342
|
+
|
|
343
|
+
if (!isDryRun && !hasHumanApproval) {
|
|
344
|
+
if (strict) {
|
|
345
|
+
blocked = true;
|
|
346
|
+
reasons.push('unreviewed_immediate_dispatch: Immediate live social broadcast requires humanReview approval or dry_run:true.');
|
|
347
|
+
} else {
|
|
348
|
+
requiresReview = true;
|
|
349
|
+
reasons.push('unreviewed_immediate_dispatch: Immediate live social broadcast requires human review confirmation before publication.');
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
} else if (toolName === 'schedule_post') {
|
|
353
|
+
const windowResult = evaluateSchedulingWindow(args.scheduled_at, {
|
|
354
|
+
now: options.now,
|
|
355
|
+
minBufferSeconds: options.minBufferSeconds || tool.minBufferSeconds,
|
|
356
|
+
});
|
|
357
|
+
if (!windowResult.valid) {
|
|
358
|
+
blocked = true;
|
|
359
|
+
reasons.push(`invalid_scheduling_window: ${windowResult.message}`);
|
|
360
|
+
}
|
|
361
|
+
} else if (toolName === 'create_campaign') {
|
|
362
|
+
const budgetResult = evaluateCampaignBudget(args.budget || args.daily_budget, {
|
|
363
|
+
maxDailyBudgetUsd: options.maxDailyBudgetUsd || tool.maxDailyBudgetUsd,
|
|
364
|
+
executiveOverride: options.executiveOverride,
|
|
365
|
+
});
|
|
366
|
+
if (!budgetResult.valid) {
|
|
367
|
+
blocked = true;
|
|
368
|
+
reasons.push(`budget_limit_exceeded: ${budgetResult.message}`);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
let action = 'allow';
|
|
373
|
+
if (blocked) {
|
|
374
|
+
action = 'block';
|
|
375
|
+
} else if (requiresReview) {
|
|
376
|
+
action = 'review';
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return {
|
|
380
|
+
allowed: action === 'allow',
|
|
381
|
+
action,
|
|
382
|
+
reasons,
|
|
383
|
+
details: {
|
|
384
|
+
toolName,
|
|
385
|
+
safetyResult,
|
|
386
|
+
attributionResult,
|
|
387
|
+
isStrict: strict,
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Builds the comprehensive governance report for CLI/diagnostic invocation.
|
|
394
|
+
*/
|
|
395
|
+
function buildSirenGovernanceReport(options = {}) {
|
|
396
|
+
const mapOnly = Boolean(options.mapOnly || options['map-only']);
|
|
397
|
+
const strict = Boolean(options.strict);
|
|
398
|
+
const toolName = options.tool || options['tool-name'];
|
|
399
|
+
const rawArgs = options.args || options.payload;
|
|
400
|
+
|
|
401
|
+
if (mapOnly) {
|
|
402
|
+
return {
|
|
403
|
+
status: 'pass',
|
|
404
|
+
mode: 'map-only',
|
|
405
|
+
sourceUrl: REPORT_SOURCE_URL,
|
|
406
|
+
mapping: FORMAT_MAPPING,
|
|
407
|
+
tools: SIREN_MCP_TOOLS,
|
|
408
|
+
brandSafetyRulesCount: BRAND_SAFETY_PATTERNS.length,
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
let evaluation = null;
|
|
413
|
+
if (toolName) {
|
|
414
|
+
let parsedArgs = {};
|
|
415
|
+
if (typeof rawArgs === 'string') {
|
|
416
|
+
try {
|
|
417
|
+
parsedArgs = JSON.parse(rawArgs);
|
|
418
|
+
} catch (err) {
|
|
419
|
+
return {
|
|
420
|
+
status: 'fail',
|
|
421
|
+
error: `Failed to parse --args as JSON: ${err.message}`,
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
} else if (typeof rawArgs === 'object' && rawArgs !== null) {
|
|
425
|
+
parsedArgs = rawArgs;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
evaluation = evaluateSirenToolCall(toolName, parsedArgs, { strict });
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return {
|
|
432
|
+
status: evaluation ? (evaluation.allowed ? 'pass' : 'fail') : 'pass',
|
|
433
|
+
toolName: toolName || null,
|
|
434
|
+
evaluation,
|
|
435
|
+
sourceUrl: REPORT_SOURCE_URL,
|
|
436
|
+
strict,
|
|
437
|
+
timestamp: new Date().toISOString(),
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Formats the governance report into clean human-readable text.
|
|
443
|
+
*/
|
|
444
|
+
function formatSirenGovernanceReport(report) {
|
|
445
|
+
const lines = [];
|
|
446
|
+
lines.push('=== Siren MCP Autonomous Marketing Governance ===');
|
|
447
|
+
lines.push(`Source: ${report.sourceUrl || REPORT_SOURCE_URL}`);
|
|
448
|
+
lines.push(`Status: ${(report.status || 'pass').toUpperCase()}`);
|
|
449
|
+
|
|
450
|
+
if (report.mode === 'map-only') {
|
|
451
|
+
lines.push('\n--- FORMAT Transfers ---');
|
|
452
|
+
for (const item of report.mapping) {
|
|
453
|
+
lines.push(` • ${item.sirenFeature} -> ${item.thumbgateRail}`);
|
|
454
|
+
lines.push(` Action: ${item.action}`);
|
|
455
|
+
}
|
|
456
|
+
lines.push('\n--- Allowlisted Siren MCP Tools ---');
|
|
457
|
+
for (const [name, meta] of Object.entries(report.tools)) {
|
|
458
|
+
lines.push(` • ${name}: ${meta.description}`);
|
|
459
|
+
}
|
|
460
|
+
return lines.join('\n');
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
if (report.evaluation) {
|
|
464
|
+
const ev = report.evaluation;
|
|
465
|
+
lines.push(`Tool: ${ev.details.toolName}`);
|
|
466
|
+
lines.push(`Action: ${ev.action.toUpperCase()}`);
|
|
467
|
+
lines.push(`Allowed: ${ev.allowed ? 'YES' : 'NO'}`);
|
|
468
|
+
if (ev.reasons.length > 0) {
|
|
469
|
+
lines.push('Reasons:');
|
|
470
|
+
for (const r of ev.reasons) {
|
|
471
|
+
lines.push(` - ${r}`);
|
|
472
|
+
}
|
|
473
|
+
} else {
|
|
474
|
+
lines.push('Result: All marketing diodes and attribution rules passed.');
|
|
475
|
+
}
|
|
476
|
+
} else {
|
|
477
|
+
lines.push('No tool call specified. Run with --tool <toolName> --args <json> to evaluate a tool call, or --map-only for architectural rails.');
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
return lines.join('\n');
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function parseCliArgs(args) {
|
|
484
|
+
const options = {
|
|
485
|
+
json: args.includes('--json'),
|
|
486
|
+
mapOnly: args.includes('--map-only'),
|
|
487
|
+
strict: args.includes('--strict'),
|
|
488
|
+
tool: null,
|
|
489
|
+
args: null,
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
const toolIdx = args.indexOf('--tool');
|
|
493
|
+
if (toolIdx !== -1 && args[toolIdx + 1]) {
|
|
494
|
+
options.tool = args[toolIdx + 1];
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
const argsIdx = args.indexOf('--args');
|
|
498
|
+
if (argsIdx !== -1 && args[argsIdx + 1]) {
|
|
499
|
+
options.args = args[argsIdx + 1];
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
return options;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
function main() {
|
|
506
|
+
const args = process.argv.slice(2);
|
|
507
|
+
const options = parseCliArgs(args);
|
|
508
|
+
|
|
509
|
+
const report = buildSirenGovernanceReport(options);
|
|
510
|
+
|
|
511
|
+
if (options.json) {
|
|
512
|
+
console.log(JSON.stringify(report, null, 2));
|
|
513
|
+
} else {
|
|
514
|
+
console.log(formatSirenGovernanceReport(report));
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (report.status === 'fail' || (report.evaluation && !report.evaluation.allowed)) {
|
|
518
|
+
process.exitCode = 1;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
if (require.main === module) {
|
|
523
|
+
main();
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
module.exports = {
|
|
527
|
+
REPORT_SOURCE_URL,
|
|
528
|
+
SIREN_MCP_TOOLS,
|
|
529
|
+
BRAND_SAFETY_PATTERNS,
|
|
530
|
+
FORMAT_MAPPING,
|
|
531
|
+
verifySirenAttribution,
|
|
532
|
+
evaluateSchedulingWindow,
|
|
533
|
+
scanBrandSafety,
|
|
534
|
+
evaluateCampaignBudget,
|
|
535
|
+
evaluateSirenToolCall,
|
|
536
|
+
buildSirenGovernanceReport,
|
|
537
|
+
formatSirenGovernanceReport,
|
|
538
|
+
parseCliArgs,
|
|
539
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Strands Box & Multi-Harness Doctor CLI
|
|
6
|
+
*
|
|
7
|
+
* Validates:
|
|
8
|
+
* 1. Strands Box containment and Dogwood policy engine health
|
|
9
|
+
* 2. Credential diode gateway (verifies secrets are injected outbound without local leak)
|
|
10
|
+
* 3. Multi-harness RL invariant transfer compliance across 5 harnesses
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const { performance } = require('node:perf_hooks');
|
|
14
|
+
const { createBoxSession, evaluateBoxAction, EVENT_FS_READ, EVENT_HTTP_REQUEST, EVENT_FS_DELETE } = require('../adapters/strands/strands-box-diode');
|
|
15
|
+
const { normalizeToCanonicalAction, evaluateCrossHarnessInvariants, calculateTransferScorecard } = require('./multi-harness-invariants');
|
|
16
|
+
|
|
17
|
+
function runStrandsBoxDiagnostics() {
|
|
18
|
+
const start = performance.now();
|
|
19
|
+
const checks = [];
|
|
20
|
+
|
|
21
|
+
// 1. Box Session Creation & Taint Tracking
|
|
22
|
+
const session = createBoxSession({
|
|
23
|
+
name: 'doctor-box',
|
|
24
|
+
workspace: process.cwd(),
|
|
25
|
+
credentialRoutes: [
|
|
26
|
+
{ match: 'api.stripe.com', header: 'Authorization', inject: 'Bearer sk_live_test_credential_injected' }
|
|
27
|
+
],
|
|
28
|
+
rateLimits: {
|
|
29
|
+
'http:request': { maxCount: 5, windowSeconds: 60 }
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const readVerdict = evaluateBoxAction(session, {
|
|
34
|
+
type: EVENT_FS_READ,
|
|
35
|
+
target: '.env.production'
|
|
36
|
+
});
|
|
37
|
+
checks.push({
|
|
38
|
+
name: 'taint_propagation_on_secret_read',
|
|
39
|
+
pass: readVerdict.allowed === true && session.isTainted === true,
|
|
40
|
+
detail: `Tainted status: ${session.isTainted}, Reason: ${readVerdict.reason}`
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// 2. Exfiltration Diode (Outbound blocked when tainted)
|
|
44
|
+
const exfilVerdict = evaluateBoxAction(session, {
|
|
45
|
+
type: EVENT_HTTP_REQUEST,
|
|
46
|
+
target: 'https://malicious-leak-sink.com/collect'
|
|
47
|
+
});
|
|
48
|
+
checks.push({
|
|
49
|
+
name: 'exfiltration_diode_blocks_tainted_egress',
|
|
50
|
+
pass: exfilVerdict.allowed === false && exfilVerdict.decision === 'BLOCK',
|
|
51
|
+
detail: `Verdict: ${exfilVerdict.decision}, Reason: ${exfilVerdict.reason}`
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// 3. Credential Injection Diode (Placeholder replaced on allowlisted host)
|
|
55
|
+
const untaintedSession = createBoxSession({
|
|
56
|
+
name: 'clean-box',
|
|
57
|
+
credentialRoutes: [
|
|
58
|
+
{ match: 'api.stripe.com', inject: 'Bearer sk_live_diode_vault_secret' }
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
const credVerdict = evaluateBoxAction(untaintedSession, {
|
|
62
|
+
type: EVENT_HTTP_REQUEST,
|
|
63
|
+
target: 'https://api.stripe.com/v1/charges',
|
|
64
|
+
params: { headers: { Authorization: 'Bearer strands_placeholder_token' } }
|
|
65
|
+
});
|
|
66
|
+
const injectedSecret = credVerdict.transformedParams?.headers?.Authorization === 'Bearer sk_live_diode_vault_secret';
|
|
67
|
+
checks.push({
|
|
68
|
+
name: 'credential_injection_diode',
|
|
69
|
+
pass: credVerdict.allowed === true && injectedSecret,
|
|
70
|
+
detail: `Injected auth: ${credVerdict.injectedAuth}`
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// 4. Critical Deletion Containment
|
|
74
|
+
const deleteVerdict = evaluateBoxAction(session, {
|
|
75
|
+
type: EVENT_FS_DELETE,
|
|
76
|
+
target: '/'
|
|
77
|
+
});
|
|
78
|
+
checks.push({
|
|
79
|
+
name: 'destructive_root_deletion_blocked',
|
|
80
|
+
pass: deleteVerdict.allowed === false && deleteVerdict.decision === 'BLOCK',
|
|
81
|
+
detail: `Verdict: ${deleteVerdict.decision}, Reason: ${deleteVerdict.reason}`
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// 5. Multi-Harness Canonical Normalization
|
|
85
|
+
const testTrajectory = [
|
|
86
|
+
{ harness: 'antigravity', toolName: 'run_command', args: { CommandLine: 'npm test' } },
|
|
87
|
+
{ harness: 'claude_code', toolName: 'Bash', args: { command: 'git status' } },
|
|
88
|
+
{ harness: 'strands', toolName: 'shell', args: { cmd: 'ls -la' } },
|
|
89
|
+
{ harness: 'openhands', toolName: 'execute_bash', args: { cmd: 'cargo build' } }
|
|
90
|
+
];
|
|
91
|
+
const scorecard = calculateTransferScorecard(testTrajectory);
|
|
92
|
+
checks.push({
|
|
93
|
+
name: 'multi_harness_transfer_scorecard',
|
|
94
|
+
pass: scorecard.formatSuccessRate === 1.0 && scorecard.transferReward > 0.8,
|
|
95
|
+
detail: `Observed: ${scorecard.harnessesObserved.join(', ')}, Reward: ${scorecard.transferReward}`
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const totalPassed = checks.filter(c => c.pass).length;
|
|
99
|
+
const elapsed = performance.now() - start;
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
status: totalPassed === checks.length ? 'HEALTHY' : 'DEGRADED',
|
|
103
|
+
checksPassed: totalPassed,
|
|
104
|
+
checksTotal: checks.length,
|
|
105
|
+
elapsedMs: Number(elapsed.toFixed(3)),
|
|
106
|
+
checks,
|
|
107
|
+
scorecard
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (require.main === module) {
|
|
112
|
+
const isJson = process.argv.includes('--json');
|
|
113
|
+
const results = runStrandsBoxDiagnostics();
|
|
114
|
+
|
|
115
|
+
if (isJson) {
|
|
116
|
+
console.log(JSON.stringify(results, null, 2));
|
|
117
|
+
} else {
|
|
118
|
+
console.log(`\n=== Strands Box & Multi-Harness Doctor ===`);
|
|
119
|
+
console.log(`Status: ${results.status} (${results.checksPassed}/${results.checksTotal} checks passed in ${results.elapsedMs}ms)\n`);
|
|
120
|
+
for (const check of results.checks) {
|
|
121
|
+
const mark = check.pass ? '✓' : '✖';
|
|
122
|
+
console.log(` ${mark} ${check.name.padEnd(45)} : ${check.detail}`);
|
|
123
|
+
}
|
|
124
|
+
console.log(`\nMulti-Harness Transfer Reward: ${results.scorecard.transferReward} (Harnesses: ${results.scorecard.harnessesObserved.join(', ')})\n`);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
process.exit(results.status === 'HEALTHY' ? 0 : 1);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
module.exports = { runStrandsBoxDiagnostics };
|