adaptive-memory-multi-model-router 2.13.17 → 2.13.20
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/.dockerignore +82 -0
- package/.env.example +303 -0
- package/.github/DISCUSSIONS_WELCOME.md +27 -0
- package/.github/DISCUSSION_TEMPLATE.yml +5 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +83 -12
- package/.github/ISSUE_TEMPLATE/config.yml +12 -6
- package/.github/ISSUE_TEMPLATE/feature_request.md +61 -10
- package/.github/PULL_REQUEST_TEMPLATE.md +53 -26
- package/.github/dependabot.yml +9 -0
- package/.github/workflows/codeql.yml +38 -0
- package/.github/workflows/npm-publish.yml +20 -0
- package/.github/workflows/stale.yml +56 -0
- package/ARCHITECTURE.md +346 -0
- package/AUDIT_REPORT.md +28 -0
- package/CHANGELOG.md +386 -22
- package/CONTRIBUTORS.md +20 -0
- package/Dockerfile +53 -0
- package/Dockerfile.proxy +33 -0
- package/PR_STATUS_REPORT.md +148 -0
- package/README.md +22 -0
- package/RUNKIT.md +83 -0
- package/_schema.html +61 -15
- package/articles/AI_AGENT_LLM_ROUTING.md +150 -0
- package/articles/FROM_ZERO_TO_10K.md +107 -0
- package/articles/LLM_BENCHMARK_DEEP_DIVE.md +153 -0
- package/articles/TWEETS_10K_DOWNLOADS.md +47 -0
- package/articles/TWEETS_BENCHMARK_FIRST.md +46 -0
- package/articles/TWEETS_MCP_PLAY.md +51 -0
- package/articles/TWEETS_SEQUENTIAL_BROKEN.md +49 -0
- package/articles/TWEETS_WHY_BUILD.md +54 -0
- package/benchmark-results.json +26 -45
- package/cli/a3m +840 -0
- package/demo/package.json +13 -0
- package/demo/public/index.html +762 -0
- package/demo/server.js +405 -0
- package/dist/cli.js +4 -0
- package/docker-compose.yml +74 -0
- package/docs/.nojekyll +0 -0
- package/docs/BENCHMARK.md +96 -22
- package/docs/_config.yml +49 -0
- package/docs/api.html +513 -0
- package/docs/benchmark.html +387 -0
- package/docs/cli-cheatsheet.md +339 -0
- package/docs/comparison.md +108 -0
- package/docs/curl-examples.md +247 -0
- package/docs/index.html +390 -99
- package/docs/openapi.yaml +1318 -0
- package/docs/quick-start.html +366 -0
- package/docs/robots.txt +1 -1
- package/docs/sitemap.xml +23 -5
- package/docs/styles.css +682 -0
- package/examples/README.md +61 -0
- package/examples/a3m-sdk.js +124 -0
- package/examples/basic-route.js +54 -0
- package/examples/chat-loop.js +202 -0
- package/examples/classify-then-route.js +102 -0
- package/examples/cost-compare.js +120 -0
- package/examples/ensemble.js +160 -0
- package/hf-space/README.md +22 -0
- package/hf-space/app.py +97 -0
- package/integrations/langchain/README.md +216 -0
- package/integrations/langchain/a3m_langchain.ts +1360 -0
- package/integrations/langchain/example.ts +287 -0
- package/integrations/vercel-ai-sdk/README.md +49 -0
- package/integrations/vercel-ai-sdk/a3m_provider.ts +78 -0
- package/integrations/vercel-ai-sdk/example.ts +25 -0
- package/llms-full.txt +43 -0
- package/llms.txt +9 -0
- package/mcp-server/README.md +188 -0
- package/mcp-server/package.json +29 -0
- package/mcp-server/src/index.ts +744 -0
- package/mcp-server/tsconfig.json +19 -0
- package/package.json +3 -3
- package/proxy/README.md +227 -0
- package/proxy/package-lock.json +831 -0
- package/proxy/package.json +17 -0
- package/proxy/rate-limit.js +145 -0
- package/proxy/rate-limit.test.js +311 -0
- package/proxy/server.js +970 -0
- package/scripts/banner.js +29 -0
- package/scripts/compare-providers.sh +230 -0
- package/scripts/cross_post.py +443 -0
- package/scripts/publish_fcc.py +106 -0
- package/scripts/push-to-gitee.sh +52 -0
- package/src/tui/dashboard.ts +13 -0
- package/tests/__mocks__/tokenUtils.ts +22 -0
- package/tests/memory/episodicMemory.test.ts +227 -0
- package/tests/package-lock.json +1628 -0
- package/tests/package.json +18 -0
- package/tests/routing/ensembleVoting.test.ts +236 -0
- package/tests/routing/providerRetry.test.ts +360 -0
- package/tests/routing/queryTypePresets.test.ts +206 -0
- package/tests/tsconfig.json +21 -0
- package/tests/vitest.config.ts +18 -0
- package/.env +0 -2
- package/media/a3m-tui-screenshot.png +0 -0
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Cross-post A3M Router article to multiple platforms using Playwright (headless)
|
|
3
|
+
"""
|
|
4
|
+
import sys, json, time, os, re
|
|
5
|
+
from playwright.sync_api import sync_playwright, TimeoutError as PwTimeout
|
|
6
|
+
|
|
7
|
+
PROFILE_PATH = "/var/folders/l9/4016_h694kdbx1wvdg5881bh0000gp/T/chrome_profile_100llyqq"
|
|
8
|
+
|
|
9
|
+
def get_article_text():
|
|
10
|
+
path = "/Users/Subho/adaptive-memory-multi-model-router/articles/FRESH_devto_2026_05.md"
|
|
11
|
+
with open(path) as f:
|
|
12
|
+
return f.read()
|
|
13
|
+
|
|
14
|
+
def safe_screenshot(page, name):
|
|
15
|
+
try:
|
|
16
|
+
page.screenshot(path=f"/tmp/{name}.png")
|
|
17
|
+
except:
|
|
18
|
+
pass
|
|
19
|
+
|
|
20
|
+
def try_fcc(browser):
|
|
21
|
+
"""Try to publish on FreeCodeCamp"""
|
|
22
|
+
page = browser.new_page()
|
|
23
|
+
results = []
|
|
24
|
+
|
|
25
|
+
try:
|
|
26
|
+
print("\n=== FCC: Starting ===")
|
|
27
|
+
page.goto("https://www.freecodecamp.org/news/settings/publishing", timeout=30000, wait_until="domcontentloaded")
|
|
28
|
+
time.sleep(3)
|
|
29
|
+
safe_screenshot(page, "fcc_1_landing")
|
|
30
|
+
|
|
31
|
+
# Check if we're on login page
|
|
32
|
+
if "login" in page.url.lower() or page.query_selector('input[type="email"]'):
|
|
33
|
+
print("[FCC] Login page detected, logging in...")
|
|
34
|
+
email_input = page.wait_for_selector('input[type="email"]', timeout=5000)
|
|
35
|
+
email_input.fill("subho.matteragent@gmail.com")
|
|
36
|
+
|
|
37
|
+
pw_input = page.wait_for_selector('input[type="password"]', timeout=5000)
|
|
38
|
+
pw_input.fill("YourChance2025!")
|
|
39
|
+
|
|
40
|
+
submit = page.query_selector('button[type="submit"]')
|
|
41
|
+
if submit:
|
|
42
|
+
submit.click()
|
|
43
|
+
time.sleep(5)
|
|
44
|
+
safe_screenshot(page, "fcc_2_after_login")
|
|
45
|
+
|
|
46
|
+
# Navigate to publishing page again
|
|
47
|
+
page.goto("https://www.freecodecamp.org/news/settings/publishing", timeout=30000, wait_until="domcontentloaded")
|
|
48
|
+
time.sleep(3)
|
|
49
|
+
|
|
50
|
+
# Check page content
|
|
51
|
+
html = page.content()
|
|
52
|
+
if "draft" in html.lower():
|
|
53
|
+
print("[FCC] Found drafts!")
|
|
54
|
+
results.append("FCC: Found drafts page, check screenshots for details")
|
|
55
|
+
|
|
56
|
+
# Try clicking any edit/publish link for the A3M article
|
|
57
|
+
for link in page.query_selector_all('a'):
|
|
58
|
+
href = link.get_attribute('href') or ''
|
|
59
|
+
text = link.inner_text() or ''
|
|
60
|
+
if 'draft' in href or 'edit' in href:
|
|
61
|
+
print(f" Link: {text[:80]} -> {href}")
|
|
62
|
+
|
|
63
|
+
# Try finding publish buttons
|
|
64
|
+
for btn in page.query_selector_all('button'):
|
|
65
|
+
text = (btn.inner_text() or '').lower()
|
|
66
|
+
if 'publish' in text or 'submit' in text:
|
|
67
|
+
print(f" Button: {btn.inner_text()}")
|
|
68
|
+
btn.click()
|
|
69
|
+
time.sleep(3)
|
|
70
|
+
safe_screenshot(page, "fcc_3_publish_clicked")
|
|
71
|
+
results.append("FCC: Publish button clicked")
|
|
72
|
+
break
|
|
73
|
+
else:
|
|
74
|
+
print(f"[FCC] No drafts section - page title: {page.title()}")
|
|
75
|
+
results.append(f"FCC: No drafts accessible. Page: {page.title()}")
|
|
76
|
+
|
|
77
|
+
except Exception as e:
|
|
78
|
+
print(f"[FCC] Error: {e}")
|
|
79
|
+
results.append(f"FCC Error: {str(e)[:100]}")
|
|
80
|
+
safe_screenshot(page, "fcc_error")
|
|
81
|
+
|
|
82
|
+
page.close()
|
|
83
|
+
return results
|
|
84
|
+
|
|
85
|
+
def try_hackernoon(browser):
|
|
86
|
+
"""Try to post on HackerNoon"""
|
|
87
|
+
page = browser.new_page()
|
|
88
|
+
results = []
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
print("\n=== HackerNoon: Starting ===")
|
|
92
|
+
page.goto("https://hackernoon.com/", timeout=30000, wait_until="domcontentloaded")
|
|
93
|
+
time.sleep(3)
|
|
94
|
+
safe_screenshot(page, "hn_1_landing")
|
|
95
|
+
|
|
96
|
+
# Try to find login button
|
|
97
|
+
login_selectors = [
|
|
98
|
+
'a[href*="login"]', 'a[href*="signin"]', 'a[href*="sign-up"]',
|
|
99
|
+
'button:has-text("Log in")', 'button:has-text("Sign in")',
|
|
100
|
+
'a:has-text("Log in")', 'a:has-text("Sign in")',
|
|
101
|
+
'[data-cy="login-button"]', '[test-id="login"]'
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
clicked_login = False
|
|
105
|
+
for sel in login_selectors:
|
|
106
|
+
try:
|
|
107
|
+
btn = page.wait_for_selector(sel, timeout=2000)
|
|
108
|
+
if btn and btn.is_visible():
|
|
109
|
+
print(f"[HN] Found login button: {sel}")
|
|
110
|
+
btn.click()
|
|
111
|
+
time.sleep(3)
|
|
112
|
+
clicked_login = True
|
|
113
|
+
break
|
|
114
|
+
except:
|
|
115
|
+
continue
|
|
116
|
+
|
|
117
|
+
if not clicked_login:
|
|
118
|
+
# Try JavaScript click on all possible login elements
|
|
119
|
+
try:
|
|
120
|
+
page.evaluate("""
|
|
121
|
+
[...document.querySelectorAll('a, button')].find(el =>
|
|
122
|
+
el.innerText.toLowerCase().includes('log in') ||
|
|
123
|
+
el.innerText.toLowerCase().includes('sign in') ||
|
|
124
|
+
el.href?.includes('login')
|
|
125
|
+
)?.click()
|
|
126
|
+
""")
|
|
127
|
+
time.sleep(3)
|
|
128
|
+
except:
|
|
129
|
+
pass
|
|
130
|
+
|
|
131
|
+
safe_screenshot(page, "hn_2_login_clicked")
|
|
132
|
+
|
|
133
|
+
# Fill in credentials if login form appears
|
|
134
|
+
try:
|
|
135
|
+
email_input = page.wait_for_selector('input[type="email"], input[name="email"]', timeout=5000)
|
|
136
|
+
email_input.fill("subho.matteragent@gmail.com")
|
|
137
|
+
time.sleep(1)
|
|
138
|
+
|
|
139
|
+
pw_input = page.wait_for_selector('input[type="password"]', timeout=3000)
|
|
140
|
+
pw_input.fill("YourChance2025!")
|
|
141
|
+
time.sleep(1)
|
|
142
|
+
|
|
143
|
+
submit = page.query_selector('button[type="submit"]')
|
|
144
|
+
if submit:
|
|
145
|
+
submit.click()
|
|
146
|
+
time.sleep(5)
|
|
147
|
+
safe_screenshot(page, "hn_3_logged_in")
|
|
148
|
+
results.append("HN: Login attempted")
|
|
149
|
+
else:
|
|
150
|
+
print("[HN] No submit button found")
|
|
151
|
+
except:
|
|
152
|
+
print("[HN] No login form appeared")
|
|
153
|
+
results.append("HN: Login form did not appear (React/Cloudflare issue)")
|
|
154
|
+
|
|
155
|
+
# Try navigating to write/create post
|
|
156
|
+
page.goto("https://hackernoon.com/new-story", timeout=30000, wait_until="domcontentloaded")
|
|
157
|
+
time.sleep(3)
|
|
158
|
+
safe_screenshot(page, "hn_4_new_story")
|
|
159
|
+
|
|
160
|
+
# Check if we can write
|
|
161
|
+
html = page.content()
|
|
162
|
+
if "new-story" in page.url or "write" in page.url or "create" in page.url:
|
|
163
|
+
results.append("HN: On story creation page")
|
|
164
|
+
|
|
165
|
+
# Try to fill in title and content
|
|
166
|
+
title_input = page.query_selector('input[placeholder*="title" i], textarea[placeholder*="title" i], [contenteditable="true"]')
|
|
167
|
+
if title_input:
|
|
168
|
+
article = get_article_text()
|
|
169
|
+
lines = article.strip().split('\n')
|
|
170
|
+
title = lines[0].replace('#', '').strip() if lines[0].startswith('#') else "Three LLM Infrastructure Problems That Shouldn't Exist in 2026"
|
|
171
|
+
|
|
172
|
+
title_input.fill(title)
|
|
173
|
+
print(f"[HN] Filled title: {title}")
|
|
174
|
+
time.sleep(1)
|
|
175
|
+
|
|
176
|
+
# Try content area
|
|
177
|
+
content_area = page.query_selector('[contenteditable="true"], textarea, .ProseMirror, [data-lexical-editor]')
|
|
178
|
+
if content_area:
|
|
179
|
+
content_area.fill(article)
|
|
180
|
+
results.append("HN: Content filled")
|
|
181
|
+
safe_screenshot(page, "hn_5_content_filled")
|
|
182
|
+
else:
|
|
183
|
+
results.append("HN: Could not find content area")
|
|
184
|
+
else:
|
|
185
|
+
results.append("HN: No title input found")
|
|
186
|
+
else:
|
|
187
|
+
results.append(f"HN: Not on create page. URL: {page.url}")
|
|
188
|
+
|
|
189
|
+
except Exception as e:
|
|
190
|
+
print(f"[HN] Error: {e}")
|
|
191
|
+
results.append(f"HN Error: {str(e)[:100]}")
|
|
192
|
+
safe_screenshot(page, "hn_error")
|
|
193
|
+
|
|
194
|
+
page.close()
|
|
195
|
+
return results
|
|
196
|
+
|
|
197
|
+
def try_linkedin(browser):
|
|
198
|
+
"""Try to post on LinkedIn using Chrome profile cookies"""
|
|
199
|
+
page = browser.new_page()
|
|
200
|
+
results = []
|
|
201
|
+
|
|
202
|
+
try:
|
|
203
|
+
print("\n=== LinkedIn: Starting ===")
|
|
204
|
+
page.goto("https://www.linkedin.com", timeout=30000, wait_until="domcontentloaded")
|
|
205
|
+
time.sleep(3)
|
|
206
|
+
safe_screenshot(page, "li_1_landing")
|
|
207
|
+
|
|
208
|
+
# Check if already logged in
|
|
209
|
+
if "feed" in page.url or "/in/" in page.url:
|
|
210
|
+
print("[LI] Already logged in!")
|
|
211
|
+
results.append("LI: Already logged in")
|
|
212
|
+
else:
|
|
213
|
+
# Try logging in
|
|
214
|
+
try:
|
|
215
|
+
email_input = page.wait_for_selector('input#session_key, input[name="session_key"], input[autocomplete="username"]', timeout=5000)
|
|
216
|
+
email_input.fill("subho.matteragent@gmail.com")
|
|
217
|
+
time.sleep(1)
|
|
218
|
+
|
|
219
|
+
pw_input = page.wait_for_selector('input#session_password, input[name="session_password"]', timeout=3000)
|
|
220
|
+
pw_input.fill("YourChance2025!")
|
|
221
|
+
time.sleep(1)
|
|
222
|
+
|
|
223
|
+
submit = page.query_selector('button[type="submit"]')
|
|
224
|
+
if submit:
|
|
225
|
+
submit.click()
|
|
226
|
+
time.sleep(5)
|
|
227
|
+
safe_screenshot(page, "li_2_logged_in")
|
|
228
|
+
results.append("LI: Login attempted")
|
|
229
|
+
except:
|
|
230
|
+
print("[LI] No login form found or already logged in")
|
|
231
|
+
|
|
232
|
+
# Try to write an article
|
|
233
|
+
page.goto("https://www.linkedin.com/post/new/", timeout=30000, wait_until="domcontentloaded")
|
|
234
|
+
time.sleep(3)
|
|
235
|
+
safe_screenshot(page, "li_3_new_post")
|
|
236
|
+
|
|
237
|
+
# Check if we're on the post page
|
|
238
|
+
if "post" in page.url:
|
|
239
|
+
# Try clicking "Write article" or similar
|
|
240
|
+
for selector in ['button:has-text("Write article")', 'a:has-text("Write article")', 'button:has-text("Create post")']:
|
|
241
|
+
try:
|
|
242
|
+
btn = page.wait_for_selector(selector, timeout=3000)
|
|
243
|
+
if btn:
|
|
244
|
+
btn.click()
|
|
245
|
+
time.sleep(3)
|
|
246
|
+
break
|
|
247
|
+
except:
|
|
248
|
+
continue
|
|
249
|
+
|
|
250
|
+
safe_screenshot(page, "li_4_article_editor")
|
|
251
|
+
|
|
252
|
+
# Try to find contenteditable area
|
|
253
|
+
editor = page.query_selector('[contenteditable="true"][aria-label*="editor" i]')
|
|
254
|
+
if editor:
|
|
255
|
+
article = get_article_text()
|
|
256
|
+
editor.fill(article)
|
|
257
|
+
results.append("LI: Content filled in editor")
|
|
258
|
+
safe_screenshot(page, "li_5_content_filled")
|
|
259
|
+
else:
|
|
260
|
+
results.append("LI: Could not find article editor")
|
|
261
|
+
else:
|
|
262
|
+
results.append(f"LI: Not on post page. URL: {page.url}")
|
|
263
|
+
|
|
264
|
+
except Exception as e:
|
|
265
|
+
print(f"[LI] Error: {e}")
|
|
266
|
+
results.append(f"LI Error: {str(e)[:100]}")
|
|
267
|
+
safe_screenshot(page, "li_error")
|
|
268
|
+
|
|
269
|
+
page.close()
|
|
270
|
+
return results
|
|
271
|
+
|
|
272
|
+
def try_devto(browser):
|
|
273
|
+
"""Write and publish a SECOND article on dev.to"""
|
|
274
|
+
page = browser.new_page()
|
|
275
|
+
results = []
|
|
276
|
+
|
|
277
|
+
second_article = """---
|
|
278
|
+
title: Why Sequential LLM Fallback Is a Lie
|
|
279
|
+
published: false
|
|
280
|
+
description: How parallel LLM execution with confidence scoring replaces the illusion of sequential fallback with actual better results
|
|
281
|
+
tags: llm, ai, infrastructure, javascript
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## The Lie
|
|
285
|
+
|
|
286
|
+
Every LLM gateway does the same thing: try Provider A, wait, fail, try Provider B, wait, fail, try Provider C. They call this "fallback." But what it really means is you always get whatever Provider A returns — good or bad — and only try the others when A is completely broken.
|
|
287
|
+
|
|
288
|
+
This isn't a sophisticated strategy. It's basic error handling dressed up as infrastructure.
|
|
289
|
+
|
|
290
|
+
## The Math
|
|
291
|
+
|
|
292
|
+
Here's something no one talks about: **running 3 providers in parallel costs less than running 2 in sequence.**
|
|
293
|
+
|
|
294
|
+
Why? Timeout waste.
|
|
295
|
+
|
|
296
|
+
If Provider A has a 5-second timeout and you're running sequentially, you burn 5 seconds waiting before even touching Provider B. In a parallel setup, all 3 run simultaneously. You pay for all 3, but you get results in the time of the fastest provider.
|
|
297
|
+
|
|
298
|
+
Worst-case sequential: 5s (A timeout) + 5s (B timeout) + 5s (C timeout) = 15s
|
|
299
|
+
Worst-case parallel: 5s (all run simultaneously)
|
|
300
|
+
|
|
301
|
+
For many use cases — especially with providers averaging 300-700ms — parallel execution is both faster AND more reliable.
|
|
302
|
+
|
|
303
|
+
## How A3M Does It
|
|
304
|
+
|
|
305
|
+
Our router doesn't do fallback. It does **ensemble execution**:
|
|
306
|
+
|
|
307
|
+
1. Classify the query by type (code, creative, analytical, simple)
|
|
308
|
+
2. Route to 3 appropriate providers in parallel
|
|
309
|
+
3. Score every result on specificity, structure, and relevance
|
|
310
|
+
4. Return the best result with confidence scores attached
|
|
311
|
+
|
|
312
|
+
The result is you get the **best** answer, not the **first** answer. And you get it faster than most sequential fallback setups.
|
|
313
|
+
|
|
314
|
+
## The Bottom Line
|
|
315
|
+
|
|
316
|
+
Sequential fallback is a crutch from the era when LLM providers were unreliable. In 2026, most providers have >99% uptime. The bottleneck isn't reliability — it's picking the right provider for the right query.
|
|
317
|
+
|
|
318
|
+
Parallel ensemble execution solves the actual problem: getting the best possible answer in the shortest possible time.
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
*A3M Router — npm: `adaptive-memory-multi-model-router`*
|
|
323
|
+
*GitHub: [github.com/Das-rebel/a3m-router](https://github.com/Das-rebel/a3m-router)*
|
|
324
|
+
"""
|
|
325
|
+
|
|
326
|
+
try:
|
|
327
|
+
print("\n=== dev.to: Starting second article ===")
|
|
328
|
+
page.goto("https://dev.to/", timeout=30000, wait_until="domcontentloaded")
|
|
329
|
+
time.sleep(3)
|
|
330
|
+
safe_screenshot(page, "dev_1_landing")
|
|
331
|
+
|
|
332
|
+
# Try logging in
|
|
333
|
+
if "sign-in" in page.url.lower() or page.query_selector('input[type="email"]'):
|
|
334
|
+
print("[dev] Login page, signing in...")
|
|
335
|
+
try:
|
|
336
|
+
email_input = page.wait_for_selector('input[type="email"], input[name="user[email]"], input[autocomplete="email"]', timeout=5000)
|
|
337
|
+
email_input.fill("subho.matteragent@gmail.com")
|
|
338
|
+
time.sleep(1)
|
|
339
|
+
|
|
340
|
+
pw_input = page.wait_for_selector('input[type="password"], input[name="user[password]"]', timeout=3000)
|
|
341
|
+
pw_input.fill("YourChance2025!")
|
|
342
|
+
time.sleep(1)
|
|
343
|
+
|
|
344
|
+
submit = page.query_selector('button[type="submit"], input[type="submit"]')
|
|
345
|
+
if submit:
|
|
346
|
+
submit.click()
|
|
347
|
+
time.sleep(5)
|
|
348
|
+
safe_screenshot(page, "dev_2_logged_in")
|
|
349
|
+
except Exception as e:
|
|
350
|
+
print(f"[dev] Login form interaction failed: {e}")
|
|
351
|
+
|
|
352
|
+
# Navigate to write a post
|
|
353
|
+
page.goto("https://dev.to/new", timeout=30000, wait_until="domcontentloaded")
|
|
354
|
+
time.sleep(3)
|
|
355
|
+
safe_screenshot(page, "dev_3_new_post")
|
|
356
|
+
|
|
357
|
+
# Check if we're on the new post page
|
|
358
|
+
if "new" in page.url:
|
|
359
|
+
# Fill title
|
|
360
|
+
title_input = page.query_selector('input[placeholder*="title" i], input#article_title, textarea#article_title')
|
|
361
|
+
if title_input:
|
|
362
|
+
title_input.fill("Why Sequential LLM Fallback Is a Lie")
|
|
363
|
+
print("[dev] Title filled")
|
|
364
|
+
|
|
365
|
+
time.sleep(1)
|
|
366
|
+
|
|
367
|
+
# Fill body - dev.to uses a textarea or contenteditable
|
|
368
|
+
body_editor = page.query_selector('textarea#article_body_markdown, [contenteditable="true"][aria-label*="content" i], textarea[aria-label*="content" i]')
|
|
369
|
+
if body_editor:
|
|
370
|
+
body_editor.fill(second_article)
|
|
371
|
+
print("[dev] Body filled")
|
|
372
|
+
|
|
373
|
+
time.sleep(1)
|
|
374
|
+
|
|
375
|
+
# Try to publish
|
|
376
|
+
publish_btn = page.query_selector('button:has-text("Publish"), input[value*="Publish"]')
|
|
377
|
+
if publish_btn:
|
|
378
|
+
publish_btn.click()
|
|
379
|
+
time.sleep(3)
|
|
380
|
+
safe_screenshot(page, "dev_4_published")
|
|
381
|
+
results.append("dev.to: Publish attempted")
|
|
382
|
+
else:
|
|
383
|
+
# Try save as draft
|
|
384
|
+
save_btn = page.query_selector('button:has-text("Save"), button:has-text("Draft")')
|
|
385
|
+
if save_btn:
|
|
386
|
+
save_btn.click()
|
|
387
|
+
time.sleep(3)
|
|
388
|
+
safe_screenshot(page, "dev_4_saved")
|
|
389
|
+
results.append("dev.to: Saved as draft")
|
|
390
|
+
else:
|
|
391
|
+
results.append("dev.to: Could not find publish or save button")
|
|
392
|
+
|
|
393
|
+
safe_screenshot(page, "dev_final")
|
|
394
|
+
else:
|
|
395
|
+
results.append(f"dev.to: Not on new post page. URL: {page.url}")
|
|
396
|
+
# Maybe we need to click "Write a post" or similar
|
|
397
|
+
write_links = page.query_selector_all('a[href="/new"], a:has-text("Write"), a:has-text("Create")')
|
|
398
|
+
for link in write_links:
|
|
399
|
+
print(f" Write link: {link.inner_text()} -> {link.get_attribute('href')}")
|
|
400
|
+
link.click()
|
|
401
|
+
time.sleep(3)
|
|
402
|
+
break
|
|
403
|
+
|
|
404
|
+
except Exception as e:
|
|
405
|
+
print(f"[dev] Error: {e}")
|
|
406
|
+
results.append(f"dev.to Error: {str(e)[:100]}")
|
|
407
|
+
safe_screenshot(page, "dev_error")
|
|
408
|
+
|
|
409
|
+
page.close()
|
|
410
|
+
return results
|
|
411
|
+
|
|
412
|
+
def main():
|
|
413
|
+
print("=== Cross-Posting A3M Router Article ===\n")
|
|
414
|
+
|
|
415
|
+
all_results = {}
|
|
416
|
+
|
|
417
|
+
with sync_playwright() as p:
|
|
418
|
+
# Use persistent context with Chrome profile for cookies
|
|
419
|
+
context = p.chromium.launch_persistent_context(
|
|
420
|
+
PROFILE_PATH,
|
|
421
|
+
headless=True,
|
|
422
|
+
args=["--no-sandbox", "--disable-blink-features=AutomationControlled"],
|
|
423
|
+
user_agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
|
424
|
+
)
|
|
425
|
+
|
|
426
|
+
# Try each platform
|
|
427
|
+
all_results["fcc"] = try_fcc(context)
|
|
428
|
+
all_results["hackernoon"] = try_hackernoon(context)
|
|
429
|
+
all_results["linkedin"] = try_linkedin(context)
|
|
430
|
+
all_results["devto"] = try_devto(context)
|
|
431
|
+
|
|
432
|
+
context.close()
|
|
433
|
+
|
|
434
|
+
print("\n\n=== RESULTS SUMMARY ===")
|
|
435
|
+
for platform, results in all_results.items():
|
|
436
|
+
print(f"\n--- {platform.upper()} ---")
|
|
437
|
+
for r in results:
|
|
438
|
+
print(f" {r}")
|
|
439
|
+
|
|
440
|
+
print("\nScreenshots saved to /tmp/*.png")
|
|
441
|
+
|
|
442
|
+
if __name__ == "__main__":
|
|
443
|
+
main()
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"""
|
|
2
|
+
FreeCodeCamp - Publish existing draft for A3M Router article
|
|
3
|
+
"""
|
|
4
|
+
import sys, json, time, os
|
|
5
|
+
sys.path.insert(0, os.path.expanduser("~/omniclaw/skills/browser/sota-browser"))
|
|
6
|
+
from playwright.sync_api import sync_playwright, TimeoutError as PwTimeout
|
|
7
|
+
|
|
8
|
+
PROFILE_PATH = "/var/folders/l9/4016_h694kdbx1wvdg5881bh0000gp/T/chrome_profile_100llyqq"
|
|
9
|
+
FCC_EMAIL = "subho.matteragent@gmail.com"
|
|
10
|
+
FCC_PASSWORD = "YourChance2025!"
|
|
11
|
+
|
|
12
|
+
def main():
|
|
13
|
+
with sync_playwright() as p:
|
|
14
|
+
browser = p.chromium.launch_persistent_context(
|
|
15
|
+
PROFILE_PATH,
|
|
16
|
+
headless=False,
|
|
17
|
+
args=["--no-sandbox", "--disable-blink-features=AutomationControlled"]
|
|
18
|
+
)
|
|
19
|
+
page = browser.new_page()
|
|
20
|
+
|
|
21
|
+
try:
|
|
22
|
+
# Go to FCC publishing settings
|
|
23
|
+
print("[FCC] Navigating to publishing settings...")
|
|
24
|
+
page.goto("https://www.freecodecamp.org/news/settings/publishing", timeout=30000)
|
|
25
|
+
time.sleep(3)
|
|
26
|
+
page.screenshot(path="/tmp/fcc_1_landing.png")
|
|
27
|
+
|
|
28
|
+
# Check if we need to login
|
|
29
|
+
current_url = page.url
|
|
30
|
+
print(f"[FCC] Current URL: {current_url}")
|
|
31
|
+
|
|
32
|
+
if "login" in current_url or "signin" in current_url or "email" in page.content().lower():
|
|
33
|
+
print("[FCC] Need to login...")
|
|
34
|
+
# Try clicking email/password
|
|
35
|
+
try:
|
|
36
|
+
# Look for email field
|
|
37
|
+
email_input = page.wait_for_selector('input[type="email"], input[name="email"], input[placeholder*="email" i]', timeout=5000)
|
|
38
|
+
email_input.fill(FCC_EMAIL)
|
|
39
|
+
time.sleep(1)
|
|
40
|
+
|
|
41
|
+
# Look for password field
|
|
42
|
+
password_input = page.wait_for_selector('input[type="password"], input[name="password"]', timeout=5000)
|
|
43
|
+
password_input.fill(FCC_PASSWORD)
|
|
44
|
+
time.sleep(1)
|
|
45
|
+
|
|
46
|
+
# Find and click submit
|
|
47
|
+
submit_btn = page.query_selector('button[type="submit"], button:has-text("Sign in"), button:has-text("Login")')
|
|
48
|
+
if submit_btn:
|
|
49
|
+
submit_btn.click()
|
|
50
|
+
time.sleep(5)
|
|
51
|
+
|
|
52
|
+
page.screenshot(path="/tmp/fcc_2_after_login.png")
|
|
53
|
+
except Exception as e:
|
|
54
|
+
print(f"[FCC] Login interaction failed: {e}")
|
|
55
|
+
page.screenshot(path="/tmp/fcc_2_login_error.png")
|
|
56
|
+
|
|
57
|
+
# Now try to access publishing page
|
|
58
|
+
page.goto("https://www.freecodecamp.org/news/settings/publishing", timeout=30000)
|
|
59
|
+
time.sleep(3)
|
|
60
|
+
page.screenshot(path="/tmp/fcc_3_publishing.png")
|
|
61
|
+
|
|
62
|
+
# Check for drafts
|
|
63
|
+
content = page.content()
|
|
64
|
+
if "draft" in content.lower():
|
|
65
|
+
print("[FCC] Found drafts section!")
|
|
66
|
+
|
|
67
|
+
# Try to find and click on a draft
|
|
68
|
+
draft_links = page.query_selector_all('a:has-text("A3M"), a:has-text("Router"), a:has-text("LLM Infrastructure")')
|
|
69
|
+
if draft_links:
|
|
70
|
+
print(f"[FCC] Found {len(draft_links)} matching draft links")
|
|
71
|
+
draft_links[0].click()
|
|
72
|
+
time.sleep(3)
|
|
73
|
+
page.screenshot(path="/tmp/fcc_4_draft_editor.png")
|
|
74
|
+
|
|
75
|
+
# Look for publish button
|
|
76
|
+
publish_btn = page.query_selector('button:has-text("Publish"), button:has-text("Submit"), button:has-text("Post")')
|
|
77
|
+
if publish_btn:
|
|
78
|
+
print("[FCC] Found publish button, clicking...")
|
|
79
|
+
publish_btn.click()
|
|
80
|
+
time.sleep(3)
|
|
81
|
+
page.screenshot(path="/tmp/fcc_5_after_publish.png")
|
|
82
|
+
print("[FCC] Publishing attempted!")
|
|
83
|
+
else:
|
|
84
|
+
print("[FCC] No publish button found on draft page")
|
|
85
|
+
else:
|
|
86
|
+
print("[FCC] No matching draft links found")
|
|
87
|
+
# List all links for debugging
|
|
88
|
+
all_links = page.query_selector_all('a[href*="draft"], a[href*="edit"]')
|
|
89
|
+
for link in all_links:
|
|
90
|
+
print(f" Link: {link.inner_text()} -> {link.get_attribute('href')}")
|
|
91
|
+
else:
|
|
92
|
+
print("[FCC] No drafts section visible")
|
|
93
|
+
# Check what's on the page
|
|
94
|
+
print(f"[FCC] Page title: {page.title()}")
|
|
95
|
+
|
|
96
|
+
# Save the screenshot for debugging
|
|
97
|
+
page.screenshot(path="/tmp/fcc_final.png")
|
|
98
|
+
|
|
99
|
+
except Exception as e:
|
|
100
|
+
print(f"[FCC] Error: {e}")
|
|
101
|
+
page.screenshot(path="/tmp/fcc_error.png")
|
|
102
|
+
finally:
|
|
103
|
+
browser.close()
|
|
104
|
+
|
|
105
|
+
if __name__ == "__main__":
|
|
106
|
+
main()
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Push mirror to Gitee for Chinese SEO
|
|
3
|
+
# Usage: ./scripts/push-to-gitee.sh
|
|
4
|
+
# Prerequisites: Gitee account + SSH key configured
|
|
5
|
+
# Gitee repo: https://gitee.com/das-rebel/a3m-router
|
|
6
|
+
# Requires: git (>=2.0)
|
|
7
|
+
|
|
8
|
+
set -euo pipefail
|
|
9
|
+
|
|
10
|
+
GITEE_REPO="git@gitee.com:das-rebel/a3m-router.git"
|
|
11
|
+
GITHUB_REPO="https://github.com/Das-rebel/a3m-router.git"
|
|
12
|
+
|
|
13
|
+
echo "=== Mirroring A3M Router to Gitee ==="
|
|
14
|
+
echo "Source: $GITHUB_REPO"
|
|
15
|
+
echo "Target: $GITEE_REPO"
|
|
16
|
+
echo ""
|
|
17
|
+
|
|
18
|
+
# Verify SSH connectivity to Gitee
|
|
19
|
+
echo "[1/4] Testing Gitee SSH connection..."
|
|
20
|
+
if ssh -T -o StrictHostKeyChecking=accept-new -o ConnectTimeout=5 git@gitee.com 2>&1 | grep -q "successfully authenticated"; then
|
|
21
|
+
echo " OK - SSH key works with Gitee"
|
|
22
|
+
elif [ $? -eq 1 ]; then
|
|
23
|
+
# Some Gitee SSH responses return exit code 1 even on success
|
|
24
|
+
echo " OK - SSH key works with Gitee"
|
|
25
|
+
else
|
|
26
|
+
echo " WARNING: SSH check failed. Continuing anyway..."
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
# Clone fresh mirror
|
|
30
|
+
echo "[2/4] Cloning mirror of GitHub repo..."
|
|
31
|
+
TEMP_DIR=$(mktemp -d)
|
|
32
|
+
cd "$TEMP_DIR"
|
|
33
|
+
git clone --mirror "$GITHUB_REPO" . 2>&1
|
|
34
|
+
echo " Done - $(git rev-list --count HEAD) commits mirrored"
|
|
35
|
+
|
|
36
|
+
# Add Gitee remote and push
|
|
37
|
+
echo "[3/4] Pushing to Gitee..."
|
|
38
|
+
git remote add gitee "$GITEE_REPO"
|
|
39
|
+
git push --mirror gitee 2>&1
|
|
40
|
+
echo " Done"
|
|
41
|
+
|
|
42
|
+
# Clean up
|
|
43
|
+
echo "[4/4] Cleaning up temporary files..."
|
|
44
|
+
cd /
|
|
45
|
+
rm -rf "$TEMP_DIR"
|
|
46
|
+
echo " Done"
|
|
47
|
+
|
|
48
|
+
echo ""
|
|
49
|
+
echo "============================================"
|
|
50
|
+
echo " Mirror pushed to Gitee!"
|
|
51
|
+
echo " Visit: https://gitee.com/das-rebel/a3m-router"
|
|
52
|
+
echo "============================================"
|
package/src/tui/dashboard.ts
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
3
3
|
* A3M Router — Overlay Box TUI (Sakura Light Theme)
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
// ── Banner ──
|
|
7
|
+
console.log(`
|
|
8
|
+
╔══════════════════════════════════════════════════════════╗
|
|
9
|
+
║ ╔═╗╔═╗╔╗╔╔═╗ ║
|
|
10
|
+
║ ╠═╣║ ║║║║║ ║ ║
|
|
11
|
+
║ ╩ ╩╚═╝╝╚╝╚═╝ ║
|
|
12
|
+
║ ║
|
|
13
|
+
║ Parallel Multi-LLM Execution Engine ║
|
|
14
|
+
║ ║
|
|
15
|
+
║ 47+ Providers · Ensemble Voting · 62% Cost Savings ║
|
|
16
|
+
╚══════════════════════════════════════════════════════════╝
|
|
17
|
+
`);
|
|
18
|
+
|
|
6
19
|
import * as blessed from 'blessed';
|
|
7
20
|
|
|
8
21
|
// ── State ──
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock token utilities for testing providerRetry.
|
|
3
|
+
* Replaces the broken import from src/utils/tokenUtils (file doesn't exist).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export function countTokens(text: string, _model?: string): number {
|
|
7
|
+
if (!text || text.length === 0) return 0;
|
|
8
|
+
const words = text.trim().split(/\s+/).length;
|
|
9
|
+
return Math.ceil(words * 1.3);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function estimateTokens(text: string): number {
|
|
13
|
+
return countTokens(text);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function estimateCost(_promptTokens: number, _completionTokens: number, _model: string): number {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const MODEL_COSTS: Record<string, { input_per_1k: number; output_per_1k: number }> = {
|
|
21
|
+
'gpt-4o': { input_per_1k: 2.50, output_per_1k: 10.00 },
|
|
22
|
+
};
|