@wenathlan/saddle 1.8.4 → 1.8.6
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/README.md +10 -10
- package/browser/playwright.js +22 -0
- package/docs/.gitkeep +0 -0
- package/docs/actionsincident.md +29 -0
- package/docs/branchaudit.md +21 -0
- package/docs/ecosystemplan.md +3 -3
- package/docs/featureaudit.md +1 -1
- package/docs/gapmatrix.md +8 -7
- package/docs/libraryapi.md +1 -0
- package/docs/logs/.gitkeep +0 -0
- package/docs/packageaudit185.md +23 -0
- package/docs/plans/00.index.md +50 -0
- package/docs/plans/01.architecture.md +86 -0
- package/docs/plans/02.research.computer.use.md +58 -0
- package/docs/plans/03.research.captcha.bypass.md +68 -0
- package/docs/plans/04.research.sandbox.ai.md +52 -0
- package/docs/plans/05.capture.platform.md +57 -0
- package/docs/plans/06.dependencies.md +97 -0
- package/docs/plans/07.captcha.test.page.md +41 -0
- package/docs/plans/08.production.infra.md +70 -0
- package/docs/plans/09.database.schema.md +121 -0
- package/docs/plans/10.cloudinary.storage.md +57 -0
- package/docs/plans/11.movement.logs.json.md +72 -0
- package/docs/plans/12.research.atlas.agent.browser.md +79 -0
- package/docs/plans/13.research.anti.detection.md +898 -0
- package/docs/plans/14.research.proxy.md +1495 -0
- package/docs/plans/15.research.retry.rate.limit.md +1958 -0
- package/docs/plans/16.research.crawling.md +1417 -0
- package/docs/plans/17.research.caching.md +1610 -0
- package/docs/plans/18.research.content.extraction.md +1952 -0
- package/docs/plans/19.research.errors.events.md +1523 -0
- package/docs/plans/20.research.zod.validation.md +1350 -0
- package/docs/plans/21.research.batch.concurrency.md +1888 -0
- package/docs/plans/22.research.universal.runtime.md +944 -0
- package/docs/plans/23.research.ai.integration.md +1465 -0
- package/docs/plans/24.research.memory.persistence.md +1979 -0
- package/docs/plans/25.research.server.api.md +342 -0
- package/docs/plans/26.research.compilation.md +249 -0
- package/docs/plans/27.research.html.parsing.md +251 -0
- package/docs/plans/28.action.plan.md +50 -0
- package/docs/plans/29.api.reference.md +174 -0
- package/docs/plans/30.architecture.plan.md +94 -0
- package/docs/plans/31.auditoria.dados.md +163 -0
- package/docs/plans/32.bots.automacao.computacional.md +214 -0
- package/docs/plans/33.bots.codigo.revisao.md +220 -0
- package/docs/plans/34.bots.seguranca.cicd.md +366 -0
- package/docs/plans/35.comparativo.concorrencia.md +464 -0
- package/docs/plans/36.computational.memory.md +340 -0
- package/docs/plans/37.deploystrategy.md +394 -0
- package/docs/plans/38.flow.md +155 -0
- package/docs/plans/39.multi.platform.bot.md +252 -0
- package/docs/plans/40.npm.publish.md +250 -0
- package/docs/plans/41.o.que.falta.md +407 -0
- package/docs/plans/42.pesquisa.concorrencia.md +721 -0
- package/docs/plans/43.plan.universal.architecture.md +496 -0
- package/docs/plans/44.reference.md +100 -0
- package/docs/plans/45.robotarchitecture.md +237 -0
- package/docs/plans/46.scdnintegration.md +284 -0
- package/docs/plans/47.multiforge.readme.md +129 -0
- package/docs/plans/48.theory.v4.repo.os.md +152 -0
- package/docs/plans/49.third.party.infra.md +12 -0
- package/docs/plans/50.file.as.compute.md +39 -0
- package/docs/plans/51.architecture.virtual.processor.md +80 -0
- package/docs/plans/52.manifesto.v8.md +11 -0
- package/docs/plans/58.cdn.list.md +23 -0
- package/docs/plans/59.sql.frameworks.md +33 -0
- package/docs/plans/60.sql.thirdparty.md +26 -0
- package/docs/plans/61.objective.multiforge.md +63 -0
- package/docs/plans/62.huggingface.upload.md +26 -0
- package/docs/plans/63.kaggle.upload.md +24 -0
- package/docs/plans/64.npm.storage.md +30 -0
- package/docs/plans/65.rclone.terabox.md +32 -0
- package/docs/plans/66.buckets.and.models.todo.md +14 -0
- package/docs/plans/67.database.todo.md +13 -0
- package/docs/plans/68.deploy.packages.todo.md +12 -0
- package/docs/plans/69.report.human.operator.md +133 -0
- package/docs/plans/70.report.brain2qwerty.ems.md +135 -0
- package/docs/plans/71.report.hd.infinito.vram.md +155 -0
- package/docs/plans/72.plan.hd.infinito.node.md +146 -0
- package/docs/plans/73.plan.scifi.repos.md +125 -0
- package/docs/plans/74.000.manifesto.v8.flat.2..md +11 -0
- package/docs/plans/README.md +489 -0
- package/docs/plans/aggregate_platforms.mjs +146 -0
- package/docs/plans/examplesession.json +36 -0
- package/docs/plans/missing-facts.md +192 -0
- package/docs/plans/models.md +64 -0
- package/docs/plans/organize.cjs +270 -0
- package/docs/plans/platforms.md +2887 -0
- package/docs/plans/sites.md +31322 -0
- package/docs/platformpipelineaudit.md +6 -2
- package/docs/registryresearch.md +2 -0
- package/docs/release.md +4 -4
- package/docs/release184notes.md +2 -2
- package/docs/release185notes.md +7 -0
- package/docs/releaseassets.md +16 -0
- package/docs/sources/farm.py +117 -0
- package/docs/sources/html/saddle1.html +132 -0
- package/docs/sources/html/saddle2.html +157 -0
- package/docs/sources/html/saddle3.html +119 -0
- package/docs/sources/html/saddle4.html +144 -0
- package/docs/sources/html/saddle5.html +72 -0
- package/docs/sources/html/saddle6.html +171 -0
- package/docs/sources/html/saddle7.html +236 -0
- package/docs/sources/saddle.ts +74 -0
- package/docs/sources/schema.prisma +88 -0
- package/docs/sources/script.sh +64 -0
- package/docs/sources/workflows.yml +458 -0
- package/docs/talks1/_body.txt +14 -0
- package/docs/talks1/_index.md +15 -0
- package/docs/talks1/_screenshot.png +0 -0
- package/docs/talks1/assistant-01.md +5 -0
- package/docs/talks1/assistant-02.md +5 -0
- package/docs/talks1/assistant-03.md +531 -0
- package/docs/talks1/assistant-04.md +26 -0
- package/docs/talks1/assistant-05.md +774 -0
- package/docs/talks1/assistant-06.md +1718 -0
- package/docs/talks1/scrape-share.cjs +185 -0
- package/docs/talks1/scrape-share.ts +183 -0
- package/docs/talks1/user-01.md +3 -0
- package/docs/talks1/user-02.md +3 -0
- package/docs/talks1/user-03.md +88 -0
- package/docs/talks1/user-04.md +3 -0
- package/docs/talks1/user-05.md +3 -0
- package/docs/talks1/user-06.md +88 -0
- package/docs/talks1/user-07.md +88 -0
- package/docs/talks2/_body.txt +14 -0
- package/docs/talks2/_index.md +16 -0
- package/docs/talks2/_screenshot.png +0 -0
- package/docs/talks2/assistant-01.md +5 -0
- package/docs/talks2/assistant-02.md +5 -0
- package/docs/talks2/assistant-03.md +424 -0
- package/docs/talks2/assistant-04.md +598 -0
- package/docs/talks2/assistant-05.md +1280 -0
- package/docs/talks2/assistant-06.md +1227 -0
- package/docs/talks2/assistant-07.md +1252 -0
- package/docs/talks2/user-01.md +3 -0
- package/docs/talks2/user-02.md +3 -0
- package/docs/talks2/user-03.md +88 -0
- package/docs/talks2/user-04.md +88 -0
- package/docs/talks2/user-05.md +88 -0
- package/docs/talks2/user-06.md +88 -0
- package/docs/talks2/user-07.md +3 -0
- package/docs/talks3/_body.txt +467 -0
- package/docs/talks3/_index.md +10 -0
- package/docs/talks3/_screenshot.png +0 -0
- package/docs/talks3/assistant-01.md +417 -0
- package/docs/talks3/assistant-02.md +417 -0
- package/docs/talks3/assistant-03.md +29 -0
- package/docs/talks3/assistant-04.md +727 -0
- package/docs/talks3/user-01.md +88 -0
- package/docs/talks3/user-02.md +88 -0
- package/docs/talks3/user-03.md +3 -0
- package/docs/talks3/user-04.md +3 -0
- package/docs/talks4/_body.txt +14 -0
- package/docs/talks4/_index.md +12 -0
- package/docs/talks4/_screenshot.png +0 -0
- package/docs/talks4/assistant-01.md +5 -0
- package/docs/talks4/assistant-02.md +5 -0
- package/docs/talks4/assistant-03.md +35 -0
- package/docs/talks4/assistant-04.md +512 -0
- package/docs/talks4/assistant-05.md +599 -0
- package/docs/talks4/user-01.md +3 -0
- package/docs/talks4/user-02.md +3 -0
- package/docs/talks4/user-03.md +88 -0
- package/docs/talks4/user-04.md +88 -0
- package/docs/talks4/user-05.md +7 -0
- package/docs/talks5/_body.txt +14 -0
- package/docs/talks5/_index.md +13 -0
- package/docs/talks5/_screenshot.png +0 -0
- package/docs/talks5/assistant-01.md +5 -0
- package/docs/talks5/assistant-02.md +5 -0
- package/docs/talks5/assistant-03.md +690 -0
- package/docs/talks5/assistant-04.md +758 -0
- package/docs/talks5/assistant-05.md +974 -0
- package/docs/talks5/user-01.md +3 -0
- package/docs/talks5/user-02.md +3 -0
- package/docs/talks5/user-03.md +105 -0
- package/docs/talks5/user-04.md +105 -0
- package/docs/talks5/user-05.md +63 -0
- package/docs/talks5/user-06.md +105 -0
- package/docs/talks6/_body.txt +14 -0
- package/docs/talks6/_index.md +9 -0
- package/docs/talks6/_screenshot.png +0 -0
- package/docs/talks6/assistant-01.md +5 -0
- package/docs/talks6/assistant-02.md +5 -0
- package/docs/talks6/assistant-03.md +1499 -0
- package/docs/talks6/user-01.md +3 -0
- package/docs/talks6/user-02.md +3 -0
- package/docs/talks6/user-03.md +88 -0
- package/docs/talks6/user-04.md +88 -0
- package/docs/talks7/_body.txt +14 -0
- package/docs/talks7/_index.md +10 -0
- package/docs/talks7/_screenshot.png +0 -0
- package/docs/talks7/assistant-01.md +5 -0
- package/docs/talks7/assistant-02.md +5 -0
- package/docs/talks7/assistant-03.md +523 -0
- package/docs/talks7/assistant-04.md +617 -0
- package/docs/talks7/user-01.md +3 -0
- package/docs/talks7/user-02.md +3 -0
- package/docs/talks7/user-03.md +105 -0
- package/docs/talks7/user-04.md +67 -0
- package/docs/talks8/conversa1.txt +1322 -0
- package/docs/talks8/conversa2.txt +237 -0
- package/docs/talks9/Beyond the Obvious_ 50 Plataformas Auto-Hospedadas de Forja de C/303/263digo para Al/303/251m de Gitea e GitLab.md" +174 -0
- package/docs/talks9/De NPM a Multi-Linguagem_ Uma Arquitetura T/303/251cnica para a Execu/303/247/303/243o Integrada de C/303/263digo no Ecossistema Node.js.md" +59 -0
- package/docs/talks9/De NPM a VMs Virtuais_ Uma An/303/241lise Arquitet/303/264nica para a Realiza/303/247/303/243o do Ciclo de Vida do Projeto SADDLE.md" +91 -0
- package/docs/talks9/Mapeamento da Engrenagem Computacional_ Uma Arquitetura para Execu/303/247/303/243o Isolada e Persist/303/252ncia em Ambientes Distribu/303/255dos.md" +116 -0
- package/docs/talks9/O Cen/303/241rio Pr/303/241tico do SADDLE_ Uma An/303/241lise de Viabilidade e Modelo de Ciclo de Vida Integrado.md" +128 -0
- package/docs/talks9/README (2).md +489 -0
- package/docs/talks9/README.md +198 -0
- package/docs/talks9/Viabilidade do Saddle_ Uma An/303/241lise T/303/251cnica da Transforma/303/247/303/243o de Armazenamento Remoto em Mem/303/263ria Computacional.md" +80 -0
- package/docs/talks9/conversa.txt +544 -0
- package/docs/talks9/other (2).md +39 -0
- package/docs/talks9/other.md +57 -0
- package/docs/talks9/outro.txt +24 -0
- package/extension/README.md +2 -2
- package/extension/build.js +1 -1
- package/extension/content.js +46 -4
- package/extension/manifest.json +1 -1
- package/extension/pagebridge.js +41 -0
- package/extension/protocol.js +21 -2
- package/extension/serviceworker.js +12 -5
- package/package.json +165 -10
- package/release/assets.js +70 -0
- package/scrape/agent.ts +122 -0
- package/scrape/batch.ts +79 -0
- package/scrape/biome.json +76 -0
- package/scrape/browser.ts +222 -0
- package/scrape/cache.ts +84 -0
- package/scrape/chunking.ts +193 -0
- package/scrape/cli.ts +105 -0
- package/scrape/crawler.ts +115 -0
- package/scrape/dev-server.ts +94 -0
- package/scrape/errors.ts +132 -0
- package/scrape/events.ts +26 -0
- package/scrape/extract.ts +165 -0
- package/scrape/fetch.ts +105 -0
- package/scrape/formats.ts +85 -0
- package/scrape/headers.ts +71 -0
- package/scrape/index.ts +92 -0
- package/scrape/jsdom.d.ts +6 -0
- package/scrape/llms-txt.ts +84 -0
- package/scrape/middleware.ts +90 -0
- package/scrape/package-lock.json +9397 -0
- package/scrape/package.json +1420 -0
- package/scrape/pool.ts +95 -0
- package/scrape/port.ts +18 -0
- package/scrape/proxy.ts +103 -0
- package/scrape/rate-limiter.ts +95 -0
- package/scrape/renderer.ts +194 -0
- package/scrape/retry.ts +64 -0
- package/scrape/robots.ts +137 -0
- package/scrape/scrape.ts +123 -0
- package/scrape/serialize.ts +310 -0
- package/scrape/server.ts +137 -0
- package/scrape/session.ts +109 -0
- package/scrape/sitemap.ts +131 -0
- package/scrape/tokens.ts +45 -0
- package/scrape/tsconfig.json +28 -0
- package/scrape/types.ts +214 -0
- package/scrape/utils.ts +77 -0
- package/scrape/vite.config.ts +55 -0
- package/scrape/vitest.config.ts +17 -0
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
# assistant
|
|
2
|
+
|
|
3
|
+
[Thinking] The user is asking a very complex and broad question about building a platform with container sandboxes using free infrastructure from various Git hosting services (GitHub, GitLab, Forgejo, Gitea, Codeberg), package registries (npm, PyPI), AI platforms (Hugging Face, Kaggle, ModelScope), and ORM libraries (Drizzle, Prisma, MySQL2). They want to understand:
|
|
4
|
+
|
|
5
|
+
How to use free infrastructure from these platforms2. How to set up pipelines, cron jobs, and sandboxes
|
|
6
|
+
How to convert storage into RAM-like memory
|
|
7
|
+
How to build their own libraries vs use third-party ones
|
|
8
|
+
Memory virtualization concepts6. I need to search for relevant open source projects and resources that address these questions, then develop a comprehensive implementation plan for this build phase.
|
|
9
|
+
|
|
10
|
+
[Thinking] Now let me search for more specific topics related to what the user is asking about - storage-to-RAM conversion, open source projects for this, and the specific platforms mentioned.
|
|
11
|
+
|
|
12
|
+
[Thinking] Now I have enough information to provide a comprehensive implementation plan. Let me synthesize all this research into a clear, actionable plan for the user.
|
|
13
|
+
The user wants to:
|
|
14
|
+
|
|
15
|
+
Build a sandbox platform similar to z.ai
|
|
16
|
+
Use free infrastructure from repos (GitHub, GitLab, Forgejo, Gitea, Codeberg)
|
|
17
|
+
Use pipelines, cron jobs
|
|
18
|
+
Convert storage to RAM memory
|
|
19
|
+
Use WASM runtimes
|
|
20
|
+
Use open source libraries and tools
|
|
21
|
+
Use npm packages, CDN delivery
|
|
22
|
+
|
|
23
|
+
Let me create a comprehensive implementation plan.
|
|
24
|
+
|
|
25
|
+
Vou pesquisar sobre projetos, bibliotecas e infraestrutura que podem ajudar nessa implementação.
|
|
26
|
+
|
|
27
|
+
Baseado na pesquisa, aqui está a implementação completa do seu projeto:
|
|
28
|
+
|
|
29
|
+
Plataforma de Sandbox com Infraestrutura Gratuita
|
|
30
|
+
1. Arquitetura Geral
|
|
31
|
+
┌─────────────────────────────────────────────────────┐
|
|
32
|
+
│ SEU PROJETO │
|
|
33
|
+
│ (Node.js/TypeScript + WASM) │
|
|
34
|
+
├─────────────────────────────────────────────────────┤
|
|
35
|
+
│ │
|
|
36
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
|
|
37
|
+
│ │ GitHub │ │ GitLab │ │ Forgejo │ │
|
|
38
|
+
│ │ Actions │ │ CI/CD │ │ Runner │ │
|
|
39
|
+
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
|
|
40
|
+
│ │ │ │ │
|
|
41
|
+
│ ▼ ▼ ▼ │
|
|
42
|
+
│ ┌─────────────────────────────────────────┐ │
|
|
43
|
+
│ │ MEMORY BRIDGE (zRAM/tmpfs/WASM) │ │
|
|
44
|
+
│ │ Storage → Compressed RAM → Virtual FS │ │
|
|
45
|
+
│ └─────────────────────────────────────────┘ │
|
|
46
|
+
│ │ │ │ │
|
|
47
|
+
│ ▼ ▼ ▼ │
|
|
48
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
|
|
49
|
+
│ │ Hugging │ │ Kaggle │ │ ModelS- │ │
|
|
50
|
+
│ │ Face │ │ Notebooks│ │ cope │ │
|
|
51
|
+
│ └──────────┘ └──────────┘ └──────────┘ │
|
|
52
|
+
│ │
|
|
53
|
+
│ ┌─────────────────────────────────────────┐ │
|
|
54
|
+
│ │ SANDBOX RUNTIME (WASM/Docker) │ │
|
|
55
|
+
│ │ gVisor / Firecracker / WebAssembly │ │
|
|
56
|
+
│ └─────────────────────────────────────────┘ │
|
|
57
|
+
└─────────────────────────────────────────────────────┘
|
|
58
|
+
2. Conversão Storage → RAM (Memory Bridge)
|
|
59
|
+
Projetos open source para usar:
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
Projeto
|
|
64
|
+
URL
|
|
65
|
+
O que faz
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
memfs
|
|
70
|
+
npm i memfs
|
|
71
|
+
Filesystem in-memory compatível com Node.js fs
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
mmap-io
|
|
75
|
+
npm i @riaskov/mmap-io
|
|
76
|
+
Memory-mapped files (arquivo → RAM)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
random-access-memory
|
|
80
|
+
npm i random-access-memory
|
|
81
|
+
Armazenamento random-access em RAM
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
zRAM
|
|
85
|
+
Kernel Linux
|
|
86
|
+
Comprime dados em RAM (até 3x mais memória)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
tmpfs
|
|
90
|
+
Kernel Linux
|
|
91
|
+
Filesystem virtual em memória
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
Script de setup - Memory Bridge:
|
|
95
|
+
#!/bin/bash
|
|
96
|
+
# setup-memory-bridge.sh
|
|
97
|
+
|
|
98
|
+
# 1. Criar zRAM (comprime RAM)
|
|
99
|
+
modprobe zram
|
|
100
|
+
zramctl /dev/zram0 --algorithm zstd --size "$(($(grep -Po 'MemTotal:\s*\K\d+' /proc/meminfo)/2))KiB"
|
|
101
|
+
mkswap /dev/zram0
|
|
102
|
+
swapon --priority 100 /dev/zram0
|
|
103
|
+
|
|
104
|
+
# 2. Criar tmpfs para workspace
|
|
105
|
+
mkdir -p /mnt/sandbox-ram
|
|
106
|
+
mount -t tmpfs -o size=4G,mode=1777 tmpfs /mnt/sandbox-ram
|
|
107
|
+
|
|
108
|
+
# 3. Criar loop device de um arquivo (armazenamento → bloco → RAM)
|
|
109
|
+
dd if=/dev/zero of=/tmp/ram-disk.img bs=1M count=4096
|
|
110
|
+
mkfs.ext4 /tmp/ram-disk.img
|
|
111
|
+
mkdir -p /mnt/ram-disk
|
|
112
|
+
mount -o loop /tmp/ram-disk.img /mnt/ram-disk
|
|
113
|
+
3. Bibliotecas Node.js Principais
|
|
114
|
+
{
|
|
115
|
+
"dependencies": {
|
|
116
|
+
"memfs": "^4.0.0",
|
|
117
|
+
"@riaskov/mmap-io": "^1.7.0",
|
|
118
|
+
"random-access-memory": "^6.2.1",
|
|
119
|
+
"dockerode": "^3.3.0",
|
|
120
|
+
"ws": "^8.16.0",
|
|
121
|
+
"express": "^4.18.0",
|
|
122
|
+
"drizzle-orm": "^0.28.0",
|
|
123
|
+
"@prisma/client": "^5.0.0",
|
|
124
|
+
"mysql2": "^3.6.0"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
4. Runner de Sandbox (usando GitHub Actions grátis)
|
|
128
|
+
.github/workflows/sandbox-runner.yml:
|
|
129
|
+
name: Sandbox Runner
|
|
130
|
+
on:
|
|
131
|
+
workflow_dispatch:
|
|
132
|
+
inputs:
|
|
133
|
+
sandbox_config:
|
|
134
|
+
description: 'Sandbox configuration JSON'
|
|
135
|
+
required: true
|
|
136
|
+
|
|
137
|
+
jobs:
|
|
138
|
+
run-sandbox:
|
|
139
|
+
runs-on: ubuntu-latest
|
|
140
|
+
container:
|
|
141
|
+
image: gvisor-runsc:latest
|
|
142
|
+
options: --runtime=runsc
|
|
143
|
+
|
|
144
|
+
steps:
|
|
145
|
+
- uses: actions/checkout@v4
|
|
146
|
+
|
|
147
|
+
- name: Setup Memory Bridge
|
|
148
|
+
run: |
|
|
149
|
+
sudo modprobe zram
|
|
150
|
+
sudo zramctl /dev/zram0 --algorithm zstd --size 4G
|
|
151
|
+
sudo mkswap /dev/zram0
|
|
152
|
+
sudo swapon /dev/zram0
|
|
153
|
+
sudo mount -t tmpfs -o size=4G tmpfs /mnt/sandbox
|
|
154
|
+
|
|
155
|
+
- name: Run Sandbox
|
|
156
|
+
run: |
|
|
157
|
+
docker run --rm \
|
|
158
|
+
--runtime=runsc \
|
|
159
|
+
--memory=8g \
|
|
160
|
+
--cpus=4 \
|
|
161
|
+
-v /mnt/sandbox:/workspace \
|
|
162
|
+
-e SANDBOX_ID=${{ github.run_id }} \
|
|
163
|
+
sandbox-image:latest
|
|
164
|
+
|
|
165
|
+
- name: Save State
|
|
166
|
+
uses: actions/upload-artifact@v4
|
|
167
|
+
with:
|
|
168
|
+
name: sandbox-state
|
|
169
|
+
path: /mnt/sandbox/
|
|
170
|
+
retention-days: 1
|
|
171
|
+
5. Runner para Forgejo/Gitea (Grátis e Self-hosted)
|
|
172
|
+
forgejo-runner-config.yml:
|
|
173
|
+
# Instalar Forgejo Runner
|
|
174
|
+
# wget https://code.forgejo.org/forgejo/forgejo-runner/releases/download/v12.10.2/forgejo-runner-12.10.2-linux-amd64
|
|
175
|
+
|
|
176
|
+
runners:
|
|
177
|
+
- name: sandbox-runner
|
|
178
|
+
type: docker
|
|
179
|
+
labels:
|
|
180
|
+
- "sandbox:docker://node:20-bookworm"
|
|
181
|
+
- "linux:docker://ubuntu:22.04"
|
|
182
|
+
config:
|
|
183
|
+
container:
|
|
184
|
+
image: node:20-bookworm
|
|
185
|
+
options: |
|
|
186
|
+
--memory=8g
|
|
187
|
+
--cpus=4
|
|
188
|
+
--runtime=runsc
|
|
189
|
+
volumes:
|
|
190
|
+
- /mnt/sandbox-ram:/workspace
|
|
191
|
+
.forgejo/workflows/sandbox.yml:
|
|
192
|
+
name: Sandbox Pipeline
|
|
193
|
+
on: [push, workflow_dispatch]
|
|
194
|
+
|
|
195
|
+
jobs:
|
|
196
|
+
sandbox:
|
|
197
|
+
runs-on: [self-hosted, sandbox]
|
|
198
|
+
container:
|
|
199
|
+
image: node:20-bookworm
|
|
200
|
+
|
|
201
|
+
steps:
|
|
202
|
+
- name: Setup Memory
|
|
203
|
+
run: |
|
|
204
|
+
mount -t tmpfs -o size=4G tmpfs /workspace/ram
|
|
205
|
+
node -e "const fs = require('memfs'); fs.mkdirSync('/workspace/ram/sandbox'); console.log('Memory bridge ready')"
|
|
206
|
+
|
|
207
|
+
- name: Execute Code
|
|
208
|
+
run: |
|
|
209
|
+
cd /workspace/ram/sandbox
|
|
210
|
+
node -e "
|
|
211
|
+
const { Volume } = require('memfs');
|
|
212
|
+
const vol = new Volume();
|
|
213
|
+
vol.mkdirSync('/sandbox');
|
|
214
|
+
vol.writeFileSync('/sandbox/index.js', 'console.log(\"Sandbox running in RAM!\")');
|
|
215
|
+
require('child_process').execSync('node /sandbox/index.js', { cwd: '/sandbox' });
|
|
216
|
+
"
|
|
217
|
+
6. Projeto Principal (npm package)
|
|
218
|
+
package.json:
|
|
219
|
+
{
|
|
220
|
+
"name": "@seuorg/sandbox-memory-bridge",
|
|
221
|
+
"version": "1.0.0",
|
|
222
|
+
"main": "dist/index.js",
|
|
223
|
+
"types": "dist/index.d.ts",
|
|
224
|
+
"scripts": {
|
|
225
|
+
"build": "tsc",
|
|
226
|
+
"dev": "tsx watch src/index.ts",
|
|
227
|
+
"test": "vitest"
|
|
228
|
+
},
|
|
229
|
+
"dependencies": {
|
|
230
|
+
"memfs": "^4.0.0",
|
|
231
|
+
"@riaskov/mmap-io": "^1.7.0",
|
|
232
|
+
"dockerode": "^3.3.0",
|
|
233
|
+
"drizzle-orm": "^0.28.0",
|
|
234
|
+
"ws": "^8.16.0"
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
src/memory-bridge.ts:
|
|
238
|
+
import { createFsFromVolume, Volume } from 'memfs';
|
|
239
|
+
|
|
240
|
+
export class MemoryBridge {
|
|
241
|
+
private vol: Volume;
|
|
242
|
+
private fs: ReturnType<typeof createFsFromVolume>;
|
|
243
|
+
|
|
244
|
+
constructor(private sizeMB: number = 4096) {
|
|
245
|
+
this.vol = new Volume();
|
|
246
|
+
this.fs = createFsFromVolume(this.vol);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Converte arquivo do disco para RAM
|
|
250
|
+
async storageToRam(diskPath: string, ramPath: string): Promise<void> {
|
|
251
|
+
const data = require('fs').readFileSync(diskPath);
|
|
252
|
+
this.vol.mkdirSync(require('path').dirname(ramPath), { recursive: true });
|
|
253
|
+
this.vol.writeFileSync(ramPath, data);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Cria sandbox em memória
|
|
257
|
+
async createSandbox(id: string): Promise<SandboxInstance> {
|
|
258
|
+
const sandboxPath = `/sandbox/${id}`;
|
|
259
|
+
this.vol.mkdirSync(sandboxPath, { recursive: true });
|
|
260
|
+
|
|
261
|
+
return {
|
|
262
|
+
id,
|
|
263
|
+
fs: this.fs,
|
|
264
|
+
path: sandboxPath,
|
|
265
|
+
execute: async (code: string) => {
|
|
266
|
+
this.vol.writeFileSync(`${sandboxPath}/index.js`, code);
|
|
267
|
+
// Executar via WASM ou child_process isolado
|
|
268
|
+
return this.executeInSandbox(sandboxPath, code);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
private async executeInSandbox(path: string, code: string): Promise<string> {
|
|
274
|
+
// Usar WASM sandbox ou child_process com limits
|
|
275
|
+
const { execSync } = require('child_process');
|
|
276
|
+
const result = execSync(`node -e "${code}"`, {
|
|
277
|
+
cwd: path,
|
|
278
|
+
timeout: 5000,
|
|
279
|
+
maxBuffer: 1024 * 1024 * 10 // 10MB
|
|
280
|
+
});
|
|
281
|
+
return result.toString();
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
7. WASM Sandbox (Browser + Node.js)
|
|
285
|
+
src/wasm-sandbox.ts:
|
|
286
|
+
// Usar portabox ou webix para WASM sandbox
|
|
287
|
+
export class WasmSandbox {
|
|
288
|
+
private memory: WebAssembly.Memory;
|
|
289
|
+
|
|
290
|
+
constructor() {
|
|
291
|
+
this.memory = new WebAssembly.Memory({
|
|
292
|
+
initial: 256, // 16MB inicial
|
|
293
|
+
maximum: 512, // 32MB máximo
|
|
294
|
+
shared: true
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
async init() {
|
|
299
|
+
// Carregar WASM module (pode ser baixado de CDN)
|
|
300
|
+
const wasmUrl = 'https://cdn.jsdelivr.net/npm/portabox@latest/blinkenlib.wasm';
|
|
301
|
+
const response = await fetch(wasmUrl);
|
|
302
|
+
const bytes = await response.arrayBuffer();
|
|
303
|
+
const module = await WebAssembly.instantiate(bytes, {
|
|
304
|
+
env: { memory: this.memory }
|
|
305
|
+
});
|
|
306
|
+
return module.instance;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
8. Deploy com Docker
|
|
310
|
+
Dockerfile:
|
|
311
|
+
FROM node:20-bookworm
|
|
312
|
+
|
|
313
|
+
# Instalar dependências do sistema
|
|
314
|
+
RUN apt-get update && apt-get install -y \
|
|
315
|
+
zram-tools \
|
|
316
|
+
e2fsprogs \
|
|
317
|
+
docker.io \
|
|
318
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
319
|
+
|
|
320
|
+
# Setup zRAM
|
|
321
|
+
RUN modprobe zram && \
|
|
322
|
+
zramctl /dev/zram0 --algorithm zstd --size 4G && \
|
|
323
|
+
mkswap /dev/zram0 && \
|
|
324
|
+
swapon /dev/zram0
|
|
325
|
+
|
|
326
|
+
# Setup tmpfs
|
|
327
|
+
RUN mkdir -p /mnt/sandbox-ram && \
|
|
328
|
+
mount -t tmpfs -o size=4G tmpfs /mnt/sandbox-ram
|
|
329
|
+
|
|
330
|
+
WORKDIR /app
|
|
331
|
+
COPY package*.json ./
|
|
332
|
+
RUN npm ci --production
|
|
333
|
+
COPY dist/ ./dist/
|
|
334
|
+
|
|
335
|
+
EXPOSE 3000
|
|
336
|
+
CMD ["node", "dist/index.js"]
|
|
337
|
+
9. Pipelines Multi-Plataforma
|
|
338
|
+
GitHub Actions (grátis para público):
|
|
339
|
+
|
|
340
|
+
Repositórios públicos: infinito minutos grátis
|
|
341
|
+
Cache: 10GB por repositório
|
|
342
|
+
Artifacts: 500MB (free tier)
|
|
343
|
+
|
|
344
|
+
GitLab CI (grátis para sempre):
|
|
345
|
+
|
|
346
|
+
400 minutos/mês grátis
|
|
347
|
+
Docker runners inclusos
|
|
348
|
+
|
|
349
|
+
Forgejo/Gitea (self-hosted = infinito):
|
|
350
|
+
|
|
351
|
+
Sem limites de minutos
|
|
352
|
+
Sem cobrança
|
|
353
|
+
Totalmente controlado
|
|
354
|
+
|
|
355
|
+
10. CDN para Execução Instantânea
|
|
356
|
+
// Usar jsDelivr para carregar pacotes sem instalar
|
|
357
|
+
const CDN_URLS = {
|
|
358
|
+
memfs: 'https://cdn.jsdelivr.net/npm/memfs@4.0.0/+esm',
|
|
359
|
+
dockerode: 'https://cdn.jsdelivr.net/npm/dockerode@3.3.0/+esm',
|
|
360
|
+
express: 'https://cdn.jsdelivr.net/npm/express@4.18.0/+esm'
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
// Executar código com dependências da CDN
|
|
364
|
+
async function executeWithCDN(code: string) {
|
|
365
|
+
const imports = Object.entries(CDN_URLS)
|
|
366
|
+
.map(([name, url]) => `import ${name} from '${url}';`)
|
|
367
|
+
.join('\n');
|
|
368
|
+
|
|
369
|
+
const fullCode = `${imports}\n${code}`;
|
|
370
|
+
return eval(fullCode);
|
|
371
|
+
}
|
|
372
|
+
Resumo - O que Usar
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
Necessidade
|
|
377
|
+
Solução
|
|
378
|
+
Custo
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
Storage → RAM
|
|
383
|
+
zRAM + tmpfs + memfs
|
|
384
|
+
Grátis
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
Sandbox isolado
|
|
388
|
+
gVisor / Firecracker / WASM
|
|
389
|
+
Grátis
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
CI/CD Pipeline
|
|
393
|
+
GitHub Actions (público) / Forgejo
|
|
394
|
+
Grátis
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
ORM
|
|
398
|
+
Drizzle + Prisma + MySQL2
|
|
399
|
+
Grátis
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
CDN execução
|
|
403
|
+
jsDelivr + esm.sh
|
|
404
|
+
Grátis
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
Container
|
|
408
|
+
Docker + Kubernetes
|
|
409
|
+
Grátis (self-hosted)
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
Runner
|
|
413
|
+
ephemerd / ez-gh-actions
|
|
414
|
+
Grátis (MIT)
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
Quer que eu crie algum desses arquivos ou explique mais alguma parte específica?
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# assistant
|
|
2
|
+
|
|
3
|
+
[Thinking] The user wants me to do a very thorough research - at least 10 searches - and provide a detailed step-by-step implementation plan. Let me search extensively for each aspect of their request and then compile everything together.
|
|
4
|
+
Let me break down what they need:
|
|
5
|
+
|
|
6
|
+
Memory bridge: storage → RAM conversion
|
|
7
|
+
|
|
8
|
+
Using infrastructure from repos (GitHub, GitLab, Forgejo, Gitea, Codeberg)
|
|
9
|
+
|
|
10
|
+
Pipelines and cron jobs for sandbox creation
|
|
11
|
+
|
|
12
|
+
Using free tiers from HuggingFace, Kaggle, ModelScope
|
|
13
|
+
|
|
14
|
+
ORMs (Drizzle, Prisma, MySQL2) converted to RAM
|
|
15
|
+
|
|
16
|
+
Open source libraries (Node.js, Python, Rust)
|
|
17
|
+
|
|
18
|
+
WASM/memory emulators
|
|
19
|
+
|
|
20
|
+
Container sandboxes (gVisor, Firecracker, etc.)
|
|
21
|
+
|
|
22
|
+
npm packages with CDN delivery
|
|
23
|
+
|
|
24
|
+
Two approaches: build own lib + use third-party
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Now I need to dig into each of these areas systematically to find the best tools, patterns, and implementations.
|
|
28
|
+
|
|
29
|
+
Vou fazer mais de 10 pesquisas detalhadas e compilar tudo em um guia passo a passo completo.
|