sera-code 0.0.0-stage → 0.1.2
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 +33 -0
- package/README.md +27 -2
- package/THIRD_PARTY_NOTICES.md +68 -0
- package/bin/sera.mjs +145 -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-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-AZC5WTED.js +1222 -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-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-LOMPDCMP.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-Z2V3PTLI.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 +377 -0
- package/lib/provider.js +71 -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 +2410 -0
- package/sera-core/src/fs-tools.ts +448 -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/model-list.ts +108 -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 +476 -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 +121 -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,551 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Uygulama Ustasi dogrulayici: `app_verify` aracinin cekirdegi. Yapilan uygulamayi GERCEKTEN calistirip kanit uretir.
|
|
3
|
+
* - HTML/URL: sistemdeki Edge/Chrome basiz (headless) acilir, CDP (DevTools Protocol) ile konsol hatasi, yakalanmamis istisna,
|
|
4
|
+
* basarisiz ag istegi, bos sayfa, yatay tasma toplanir; masaustu + 390px mobil ekran goruntusu dosyaya kaydedilir.
|
|
5
|
+
* Bagimlilik YOK (playwright indirilmez): Node'un yerlesik WebSocket'i + Edge/Chrome'un --remote-debugging-port'u.
|
|
6
|
+
* - Komut: zaman asimli calistirilir, cikis kodu + son satirlar.
|
|
7
|
+
* - Sunucu: arka planda baslatilir, port hazir olunca HTTP GET + tarayici kontrolu, sonra agac olarak kapatilir.
|
|
8
|
+
* Durust sinir: tarayici bulunamazsa sonuc "ATLANDI" (GECTI DEGIL) — sahte basari iddiasi yok.
|
|
9
|
+
*/
|
|
10
|
+
import { type ChildProcess, spawn, spawnSync } from "node:child_process";
|
|
11
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
12
|
+
import net from "node:net";
|
|
13
|
+
import { tmpdir } from "node:os";
|
|
14
|
+
import { join, resolve } from "node:path";
|
|
15
|
+
import { pathToFileURL } from "node:url";
|
|
16
|
+
import { shellForWrapped } from "./sandbox.ts";
|
|
17
|
+
|
|
18
|
+
export type VerifyStatus = "GEÇTİ" | "KALDI" | "ATLANDI";
|
|
19
|
+
export interface VerifyResult {
|
|
20
|
+
status: VerifyStatus;
|
|
21
|
+
text: string;
|
|
22
|
+
errors: string[];
|
|
23
|
+
screenshots: string[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
|
27
|
+
|
|
28
|
+
/** Sistemdeki Chromium tabanli tarayici (Edge/Chrome). SERA_BROWSER ile elle verilebilir. */
|
|
29
|
+
export function findBrowser(env: Record<string, string | undefined> = process.env): string | undefined {
|
|
30
|
+
const c: string[] = [];
|
|
31
|
+
if (env.SERA_BROWSER) c.push(env.SERA_BROWSER);
|
|
32
|
+
if (process.platform === "win32") {
|
|
33
|
+
const roots = [env["ProgramFiles(x86)"], env.ProgramFiles, env.LOCALAPPDATA].filter(Boolean) as string[];
|
|
34
|
+
for (const r of roots) {
|
|
35
|
+
c.push(join(r, "Microsoft/Edge/Application/msedge.exe"));
|
|
36
|
+
c.push(join(r, "Google/Chrome/Application/chrome.exe"));
|
|
37
|
+
}
|
|
38
|
+
} else if (process.platform === "darwin") {
|
|
39
|
+
c.push("/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge");
|
|
40
|
+
c.push("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome");
|
|
41
|
+
} else {
|
|
42
|
+
for (const n of ["microsoft-edge", "google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]) {
|
|
43
|
+
for (const d of (env.PATH ?? "").split(":")) if (d) c.push(join(d, n));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return c.find((p) => {
|
|
47
|
+
try {
|
|
48
|
+
return statSync(p).isFile();
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function killTree(child: ChildProcess): void {
|
|
56
|
+
if (!child.pid) return;
|
|
57
|
+
try {
|
|
58
|
+
if (process.platform === "win32")
|
|
59
|
+
spawnSync("taskkill", ["/PID", String(child.pid), "/T", "/F"], { windowsHide: true });
|
|
60
|
+
else {
|
|
61
|
+
try {
|
|
62
|
+
process.kill(-child.pid, "SIGKILL");
|
|
63
|
+
} catch {
|
|
64
|
+
child.kill("SIGKILL");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
} catch {
|
|
68
|
+
/* zaten kapali */
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ---------- minimal CDP istemcisi ----------
|
|
73
|
+
type CdpEvent = { method: string; params: any };
|
|
74
|
+
class Cdp {
|
|
75
|
+
private id = 0;
|
|
76
|
+
private pending = new Map<number, { res: (v: any) => void; rej: (e: Error) => void }>();
|
|
77
|
+
private handlers: ((e: CdpEvent) => void)[] = [];
|
|
78
|
+
private ws: WebSocket;
|
|
79
|
+
private constructor(ws: WebSocket) {
|
|
80
|
+
this.ws = ws;
|
|
81
|
+
ws.addEventListener("message", (m: MessageEvent) => {
|
|
82
|
+
const d = JSON.parse(String(m.data));
|
|
83
|
+
if (d.id !== undefined) {
|
|
84
|
+
const p = this.pending.get(d.id);
|
|
85
|
+
if (!p) return;
|
|
86
|
+
this.pending.delete(d.id);
|
|
87
|
+
if (d.error) p.rej(new Error(`${d.error.message}`));
|
|
88
|
+
else p.res(d.result);
|
|
89
|
+
} else if (d.method) for (const h of this.handlers) h(d as CdpEvent);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
static connect(url: string): Promise<Cdp> {
|
|
93
|
+
return new Promise((res, rej) => {
|
|
94
|
+
const ws = new WebSocket(url);
|
|
95
|
+
ws.addEventListener("open", () => res(new Cdp(ws)));
|
|
96
|
+
ws.addEventListener("error", () => rej(new Error("DevTools baglantisi kurulamadi")));
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
send(method: string, params: Record<string, unknown> = {}): Promise<any> {
|
|
100
|
+
const id = ++this.id;
|
|
101
|
+
return new Promise((res, rej) => {
|
|
102
|
+
this.pending.set(id, { res, rej });
|
|
103
|
+
this.ws.send(JSON.stringify({ id, method, params }));
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
on(h: (e: CdpEvent) => void): void {
|
|
107
|
+
this.handlers.push(h);
|
|
108
|
+
}
|
|
109
|
+
close(): void {
|
|
110
|
+
try {
|
|
111
|
+
this.ws.close();
|
|
112
|
+
} catch {
|
|
113
|
+
/* kapali */
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
interface Launched {
|
|
119
|
+
cdp: Cdp;
|
|
120
|
+
child: ChildProcess;
|
|
121
|
+
dir: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function launch(exe: string, signal?: AbortSignal): Promise<Launched> {
|
|
125
|
+
const dir = mkdtempSync(join(tmpdir(), "sera-br-"));
|
|
126
|
+
const args = [
|
|
127
|
+
"--headless=new",
|
|
128
|
+
"--remote-debugging-port=0",
|
|
129
|
+
`--user-data-dir=${dir}`,
|
|
130
|
+
"--no-first-run",
|
|
131
|
+
"--no-default-browser-check",
|
|
132
|
+
"--disable-extensions",
|
|
133
|
+
"--disable-background-networking",
|
|
134
|
+
"--mute-audio",
|
|
135
|
+
"--hide-scrollbars",
|
|
136
|
+
"about:blank",
|
|
137
|
+
];
|
|
138
|
+
if (process.platform === "linux" && process.getuid?.() === 0) args.unshift("--no-sandbox");
|
|
139
|
+
const child = spawn(exe, args, { stdio: "ignore", windowsHide: true, detached: process.platform !== "win32" });
|
|
140
|
+
child.on("error", () => {});
|
|
141
|
+
try {
|
|
142
|
+
let port = 0;
|
|
143
|
+
const portFile = join(dir, "DevToolsActivePort");
|
|
144
|
+
for (let i = 0; i < 150 && !port; i++) {
|
|
145
|
+
if (signal?.aborted) throw new Error("iptal edildi");
|
|
146
|
+
if (existsSync(portFile)) port = Number(readFileSync(portFile, "utf8").split("\n")[0]) || 0;
|
|
147
|
+
if (!port) await sleep(100);
|
|
148
|
+
}
|
|
149
|
+
if (!port) throw new Error("tarayici 15 sn icinde hazir olmadi");
|
|
150
|
+
const list = (await (await fetch(`http://127.0.0.1:${port}/json/list`)).json()) as any[];
|
|
151
|
+
const page = list.find((t) => t.type === "page");
|
|
152
|
+
if (!page?.webSocketDebuggerUrl) throw new Error("tarayici sayfasi bulunamadi");
|
|
153
|
+
return { cdp: await Cdp.connect(page.webSocketDebuggerUrl), child, dir };
|
|
154
|
+
} catch (e) {
|
|
155
|
+
killTree(child);
|
|
156
|
+
cleanDir(dir);
|
|
157
|
+
throw e;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function cleanDir(dir: string): void {
|
|
162
|
+
for (let i = 0; i < 5; i++) {
|
|
163
|
+
try {
|
|
164
|
+
rmSync(dir, { recursive: true, force: true });
|
|
165
|
+
return;
|
|
166
|
+
} catch {
|
|
167
|
+
spawnSync(process.execPath, ["-e", "setTimeout(()=>{},300)"]); // dosya kilidi (Windows): kisa bekle
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const KEYS: Record<string, number> = {
|
|
173
|
+
ArrowLeft: 37,
|
|
174
|
+
ArrowUp: 38,
|
|
175
|
+
ArrowRight: 39,
|
|
176
|
+
ArrowDown: 40,
|
|
177
|
+
Enter: 13,
|
|
178
|
+
Escape: 27,
|
|
179
|
+
Space: 32,
|
|
180
|
+
" ": 32,
|
|
181
|
+
Tab: 9,
|
|
182
|
+
Backspace: 8,
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/** Etkilesim adimi: "press:ArrowRight" | "click:#btn" | "type:metin" | "wait:500". */
|
|
186
|
+
async function runAction(cdp: Cdp, a: string): Promise<string | undefined> {
|
|
187
|
+
const i = a.indexOf(":");
|
|
188
|
+
const kind = i < 0 ? a : a.slice(0, i);
|
|
189
|
+
const arg = i < 0 ? "" : a.slice(i + 1);
|
|
190
|
+
if (kind === "wait") {
|
|
191
|
+
await sleep(Math.min(5000, Math.max(0, Number(arg) || 300)));
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
if (kind === "press") {
|
|
195
|
+
const name = arg === "Space" ? " " : arg;
|
|
196
|
+
const vk = KEYS[arg] ?? KEYS[name] ?? (name.length === 1 ? name.toUpperCase().charCodeAt(0) : 0);
|
|
197
|
+
const text = name.length === 1 ? name : arg === "Enter" ? "\r" : undefined;
|
|
198
|
+
const base = {
|
|
199
|
+
key: name,
|
|
200
|
+
code: name.length === 1 ? (/[a-z]/i.test(name) ? `Key${name.toUpperCase()}` : name) : arg,
|
|
201
|
+
windowsVirtualKeyCode: vk,
|
|
202
|
+
nativeVirtualKeyCode: vk,
|
|
203
|
+
};
|
|
204
|
+
await cdp.send("Input.dispatchKeyEvent", {
|
|
205
|
+
type: text ? "keyDown" : "rawKeyDown",
|
|
206
|
+
...base,
|
|
207
|
+
...(text ? { text } : {}),
|
|
208
|
+
});
|
|
209
|
+
await cdp.send("Input.dispatchKeyEvent", { type: "keyUp", ...base });
|
|
210
|
+
await sleep(150);
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
if (kind === "type") {
|
|
214
|
+
await cdp.send("Input.insertText", { text: arg });
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
if (kind === "click") {
|
|
218
|
+
const r = await cdp.send("Runtime.evaluate", {
|
|
219
|
+
expression: `(()=>{const e=document.querySelector(${JSON.stringify(arg)});if(!e)return null;e.scrollIntoView({block:"center"});const b=e.getBoundingClientRect();return {x:b.left+b.width/2,y:b.top+b.height/2}})()`,
|
|
220
|
+
returnByValue: true,
|
|
221
|
+
});
|
|
222
|
+
const pt = r.result?.value as { x: number; y: number } | null;
|
|
223
|
+
if (!pt) return `etkilesim basarisiz: '${arg}' ogesi bulunamadi`;
|
|
224
|
+
for (const type of ["mouseMoved", "mousePressed", "mouseReleased"])
|
|
225
|
+
await cdp.send("Input.dispatchMouseEvent", {
|
|
226
|
+
type,
|
|
227
|
+
x: pt.x,
|
|
228
|
+
y: pt.y,
|
|
229
|
+
button: "left",
|
|
230
|
+
clickCount: 1,
|
|
231
|
+
buttons: type === "mousePressed" ? 1 : 0,
|
|
232
|
+
});
|
|
233
|
+
await sleep(250);
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
return `bilinmeyen etkilesim adimi: '${a}' (press:Tus | click:secici | type:metin | wait:ms)`;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface VerifyHtmlOpts {
|
|
240
|
+
url: string;
|
|
241
|
+
label: string;
|
|
242
|
+
actions?: string[];
|
|
243
|
+
outDir?: string;
|
|
244
|
+
browser?: string;
|
|
245
|
+
signal?: AbortSignal;
|
|
246
|
+
timeoutMs?: number;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export async function verifyInBrowser(o: VerifyHtmlOpts): Promise<VerifyResult> {
|
|
250
|
+
const exe = o.browser ?? findBrowser();
|
|
251
|
+
if (!exe)
|
|
252
|
+
return {
|
|
253
|
+
status: "ATLANDI",
|
|
254
|
+
text: `ATLANDI — ${o.label}: bilgisayarda Edge/Chrome bulunamadi, tarayici dogrulamasi YAPILAMADI (basarili sayilmaz; kodu elle gozden gecir).`,
|
|
255
|
+
errors: [],
|
|
256
|
+
screenshots: [],
|
|
257
|
+
};
|
|
258
|
+
const outDir = o.outDir ?? join(tmpdir(), "sera-verify", String(Date.now()));
|
|
259
|
+
mkdirSync(outDir, { recursive: true });
|
|
260
|
+
const errors: string[] = [];
|
|
261
|
+
const warns: string[] = [];
|
|
262
|
+
const shots: string[] = [];
|
|
263
|
+
const seen = new Set<string>();
|
|
264
|
+
const addErr = (s: string) => {
|
|
265
|
+
const k = s.slice(0, 300);
|
|
266
|
+
if (seen.has(k) || errors.length >= 12) return;
|
|
267
|
+
seen.add(k);
|
|
268
|
+
errors.push(k);
|
|
269
|
+
};
|
|
270
|
+
let L: Launched | undefined;
|
|
271
|
+
const run = async (): Promise<void> => {
|
|
272
|
+
L = await launch(exe, o.signal);
|
|
273
|
+
const { cdp } = L;
|
|
274
|
+
const urlOf = (u?: string) => (u ? ` (${u.replace(/^file:\/\/\/?/, "")})` : "");
|
|
275
|
+
cdp.on((e) => {
|
|
276
|
+
const p = e.params;
|
|
277
|
+
if (e.method === "Runtime.exceptionThrown") {
|
|
278
|
+
const d = p.exceptionDetails;
|
|
279
|
+
addErr(
|
|
280
|
+
`Yakalanmamış istisna: ${d.exception?.description?.split("\n")[0] ?? d.text}${d.lineNumber !== undefined ? ` [satır ${d.lineNumber + 1}]` : ""}`,
|
|
281
|
+
);
|
|
282
|
+
} else if (e.method === "Runtime.consoleAPICalled" && p.type === "error") {
|
|
283
|
+
addErr(`Konsol hatası: ${(p.args as any[]).map((a) => a.value ?? a.description ?? a.type).join(" ")}`);
|
|
284
|
+
} else if (e.method === "Log.entryAdded" && p.entry.level === "error") {
|
|
285
|
+
if (!/^Failed to load resource/i.test(p.entry.text))
|
|
286
|
+
addErr(`Tarayıcı günlüğü: ${p.entry.text}${urlOf(p.entry.url)}`);
|
|
287
|
+
} else if (e.method === "Network.loadingFailed" && !p.canceled) {
|
|
288
|
+
addErr(`Ağ isteği başarısız: ${p.errorText}${p.requestId ? "" : ""}`);
|
|
289
|
+
} else if (
|
|
290
|
+
e.method === "Network.responseReceived" &&
|
|
291
|
+
p.response.status >= 400 &&
|
|
292
|
+
!/favicon\.ico/.test(p.response.url)
|
|
293
|
+
) {
|
|
294
|
+
addErr(`Ağ isteği HTTP ${p.response.status}: ${p.response.url.replace(/^file:\/\/\/?/, "")}`);
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
for (const m of ["Page.enable", "Runtime.enable", "Log.enable", "Network.enable"]) await cdp.send(m);
|
|
298
|
+
const load = (): Promise<void> =>
|
|
299
|
+
new Promise((res) => {
|
|
300
|
+
const t = setTimeout(res, 15_000);
|
|
301
|
+
cdp.on((e) => {
|
|
302
|
+
if (e.method === "Page.loadEventFired") {
|
|
303
|
+
clearTimeout(t);
|
|
304
|
+
res();
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
const snap = async (name: string) => {
|
|
309
|
+
const r = await cdp.send("Page.captureScreenshot", { format: "png" });
|
|
310
|
+
const f = join(outDir, name);
|
|
311
|
+
writeFileSync(f, Buffer.from(r.data, "base64"));
|
|
312
|
+
shots.push(f);
|
|
313
|
+
};
|
|
314
|
+
const probe = async () =>
|
|
315
|
+
(
|
|
316
|
+
await cdp.send("Runtime.evaluate", {
|
|
317
|
+
expression: `({text:(document.body&&document.body.innerText||"").trim().length,vis:document.querySelectorAll("canvas,svg,img,video,input,button,iframe").length,sw:document.documentElement.scrollWidth,iw:window.innerWidth})`,
|
|
318
|
+
returnByValue: true,
|
|
319
|
+
})
|
|
320
|
+
).result?.value as { text: number; vis: number; sw: number; iw: number } | undefined;
|
|
321
|
+
|
|
322
|
+
await cdp.send("Emulation.setDeviceMetricsOverride", {
|
|
323
|
+
width: 1280,
|
|
324
|
+
height: 800,
|
|
325
|
+
deviceScaleFactor: 1,
|
|
326
|
+
mobile: false,
|
|
327
|
+
});
|
|
328
|
+
const l1 = load();
|
|
329
|
+
const nav = await cdp.send("Page.navigate", { url: o.url });
|
|
330
|
+
if (nav.errorText) addErr(`Sayfa açılamadı: ${nav.errorText}`);
|
|
331
|
+
await l1;
|
|
332
|
+
await sleep(800);
|
|
333
|
+
const p1 = await probe();
|
|
334
|
+
if (p1 && p1.text === 0 && p1.vis === 0)
|
|
335
|
+
addErr("Sayfa boş görünüyor (görünür metin, canvas, görsel ya da düğme yok).");
|
|
336
|
+
await snap("masaustu.png");
|
|
337
|
+
if (o.actions?.length) {
|
|
338
|
+
for (const a of o.actions) {
|
|
339
|
+
const err = await runAction(cdp, a);
|
|
340
|
+
if (err) addErr(err);
|
|
341
|
+
}
|
|
342
|
+
await sleep(500);
|
|
343
|
+
await snap("etkilesim.png");
|
|
344
|
+
}
|
|
345
|
+
await cdp.send("Emulation.setDeviceMetricsOverride", {
|
|
346
|
+
width: 390,
|
|
347
|
+
height: 844,
|
|
348
|
+
deviceScaleFactor: 2,
|
|
349
|
+
mobile: true,
|
|
350
|
+
});
|
|
351
|
+
const l2 = load();
|
|
352
|
+
await cdp.send("Page.reload");
|
|
353
|
+
await l2;
|
|
354
|
+
await sleep(800);
|
|
355
|
+
const p2 = await probe();
|
|
356
|
+
if (p2 && p2.sw > p2.iw + 2) warns.push(`UYARI: mobilde (390px) yatay taşma var (içerik ${p2.sw}px).`);
|
|
357
|
+
await snap("mobil.png");
|
|
358
|
+
cdp.close();
|
|
359
|
+
};
|
|
360
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
361
|
+
try {
|
|
362
|
+
await Promise.race([
|
|
363
|
+
run(),
|
|
364
|
+
new Promise<never>((_, rej) => {
|
|
365
|
+
timer = setTimeout(
|
|
366
|
+
() => rej(new Error("tarayici dogrulamasi zaman asimina ugradi")),
|
|
367
|
+
o.timeoutMs ?? 45_000,
|
|
368
|
+
);
|
|
369
|
+
}),
|
|
370
|
+
]);
|
|
371
|
+
} catch (e) {
|
|
372
|
+
addErr(`Doğrulama çalıştırılamadı: ${e instanceof Error ? e.message : String(e)}`);
|
|
373
|
+
} finally {
|
|
374
|
+
if (timer) clearTimeout(timer);
|
|
375
|
+
if (L) {
|
|
376
|
+
L.cdp.close();
|
|
377
|
+
killTree(L.child);
|
|
378
|
+
cleanDir(L.dir);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
const status: VerifyStatus = errors.length ? "KALDI" : "GEÇTİ";
|
|
382
|
+
const lines = [`${status} — ${o.label}`];
|
|
383
|
+
lines.push(
|
|
384
|
+
errors.length
|
|
385
|
+
? `Hatalar (${errors.length}):`
|
|
386
|
+
: "Konsol hatası, yakalanmamış istisna, başarısız ağ isteği yok; sayfa dolu.",
|
|
387
|
+
);
|
|
388
|
+
for (const e of errors) lines.push(`- ${e}`);
|
|
389
|
+
for (const w of warns) lines.push(`- ${w}`);
|
|
390
|
+
if (shots.length) lines.push(`Ekran görüntüleri: ${shots.join(" | ")}`);
|
|
391
|
+
if (status === "KALDI") lines.push("Hataları düzelt ve app_verify'ı tekrar çalıştır.");
|
|
392
|
+
return { status, text: lines.join("\n"), errors, screenshots: shots };
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// ---------- hedef cozumleme ----------
|
|
396
|
+
export type Target =
|
|
397
|
+
| { kind: "url"; url: string; label: string }
|
|
398
|
+
| { kind: "file"; file: string; url: string; label: string };
|
|
399
|
+
|
|
400
|
+
export function resolveTarget(raw: string, cwd: string): Target {
|
|
401
|
+
const t = raw.trim();
|
|
402
|
+
if (/^https?:\/\//i.test(t)) {
|
|
403
|
+
const u = new URL(t);
|
|
404
|
+
if (!/^(localhost|127\.0\.0\.1|\[::1\])$/.test(u.hostname))
|
|
405
|
+
throw new Error(
|
|
406
|
+
"app_verify yalnızca yerel adresleri (localhost / 127.0.0.1) açar; dış siteler için web_fetch kullan.",
|
|
407
|
+
);
|
|
408
|
+
return { kind: "url", url: u.toString(), label: u.toString() };
|
|
409
|
+
}
|
|
410
|
+
let f = resolve(cwd, t);
|
|
411
|
+
if (existsSync(f) && statSync(f).isDirectory()) f = join(f, "index.html");
|
|
412
|
+
if (!existsSync(f)) throw new Error(`Dosya bulunamadı: ${f}`);
|
|
413
|
+
return { kind: "file", file: f, url: pathToFileURL(f).toString(), label: f };
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// ---------- komut ----------
|
|
417
|
+
const tailLines = (s: string, n = 30) =>
|
|
418
|
+
s
|
|
419
|
+
.split(/\r?\n/)
|
|
420
|
+
.filter((l) => l.trim())
|
|
421
|
+
.slice(-n)
|
|
422
|
+
.join("\n");
|
|
423
|
+
|
|
424
|
+
export async function runCommandCheck(
|
|
425
|
+
command: string,
|
|
426
|
+
cwd: string,
|
|
427
|
+
timeoutMs: number,
|
|
428
|
+
signal?: AbortSignal,
|
|
429
|
+
): Promise<VerifyResult> {
|
|
430
|
+
const child = spawn(command, {
|
|
431
|
+
cwd,
|
|
432
|
+
shell: shellForWrapped(command),
|
|
433
|
+
windowsHide: true,
|
|
434
|
+
detached: process.platform !== "win32",
|
|
435
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
436
|
+
});
|
|
437
|
+
let buf = "";
|
|
438
|
+
const add = (d: Buffer) => {
|
|
439
|
+
buf = (buf + d.toString("utf8")).slice(-16_000);
|
|
440
|
+
};
|
|
441
|
+
child.stdout?.on("data", add);
|
|
442
|
+
child.stderr?.on("data", add);
|
|
443
|
+
let timedOut = false;
|
|
444
|
+
const timer = setTimeout(() => {
|
|
445
|
+
timedOut = true;
|
|
446
|
+
killTree(child);
|
|
447
|
+
}, timeoutMs);
|
|
448
|
+
const onAbort = () => killTree(child);
|
|
449
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
450
|
+
const code = await new Promise<number | null>((res) => {
|
|
451
|
+
child.on("error", () => res(-1));
|
|
452
|
+
child.on("close", (c) => res(c));
|
|
453
|
+
});
|
|
454
|
+
clearTimeout(timer);
|
|
455
|
+
signal?.removeEventListener("abort", onAbort);
|
|
456
|
+
const ok = code === 0 && !timedOut;
|
|
457
|
+
const status: VerifyStatus = ok ? "GEÇTİ" : "KALDI";
|
|
458
|
+
const head = timedOut ? `zaman aşımı (${Math.round(timeoutMs / 1000)} sn) — süreç kapatıldı` : `çıkış kodu ${code}`;
|
|
459
|
+
return {
|
|
460
|
+
status,
|
|
461
|
+
text: `${status} — \`${command}\`: ${head}\nSon çıktı:\n${tailLines(buf) || "(çıktı yok)"}${ok ? "" : "\nHatayı düzelt ve tekrar çalıştır."}`,
|
|
462
|
+
errors: ok ? [] : [head],
|
|
463
|
+
screenshots: [],
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// ---------- sunucu ----------
|
|
468
|
+
function portOpen(port: number): Promise<boolean> {
|
|
469
|
+
return new Promise((res) => {
|
|
470
|
+
const s = net.connect({ port, host: "127.0.0.1" });
|
|
471
|
+
s.once("connect", () => {
|
|
472
|
+
s.destroy();
|
|
473
|
+
res(true);
|
|
474
|
+
});
|
|
475
|
+
s.once("error", () => res(false));
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export async function verifyServer(
|
|
480
|
+
command: string,
|
|
481
|
+
port: number,
|
|
482
|
+
cwd: string,
|
|
483
|
+
opts: { actions?: string[]; browser?: string; signal?: AbortSignal; readyMs?: number; path?: string } = {},
|
|
484
|
+
): Promise<VerifyResult> {
|
|
485
|
+
const child = spawn(command, {
|
|
486
|
+
cwd,
|
|
487
|
+
shell: shellForWrapped(command),
|
|
488
|
+
windowsHide: true,
|
|
489
|
+
detached: process.platform !== "win32",
|
|
490
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
491
|
+
});
|
|
492
|
+
let buf = "";
|
|
493
|
+
const add = (d: Buffer) => {
|
|
494
|
+
buf = (buf + d.toString("utf8")).slice(-8000);
|
|
495
|
+
};
|
|
496
|
+
child.stdout?.on("data", add);
|
|
497
|
+
child.stderr?.on("data", add);
|
|
498
|
+
let exited = false;
|
|
499
|
+
child.on("close", () => {
|
|
500
|
+
exited = true;
|
|
501
|
+
});
|
|
502
|
+
child.on("error", () => {
|
|
503
|
+
exited = true;
|
|
504
|
+
});
|
|
505
|
+
try {
|
|
506
|
+
const t0 = Date.now();
|
|
507
|
+
let up = false;
|
|
508
|
+
while (Date.now() - t0 < (opts.readyMs ?? 30_000) && !exited) {
|
|
509
|
+
if (opts.signal?.aborted) throw new Error("iptal edildi");
|
|
510
|
+
if (await portOpen(port)) {
|
|
511
|
+
up = true;
|
|
512
|
+
break;
|
|
513
|
+
}
|
|
514
|
+
await sleep(300);
|
|
515
|
+
}
|
|
516
|
+
if (!up)
|
|
517
|
+
return {
|
|
518
|
+
status: "KALDI",
|
|
519
|
+
text: `KALDI — sunucu \`${command}\` ${exited ? "kendiliğinden kapandı" : "30 sn içinde"} ${port} portunu açmadı.\nSon çıktı:\n${tailLines(buf) || "(çıktı yok)"}`,
|
|
520
|
+
errors: ["sunucu ayağa kalkmadı"],
|
|
521
|
+
screenshots: [],
|
|
522
|
+
};
|
|
523
|
+
const url = `http://127.0.0.1:${port}${opts.path ?? "/"}`;
|
|
524
|
+
let http: string;
|
|
525
|
+
let httpOk = false;
|
|
526
|
+
try {
|
|
527
|
+
const r = await fetch(url, { signal: AbortSignal.timeout(10_000) });
|
|
528
|
+
http = `HTTP ${r.status}`;
|
|
529
|
+
httpOk = r.status < 400;
|
|
530
|
+
} catch (e) {
|
|
531
|
+
http = `HTTP isteği başarısız: ${e instanceof Error ? e.message : String(e)}`;
|
|
532
|
+
}
|
|
533
|
+
const b = await verifyInBrowser({
|
|
534
|
+
url,
|
|
535
|
+
label: url,
|
|
536
|
+
actions: opts.actions,
|
|
537
|
+
browser: opts.browser,
|
|
538
|
+
signal: opts.signal,
|
|
539
|
+
});
|
|
540
|
+
const status: VerifyStatus = !httpOk ? "KALDI" : b.status;
|
|
541
|
+
const errors = httpOk ? b.errors : [http, ...b.errors];
|
|
542
|
+
return {
|
|
543
|
+
status,
|
|
544
|
+
text: `${b.text.replace(/^(GEÇTİ|KALDI|ATLANDI)/, status)}\nSunucu: ${command} → ${http}; iş bitince kapatıldı.`,
|
|
545
|
+
errors,
|
|
546
|
+
screenshots: b.screenshots,
|
|
547
|
+
};
|
|
548
|
+
} finally {
|
|
549
|
+
killTree(child);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Onay modları matrisi (/sera-mode — Dalga 2, rakip matris madde 6; rakip: Gemini/Claude Code/Cursor izin modları).
|
|
3
|
+
* Kullanıcıya tek bir anahtarla "Sera'ya ne kadar yetki" seçtirir:
|
|
4
|
+
* - oku (read): yalnız okur; dosya değiştirme, komut çalıştırma, ağ ve MCP KAPALI.
|
|
5
|
+
* - düzenle (edit): dosya düzenler ve okur; komut çalıştırma, ağ, MCP KAPALI.
|
|
6
|
+
* - tam (full): her şey açık (mevcut izin kapısı yine sorar).
|
|
7
|
+
* Ayrı bir AĞ ekseni: ağ=kapalı her modda dışarı-gönderimi (egress) engeller.
|
|
8
|
+
*
|
|
9
|
+
* GÜVENLİK ilkesi: bu kat yalnız DARALTIR — mevcut permission-bridge/agent-mode/egress'in izin verdiği hiçbir şeyi
|
|
10
|
+
* GENİŞLETMEZ; yalnız ek engel koyar. Varsayılan (tam + ağ=sor) hiçbir şeyi değiştirmez (regresyon yok). Bu modül
|
|
11
|
+
* SAFtır; chain'de permission ADIMINDAN ÖNCE çalışır (ilk engelleyen kazanır → mod engellerse izin sorusu hiç sorulmaz).
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export type ApprovalMode = "read" | "edit" | "full";
|
|
15
|
+
/** Ağ ekseni: "ask" = mevcut davranış (egress kapısı sorar), "block" = dışarı-gönderim tümden kapalı. */
|
|
16
|
+
export type NetPolicy = "ask" | "block";
|
|
17
|
+
|
|
18
|
+
export interface ApprovalPolicy {
|
|
19
|
+
mode: ApprovalMode;
|
|
20
|
+
net: NetPolicy;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const DEFAULT_POLICY: ApprovalPolicy = { mode: "full", net: "ask" };
|
|
24
|
+
|
|
25
|
+
/** Bir araç çağrısının soyut türü (mod kuralları bunun üzerine uygulanır). */
|
|
26
|
+
export type CallKind = "read" | "edit" | "exec" | "egress" | "mcp";
|
|
27
|
+
|
|
28
|
+
/** Varsayılan mı? (tam + ağ=sor): hızlı yol, hiçbir şey engellenmez. */
|
|
29
|
+
export function isDefaultPolicy(p: ApprovalPolicy): boolean {
|
|
30
|
+
return p.mode === "full" && p.net === "ask";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Araç adı + sınıflandırma bayraklarından soyut tür. egress (dışarı-gönderim) her şeyin önünde gelir; komutsuz kabuk
|
|
35
|
+
* (proc list/read gibi) "read" sayılır.
|
|
36
|
+
*/
|
|
37
|
+
export function callKind(toolName: string, flags: { hasCommand: boolean; egress: boolean }): CallKind {
|
|
38
|
+
if (flags.egress) return "egress";
|
|
39
|
+
// Web araclari (web_fetch/web_search) dis aga cikar: oku/duzenle modunda ve ag=kapali iken engellenir.
|
|
40
|
+
if (toolName === "web_fetch" || toolName === "web_search") return "egress";
|
|
41
|
+
if (toolName.startsWith("mcp__")) return "mcp";
|
|
42
|
+
if (toolName === "edit" || toolName === "write" || toolName === "notebook_edit") return "edit";
|
|
43
|
+
// Uygulama Ustasi: app_verify komutlu ise exec; komutsuz (html dogrulama) ve open_app okuma gibi.
|
|
44
|
+
if (toolName === "app_verify") return flags.hasCommand ? "exec" : "read";
|
|
45
|
+
if (toolName === "open_app") return "read";
|
|
46
|
+
if (toolName === "bash" || toolName === "powershell" || toolName === "proc")
|
|
47
|
+
return flags.hasCommand ? "exec" : "read";
|
|
48
|
+
// GitHub'a yazan araçlar dışarı-gönderimdir.
|
|
49
|
+
if (toolName === "github_yedek" || toolName === "github_ajan") return "egress";
|
|
50
|
+
// AÇIK okuma listesi (Fable incelemesi 2026-11-12, YÜKSEK 3): eskiden listede olmayan HER araç "read" sayılıyordu;
|
|
51
|
+
// dosya yazan/ağa çıkan tuval, video, image, ios_build gibi araçlar salt-okunur modda engellenmiyordu.
|
|
52
|
+
// task/ofis okuma sayılır çünkü alt ajan üst modun AYNISIYLA başlatılır (SERA_MODE/SERA_NET aktarılır).
|
|
53
|
+
if (READ_TOOLS.has(toolName)) return "read";
|
|
54
|
+
return "exec"; // bilinmeyen araç: güvenli taraf (yalnız oku/düzenle modunda engellenir; tam modda davranış aynı)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const READ_TOOLS = new Set([
|
|
58
|
+
"read",
|
|
59
|
+
"research_recall",
|
|
60
|
+
"grep",
|
|
61
|
+
"find",
|
|
62
|
+
"glob",
|
|
63
|
+
"ls",
|
|
64
|
+
"lsp",
|
|
65
|
+
"question",
|
|
66
|
+
"skill",
|
|
67
|
+
"todowrite",
|
|
68
|
+
"todoread",
|
|
69
|
+
"task_status",
|
|
70
|
+
"goal_done",
|
|
71
|
+
"task",
|
|
72
|
+
"ofis",
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
const MODE_LABEL: Record<ApprovalMode, string> = { read: "salt-okunur", edit: "düzenle", full: "tam" };
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Politika bu türü engelliyor mu? Engelliyorsa gerekçe (string) döner, yoksa undefined (mevcut davranış sürer).
|
|
79
|
+
* Yalnız DARALTIR. Ağ ekseni moddan bağımsız; oku/düzenle modları ayrıca exec/mcp/egress'i, oku ek olarak edit'i kapatır.
|
|
80
|
+
*/
|
|
81
|
+
export function approvalBlock(policy: ApprovalPolicy, kind: CallKind): string | undefined {
|
|
82
|
+
if (kind === "egress" && (policy.net === "block" || policy.mode !== "full"))
|
|
83
|
+
return policy.net === "block"
|
|
84
|
+
? "ağ/dışarı-gönderim kapalı (ağ=kapalı)"
|
|
85
|
+
: `${MODE_LABEL[policy.mode]} modu: ağ/dışarı-gönderim kapalı`;
|
|
86
|
+
if (policy.mode === "read") {
|
|
87
|
+
if (kind === "edit") return "salt-okunur mod: dosya değiştirme kapalı";
|
|
88
|
+
if (kind === "exec") return "salt-okunur mod: komut çalıştırma kapalı";
|
|
89
|
+
if (kind === "mcp") return "salt-okunur mod: MCP aracı kapalı";
|
|
90
|
+
}
|
|
91
|
+
if (policy.mode === "edit") {
|
|
92
|
+
if (kind === "exec") return "düzenle modu: komut çalıştırma kapalı (önce /sera-mode tam)";
|
|
93
|
+
if (kind === "mcp") return "düzenle modu: MCP aracı kapalı";
|
|
94
|
+
}
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface ModeParse {
|
|
99
|
+
mode?: ApprovalMode;
|
|
100
|
+
net?: NetPolicy;
|
|
101
|
+
show?: boolean;
|
|
102
|
+
invalid?: boolean;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** `/sera-mode oku|düzenle|tam` · `/sera-mode ağ kapat|aç` · argümansız = durumu göster. */
|
|
106
|
+
export function parseModeCommand(args: string): ModeParse {
|
|
107
|
+
const a = args.trim().toLowerCase().replace(/\s+/g, " ");
|
|
108
|
+
if (!a) return { show: true };
|
|
109
|
+
if (/^(oku|read|salt-?oku\w*)$/.test(a)) return { mode: "read" };
|
|
110
|
+
if (/^(düzenle|duzenle|edit)$/.test(a)) return { mode: "edit" };
|
|
111
|
+
if (/^(tam|full)$/.test(a)) return { mode: "full" };
|
|
112
|
+
if (/^(ağ|ag|net) ?(kapat|kapalı|kapali|block|off|kapa)$/.test(a)) return { net: "block" };
|
|
113
|
+
if (/^(ağ|ag|net) ?(aç|ac|ask|on|open)$/.test(a)) return { net: "ask" };
|
|
114
|
+
return { invalid: true };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Ortam değişkeninden başlangıç politikası (sera -p / alt süreç için): SERA_MODE, SERA_NET. */
|
|
118
|
+
export function policyFromEnv(env: Record<string, string | undefined>): ApprovalPolicy {
|
|
119
|
+
const m = parseModeCommand(env.SERA_MODE ?? "").mode;
|
|
120
|
+
const net = (env.SERA_NET ?? "").toLowerCase();
|
|
121
|
+
return {
|
|
122
|
+
mode: m ?? "full",
|
|
123
|
+
net: net === "block" || net === "kapat" || net === "off" ? "block" : "ask",
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function policyLabel(p: ApprovalPolicy): string {
|
|
128
|
+
return `mod: ${MODE_LABEL[p.mode]}, ağ: ${p.net === "block" ? "kapalı" : "sor"}`;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export const MODE_USAGE = "Kullanım: /sera-mode oku|düzenle|tam · ağ için: /sera-mode ağ kapat | /sera-mode ağ aç";
|