Skip to content

Commit 56a6d96

Browse files
committed
Add extractor providers, async warmup, R2 runtime log buffering, and staging updates
1 parent e6b7a61 commit 56a6d96

16 files changed

Lines changed: 1089 additions & 83 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
.env.local
22
.env.e2e.local
33
.env.local
4+
.secrets/
5+
.crawler
6+
telegram/.crawler
47
shared/recommended-model-set.local.json
58
.telegram.yaml
9+
.telegram.stage.yaml
610
telegram/.env
711
telegram/data/runtime-state.json
812

comicbot/config/default.bot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ generation:
1313
panel_count: 3
1414
objective: explain-like-im-five
1515
output_language: en
16+
url_extractor: gemini
1617
detail_level: low
1718
style_prompt: "clean comic panel art, readable characters, coherent scene progression"
1819

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"probe:providers:extension": "node scripts/provider-model-probe-extension.js",
1616
"test:e2e:headed": "playwright test --headed",
1717
"test:all": "npm run test && npm run test:e2e",
18+
"release:telegram-bot": "pwsh -NoProfile -File ./scripts/package-telegram-bot-release.ps1",
1819
"docs:build": "pwsh -NoProfile -File ./scripts/convert-docs-md-to-html.ps1",
1920
"docs:build:keep-badges": "pwsh -NoProfile -File ./scripts/convert-docs-md-to-html.ps1 -PreserveBadges",
2021
"engine:comicify": "node engine/cli/comic-engine-cli.js",
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
param(
2+
[string]$OutputDir = ".release"
3+
)
4+
5+
$ErrorActionPreference = "Stop"
6+
7+
if (-not (Test-Path "package.json")) {
8+
throw "Run this script from repository root."
9+
}
10+
11+
$packageJson = Get-Content -Raw "package.json" | ConvertFrom-Json
12+
$version = [string]$packageJson.version
13+
if ([string]::IsNullOrWhiteSpace($version)) {
14+
throw "Could not resolve version from package.json"
15+
}
16+
17+
$packageName = "Web2Comics-TelegramBot-v$version"
18+
$stagingRoot = Join-Path $OutputDir $packageName
19+
$zipPath = Join-Path $OutputDir "$packageName-deploy.zip"
20+
21+
if (Test-Path $stagingRoot) {
22+
Remove-Item $stagingRoot -Recurse -Force
23+
}
24+
if (Test-Path $zipPath) {
25+
Remove-Item $zipPath -Force
26+
}
27+
if (-not (Test-Path $OutputDir)) {
28+
New-Item -ItemType Directory -Path $OutputDir | Out-Null
29+
}
30+
New-Item -ItemType Directory -Path $stagingRoot | Out-Null
31+
32+
# Required runtime/deploy content for standalone bot deployment.
33+
$includePaths = @(
34+
"telegram",
35+
"engine",
36+
"docker",
37+
"render",
38+
"scripts/deploy-bot-auto.js",
39+
"scripts/validate-secrets.js",
40+
"scripts/cloudflare/create-scoped-tokens.js",
41+
"package.json",
42+
"package-lock.json",
43+
"README.md"
44+
)
45+
46+
foreach ($entry in $includePaths) {
47+
if (-not (Test-Path $entry)) { continue }
48+
$destination = Join-Path $stagingRoot $entry
49+
$destDir = Split-Path -Parent $destination
50+
if (-not (Test-Path $destDir)) {
51+
New-Item -ItemType Directory -Path $destDir -Force | Out-Null
52+
}
53+
if ((Get-Item $entry).PSIsContainer) {
54+
Copy-Item $entry -Destination $destination -Recurse -Force
55+
} else {
56+
Copy-Item $entry -Destination $destination -Force
57+
}
58+
}
59+
60+
# Remove secrets and transient artifacts aggressively.
61+
$removePaths = @(
62+
".env",
63+
".env.local",
64+
".env.e2e.local",
65+
".telegram.yaml",
66+
".cloudflare.yaml",
67+
".aws.yaml",
68+
"telegram/.env",
69+
"telegram/out",
70+
"telegram/data",
71+
"telegram/cfgs",
72+
"cloudflare/.dev.vars",
73+
"cloudflare/.wrangler",
74+
".wrangler",
75+
"node_modules"
76+
)
77+
foreach ($rel in $removePaths) {
78+
$p = Join-Path $stagingRoot $rel
79+
if (Test-Path $p) {
80+
Remove-Item $p -Recurse -Force -ErrorAction SilentlyContinue
81+
}
82+
}
83+
84+
# Remove any accidentally copied secret-like files.
85+
Get-ChildItem -Path $stagingRoot -Recurse -File -ErrorAction SilentlyContinue |
86+
Where-Object {
87+
$_.Name -match '(^|\.)(env|yaml|yml)$' -and
88+
($_.FullName -match 'telegram\\\.env$' -or $_.Name -match '^\.(telegram|cloudflare|aws)\.ya?ml$' -or $_.Name -match '^\.env')
89+
} |
90+
ForEach-Object { Remove-Item $_.FullName -Force -ErrorAction SilentlyContinue }
91+
92+
Compress-Archive -Path $stagingRoot -DestinationPath $zipPath -CompressionLevel Optimal -Force
93+
94+
$zipItem = Get-Item $zipPath
95+
Write-Output "Created: $($zipItem.FullName)"
96+
Write-Output "Size: $([Math]::Round($zipItem.Length / 1MB, 2)) MB"
97+
Write-Output "Package root: $stagingRoot"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
input:
2+
format: auto
3+
max_chars: 14000
4+
strip_selectors:
5+
- script
6+
- style
7+
- noscript
8+
- nav
9+
- footer
10+
- aside
11+
generation:
12+
panel_count: 8
13+
objective: explain-like-im-five
14+
objective_name: Explain Like I Am Five
15+
objective_description: Use simple words, short sentences, and relatable examples suitable for a young audience.
16+
output_language: he
17+
detail_level: low
18+
style_name: Classic
19+
style_description: clean illustrated art, readable characters, coherent scene progression
20+
style_prompt: clean illustrated art, readable characters, coherent scene progression
21+
consistency: true
22+
panel_watermark: true
23+
debug_prompts: false
24+
invent_temperature: 0.95
25+
delivery_mode: default
26+
providers:
27+
text:
28+
provider: gemini
29+
model: gemini-2.5-flash
30+
api_key_env: GEMINI_API_KEY
31+
image:
32+
provider: gemini
33+
model: gemini-2.0-flash-exp-image-generation
34+
api_key_env: GEMINI_API_KEY
35+
runtime:
36+
timeout_ms: 120000
37+
image_concurrency: 3
38+
retries: 1
39+
output:
40+
width: 1400
41+
panel_height: 700
42+
caption_height: 120
43+
padding: 24
44+
gap: 16
45+
header_height: 120
46+
footer_height: 34
47+
background: '#f8fafc'
48+
brand: Made with Web2Comics Engine

telegram/config/default.render.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ generation:
1515
objective_name: "Explain Like I Am Five"
1616
objective_description: "Use simple words, short sentences, and relatable examples suitable for a young audience."
1717
output_language: auto
18+
url_extractor: gemini
1819
consistency: true
1920
panel_watermark: true
2021
debug_prompts: false

telegram/src/data/messages.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ function buildHelpMessage(chatId, options = {}) {
6262
...styleShortcutLines,
6363
'/new_style <name> <text> - save a custom named style.',
6464
'/language <code> - set output language.',
65+
'/extractor <gemini|firecrawl|jina|chromium> - set URL story extraction vendor.',
6566
'/mode <default|media_group|single> - set delivery mode.',
6667
'/consistency <on|off> - toggle reference-style consistency flow.',
6768
'/detail <low|medium|high> - set output detail level.',

telegram/src/data/options.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const OPTION_MAP = {
55
'generation.panel_count': ['3', '4', '5', '6', '8', '10', '12'],
66
'generation.objective': OBJECTIVE_VALUES.slice(),
77
'generation.output_language': ['en', 'auto', 'es', 'fr', 'de', 'it', 'pt', 'ru', 'ja', 'ko', 'zh', 'he'],
8+
'generation.url_extractor': ['gemini', 'firecrawl', 'jina', 'chromium'],
89
'generation.consistency': ['off', 'on'],
910
'generation.invent_temperature': ['0.3', '0.5', '0.7', '0.95', '1.2', '1.5'],
1011
'generation.delivery_mode': ['default', 'media_group', 'single'],
@@ -29,7 +30,9 @@ const SECRET_KEYS = [
2930
'OPENROUTER_API_KEY',
3031
'HUGGINGFACE_INFERENCE_API_TOKEN',
3132
'CLOUDFLARE_ACCOUNT_ID',
32-
'CLOUDFLARE_API_TOKEN'
33+
'CLOUDFLARE_API_TOKEN',
34+
'FIRECRAWL_API_KEY',
35+
'JINA_API_KEY'
3336
];
3437

3538
module.exports = {

0 commit comments

Comments
 (0)