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.
Files changed (457) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE-SERA.md +33 -0
  3. package/README.md +27 -2
  4. package/THIRD_PARTY_NOTICES.md +68 -0
  5. package/bin/sera.mjs +145 -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-6QGV3IWD.js +6 -0
  15. package/dist/bundle/chunks/chunk-7CBJINYJ.js +20 -0
  16. package/dist/bundle/chunks/chunk-7DDKXS2Q.js +2 -0
  17. package/dist/bundle/chunks/chunk-7RZ5BS7U.js +2 -0
  18. package/dist/bundle/chunks/chunk-7ZC4UXSL.js +2 -0
  19. package/dist/bundle/chunks/chunk-AZC5WTED.js +1222 -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-HODJBMOY.js +9 -0
  26. package/dist/bundle/chunks/chunk-HQBQWHLD.js +7 -0
  27. package/dist/bundle/chunks/chunk-HQJBN2MC.js +2 -0
  28. package/dist/bundle/chunks/chunk-JXWJOIH4.js +2 -0
  29. package/dist/bundle/chunks/chunk-KXU77PUU.js +4 -0
  30. package/dist/bundle/chunks/chunk-L2ZPNLYD.js +2 -0
  31. package/dist/bundle/chunks/chunk-LOMPDCMP.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-Z2V3PTLI.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 +377 -0
  181. package/lib/provider.js +71 -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 +2410 -0
  383. package/sera-core/src/fs-tools.ts +448 -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/model-list.ts +108 -0
  412. package/sera-core/src/no-progress.ts +177 -0
  413. package/sera-core/src/notebook-tool.ts +179 -0
  414. package/sera-core/src/ofis.ts +473 -0
  415. package/sera-core/src/path-guard.ts +139 -0
  416. package/sera-core/src/permission-bridge.ts +228 -0
  417. package/sera-core/src/policy-chain.ts +122 -0
  418. package/sera-core/src/pricing.ts +71 -0
  419. package/sera-core/src/proc.ts +149 -0
  420. package/sera-core/src/rea.ts +188 -0
  421. package/sera-core/src/repo-map.ts +230 -0
  422. package/sera-core/src/research.ts +347 -0
  423. package/sera-core/src/rules-memory.ts +227 -0
  424. package/sera-core/src/sandbox.ts +476 -0
  425. package/sera-core/src/server-error.ts +78 -0
  426. package/sera-core/src/skills.ts +268 -0
  427. package/sera-core/src/snapshot.ts +143 -0
  428. package/sera-core/src/spec-gate.ts +112 -0
  429. package/sera-core/src/subagent.ts +261 -0
  430. package/sera-core/src/teslim.ts +121 -0
  431. package/sera-core/src/test-fix.ts +184 -0
  432. package/sera-core/src/todo-question.ts +163 -0
  433. package/sera-core/src/turn-snapshots.ts +126 -0
  434. package/sera-core/src/tuval/arac.ts +338 -0
  435. package/sera-core/src/tuval/arsiv.ts +106 -0
  436. package/sera-core/src/tuval/belge.ts +216 -0
  437. package/sera-core/src/tuval/birlestir.ts +282 -0
  438. package/sera-core/src/tuval/disa.ts +235 -0
  439. package/sera-core/src/tuval/editor.ts +583 -0
  440. package/sera-core/src/tuval/film-cekirdek.ts +170 -0
  441. package/sera-core/src/tuval/film-disa.ts +188 -0
  442. package/sera-core/src/tuval/film-oynatici.ts +307 -0
  443. package/sera-core/src/tuval/kimlik.ts +156 -0
  444. package/sera-core/src/tuval/pano.ts +763 -0
  445. package/sera-core/src/tuval/proje.ts +728 -0
  446. package/sera-core/src/tuval/sistem-cekirdek.ts +167 -0
  447. package/sera-core/src/tuval/sistem.ts +328 -0
  448. package/sera-core/src/tuval/sunucu.ts +413 -0
  449. package/sera-core/src/tuval/uretim.ts +24 -0
  450. package/sera-core/src/tuval/veri-cekirdek.ts +477 -0
  451. package/sera-core/src/tuval/xlsx.ts +215 -0
  452. package/sera-core/src/tuval/zip.ts +163 -0
  453. package/sera-core/src/untrusted.ts +201 -0
  454. package/sera-core/src/video-edit-tool.ts +411 -0
  455. package/sera-core/src/video-tool.ts +217 -0
  456. package/sera-core/src/web-tools.ts +257 -0
  457. package/sera-core/src/zk.ts +104 -0
@@ -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
+ }
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Arka plan surec yoneticisi ("proc" araci): dev sunucusu, izleyici, uzun test gibi surecleri bloke etmeden calistirir;
3
+ * cikti okunur, stdin'e yazilir, kapatilir. Pi'nin yerlesik `bash` araci her komutu bitene kadar bekler; bu arac onun tamamlayicisidir.
4
+ *
5
+ * SINIR (durust): gercek PTY DEGIL. stdin/stdout/stderr boru (pipe) ile yonetilir; TTY isteyen etkilesimli programlar
6
+ * (vim, ssh parola istemi, renkli ilerleme cubuklari) boru modunda calisir. Yerel native PTY bagimliligi eklenmedi.
7
+ * Guvenlik: komutlar "bash" ile AYNI izin/komut-politikasindan gecer (command-policy, permission-bridge, plan modu).
8
+ */
9
+ import { type ChildProcess, spawn, spawnSync } from "node:child_process";
10
+ import { resolveCommand } from "./lsp.ts";
11
+
12
+ export interface ProcInfo {
13
+ id: string;
14
+ command: string;
15
+ status: "running" | "exited" | "killed";
16
+ exitCode: number | null;
17
+ startedAt: number;
18
+ bytes: number;
19
+ }
20
+
21
+ interface Entry extends ProcInfo {
22
+ child: ChildProcess;
23
+ buf: string;
24
+ /** buf'in basindan atilan karakter sayisi (ofset hesabi icin). */
25
+ dropped: number;
26
+ }
27
+
28
+ const MAX_BUF = 64 * 1024;
29
+
30
+ export class ProcManager {
31
+ private procs = new Map<string, Entry>();
32
+ private seq = 0;
33
+ private readonly max: number;
34
+
35
+ constructor(max = 5) {
36
+ this.max = max;
37
+ }
38
+
39
+ private shellFor(command: string): { cmd: string; args: string[] } {
40
+ if (process.platform !== "win32") return { cmd: "sh", args: ["-c", command] };
41
+ const bash = resolveCommand("bash", process.cwd());
42
+ // Git Bash varsa onu kullan (Pi'nin bash araciyla ayni sozdizimi); yoksa cmd.exe
43
+ return bash ? { cmd: bash, args: ["-c", command] } : { cmd: "cmd.exe", args: ["/d", "/s", "/c", command] };
44
+ }
45
+
46
+ start(command: string, cwd: string, env: Record<string, string | undefined> = process.env): ProcInfo {
47
+ const running = [...this.procs.values()].filter((p) => p.status === "running").length;
48
+ if (running >= this.max)
49
+ throw new Error(`Zaten ${running} arka plan sureci calisiyor (en fazla ${this.max}); birini kapat.`);
50
+ const { cmd, args } = this.shellFor(command);
51
+ const child = spawn(cmd, args, {
52
+ cwd,
53
+ env: env as NodeJS.ProcessEnv,
54
+ windowsHide: true,
55
+ detached: process.platform !== "win32",
56
+ stdio: ["pipe", "pipe", "pipe"],
57
+ });
58
+ const e: Entry = {
59
+ id: `p${++this.seq}`,
60
+ command,
61
+ status: "running",
62
+ exitCode: null,
63
+ startedAt: Date.now(),
64
+ bytes: 0,
65
+ child,
66
+ buf: "",
67
+ dropped: 0,
68
+ };
69
+ const add = (c: Buffer) => {
70
+ const t = c.toString("utf8");
71
+ e.bytes += t.length;
72
+ e.buf += t;
73
+ if (e.buf.length > MAX_BUF) {
74
+ const cut = e.buf.length - MAX_BUF;
75
+ e.buf = e.buf.slice(cut);
76
+ e.dropped += cut;
77
+ }
78
+ };
79
+ child.stdout?.on("data", add);
80
+ child.stderr?.on("data", add);
81
+ child.on("error", (err) => {
82
+ add(Buffer.from(`[surec baslatilamadi: ${err.message}]`));
83
+ if (e.status === "running") e.status = "exited";
84
+ });
85
+ child.on("close", (code) => {
86
+ if (e.status === "running") e.status = "exited";
87
+ e.exitCode = code;
88
+ });
89
+ this.procs.set(e.id, e);
90
+ return this.info(e);
91
+ }
92
+
93
+ private info(e: Entry): ProcInfo {
94
+ return {
95
+ id: e.id,
96
+ command: e.command,
97
+ status: e.status,
98
+ exitCode: e.exitCode,
99
+ startedAt: e.startedAt,
100
+ bytes: e.bytes,
101
+ };
102
+ }
103
+
104
+ list(): ProcInfo[] {
105
+ return [...this.procs.values()].map((e) => this.info(e));
106
+ }
107
+
108
+ /** Cikti: `since` (onceki okumadan donen `next`) sonrasi; yeni baslamissa hepsi. Tampondan dusenler "[...]" ile belirtilir. */
109
+ read(id: string, since = 0): { info: ProcInfo; text: string; next: number } {
110
+ const e = this.procs.get(id);
111
+ if (!e) throw new Error(`Bilinmeyen surec: ${id}`);
112
+ const total = e.dropped + e.buf.length;
113
+ const from = Math.max(since, e.dropped);
114
+ const lost = since < e.dropped ? "[... eski cikti tampondan dustu ...]\n" : "";
115
+ return { info: this.info(e), text: lost + e.buf.slice(from - e.dropped), next: total };
116
+ }
117
+
118
+ write(id: string, text: string): void {
119
+ const e = this.procs.get(id);
120
+ if (!e) throw new Error(`Bilinmeyen surec: ${id}`);
121
+ if (e.status !== "running") throw new Error(`${id} calismiyor (${e.status}).`);
122
+ e.child.stdin?.write(text.endsWith("\n") ? text : `${text}\n`);
123
+ }
124
+
125
+ kill(id: string): ProcInfo {
126
+ const e = this.procs.get(id);
127
+ if (!e) throw new Error(`Bilinmeyen surec: ${id}`);
128
+ if (e.status === "running") {
129
+ e.status = "killed";
130
+ killTree(e.child);
131
+ }
132
+ return this.info(e);
133
+ }
134
+
135
+ killAll(): void {
136
+ for (const e of this.procs.values()) if (e.status === "running") this.kill(e.id);
137
+ }
138
+ }
139
+
140
+ export function killTree(child: ChildProcess): void {
141
+ if (child.pid === undefined) return;
142
+ try {
143
+ if (process.platform === "win32")
144
+ spawnSync("taskkill", ["/pid", String(child.pid), "/T", "/F"], { windowsHide: true });
145
+ else process.kill(-child.pid, "SIGKILL");
146
+ } catch {
147
+ // zaten kapali
148
+ }
149
+ }