@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.
Files changed (263) hide show
  1. package/README.md +10 -10
  2. package/browser/playwright.js +22 -0
  3. package/docs/.gitkeep +0 -0
  4. package/docs/actionsincident.md +29 -0
  5. package/docs/branchaudit.md +21 -0
  6. package/docs/ecosystemplan.md +3 -3
  7. package/docs/featureaudit.md +1 -1
  8. package/docs/gapmatrix.md +8 -7
  9. package/docs/libraryapi.md +1 -0
  10. package/docs/logs/.gitkeep +0 -0
  11. package/docs/packageaudit185.md +23 -0
  12. package/docs/plans/00.index.md +50 -0
  13. package/docs/plans/01.architecture.md +86 -0
  14. package/docs/plans/02.research.computer.use.md +58 -0
  15. package/docs/plans/03.research.captcha.bypass.md +68 -0
  16. package/docs/plans/04.research.sandbox.ai.md +52 -0
  17. package/docs/plans/05.capture.platform.md +57 -0
  18. package/docs/plans/06.dependencies.md +97 -0
  19. package/docs/plans/07.captcha.test.page.md +41 -0
  20. package/docs/plans/08.production.infra.md +70 -0
  21. package/docs/plans/09.database.schema.md +121 -0
  22. package/docs/plans/10.cloudinary.storage.md +57 -0
  23. package/docs/plans/11.movement.logs.json.md +72 -0
  24. package/docs/plans/12.research.atlas.agent.browser.md +79 -0
  25. package/docs/plans/13.research.anti.detection.md +898 -0
  26. package/docs/plans/14.research.proxy.md +1495 -0
  27. package/docs/plans/15.research.retry.rate.limit.md +1958 -0
  28. package/docs/plans/16.research.crawling.md +1417 -0
  29. package/docs/plans/17.research.caching.md +1610 -0
  30. package/docs/plans/18.research.content.extraction.md +1952 -0
  31. package/docs/plans/19.research.errors.events.md +1523 -0
  32. package/docs/plans/20.research.zod.validation.md +1350 -0
  33. package/docs/plans/21.research.batch.concurrency.md +1888 -0
  34. package/docs/plans/22.research.universal.runtime.md +944 -0
  35. package/docs/plans/23.research.ai.integration.md +1465 -0
  36. package/docs/plans/24.research.memory.persistence.md +1979 -0
  37. package/docs/plans/25.research.server.api.md +342 -0
  38. package/docs/plans/26.research.compilation.md +249 -0
  39. package/docs/plans/27.research.html.parsing.md +251 -0
  40. package/docs/plans/28.action.plan.md +50 -0
  41. package/docs/plans/29.api.reference.md +174 -0
  42. package/docs/plans/30.architecture.plan.md +94 -0
  43. package/docs/plans/31.auditoria.dados.md +163 -0
  44. package/docs/plans/32.bots.automacao.computacional.md +214 -0
  45. package/docs/plans/33.bots.codigo.revisao.md +220 -0
  46. package/docs/plans/34.bots.seguranca.cicd.md +366 -0
  47. package/docs/plans/35.comparativo.concorrencia.md +464 -0
  48. package/docs/plans/36.computational.memory.md +340 -0
  49. package/docs/plans/37.deploystrategy.md +394 -0
  50. package/docs/plans/38.flow.md +155 -0
  51. package/docs/plans/39.multi.platform.bot.md +252 -0
  52. package/docs/plans/40.npm.publish.md +250 -0
  53. package/docs/plans/41.o.que.falta.md +407 -0
  54. package/docs/plans/42.pesquisa.concorrencia.md +721 -0
  55. package/docs/plans/43.plan.universal.architecture.md +496 -0
  56. package/docs/plans/44.reference.md +100 -0
  57. package/docs/plans/45.robotarchitecture.md +237 -0
  58. package/docs/plans/46.scdnintegration.md +284 -0
  59. package/docs/plans/47.multiforge.readme.md +129 -0
  60. package/docs/plans/48.theory.v4.repo.os.md +152 -0
  61. package/docs/plans/49.third.party.infra.md +12 -0
  62. package/docs/plans/50.file.as.compute.md +39 -0
  63. package/docs/plans/51.architecture.virtual.processor.md +80 -0
  64. package/docs/plans/52.manifesto.v8.md +11 -0
  65. package/docs/plans/58.cdn.list.md +23 -0
  66. package/docs/plans/59.sql.frameworks.md +33 -0
  67. package/docs/plans/60.sql.thirdparty.md +26 -0
  68. package/docs/plans/61.objective.multiforge.md +63 -0
  69. package/docs/plans/62.huggingface.upload.md +26 -0
  70. package/docs/plans/63.kaggle.upload.md +24 -0
  71. package/docs/plans/64.npm.storage.md +30 -0
  72. package/docs/plans/65.rclone.terabox.md +32 -0
  73. package/docs/plans/66.buckets.and.models.todo.md +14 -0
  74. package/docs/plans/67.database.todo.md +13 -0
  75. package/docs/plans/68.deploy.packages.todo.md +12 -0
  76. package/docs/plans/69.report.human.operator.md +133 -0
  77. package/docs/plans/70.report.brain2qwerty.ems.md +135 -0
  78. package/docs/plans/71.report.hd.infinito.vram.md +155 -0
  79. package/docs/plans/72.plan.hd.infinito.node.md +146 -0
  80. package/docs/plans/73.plan.scifi.repos.md +125 -0
  81. package/docs/plans/74.000.manifesto.v8.flat.2..md +11 -0
  82. package/docs/plans/README.md +489 -0
  83. package/docs/plans/aggregate_platforms.mjs +146 -0
  84. package/docs/plans/examplesession.json +36 -0
  85. package/docs/plans/missing-facts.md +192 -0
  86. package/docs/plans/models.md +64 -0
  87. package/docs/plans/organize.cjs +270 -0
  88. package/docs/plans/platforms.md +2887 -0
  89. package/docs/plans/sites.md +31322 -0
  90. package/docs/platformpipelineaudit.md +6 -2
  91. package/docs/registryresearch.md +2 -0
  92. package/docs/release.md +4 -4
  93. package/docs/release184notes.md +2 -2
  94. package/docs/release185notes.md +7 -0
  95. package/docs/releaseassets.md +16 -0
  96. package/docs/sources/farm.py +117 -0
  97. package/docs/sources/html/saddle1.html +132 -0
  98. package/docs/sources/html/saddle2.html +157 -0
  99. package/docs/sources/html/saddle3.html +119 -0
  100. package/docs/sources/html/saddle4.html +144 -0
  101. package/docs/sources/html/saddle5.html +72 -0
  102. package/docs/sources/html/saddle6.html +171 -0
  103. package/docs/sources/html/saddle7.html +236 -0
  104. package/docs/sources/saddle.ts +74 -0
  105. package/docs/sources/schema.prisma +88 -0
  106. package/docs/sources/script.sh +64 -0
  107. package/docs/sources/workflows.yml +458 -0
  108. package/docs/talks1/_body.txt +14 -0
  109. package/docs/talks1/_index.md +15 -0
  110. package/docs/talks1/_screenshot.png +0 -0
  111. package/docs/talks1/assistant-01.md +5 -0
  112. package/docs/talks1/assistant-02.md +5 -0
  113. package/docs/talks1/assistant-03.md +531 -0
  114. package/docs/talks1/assistant-04.md +26 -0
  115. package/docs/talks1/assistant-05.md +774 -0
  116. package/docs/talks1/assistant-06.md +1718 -0
  117. package/docs/talks1/scrape-share.cjs +185 -0
  118. package/docs/talks1/scrape-share.ts +183 -0
  119. package/docs/talks1/user-01.md +3 -0
  120. package/docs/talks1/user-02.md +3 -0
  121. package/docs/talks1/user-03.md +88 -0
  122. package/docs/talks1/user-04.md +3 -0
  123. package/docs/talks1/user-05.md +3 -0
  124. package/docs/talks1/user-06.md +88 -0
  125. package/docs/talks1/user-07.md +88 -0
  126. package/docs/talks2/_body.txt +14 -0
  127. package/docs/talks2/_index.md +16 -0
  128. package/docs/talks2/_screenshot.png +0 -0
  129. package/docs/talks2/assistant-01.md +5 -0
  130. package/docs/talks2/assistant-02.md +5 -0
  131. package/docs/talks2/assistant-03.md +424 -0
  132. package/docs/talks2/assistant-04.md +598 -0
  133. package/docs/talks2/assistant-05.md +1280 -0
  134. package/docs/talks2/assistant-06.md +1227 -0
  135. package/docs/talks2/assistant-07.md +1252 -0
  136. package/docs/talks2/user-01.md +3 -0
  137. package/docs/talks2/user-02.md +3 -0
  138. package/docs/talks2/user-03.md +88 -0
  139. package/docs/talks2/user-04.md +88 -0
  140. package/docs/talks2/user-05.md +88 -0
  141. package/docs/talks2/user-06.md +88 -0
  142. package/docs/talks2/user-07.md +3 -0
  143. package/docs/talks3/_body.txt +467 -0
  144. package/docs/talks3/_index.md +10 -0
  145. package/docs/talks3/_screenshot.png +0 -0
  146. package/docs/talks3/assistant-01.md +417 -0
  147. package/docs/talks3/assistant-02.md +417 -0
  148. package/docs/talks3/assistant-03.md +29 -0
  149. package/docs/talks3/assistant-04.md +727 -0
  150. package/docs/talks3/user-01.md +88 -0
  151. package/docs/talks3/user-02.md +88 -0
  152. package/docs/talks3/user-03.md +3 -0
  153. package/docs/talks3/user-04.md +3 -0
  154. package/docs/talks4/_body.txt +14 -0
  155. package/docs/talks4/_index.md +12 -0
  156. package/docs/talks4/_screenshot.png +0 -0
  157. package/docs/talks4/assistant-01.md +5 -0
  158. package/docs/talks4/assistant-02.md +5 -0
  159. package/docs/talks4/assistant-03.md +35 -0
  160. package/docs/talks4/assistant-04.md +512 -0
  161. package/docs/talks4/assistant-05.md +599 -0
  162. package/docs/talks4/user-01.md +3 -0
  163. package/docs/talks4/user-02.md +3 -0
  164. package/docs/talks4/user-03.md +88 -0
  165. package/docs/talks4/user-04.md +88 -0
  166. package/docs/talks4/user-05.md +7 -0
  167. package/docs/talks5/_body.txt +14 -0
  168. package/docs/talks5/_index.md +13 -0
  169. package/docs/talks5/_screenshot.png +0 -0
  170. package/docs/talks5/assistant-01.md +5 -0
  171. package/docs/talks5/assistant-02.md +5 -0
  172. package/docs/talks5/assistant-03.md +690 -0
  173. package/docs/talks5/assistant-04.md +758 -0
  174. package/docs/talks5/assistant-05.md +974 -0
  175. package/docs/talks5/user-01.md +3 -0
  176. package/docs/talks5/user-02.md +3 -0
  177. package/docs/talks5/user-03.md +105 -0
  178. package/docs/talks5/user-04.md +105 -0
  179. package/docs/talks5/user-05.md +63 -0
  180. package/docs/talks5/user-06.md +105 -0
  181. package/docs/talks6/_body.txt +14 -0
  182. package/docs/talks6/_index.md +9 -0
  183. package/docs/talks6/_screenshot.png +0 -0
  184. package/docs/talks6/assistant-01.md +5 -0
  185. package/docs/talks6/assistant-02.md +5 -0
  186. package/docs/talks6/assistant-03.md +1499 -0
  187. package/docs/talks6/user-01.md +3 -0
  188. package/docs/talks6/user-02.md +3 -0
  189. package/docs/talks6/user-03.md +88 -0
  190. package/docs/talks6/user-04.md +88 -0
  191. package/docs/talks7/_body.txt +14 -0
  192. package/docs/talks7/_index.md +10 -0
  193. package/docs/talks7/_screenshot.png +0 -0
  194. package/docs/talks7/assistant-01.md +5 -0
  195. package/docs/talks7/assistant-02.md +5 -0
  196. package/docs/talks7/assistant-03.md +523 -0
  197. package/docs/talks7/assistant-04.md +617 -0
  198. package/docs/talks7/user-01.md +3 -0
  199. package/docs/talks7/user-02.md +3 -0
  200. package/docs/talks7/user-03.md +105 -0
  201. package/docs/talks7/user-04.md +67 -0
  202. package/docs/talks8/conversa1.txt +1322 -0
  203. package/docs/talks8/conversa2.txt +237 -0
  204. 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
  205. 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
  206. 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
  207. 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
  208. 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
  209. package/docs/talks9/README (2).md +489 -0
  210. package/docs/talks9/README.md +198 -0
  211. 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
  212. package/docs/talks9/conversa.txt +544 -0
  213. package/docs/talks9/other (2).md +39 -0
  214. package/docs/talks9/other.md +57 -0
  215. package/docs/talks9/outro.txt +24 -0
  216. package/extension/README.md +2 -2
  217. package/extension/build.js +1 -1
  218. package/extension/content.js +46 -4
  219. package/extension/manifest.json +1 -1
  220. package/extension/pagebridge.js +41 -0
  221. package/extension/protocol.js +21 -2
  222. package/extension/serviceworker.js +12 -5
  223. package/package.json +165 -10
  224. package/release/assets.js +70 -0
  225. package/scrape/agent.ts +122 -0
  226. package/scrape/batch.ts +79 -0
  227. package/scrape/biome.json +76 -0
  228. package/scrape/browser.ts +222 -0
  229. package/scrape/cache.ts +84 -0
  230. package/scrape/chunking.ts +193 -0
  231. package/scrape/cli.ts +105 -0
  232. package/scrape/crawler.ts +115 -0
  233. package/scrape/dev-server.ts +94 -0
  234. package/scrape/errors.ts +132 -0
  235. package/scrape/events.ts +26 -0
  236. package/scrape/extract.ts +165 -0
  237. package/scrape/fetch.ts +105 -0
  238. package/scrape/formats.ts +85 -0
  239. package/scrape/headers.ts +71 -0
  240. package/scrape/index.ts +92 -0
  241. package/scrape/jsdom.d.ts +6 -0
  242. package/scrape/llms-txt.ts +84 -0
  243. package/scrape/middleware.ts +90 -0
  244. package/scrape/package-lock.json +9397 -0
  245. package/scrape/package.json +1420 -0
  246. package/scrape/pool.ts +95 -0
  247. package/scrape/port.ts +18 -0
  248. package/scrape/proxy.ts +103 -0
  249. package/scrape/rate-limiter.ts +95 -0
  250. package/scrape/renderer.ts +194 -0
  251. package/scrape/retry.ts +64 -0
  252. package/scrape/robots.ts +137 -0
  253. package/scrape/scrape.ts +123 -0
  254. package/scrape/serialize.ts +310 -0
  255. package/scrape/server.ts +137 -0
  256. package/scrape/session.ts +109 -0
  257. package/scrape/sitemap.ts +131 -0
  258. package/scrape/tokens.ts +45 -0
  259. package/scrape/tsconfig.json +28 -0
  260. package/scrape/types.ts +214 -0
  261. package/scrape/utils.ts +77 -0
  262. package/scrape/vite.config.ts +55 -0
  263. 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?