sera-code 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/NOTICE-SERA.md +25 -0
- package/README.md +27 -2
- package/THIRD_PARTY_NOTICES.md +68 -0
- package/bin/sera.mjs +137 -0
- package/dist/bundle/chunks/anthropic-messages-RD7GXOQL.js +6 -0
- package/dist/bundle/chunks/anthropic.js +75 -0
- package/dist/bundle/chunks/azure-openai-responses-CJT3KTVK.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +89 -0
- package/dist/bundle/chunks/chunk-46WGNYIE.js +82 -0
- package/dist/bundle/chunks/chunk-4UNN5OGR.js +4 -0
- package/dist/bundle/chunks/chunk-53H5DPHA.js +16 -0
- package/dist/bundle/chunks/chunk-5AGIVGSV.js +6 -0
- package/dist/bundle/chunks/chunk-6JXVX6Q2.js +2 -0
- package/dist/bundle/chunks/chunk-6QGV3IWD.js +6 -0
- package/dist/bundle/chunks/chunk-7CBJINYJ.js +20 -0
- package/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
- package/dist/bundle/chunks/chunk-7RZ5BS7U.js +2 -0
- package/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
- package/dist/bundle/chunks/chunk-BPHHHEET.js +9 -0
- package/dist/bundle/chunks/chunk-BSS6T6KQ.js +2 -0
- package/dist/bundle/chunks/chunk-CF5GWZHW.js +31 -0
- package/dist/bundle/chunks/chunk-EDSQGWII.js +44 -0
- package/dist/bundle/chunks/chunk-FFMDRXC4.js +10 -0
- package/dist/bundle/chunks/chunk-GUGC72EB.js +1222 -0
- package/dist/bundle/chunks/chunk-HODJBMOY.js +9 -0
- package/dist/bundle/chunks/chunk-HQBQWHLD.js +7 -0
- package/dist/bundle/chunks/chunk-HQJBN2MC.js +2 -0
- package/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
- package/dist/bundle/chunks/chunk-KXU77PUU.js +4 -0
- package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
- package/dist/bundle/chunks/chunk-LPXNMA2W.js +2 -0
- package/dist/bundle/chunks/chunk-LVVZS2NO.js +12 -0
- package/dist/bundle/chunks/chunk-M3LEVT3X.js +2 -0
- package/dist/bundle/chunks/chunk-P7FPUEYA.js +2 -0
- package/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
- package/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
- package/dist/bundle/chunks/chunk-PMRZO46Y.js +2 -0
- package/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
- package/dist/bundle/chunks/chunk-QTM7S6TH.js +2 -0
- package/dist/bundle/chunks/chunk-RDZVAGPR.js +2 -0
- package/dist/bundle/chunks/chunk-TLNP2BSO.js +2 -0
- package/dist/bundle/chunks/chunk-TMKHGABX.js +2 -0
- package/dist/bundle/chunks/chunk-TMTOQ7H7.js +2 -0
- package/dist/bundle/chunks/chunk-UKVNB6C4.js +2 -0
- package/dist/bundle/chunks/chunk-USJZMAIR.js +2 -0
- package/dist/bundle/chunks/chunk-UTB4DTYQ.js +2 -0
- package/dist/bundle/chunks/chunk-ZLAHUYDW.js +131 -0
- package/dist/bundle/chunks/chunk-ZNCN2NGY.js +60 -0
- package/dist/bundle/chunks/cli-MML2DU4A.js +51 -0
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-QPZQRBK5.js +2 -0
- package/dist/bundle/chunks/codemode-worker.js +478 -0
- package/dist/bundle/chunks/dist-ZNZCJI7B.js +7 -0
- package/dist/bundle/chunks/easter-egg-3d-VOETWRJO.js +2 -0
- package/dist/bundle/chunks/execute-HXDNZ26B.js +505 -0
- package/dist/bundle/chunks/github-copilot.js +2 -0
- package/dist/bundle/chunks/google-generative-ai-SJXMIEPZ.js +2 -0
- package/dist/bundle/chunks/google-vertex-VSXQ3BDH.js +2 -0
- package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +13 -0
- package/dist/bundle/chunks/image-resize-worker.js +2 -0
- package/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +21 -0
- package/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +2 -0
- package/dist/bundle/chunks/kimi-coding.js +2 -0
- package/dist/bundle/chunks/lib-4AVRLBHM.js +9 -0
- package/dist/bundle/chunks/llama-cpp-classify-4KFSGAMH.js +22 -0
- package/dist/bundle/chunks/meta.js +2 -0
- package/dist/bundle/chunks/mistral-conversations-JYWDZV2K.js +5 -0
- package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +3 -0
- package/dist/bundle/chunks/node-AUOGOBCN.js +2 -0
- package/dist/bundle/chunks/node-KCMANYC2.js +16 -0
- package/dist/bundle/chunks/openai-chatgpt.js +75 -0
- package/dist/bundle/chunks/openai-codex-responses-OQV5DCFA.js +10 -0
- package/dist/bundle/chunks/openai-codex.js +75 -0
- package/dist/bundle/chunks/openai-completions-RFDJM2W5.js +7 -0
- package/dist/bundle/chunks/openai-decisions-O6PHBSCB.js +5 -0
- package/dist/bundle/chunks/openai-responses-LVNAPALQ.js +4 -0
- package/dist/bundle/chunks/openrouter-images-4WG6OOLH.js +2 -0
- package/dist/bundle/chunks/openrouter.js +75 -0
- package/dist/bundle/chunks/pdfjs-BETXZQ7A.js +108 -0
- package/dist/bundle/chunks/pdfjs-decoders-37HBPYHX.js +2 -0
- package/dist/bundle/chunks/pdfjs-jbig2-MH7WRXUP.js +2 -0
- package/dist/bundle/chunks/pdfjs-jbig2_nowasm_fallback-UVK7AQLA.js +2 -0
- package/dist/bundle/chunks/pdfjs-openjpeg-TC2QHC4G.js +2 -0
- package/dist/bundle/chunks/pdfjs-openjpeg_nowasm_fallback-ZC2FTHCZ.js +3 -0
- package/dist/bundle/chunks/pi-messages-EZXKVRR6.js +8 -0
- package/dist/bundle/chunks/radius.js +75 -0
- package/dist/bundle/chunks/runtime-JAH75CB5.js +2 -0
- package/dist/bundle/chunks/src-QKGKDFSU.js +4 -0
- package/dist/bundle/chunks/typesafe-system-one-X3JT6ECA.js +2 -0
- package/dist/bundle/chunks/virtual-modules-I5QRIHN6.js +2 -0
- package/dist/bundle/chunks/xai.js +2 -0
- package/dist/bundle/cli-runtime.js +3 -0
- package/dist/bundle/cli.js +5 -0
- package/dist/bundle/index.js +2 -0
- package/dist/bundle/rpc-entry.js +3 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +249 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +37 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +228 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +1085 -0
- package/dist/core/export-html/template.html +56 -0
- package/dist/core/export-html/template.js +2044 -0
- package/dist/core/export-html/tool-renderer.d.ts +34 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +110 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
- package/dist/core/export-html/vendor/marked.min.js +79 -0
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/theme/dark.json +81 -0
- package/dist/modes/interactive/theme/light.json +81 -0
- package/dist/modes/interactive/theme/system-theme.d.ts +55 -0
- package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/system-theme.js +546 -0
- package/dist/modes/interactive/theme/system-theme.js.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +81 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-controller.js +210 -0
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.js +105 -0
- package/dist/modes/interactive/theme/theme-schema.js.map +1 -0
- package/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
- package/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-tokens.js +94 -0
- package/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
- package/dist/modes/interactive/theme/theme.d.ts +155 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +905 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/docs/cli-integration.md +106 -0
- package/docs/cli.md +333 -0
- package/docs/codemode.md +230 -0
- package/docs/compaction.md +463 -0
- package/docs/configuration.md +47 -0
- package/docs/containerization.md +183 -0
- package/docs/custom-provider.md +227 -0
- package/docs/docs.json +220 -0
- package/docs/environment-variables.md +102 -0
- package/docs/extensions.md +400 -0
- package/docs/how-pi-works.md +49 -0
- package/docs/index.md +39 -0
- package/docs/json.md +226 -0
- package/docs/keybindings.md +195 -0
- package/docs/llama-cpp.md +121 -0
- package/docs/mcp.md +272 -0
- package/docs/message-types.md +279 -0
- package/docs/models-configuration.md +196 -0
- package/docs/models.md +225 -0
- package/docs/nvidia-rtx-llama-cpp.md +96 -0
- package/docs/packages.md +131 -0
- package/docs/prompt-templates.md +59 -0
- package/docs/providers.md +247 -0
- package/docs/quickstart.md +136 -0
- package/docs/rpc-commands.md +860 -0
- package/docs/rpc-extension-ui.md +200 -0
- package/docs/rpc.md +193 -0
- package/docs/sdk.md +147 -0
- package/docs/security.md +99 -0
- package/docs/session-format.md +293 -0
- package/docs/sessions.md +66 -0
- package/docs/settings.md +172 -0
- package/docs/shell-aliases.md +93 -0
- package/docs/skills.md +93 -0
- package/docs/slash-commands.md +61 -0
- package/docs/terminal-setup.md +233 -0
- package/docs/termux.md +117 -0
- package/docs/themes.md +138 -0
- package/docs/tmux.md +55 -0
- package/docs/tui.md +195 -0
- package/docs/usage.md +94 -0
- package/docs/virtual-models.md +114 -0
- package/docs/windows.md +81 -0
- package/lib/auth.js +190 -0
- package/lib/provider.js +52 -0
- package/package.json +43 -5
- package/sera-core/skills/apple-tasarim/SKILL.md +48 -0
- package/sera-core/skills/apple-tasarim/referanslar/apple-hig.md +55 -0
- package/sera-core/skills/belge-yarat/SKILL.md +64 -0
- package/sera-core/skills/belge-yarat/referanslar/belge-yazim.md +60 -0
- package/sera-core/skills/derin-arastirma/SKILL.md +52 -0
- package/sera-core/skills/derin-arastirma/referanslar/arastirma-yontem.md +50 -0
- package/sera-core/skills/dusunme-dogrulama/SKILL.md +59 -0
- package/sera-core/skills/dusunme-dogrulama/referanslar/dusunme-kontrol.md +54 -0
- package/sera-core/skills/film-stilleri/SKILL.md +51 -0
- package/sera-core/skills/hyperframes/LICENSE-UPSTREAM +190 -0
- package/sera-core/skills/hyperframes/SKILL.md +79 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/biennale-yellow/FRAME.md +289 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/blockframe/FRAME.md +275 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/blue-professional/FRAME.md +307 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/bold-poster/FRAME.md +275 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/broadside/FRAME.md +284 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/capsule/FRAME.md +284 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/cartesian/FRAME.md +278 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/cobalt-grid/FRAME.md +265 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/code-editorial/FRAME.md +277 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/coral/FRAME.md +314 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/creative-mode/FRAME.md +333 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/daisy-days/FRAME.md +274 -0
- package/sera-core/skills/hyperframes/assets/frame-presets/editorial-forest/FRAME.md +265 -0
- package/sera-core/skills/hyperframes/references/captions.md +46 -0
- package/sera-core/skills/hyperframes/references/film.md +48 -0
- package/sera-core/skills/hyperframes/references/format.md +159 -0
- package/sera-core/skills/hyperframes/references/look.md +69 -0
- package/sera-core/skills/hyperframes/references/motion.md +95 -0
- package/sera-core/skills/hyperframes/references/overlays.md +39 -0
- package/sera-core/skills/hyperframes/references/path-tracing.md +36 -0
- package/sera-core/skills/hyperframes/references/plugin-installation.md +42 -0
- package/sera-core/skills/hyperframes/references/review.md +51 -0
- package/sera-core/skills/hyperframes/references/runtimes.md +69 -0
- package/sera-core/skills/hyperframes/references/skill-lifecycle.md +54 -0
- package/sera-core/skills/hyperframes/references/sound.md +43 -0
- package/sera-core/skills/hyperframes/references/spec.md +76 -0
- package/sera-core/skills/hyperframes/references/story.md +103 -0
- package/sera-core/skills/hyperframes/references/storyboard-format.md +107 -0
- package/sera-core/skills/hyperframes/references/storyboard.md +36 -0
- package/sera-core/skills/hyperframes/references/types/3d.md +25 -0
- package/sera-core/skills/hyperframes/references/types/character.md +20 -0
- package/sera-core/skills/hyperframes/references/types/data.md +19 -0
- package/sera-core/skills/hyperframes/references/types/explainer.md +34 -0
- package/sera-core/skills/hyperframes/references/types/launch.md +41 -0
- package/sera-core/skills/hyperframes/references/types/music.md +24 -0
- package/sera-core/skills/hyperframes/references/types/vertical.md +23 -0
- package/sera-core/skills/hyperframes-cli/LICENSE-UPSTREAM +190 -0
- package/sera-core/skills/hyperframes-cli/SKILL.md +99 -0
- package/sera-core/skills/hyperframes-cli/references/beats.md +17 -0
- package/sera-core/skills/hyperframes-cli/references/compare-and-batch.md +105 -0
- package/sera-core/skills/hyperframes-cli/references/conventions.md +16 -0
- package/sera-core/skills/hyperframes-cli/references/doctor-browser.md +80 -0
- package/sera-core/skills/hyperframes-cli/references/feedback.md +14 -0
- package/sera-core/skills/hyperframes-cli/references/init-and-scaffold.md +75 -0
- package/sera-core/skills/hyperframes-cli/references/lint-validate-inspect.md +164 -0
- package/sera-core/skills/hyperframes-cli/references/preview-render.md +204 -0
- package/sera-core/skills/hyperframes-cli/references/upgrade-info-misc.md +134 -0
- package/sera-core/skills/impeccable/LICENSE-UPSTREAM +191 -0
- package/sera-core/skills/impeccable/NOTICE-UPSTREAM.md +11 -0
- package/sera-core/skills/impeccable/SKILL.md +89 -0
- package/sera-core/skills/impeccable/reference/adapt.md +318 -0
- package/sera-core/skills/impeccable/reference/adapt.native.md +58 -0
- package/sera-core/skills/impeccable/reference/android.md +46 -0
- package/sera-core/skills/impeccable/reference/animate.md +89 -0
- package/sera-core/skills/impeccable/reference/audit.md +139 -0
- package/sera-core/skills/impeccable/reference/audit.native.md +139 -0
- package/sera-core/skills/impeccable/reference/bolder.md +33 -0
- package/sera-core/skills/impeccable/reference/clarify.md +94 -0
- package/sera-core/skills/impeccable/reference/colorize.md +86 -0
- package/sera-core/skills/impeccable/reference/component-review.md +63 -0
- package/sera-core/skills/impeccable/reference/craft-floor.md +44 -0
- package/sera-core/skills/impeccable/reference/craft.md +5 -0
- package/sera-core/skills/impeccable/reference/critique.md +819 -0
- package/sera-core/skills/impeccable/reference/degraded/asset-producer.md +42 -0
- package/sera-core/skills/impeccable/reference/degraded/documenter.md +24 -0
- package/sera-core/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
- package/sera-core/skills/impeccable/reference/degraded/manual-edit-applier.md +93 -0
- package/sera-core/skills/impeccable/reference/delight.md +70 -0
- package/sera-core/skills/impeccable/reference/distill.md +111 -0
- package/sera-core/skills/impeccable/reference/doctor.md +54 -0
- package/sera-core/skills/impeccable/reference/document.md +416 -0
- package/sera-core/skills/impeccable/reference/extract.md +69 -0
- package/sera-core/skills/impeccable/reference/generate.md +101 -0
- package/sera-core/skills/impeccable/reference/harden.md +362 -0
- package/sera-core/skills/impeccable/reference/hooks.md +120 -0
- package/sera-core/skills/impeccable/reference/init.md +133 -0
- package/sera-core/skills/impeccable/reference/ios.md +51 -0
- package/sera-core/skills/impeccable/reference/layout.md +84 -0
- package/sera-core/skills/impeccable/reference/live-setup.md +104 -0
- package/sera-core/skills/impeccable/reference/live.md +327 -0
- package/sera-core/skills/impeccable/reference/mode-operate.md +21 -0
- package/sera-core/skills/impeccable/reference/mode-persuade.md +19 -0
- package/sera-core/skills/impeccable/reference/mode-read.md +21 -0
- package/sera-core/skills/impeccable/reference/new-work.md +152 -0
- package/sera-core/skills/impeccable/reference/onboard.md +234 -0
- package/sera-core/skills/impeccable/reference/operate.md +61 -0
- package/sera-core/skills/impeccable/reference/optimize.md +257 -0
- package/sera-core/skills/impeccable/reference/overdrive.md +127 -0
- package/sera-core/skills/impeccable/reference/polish.md +105 -0
- package/sera-core/skills/impeccable/reference/quieter.md +99 -0
- package/sera-core/skills/impeccable/reference/region-map.md +26 -0
- package/sera-core/skills/impeccable/reference/routing.md +24 -0
- package/sera-core/skills/impeccable/reference/shape.md +59 -0
- package/sera-core/skills/impeccable/reference/typeset.md +90 -0
- package/sera-core/skills/impeccable/reference/visualize.md +47 -0
- package/sera-core/skills/oyun-yarat/SKILL.md +106 -0
- package/sera-core/skills/oyun-yarat/referanslar/3b-yaris.md +74 -0
- package/sera-core/skills/oyun-yarat/referanslar/kaplay.md +99 -0
- package/sera-core/skills/oyun-yarat/referanslar/oyun-desenleri.md +73 -0
- package/sera-core/skills/oyun-yarat/sablonlar/kaplay-2d.html +164 -0
- package/sera-core/skills/oyun-yarat/sablonlar/three-yaris.html +149 -0
- package/sera-core/skills/oyun-yarat/sablonlar/tuval-minimal.html +77 -0
- package/sera-core/skills/receiving-code-review/LICENSE-UPSTREAM +21 -0
- package/sera-core/skills/receiving-code-review/SKILL.md +205 -0
- package/sera-core/skills/refero-design/LICENSE-UPSTREAM +21 -0
- package/sera-core/skills/refero-design/SKILL.md +534 -0
- package/sera-core/skills/refero-design/references/anti-ai-slop.md +292 -0
- package/sera-core/skills/refero-design/references/color.md +563 -0
- package/sera-core/skills/refero-design/references/copywriting.md +222 -0
- package/sera-core/skills/refero-design/references/craft-details.md +525 -0
- package/sera-core/skills/refero-design/references/example-workflow.md +264 -0
- package/sera-core/skills/refero-design/references/icons.md +166 -0
- package/sera-core/skills/refero-design/references/mcp-tools.md +258 -0
- package/sera-core/skills/refero-design/references/motion.md +504 -0
- package/sera-core/skills/refero-design/references/typography.md +737 -0
- package/sera-core/skills/refero-design/references/visual-workflow.md +105 -0
- package/sera-core/skills/requesting-code-review/LICENSE-UPSTREAM +21 -0
- package/sera-core/skills/requesting-code-review/SKILL.md +95 -0
- package/sera-core/skills/requesting-code-review/code-reviewer.md +198 -0
- package/sera-core/skills/reverse-engineer-anything/DISCLAIMER.md +136 -0
- package/sera-core/skills/reverse-engineer-anything/LICENSE-REA-MIT +21 -0
- package/sera-core/skills/reverse-engineer-anything/SKILL.md +363 -0
- package/sera-core/skills/reverse-engineer-anything/THIRD_PARTY_NOTICES.md +135 -0
- package/sera-core/skills/reverse-engineer-anything/references/android-applications.md +36 -0
- package/sera-core/skills/reverse-engineer-anything/references/connection-and-recovery.md +127 -0
- package/sera-core/skills/reverse-engineer-anything/references/evidence-workflows.md +71 -0
- package/sera-core/skills/reverse-engineer-anything/references/javascript-applications.md +218 -0
- package/sera-core/skills/reverse-engineer-anything/references/native-and-artifacts.md +297 -0
- package/sera-core/skills/reverse-engineer-anything/references/runtime-observation.md +78 -0
- package/sera-core/skills/seo-audit/LICENSE-UPSTREAM +21 -0
- package/sera-core/skills/seo-audit/SKILL.md +210 -0
- package/sera-core/skills/sera-guvenlik-denetim/SKILL.md +44 -0
- package/sera-core/skills/sera-guvenlik-denetim/referanslar/guvenlik-listesi.md +33 -0
- package/sera-core/skills/sera-hata-ayikla/SKILL.md +27 -0
- package/sera-core/skills/sera-hata-ayikla/referanslar/hata-ayiklama.md +37 -0
- package/sera-core/skills/sera-kod-inceleme/SKILL.md +44 -0
- package/sera-core/skills/sera-kod-inceleme/referanslar/inceleme-listesi.md +62 -0
- package/sera-core/skills/sera-ofis-dosya/SKILL.md +27 -0
- package/sera-core/skills/sera-ofis-dosya/referanslar/ofis-dosya.md +93 -0
- package/sera-core/skills/sera-research/SKILL.md +90 -0
- package/sera-core/skills/sera-tasarim/SKILL.md +149 -0
- package/sera-core/skills/sera-teslim-sozlesmesi/SKILL.md +592 -0
- package/sera-core/skills/sera-test-yaz/SKILL.md +26 -0
- package/sera-core/skills/sera-test-yaz/referanslar/test-yazimi.md +35 -0
- package/sera-core/skills/sera-veri-gorsel/SKILL.md +65 -0
- package/sera-core/skills/sera-web-test/SKILL.md +26 -0
- package/sera-core/skills/sera-web-test/referanslar/web-test.md +44 -0
- package/sera-core/skills/sera-zamanli-gorev/SKILL.md +22 -0
- package/sera-core/skills/sera-zamanli-gorev/referanslar/zamanli-gorev.md +58 -0
- package/sera-core/skills/systematic-debugging/LICENSE-UPSTREAM +21 -0
- package/sera-core/skills/systematic-debugging/SKILL.md +283 -0
- package/sera-core/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/sera-core/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/sera-core/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/sera-core/skills/test-driven-development/LICENSE-UPSTREAM +21 -0
- package/sera-core/skills/test-driven-development/SKILL.md +330 -0
- package/sera-core/skills/test-driven-development/writing-good-tests.md +198 -0
- package/sera-core/skills/ticaret-icerik/SKILL.md +49 -0
- package/sera-core/skills/ticaret-icerik/referanslar/ticaret-icerik.md +54 -0
- package/sera-core/skills/uygulama-yarat/SKILL.md +95 -0
- package/sera-core/skills/uygulama-yarat/referanslar/uygulama-desenleri.md +63 -0
- package/sera-core/skills/uygulama-yarat/sablonlar/uygulama-tek-dosya.html +121 -0
- package/sera-core/skills/uyumluluk-denetim/SKILL.md +56 -0
- package/sera-core/skills/uyumluluk-denetim/referanslar/mevzuat-tablosu.md +65 -0
- package/sera-core/skills/veri-analizi/SKILL.md +54 -0
- package/sera-core/skills/veri-analizi/referanslar/veri-analizi-yontem.md +49 -0
- package/sera-core/skills/veri-analizi/sablonlar/profil.mjs +79 -0
- package/sera-core/skills/video-duzen/SKILL.md +50 -0
- package/sera-core/skills/video-duzen/referanslar/video-duzen.md +100 -0
- package/sera-core/skills/web-yayin-listesi/SKILL.md +115 -0
- package/sera-core/skills/writing-plans/LICENSE-UPSTREAM +21 -0
- package/sera-core/skills/writing-plans/SKILL.md +204 -0
- package/sera-core/src/action-nudge.ts +200 -0
- package/sera-core/src/agent-mode.ts +143 -0
- package/sera-core/src/agents.ts +185 -0
- package/sera-core/src/app-master.ts +275 -0
- package/sera-core/src/app-verify.ts +551 -0
- package/sera-core/src/approval.ts +131 -0
- package/sera-core/src/budget.ts +136 -0
- package/sera-core/src/command-policy.ts +808 -0
- package/sera-core/src/config.ts +135 -0
- package/sera-core/src/context-diet.ts +272 -0
- package/sera-core/src/device-id.ts +48 -0
- package/sera-core/src/dogal-arac.ts +203 -0
- package/sera-core/src/dogal-niyet.ts +173 -0
- package/sera-core/src/egress-allow.ts +52 -0
- package/sera-core/src/export.ts +124 -0
- package/sera-core/src/exposure.ts +8 -0
- package/sera-core/src/extension.ts +2416 -0
- package/sera-core/src/fs-tools.ts +444 -0
- package/sera-core/src/generated/build-rules.ts +26 -0
- package/sera-core/src/generated/zero-knowledge.ts +170 -0
- package/sera-core/src/github-agent-command.ts +133 -0
- package/sera-core/src/github-agent-engine.ts +198 -0
- package/sera-core/src/github-agent-schedule.ts +180 -0
- package/sera-core/src/github-agent.ts +669 -0
- package/sera-core/src/github-ajan-akis.ts +193 -0
- package/sera-core/src/github-ajan-gercek.ts +102 -0
- package/sera-core/src/github-tick.ts +78 -0
- package/sera-core/src/github-yedek.ts +269 -0
- package/sera-core/src/goal.ts +119 -0
- package/sera-core/src/handoff.ts +132 -0
- package/sera-core/src/hooks.ts +284 -0
- package/sera-core/src/image-tool.ts +118 -0
- package/sera-core/src/intake-brief.ts +82 -0
- package/sera-core/src/intake-core.ts +1152 -0
- package/sera-core/src/intake-hook.ts +88 -0
- package/sera-core/src/ios-build-tool.ts +134 -0
- package/sera-core/src/lazy-capability.ts +125 -0
- package/sera-core/src/lazy-mcp.ts +300 -0
- package/sera-core/src/limit-command.ts +51 -0
- package/sera-core/src/loop-brake.ts +129 -0
- package/sera-core/src/lsp.ts +618 -0
- package/sera-core/src/mcp-bridge.ts +159 -0
- package/sera-core/src/mcp-pin.ts +105 -0
- package/sera-core/src/mcp-ssrf.ts +124 -0
- package/sera-core/src/message-cap.ts +45 -0
- package/sera-core/src/no-progress.ts +177 -0
- package/sera-core/src/notebook-tool.ts +179 -0
- package/sera-core/src/ofis.ts +473 -0
- package/sera-core/src/path-guard.ts +139 -0
- package/sera-core/src/permission-bridge.ts +228 -0
- package/sera-core/src/policy-chain.ts +122 -0
- package/sera-core/src/pricing.ts +71 -0
- package/sera-core/src/proc.ts +149 -0
- package/sera-core/src/rea.ts +188 -0
- package/sera-core/src/repo-map.ts +230 -0
- package/sera-core/src/research.ts +347 -0
- package/sera-core/src/rules-memory.ts +227 -0
- package/sera-core/src/sandbox.ts +445 -0
- package/sera-core/src/server-error.ts +78 -0
- package/sera-core/src/skills.ts +268 -0
- package/sera-core/src/snapshot.ts +143 -0
- package/sera-core/src/spec-gate.ts +112 -0
- package/sera-core/src/subagent.ts +261 -0
- package/sera-core/src/teslim.ts +120 -0
- package/sera-core/src/test-fix.ts +184 -0
- package/sera-core/src/todo-question.ts +163 -0
- package/sera-core/src/turn-snapshots.ts +126 -0
- package/sera-core/src/tuval/arac.ts +338 -0
- package/sera-core/src/tuval/arsiv.ts +106 -0
- package/sera-core/src/tuval/belge.ts +216 -0
- package/sera-core/src/tuval/birlestir.ts +282 -0
- package/sera-core/src/tuval/disa.ts +235 -0
- package/sera-core/src/tuval/editor.ts +583 -0
- package/sera-core/src/tuval/film-cekirdek.ts +170 -0
- package/sera-core/src/tuval/film-disa.ts +188 -0
- package/sera-core/src/tuval/film-oynatici.ts +307 -0
- package/sera-core/src/tuval/kimlik.ts +156 -0
- package/sera-core/src/tuval/pano.ts +763 -0
- package/sera-core/src/tuval/proje.ts +728 -0
- package/sera-core/src/tuval/sistem-cekirdek.ts +167 -0
- package/sera-core/src/tuval/sistem.ts +328 -0
- package/sera-core/src/tuval/sunucu.ts +413 -0
- package/sera-core/src/tuval/uretim.ts +24 -0
- package/sera-core/src/tuval/veri-cekirdek.ts +477 -0
- package/sera-core/src/tuval/xlsx.ts +215 -0
- package/sera-core/src/tuval/zip.ts +163 -0
- package/sera-core/src/untrusted.ts +201 -0
- package/sera-core/src/video-edit-tool.ts +411 -0
- package/sera-core/src/video-tool.ts +217 -0
- package/sera-core/src/web-tools.ts +257 -0
- package/sera-core/src/zk.ts +104 -0
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OS sandbox (rakip boşluğu E1 — CANLI; temeli PR#8). Kabuk komutlarını işletim sistemi seviyesinde izole bir kutuda
|
|
3
|
+
* çalıştırır — @anthropic-ai/sandbox-runtime ile (Claude Code'un /sandbox'ı; Apache-2.0, TypeScript).
|
|
4
|
+
* Linux bubblewrap+ağ-namespace, macOS Seatbelt, Windows srt-sandbox (yazma-kısıtlı token + ağ proxy'si; WFP kurulumu varsa çekirdek seviyesi ağ çiti).
|
|
5
|
+
*
|
|
6
|
+
* Bu modül: (1) config okuma, (2) Sera cwd/ayarından sandbox-runtime config'ini ÜRETME (saf, test edilir),
|
|
7
|
+
* (3) SandboxRunner: ilk kabuk komutunda TEMBEL yüklenir/başlar, sonra önbellekten sarmalar. Modül kurulu değilse,
|
|
8
|
+
* platform desteklemiyorsa ya da başlatma hata verirse sandboxed:false + Türkçe neden döner (komut sarmalanmadan geçer;
|
|
9
|
+
* çağıran taraf bunu kullanıcıya AÇIKÇA söyler — asla sessizce "izole sandım" yanılgısı üretmez).
|
|
10
|
+
*
|
|
11
|
+
* GÜVENLİK: yazma yalnız cwd + geçici klasör + izinliler; ağ yalnız allowlist (paket kayıtları vb.); gizli dizinler
|
|
12
|
+
* (~/.ssh ~/.aws ...) OKUNAMAZ; gizli dosyalar (.env, anahtarlar) her zaman denyWrite. Varsayılan AÇIK; SERA_SANDBOX=0 kapatır.
|
|
13
|
+
* Windows'ta `windows-install` (admin) İSTEMEZ: kurulu değilse yazma/okuma kısıtları yine çalışır (yazma-kısıtlı token),
|
|
14
|
+
* ağ proxy ortam değişkenleriyle yönlendirilir (çekirdek seviyesi ağ çiti için kurulum gerekir).
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync, mkdirSync, readdirSync } from "node:fs";
|
|
17
|
+
import { homedir, tmpdir } from "node:os";
|
|
18
|
+
import { isAbsolute, join, relative } from "node:path";
|
|
19
|
+
|
|
20
|
+
export interface SandboxConfig {
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
/** cwd'ye EK yazılabilir yollar (cwd her zaman eklenir). */
|
|
23
|
+
allowWrite: string[];
|
|
24
|
+
/** Ağ allowlist (ör. "github.com", "*.npmjs.org"). Boş = ağ erişimi yok. */
|
|
25
|
+
allowedDomains: string[];
|
|
26
|
+
/** Her zaman yazılamaz (gizli dosyalar). Varsayılanlar DEFAULT_DENY_WRITE ile birleşir. */
|
|
27
|
+
denyWrite: string[];
|
|
28
|
+
/** EK okunamaz yollar (varsayılan gizli dizinler defaultDenyRead() ile birleşir). */
|
|
29
|
+
denyRead: string[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Ağ allowlist'i: paket kayıtları + kod barındırma. Config/env bunu GENİŞLETİR (daraltmak için sandbox.allowedDomains yetmez: settings'te kendi listeni ver ya da SERA_SANDBOX=0). */
|
|
33
|
+
export const DEFAULT_ALLOWED_DOMAINS: readonly string[] = [
|
|
34
|
+
"registry.npmjs.org",
|
|
35
|
+
"*.npmjs.org",
|
|
36
|
+
"registry.yarnpkg.com",
|
|
37
|
+
"pypi.org",
|
|
38
|
+
"files.pythonhosted.org",
|
|
39
|
+
"github.com",
|
|
40
|
+
"*.github.com",
|
|
41
|
+
"*.githubusercontent.com",
|
|
42
|
+
"crates.io",
|
|
43
|
+
"static.crates.io",
|
|
44
|
+
"index.crates.io",
|
|
45
|
+
"proxy.golang.org",
|
|
46
|
+
"sum.golang.org",
|
|
47
|
+
"rubygems.org",
|
|
48
|
+
"*.rubygems.org",
|
|
49
|
+
"repo.maven.apache.org",
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
/** Sandbox içinde OKUNAMAZ gizli dizin/dosyalar (ev dizinine göre). */
|
|
53
|
+
export function defaultDenyRead(home: string = homedir()): string[] {
|
|
54
|
+
const j = (...p: string[]) => join(home, ...p);
|
|
55
|
+
return [
|
|
56
|
+
j(".ssh"),
|
|
57
|
+
j(".aws"),
|
|
58
|
+
j(".gnupg"),
|
|
59
|
+
j(".azure"),
|
|
60
|
+
j(".kube"),
|
|
61
|
+
j(".docker", "config.json"),
|
|
62
|
+
j(".config", "gcloud"),
|
|
63
|
+
j(".config", "gh"),
|
|
64
|
+
j(".netrc"),
|
|
65
|
+
j(".git-credentials"),
|
|
66
|
+
j(".npmrc"),
|
|
67
|
+
j("AppData", "Roaming", "gcloud"),
|
|
68
|
+
j("AppData", "Roaming", "GitHub CLI"),
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Sandbox açıkken bile asla yazılmaması gereken gizli yollar (allowWrite cwd'yi açsa bile bunlar engellenir). */
|
|
73
|
+
export const DEFAULT_DENY_WRITE: readonly string[] = [
|
|
74
|
+
".env",
|
|
75
|
+
".env.*",
|
|
76
|
+
"*.pem",
|
|
77
|
+
"*.key",
|
|
78
|
+
"id_rsa",
|
|
79
|
+
"id_ed25519",
|
|
80
|
+
".git/config",
|
|
81
|
+
".npmrc",
|
|
82
|
+
".netrc",
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
/** sandbox-runtime'ın beklediği config biçimi (yerel gevşek tip — dep kurulu olmadan da tsc geçsin diye). */
|
|
86
|
+
export interface SandboxRuntimeConfig {
|
|
87
|
+
filesystem: { allowWrite: string[]; denyWrite: string[]; denyRead: string[] };
|
|
88
|
+
network: { allowedDomains: string[]; deniedDomains: string[] };
|
|
89
|
+
/** Yalnız Windows: paketli srt-win.exe yolu (SandboxRunner modülden VENDORED_SRT_WIN_EXE ile doldurur). */
|
|
90
|
+
windows?: { srtWin?: { path: string } };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const list = (v: unknown): string[] =>
|
|
94
|
+
Array.isArray(v) ? v.filter((x): x is string => typeof x === "string" && !!x.trim()).map((x) => x.trim()) : [];
|
|
95
|
+
|
|
96
|
+
const envList = (v: string | undefined): string[] | undefined =>
|
|
97
|
+
v === undefined
|
|
98
|
+
? undefined
|
|
99
|
+
: v
|
|
100
|
+
.split(",")
|
|
101
|
+
.map((s) => s.trim())
|
|
102
|
+
.filter(Boolean);
|
|
103
|
+
|
|
104
|
+
/** config dosyası + ortamdan SandboxConfig. Varsayılan AÇIK; kapatma: SERA_SANDBOX=0 ya da settings.json sandbox.enabled=false. */
|
|
105
|
+
export function sandboxFromConfig(
|
|
106
|
+
file: { sandbox?: Partial<SandboxConfig> } | undefined,
|
|
107
|
+
env: Record<string, string | undefined>,
|
|
108
|
+
): SandboxConfig {
|
|
109
|
+
const f = file?.sandbox ?? {};
|
|
110
|
+
const enabled = env.SERA_SANDBOX === "1" ? true : env.SERA_SANDBOX === "0" ? false : (f.enabled ?? true);
|
|
111
|
+
return {
|
|
112
|
+
enabled,
|
|
113
|
+
allowWrite: envList(env.SERA_SANDBOX_ALLOW_WRITE) ?? list(f.allowWrite),
|
|
114
|
+
allowedDomains: envList(env.SERA_SANDBOX_ALLOW_NET) ?? list(f.allowedDomains),
|
|
115
|
+
denyWrite: list(f.denyWrite),
|
|
116
|
+
denyRead: list(f.denyRead),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Sandbox'ın yazabildiği geçici klasör. Windows'ta Temp'in KENDİSİ verilemez (sandbox-runtime profil-okuma dışlaması: "grant a
|
|
122
|
+
* directory inside it instead"); Sera kendi alt klasörünü kullanır. Diğer platformlarda sistem geçici klasörü.
|
|
123
|
+
*/
|
|
124
|
+
export function sandboxTmpDir(platform: NodeJS.Platform = process.platform): string {
|
|
125
|
+
return platform === "win32" ? join(tmpdir(), "sera-sandbox") : tmpdir();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const uniq = (a: string[]): string[] => a.filter((p, i) => !!p && a.indexOf(p) === i);
|
|
129
|
+
|
|
130
|
+
const lc = (p: string) => p.replace(/[\\/]+$/, "").toLowerCase();
|
|
131
|
+
/** a, b'nin atasi mi (ya da ayni yol)? */
|
|
132
|
+
const isAncestor = (a: string, b: string) => {
|
|
133
|
+
const r = relative(lc(a), lc(b));
|
|
134
|
+
return r === "" || (!r.startsWith("..") && !isAbsolute(r));
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Yazma kok(ler)i. cwd gizli kimlik klasorlerini (~/.ssh, ~/.aws, AppData\Roaming\gcloud ...) ICERIYORSA (or. Sera ev klasorunde
|
|
139
|
+
* acildi) sandbox-runtime cwd'ye yazma iznini reddeder ve sandbox tamamen kapanirdi (sahip 2026-11-12 ekran goruntusu). Bunun yerine
|
|
140
|
+
* cwd'nin, gizli yol icermeyen ve nokta ile baslamayan alt klasorleri (Desktop, Documents, projeler...) ayri ayri izinlenir:
|
|
141
|
+
* sandbox ACIK kalir, kimlik klasorleri hic izinlenmez.
|
|
142
|
+
*/
|
|
143
|
+
export function writeRoots(cwd: string, home: string = homedir(), list: (d: string) => string[] = listDirs): string[] {
|
|
144
|
+
const secrets = defaultDenyRead(home);
|
|
145
|
+
if (!secrets.some((x) => isAncestor(cwd, x))) return [cwd];
|
|
146
|
+
return list(cwd)
|
|
147
|
+
.filter((n) => !n.startsWith("."))
|
|
148
|
+
.map((n) => join(cwd, n))
|
|
149
|
+
.filter((d) => !secrets.some((x) => isAncestor(d, x) || isAncestor(x, d)));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function listDirs(d: string): string[] {
|
|
153
|
+
try {
|
|
154
|
+
return readdirSync(d, { withFileTypes: true })
|
|
155
|
+
.filter((e) => e.isDirectory())
|
|
156
|
+
.map((e) => e.name);
|
|
157
|
+
} catch {
|
|
158
|
+
return [];
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Sera cwd + config'inden sandbox-runtime config'i üretir (SAF). allowWrite = cwd + geçici klasör + ek yollar;
|
|
164
|
+
* denyWrite = gizli varsayılanlar + config; denyRead = gizli dizinler (Windows hariç: runtime yerleşik) + config; network.allowedDomains = varsayılan
|
|
165
|
+
* paket kayıtları + config/env (genişletir). deniedDomains boş.
|
|
166
|
+
*/
|
|
167
|
+
export function buildRuntimeConfig(
|
|
168
|
+
cwd: string,
|
|
169
|
+
cfg: SandboxConfig,
|
|
170
|
+
opts: { tmp?: string; home?: string; platform?: NodeJS.Platform; listDirs?: (d: string) => string[] } = {},
|
|
171
|
+
): SandboxRuntimeConfig {
|
|
172
|
+
// Windows: sandbox-runtime kimlik bilgisi depolarını (.ssh .aws .gnupg ... ) KENDİ yerleşik dışlamasıyla korur; ayrıca
|
|
173
|
+
// denyRead vermek profil ağacında çok pahalı/takılan ACL yürüyüşü doğurur (ölçüldü). Yalnız kullanıcının kendi eki geçer.
|
|
174
|
+
const baseRead = (opts.platform ?? process.platform) === "win32" ? [] : defaultDenyRead(opts.home);
|
|
175
|
+
return {
|
|
176
|
+
filesystem: {
|
|
177
|
+
allowWrite: uniq([
|
|
178
|
+
...writeRoots(cwd, opts.home, opts.listDirs),
|
|
179
|
+
opts.tmp ?? sandboxTmpDir(),
|
|
180
|
+
...cfg.allowWrite,
|
|
181
|
+
]),
|
|
182
|
+
denyWrite: uniq([...DEFAULT_DENY_WRITE, ...cfg.denyWrite]),
|
|
183
|
+
denyRead: uniq([...baseRead, ...cfg.denyRead]),
|
|
184
|
+
},
|
|
185
|
+
network: { allowedDomains: uniq([...DEFAULT_ALLOWED_DOMAINS, ...cfg.allowedDomains]), deniedDomains: [] },
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const hasGlob = (p: string): boolean => /[*?[\]]/.test(p);
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* denyWrite'tan, diskte OLMAYAN düz (glob'suz) yolları ayıklar. Neden: sandbox-runtime (Windows/bwrap) var olmayan bir
|
|
193
|
+
* denyWrite yolu için proje klasörüne 0 baytlık "taş" dosya/klasör (.env, id_rsa, .git/) YARATIR; kullanıcı projesini
|
|
194
|
+
* kirletmemeli. Glob'lar (.env.*, *.pem) runtime tarafından yalnız VAR OLAN dosyalara genişletilir -> olduğu gibi kalır.
|
|
195
|
+
* Not: sonradan oluşturulan .env korumasız kalır (var olanı ezmeyi/değiştirmeyi engellemek amaçtır).
|
|
196
|
+
*/
|
|
197
|
+
export function existingDenyWrite(cwd: string, entries: readonly string[], exists: (p: string) => boolean): string[] {
|
|
198
|
+
return entries.filter((e) => hasGlob(e) || exists(isAbsolute(e) ? e : join(cwd, e)));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface WrapResult {
|
|
202
|
+
/** Sarmalanmış komut (sandboxed=false ise orijinalin AYNISI). */
|
|
203
|
+
wrapped: string;
|
|
204
|
+
/** true = komut gerçekten sandbox altında; false = sandbox yok/kapalı/desteklenmiyor (komut değişmedi). */
|
|
205
|
+
sandboxed: boolean;
|
|
206
|
+
/** sandboxed=false iken neden (Türkçe: kurulu değil / platform / hata). */
|
|
207
|
+
reason?: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** sandbox-runtime modülünün ihtiyaç duyulan yüzeyi (gevşek). */
|
|
211
|
+
export interface SandboxRuntimeModule {
|
|
212
|
+
SandboxManager: {
|
|
213
|
+
initialize(config: SandboxRuntimeConfig): Promise<unknown>;
|
|
214
|
+
/** Linux/macOS: kabuk dizgesi döner. */
|
|
215
|
+
wrapWithSandbox(command: string): Promise<string>;
|
|
216
|
+
/** Windows: dizgi değil argv döner (shell:false ile çalıştırılmalı). */
|
|
217
|
+
wrapWithSandboxArgv?(command: string, binShell?: string): Promise<{ argv: string[] }>;
|
|
218
|
+
reset?(): Promise<void>;
|
|
219
|
+
};
|
|
220
|
+
VENDORED_SRT_WIN_EXE?: string;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Varsayılan yükleyici: paket kuruluysa döndürür, değilse null (dinamik import — TEMBEL: ilk kabuk komutunda). */
|
|
224
|
+
export async function defaultLoader(): Promise<SandboxRuntimeModule | null> {
|
|
225
|
+
// Değişkenli specifier: paket zorunlu bir bağımlılık değil; kurulu değilse tsc/çalışma zamanı patlamasın.
|
|
226
|
+
const spec = "@anthropic-ai/sandbox-runtime";
|
|
227
|
+
try {
|
|
228
|
+
return (await import(spec)) as unknown as SandboxRuntimeModule;
|
|
229
|
+
} catch {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** POSIX tek tırnak kaçışı (Git Bash / sh). */
|
|
235
|
+
export const shQuote = (s: string): string => `'${s.replaceAll("'", "'\\''")}'`;
|
|
236
|
+
|
|
237
|
+
/** argv'yi bir bash komut satırına çevirir. MSYS argüman/yol dönüşümü kapatılır (--env PATH=... bozulmasın). */
|
|
238
|
+
export function argvToBashLine(argv: readonly string[]): string {
|
|
239
|
+
return `MSYS2_ARG_CONV_EXCL='*' ${argv.map(shQuote).join(" ")}`;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const psQuote = (s: string): string => `'${s.replaceAll("'", "''")}'`;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* wrapWithSandboxArgv(cmd, "powershell") argv'si [...srt-win..., "--", powershell.exe, "-NoProfile", "-Command", cmd] biter.
|
|
246
|
+
* PowerShell 5.1 yerel exe'ye giden argümanlardaki çift tırnağı yutar -> komut -EncodedCommand (UTF-16LE base64) olur; -OutputFormat Text hata akışının CLIXML'e dönüşmesini önler.
|
|
247
|
+
* Dış PowerShell için her argüman tek tırnaklı ("&" çağrısı). Beklenen biçim yoksa/başka argümanda çift tırnak varsa null.
|
|
248
|
+
*/
|
|
249
|
+
export function psEncodeArgv(argv: readonly string[] | undefined, command: string): string | null {
|
|
250
|
+
if (!argv || argv.length < 3) return null;
|
|
251
|
+
const n = argv.length;
|
|
252
|
+
if (argv[n - 2] !== "-Command" || argv[n - 1] !== command) return null;
|
|
253
|
+
const head = argv.slice(0, n - 2);
|
|
254
|
+
if (head.some((a) => a.includes('"'))) return null;
|
|
255
|
+
const enc = Buffer.from(command, "utf16le").toString("base64");
|
|
256
|
+
return `& ${[...head, "-OutputFormat", "Text", "-EncodedCommand", enc].map(psQuote).join(" ")}`;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Fable #15: sandbox ile sarilmis komutu `spawn(..., { shell })` ile calistiran araclar (app_verify) icin kabuk.
|
|
261
|
+
* Windows'ta sarmalama bash satiri uretir (argvToBashLine) → cmd.exe degil Git Bash ile calismali.
|
|
262
|
+
*/
|
|
263
|
+
export function shellForWrapped(command: string, platform: NodeJS.Platform = process.platform): string | true {
|
|
264
|
+
if (platform !== "win32" || !command.startsWith("MSYS2_ARG_CONV_EXCL=")) return true;
|
|
265
|
+
return GIT_BASH_CANDIDATES.find((c) => existsSync(c)) ?? true;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const GIT_BASH_CANDIDATES = [
|
|
269
|
+
"C:/Program Files/Git/bin/bash.exe",
|
|
270
|
+
"C:/Program Files (x86)/Git/bin/bash.exe",
|
|
271
|
+
"C:/Program Files/Git/usr/bin/bash.exe",
|
|
272
|
+
];
|
|
273
|
+
|
|
274
|
+
export interface RunnerOptions {
|
|
275
|
+
cwd: string;
|
|
276
|
+
platform?: NodeJS.Platform;
|
|
277
|
+
loader?: () => Promise<SandboxRuntimeModule | null>;
|
|
278
|
+
/** Windows'ta komutu çalıştıracak bash (Pi'nin bash aracıyla aynı sözdizimi). Verilmezse Git Bash aranır. */
|
|
279
|
+
bashPath?: string;
|
|
280
|
+
exists?: (p: string) => boolean;
|
|
281
|
+
/** initialize() zaman aşımı (ms; vars. 60000). Aşılırsa sandbox yok sayılır + Türkçe neden (donma önleme). */
|
|
282
|
+
initTimeoutMs?: number;
|
|
283
|
+
/** Sandbox'a geçirilecek işaret ortamı kaynağı (vars. process.env; testler için). */
|
|
284
|
+
env?: Record<string, string | undefined>;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Sandbox içindeki süreç, üst sürecin ortamını MİRAS ALMAZ (srt-win yalnız PATH/PATHEXT + proxy ortamını verir). Motorun
|
|
289
|
+
* alt süreçlere bilerek verdiği işaretler (AI_AGENT=sera, SERA_NO_REMOTE_CATALOG) bu yüzden komutun başına eklenir;
|
|
290
|
+
* sırlar (API anahtarları vb.) geçirilmez. Sandbox'sız yolda ortam zaten miras kalır.
|
|
291
|
+
*/
|
|
292
|
+
export const SANDBOX_PASSTHROUGH_ENV = ["AI_AGENT", "SERA_NO_REMOTE_CATALOG"] as const;
|
|
293
|
+
export function withPassthroughEnv(
|
|
294
|
+
command: string,
|
|
295
|
+
shell: "bash" | "powershell",
|
|
296
|
+
env: Record<string, string | undefined> = process.env,
|
|
297
|
+
): string {
|
|
298
|
+
const pairs = SANDBOX_PASSTHROUGH_ENV.flatMap((k) => (env[k] ? [[k, env[k] as string] as const] : []));
|
|
299
|
+
if (pairs.length === 0) return command;
|
|
300
|
+
if (shell === "powershell") return `${pairs.map(([k, v]) => `$env:${k}=${psQuote(v)}`).join("; ")}; ${command}`;
|
|
301
|
+
return `export ${pairs.map(([k, v]) => `${k}=${shQuote(v)}`).join(" ")}; ${command}`;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Bir proje için TEK sandbox oturumu. İlk wrap()'ta modül yüklenir + initialize edilir (tembel; sandbox kullanılmayan
|
|
306
|
+
* oturumda hiç yüklenmez), sonra her komut yalnız wrapWithSandbox çağrısı kadar maliyetlidir. Başlatma başarısızsa
|
|
307
|
+
* sonuç ÖNBELLEĞE alınır (her komutta yeniden denenip yavaşlamasın): sonraki çağrılar aynı Türkçe nedenle sandboxed:false döner.
|
|
308
|
+
*/
|
|
309
|
+
export class SandboxRunner {
|
|
310
|
+
private mod: SandboxRuntimeModule | null = null;
|
|
311
|
+
private failed: string | undefined;
|
|
312
|
+
private starting: Promise<void> | undefined;
|
|
313
|
+
private readonly platform: NodeJS.Platform;
|
|
314
|
+
private readonly loader: () => Promise<SandboxRuntimeModule | null>;
|
|
315
|
+
private readonly rt: SandboxRuntimeConfig;
|
|
316
|
+
private readonly exists: (p: string) => boolean;
|
|
317
|
+
private readonly bash?: string;
|
|
318
|
+
private readonly initTimeoutMs: number;
|
|
319
|
+
private readonly env: Record<string, string | undefined>;
|
|
320
|
+
|
|
321
|
+
constructor(cfg: SandboxConfig, opts: RunnerOptions) {
|
|
322
|
+
this.platform = opts.platform ?? process.platform;
|
|
323
|
+
this.loader = opts.loader ?? defaultLoader;
|
|
324
|
+
this.exists = opts.exists ?? ((p) => existsSync(p));
|
|
325
|
+
const rt = buildRuntimeConfig(opts.cwd, cfg, { platform: this.platform });
|
|
326
|
+
rt.filesystem.denyWrite = existingDenyWrite(opts.cwd, rt.filesystem.denyWrite, this.exists);
|
|
327
|
+
this.rt = rt;
|
|
328
|
+
this.bash = opts.bashPath;
|
|
329
|
+
this.initTimeoutMs = opts.initTimeoutMs ?? 60_000;
|
|
330
|
+
this.env = opts.env ?? process.env;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** Modül yüklemesi/başlatması denendi mi (tembellik testi). */
|
|
334
|
+
get started(): boolean {
|
|
335
|
+
return this.starting !== undefined;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/** Başlatma başarısızlık nedeni (varsa). */
|
|
339
|
+
get failure(): string | undefined {
|
|
340
|
+
return this.failed;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
private winBash(): string | undefined {
|
|
344
|
+
return this.bash ?? GIT_BASH_CANDIDATES.find((c) => this.exists(c));
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
private async start(): Promise<void> {
|
|
348
|
+
const mod = await this.loader();
|
|
349
|
+
if (!mod?.SandboxManager) {
|
|
350
|
+
this.failed = "sandbox-runtime kurulu değil";
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const rt: SandboxRuntimeConfig = { ...this.rt };
|
|
354
|
+
if (this.platform === "win32") {
|
|
355
|
+
if (!mod.VENDORED_SRT_WIN_EXE || !mod.SandboxManager.wrapWithSandboxArgv) {
|
|
356
|
+
this.failed = "kurulu sandbox-runtime sürümü Windows'u desteklemiyor (>=0.0.81 gerekir)";
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
rt.windows = { srtWin: { path: mod.VENDORED_SRT_WIN_EXE } };
|
|
360
|
+
for (const p of this.rt.filesystem.allowWrite) {
|
|
361
|
+
try {
|
|
362
|
+
mkdirSync(p, { recursive: true }); // izinli yazma kökleri var olmalı (Windows ACL verilebilsin)
|
|
363
|
+
} catch {
|
|
364
|
+
/* oluşturulamıyorsa initialize net hata verir */
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
369
|
+
try {
|
|
370
|
+
await Promise.race([
|
|
371
|
+
mod.SandboxManager.initialize(rt),
|
|
372
|
+
new Promise<never>((_, rej) => {
|
|
373
|
+
timer = setTimeout(
|
|
374
|
+
() => rej(new Error(`başlatma ${Math.round(this.initTimeoutMs / 1000)} sn içinde bitmedi`)),
|
|
375
|
+
this.initTimeoutMs,
|
|
376
|
+
);
|
|
377
|
+
timer.unref?.();
|
|
378
|
+
}),
|
|
379
|
+
]);
|
|
380
|
+
this.mod = mod;
|
|
381
|
+
} catch (e) {
|
|
382
|
+
this.failed = e instanceof Error ? e.message : String(e);
|
|
383
|
+
} finally {
|
|
384
|
+
if (timer) clearTimeout(timer);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** Komutu sandbox altında çalışacak biçime sarmalar. Hata/yok → sandboxed:false + neden (komut DEĞİŞMEZ). */
|
|
389
|
+
async wrap(original: string, shell: "bash" | "powershell" = "bash"): Promise<WrapResult> {
|
|
390
|
+
this.starting ??= this.start();
|
|
391
|
+
await this.starting;
|
|
392
|
+
if (!this.mod) return { wrapped: original, sandboxed: false, reason: this.failed ?? "sandbox başlatılamadı" };
|
|
393
|
+
const command = withPassthroughEnv(original, shell, this.env);
|
|
394
|
+
try {
|
|
395
|
+
if (this.platform === "win32" && shell === "powershell") {
|
|
396
|
+
const w = await this.mod.SandboxManager.wrapWithSandboxArgv?.(command, "powershell");
|
|
397
|
+
const enc = psEncodeArgv(w?.argv, command);
|
|
398
|
+
return enc
|
|
399
|
+
? { wrapped: enc, sandboxed: true }
|
|
400
|
+
: { wrapped: original, sandboxed: false, reason: "PowerShell komutu sarmalanamadı" };
|
|
401
|
+
}
|
|
402
|
+
if (this.platform === "win32") {
|
|
403
|
+
if (!this.winBash())
|
|
404
|
+
return {
|
|
405
|
+
wrapped: original,
|
|
406
|
+
sandboxed: false,
|
|
407
|
+
reason: "Git Bash bulunamadı (Windows sandbox'ı bash komutlarını sarmalar)",
|
|
408
|
+
};
|
|
409
|
+
const w = await this.mod.SandboxManager.wrapWithSandboxArgv?.(command, this.winBash());
|
|
410
|
+
return w?.argv?.length
|
|
411
|
+
? { wrapped: argvToBashLine(w.argv), sandboxed: true }
|
|
412
|
+
: { wrapped: original, sandboxed: false, reason: "sandbox argv üretmedi" };
|
|
413
|
+
}
|
|
414
|
+
const wrapped = await this.mod.SandboxManager.wrapWithSandbox(command);
|
|
415
|
+
return { wrapped: wrapped || original, sandboxed: !!wrapped };
|
|
416
|
+
} catch (e) {
|
|
417
|
+
return { wrapped: original, sandboxed: false, reason: e instanceof Error ? e.message : String(e) };
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** Oturum kapanırken proxy/ACL kaynaklarını bırakır (başlamadıysa hiçbir şey yapmaz). */
|
|
422
|
+
async shutdown(): Promise<void> {
|
|
423
|
+
try {
|
|
424
|
+
await this.mod?.SandboxManager.reset?.();
|
|
425
|
+
} catch {
|
|
426
|
+
/* kapanışta hata önemsiz */
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/** Bayrak: komutun başındaki bu önek, "bu komutu sandbox DIŞINDA çalıştır" isteğidir (kullanıcı onayı şart). */
|
|
432
|
+
export const UNSANDBOXED_MARKER = "SERA_UNSANDBOXED=1";
|
|
433
|
+
|
|
434
|
+
/** Önek varsa {unsandboxed:true, command: önek atılmış} döner (komutun başında; boşluk toleranslı). */
|
|
435
|
+
export function parseUnsandboxed(command: string): { unsandboxed: boolean; command: string } {
|
|
436
|
+
const m = /^\s*SERA_UNSANDBOXED=1(?:\s+|$)/.exec(command);
|
|
437
|
+
return m ? { unsandboxed: true, command: command.slice(m[0].length) } : { unsandboxed: false, command };
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/** Sandbox engelini gösteren çıktı kalıpları (araç sonucuna "sandbox dışı çalıştır" ipucu eklemek için). */
|
|
441
|
+
const DENIAL =
|
|
442
|
+
/permission denied|operation not permitted|EACCES|EPERM|access is denied|403 forbidden|read-only file system|sistem belirtilen yolu|erişim engellendi|connection (?:refused|blocked)|request was cancelled|ENOTFOUND/i;
|
|
443
|
+
export const looksSandboxDenied = (text: string): boolean => DENIAL.test(text);
|
|
444
|
+
|
|
445
|
+
export const SANDBOX_HINT = `\n[Sera sandbox] Bu komut sandbox içinde çalıştı; hata sandbox kısıtından (yazma yalnız proje+geçici klasör, ağ yalnız izinli alan adları, gizli dizinler okunamaz) kaynaklanıyor olabilir. Komutun gerçekten sandbox dışında çalışması gerekiyorsa başına \`${UNSANDBOXED_MARKER} \` ekleyerek yeniden dene; kullanıcıdan onay istenir.`;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Sunucuya üretim isteği atan araçlar (image, video, video-edit) için ortak hata metni.
|
|
2
|
+
// Web ve TUI ile aynı üç bilgi: ne oldu / hakkın gitti mi / ne yapmalısın. Limit dolunca YÖNLENDİRME yok
|
|
3
|
+
// (başka pakete/modele geç önerisi yasak): yalnız yenilenme anı. Ham İngilizce sağlayıcı metni ve motor adı sızmaz.
|
|
4
|
+
|
|
5
|
+
export interface ServerErrorInput {
|
|
6
|
+
/** "Görsel üretimi" gibi kullanıcıya görünen iş adı. */
|
|
7
|
+
noun: string;
|
|
8
|
+
status: number;
|
|
9
|
+
/** Yanıt gövdesi (JSON ise nesne, değilse undefined). */
|
|
10
|
+
body?: unknown;
|
|
11
|
+
/** Hak sunucuda 502'de iade ediliyor (image/video başlatma/editor render). false ise 502 "gitmedi" der. */
|
|
12
|
+
refundsOn502?: boolean;
|
|
13
|
+
loginMsg?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const TR_CHARS = /[çğıöşüÇĞİÖŞÜ]/;
|
|
17
|
+
const TR_KEYS = /yenilen|hakk[ıi]n|iade/i;
|
|
18
|
+
|
|
19
|
+
/** Sunucunun Türkçe mesajı (detail / error / message). İngilizce/kod değerleri ("upstream_error") elenir. */
|
|
20
|
+
export function serverTurkishMessage(body: unknown): string | undefined {
|
|
21
|
+
if (!body || typeof body !== "object") return undefined;
|
|
22
|
+
const b = body as Record<string, unknown>;
|
|
23
|
+
for (const k of ["detail", "error", "message"]) {
|
|
24
|
+
const v = b[k];
|
|
25
|
+
if (typeof v === "string") {
|
|
26
|
+
const s = v.trim();
|
|
27
|
+
if (s && s.length <= 400 && (TR_KEYS.test(s) || TR_CHARS.test(s))) return s;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function resetOf(body: unknown): string | undefined {
|
|
34
|
+
if (!body || typeof body !== "object") return undefined;
|
|
35
|
+
const r = (body as Record<string, unknown>).resetLabel;
|
|
36
|
+
return typeof r === "string" && r.trim() ? r.trim() : undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Sunucu yanıtından kullanıcıya gösterilecek tek metin. */
|
|
40
|
+
export function formatServerError(i: ServerErrorInput): string {
|
|
41
|
+
const { noun, status, body } = i;
|
|
42
|
+
const msg = serverTurkishMessage(body);
|
|
43
|
+
const reset = resetOf(body);
|
|
44
|
+
if (status === 401) return `${i.loginMsg ?? `${noun} için önce \`sera login\` ile giriş yapmalısın.`}`;
|
|
45
|
+
if (msg) {
|
|
46
|
+
// 429 + resetLabel: mesajda yenilenme anı yoksa ekle.
|
|
47
|
+
if (status === 429 && reset && !msg.includes(reset)) return `${msg} Yenilenme: ${reset}.`;
|
|
48
|
+
// Sunucu hak durumunu yazmadıysa (ör. Türkçe ama yalnız "Ne istediğini yaz.") durumu ekle.
|
|
49
|
+
if (/hakk[ıi]n/i.test(msg)) return msg;
|
|
50
|
+
const not = hakNotu(status, i.refundsOn502);
|
|
51
|
+
return not ? `${msg} ${not}` : msg;
|
|
52
|
+
}
|
|
53
|
+
if (status === 429) {
|
|
54
|
+
return reset
|
|
55
|
+
? `Hakkın doldu. Yenilenme: ${reset}.`
|
|
56
|
+
: `${noun} şu an sınırda; bu istek işlenmedi. Biraz sonra tekrar dene.`;
|
|
57
|
+
}
|
|
58
|
+
if (status === 402) return `Bu paket ${noun.toLowerCase()} hakkı vermiyor.`;
|
|
59
|
+
if (status === 403) return `${noun} için yetkin yok. Giriş yaptığın hesabı kontrol et.`;
|
|
60
|
+
if (status === 400) return `İstek geçersiz. İsteğini değiştirip tekrar dene.`;
|
|
61
|
+
if (status === 502 && i.refundsOn502 !== false) {
|
|
62
|
+
return `${noun} başarısız oldu (sunucu hatası). Hakkın iade edildi. Biraz sonra tekrar dene.`;
|
|
63
|
+
}
|
|
64
|
+
if (status >= 500) {
|
|
65
|
+
return `${noun} başarısız oldu (sunucu hatası). Biraz sonra tekrar dene.`;
|
|
66
|
+
}
|
|
67
|
+
return `İstek reddedildi (HTTP ${status}). Biraz sonra tekrar dene.`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function hakNotu(status: number, refundsOn502?: boolean): string {
|
|
71
|
+
if (status === 502 && refundsOn502 !== false) return "Hakkın iade edildi.";
|
|
72
|
+
return "";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Ağ hatası (istek sunucuya ulaşmadı). Ham hata metni sızmaz. */
|
|
76
|
+
export function networkErrorText(noun: string): string {
|
|
77
|
+
return `${noun} sunucusuna ulaşılamadı. Bağlantını kontrol edip tekrar dene.`;
|
|
78
|
+
}
|