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.
Files changed (456) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE-SERA.md +25 -0
  3. package/README.md +27 -2
  4. package/THIRD_PARTY_NOTICES.md +68 -0
  5. package/bin/sera.mjs +137 -0
  6. package/dist/bundle/chunks/anthropic-messages-RD7GXOQL.js +6 -0
  7. package/dist/bundle/chunks/anthropic.js +75 -0
  8. package/dist/bundle/chunks/azure-openai-responses-CJT3KTVK.js +2 -0
  9. package/dist/bundle/chunks/bedrock-converse-stream.js +89 -0
  10. package/dist/bundle/chunks/chunk-46WGNYIE.js +82 -0
  11. package/dist/bundle/chunks/chunk-4UNN5OGR.js +4 -0
  12. package/dist/bundle/chunks/chunk-53H5DPHA.js +16 -0
  13. package/dist/bundle/chunks/chunk-5AGIVGSV.js +6 -0
  14. package/dist/bundle/chunks/chunk-6JXVX6Q2.js +2 -0
  15. package/dist/bundle/chunks/chunk-6QGV3IWD.js +6 -0
  16. package/dist/bundle/chunks/chunk-7CBJINYJ.js +20 -0
  17. package/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
  18. package/dist/bundle/chunks/chunk-7RZ5BS7U.js +2 -0
  19. package/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
  20. package/dist/bundle/chunks/chunk-BPHHHEET.js +9 -0
  21. package/dist/bundle/chunks/chunk-BSS6T6KQ.js +2 -0
  22. package/dist/bundle/chunks/chunk-CF5GWZHW.js +31 -0
  23. package/dist/bundle/chunks/chunk-EDSQGWII.js +44 -0
  24. package/dist/bundle/chunks/chunk-FFMDRXC4.js +10 -0
  25. package/dist/bundle/chunks/chunk-GUGC72EB.js +1222 -0
  26. package/dist/bundle/chunks/chunk-HODJBMOY.js +9 -0
  27. package/dist/bundle/chunks/chunk-HQBQWHLD.js +7 -0
  28. package/dist/bundle/chunks/chunk-HQJBN2MC.js +2 -0
  29. package/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
  30. package/dist/bundle/chunks/chunk-KXU77PUU.js +4 -0
  31. package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
  32. package/dist/bundle/chunks/chunk-LPXNMA2W.js +2 -0
  33. package/dist/bundle/chunks/chunk-LVVZS2NO.js +12 -0
  34. package/dist/bundle/chunks/chunk-M3LEVT3X.js +2 -0
  35. package/dist/bundle/chunks/chunk-P7FPUEYA.js +2 -0
  36. package/dist/bundle/chunks/chunk-PGXDEOVV.js +2 -0
  37. package/dist/bundle/chunks/chunk-PJACZCIR.js +2 -0
  38. package/dist/bundle/chunks/chunk-PMRZO46Y.js +2 -0
  39. package/dist/bundle/chunks/chunk-PRRNXB7S.js +2 -0
  40. package/dist/bundle/chunks/chunk-QTM7S6TH.js +2 -0
  41. package/dist/bundle/chunks/chunk-RDZVAGPR.js +2 -0
  42. package/dist/bundle/chunks/chunk-TLNP2BSO.js +2 -0
  43. package/dist/bundle/chunks/chunk-TMKHGABX.js +2 -0
  44. package/dist/bundle/chunks/chunk-TMTOQ7H7.js +2 -0
  45. package/dist/bundle/chunks/chunk-UKVNB6C4.js +2 -0
  46. package/dist/bundle/chunks/chunk-USJZMAIR.js +2 -0
  47. package/dist/bundle/chunks/chunk-UTB4DTYQ.js +2 -0
  48. package/dist/bundle/chunks/chunk-ZLAHUYDW.js +131 -0
  49. package/dist/bundle/chunks/chunk-ZNCN2NGY.js +60 -0
  50. package/dist/bundle/chunks/cli-MML2DU4A.js +51 -0
  51. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-QPZQRBK5.js +2 -0
  52. package/dist/bundle/chunks/codemode-worker.js +478 -0
  53. package/dist/bundle/chunks/dist-ZNZCJI7B.js +7 -0
  54. package/dist/bundle/chunks/easter-egg-3d-VOETWRJO.js +2 -0
  55. package/dist/bundle/chunks/execute-HXDNZ26B.js +505 -0
  56. package/dist/bundle/chunks/github-copilot.js +2 -0
  57. package/dist/bundle/chunks/google-generative-ai-SJXMIEPZ.js +2 -0
  58. package/dist/bundle/chunks/google-vertex-VSXQ3BDH.js +2 -0
  59. package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +13 -0
  60. package/dist/bundle/chunks/image-resize-worker.js +2 -0
  61. package/dist/bundle/chunks/jiti-loader-GL4HJFAD.js +21 -0
  62. package/dist/bundle/chunks/jiti-static-loader-2RCDI6B4.js +2 -0
  63. package/dist/bundle/chunks/kimi-coding.js +2 -0
  64. package/dist/bundle/chunks/lib-4AVRLBHM.js +9 -0
  65. package/dist/bundle/chunks/llama-cpp-classify-4KFSGAMH.js +22 -0
  66. package/dist/bundle/chunks/meta.js +2 -0
  67. package/dist/bundle/chunks/mistral-conversations-JYWDZV2K.js +5 -0
  68. package/dist/bundle/chunks/multipart-parser-FMGQ7342.js +3 -0
  69. package/dist/bundle/chunks/node-AUOGOBCN.js +2 -0
  70. package/dist/bundle/chunks/node-KCMANYC2.js +16 -0
  71. package/dist/bundle/chunks/openai-chatgpt.js +75 -0
  72. package/dist/bundle/chunks/openai-codex-responses-OQV5DCFA.js +10 -0
  73. package/dist/bundle/chunks/openai-codex.js +75 -0
  74. package/dist/bundle/chunks/openai-completions-RFDJM2W5.js +7 -0
  75. package/dist/bundle/chunks/openai-decisions-O6PHBSCB.js +5 -0
  76. package/dist/bundle/chunks/openai-responses-LVNAPALQ.js +4 -0
  77. package/dist/bundle/chunks/openrouter-images-4WG6OOLH.js +2 -0
  78. package/dist/bundle/chunks/openrouter.js +75 -0
  79. package/dist/bundle/chunks/pdfjs-BETXZQ7A.js +108 -0
  80. package/dist/bundle/chunks/pdfjs-decoders-37HBPYHX.js +2 -0
  81. package/dist/bundle/chunks/pdfjs-jbig2-MH7WRXUP.js +2 -0
  82. package/dist/bundle/chunks/pdfjs-jbig2_nowasm_fallback-UVK7AQLA.js +2 -0
  83. package/dist/bundle/chunks/pdfjs-openjpeg-TC2QHC4G.js +2 -0
  84. package/dist/bundle/chunks/pdfjs-openjpeg_nowasm_fallback-ZC2FTHCZ.js +3 -0
  85. package/dist/bundle/chunks/pi-messages-EZXKVRR6.js +8 -0
  86. package/dist/bundle/chunks/radius.js +75 -0
  87. package/dist/bundle/chunks/runtime-JAH75CB5.js +2 -0
  88. package/dist/bundle/chunks/src-QKGKDFSU.js +4 -0
  89. package/dist/bundle/chunks/typesafe-system-one-X3JT6ECA.js +2 -0
  90. package/dist/bundle/chunks/virtual-modules-I5QRIHN6.js +2 -0
  91. package/dist/bundle/chunks/xai.js +2 -0
  92. package/dist/bundle/cli-runtime.js +3 -0
  93. package/dist/bundle/cli.js +5 -0
  94. package/dist/bundle/index.js +2 -0
  95. package/dist/bundle/rpc-entry.js +3 -0
  96. package/dist/core/export-html/ansi-to-html.d.ts +22 -0
  97. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  98. package/dist/core/export-html/ansi-to-html.js +249 -0
  99. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  100. package/dist/core/export-html/index.d.ts +37 -0
  101. package/dist/core/export-html/index.d.ts.map +1 -0
  102. package/dist/core/export-html/index.js +228 -0
  103. package/dist/core/export-html/index.js.map +1 -0
  104. package/dist/core/export-html/template.css +1085 -0
  105. package/dist/core/export-html/template.html +56 -0
  106. package/dist/core/export-html/template.js +2044 -0
  107. package/dist/core/export-html/tool-renderer.d.ts +34 -0
  108. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  109. package/dist/core/export-html/tool-renderer.js +110 -0
  110. package/dist/core/export-html/tool-renderer.js.map +1 -0
  111. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  112. package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
  113. package/dist/core/export-html/vendor/marked.min.js +79 -0
  114. package/dist/modes/interactive/assets/clankolas.png +0 -0
  115. package/dist/modes/interactive/theme/dark.json +81 -0
  116. package/dist/modes/interactive/theme/light.json +81 -0
  117. package/dist/modes/interactive/theme/system-theme.d.ts +55 -0
  118. package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
  119. package/dist/modes/interactive/theme/system-theme.js +546 -0
  120. package/dist/modes/interactive/theme/system-theme.js.map +1 -0
  121. package/dist/modes/interactive/theme/theme-controller.d.ts +81 -0
  122. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
  123. package/dist/modes/interactive/theme/theme-controller.js +210 -0
  124. package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
  125. package/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
  126. package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
  127. package/dist/modes/interactive/theme/theme-schema.js +105 -0
  128. package/dist/modes/interactive/theme/theme-schema.js.map +1 -0
  129. package/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
  130. package/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
  131. package/dist/modes/interactive/theme/theme-tokens.js +94 -0
  132. package/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
  133. package/dist/modes/interactive/theme/theme.d.ts +155 -0
  134. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  135. package/dist/modes/interactive/theme/theme.js +905 -0
  136. package/dist/modes/interactive/theme/theme.js.map +1 -0
  137. package/docs/cli-integration.md +106 -0
  138. package/docs/cli.md +333 -0
  139. package/docs/codemode.md +230 -0
  140. package/docs/compaction.md +463 -0
  141. package/docs/configuration.md +47 -0
  142. package/docs/containerization.md +183 -0
  143. package/docs/custom-provider.md +227 -0
  144. package/docs/docs.json +220 -0
  145. package/docs/environment-variables.md +102 -0
  146. package/docs/extensions.md +400 -0
  147. package/docs/how-pi-works.md +49 -0
  148. package/docs/index.md +39 -0
  149. package/docs/json.md +226 -0
  150. package/docs/keybindings.md +195 -0
  151. package/docs/llama-cpp.md +121 -0
  152. package/docs/mcp.md +272 -0
  153. package/docs/message-types.md +279 -0
  154. package/docs/models-configuration.md +196 -0
  155. package/docs/models.md +225 -0
  156. package/docs/nvidia-rtx-llama-cpp.md +96 -0
  157. package/docs/packages.md +131 -0
  158. package/docs/prompt-templates.md +59 -0
  159. package/docs/providers.md +247 -0
  160. package/docs/quickstart.md +136 -0
  161. package/docs/rpc-commands.md +860 -0
  162. package/docs/rpc-extension-ui.md +200 -0
  163. package/docs/rpc.md +193 -0
  164. package/docs/sdk.md +147 -0
  165. package/docs/security.md +99 -0
  166. package/docs/session-format.md +293 -0
  167. package/docs/sessions.md +66 -0
  168. package/docs/settings.md +172 -0
  169. package/docs/shell-aliases.md +93 -0
  170. package/docs/skills.md +93 -0
  171. package/docs/slash-commands.md +61 -0
  172. package/docs/terminal-setup.md +233 -0
  173. package/docs/termux.md +117 -0
  174. package/docs/themes.md +138 -0
  175. package/docs/tmux.md +55 -0
  176. package/docs/tui.md +195 -0
  177. package/docs/usage.md +94 -0
  178. package/docs/virtual-models.md +114 -0
  179. package/docs/windows.md +81 -0
  180. package/lib/auth.js +190 -0
  181. package/lib/provider.js +52 -0
  182. package/package.json +43 -5
  183. package/sera-core/skills/apple-tasarim/SKILL.md +48 -0
  184. package/sera-core/skills/apple-tasarim/referanslar/apple-hig.md +55 -0
  185. package/sera-core/skills/belge-yarat/SKILL.md +64 -0
  186. package/sera-core/skills/belge-yarat/referanslar/belge-yazim.md +60 -0
  187. package/sera-core/skills/derin-arastirma/SKILL.md +52 -0
  188. package/sera-core/skills/derin-arastirma/referanslar/arastirma-yontem.md +50 -0
  189. package/sera-core/skills/dusunme-dogrulama/SKILL.md +59 -0
  190. package/sera-core/skills/dusunme-dogrulama/referanslar/dusunme-kontrol.md +54 -0
  191. package/sera-core/skills/film-stilleri/SKILL.md +51 -0
  192. package/sera-core/skills/hyperframes/LICENSE-UPSTREAM +190 -0
  193. package/sera-core/skills/hyperframes/SKILL.md +79 -0
  194. package/sera-core/skills/hyperframes/assets/frame-presets/biennale-yellow/FRAME.md +289 -0
  195. package/sera-core/skills/hyperframes/assets/frame-presets/blockframe/FRAME.md +275 -0
  196. package/sera-core/skills/hyperframes/assets/frame-presets/blue-professional/FRAME.md +307 -0
  197. package/sera-core/skills/hyperframes/assets/frame-presets/bold-poster/FRAME.md +275 -0
  198. package/sera-core/skills/hyperframes/assets/frame-presets/broadside/FRAME.md +284 -0
  199. package/sera-core/skills/hyperframes/assets/frame-presets/capsule/FRAME.md +284 -0
  200. package/sera-core/skills/hyperframes/assets/frame-presets/cartesian/FRAME.md +278 -0
  201. package/sera-core/skills/hyperframes/assets/frame-presets/cobalt-grid/FRAME.md +265 -0
  202. package/sera-core/skills/hyperframes/assets/frame-presets/code-editorial/FRAME.md +277 -0
  203. package/sera-core/skills/hyperframes/assets/frame-presets/coral/FRAME.md +314 -0
  204. package/sera-core/skills/hyperframes/assets/frame-presets/creative-mode/FRAME.md +333 -0
  205. package/sera-core/skills/hyperframes/assets/frame-presets/daisy-days/FRAME.md +274 -0
  206. package/sera-core/skills/hyperframes/assets/frame-presets/editorial-forest/FRAME.md +265 -0
  207. package/sera-core/skills/hyperframes/references/captions.md +46 -0
  208. package/sera-core/skills/hyperframes/references/film.md +48 -0
  209. package/sera-core/skills/hyperframes/references/format.md +159 -0
  210. package/sera-core/skills/hyperframes/references/look.md +69 -0
  211. package/sera-core/skills/hyperframes/references/motion.md +95 -0
  212. package/sera-core/skills/hyperframes/references/overlays.md +39 -0
  213. package/sera-core/skills/hyperframes/references/path-tracing.md +36 -0
  214. package/sera-core/skills/hyperframes/references/plugin-installation.md +42 -0
  215. package/sera-core/skills/hyperframes/references/review.md +51 -0
  216. package/sera-core/skills/hyperframes/references/runtimes.md +69 -0
  217. package/sera-core/skills/hyperframes/references/skill-lifecycle.md +54 -0
  218. package/sera-core/skills/hyperframes/references/sound.md +43 -0
  219. package/sera-core/skills/hyperframes/references/spec.md +76 -0
  220. package/sera-core/skills/hyperframes/references/story.md +103 -0
  221. package/sera-core/skills/hyperframes/references/storyboard-format.md +107 -0
  222. package/sera-core/skills/hyperframes/references/storyboard.md +36 -0
  223. package/sera-core/skills/hyperframes/references/types/3d.md +25 -0
  224. package/sera-core/skills/hyperframes/references/types/character.md +20 -0
  225. package/sera-core/skills/hyperframes/references/types/data.md +19 -0
  226. package/sera-core/skills/hyperframes/references/types/explainer.md +34 -0
  227. package/sera-core/skills/hyperframes/references/types/launch.md +41 -0
  228. package/sera-core/skills/hyperframes/references/types/music.md +24 -0
  229. package/sera-core/skills/hyperframes/references/types/vertical.md +23 -0
  230. package/sera-core/skills/hyperframes-cli/LICENSE-UPSTREAM +190 -0
  231. package/sera-core/skills/hyperframes-cli/SKILL.md +99 -0
  232. package/sera-core/skills/hyperframes-cli/references/beats.md +17 -0
  233. package/sera-core/skills/hyperframes-cli/references/compare-and-batch.md +105 -0
  234. package/sera-core/skills/hyperframes-cli/references/conventions.md +16 -0
  235. package/sera-core/skills/hyperframes-cli/references/doctor-browser.md +80 -0
  236. package/sera-core/skills/hyperframes-cli/references/feedback.md +14 -0
  237. package/sera-core/skills/hyperframes-cli/references/init-and-scaffold.md +75 -0
  238. package/sera-core/skills/hyperframes-cli/references/lint-validate-inspect.md +164 -0
  239. package/sera-core/skills/hyperframes-cli/references/preview-render.md +204 -0
  240. package/sera-core/skills/hyperframes-cli/references/upgrade-info-misc.md +134 -0
  241. package/sera-core/skills/impeccable/LICENSE-UPSTREAM +191 -0
  242. package/sera-core/skills/impeccable/NOTICE-UPSTREAM.md +11 -0
  243. package/sera-core/skills/impeccable/SKILL.md +89 -0
  244. package/sera-core/skills/impeccable/reference/adapt.md +318 -0
  245. package/sera-core/skills/impeccable/reference/adapt.native.md +58 -0
  246. package/sera-core/skills/impeccable/reference/android.md +46 -0
  247. package/sera-core/skills/impeccable/reference/animate.md +89 -0
  248. package/sera-core/skills/impeccable/reference/audit.md +139 -0
  249. package/sera-core/skills/impeccable/reference/audit.native.md +139 -0
  250. package/sera-core/skills/impeccable/reference/bolder.md +33 -0
  251. package/sera-core/skills/impeccable/reference/clarify.md +94 -0
  252. package/sera-core/skills/impeccable/reference/colorize.md +86 -0
  253. package/sera-core/skills/impeccable/reference/component-review.md +63 -0
  254. package/sera-core/skills/impeccable/reference/craft-floor.md +44 -0
  255. package/sera-core/skills/impeccable/reference/craft.md +5 -0
  256. package/sera-core/skills/impeccable/reference/critique.md +819 -0
  257. package/sera-core/skills/impeccable/reference/degraded/asset-producer.md +42 -0
  258. package/sera-core/skills/impeccable/reference/degraded/documenter.md +24 -0
  259. package/sera-core/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
  260. package/sera-core/skills/impeccable/reference/degraded/manual-edit-applier.md +93 -0
  261. package/sera-core/skills/impeccable/reference/delight.md +70 -0
  262. package/sera-core/skills/impeccable/reference/distill.md +111 -0
  263. package/sera-core/skills/impeccable/reference/doctor.md +54 -0
  264. package/sera-core/skills/impeccable/reference/document.md +416 -0
  265. package/sera-core/skills/impeccable/reference/extract.md +69 -0
  266. package/sera-core/skills/impeccable/reference/generate.md +101 -0
  267. package/sera-core/skills/impeccable/reference/harden.md +362 -0
  268. package/sera-core/skills/impeccable/reference/hooks.md +120 -0
  269. package/sera-core/skills/impeccable/reference/init.md +133 -0
  270. package/sera-core/skills/impeccable/reference/ios.md +51 -0
  271. package/sera-core/skills/impeccable/reference/layout.md +84 -0
  272. package/sera-core/skills/impeccable/reference/live-setup.md +104 -0
  273. package/sera-core/skills/impeccable/reference/live.md +327 -0
  274. package/sera-core/skills/impeccable/reference/mode-operate.md +21 -0
  275. package/sera-core/skills/impeccable/reference/mode-persuade.md +19 -0
  276. package/sera-core/skills/impeccable/reference/mode-read.md +21 -0
  277. package/sera-core/skills/impeccable/reference/new-work.md +152 -0
  278. package/sera-core/skills/impeccable/reference/onboard.md +234 -0
  279. package/sera-core/skills/impeccable/reference/operate.md +61 -0
  280. package/sera-core/skills/impeccable/reference/optimize.md +257 -0
  281. package/sera-core/skills/impeccable/reference/overdrive.md +127 -0
  282. package/sera-core/skills/impeccable/reference/polish.md +105 -0
  283. package/sera-core/skills/impeccable/reference/quieter.md +99 -0
  284. package/sera-core/skills/impeccable/reference/region-map.md +26 -0
  285. package/sera-core/skills/impeccable/reference/routing.md +24 -0
  286. package/sera-core/skills/impeccable/reference/shape.md +59 -0
  287. package/sera-core/skills/impeccable/reference/typeset.md +90 -0
  288. package/sera-core/skills/impeccable/reference/visualize.md +47 -0
  289. package/sera-core/skills/oyun-yarat/SKILL.md +106 -0
  290. package/sera-core/skills/oyun-yarat/referanslar/3b-yaris.md +74 -0
  291. package/sera-core/skills/oyun-yarat/referanslar/kaplay.md +99 -0
  292. package/sera-core/skills/oyun-yarat/referanslar/oyun-desenleri.md +73 -0
  293. package/sera-core/skills/oyun-yarat/sablonlar/kaplay-2d.html +164 -0
  294. package/sera-core/skills/oyun-yarat/sablonlar/three-yaris.html +149 -0
  295. package/sera-core/skills/oyun-yarat/sablonlar/tuval-minimal.html +77 -0
  296. package/sera-core/skills/receiving-code-review/LICENSE-UPSTREAM +21 -0
  297. package/sera-core/skills/receiving-code-review/SKILL.md +205 -0
  298. package/sera-core/skills/refero-design/LICENSE-UPSTREAM +21 -0
  299. package/sera-core/skills/refero-design/SKILL.md +534 -0
  300. package/sera-core/skills/refero-design/references/anti-ai-slop.md +292 -0
  301. package/sera-core/skills/refero-design/references/color.md +563 -0
  302. package/sera-core/skills/refero-design/references/copywriting.md +222 -0
  303. package/sera-core/skills/refero-design/references/craft-details.md +525 -0
  304. package/sera-core/skills/refero-design/references/example-workflow.md +264 -0
  305. package/sera-core/skills/refero-design/references/icons.md +166 -0
  306. package/sera-core/skills/refero-design/references/mcp-tools.md +258 -0
  307. package/sera-core/skills/refero-design/references/motion.md +504 -0
  308. package/sera-core/skills/refero-design/references/typography.md +737 -0
  309. package/sera-core/skills/refero-design/references/visual-workflow.md +105 -0
  310. package/sera-core/skills/requesting-code-review/LICENSE-UPSTREAM +21 -0
  311. package/sera-core/skills/requesting-code-review/SKILL.md +95 -0
  312. package/sera-core/skills/requesting-code-review/code-reviewer.md +198 -0
  313. package/sera-core/skills/reverse-engineer-anything/DISCLAIMER.md +136 -0
  314. package/sera-core/skills/reverse-engineer-anything/LICENSE-REA-MIT +21 -0
  315. package/sera-core/skills/reverse-engineer-anything/SKILL.md +363 -0
  316. package/sera-core/skills/reverse-engineer-anything/THIRD_PARTY_NOTICES.md +135 -0
  317. package/sera-core/skills/reverse-engineer-anything/references/android-applications.md +36 -0
  318. package/sera-core/skills/reverse-engineer-anything/references/connection-and-recovery.md +127 -0
  319. package/sera-core/skills/reverse-engineer-anything/references/evidence-workflows.md +71 -0
  320. package/sera-core/skills/reverse-engineer-anything/references/javascript-applications.md +218 -0
  321. package/sera-core/skills/reverse-engineer-anything/references/native-and-artifacts.md +297 -0
  322. package/sera-core/skills/reverse-engineer-anything/references/runtime-observation.md +78 -0
  323. package/sera-core/skills/seo-audit/LICENSE-UPSTREAM +21 -0
  324. package/sera-core/skills/seo-audit/SKILL.md +210 -0
  325. package/sera-core/skills/sera-guvenlik-denetim/SKILL.md +44 -0
  326. package/sera-core/skills/sera-guvenlik-denetim/referanslar/guvenlik-listesi.md +33 -0
  327. package/sera-core/skills/sera-hata-ayikla/SKILL.md +27 -0
  328. package/sera-core/skills/sera-hata-ayikla/referanslar/hata-ayiklama.md +37 -0
  329. package/sera-core/skills/sera-kod-inceleme/SKILL.md +44 -0
  330. package/sera-core/skills/sera-kod-inceleme/referanslar/inceleme-listesi.md +62 -0
  331. package/sera-core/skills/sera-ofis-dosya/SKILL.md +27 -0
  332. package/sera-core/skills/sera-ofis-dosya/referanslar/ofis-dosya.md +93 -0
  333. package/sera-core/skills/sera-research/SKILL.md +90 -0
  334. package/sera-core/skills/sera-tasarim/SKILL.md +149 -0
  335. package/sera-core/skills/sera-teslim-sozlesmesi/SKILL.md +592 -0
  336. package/sera-core/skills/sera-test-yaz/SKILL.md +26 -0
  337. package/sera-core/skills/sera-test-yaz/referanslar/test-yazimi.md +35 -0
  338. package/sera-core/skills/sera-veri-gorsel/SKILL.md +65 -0
  339. package/sera-core/skills/sera-web-test/SKILL.md +26 -0
  340. package/sera-core/skills/sera-web-test/referanslar/web-test.md +44 -0
  341. package/sera-core/skills/sera-zamanli-gorev/SKILL.md +22 -0
  342. package/sera-core/skills/sera-zamanli-gorev/referanslar/zamanli-gorev.md +58 -0
  343. package/sera-core/skills/systematic-debugging/LICENSE-UPSTREAM +21 -0
  344. package/sera-core/skills/systematic-debugging/SKILL.md +283 -0
  345. package/sera-core/skills/systematic-debugging/condition-based-waiting.md +115 -0
  346. package/sera-core/skills/systematic-debugging/defense-in-depth.md +122 -0
  347. package/sera-core/skills/systematic-debugging/root-cause-tracing.md +169 -0
  348. package/sera-core/skills/test-driven-development/LICENSE-UPSTREAM +21 -0
  349. package/sera-core/skills/test-driven-development/SKILL.md +330 -0
  350. package/sera-core/skills/test-driven-development/writing-good-tests.md +198 -0
  351. package/sera-core/skills/ticaret-icerik/SKILL.md +49 -0
  352. package/sera-core/skills/ticaret-icerik/referanslar/ticaret-icerik.md +54 -0
  353. package/sera-core/skills/uygulama-yarat/SKILL.md +95 -0
  354. package/sera-core/skills/uygulama-yarat/referanslar/uygulama-desenleri.md +63 -0
  355. package/sera-core/skills/uygulama-yarat/sablonlar/uygulama-tek-dosya.html +121 -0
  356. package/sera-core/skills/uyumluluk-denetim/SKILL.md +56 -0
  357. package/sera-core/skills/uyumluluk-denetim/referanslar/mevzuat-tablosu.md +65 -0
  358. package/sera-core/skills/veri-analizi/SKILL.md +54 -0
  359. package/sera-core/skills/veri-analizi/referanslar/veri-analizi-yontem.md +49 -0
  360. package/sera-core/skills/veri-analizi/sablonlar/profil.mjs +79 -0
  361. package/sera-core/skills/video-duzen/SKILL.md +50 -0
  362. package/sera-core/skills/video-duzen/referanslar/video-duzen.md +100 -0
  363. package/sera-core/skills/web-yayin-listesi/SKILL.md +115 -0
  364. package/sera-core/skills/writing-plans/LICENSE-UPSTREAM +21 -0
  365. package/sera-core/skills/writing-plans/SKILL.md +204 -0
  366. package/sera-core/src/action-nudge.ts +200 -0
  367. package/sera-core/src/agent-mode.ts +143 -0
  368. package/sera-core/src/agents.ts +185 -0
  369. package/sera-core/src/app-master.ts +275 -0
  370. package/sera-core/src/app-verify.ts +551 -0
  371. package/sera-core/src/approval.ts +131 -0
  372. package/sera-core/src/budget.ts +136 -0
  373. package/sera-core/src/command-policy.ts +808 -0
  374. package/sera-core/src/config.ts +135 -0
  375. package/sera-core/src/context-diet.ts +272 -0
  376. package/sera-core/src/device-id.ts +48 -0
  377. package/sera-core/src/dogal-arac.ts +203 -0
  378. package/sera-core/src/dogal-niyet.ts +173 -0
  379. package/sera-core/src/egress-allow.ts +52 -0
  380. package/sera-core/src/export.ts +124 -0
  381. package/sera-core/src/exposure.ts +8 -0
  382. package/sera-core/src/extension.ts +2416 -0
  383. package/sera-core/src/fs-tools.ts +444 -0
  384. package/sera-core/src/generated/build-rules.ts +26 -0
  385. package/sera-core/src/generated/zero-knowledge.ts +170 -0
  386. package/sera-core/src/github-agent-command.ts +133 -0
  387. package/sera-core/src/github-agent-engine.ts +198 -0
  388. package/sera-core/src/github-agent-schedule.ts +180 -0
  389. package/sera-core/src/github-agent.ts +669 -0
  390. package/sera-core/src/github-ajan-akis.ts +193 -0
  391. package/sera-core/src/github-ajan-gercek.ts +102 -0
  392. package/sera-core/src/github-tick.ts +78 -0
  393. package/sera-core/src/github-yedek.ts +269 -0
  394. package/sera-core/src/goal.ts +119 -0
  395. package/sera-core/src/handoff.ts +132 -0
  396. package/sera-core/src/hooks.ts +284 -0
  397. package/sera-core/src/image-tool.ts +118 -0
  398. package/sera-core/src/intake-brief.ts +82 -0
  399. package/sera-core/src/intake-core.ts +1152 -0
  400. package/sera-core/src/intake-hook.ts +88 -0
  401. package/sera-core/src/ios-build-tool.ts +134 -0
  402. package/sera-core/src/lazy-capability.ts +125 -0
  403. package/sera-core/src/lazy-mcp.ts +300 -0
  404. package/sera-core/src/limit-command.ts +51 -0
  405. package/sera-core/src/loop-brake.ts +129 -0
  406. package/sera-core/src/lsp.ts +618 -0
  407. package/sera-core/src/mcp-bridge.ts +159 -0
  408. package/sera-core/src/mcp-pin.ts +105 -0
  409. package/sera-core/src/mcp-ssrf.ts +124 -0
  410. package/sera-core/src/message-cap.ts +45 -0
  411. package/sera-core/src/no-progress.ts +177 -0
  412. package/sera-core/src/notebook-tool.ts +179 -0
  413. package/sera-core/src/ofis.ts +473 -0
  414. package/sera-core/src/path-guard.ts +139 -0
  415. package/sera-core/src/permission-bridge.ts +228 -0
  416. package/sera-core/src/policy-chain.ts +122 -0
  417. package/sera-core/src/pricing.ts +71 -0
  418. package/sera-core/src/proc.ts +149 -0
  419. package/sera-core/src/rea.ts +188 -0
  420. package/sera-core/src/repo-map.ts +230 -0
  421. package/sera-core/src/research.ts +347 -0
  422. package/sera-core/src/rules-memory.ts +227 -0
  423. package/sera-core/src/sandbox.ts +445 -0
  424. package/sera-core/src/server-error.ts +78 -0
  425. package/sera-core/src/skills.ts +268 -0
  426. package/sera-core/src/snapshot.ts +143 -0
  427. package/sera-core/src/spec-gate.ts +112 -0
  428. package/sera-core/src/subagent.ts +261 -0
  429. package/sera-core/src/teslim.ts +120 -0
  430. package/sera-core/src/test-fix.ts +184 -0
  431. package/sera-core/src/todo-question.ts +163 -0
  432. package/sera-core/src/turn-snapshots.ts +126 -0
  433. package/sera-core/src/tuval/arac.ts +338 -0
  434. package/sera-core/src/tuval/arsiv.ts +106 -0
  435. package/sera-core/src/tuval/belge.ts +216 -0
  436. package/sera-core/src/tuval/birlestir.ts +282 -0
  437. package/sera-core/src/tuval/disa.ts +235 -0
  438. package/sera-core/src/tuval/editor.ts +583 -0
  439. package/sera-core/src/tuval/film-cekirdek.ts +170 -0
  440. package/sera-core/src/tuval/film-disa.ts +188 -0
  441. package/sera-core/src/tuval/film-oynatici.ts +307 -0
  442. package/sera-core/src/tuval/kimlik.ts +156 -0
  443. package/sera-core/src/tuval/pano.ts +763 -0
  444. package/sera-core/src/tuval/proje.ts +728 -0
  445. package/sera-core/src/tuval/sistem-cekirdek.ts +167 -0
  446. package/sera-core/src/tuval/sistem.ts +328 -0
  447. package/sera-core/src/tuval/sunucu.ts +413 -0
  448. package/sera-core/src/tuval/uretim.ts +24 -0
  449. package/sera-core/src/tuval/veri-cekirdek.ts +477 -0
  450. package/sera-core/src/tuval/xlsx.ts +215 -0
  451. package/sera-core/src/tuval/zip.ts +163 -0
  452. package/sera-core/src/untrusted.ts +201 -0
  453. package/sera-core/src/video-edit-tool.ts +411 -0
  454. package/sera-core/src/video-tool.ts +217 -0
  455. package/sera-core/src/web-tools.ts +257 -0
  456. package/sera-core/src/zk.ts +104 -0
@@ -0,0 +1,139 @@
1
+ /**
2
+ * E4: proje disi dosya onayi. edit/write hedefi proje kokunun disindaysa, ve read hedefi proje disinda duyarli bir
3
+ * yolsa (~/.ssh, ~/.aws, .env ...) arac cagrisi kullanici onayina baglanir. Karar vermeden once yol GERCEK konuma
4
+ * cozulur: `..`, sembolik baglantilar (henuz olmayan dosya icin en yakin var olan ust klasor), Windows buyuk/kucuk
5
+ * harf ve `\?\` on eki. Saf mantik; onay sorusu PermissionGate.confirm uzerinden gider.
6
+ */
7
+ import { existsSync, lstatSync, readlinkSync, realpathSync } from "node:fs";
8
+ import { homedir, tmpdir } from "node:os";
9
+ import { delimiter, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
10
+ import { fileURLToPath } from "node:url";
11
+
12
+ const UNICODE_SPACES = new RegExp(
13
+ `[${[0xa0, 0x202f, 0x205f, 0x3000, ...Array.from({ length: 11 }, (_, k) => 0x2000 + k)].map((n) => String.fromCharCode(n)).join("")}]`,
14
+ "g",
15
+ );
16
+
17
+ const SENSITIVE_DIR = /(^|\/)\.(ssh|aws|gnupg|kube|azure|config\/gcloud|docker)(\/|$)/i;
18
+ const SENSITIVE_FILE =
19
+ /(^|\/)(\.env(\.(?!example$|sample$|template$)[^/]*)?|id_(rsa|dsa|ecdsa|ed25519)(\.pub)?|\.netrc|\.npmrc|\.pypirc|\.git-credentials|credentials(\.json)?|secrets?\.(json|ya?ml)|[^/]*\.(pem|key|pfx|p12|kdbx)|login data|cookies)$/i;
20
+
21
+ const READ_LIKE = new Set(["read", "grep", "glob", "ls", "find"]);
22
+
23
+ /** Kimlik bilgisi/gizli anahtar tasiyan yol mu (konumdan bagimsiz). */
24
+ export function isSensitivePath(p: string): boolean {
25
+ const n = p.replaceAll("\\", "/");
26
+ return SENSITIVE_DIR.test(n) || SENSITIVE_FILE.test(n);
27
+ }
28
+
29
+ /**
30
+ * Pi'nin arac yol cozumuyle AYNI normallestirme (utils/paths.ts normalizePath): bas `@`, unicode bosluklar, Windows'ta
31
+ * Git-Bash `/c/...`, `~`, `file://`. Farkli cozmek kontrol atlatmaya yol acar.
32
+ */
33
+ export function expandPath(p: string, home = homedir(), win = process.platform === "win32"): string {
34
+ let s = p.replace(UNICODE_SPACES, " ");
35
+ if (s.startsWith("@")) s = s.slice(1);
36
+ if (win && s.startsWith("/") && !s.startsWith("//") && !s.includes("\\")) {
37
+ const m = s.match(/^\/(?:mnt\/|cygdrive\/)?([a-z])(?:\/(.*))?$/i);
38
+ if (m) s = `${m[1].toUpperCase()}:\\${(m[2] ?? "").replaceAll("/", "\\")}`;
39
+ }
40
+ if (s === "~") return home;
41
+ if (s.startsWith("~/") || (win && s.startsWith("~\\"))) return join(home, s.slice(2));
42
+ if (/^file:\/\//.test(s)) {
43
+ try {
44
+ return fileURLToPath(s);
45
+ } catch {
46
+ return s;
47
+ }
48
+ }
49
+ return s;
50
+ }
51
+
52
+ /** Yolu gercek konuma cozer: var olan en yakin ust klasoru realpath, kalani oldugu gibi ekler. */
53
+ export function resolveReal(p: string, depth = 0): string {
54
+ let cur = resolve(p);
55
+ const rest: string[] = [];
56
+ while (!existsSync(cur)) {
57
+ // kirik sembolik baglanti: yazma baglantinin HEDEFINDE olusur -> hedefe takip et
58
+ try {
59
+ if (depth < 8 && lstatSync(cur).isSymbolicLink()) {
60
+ const t = resolve(dirname(cur), readlinkSync(cur));
61
+ return resolveReal(resolve(t, ...rest), depth + 1);
62
+ }
63
+ } catch {
64
+ // baglanti degil / yok
65
+ }
66
+ const up = dirname(cur);
67
+ if (up === cur) break;
68
+ rest.unshift(cur.slice(up.length).replace(/^[\\/]+/, ""));
69
+ cur = up;
70
+ }
71
+ let real = cur;
72
+ try {
73
+ real = realpathSync.native(cur);
74
+ } catch {
75
+ // kullanilamayan yol: oldugu gibi
76
+ }
77
+ return resolve(real, ...rest).replace(/^\\\\\?\\/, "");
78
+ }
79
+
80
+ const fold = (p: string, ci: boolean) => (ci ? p.toLowerCase() : p);
81
+
82
+ export function isInside(root: string, target: string, caseInsensitive = process.platform === "win32"): boolean {
83
+ const r = fold(root, caseInsensitive);
84
+ const t = fold(target, caseInsensitive);
85
+ const rel = relative(r, t);
86
+ return rel === "" || (!rel.startsWith(`..${sep}`) && rel !== ".." && !isAbsolute(rel));
87
+ }
88
+
89
+ export interface PathGuardOptions {
90
+ /** Ek izinli kokler (SERA_ALLOW_PATHS, `;`/`:` ile ayrilmis). */
91
+ extraRoots?: string[];
92
+ caseInsensitive?: boolean;
93
+ home?: string;
94
+ }
95
+
96
+ export interface OutsideFinding {
97
+ path: string;
98
+ sensitive: boolean;
99
+ write: boolean;
100
+ reason: string;
101
+ }
102
+
103
+ export function extraRootsFromEnv(env: NodeJS.ProcessEnv = process.env): string[] {
104
+ return (env.SERA_ALLOW_PATHS ?? "")
105
+ .split(delimiter)
106
+ .map((s) => s.trim())
107
+ .filter(Boolean);
108
+ }
109
+
110
+ /** undefined = proje icinde / zararsiz; aksi halde onay gerektiren bulgu. */
111
+ export function checkOutside(
112
+ cwd: string,
113
+ toolName: string,
114
+ input: unknown,
115
+ opts: PathGuardOptions = {},
116
+ ): OutsideFinding | undefined {
117
+ const write = toolName === "edit" || toolName === "write" || toolName === "notebook_edit";
118
+ // grep/glob/ls/find da proje dışı DUYARLI dizini tarayabilir (Fable 2026-11-12 ORTA 8): okuma gibi denetlenir.
119
+ if (!write && !READ_LIKE.has(toolName)) return undefined;
120
+ const i = (input ?? {}) as Record<string, unknown>;
121
+ const raw = String(i.path ?? i.file_path ?? "").trim();
122
+ if (!raw) return undefined;
123
+ const ci = opts.caseInsensitive ?? process.platform === "win32";
124
+ const target = resolveReal(
125
+ isAbsolute(expandPath(raw, opts.home)) ? expandPath(raw, opts.home) : resolve(cwd, expandPath(raw, opts.home)),
126
+ );
127
+ const root = resolveReal(cwd);
128
+ if (isInside(root, target, ci)) return undefined;
129
+ const sensitive = isSensitivePath(target);
130
+ if (!write && !sensitive) return undefined;
131
+ const allowed = [...(opts.extraRoots ?? []).map((r) => resolveReal(resolve(cwd, expandPath(r, opts.home))))];
132
+ // gecici klasor: yazma serbest (derleme/ara dosyalar); duyarli yol her zaman sorulur.
133
+ if (write && !sensitive) allowed.push(resolveReal(tmpdir()));
134
+ if (!sensitive && allowed.some((a) => isInside(a, target, ci))) return undefined;
135
+ const reason = sensitive
136
+ ? `Proje dışındaki duyarlı bir dosya ${write ? "değiştirilmek" : "okunmak"} isteniyor: ${target}. Anahtar/parola içerebilir. Onaylıyor musun?`
137
+ : `Proje klasörünün DIŞINDA bir dosya ${toolName === "edit" ? "düzenlenmek" : "yazılmak"} isteniyor: ${target} (proje: ${root}). Onaylıyor musun?`;
138
+ return { path: target, sensitive, write, reason };
139
+ }
@@ -0,0 +1,228 @@
1
+ /**
2
+ * Izin koprusu (Pi cekirdegine dokunmadan): tehlikeli arac cagrisini calistirmadan once host'a
3
+ * (Pi RPC `extension_ui_request` select) sorar. Host Sera Code adaptoru ise kendi izin penceresini acar.
4
+ * Etkinlestirme: SERA_PERMISSIONS=1 (adaptor surec baslatirken verir). Kapaliyken hicbir etkisi yoktur.
5
+ */
6
+
7
+ import { classifyToolCall, type Decision, type PolicyOptions, patternCovers } from "./command-policy.ts";
8
+ import { type EgressAllowRule, egressAllowed } from "./egress-allow.ts";
9
+ import { lazyGateInfo } from "./lazy-mcp.ts";
10
+
11
+ export const PERMISSION_TITLE_PREFIX = "sera-permission:";
12
+ export type PermissionReply = "once" | "always" | "reject";
13
+
14
+ /** Sera izin adi: bash/powershell -> bash, edit/write -> edit. Tehlikeli degilse undefined. */
15
+ export function permissionKind(toolName: string, tools: ReadonlySet<string>): "bash" | "edit" | "mcp" | undefined {
16
+ // MCP sunucu araclari (mcp__<sunucu>__<arac>): "mcp" listede ise her biri sorulur.
17
+ if (toolName.startsWith("mcp__")) return tools.has("mcp") ? "mcp" : undefined;
18
+ if (toolName === "app_verify") return tools.has("bash") ? "bash" : undefined; // command-policy komutsuzu "safe" sayar
19
+ if (!tools.has(toolName)) return undefined;
20
+ if (toolName === "bash" || toolName === "powershell" || toolName === "proc") return "bash";
21
+ if (toolName === "edit" || toolName === "write" || toolName === "notebook_edit") return "edit";
22
+ return undefined;
23
+ }
24
+
25
+ export function parsePermissionTools(raw: string | undefined): Set<string> {
26
+ const v = (raw ?? "").trim() || "bash,powershell,proc,edit,write,mcp";
27
+ return new Set(
28
+ v
29
+ .split(",")
30
+ .map((s) => s.trim())
31
+ .filter(Boolean),
32
+ );
33
+ }
34
+
35
+ export interface SelectUI {
36
+ select(title: string, options: string[]): Promise<string | undefined>;
37
+ }
38
+
39
+ /** Uzak bir hizmete veri gonderebilecek MCP arac adlari (mcp__sunucu__arac): sticky + DISARI GONDERIM sorusu. */
40
+ const MCP_SEND_TOOL =
41
+ /(^|[_-])(send|post|publish|upload|push|email|mail|message|comment|webhook|notify|share|submit|deploy|tweet|invite|reply)([_-]|$)|create[_-](issue|pr|pull[_-]request|gist|repo|comment|message|post|ticket|page|release)/i;
42
+
43
+ export interface GateOptions {
44
+ /** git uzak adini (origin) gercek adrese cevirir; cwd arac cagrisinin calisma klasoru. */
45
+ resolveRemote?: (name: string, cwd?: string) => string | undefined;
46
+ /** true: yalniz DISARI GONDERIM sorulur (izin kopru ayari kapaliyken bile; `sera run`/-p dahil). */
47
+ egressOnly?: boolean;
48
+ /** Kullanicinin ayar dosyasindaki dar istisnalar (tam komut + tam uzak ad). */
49
+ egressAllow?: readonly EgressAllowRule[];
50
+ /** İzin sorusu zaman aşımı (ms): arayüz bu sürede yanıt vermezse güvenli tarafta REDDET (donma önleme). 0/undefined = kapalı. */
51
+ askTimeoutMs?: number;
52
+ }
53
+
54
+ export class PermissionGate {
55
+ private readonly always = new Set<string>();
56
+ private readonly tools: ReadonlySet<string>;
57
+ private readonly opts: GateOptions;
58
+ constructor(tools: ReadonlySet<string>, opts: GateOptions = {}) {
59
+ this.tools = tools;
60
+ this.opts = opts;
61
+ }
62
+
63
+ private allowed(kind: string, key: string | undefined, input: unknown): boolean {
64
+ if (kind !== "bash") return !!key && this.always.has(key);
65
+ const cmd = String((input as { command?: unknown } | undefined)?.command ?? "");
66
+ for (const k of this.always) if (k.startsWith("bash:") && patternCovers(k.slice(5), cmd)) return true;
67
+ return false;
68
+ }
69
+
70
+ /** undefined = calistir; {block} = engelle. */
71
+ async check(
72
+ toolName: string,
73
+ toolCallId: string,
74
+ input: unknown,
75
+ ui: SelectUI | undefined,
76
+ env: { cwd?: string } = {},
77
+ ): Promise<{ block: true; reason: string } | undefined> {
78
+ const isShell =
79
+ toolName === "bash" || toolName === "powershell" || toolName === "proc" || toolName === "app_verify";
80
+ // Tembel MCP giris noktasi (mcp__<ad>__lazy): kesif eylemleri (groups/tools/schema/stop) sorulmaz; "call" asil arac adiyla denetlenir.
81
+ const lazy = lazyGateInfo(toolName, input);
82
+ if (lazy?.discovery) return undefined;
83
+ const sendName = lazy?.tool ?? toolName.split("__").slice(2).join("_");
84
+ const policyOpts: PolicyOptions = {
85
+ resolveRemote: this.opts.resolveRemote && ((n) => this.opts.resolveRemote?.(n, env.cwd)),
86
+ };
87
+ // DISARI GONDERIM: arac/mod/izin ayari ne olursa olsun (yolo, alt ajan, test-duzelt, kopru kapali) ayni kapidan gecer.
88
+ let egress: Decision | undefined;
89
+ if (isShell) {
90
+ const dd = classifyToolCall(toolName, input, policyOpts);
91
+ if (dd?.egress && dd.verdict === "ask") egress = dd;
92
+ } else if (toolName.startsWith("mcp__") && MCP_SEND_TOOL.test(sendName)) {
93
+ egress = {
94
+ verdict: "ask",
95
+ sticky: true,
96
+ egress: true,
97
+ reason: `Bu araç verilerini harici bir hizmete gönderebilir: ${toolName}. Onaylıyor musun?`,
98
+ };
99
+ }
100
+ if (egress) {
101
+ const cmd = String((input as { command?: unknown } | undefined)?.command ?? "");
102
+ if (isShell && egressAllowed(this.opts.egressAllow ?? [], cmd, egress.target)) return undefined;
103
+ return this.ask(toolName, toolCallId, input, ui, isShell ? "bash" : "mcp", egress);
104
+ }
105
+ if (this.opts.egressOnly) return undefined;
106
+ const kind = permissionKind(toolName, this.tools);
107
+ if (!kind) return undefined;
108
+ // command-policy: zararsiz okuma komutu sorulmaz; geri donussuz komut/yol hic calismaz.
109
+ const d = kind === "mcp" ? undefined : classifyToolCall(toolName, input, policyOpts);
110
+ if (d?.verdict === "deny") return { block: true, reason: d.reason ?? "Bu islem engellendi." };
111
+ if (d?.verdict === "safe") return undefined;
112
+ // "always": bash icin KOMUT DESENI bazinda (npm test izni rm'ye gecmez), edit icin tur, MCP icin arac bazinda.
113
+ // sticky (riskli komut, korumali yol): "always" kapsamaz, her seferinde sorulur.
114
+ const key =
115
+ kind === "mcp" ? `mcp:${toolName}` : kind === "bash" ? (d?.pattern ? `bash:${d.pattern}` : undefined) : kind;
116
+ if (!d?.sticky && this.allowed(kind, key, input)) return undefined;
117
+ return this.ask(toolName, toolCallId, input, ui, kind, d, key);
118
+ }
119
+
120
+ /**
121
+ * Sandbox DIŞINDA çalıştırma onayı (kaçış yolu): mevcut izin penceresiyle (ui.select) sorar. Her seferinde sorulur
122
+ * ("always" hatırlanmaz: sticky). Arayüz yoksa REDDEDİLİR. undefined = onaylandı.
123
+ */
124
+ askUnsandboxed(
125
+ toolName: string,
126
+ toolCallId: string,
127
+ input: unknown,
128
+ ui: SelectUI | undefined,
129
+ ): Promise<{ block: true; reason: string } | undefined> {
130
+ const cmd = String((input as { command?: unknown } | undefined)?.command ?? "");
131
+ const reason = `Sandbox DIŞINDA çalıştırılsın mı? Bu komut dosya sistemine/ağa kısıtsız erişir: ${cmd.slice(0, 200)}`;
132
+ return this.ask(toolName, toolCallId, input, ui, "bash", { verdict: "ask", sticky: true, reason });
133
+ }
134
+
135
+ /**
136
+ * Ek koruma katmanlari (E2 supheli icerik, E4 proje disi yol) icin ayni onay yolu: ayni `extension_ui_request` select,
137
+ * ayni "once/always/reject" yaniti. Arayuz yoksa VARSAYILAN RED (gerekce modele gider). key verilirse ve sticky degilse
138
+ * "always" yalniz o anahtari kapsar.
139
+ */
140
+ async confirm(
141
+ toolName: string,
142
+ toolCallId: string,
143
+ input: unknown,
144
+ ui: SelectUI | undefined,
145
+ kind: "bash" | "edit" | "mcp",
146
+ reason: string,
147
+ opts: { sticky?: boolean; key?: string; egress?: boolean } = {},
148
+ ): Promise<{ block: true; reason: string } | undefined> {
149
+ if (opts.key && !opts.sticky && this.always.has(opts.key)) return undefined;
150
+ if (!ui)
151
+ return {
152
+ block: true,
153
+ reason: `${reason.replace(/ Onaylıyor musun\?$/, "")} Etkileşimsiz çalışma: onay alınamadı, araç ÇALIŞTIRILMADI. Bunu kullanıcı kendisi yapmalı ya da etkileşimli oturumda onaylamalı.`,
154
+ };
155
+ const d: Decision = { verdict: "ask", reason, sticky: opts.sticky ?? !opts.key, egress: opts.egress };
156
+ return this.ask(toolName, toolCallId, input, ui, kind, d, opts.key);
157
+ }
158
+
159
+ private async ask(
160
+ toolName: string,
161
+ toolCallId: string,
162
+ input: unknown,
163
+ ui: SelectUI | undefined,
164
+ kind: "bash" | "edit" | "mcp",
165
+ d: Decision | undefined,
166
+ key?: string,
167
+ ): Promise<{ block: true; reason: string } | undefined> {
168
+ if (!ui) {
169
+ // Etkilesimsiz calisma (TTY/arayuz yok): soru sorulamaz -> VARSAYILAN RED; gerekce modele ve kullaniciya gorunur.
170
+ return {
171
+ block: true,
172
+ reason: d?.egress
173
+ ? `Dışarı veri gönderimi onaylanamadı (etkileşimsiz çalışma: soru sorulamıyor), komut ÇALIŞTIRILMADI. ${d.reason ?? ""} Bunu kullanıcı kendisi çalıştırmalı ya da etkileşimli oturumda onaylamalı.`
174
+ : "Izin istenemedi (arayuz yok); arac calistirilmadi.",
175
+ };
176
+ }
177
+ const title =
178
+ PERMISSION_TITLE_PREFIX +
179
+ JSON.stringify({
180
+ kind,
181
+ tool: toolName,
182
+ callID: toolCallId,
183
+ input,
184
+ reason: d?.reason,
185
+ pattern: d?.sticky ? undefined : d?.pattern,
186
+ sticky: !!d?.sticky,
187
+ egress: !!d?.egress,
188
+ target: d?.target,
189
+ });
190
+ let reply: string | undefined;
191
+ let timedOut = false;
192
+ const timeoutMs = this.opts.askTimeoutMs;
193
+ try {
194
+ if (timeoutMs && timeoutMs > 0) {
195
+ let timer: ReturnType<typeof setTimeout> | undefined;
196
+ reply = await Promise.race([
197
+ ui.select(title, ["once", "always", "reject"]),
198
+ new Promise<string>((res) => {
199
+ timer = setTimeout(() => {
200
+ timedOut = true;
201
+ res("reject");
202
+ }, timeoutMs);
203
+ timer.unref();
204
+ }),
205
+ ]);
206
+ if (timer) clearTimeout(timer);
207
+ } else {
208
+ reply = await ui.select(title, ["once", "always", "reject"]);
209
+ }
210
+ } catch {
211
+ reply = undefined;
212
+ }
213
+ if (timedOut)
214
+ return {
215
+ block: true,
216
+ reason: `İzin sorusu ${Math.round(timeoutMs! / 1000)} sn içinde yanıtlanmadı; güvenli tarafta reddedildi (araç çalıştırılmadı). Gerekiyorsa tekrar dene.`,
217
+ };
218
+ if (reply === "once") return undefined;
219
+ if (reply === "always") {
220
+ if (!d?.sticky && key) this.always.add(key);
221
+ return undefined;
222
+ }
223
+ return {
224
+ block: true,
225
+ reason: "Kullanici bu arac cagrisini reddetti; arac calistirilmadi. Alternatif sor ya da farkli yaklas.",
226
+ };
227
+ }
228
+ }
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Policy chain: every Sera tool_call / tool_result policy runs through ONE registered handler, in a fixed order
3
+ * that does not depend on the order modules happen to be registered in (Pi runs handlers in registration order).
4
+ *
5
+ * tool_call: loop-brake -> sandbox-mark (strips the SERA_UNSANDBOXED=1 prefix so every later policy sees the clean command) -> agent-mode -> protected-paths -> skill -> hooks -> approval (/sera-mode: salt daraltir, soru sormaz; moda aykiri cagri workspace/taint sorusuna hic gelmez)
6
+ * -> workspace-guard (E4: proje disi yol onayi)
7
+ * -> taint-guard (E2: supheli icerik sonrasi riskli eylem onayi) -> permission -> checkpoint -> sandbox.
8
+ * Cheap deterministic checks first, asking the user last; checkpoint (pre-change snapshot) only for calls that
9
+ * passed every check, right before the tool touches files; sandbox (wraps the shell command / asks to run it unsandboxed) is LAST so every policy above judged the original command. The first block wins; later steps (including the
10
+ * permission prompt) do not run. Loop-brake is first on purpose: it must also count calls that a later step
11
+ * blocks, otherwise a model retrying a blocked write forever would never be stopped.
12
+ * tool_result: untrusted (E2: guvenilmez arac ciktisini isaretle + enjeksiyon taramasi; ilk adim, sonraki adimlarin ekledigi
13
+ * guvenilir notlar sarmalin disinda kalir) -> loop-brake -> output-cap (cuts one oversized text result, keeps head+tail) -> context-diet -> hooks -> checkpoint -> lsp (formatter + diagnostics after edit/write) -> test-fix (only observes edited paths during /test) -> no-progress (E5: ilerleme-yok notunu ekler).
14
+ * Each step sees the previous step's content; a step may only append to content, except output-cap, which shortens one oversized text part (full text spilled to a file).
15
+ *
16
+ * Steps not listed in the order arrays are rejected at registration, so a new module must pick its place here.
17
+ */
18
+
19
+ export interface CallVerdict {
20
+ block?: boolean;
21
+ reason?: string;
22
+ terminate?: boolean;
23
+ }
24
+
25
+ export const CALL_ORDER = [
26
+ "loop-brake",
27
+ "sandbox-mark",
28
+ "agent-mode",
29
+ "protected-paths",
30
+ "ofis-dosya",
31
+ "skill",
32
+ "hooks",
33
+ "approval",
34
+ "workspace-guard",
35
+ "taint-guard",
36
+ "permission",
37
+ "research",
38
+ "checkpoint",
39
+ "sandbox",
40
+ ] as const;
41
+ export const RESULT_ORDER = [
42
+ "untrusted",
43
+ "loop-brake",
44
+ "output-cap",
45
+ "context-diet",
46
+ "hooks",
47
+ "checkpoint",
48
+ "lsp",
49
+ "test-fix",
50
+ "sandbox",
51
+ "no-progress",
52
+ ] as const;
53
+
54
+ export type CallStepName = (typeof CALL_ORDER)[number];
55
+ export type ResultStepName = (typeof RESULT_ORDER)[number];
56
+
57
+ export interface CallStep<E, C> {
58
+ name: CallStepName;
59
+ run(event: E, ctx: C): CallVerdict | undefined | Promise<CallVerdict | undefined>;
60
+ }
61
+
62
+ export interface ResultEventLike {
63
+ content: unknown[];
64
+ }
65
+
66
+ export interface ResultStep<E extends ResultEventLike, C> {
67
+ name: ResultStepName;
68
+ run(event: E, ctx: C): { content: E["content"] } | undefined | Promise<{ content: E["content"] } | undefined>;
69
+ }
70
+
71
+ function ordered<S extends { name: string }>(order: readonly string[], steps: readonly S[]): S[] {
72
+ const seen = new Set<string>();
73
+ for (const s of steps) {
74
+ if (!order.includes(s.name)) throw new Error(`policy-chain: bilinmeyen adim '${s.name}'`);
75
+ if (seen.has(s.name)) throw new Error(`policy-chain: adim iki kez kayitli '${s.name}'`);
76
+ seen.add(s.name);
77
+ }
78
+ return [...steps].sort((a, b) => order.indexOf(a.name) - order.indexOf(b.name));
79
+ }
80
+
81
+ /** Builds the single tool_call handler. Steps may be given in any order. */
82
+ export function callChain<E, C>(steps: readonly CallStep<E, C>[]) {
83
+ const list = ordered(CALL_ORDER, steps);
84
+ return async (event: E, ctx: C): Promise<CallVerdict | undefined> => {
85
+ for (const step of list) {
86
+ let v: CallVerdict | undefined;
87
+ try {
88
+ v = await step.run(event, ctx);
89
+ } catch (e) {
90
+ // Fail-closed (kale): bir güvenlik kapısı hata verirse işlem ÇÖKMEZ, güvenli tarafta ENGELLENİR.
91
+ return {
92
+ block: true,
93
+ reason: `[Sera güvenlik] '${step.name}' kontrolü hata verdi; işlem güvenli tarafta engellendi: ${e instanceof Error ? e.message : String(e)}`,
94
+ };
95
+ }
96
+ if (v?.block) return v;
97
+ }
98
+ return undefined;
99
+ };
100
+ }
101
+
102
+ /** Builds the single tool_result handler. Returns undefined when no step changed the content. */
103
+ export function resultChain<E extends ResultEventLike, C>(steps: readonly ResultStep<E, C>[]) {
104
+ const list = ordered(RESULT_ORDER, steps);
105
+ return async (event: E, ctx: C): Promise<{ content: E["content"] } | undefined> => {
106
+ let current = event;
107
+ let changed = false;
108
+ for (const step of list) {
109
+ let r: { content: E["content"] } | undefined;
110
+ try {
111
+ r = await step.run(current, ctx);
112
+ } catch {
113
+ // Sonuç işleme adımı hata verirse ÇIKTI engellenmez/çökmez: adım atlanır, önceki içerik korunur.
114
+ continue;
115
+ }
116
+ if (!r) continue;
117
+ current = { ...current, content: r.content };
118
+ changed = true;
119
+ }
120
+ return changed ? { content: current.content } : undefined;
121
+ };
122
+ }
@@ -0,0 +1,71 @@
1
+ // Sera model price table: USD per 1M tokens. Source: owner-provided price list (2026-10-27).
2
+ // Pricing is resolved by (a) explicit SERA_PRICE_MODEL / config, (b) substring match of the model id,
3
+ // (c) fallback to the cost Pi computed from its own catalog (usage.cost.total).
4
+
5
+ export interface Price {
6
+ input: number;
7
+ output: number;
8
+ cacheRead: number;
9
+ }
10
+
11
+ export interface UsageLike {
12
+ input: number; // uncached input tokens (Pi semantics: prompt - cacheRead - cacheWrite)
13
+ output: number;
14
+ cacheRead: number;
15
+ cacheWrite?: number;
16
+ cost?: { total?: number };
17
+ }
18
+
19
+ export const PRICE_TABLE: Record<string, Price> = {
20
+ "deepseek-v4-flash": { input: 0.09, output: 0.18, cacheRead: 0.018 },
21
+ "mimo-v2.6-pro": { input: 0.43, output: 0.87, cacheRead: 0.043 },
22
+ "mimo-v2.6-flash": { input: 0.14, output: 0.28, cacheRead: 0.014 },
23
+ "glm-5.3-flash": { input: 0.15, output: 0.5, cacheRead: 0.015 },
24
+ };
25
+
26
+ export function resolvePrice(modelId: string | undefined, explicitKey?: string): Price | undefined {
27
+ if (explicitKey) {
28
+ const k = explicitKey.toLowerCase();
29
+ if (PRICE_TABLE[k]) return PRICE_TABLE[k];
30
+ }
31
+ if (!modelId) return undefined;
32
+ const id = modelId.toLowerCase();
33
+ for (const [key, price] of Object.entries(PRICE_TABLE)) if (id.includes(key)) return price;
34
+ return undefined;
35
+ }
36
+
37
+ /**
38
+ * Fiyati bilinmeyen modeller icin IHTIYATLI varsayilan (USD / 1M token). Bilinen en pahali kademeden
39
+ * (PRICE_TABLE) belirgin sekilde yuksek tutulur: USD tavani kor kalmasin, asiri harcama yerine erken dursun.
40
+ * Pi katalogu `usage.cost.total` > 0 verdiyse o gercek rakam kullanilir; yalniz 0/yok ise bu sabit devreye girer.
41
+ */
42
+ export const FALLBACK_PRICE: Price = { input: 3, output: 15, cacheRead: 0.3 };
43
+
44
+ export const UNPRICED_WARNING = "Bu modelin fiyati bilinmiyor; butce tahmini ihtiyatli fiyatla hesaplaniyor";
45
+
46
+ function priced(usage: UsageLike, price: Price): number {
47
+ return (
48
+ ((usage.input + (usage.cacheWrite ?? 0)) * price.input +
49
+ usage.output * price.output +
50
+ usage.cacheRead * price.cacheRead) /
51
+ 1_000_000
52
+ );
53
+ }
54
+
55
+ /** Cost of one call in USD; `fallback` = fiyat bilinmiyordu, ihtiyatli sabit kullanildi. cacheWrite is billed at the input rate. */
56
+ export function costDetail(
57
+ usage: UsageLike,
58
+ price: Price | undefined,
59
+ catalogKnown = false,
60
+ ): { usd: number; fallback: boolean } {
61
+ if (price) return { usd: priced(usage, price), fallback: false };
62
+ const catalog = usage.cost?.total;
63
+ if (catalog !== undefined && catalog > 0) return { usd: catalog, fallback: false };
64
+ // Katalog bu modelin maliyet alanlarini TANIMLIYOR (0 dahil) = acikca ucretsiz: $0, uyari yok.
65
+ if (catalogKnown) return { usd: catalog ?? 0, fallback: false };
66
+ return { usd: priced(usage, FALLBACK_PRICE), fallback: true };
67
+ }
68
+
69
+ export function costOf(usage: UsageLike, price: Price | undefined, catalogKnown = false): number {
70
+ return costDetail(usage, price, catalogKnown).usd;
71
+ }