@kortix/sandbox 0.4.1

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 (246) hide show
  1. package/config/customize.sh +143 -0
  2. package/config/kortix-env-setup.sh +25 -0
  3. package/kortix-master/package.json +22 -0
  4. package/kortix-master/src/config.ts +22 -0
  5. package/kortix-master/src/index.ts +44 -0
  6. package/kortix-master/src/routes/env.ts +65 -0
  7. package/kortix-master/src/routes/proxy.ts +108 -0
  8. package/kortix-master/src/routes/update.ts +185 -0
  9. package/kortix-master/src/services/proxy.ts +43 -0
  10. package/kortix-master/src/services/secret-store.ts +156 -0
  11. package/kortix-master/tsconfig.json +14 -0
  12. package/opencode/agents/kortix-browser.md +142 -0
  13. package/opencode/agents/kortix-build.md +62 -0
  14. package/opencode/agents/kortix-explore.md +66 -0
  15. package/opencode/agents/kortix-image-gen.md +33 -0
  16. package/opencode/agents/kortix-main.md +450 -0
  17. package/opencode/agents/kortix-plan.md +100 -0
  18. package/opencode/agents/kortix-research.md +84 -0
  19. package/opencode/agents/kortix-sheets.md +61 -0
  20. package/opencode/agents/kortix-slides.md +64 -0
  21. package/opencode/agents/kortix-web-dev.md +572 -0
  22. package/opencode/commands/email.md +36 -0
  23. package/opencode/commands/init.md +43 -0
  24. package/opencode/commands/journal.md +44 -0
  25. package/opencode/commands/memory-init.md +81 -0
  26. package/opencode/commands/memory-search.md +50 -0
  27. package/opencode/commands/memory-status.md +56 -0
  28. package/opencode/commands/research.md +36 -0
  29. package/opencode/commands/search.md +38 -0
  30. package/opencode/commands/slides.md +32 -0
  31. package/opencode/commands/spreadsheet.md +30 -0
  32. package/opencode/memory.json +37 -0
  33. package/opencode/ocx.jsonc +10 -0
  34. package/opencode/opencode.jsonc +103 -0
  35. package/opencode/package.json +25 -0
  36. package/opencode/patches/apply.sh +19 -0
  37. package/opencode/patches/opencode-pty-spawn.txt +49 -0
  38. package/opencode/plugin/background-agents.ts.disabled +483 -0
  39. package/opencode/plugin/kdco-primitives/get-project-id.ts +172 -0
  40. package/opencode/plugin/kdco-primitives/index.ts +26 -0
  41. package/opencode/plugin/kdco-primitives/log-warn.ts +51 -0
  42. package/opencode/plugin/kdco-primitives/mutex.ts +122 -0
  43. package/opencode/plugin/kdco-primitives/shell.ts +138 -0
  44. package/opencode/plugin/kdco-primitives/temp.ts +36 -0
  45. package/opencode/plugin/kdco-primitives/terminal-detect.ts +34 -0
  46. package/opencode/plugin/kdco-primitives/types.ts +13 -0
  47. package/opencode/plugin/kdco-primitives/with-timeout.ts +84 -0
  48. package/opencode/plugin/memory.ts +306 -0
  49. package/opencode/plugin/worktree/state.ts +412 -0
  50. package/opencode/plugin/worktree/terminal.ts +1002 -0
  51. package/opencode/plugin/worktree.ts +861 -0
  52. package/opencode/skills/KORTIX-browser/SKILL.md +478 -0
  53. package/opencode/skills/KORTIX-cron-triggers/SKILL.md +173 -0
  54. package/opencode/skills/KORTIX-deep-research/SKILL.md +278 -0
  55. package/opencode/skills/KORTIX-docx/SKILL.md +398 -0
  56. package/opencode/skills/KORTIX-docx/scripts/__init__.py +1 -0
  57. package/opencode/skills/KORTIX-docx/scripts/accept_changes.py +104 -0
  58. package/opencode/skills/KORTIX-docx/scripts/comment.py +244 -0
  59. package/opencode/skills/KORTIX-docx/scripts/office/helpers/__init__.py +0 -0
  60. package/opencode/skills/KORTIX-docx/scripts/office/helpers/merge_runs.py +199 -0
  61. package/opencode/skills/KORTIX-docx/scripts/office/helpers/simplify_redlines.py +197 -0
  62. package/opencode/skills/KORTIX-docx/scripts/office/pack.py +159 -0
  63. package/opencode/skills/KORTIX-docx/scripts/office/soffice.py +183 -0
  64. package/opencode/skills/KORTIX-docx/scripts/office/unpack.py +132 -0
  65. package/opencode/skills/KORTIX-docx/scripts/office/validate.py +111 -0
  66. package/opencode/skills/KORTIX-docx/scripts/office/validators/__init__.py +15 -0
  67. package/opencode/skills/KORTIX-docx/scripts/office/validators/base.py +847 -0
  68. package/opencode/skills/KORTIX-docx/scripts/office/validators/docx.py +446 -0
  69. package/opencode/skills/KORTIX-docx/scripts/office/validators/pptx.py +275 -0
  70. package/opencode/skills/KORTIX-docx/scripts/office/validators/redlining.py +247 -0
  71. package/opencode/skills/KORTIX-docx/scripts/render_docx.py +179 -0
  72. package/opencode/skills/KORTIX-docx/scripts/templates/comments.xml +3 -0
  73. package/opencode/skills/KORTIX-docx/scripts/templates/commentsExtended.xml +3 -0
  74. package/opencode/skills/KORTIX-docx/scripts/templates/commentsExtensible.xml +3 -0
  75. package/opencode/skills/KORTIX-docx/scripts/templates/commentsIds.xml +3 -0
  76. package/opencode/skills/KORTIX-docx/scripts/templates/people.xml +3 -0
  77. package/opencode/skills/KORTIX-domain-research/SKILL.md +96 -0
  78. package/opencode/skills/KORTIX-domain-research/scripts/domain-lookup.py +810 -0
  79. package/opencode/skills/KORTIX-elevenlabs/SKILL.md +230 -0
  80. package/opencode/skills/KORTIX-elevenlabs/scripts/tts.py +389 -0
  81. package/opencode/skills/KORTIX-email/SKILL.md +145 -0
  82. package/opencode/skills/KORTIX-legal-writer/SKILL.md +409 -0
  83. package/opencode/skills/KORTIX-legal-writer/references/bluebook.md +152 -0
  84. package/opencode/skills/KORTIX-legal-writer/references/document-types.md +416 -0
  85. package/opencode/skills/KORTIX-legal-writer/scripts/courtlistener.py +291 -0
  86. package/opencode/skills/KORTIX-legal-writer/scripts/ecfr_lookup.py +299 -0
  87. package/opencode/skills/KORTIX-legal-writer/scripts/verify-legal.py +507 -0
  88. package/opencode/skills/KORTIX-logo-creator/SKILL.md +293 -0
  89. package/opencode/skills/KORTIX-logo-creator/references/prompt-patterns.md +134 -0
  90. package/opencode/skills/KORTIX-logo-creator/scripts/compose_logo.py +406 -0
  91. package/opencode/skills/KORTIX-logo-creator/scripts/create_logo_sheet.py +258 -0
  92. package/opencode/skills/KORTIX-logo-creator/scripts/remove_bg.py +96 -0
  93. package/opencode/skills/KORTIX-memory/SKILL.md +261 -0
  94. package/opencode/skills/KORTIX-memory/scripts/export-sessions.py +409 -0
  95. package/opencode/skills/KORTIX-paper-creator/SKILL.md +549 -0
  96. package/opencode/skills/KORTIX-paper-creator/assets/template.tex +101 -0
  97. package/opencode/skills/KORTIX-paper-creator/scripts/compile.sh +177 -0
  98. package/opencode/skills/KORTIX-paper-creator/scripts/openalex_to_bibtex.py +220 -0
  99. package/opencode/skills/KORTIX-paper-creator/scripts/verify.sh +354 -0
  100. package/opencode/skills/KORTIX-paper-search/SKILL.md +418 -0
  101. package/opencode/skills/KORTIX-pdf/SKILL.md +232 -0
  102. package/opencode/skills/KORTIX-pdf/forms.md +36 -0
  103. package/opencode/skills/KORTIX-pdf/reference.md +105 -0
  104. package/opencode/skills/KORTIX-pdf/scripts/check_bounding_boxes.py +65 -0
  105. package/opencode/skills/KORTIX-pdf/scripts/check_fillable_fields.py +11 -0
  106. package/opencode/skills/KORTIX-pdf/scripts/convert_pdf_to_images.py +33 -0
  107. package/opencode/skills/KORTIX-pdf/scripts/create_validation_image.py +37 -0
  108. package/opencode/skills/KORTIX-pdf/scripts/extract_form_field_info.py +122 -0
  109. package/opencode/skills/KORTIX-pdf/scripts/extract_form_structure.py +115 -0
  110. package/opencode/skills/KORTIX-pdf/scripts/fill_fillable_fields.py +98 -0
  111. package/opencode/skills/KORTIX-pdf/scripts/fill_pdf_form_with_annotations.py +107 -0
  112. package/opencode/skills/KORTIX-plan/SKILL.md +228 -0
  113. package/opencode/skills/KORTIX-presentation-viewer/SKILL.md +87 -0
  114. package/opencode/skills/KORTIX-presentation-viewer/serve.ts +136 -0
  115. package/opencode/skills/KORTIX-presentation-viewer/viewer.html +559 -0
  116. package/opencode/skills/KORTIX-presentations/SKILL.md +344 -0
  117. package/opencode/skills/KORTIX-remotion/SKILL.md +56 -0
  118. package/opencode/skills/KORTIX-remotion/rules/3d.md +86 -0
  119. package/opencode/skills/KORTIX-remotion/rules/animations.md +29 -0
  120. package/opencode/skills/KORTIX-remotion/rules/assets.md +78 -0
  121. package/opencode/skills/KORTIX-remotion/rules/audio-visualization.md +198 -0
  122. package/opencode/skills/KORTIX-remotion/rules/audio.md +169 -0
  123. package/opencode/skills/KORTIX-remotion/rules/calculate-metadata.md +104 -0
  124. package/opencode/skills/KORTIX-remotion/rules/can-decode.md +75 -0
  125. package/opencode/skills/KORTIX-remotion/rules/charts.md +120 -0
  126. package/opencode/skills/KORTIX-remotion/rules/compositions.md +141 -0
  127. package/opencode/skills/KORTIX-remotion/rules/display-captions.md +184 -0
  128. package/opencode/skills/KORTIX-remotion/rules/extract-frames.md +229 -0
  129. package/opencode/skills/KORTIX-remotion/rules/ffmpeg.md +38 -0
  130. package/opencode/skills/KORTIX-remotion/rules/fonts.md +152 -0
  131. package/opencode/skills/KORTIX-remotion/rules/get-audio-duration.md +58 -0
  132. package/opencode/skills/KORTIX-remotion/rules/get-video-dimensions.md +68 -0
  133. package/opencode/skills/KORTIX-remotion/rules/get-video-duration.md +58 -0
  134. package/opencode/skills/KORTIX-remotion/rules/gifs.md +141 -0
  135. package/opencode/skills/KORTIX-remotion/rules/images.md +130 -0
  136. package/opencode/skills/KORTIX-remotion/rules/import-srt-captions.md +69 -0
  137. package/opencode/skills/KORTIX-remotion/rules/light-leaks.md +73 -0
  138. package/opencode/skills/KORTIX-remotion/rules/lottie.md +68 -0
  139. package/opencode/skills/KORTIX-remotion/rules/maps.md +401 -0
  140. package/opencode/skills/KORTIX-remotion/rules/measuring-dom-nodes.md +35 -0
  141. package/opencode/skills/KORTIX-remotion/rules/measuring-text.md +143 -0
  142. package/opencode/skills/KORTIX-remotion/rules/parameters.md +98 -0
  143. package/opencode/skills/KORTIX-remotion/rules/sequencing.md +118 -0
  144. package/opencode/skills/KORTIX-remotion/rules/subtitles.md +36 -0
  145. package/opencode/skills/KORTIX-remotion/rules/tailwind.md +11 -0
  146. package/opencode/skills/KORTIX-remotion/rules/text-animations.md +20 -0
  147. package/opencode/skills/KORTIX-remotion/rules/timing.md +179 -0
  148. package/opencode/skills/KORTIX-remotion/rules/transcribe-captions.md +70 -0
  149. package/opencode/skills/KORTIX-remotion/rules/transitions.md +197 -0
  150. package/opencode/skills/KORTIX-remotion/rules/transparent-videos.md +106 -0
  151. package/opencode/skills/KORTIX-remotion/rules/trimming.md +53 -0
  152. package/opencode/skills/KORTIX-remotion/rules/videos.md +171 -0
  153. package/opencode/skills/KORTIX-secrets/SKILL.md +280 -0
  154. package/opencode/skills/KORTIX-semantic-search/SKILL.md +213 -0
  155. package/opencode/skills/KORTIX-session-search/SKILL.md +807 -0
  156. package/opencode/skills/KORTIX-session-search/Untitled +1 -0
  157. package/opencode/skills/KORTIX-skill-creator/SKILL.md +163 -0
  158. package/opencode/skills/KORTIX-web-research/SKILL.md +69 -0
  159. package/opencode/skills/KORTIX-xlsx/LICENSE.txt +30 -0
  160. package/opencode/skills/KORTIX-xlsx/SKILL.md +549 -0
  161. package/opencode/skills/KORTIX-xlsx/scripts/office/helpers/__init__.py +0 -0
  162. package/opencode/skills/KORTIX-xlsx/scripts/office/helpers/merge_runs.py +199 -0
  163. package/opencode/skills/KORTIX-xlsx/scripts/office/helpers/simplify_redlines.py +197 -0
  164. package/opencode/skills/KORTIX-xlsx/scripts/office/pack.py +159 -0
  165. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  166. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  167. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  168. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  169. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  170. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  171. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  172. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  173. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  174. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  175. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  176. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  177. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  178. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  179. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  180. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  181. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  182. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  183. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  184. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  185. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  186. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  187. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  188. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  189. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  190. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  191. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  192. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  193. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  194. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  195. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  196. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/mce/mc.xsd +75 -0
  197. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
  198. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
  199. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
  200. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
  201. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
  202. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  203. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
  204. package/opencode/skills/KORTIX-xlsx/scripts/office/soffice.py +183 -0
  205. package/opencode/skills/KORTIX-xlsx/scripts/office/unpack.py +132 -0
  206. package/opencode/skills/KORTIX-xlsx/scripts/office/validate.py +111 -0
  207. package/opencode/skills/KORTIX-xlsx/scripts/office/validators/__init__.py +15 -0
  208. package/opencode/skills/KORTIX-xlsx/scripts/office/validators/base.py +847 -0
  209. package/opencode/skills/KORTIX-xlsx/scripts/office/validators/docx.py +446 -0
  210. package/opencode/skills/KORTIX-xlsx/scripts/office/validators/pptx.py +275 -0
  211. package/opencode/skills/KORTIX-xlsx/scripts/office/validators/redlining.py +247 -0
  212. package/opencode/skills/KORTIX-xlsx/scripts/recalc.py +184 -0
  213. package/opencode/tools/image-gen.ts +342 -0
  214. package/opencode/tools/image-search.ts +190 -0
  215. package/opencode/tools/memory-get.ts +168 -0
  216. package/opencode/tools/memory-search.ts +247 -0
  217. package/opencode/tools/presentation-gen.ts +723 -0
  218. package/opencode/tools/scrape-webpage.ts +115 -0
  219. package/opencode/tools/scripts/.python-version +1 -0
  220. package/opencode/tools/scripts/convert_pdf.py +184 -0
  221. package/opencode/tools/scripts/convert_pptx.py +562 -0
  222. package/opencode/tools/scripts/pyproject.toml +11 -0
  223. package/opencode/tools/scripts/uv.lock +287 -0
  224. package/opencode/tools/scripts/validate_slide.py +74 -0
  225. package/opencode/tools/show-user.ts +217 -0
  226. package/opencode/tools/tests/e2e-presentation-fix.ts +277 -0
  227. package/opencode/tools/tests/image-gen.test.ts +215 -0
  228. package/opencode/tools/tests/image-search.test.ts +125 -0
  229. package/opencode/tools/tests/memory-system-benchmark.ts +1076 -0
  230. package/opencode/tools/tests/presentation-gen.test.ts +389 -0
  231. package/opencode/tools/tests/scrape-webpage.test.ts +74 -0
  232. package/opencode/tools/tests/show-user.test.ts +241 -0
  233. package/opencode/tools/tests/video-gen.test.ts +110 -0
  234. package/opencode/tools/tests/web-search.test.ts +106 -0
  235. package/opencode/tools/video-gen.ts +200 -0
  236. package/opencode/tools/web-search.ts +153 -0
  237. package/opencode/tsconfig.json +29 -0
  238. package/package.json +36 -0
  239. package/patch-agent-browser.js +100 -0
  240. package/postinstall.sh +88 -0
  241. package/services/KORTIX-presentation-viewer/run +37 -0
  242. package/services/agent-browser-viewer/run +48 -0
  243. package/services/kortix-master/run +16 -0
  244. package/services/lss-sync/run +22 -0
  245. package/services/opencode-serve/run +25 -0
  246. package/services/opencode-web/run +21 -0
@@ -0,0 +1,100 @@
1
+ const fs = require('fs');
2
+
3
+ // ── Patch 1: handleLaunch env var fallbacks ─────────────────────────────────
4
+ // The Rust CLI sends a launch command to the Node.js daemon but doesn't
5
+ // include executablePath/args/profile in the JSON. We inject env var fallbacks.
6
+ const actionsFile = '/usr/lib/node_modules/agent-browser/dist/actions.js';
7
+ let actions = fs.readFileSync(actionsFile, 'utf8');
8
+
9
+ const oldLaunch = [
10
+ 'async function handleLaunch(command, browser) {',
11
+ ' await browser.launch(command);',
12
+ ' return successResponse(command.id, { launched: true });',
13
+ '}',
14
+ ].join('\n');
15
+
16
+ const newLaunch = [
17
+ 'async function handleLaunch(command, browser) {',
18
+ ' if (!command.executablePath && process.env.AGENT_BROWSER_EXECUTABLE_PATH) command.executablePath = process.env.AGENT_BROWSER_EXECUTABLE_PATH;',
19
+ ' var _isPrimary = (process.env.AGENT_BROWSER_SESSION || "default") === (process.env.AGENT_BROWSER_PRIMARY_SESSION || process.env.AGENT_BROWSER_SESSION || "default");',
20
+ ' if (!_isPrimary) { delete command.profile; } else if (!command.profile && process.env.AGENT_BROWSER_PROFILE) { command.profile = process.env.AGENT_BROWSER_PROFILE; }',
21
+ ' if (!command.args && process.env.AGENT_BROWSER_ARGS) command.args = process.env.AGENT_BROWSER_ARGS.split(/[,]/).map(function(a){return a.trim()}).filter(Boolean);',
22
+ ' if (command.headless === undefined && process.env.AGENT_BROWSER_HEADED === "1") command.headless = false;',
23
+ ' if (!command.userAgent && process.env.AGENT_BROWSER_USER_AGENT) command.userAgent = process.env.AGENT_BROWSER_USER_AGENT;',
24
+ ' if (!command.proxy && process.env.AGENT_BROWSER_PROXY) command.proxy = { server: process.env.AGENT_BROWSER_PROXY };',
25
+ ' if (!command.viewport) command.viewport = { width: 1920, height: 1080 };',
26
+ ' await browser.launch(command);',
27
+ ' return successResponse(command.id, { launched: true });',
28
+ '}',
29
+ ].join('\n');
30
+
31
+ if (!actions.includes(oldLaunch)) {
32
+ console.error('PATCH 1 FAILED - handleLaunch pattern not found in actions.js');
33
+ process.exit(1);
34
+ }
35
+ actions = actions.replace(oldLaunch, newLaunch);
36
+ fs.writeFileSync(actionsFile, actions);
37
+ console.log('PATCH 1 OK - handleLaunch env var fallbacks');
38
+
39
+ // ── Patch 2: REMOVED — upstream agent-browser now allows localhost origins
40
+ // via isAllowedOrigin() in stream-server.js. No patch needed.
41
+ console.log('PATCH 2 SKIPPED - upstream already allows localhost origins');
42
+
43
+ // ── Patch 3: stream port per session ────────────────────────────────────────
44
+ // When AGENT_BROWSER_STREAM_PORT is set globally, ALL sessions try to bind
45
+ // that port. Named sessions crash with EADDRINUSE. Fix: only the default
46
+ // session uses the env var port; named sessions use the hash-based port.
47
+ const daemonFile = '/usr/lib/node_modules/agent-browser/dist/daemon.js';
48
+ let daemon = fs.readFileSync(daemonFile, 'utf8');
49
+
50
+ const oldStreamPort = `const streamPort = options?.streamPort ??
51
+ (process.env.AGENT_BROWSER_STREAM_PORT
52
+ ? parseInt(process.env.AGENT_BROWSER_STREAM_PORT, 10)
53
+ : 0);`;
54
+
55
+ const newStreamPort = `const isPrimarySession = (process.env.AGENT_BROWSER_SESSION || 'default') === (process.env.AGENT_BROWSER_PRIMARY_SESSION || process.env.AGENT_BROWSER_SESSION || 'default');
56
+ const streamPort = options?.streamPort ??
57
+ (isPrimarySession && process.env.AGENT_BROWSER_STREAM_PORT
58
+ ? parseInt(process.env.AGENT_BROWSER_STREAM_PORT, 10)
59
+ : (!isPrimarySession ? getPortForSession(currentSession) : 0));`;
60
+
61
+ if (!daemon.includes(oldStreamPort)) {
62
+ console.error('PATCH 3 FAILED - streamPort pattern not found in daemon.js');
63
+ process.exit(1);
64
+ }
65
+ daemon = daemon.replace(oldStreamPort, newStreamPort);
66
+ fs.writeFileSync(daemonFile, daemon);
67
+ console.log('PATCH 3 OK - named sessions use hash-based stream ports');
68
+
69
+ // ── Patch 4: auto-launch profile only for default session ───────────────────
70
+ // The daemon's auto-launch path (line ~282) reads AGENT_BROWSER_PROFILE
71
+ // unconditionally. Named sessions must NOT use the persistent profile or
72
+ // Chromium will fail with "profile already in use".
73
+ const oldAutoProfile = "profile: process.env.AGENT_BROWSER_PROFILE,";
74
+ const newAutoProfile = 'profile: (process.env.AGENT_BROWSER_SESSION || "default") === (process.env.AGENT_BROWSER_PRIMARY_SESSION || process.env.AGENT_BROWSER_SESSION || "default") ? process.env.AGENT_BROWSER_PROFILE : undefined,';
75
+
76
+ if (!daemon.includes(oldAutoProfile)) {
77
+ console.error('PATCH 4 FAILED - auto-launch profile pattern not found in daemon.js');
78
+ process.exit(1);
79
+ }
80
+ daemon = daemon.replace(oldAutoProfile, newAutoProfile);
81
+ fs.writeFileSync(daemonFile, daemon);
82
+ console.log('PATCH 4 OK - auto-launch profile only for default session');
83
+
84
+ // ── Patch 5: fix newTab/newWindow with persistent contexts ──────────────────
85
+ // When using launchPersistentContext (profile mode), this.browser is null.
86
+ // newTab() checks `!this.browser` and throws "Browser not launched".
87
+ // Fix: also check this.contexts.length > 0 as an alternative.
88
+ const browserFile = '/usr/lib/node_modules/agent-browser/dist/browser.js';
89
+ let browser = fs.readFileSync(browserFile, 'utf8');
90
+
91
+ const oldNewTabCheck = "if (!this.browser || this.contexts.length === 0) {\n throw new Error('Browser not launched');\n }\n // Invalidate CDP session since we're switching to a new page";
92
+ const newNewTabCheck = "if ((!this.browser && this.contexts.length === 0) || this.contexts.length === 0) {\n throw new Error('Browser not launched');\n }\n // Invalidate CDP session since we're switching to a new page";
93
+
94
+ if (!browser.includes(oldNewTabCheck)) {
95
+ console.error('PATCH 5 FAILED - newTab check pattern not found in browser.js');
96
+ process.exit(1);
97
+ }
98
+ browser = browser.replace(oldNewTabCheck, newNewTabCheck);
99
+ fs.writeFileSync(browserFile, browser);
100
+ console.log('PATCH 5 OK - newTab works with persistent contexts');
package/postinstall.sh ADDED
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env bash
2
+ # @kortix/sandbox postinstall
3
+ #
4
+ # Copies source files to their runtime locations under /opt/ and installs
5
+ # local dependencies. Runs automatically after `npm install -g @kortix/sandbox`.
6
+ #
7
+ # This script is idempotent — safe to run multiple times.
8
+
9
+ set -euo pipefail
10
+
11
+ PKG_DIR="$(cd "$(dirname "$0")" && pwd)"
12
+
13
+ # Detect if we're running inside a sandbox (vs. being installed as a dev dep locally)
14
+ if [ ! -d "/opt" ] || [ "$(id -u)" = "0" ] && [ ! -d "/opt/bun" ]; then
15
+ echo "[sandbox-postinstall] Not in sandbox environment, skipping file deployment"
16
+ exit 0
17
+ fi
18
+
19
+ echo "[sandbox-postinstall] Deploying @kortix/sandbox files..."
20
+
21
+ # ── Kortix Master ────────────────────────────────────────────────────────────
22
+ echo "[sandbox-postinstall] Updating kortix-master..."
23
+ mkdir -p /opt/kortix-master
24
+ # Copy source files (preserving structure), skip node_modules
25
+ rsync -a --delete \
26
+ --exclude='node_modules' \
27
+ --exclude='bun.lock' \
28
+ "$PKG_DIR/kortix-master/" /opt/kortix-master/
29
+
30
+ # Install deps
31
+ cd /opt/kortix-master && bun install 2>/dev/null || true
32
+
33
+ # ── OpenCode config/agents/tools/skills ──────────────────────────────────────
34
+ echo "[sandbox-postinstall] Updating opencode config..."
35
+ mkdir -p /opt/opencode
36
+
37
+ # Sync source files — delete stale files but preserve node_modules and runtime data
38
+ rsync -a --delete \
39
+ --exclude='node_modules' \
40
+ --exclude='bun.lock' \
41
+ --exclude='.local' \
42
+ "$PKG_DIR/opencode/" /opt/opencode/
43
+
44
+ # Install deps (runs opencode patches via its own postinstall)
45
+ cd /opt/opencode && bun install 2>/dev/null || true
46
+
47
+ # ── s6 service scripts ──────────────────────────────────────────────────────
48
+ if [ -d "$PKG_DIR/services" ] && [ -d "/etc/services.d" ]; then
49
+ echo "[sandbox-postinstall] Updating s6 service scripts..."
50
+ rsync -a "$PKG_DIR/services/" /etc/services.d/
51
+ chmod +x /etc/services.d/*/run 2>/dev/null || true
52
+ fi
53
+
54
+ # ── Init scripts ─────────────────────────────────────────────────────────────
55
+ if [ -d "$PKG_DIR/config" ] && [ -d "/custom-cont-init.d" ]; then
56
+ echo "[sandbox-postinstall] Updating init scripts..."
57
+ cp -f "$PKG_DIR/config/kortix-env-setup.sh" /custom-cont-init.d/98-kortix-env 2>/dev/null || true
58
+ cp -f "$PKG_DIR/config/customize.sh" /custom-cont-init.d/99-customize 2>/dev/null || true
59
+ chmod +x /custom-cont-init.d/98-kortix-env /custom-cont-init.d/99-customize 2>/dev/null || true
60
+ fi
61
+
62
+ # ── Agent browser patches ────────────────────────────────────────────────────
63
+ if [ -f "$PKG_DIR/patch-agent-browser.js" ]; then
64
+ echo "[sandbox-postinstall] Applying agent-browser patches..."
65
+ node "$PKG_DIR/patch-agent-browser.js" 2>/dev/null || true
66
+ fi
67
+
68
+ # ── Version file ─────────────────────────────────────────────────────────────
69
+ # Read version from package.json (the single source of truth) and write to .version
70
+ mkdir -p /opt/kortix
71
+ PKG_VERSION=$(node -e "console.log(require('$PKG_DIR/package.json').version)" 2>/dev/null || echo "0.0.0")
72
+ echo "{\"version\":\"$PKG_VERSION\",\"updatedAt\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"}" > /opt/kortix/.version
73
+
74
+ # ── Fix ownership ────────────────────────────────────────────────────────────
75
+ chown -R 1000:1000 /opt/kortix-master /opt/opencode /opt/kortix 2>/dev/null || true
76
+
77
+ # ── pip packages ─────────────────────────────────────────────────────────────
78
+ # These are pinned to versions tested with this sandbox release.
79
+ echo "[sandbox-postinstall] Checking pip packages..."
80
+ pip3 install --break-system-packages -q \
81
+ 'local-semantic-search' \
82
+ 'playwright==1.58.0' \
83
+ 'pypdf2==3.0.1' \
84
+ 'python-pptx==1.0.2' \
85
+ 'pillow==12.1.0' \
86
+ 2>/dev/null || true
87
+
88
+ echo "[sandbox-postinstall] Done."
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/with-contenv bash
2
+ # KORTIX Presentation Viewer — s6 service
3
+ #
4
+ # Watches for presentations in /workspace/presentations/ and serves
5
+ # the most recently updated one on port 3210.
6
+ # If no presentation exists yet, waits until one appears.
7
+
8
+ PRES_ROOT="/workspace/presentations"
9
+ VIEWER="/opt/opencode/skills/KORTIX-presentation-viewer/serve.ts"
10
+ PORT=3210
11
+
12
+ wait_for_presentation() {
13
+ while true; do
14
+ if [ -d "$PRES_ROOT" ]; then
15
+ LATEST=$(find "$PRES_ROOT" -maxdepth 2 -name "metadata.json" -newer /tmp/.pv-last-check 2>/dev/null | head -1)
16
+ if [ -z "$LATEST" ]; then
17
+ LATEST=$(find "$PRES_ROOT" -maxdepth 2 -name "metadata.json" 2>/dev/null | head -1)
18
+ fi
19
+ if [ -n "$LATEST" ]; then
20
+ dirname "$LATEST"
21
+ return 0
22
+ fi
23
+ fi
24
+ sleep 3
25
+ done
26
+ }
27
+
28
+ touch /tmp/.pv-last-check
29
+
30
+ echo "[KORTIX-pv] Waiting for a presentation in $PRES_ROOT ..."
31
+ PRES_DIR=$(wait_for_presentation)
32
+ echo "[KORTIX-pv] Serving: $PRES_DIR on port $PORT"
33
+
34
+ touch /tmp/.pv-last-check
35
+
36
+ exec s6-setuidgid abc \
37
+ /usr/local/bin/bun run "$VIEWER" "$PRES_DIR"
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/with-contenv bash
2
+ # Agent Browser Viewer — s6 service
3
+ #
4
+ # Serves the browser viewer UI on port 9224.
5
+ # - GET / → viewer HTML
6
+ # - GET /sessions → JSON list of active sessions + stream ports
7
+
8
+ echo "[agent-browser-viewer] Starting viewer on port 9224"
9
+
10
+ exec s6-setuidgid abc \
11
+ node -e '
12
+ const http = require("http");
13
+ const fs = require("fs");
14
+ const path = require("path");
15
+
16
+ const html = fs.readFileSync("/opt/agent-browser-viewer/index.html");
17
+ const socketDir = process.env.AGENT_BROWSER_SOCKET_DIR || "/workspace/.agent-browser";
18
+
19
+ function getSessions() {
20
+ try {
21
+ const files = fs.readdirSync(socketDir);
22
+ const sessions = [];
23
+ for (const f of files) {
24
+ if (f.endsWith(".stream")) {
25
+ const name = f.replace(".stream", "");
26
+ const port = parseInt(fs.readFileSync(path.join(socketDir, f), "utf8").trim(), 10);
27
+ const hasSock = files.includes(name + ".sock");
28
+ if (port > 0 && hasSock) {
29
+ sessions.push({ name, port });
30
+ }
31
+ }
32
+ }
33
+ return sessions;
34
+ } catch(e) { return []; }
35
+ }
36
+
37
+ http.createServer((req, res) => {
38
+ if (req.url === "/sessions") {
39
+ res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-cache" });
40
+ res.end(JSON.stringify(getSessions()));
41
+ } else {
42
+ res.writeHead(200, { "Content-Type": "text/html", "Cache-Control": "no-cache" });
43
+ res.end(html);
44
+ }
45
+ }).listen(9224, "0.0.0.0", () => {
46
+ console.log("[agent-browser-viewer] Ready at http://0.0.0.0:9224");
47
+ });
48
+ '
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/with-contenv bash
2
+ # Kortix Master — s6 service
3
+ #
4
+ # Reverse proxy that sits in front of OpenCode on port 8000.
5
+ # All external traffic enters through Kortix Master, which proxies
6
+ # to the OpenCode API server on localhost:4096.
7
+
8
+ echo "[kortix-master] Starting on port 8000, proxying to OpenCode at localhost:4096"
9
+
10
+ exec s6-setuidgid abc \
11
+ env HOME=/workspace \
12
+ KORTIX_MASTER_PORT=8000 \
13
+ OPENCODE_HOST=localhost \
14
+ OPENCODE_PORT=4096 \
15
+ PATH="/opt/bun/bin:/usr/local/bin:/usr/bin:/bin" \
16
+ /opt/bun/bin/bun run /opt/kortix-master/src/index.ts
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/with-contenv bash
2
+ # lss-sync — File-watcher daemon that keeps the semantic search index in sync.
3
+ #
4
+ # Uses watchdog (inotify/FSEvents) to detect file changes in real time and
5
+ # triggers re-indexing with debounce. Changes are picked up within seconds.
6
+ #
7
+ # Watches:
8
+ # /workspace — User files and projects
9
+ # /workspace/.kortix — Agent memory
10
+
11
+ exec s6-setuidgid abc \
12
+ env HOME=/workspace \
13
+ OPENAI_API_KEY="${OPENAI_API_KEY}" \
14
+ LSS_DIR=/workspace/.lss \
15
+ PATH="/lsiopy/bin:/usr/local/bin:/usr/bin:/bin" \
16
+ lss-sync \
17
+ --watch /workspace \
18
+ --exclude node_modules \
19
+ --exclude .git \
20
+ --exclude __pycache__ \
21
+ --startup-delay 15 \
22
+ --debounce 2
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/with-contenv bash
2
+ # OpenCode API Server — s6 service
3
+ #
4
+ # Runs `opencode serve` on port 4096 (internal only, proxied by kortix-master).
5
+ # This is the headless API server, distinct from `opencode web` (the Web UI).
6
+
7
+ # Wait a moment for filesystem to settle
8
+ sleep 3
9
+
10
+ cd /workspace
11
+
12
+ # Ensure OpenCode data dirs exist and are owned by abc (guards against
13
+ # Daytona race conditions where /workspace ownership may shift after startup.sh)
14
+ mkdir -p /workspace/.local/share/opencode/log \
15
+ /workspace/.local/share/opencode/storage \
16
+ /workspace/.local/share/opencode/snapshot
17
+ chown -R abc:abc /workspace/.local/share/opencode
18
+
19
+ echo "[opencode-serve] Starting OpenCode API server on port 4096"
20
+
21
+ exec s6-setuidgid abc \
22
+ env HOME=/workspace \
23
+ OPENCODE_CONFIG_DIR=/opt/opencode \
24
+ PATH="/opt/bun/bin:/usr/local/bin:/usr/bin:/bin" \
25
+ opencode serve --port 4096 --hostname 0.0.0.0
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/with-contenv bash
2
+ # OpenCode Web UI — serves the web interface on port 3111
3
+ #
4
+ # Runs `opencode web` headless so it's accessible via the browser at
5
+ # http://localhost:3111 (mapped from the container).
6
+
7
+ cd /workspace
8
+
9
+ # Ensure OpenCode data dirs exist and are owned by abc
10
+ mkdir -p /workspace/.local/share/opencode/log \
11
+ /workspace/.local/share/opencode/storage \
12
+ /workspace/.local/share/opencode/snapshot
13
+ chown -R abc:abc /workspace/.local/share/opencode
14
+
15
+ exec s6-setuidgid abc \
16
+ env HOME=/workspace \
17
+ OPENCODE_CONFIG_DIR=/opt/opencode \
18
+ OPENCODE_SERVER_USERNAME= \
19
+ OPENCODE_SERVER_PASSWORD= \
20
+ PATH="/opt/bun/bin:/usr/local/bin:/usr/bin:/bin" \
21
+ opencode web --port 3111 --hostname 0.0.0.0