oh-my-opencode 5.1.84 → 5.1.86

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 (405) hide show
  1. package/.agents/command/remove-deadcode.md +1 -1
  2. package/.agents/skills/remove-deadcode/SKILL.md +1 -1
  3. package/.agents/skills/work-with-pr/SKILL.md +2 -2
  4. package/.opencode/command/remove-deadcode.md +1 -1
  5. package/.opencode/skills/work-with-pr/SKILL.md +2 -2
  6. package/THIRD-PARTY-NOTICES.md +9 -3
  7. package/dist/cli/index.js +1022 -842
  8. package/dist/cli/service-auth/devices.d.ts +5 -2
  9. package/dist/cli-node/index.js +1022 -842
  10. package/dist/config/schema/agent-names.d.ts +1 -0
  11. package/dist/index.js +180 -205
  12. package/dist/skills/browser/SKILL.md +4 -1
  13. package/dist/skills/browser/references/commands.md +5 -2
  14. package/dist/skills/browser/references/desktop.md +1 -0
  15. package/dist/skills/browser/references/owned-engine/README.md +2 -0
  16. package/dist/skills/browser/references/owned-engine/frames-and-humans.md +2 -0
  17. package/dist/skills/browser/references/owned-engine/network.md +10 -5
  18. package/dist/skills/browser/references/recipes/1password.md +2 -0
  19. package/dist/skills/browser/runtime/omowright/index.js +11 -11
  20. package/dist/skills/browser/runtime/omowright/manifest.json +4 -4
  21. package/dist/skills/debugging/SKILL.md +1 -1
  22. package/dist/skills/git/SKILL.md +62 -0
  23. package/dist/skills/git/agents/openai.yaml +13 -0
  24. package/dist/skills/github/SKILL.md +94 -0
  25. package/dist/skills/github/references/branch-rules.md +129 -0
  26. package/dist/skills/github/references/evidence-attachments.md +16 -0
  27. package/dist/skills/github/references/repo-setup.md +152 -0
  28. package/dist/skills/github/references/waiting.md +52 -0
  29. package/dist/skills/github/references/workflows.md +161 -0
  30. package/dist/skills/github/scripts/cli.ts +8 -0
  31. package/dist/skills/github/scripts/package.json +12 -0
  32. package/dist/skills/github/scripts/sdk.ts +11 -0
  33. package/dist/skills/github/scripts/src/account.ts +243 -0
  34. package/dist/skills/github/scripts/src/actions-write.ts +86 -0
  35. package/dist/skills/github/scripts/src/actions.ts +210 -0
  36. package/dist/skills/github/scripts/src/attestations.ts +136 -0
  37. package/dist/skills/github/scripts/src/blake2b.ts +102 -0
  38. package/dist/skills/github/scripts/src/branch-protection.ts +192 -0
  39. package/dist/skills/github/scripts/src/caches.ts +105 -0
  40. package/dist/skills/github/scripts/src/checks.ts +107 -0
  41. package/dist/skills/github/scripts/src/codespaces.ts +230 -0
  42. package/dist/skills/github/scripts/src/conversation-lock.ts +50 -0
  43. package/dist/skills/github/scripts/src/discussion-list.ts +126 -0
  44. package/dist/skills/github/scripts/src/discussion-lookup.ts +127 -0
  45. package/dist/skills/github/scripts/src/discussions.ts +234 -0
  46. package/dist/skills/github/scripts/src/env.ts +100 -0
  47. package/dist/skills/github/scripts/src/errors.ts +79 -0
  48. package/dist/skills/github/scripts/src/fields.ts +27 -0
  49. package/dist/skills/github/scripts/src/gist-shape.ts +58 -0
  50. package/dist/skills/github/scripts/src/gists-write.ts +130 -0
  51. package/dist/skills/github/scripts/src/gists.ts +118 -0
  52. package/dist/skills/github/scripts/src/git-auth.ts +46 -0
  53. package/dist/skills/github/scripts/src/http.ts +159 -0
  54. package/dist/skills/github/scripts/src/issue-develop.ts +118 -0
  55. package/dist/skills/github/scripts/src/issues-extra.ts +135 -0
  56. package/dist/skills/github/scripts/src/issues-write.ts +174 -0
  57. package/dist/skills/github/scripts/src/issues.ts +156 -0
  58. package/dist/skills/github/scripts/src/keys.ts +176 -0
  59. package/dist/skills/github/scripts/src/labels.ts +209 -0
  60. package/dist/skills/github/scripts/src/merge.ts +115 -0
  61. package/dist/skills/github/scripts/src/poly1305.ts +22 -0
  62. package/dist/skills/github/scripts/src/pr-checkout.ts +92 -0
  63. package/dist/skills/github/scripts/src/pr-view.ts +106 -0
  64. package/dist/skills/github/scripts/src/project-fields.ts +144 -0
  65. package/dist/skills/github/scripts/src/project-item-edit.ts +153 -0
  66. package/dist/skills/github/scripts/src/project-items.ts +191 -0
  67. package/dist/skills/github/scripts/src/project-links.ts +104 -0
  68. package/dist/skills/github/scripts/src/project-ref.ts +145 -0
  69. package/dist/skills/github/scripts/src/project-state.ts +99 -0
  70. package/dist/skills/github/scripts/src/projects.ts +158 -0
  71. package/dist/skills/github/scripts/src/pulls-extra.ts +165 -0
  72. package/dist/skills/github/scripts/src/pulls-read.ts +176 -0
  73. package/dist/skills/github/scripts/src/pulls-review.ts +206 -0
  74. package/dist/skills/github/scripts/src/pulls-write.ts +187 -0
  75. package/dist/skills/github/scripts/src/raw.ts +78 -0
  76. package/dist/skills/github/scripts/src/read.ts +77 -0
  77. package/dist/skills/github/scripts/src/release-assets.ts +111 -0
  78. package/dist/skills/github/scripts/src/release-download.ts +151 -0
  79. package/dist/skills/github/scripts/src/release-write.ts +197 -0
  80. package/dist/skills/github/scripts/src/repo-admin.ts +112 -0
  81. package/dist/skills/github/scripts/src/repo-content.ts +187 -0
  82. package/dist/skills/github/scripts/src/repo-create.ts +139 -0
  83. package/dist/skills/github/scripts/src/repo-extras.ts +217 -0
  84. package/dist/skills/github/scripts/src/repo-list.ts +143 -0
  85. package/dist/skills/github/scripts/src/repo-settings.ts +176 -0
  86. package/dist/skills/github/scripts/src/repo-sync.ts +81 -0
  87. package/dist/skills/github/scripts/src/repo-url.ts +104 -0
  88. package/dist/skills/github/scripts/src/repos.ts +87 -0
  89. package/dist/skills/github/scripts/src/ruleset-shape.ts +96 -0
  90. package/dist/skills/github/scripts/src/rulesets-write.ts +124 -0
  91. package/dist/skills/github/scripts/src/rulesets.ts +80 -0
  92. package/dist/skills/github/scripts/src/run-download.ts +88 -0
  93. package/dist/skills/github/scripts/src/salsa20.ts +97 -0
  94. package/dist/skills/github/scripts/src/scopes.ts +165 -0
  95. package/dist/skills/github/scripts/src/sealed-box.ts +75 -0
  96. package/dist/skills/github/scripts/src/search-commits.ts +114 -0
  97. package/dist/skills/github/scripts/src/search.ts +116 -0
  98. package/dist/skills/github/scripts/src/secrets.ts +131 -0
  99. package/dist/skills/github/scripts/src/snappy.ts +57 -0
  100. package/dist/skills/github/scripts/src/status-search.ts +55 -0
  101. package/dist/skills/github/scripts/src/transfer.ts +97 -0
  102. package/dist/skills/github/scripts/src/types.ts +75 -0
  103. package/dist/skills/github/scripts/src/variables.ts +86 -0
  104. package/dist/skills/github/scripts/src/wait.ts +164 -0
  105. package/dist/skills/github/scripts/src/wire.ts +159 -0
  106. package/dist/skills/github/scripts/src/workflows.ts +144 -0
  107. package/dist/skills/github/scripts/src/zip.ts +104 -0
  108. package/dist/skills/github/scripts/surface.ts +106 -0
  109. package/dist/skills/github/scripts/vendor/surface/SOURCE.json +15 -0
  110. package/dist/skills/github/scripts/vendor/surface/cli.ts +203 -0
  111. package/dist/skills/github/scripts/vendor/surface/flags.ts +195 -0
  112. package/dist/skills/github/scripts/vendor/surface/help.ts +89 -0
  113. package/dist/skills/github/scripts/vendor/surface/http.ts +180 -0
  114. package/dist/skills/github/scripts/vendor/surface/index.ts +44 -0
  115. package/dist/skills/github/scripts/vendor/surface/mcp.ts +241 -0
  116. package/dist/skills/github/scripts/vendor/surface/schema.ts +200 -0
  117. package/dist/skills/github/scripts/vendor/surface/stdio.ts +54 -0
  118. package/dist/skills/github/scripts/vendor/surface/surface.ts +250 -0
  119. package/dist/skills/github/scripts/vendor/surface/tools.ts +80 -0
  120. package/dist/skills/programming/SKILL.md +1 -1
  121. package/dist/skills/ulw-execute/SKILL.md +1 -1
  122. package/dist/tui.js +30 -27
  123. package/package.json +28 -26
  124. package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
  125. package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
  126. package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
  127. package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
  128. package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
  129. package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
  130. package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
  131. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
  132. package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
  133. package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +2 -2
  134. package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
  135. package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
  136. package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
  137. package/packages/omo-codex/plugin/components/rules/package.json +1 -1
  138. package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
  139. package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
  140. package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
  141. package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
  142. package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
  143. package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
  144. package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +1 -1
  145. package/packages/omo-codex/plugin/components/ulw-execute-continuation/package.json +1 -1
  146. package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +5 -5
  147. package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
  148. package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/SKILL.md +1 -1
  149. package/packages/omo-codex/plugin/components/ulw-loop/skills/ulw-loop/references/full-workflow.md +3 -3
  150. package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
  151. package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
  152. package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
  153. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
  154. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
  155. package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
  156. package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
  157. package/packages/omo-codex/plugin/hooks/post-tool-use-recording-spawn-admission.json +1 -1
  158. package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
  159. package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
  160. package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
  161. package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
  162. package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
  163. package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
  164. package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
  165. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +1 -1
  166. package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
  167. package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
  168. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
  169. package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
  170. package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
  171. package/packages/omo-codex/plugin/package-lock.json +12 -12
  172. package/packages/omo-codex/plugin/package.json +1 -1
  173. package/packages/omo-codex/plugin/skills/browser/SKILL.md +4 -1
  174. package/packages/omo-codex/plugin/skills/browser/references/commands.md +5 -2
  175. package/packages/omo-codex/plugin/skills/browser/references/desktop.md +1 -0
  176. package/packages/omo-codex/plugin/skills/browser/references/owned-engine/README.md +2 -0
  177. package/packages/omo-codex/plugin/skills/browser/references/owned-engine/frames-and-humans.md +2 -0
  178. package/packages/omo-codex/plugin/skills/browser/references/owned-engine/network.md +10 -5
  179. package/packages/omo-codex/plugin/skills/browser/references/recipes/1password.md +2 -0
  180. package/packages/omo-codex/plugin/skills/browser/runtime/omowright/index.js +11 -11
  181. package/packages/omo-codex/plugin/skills/browser/runtime/omowright/manifest.json +4 -4
  182. package/packages/omo-codex/plugin/skills/debugging/SKILL.md +1 -1
  183. package/packages/omo-codex/plugin/skills/git/SKILL.md +62 -0
  184. package/packages/omo-codex/plugin/skills/git/agents/openai.yaml +13 -0
  185. package/packages/omo-codex/plugin/skills/github/SKILL.md +94 -0
  186. package/packages/omo-codex/plugin/skills/github/agents/openai.yaml +2 -0
  187. package/packages/omo-codex/plugin/skills/github/references/branch-rules.md +129 -0
  188. package/packages/omo-codex/plugin/skills/github/references/evidence-attachments.md +16 -0
  189. package/packages/omo-codex/plugin/skills/github/references/repo-setup.md +152 -0
  190. package/packages/omo-codex/plugin/skills/github/references/waiting.md +52 -0
  191. package/packages/omo-codex/plugin/skills/github/references/workflows.md +161 -0
  192. package/packages/omo-codex/plugin/skills/github/scripts/cli.ts +8 -0
  193. package/packages/omo-codex/plugin/skills/github/scripts/package.json +12 -0
  194. package/packages/omo-codex/plugin/skills/github/scripts/sdk.ts +11 -0
  195. package/packages/omo-codex/plugin/skills/github/scripts/src/account.ts +243 -0
  196. package/packages/omo-codex/plugin/skills/github/scripts/src/actions-write.ts +86 -0
  197. package/packages/omo-codex/plugin/skills/github/scripts/src/actions.ts +210 -0
  198. package/packages/omo-codex/plugin/skills/github/scripts/src/attestations.ts +136 -0
  199. package/packages/omo-codex/plugin/skills/github/scripts/src/blake2b.ts +102 -0
  200. package/packages/omo-codex/plugin/skills/github/scripts/src/branch-protection.ts +192 -0
  201. package/packages/omo-codex/plugin/skills/github/scripts/src/caches.ts +105 -0
  202. package/packages/omo-codex/plugin/skills/github/scripts/src/checks.ts +107 -0
  203. package/packages/omo-codex/plugin/skills/github/scripts/src/codespaces.ts +230 -0
  204. package/packages/omo-codex/plugin/skills/github/scripts/src/conversation-lock.ts +50 -0
  205. package/packages/omo-codex/plugin/skills/github/scripts/src/discussion-list.ts +126 -0
  206. package/packages/omo-codex/plugin/skills/github/scripts/src/discussion-lookup.ts +127 -0
  207. package/packages/omo-codex/plugin/skills/github/scripts/src/discussions.ts +234 -0
  208. package/packages/omo-codex/plugin/skills/github/scripts/src/env.ts +100 -0
  209. package/packages/omo-codex/plugin/skills/github/scripts/src/errors.ts +79 -0
  210. package/packages/omo-codex/plugin/skills/github/scripts/src/fields.ts +27 -0
  211. package/packages/omo-codex/plugin/skills/github/scripts/src/gist-shape.ts +58 -0
  212. package/packages/omo-codex/plugin/skills/github/scripts/src/gists-write.ts +130 -0
  213. package/packages/omo-codex/plugin/skills/github/scripts/src/gists.ts +118 -0
  214. package/packages/omo-codex/plugin/skills/github/scripts/src/git-auth.ts +46 -0
  215. package/packages/omo-codex/plugin/skills/github/scripts/src/http.ts +159 -0
  216. package/packages/omo-codex/plugin/skills/github/scripts/src/issue-develop.ts +118 -0
  217. package/packages/omo-codex/plugin/skills/github/scripts/src/issues-extra.ts +135 -0
  218. package/packages/omo-codex/plugin/skills/github/scripts/src/issues-write.ts +174 -0
  219. package/packages/omo-codex/plugin/skills/github/scripts/src/issues.ts +156 -0
  220. package/packages/omo-codex/plugin/skills/github/scripts/src/keys.ts +176 -0
  221. package/packages/omo-codex/plugin/skills/github/scripts/src/labels.ts +209 -0
  222. package/packages/omo-codex/plugin/skills/github/scripts/src/merge.ts +115 -0
  223. package/packages/omo-codex/plugin/skills/github/scripts/src/poly1305.ts +22 -0
  224. package/packages/omo-codex/plugin/skills/github/scripts/src/pr-checkout.ts +92 -0
  225. package/packages/omo-codex/plugin/skills/github/scripts/src/pr-view.ts +106 -0
  226. package/packages/omo-codex/plugin/skills/github/scripts/src/project-fields.ts +144 -0
  227. package/packages/omo-codex/plugin/skills/github/scripts/src/project-item-edit.ts +153 -0
  228. package/packages/omo-codex/plugin/skills/github/scripts/src/project-items.ts +191 -0
  229. package/packages/omo-codex/plugin/skills/github/scripts/src/project-links.ts +104 -0
  230. package/packages/omo-codex/plugin/skills/github/scripts/src/project-ref.ts +145 -0
  231. package/packages/omo-codex/plugin/skills/github/scripts/src/project-state.ts +99 -0
  232. package/packages/omo-codex/plugin/skills/github/scripts/src/projects.ts +158 -0
  233. package/packages/omo-codex/plugin/skills/github/scripts/src/pulls-extra.ts +165 -0
  234. package/packages/omo-codex/plugin/skills/github/scripts/src/pulls-read.ts +176 -0
  235. package/packages/omo-codex/plugin/skills/github/scripts/src/pulls-review.ts +206 -0
  236. package/packages/omo-codex/plugin/skills/github/scripts/src/pulls-write.ts +187 -0
  237. package/packages/omo-codex/plugin/skills/github/scripts/src/raw.ts +78 -0
  238. package/packages/omo-codex/plugin/skills/github/scripts/src/read.ts +77 -0
  239. package/packages/omo-codex/plugin/skills/github/scripts/src/release-assets.ts +111 -0
  240. package/packages/omo-codex/plugin/skills/github/scripts/src/release-download.ts +151 -0
  241. package/packages/omo-codex/plugin/skills/github/scripts/src/release-write.ts +197 -0
  242. package/packages/omo-codex/plugin/skills/github/scripts/src/repo-admin.ts +112 -0
  243. package/packages/omo-codex/plugin/skills/github/scripts/src/repo-content.ts +187 -0
  244. package/packages/omo-codex/plugin/skills/github/scripts/src/repo-create.ts +139 -0
  245. package/packages/omo-codex/plugin/skills/github/scripts/src/repo-extras.ts +217 -0
  246. package/packages/omo-codex/plugin/skills/github/scripts/src/repo-list.ts +143 -0
  247. package/packages/omo-codex/plugin/skills/github/scripts/src/repo-settings.ts +176 -0
  248. package/packages/omo-codex/plugin/skills/github/scripts/src/repo-sync.ts +81 -0
  249. package/packages/omo-codex/plugin/skills/github/scripts/src/repo-url.ts +104 -0
  250. package/packages/omo-codex/plugin/skills/github/scripts/src/repos.ts +87 -0
  251. package/packages/omo-codex/plugin/skills/github/scripts/src/ruleset-shape.ts +96 -0
  252. package/packages/omo-codex/plugin/skills/github/scripts/src/rulesets-write.ts +124 -0
  253. package/packages/omo-codex/plugin/skills/github/scripts/src/rulesets.ts +80 -0
  254. package/packages/omo-codex/plugin/skills/github/scripts/src/run-download.ts +88 -0
  255. package/packages/omo-codex/plugin/skills/github/scripts/src/salsa20.ts +97 -0
  256. package/packages/omo-codex/plugin/skills/github/scripts/src/scopes.ts +165 -0
  257. package/packages/omo-codex/plugin/skills/github/scripts/src/sealed-box.ts +75 -0
  258. package/packages/omo-codex/plugin/skills/github/scripts/src/search-commits.ts +114 -0
  259. package/packages/omo-codex/plugin/skills/github/scripts/src/search.ts +116 -0
  260. package/packages/omo-codex/plugin/skills/github/scripts/src/secrets.ts +131 -0
  261. package/packages/omo-codex/plugin/skills/github/scripts/src/snappy.ts +57 -0
  262. package/packages/omo-codex/plugin/skills/github/scripts/src/status-search.ts +55 -0
  263. package/packages/omo-codex/plugin/skills/github/scripts/src/transfer.ts +97 -0
  264. package/packages/omo-codex/plugin/skills/github/scripts/src/types.ts +75 -0
  265. package/packages/omo-codex/plugin/skills/github/scripts/src/variables.ts +86 -0
  266. package/packages/omo-codex/plugin/skills/github/scripts/src/wait.ts +164 -0
  267. package/packages/omo-codex/plugin/skills/github/scripts/src/wire.ts +159 -0
  268. package/packages/omo-codex/plugin/skills/github/scripts/src/workflows.ts +144 -0
  269. package/packages/omo-codex/plugin/skills/github/scripts/src/zip.ts +104 -0
  270. package/packages/omo-codex/plugin/skills/github/scripts/surface.ts +106 -0
  271. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/SOURCE.json +15 -0
  272. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/cli.ts +203 -0
  273. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/flags.ts +195 -0
  274. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/help.ts +89 -0
  275. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/http.ts +180 -0
  276. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/index.ts +44 -0
  277. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/mcp.ts +241 -0
  278. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/schema.ts +200 -0
  279. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/stdio.ts +54 -0
  280. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/surface.ts +250 -0
  281. package/packages/omo-codex/plugin/skills/github/scripts/vendor/surface/tools.ts +80 -0
  282. package/packages/omo-codex/plugin/skills/programming/SKILL.md +1 -1
  283. package/packages/omo-codex/plugin/skills/ulw-execute/SKILL.md +1 -1
  284. package/packages/omo-codex/plugin/skills/ulw-loop/SKILL.md +1 -1
  285. package/packages/omo-codex/plugin/skills/ulw-loop/references/full-workflow.md +3 -3
  286. package/packages/omo-codex/plugin/test/sync-skills-codex-compatibility.test.mjs +1 -1
  287. package/packages/omo-codex/plugin/test/sync-skills-test-support.mjs +2 -1
  288. package/packages/omo-codex/plugin/test/sync-skills.test.mjs +5 -5
  289. package/packages/omo-codex/scripts/install-dist/install-local.mjs +20 -15
  290. package/packages/shared-skills/skills/browser/SKILL.md +4 -1
  291. package/packages/shared-skills/skills/browser/references/commands.md +5 -2
  292. package/packages/shared-skills/skills/browser/references/desktop.md +1 -0
  293. package/packages/shared-skills/skills/browser/references/owned-engine/README.md +2 -0
  294. package/packages/shared-skills/skills/browser/references/owned-engine/frames-and-humans.md +2 -0
  295. package/packages/shared-skills/skills/browser/references/owned-engine/network.md +10 -5
  296. package/packages/shared-skills/skills/browser/references/recipes/1password.md +2 -0
  297. package/packages/shared-skills/skills/browser/runtime/omowright/index.js +11 -11
  298. package/packages/shared-skills/skills/browser/runtime/omowright/manifest.json +4 -4
  299. package/packages/shared-skills/skills/debugging/SKILL.md +1 -1
  300. package/packages/shared-skills/skills/git/SKILL.md +62 -0
  301. package/packages/shared-skills/skills/git/agents/openai.yaml +13 -0
  302. package/packages/shared-skills/skills/github/SKILL.md +94 -0
  303. package/packages/shared-skills/skills/github/references/branch-rules.md +129 -0
  304. package/packages/shared-skills/skills/github/references/evidence-attachments.md +16 -0
  305. package/packages/shared-skills/skills/github/references/repo-setup.md +152 -0
  306. package/packages/shared-skills/skills/github/references/waiting.md +52 -0
  307. package/packages/shared-skills/skills/github/references/workflows.md +161 -0
  308. package/packages/shared-skills/skills/github/scripts/cli.ts +8 -0
  309. package/packages/shared-skills/skills/github/scripts/package.json +12 -0
  310. package/packages/shared-skills/skills/github/scripts/sdk.ts +11 -0
  311. package/packages/shared-skills/skills/github/scripts/src/account.ts +243 -0
  312. package/packages/shared-skills/skills/github/scripts/src/actions-write.ts +86 -0
  313. package/packages/shared-skills/skills/github/scripts/src/actions.ts +210 -0
  314. package/packages/shared-skills/skills/github/scripts/src/attestations.ts +136 -0
  315. package/packages/shared-skills/skills/github/scripts/src/blake2b.ts +102 -0
  316. package/packages/shared-skills/skills/github/scripts/src/branch-protection.ts +192 -0
  317. package/packages/shared-skills/skills/github/scripts/src/caches.ts +105 -0
  318. package/packages/shared-skills/skills/github/scripts/src/checks.ts +107 -0
  319. package/packages/shared-skills/skills/github/scripts/src/codespaces.ts +230 -0
  320. package/packages/shared-skills/skills/github/scripts/src/conversation-lock.ts +50 -0
  321. package/packages/shared-skills/skills/github/scripts/src/discussion-list.ts +126 -0
  322. package/packages/shared-skills/skills/github/scripts/src/discussion-lookup.ts +127 -0
  323. package/packages/shared-skills/skills/github/scripts/src/discussions.ts +234 -0
  324. package/packages/shared-skills/skills/github/scripts/src/env.ts +100 -0
  325. package/packages/shared-skills/skills/github/scripts/src/errors.ts +79 -0
  326. package/packages/shared-skills/skills/github/scripts/src/fields.ts +27 -0
  327. package/packages/shared-skills/skills/github/scripts/src/gist-shape.ts +58 -0
  328. package/packages/shared-skills/skills/github/scripts/src/gists-write.ts +130 -0
  329. package/packages/shared-skills/skills/github/scripts/src/gists.ts +118 -0
  330. package/packages/shared-skills/skills/github/scripts/src/git-auth.ts +46 -0
  331. package/packages/shared-skills/skills/github/scripts/src/http.ts +159 -0
  332. package/packages/shared-skills/skills/github/scripts/src/issue-develop.ts +118 -0
  333. package/packages/shared-skills/skills/github/scripts/src/issues-extra.ts +135 -0
  334. package/packages/shared-skills/skills/github/scripts/src/issues-write.ts +174 -0
  335. package/packages/shared-skills/skills/github/scripts/src/issues.ts +156 -0
  336. package/packages/shared-skills/skills/github/scripts/src/keys.ts +176 -0
  337. package/packages/shared-skills/skills/github/scripts/src/labels.ts +209 -0
  338. package/packages/shared-skills/skills/github/scripts/src/merge.ts +115 -0
  339. package/packages/shared-skills/skills/github/scripts/src/poly1305.ts +22 -0
  340. package/packages/shared-skills/skills/github/scripts/src/pr-checkout.ts +92 -0
  341. package/packages/shared-skills/skills/github/scripts/src/pr-view.ts +106 -0
  342. package/packages/shared-skills/skills/github/scripts/src/project-fields.ts +144 -0
  343. package/packages/shared-skills/skills/github/scripts/src/project-item-edit.ts +153 -0
  344. package/packages/shared-skills/skills/github/scripts/src/project-items.ts +191 -0
  345. package/packages/shared-skills/skills/github/scripts/src/project-links.ts +104 -0
  346. package/packages/shared-skills/skills/github/scripts/src/project-ref.ts +145 -0
  347. package/packages/shared-skills/skills/github/scripts/src/project-state.ts +99 -0
  348. package/packages/shared-skills/skills/github/scripts/src/projects.ts +158 -0
  349. package/packages/shared-skills/skills/github/scripts/src/pulls-extra.ts +165 -0
  350. package/packages/shared-skills/skills/github/scripts/src/pulls-read.ts +176 -0
  351. package/packages/shared-skills/skills/github/scripts/src/pulls-review.ts +206 -0
  352. package/packages/shared-skills/skills/github/scripts/src/pulls-write.ts +187 -0
  353. package/packages/shared-skills/skills/github/scripts/src/raw.ts +78 -0
  354. package/packages/shared-skills/skills/github/scripts/src/read.ts +77 -0
  355. package/packages/shared-skills/skills/github/scripts/src/release-assets.ts +111 -0
  356. package/packages/shared-skills/skills/github/scripts/src/release-download.ts +151 -0
  357. package/packages/shared-skills/skills/github/scripts/src/release-write.ts +197 -0
  358. package/packages/shared-skills/skills/github/scripts/src/repo-admin.ts +112 -0
  359. package/packages/shared-skills/skills/github/scripts/src/repo-content.ts +187 -0
  360. package/packages/shared-skills/skills/github/scripts/src/repo-create.ts +139 -0
  361. package/packages/shared-skills/skills/github/scripts/src/repo-extras.ts +217 -0
  362. package/packages/shared-skills/skills/github/scripts/src/repo-list.ts +143 -0
  363. package/packages/shared-skills/skills/github/scripts/src/repo-settings.ts +176 -0
  364. package/packages/shared-skills/skills/github/scripts/src/repo-sync.ts +81 -0
  365. package/packages/shared-skills/skills/github/scripts/src/repo-url.ts +104 -0
  366. package/packages/shared-skills/skills/github/scripts/src/repos.ts +87 -0
  367. package/packages/shared-skills/skills/github/scripts/src/ruleset-shape.ts +96 -0
  368. package/packages/shared-skills/skills/github/scripts/src/rulesets-write.ts +124 -0
  369. package/packages/shared-skills/skills/github/scripts/src/rulesets.ts +80 -0
  370. package/packages/shared-skills/skills/github/scripts/src/run-download.ts +88 -0
  371. package/packages/shared-skills/skills/github/scripts/src/salsa20.ts +97 -0
  372. package/packages/shared-skills/skills/github/scripts/src/scopes.ts +165 -0
  373. package/packages/shared-skills/skills/github/scripts/src/sealed-box.ts +75 -0
  374. package/packages/shared-skills/skills/github/scripts/src/search-commits.ts +114 -0
  375. package/packages/shared-skills/skills/github/scripts/src/search.ts +116 -0
  376. package/packages/shared-skills/skills/github/scripts/src/secrets.ts +131 -0
  377. package/packages/shared-skills/skills/github/scripts/src/snappy.ts +57 -0
  378. package/packages/shared-skills/skills/github/scripts/src/status-search.ts +55 -0
  379. package/packages/shared-skills/skills/github/scripts/src/transfer.ts +97 -0
  380. package/packages/shared-skills/skills/github/scripts/src/types.ts +75 -0
  381. package/packages/shared-skills/skills/github/scripts/src/variables.ts +86 -0
  382. package/packages/shared-skills/skills/github/scripts/src/wait.ts +164 -0
  383. package/packages/shared-skills/skills/github/scripts/src/wire.ts +159 -0
  384. package/packages/shared-skills/skills/github/scripts/src/workflows.ts +144 -0
  385. package/packages/shared-skills/skills/github/scripts/src/zip.ts +104 -0
  386. package/packages/shared-skills/skills/github/scripts/surface.ts +106 -0
  387. package/packages/shared-skills/skills/github/scripts/vendor/surface/SOURCE.json +15 -0
  388. package/packages/shared-skills/skills/github/scripts/vendor/surface/cli.ts +203 -0
  389. package/packages/shared-skills/skills/github/scripts/vendor/surface/flags.ts +195 -0
  390. package/packages/shared-skills/skills/github/scripts/vendor/surface/help.ts +89 -0
  391. package/packages/shared-skills/skills/github/scripts/vendor/surface/http.ts +180 -0
  392. package/packages/shared-skills/skills/github/scripts/vendor/surface/index.ts +44 -0
  393. package/packages/shared-skills/skills/github/scripts/vendor/surface/mcp.ts +241 -0
  394. package/packages/shared-skills/skills/github/scripts/vendor/surface/schema.ts +200 -0
  395. package/packages/shared-skills/skills/github/scripts/vendor/surface/stdio.ts +54 -0
  396. package/packages/shared-skills/skills/github/scripts/vendor/surface/surface.ts +250 -0
  397. package/packages/shared-skills/skills/github/scripts/vendor/surface/tools.ts +80 -0
  398. package/packages/shared-skills/skills/programming/SKILL.md +1 -1
  399. package/packages/shared-skills/skills/ulw-execute/SKILL.md +1 -1
  400. package/dist/skills/git-master/SKILL.md +0 -114
  401. package/dist/skills/git-master/agents/openai.yaml +0 -13
  402. package/packages/omo-codex/plugin/skills/git-master/SKILL.md +0 -114
  403. package/packages/omo-codex/plugin/skills/git-master/agents/openai.yaml +0 -13
  404. package/packages/shared-skills/skills/git-master/SKILL.md +0 -114
  405. package/packages/shared-skills/skills/git-master/agents/openai.yaml +0 -13
@@ -0,0 +1,195 @@
1
+ // Command-line flags from an input schema: each top-level property is `--kebab-name`, typed by
2
+ // its schema. `--json '{...}'` (or `--input file`, `-` for stdin) supplies the whole input, and
3
+ // flags given beside it override its fields. A field its schema marks `writeOnly` is a secret: other
4
+ // processes can read an argument list, so it is accepted only through `--input`.
5
+ import { SurfaceError } from "./surface.ts";
6
+ import type { JsonSchema } from "./schema.ts";
7
+
8
+ export type Property = {
9
+ readonly name: string;
10
+ readonly flag: string;
11
+ readonly schema: JsonSchema;
12
+ readonly required: boolean;
13
+ };
14
+
15
+ const isObject = (
16
+ value: unknown,
17
+ ): value is { readonly [key: string]: unknown } =>
18
+ typeof value === "object" && value !== null && !Array.isArray(value);
19
+
20
+ export const kebab = (name: string): string =>
21
+ name
22
+ .replace(/([a-z0-9])([A-Z])/g, "$1-$2")
23
+ .replaceAll("_", "-")
24
+ .toLowerCase();
25
+
26
+ export const propertiesOf = (schema: JsonSchema): readonly Property[] => {
27
+ const properties = isObject(schema["properties"]) ? schema["properties"] : {};
28
+ const required = Array.isArray(schema["required"]) ? schema["required"] : [];
29
+ return Object.entries(properties).map(([name, value]) => ({
30
+ name,
31
+ flag: kebab(name),
32
+ schema: isObject(value) ? value : {},
33
+ required: required.includes(name),
34
+ }));
35
+ };
36
+
37
+ const kindOf = (schema: JsonSchema): string => {
38
+ const kind = schema["type"];
39
+ if (typeof kind === "string") return kind;
40
+ if (Array.isArray(kind))
41
+ return kind.find((each) => each !== "null") ?? "json";
42
+ return Array.isArray(schema["enum"]) ? "string" : "json";
43
+ };
44
+
45
+ export const typeLabel = (schema: JsonSchema): string => {
46
+ if (Array.isArray(schema["enum"]))
47
+ return schema["enum"].map(String).join("|");
48
+ const kind = kindOf(schema);
49
+ if (kind === "array")
50
+ return `${typeLabel(isObject(schema["items"]) ? schema["items"] : {})}...`;
51
+ return kind === "object" ? "json" : kind;
52
+ };
53
+
54
+ const parseJson = (text: string, what: string): unknown => {
55
+ try {
56
+ return JSON.parse(text);
57
+ } catch {
58
+ throw new SurfaceError(
59
+ "usage",
60
+ `${what} is not valid JSON (${text.length} characters given)`,
61
+ "check the quoting, or pass the input with --input <file|->",
62
+ );
63
+ }
64
+ };
65
+
66
+ const secretInArgv = (flag: string): SurfaceError =>
67
+ new SurfaceError(
68
+ "usage",
69
+ `--${flag} is a secret and cannot be passed as an argument`,
70
+ "pass the whole input on stdin with --input -, or from a file with --input <file>",
71
+ );
72
+
73
+ const scalar = (schema: JsonSchema, raw: string, flag: string): unknown => {
74
+ const kind = kindOf(schema);
75
+ if (kind === "string") return raw;
76
+ if (kind === "boolean") {
77
+ if (raw === "true" || raw === "false") return raw === "true";
78
+ throw new SurfaceError(
79
+ "usage",
80
+ `--${flag} takes true or false, not ${raw}`,
81
+ );
82
+ }
83
+ if (kind === "number" || kind === "integer") {
84
+ const value = Number(raw);
85
+ if (raw.trim() === "" || !Number.isFinite(value)) {
86
+ throw new SurfaceError("usage", `--${flag} takes a number, not ${raw}`);
87
+ }
88
+ return value;
89
+ }
90
+ return parseJson(raw, `--${flag}`);
91
+ };
92
+
93
+ export type Parsed = {
94
+ readonly input: Readonly<Record<string, unknown>>;
95
+ readonly help: boolean;
96
+ };
97
+
98
+ export const parseFlags = async (
99
+ schema: JsonSchema,
100
+ argv: readonly string[],
101
+ readStdin: () => Promise<string>,
102
+ ): Promise<Parsed> => {
103
+ const properties = propertiesOf(schema);
104
+ const byFlag = new Map(properties.map((each) => [each.flag, each]));
105
+ const secrets = properties.filter(
106
+ (each) => each.schema["writeOnly"] === true,
107
+ );
108
+ let base: Readonly<Record<string, unknown>> = {};
109
+ const given: Record<string, unknown> = {};
110
+ let help = false;
111
+ for (let at = 0; at < argv.length; at += 1) {
112
+ const token = argv[at] ?? "";
113
+ if (token === "--help" || token === "-h") {
114
+ help = true;
115
+ continue;
116
+ }
117
+ if (!token.startsWith("--")) {
118
+ throw new SurfaceError(
119
+ "usage",
120
+ `unexpected argument ${token}`,
121
+ "inputs are --flags",
122
+ );
123
+ }
124
+ const [name = "", inline] = token.slice(2).split(/=(.*)/s, 2);
125
+ const next = (): string => {
126
+ if (inline !== undefined) return inline;
127
+ const value = argv[at + 1];
128
+ if (value === undefined)
129
+ throw new SurfaceError("usage", `--${name} needs a value`);
130
+ at += 1;
131
+ return value;
132
+ };
133
+ if (name === "json" || name === "input") {
134
+ const source = next();
135
+ const text =
136
+ name === "json"
137
+ ? source
138
+ : source === "-"
139
+ ? await readStdin()
140
+ : await Bun.file(source).text();
141
+ const value = parseJson(text, `--${name}`);
142
+ if (!isObject(value))
143
+ throw new SurfaceError("usage", `--${name} must be a JSON object`);
144
+ const carried = secrets.find((each) => each.name in value);
145
+ if (name === "json" && carried !== undefined)
146
+ throw secretInArgv(carried.flag);
147
+ base = value;
148
+ continue;
149
+ }
150
+ const negated = name.startsWith("no-")
151
+ ? byFlag.get(name.slice(3))
152
+ : undefined;
153
+ if (
154
+ negated !== undefined &&
155
+ kindOf(negated.schema) === "boolean" &&
156
+ inline === undefined
157
+ ) {
158
+ given[negated.name] = false;
159
+ continue;
160
+ }
161
+ const property = byFlag.get(name);
162
+ if (property === undefined) {
163
+ const known =
164
+ [...byFlag.keys()].map((flag) => `--${flag}`).join(", ") || "none";
165
+ throw new SurfaceError(
166
+ "usage",
167
+ `unknown flag --${name}`,
168
+ `flags: ${known}, --json, --input`,
169
+ );
170
+ }
171
+ if (secrets.includes(property)) throw secretInArgv(property.flag);
172
+ const kind = kindOf(property.schema);
173
+ if (
174
+ kind === "boolean" &&
175
+ inline === undefined &&
176
+ !["true", "false"].includes(argv[at + 1] ?? "")
177
+ ) {
178
+ given[property.name] = true;
179
+ continue;
180
+ }
181
+ if (kind === "array") {
182
+ const items = isObject(property.schema["items"])
183
+ ? property.schema["items"]
184
+ : {};
185
+ const previous = given[property.name];
186
+ given[property.name] = [
187
+ ...(Array.isArray(previous) ? previous : []),
188
+ scalar(items, next(), name),
189
+ ];
190
+ continue;
191
+ }
192
+ given[property.name] = scalar(property.schema, next(), name);
193
+ }
194
+ return { input: { ...base, ...given }, help };
195
+ };
@@ -0,0 +1,89 @@
1
+ // The text `--help` prints: the overview of a surface or a group, one operation's flags, and the
2
+ // `mcp` command. It is built from the surface definition and the caller's label, and the command
3
+ // line prints it through its redactor like everything else.
4
+ import { propertiesOf, typeLabel } from "./flags.ts";
5
+ import { toolName } from "./mcp.ts";
6
+ import {
7
+ isOp,
8
+ type AnyOp,
9
+ type Ops,
10
+ type SurfaceDefinition,
11
+ } from "./surface.ts";
12
+
13
+ const firstLine = (text: string): string => text.split("\n")[0] ?? "";
14
+
15
+ const listing = (
16
+ ops: Ops,
17
+ prefix: readonly string[],
18
+ depth: number,
19
+ ): string[] =>
20
+ Object.entries(ops).flatMap(([name, value]) => {
21
+ const path = [...prefix, name].join(" ");
22
+ return isOp(value)
23
+ ? [` ${path.padEnd(28)} ${firstLine(value.description)}`]
24
+ : depth > 0
25
+ ? listing(value, [...prefix, name], depth - 1)
26
+ : [
27
+ ` ${path.padEnd(28)} (${Object.keys(value).length} commands: ${path} --help)`,
28
+ ];
29
+ });
30
+
31
+ export const overview = (
32
+ surface: SurfaceDefinition<Ops>,
33
+ cli: string,
34
+ ops: Ops,
35
+ prefix: readonly string[],
36
+ ): string =>
37
+ [
38
+ prefix.length === 0
39
+ ? `${surface.name} ${surface.version}${surface.description === undefined ? "" : `: ${surface.description}`}`
40
+ : `${cli} ${prefix.join(" ")}`,
41
+ "",
42
+ `usage: ${cli} ${[...prefix, "<command>"].join(" ")} [--flags | --json '{...}' | --input file]`,
43
+ "",
44
+ "commands:",
45
+ ...listing(ops, prefix, prefix.length === 0 ? 0 : 1),
46
+ ...(prefix.length === 0
47
+ ? [
48
+ ` ${"mcp".padEnd(28)} serve every command as an MCP server (mcp --help)`,
49
+ ]
50
+ : []),
51
+ ].join("\n");
52
+
53
+ export const opHelp = (
54
+ cli: string,
55
+ path: readonly string[],
56
+ op: AnyOp,
57
+ ): string => {
58
+ const flags = propertiesOf(op.input.json).map((each) => {
59
+ const said =
60
+ typeof each.schema["description"] === "string"
61
+ ? each.schema["description"]
62
+ : "";
63
+ const secret =
64
+ each.schema["writeOnly"] === true ? "(secret: --input only) " : "";
65
+ return ` --${`${each.flag} <${typeLabel(each.schema)}>`.padEnd(34)} ${each.required ? "(required) " : ""}${secret}${firstLine(said)}`;
66
+ });
67
+ const hints = Object.entries(op.annotations ?? {})
68
+ .filter(([, on]) => on)
69
+ .map(([hint]) => hint);
70
+ return [
71
+ `${cli} ${path.join(" ")}: ${op.description}`,
72
+ "",
73
+ ...(flags.length === 0 ? ["takes no input"] : ["flags:", ...flags]),
74
+ " --json <object>, --input <file|-> the whole input as JSON; flags override its fields",
75
+ "",
76
+ `mcp tool: ${toolName(path)}${hints.length === 0 ? "" : ` (${hints.join(", ")})`}`,
77
+ ].join("\n");
78
+ };
79
+
80
+ export const mcpHelp = (cli: string): string =>
81
+ [
82
+ `usage: ${cli} mcp [--http --token-env NAME] [--host 127.0.0.1] [--port 0] [--path /mcp]`,
83
+ " [--read-only] [--only pattern,...] [--exclude pattern,...]",
84
+ "",
85
+ "stdio by default (one JSON-RPC message per line). --http serves Streamable HTTP and prints",
86
+ "its URL on stderr. It is plain HTTP, so it serves loopback only and every request must carry",
87
+ "`Authorization: Bearer <the value of $NAME>` (--token-env NAME is required with --http).",
88
+ "Speaks MCP 2026-07-28 (stateless) and the initialize-based revisions back to 2024-11-05.",
89
+ ].join("\n");
@@ -0,0 +1,180 @@
1
+ // The Streamable HTTP binding, JSON responses only (no operation streams). Modern requests are
2
+ // checked against the MCP-Protocol-Version, Mcp-Method and Mcp-Name headers; a request without
3
+ // modern `_meta` is served under legacy semantics with no session, which those revisions allow.
4
+ // It speaks plain HTTP, so it binds to loopback only, refuses a foreign Origin (DNS rebinding) and
5
+ // requires a bearer token on every request: without one, any local process, another user's
6
+ // included, could run the surface's operations with this process's credentials.
7
+ import { createHash, timingSafeEqual } from "node:crypto";
8
+ import { ERRORS, type McpHandler, type Reply } from "./mcp.ts";
9
+ import { SurfaceError } from "./surface.ts";
10
+
11
+ export type HttpOptions = {
12
+ readonly hostname?: string;
13
+ readonly port?: number;
14
+ readonly path?: string;
15
+ /** Required on every request as `Authorization: Bearer <token>`. */
16
+ readonly token: string;
17
+ };
18
+
19
+ export type HttpServer = {
20
+ readonly url: string;
21
+ readonly stop: () => Promise<void>;
22
+ };
23
+
24
+ const LOOPBACK = new Set(["127.0.0.1", "::1", "localhost"]);
25
+ const META_VERSION = "io.modelcontextprotocol/protocolVersion";
26
+
27
+ const isObject = (
28
+ value: unknown,
29
+ ): value is { readonly [key: string]: unknown } =>
30
+ typeof value === "object" && value !== null && !Array.isArray(value);
31
+
32
+ const decoded = (header: string): string => {
33
+ const match = /^=\?base64\?(.*)\?=$/s.exec(header);
34
+ return match === null
35
+ ? header
36
+ : Buffer.from(match[1] ?? "", "base64").toString("utf8");
37
+ };
38
+
39
+ const json = (body: unknown, status: number): Response =>
40
+ Response.json(body, { status, headers: { "cache-control": "no-store" } });
41
+
42
+ const refuse = (
43
+ id: unknown,
44
+ status: number,
45
+ code: number,
46
+ message: string,
47
+ ): Response =>
48
+ json({ jsonrpc: "2.0", id: id ?? null, error: { code, message } }, status);
49
+
50
+ const statusOf = (reply: Reply, modern: boolean): number => {
51
+ const error = reply["error"];
52
+ if (!modern || !isObject(error)) return 200;
53
+ if (error["code"] === ERRORS.methodNotFound) return 404;
54
+ const malformed = [
55
+ ERRORS.invalidParams,
56
+ ERRORS.unsupportedVersion,
57
+ ERRORS.headerMismatch,
58
+ ];
59
+ return malformed.some((code) => code === error["code"]) ? 400 : 200;
60
+ };
61
+
62
+ const headerProblem = (
63
+ request: Request,
64
+ message: { readonly [key: string]: unknown },
65
+ ): string | undefined => {
66
+ const params = isObject(message["params"]) ? message["params"] : {};
67
+ const meta = isObject(params["_meta"]) ? params["_meta"] : {};
68
+ const version = request.headers.get("mcp-protocol-version");
69
+ if (version !== meta[META_VERSION])
70
+ return "MCP-Protocol-Version header does not match _meta";
71
+ if (request.headers.get("mcp-method") !== message["method"])
72
+ return "Mcp-Method header does not match the body";
73
+ const named = message["method"] === "tools/call";
74
+ const name = request.headers.get("mcp-name");
75
+ if (named && (name === null || decoded(name) !== params["name"]))
76
+ return "Mcp-Name header does not match params.name";
77
+ return undefined;
78
+ };
79
+
80
+ const originAllowed = (request: Request): boolean => {
81
+ const origin = request.headers.get("origin");
82
+ if (origin === null) return true;
83
+ try {
84
+ return LOOPBACK.has(new URL(origin).hostname.replace(/^\[|\]$/g, ""));
85
+ } catch {
86
+ return false;
87
+ }
88
+ };
89
+
90
+ const digest = (text: string): Buffer =>
91
+ createHash("sha256").update(text).digest();
92
+
93
+ export const serveHttp = (
94
+ handler: McpHandler,
95
+ options: HttpOptions,
96
+ ): HttpServer => {
97
+ const hostname = options.hostname ?? "127.0.0.1";
98
+ const path = options.path ?? "/mcp";
99
+ if (!LOOPBACK.has(hostname)) {
100
+ throw new SurfaceError(
101
+ "usage",
102
+ `serving on ${hostname} is refused: only loopback is served, because this is plain HTTP`,
103
+ "bind 127.0.0.1 and reach it through an SSH tunnel or a proxy that terminates TLS",
104
+ );
105
+ }
106
+ // Checked at run time as well: a caller without the types must not end up serving "Bearer undefined".
107
+ const token: unknown = options.token;
108
+ if (typeof token !== "string" || token === "") {
109
+ throw new SurfaceError(
110
+ "usage",
111
+ "the HTTP server needs a bearer token",
112
+ "set one with --token-env NAME",
113
+ );
114
+ }
115
+ const expected = digest(`Bearer ${token}`);
116
+ const authorized = (request: Request): boolean =>
117
+ timingSafeEqual(
118
+ digest(request.headers.get("authorization") ?? ""),
119
+ expected,
120
+ );
121
+ const server = Bun.serve({
122
+ hostname,
123
+ port: options.port ?? 0,
124
+ // Whatever a handler throws stays in this process: the default error page would print it.
125
+ error: () => refuse(null, 500, ERRORS.internal, "Internal error"),
126
+ fetch: async (request) => {
127
+ if (new URL(request.url).pathname !== path)
128
+ return new Response("not found", { status: 404 });
129
+ if (!originAllowed(request))
130
+ return refuse(null, 403, ERRORS.invalidRequest, "Origin not allowed");
131
+ if (!authorized(request)) {
132
+ return new Response("unauthorized", {
133
+ status: 401,
134
+ headers: { "www-authenticate": "Bearer" },
135
+ });
136
+ }
137
+ if (request.method !== "POST")
138
+ return new Response("method not allowed", {
139
+ status: 405,
140
+ headers: { allow: "POST" },
141
+ });
142
+ let message: unknown;
143
+ try {
144
+ message = await request.json();
145
+ } catch {
146
+ return refuse(null, 400, ERRORS.parse, "Parse error");
147
+ }
148
+ if (!isObject(message))
149
+ return refuse(null, 400, ERRORS.invalidRequest, "Invalid Request");
150
+ const params = isObject(message["params"]) ? message["params"] : {};
151
+ const modern =
152
+ isObject(params["_meta"]) && META_VERSION in params["_meta"];
153
+ if (modern) {
154
+ const problem = headerProblem(request, message);
155
+ // This reply echoes the caller's id and never reaches the handler, so it is redacted here.
156
+ if (problem !== undefined)
157
+ return json(
158
+ await handler.redact({
159
+ jsonrpc: "2.0",
160
+ id: message["id"] ?? null,
161
+ error: {
162
+ code: ERRORS.headerMismatch,
163
+ message: `Header mismatch: ${problem}`,
164
+ },
165
+ }),
166
+ 400,
167
+ );
168
+ }
169
+ const reply = await handler.handle(message, {
170
+ legacy: modern ? undefined : "stateless",
171
+ });
172
+ if (reply === undefined) return new Response(null, { status: 202 });
173
+ return json(reply, statusOf(reply, modern));
174
+ },
175
+ });
176
+ return {
177
+ url: `http://${hostname.includes(":") ? `[${hostname}]` : hostname}:${server.port}${path}`,
178
+ stop: () => server.stop(true),
179
+ };
180
+ };
@@ -0,0 +1,44 @@
1
+ export { s, problems, conforms } from "./schema.ts";
2
+ export type {
3
+ Doc,
4
+ Infer,
5
+ JsonSchema,
6
+ ObjectOf,
7
+ Schema,
8
+ Shape,
9
+ } from "./schema.ts";
10
+ export {
11
+ bind,
12
+ defineSurface,
13
+ describeError,
14
+ entries,
15
+ internalError,
16
+ isOp,
17
+ op,
18
+ secretTally,
19
+ SurfaceError,
20
+ } from "./surface.ts";
21
+ export type {
22
+ Annotations,
23
+ AnyOp,
24
+ Client,
25
+ Described,
26
+ Entry,
27
+ Op,
28
+ Ops,
29
+ SurfaceDefinition,
30
+ } from "./surface.ts";
31
+ export { runCli } from "./cli.ts";
32
+ export type { CliIo } from "./cli.ts";
33
+ export {
34
+ ERRORS,
35
+ LEGACY_VERSIONS,
36
+ MODERN_VERSIONS,
37
+ mcpHandler,
38
+ toolName,
39
+ } from "./mcp.ts";
40
+ export type { Connection, McpHandler, McpOptions, Reply, Tool } from "./mcp.ts";
41
+ export { serveStdio } from "./stdio.ts";
42
+ export type { StdioStreams } from "./stdio.ts";
43
+ export { serveHttp } from "./http.ts";
44
+ export type { HttpOptions, HttpServer } from "./http.ts";