operon-agents-core 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (511) hide show
  1. package/LICENSE +55 -0
  2. package/README.md +7 -0
  3. package/dist/agent/agent.d.ts +65 -0
  4. package/dist/agent/agent.js +39 -0
  5. package/dist/agent/compose-hooks.d.ts +13 -0
  6. package/dist/agent/compose-hooks.js +197 -0
  7. package/dist/agent/concurrency.d.ts +22 -0
  8. package/dist/agent/concurrency.js +70 -0
  9. package/dist/agent/context-report.d.ts +60 -0
  10. package/dist/agent/context-report.js +45 -0
  11. package/dist/agent/graph.d.ts +48 -0
  12. package/dist/agent/graph.js +129 -0
  13. package/dist/agent/guardrail.d.ts +105 -0
  14. package/dist/agent/guardrail.js +314 -0
  15. package/dist/agent/handoff-executor.d.ts +21 -0
  16. package/dist/agent/handoff-executor.js +95 -0
  17. package/dist/agent/handoff.d.ts +42 -0
  18. package/dist/agent/handoff.js +70 -0
  19. package/dist/agent/index.d.ts +25 -0
  20. package/dist/agent/index.js +19 -0
  21. package/dist/agent/instruction-context.d.ts +33 -0
  22. package/dist/agent/instruction-context.js +100 -0
  23. package/dist/agent/pause.d.ts +12 -0
  24. package/dist/agent/pause.js +82 -0
  25. package/dist/agent/profile-builtins.d.ts +8 -0
  26. package/dist/agent/profile-builtins.js +130 -0
  27. package/dist/agent/profiles.d.ts +94 -0
  28. package/dist/agent/profiles.js +264 -0
  29. package/dist/agent/recovery.d.ts +10 -0
  30. package/dist/agent/recovery.js +151 -0
  31. package/dist/agent/run-support.d.ts +79 -0
  32. package/dist/agent/run-support.js +211 -0
  33. package/dist/agent/runner.d.ts +246 -0
  34. package/dist/agent/runner.js +786 -0
  35. package/dist/agent/session.d.ts +363 -0
  36. package/dist/agent/session.js +937 -0
  37. package/dist/agent/subagent-tools.d.ts +18 -0
  38. package/dist/agent/subagent-tools.js +650 -0
  39. package/dist/agent/subagent.d.ts +56 -0
  40. package/dist/agent/subagent.js +50 -0
  41. package/dist/agent/toolset.d.ts +24 -0
  42. package/dist/agent/toolset.js +112 -0
  43. package/dist/agent/workflow/index.d.ts +9 -0
  44. package/dist/agent/workflow/index.js +8 -0
  45. package/dist/agent/workflow/journal.d.ts +180 -0
  46. package/dist/agent/workflow/journal.js +224 -0
  47. package/dist/agent/workflow/manager.d.ts +27 -0
  48. package/dist/agent/workflow/manager.js +33 -0
  49. package/dist/agent/workflow/parse.d.ts +17 -0
  50. package/dist/agent/workflow/parse.js +174 -0
  51. package/dist/agent/workflow/prompt.d.ts +8 -0
  52. package/dist/agent/workflow/prompt.js +84 -0
  53. package/dist/agent/workflow/runtime.d.ts +64 -0
  54. package/dist/agent/workflow/runtime.js +380 -0
  55. package/dist/agent/workflow/sandbox.d.ts +35 -0
  56. package/dist/agent/workflow/sandbox.js +90 -0
  57. package/dist/agent/workflow/snapshot.d.ts +36 -0
  58. package/dist/agent/workflow/snapshot.js +9 -0
  59. package/dist/agent/workflow/structured.d.ts +35 -0
  60. package/dist/agent/workflow/structured.js +79 -0
  61. package/dist/agent/workflow/tool.d.ts +14 -0
  62. package/dist/agent/workflow/tool.js +569 -0
  63. package/dist/agent/workflow/types.d.ts +100 -0
  64. package/dist/agent/workflow/types.js +17 -0
  65. package/dist/agent/worktree.d.ts +38 -0
  66. package/dist/agent/worktree.js +56 -0
  67. package/dist/capabilities/assembler.d.ts +39 -0
  68. package/dist/capabilities/assembler.js +171 -0
  69. package/dist/capabilities/background/agent-task.d.ts +51 -0
  70. package/dist/capabilities/background/agent-task.js +101 -0
  71. package/dist/capabilities/background/command-task.d.ts +43 -0
  72. package/dist/capabilities/background/command-task.js +86 -0
  73. package/dist/capabilities/background/index.d.ts +20 -0
  74. package/dist/capabilities/background/index.js +57 -0
  75. package/dist/capabilities/background/manager.d.ts +194 -0
  76. package/dist/capabilities/background/manager.js +1131 -0
  77. package/dist/capabilities/background/persist-disk.d.ts +17 -0
  78. package/dist/capabilities/background/persist-disk.js +66 -0
  79. package/dist/capabilities/background/persist.d.ts +61 -0
  80. package/dist/capabilities/background/persist.js +117 -0
  81. package/dist/capabilities/background/question-task.d.ts +32 -0
  82. package/dist/capabilities/background/question-task.js +56 -0
  83. package/dist/capabilities/background/registrar.d.ts +12 -0
  84. package/dist/capabilities/background/registrar.js +9 -0
  85. package/dist/capabilities/background/swappable-sink.d.ts +20 -0
  86. package/dist/capabilities/background/swappable-sink.js +20 -0
  87. package/dist/capabilities/background/task.d.ts +114 -0
  88. package/dist/capabilities/background/task.js +20 -0
  89. package/dist/capabilities/background/tools.d.ts +6 -0
  90. package/dist/capabilities/background/tools.js +190 -0
  91. package/dist/capabilities/background/workflow-task.d.ts +48 -0
  92. package/dist/capabilities/background/workflow-task.js +91 -0
  93. package/dist/capabilities/capability-state.d.ts +13 -0
  94. package/dist/capabilities/capability-state.js +37 -0
  95. package/dist/capabilities/capability.d.ts +145 -0
  96. package/dist/capabilities/capability.js +2 -0
  97. package/dist/capabilities/compaction/full.d.ts +27 -0
  98. package/dist/capabilities/compaction/full.js +155 -0
  99. package/dist/capabilities/compaction/index.d.ts +17 -0
  100. package/dist/capabilities/compaction/index.js +145 -0
  101. package/dist/capabilities/compaction/instruction.d.ts +2 -0
  102. package/dist/capabilities/compaction/instruction.js +31 -0
  103. package/dist/capabilities/compaction/micro.d.ts +17 -0
  104. package/dist/capabilities/compaction/micro.js +57 -0
  105. package/dist/capabilities/compaction/service.d.ts +28 -0
  106. package/dist/capabilities/compaction/service.js +52 -0
  107. package/dist/capabilities/compaction/strategy.d.ts +43 -0
  108. package/dist/capabilities/compaction/strategy.js +116 -0
  109. package/dist/capabilities/compaction/tokens.d.ts +5 -0
  110. package/dist/capabilities/compaction/tokens.js +28 -0
  111. package/dist/capabilities/goal/goal-store.d.ts +69 -0
  112. package/dist/capabilities/goal/goal-store.js +172 -0
  113. package/dist/capabilities/goal/index.d.ts +6 -0
  114. package/dist/capabilities/goal/index.js +31 -0
  115. package/dist/capabilities/goal/injector.d.ts +9 -0
  116. package/dist/capabilities/goal/injector.js +79 -0
  117. package/dist/capabilities/goal/tools.d.ts +6 -0
  118. package/dist/capabilities/goal/tools.js +86 -0
  119. package/dist/capabilities/index.d.ts +25 -0
  120. package/dist/capabilities/index.js +22 -0
  121. package/dist/capabilities/injection.d.ts +44 -0
  122. package/dist/capabilities/injection.js +112 -0
  123. package/dist/capabilities/plan/index.d.ts +6 -0
  124. package/dist/capabilities/plan/index.js +25 -0
  125. package/dist/capabilities/plan/injector.d.ts +13 -0
  126. package/dist/capabilities/plan/injector.js +83 -0
  127. package/dist/capabilities/plan/plan-mode.d.ts +38 -0
  128. package/dist/capabilities/plan/plan-mode.js +113 -0
  129. package/dist/capabilities/plan/policies.d.ts +6 -0
  130. package/dist/capabilities/plan/policies.js +89 -0
  131. package/dist/capabilities/plan/tools.d.ts +15 -0
  132. package/dist/capabilities/plan/tools.js +87 -0
  133. package/dist/capabilities/skills/flow-provider.d.ts +6 -0
  134. package/dist/capabilities/skills/flow-provider.js +50 -0
  135. package/dist/capabilities/skills/index.d.ts +43 -0
  136. package/dist/capabilities/skills/index.js +48 -0
  137. package/dist/capabilities/skills/injector.d.ts +11 -0
  138. package/dist/capabilities/skills/injector.js +27 -0
  139. package/dist/capabilities/skills/parser.d.ts +36 -0
  140. package/dist/capabilities/skills/parser.js +334 -0
  141. package/dist/capabilities/skills/registry.d.ts +33 -0
  142. package/dist/capabilities/skills/registry.js +118 -0
  143. package/dist/capabilities/skills/scanner.d.ts +26 -0
  144. package/dist/capabilities/skills/scanner.js +154 -0
  145. package/dist/capabilities/skills/service.d.ts +39 -0
  146. package/dist/capabilities/skills/service.js +68 -0
  147. package/dist/capabilities/skills/skill-tool.d.ts +13 -0
  148. package/dist/capabilities/skills/skill-tool.js +72 -0
  149. package/dist/capabilities/skills/types.d.ts +62 -0
  150. package/dist/capabilities/skills/types.js +26 -0
  151. package/dist/capabilities/task/index.d.ts +23 -0
  152. package/dist/capabilities/task/index.js +38 -0
  153. package/dist/capabilities/task/injector.d.ts +9 -0
  154. package/dist/capabilities/task/injector.js +62 -0
  155. package/dist/capabilities/task/persist-disk.d.ts +19 -0
  156. package/dist/capabilities/task/persist-disk.js +84 -0
  157. package/dist/capabilities/task/persist.d.ts +52 -0
  158. package/dist/capabilities/task/persist.js +84 -0
  159. package/dist/capabilities/task/task-store.d.ts +44 -0
  160. package/dist/capabilities/task/task-store.js +106 -0
  161. package/dist/capabilities/task/tools.d.ts +12 -0
  162. package/dist/capabilities/task/tools.js +164 -0
  163. package/dist/capabilities/todo/index.d.ts +8 -0
  164. package/dist/capabilities/todo/index.js +21 -0
  165. package/dist/capabilities/todo/injector.d.ts +9 -0
  166. package/dist/capabilities/todo/injector.js +68 -0
  167. package/dist/capabilities/todo/todo-store.d.ts +19 -0
  168. package/dist/capabilities/todo/todo-store.js +36 -0
  169. package/dist/capabilities/todo/tools.d.ts +6 -0
  170. package/dist/capabilities/todo/tools.js +70 -0
  171. package/dist/capabilities/tool-provider.d.ts +12 -0
  172. package/dist/capabilities/tool-provider.js +20 -0
  173. package/dist/capabilities/user-hooks/engine.d.ts +22 -0
  174. package/dist/capabilities/user-hooks/engine.js +105 -0
  175. package/dist/capabilities/user-hooks/index.d.ts +13 -0
  176. package/dist/capabilities/user-hooks/index.js +126 -0
  177. package/dist/capabilities/user-hooks/types.d.ts +26 -0
  178. package/dist/capabilities/user-hooks/types.js +19 -0
  179. package/dist/capabilities/workflow/index.d.ts +16 -0
  180. package/dist/capabilities/workflow/index.js +15 -0
  181. package/dist/commands/index.d.ts +31 -0
  182. package/dist/commands/index.js +318 -0
  183. package/dist/config/config-store.d.ts +29 -0
  184. package/dist/config/config-store.js +103 -0
  185. package/dist/config/file-source.d.ts +40 -0
  186. package/dist/config/file-source.js +78 -0
  187. package/dist/config/flags.d.ts +13 -0
  188. package/dist/config/flags.js +25 -0
  189. package/dist/config/index.d.ts +17 -0
  190. package/dist/config/index.js +10 -0
  191. package/dist/config/merge.d.ts +5 -0
  192. package/dist/config/merge.js +57 -0
  193. package/dist/config/model-catalog.d.ts +17 -0
  194. package/dist/config/model-catalog.js +37 -0
  195. package/dist/config/paths.d.ts +31 -0
  196. package/dist/config/paths.js +28 -0
  197. package/dist/config/provider-manager.d.ts +57 -0
  198. package/dist/config/provider-manager.js +344 -0
  199. package/dist/config/resolver.d.ts +40 -0
  200. package/dist/config/resolver.js +52 -0
  201. package/dist/config/schema.d.ts +389 -0
  202. package/dist/config/schema.js +132 -0
  203. package/dist/events/events.d.ts +348 -0
  204. package/dist/events/events.js +146 -0
  205. package/dist/events/index.d.ts +10 -0
  206. package/dist/events/index.js +5 -0
  207. package/dist/events/projection.d.ts +207 -0
  208. package/dist/events/projection.js +438 -0
  209. package/dist/events/publisher.d.ts +48 -0
  210. package/dist/events/publisher.js +404 -0
  211. package/dist/events/redacting-sink.d.ts +11 -0
  212. package/dist/events/redacting-sink.js +31 -0
  213. package/dist/home.d.ts +16 -0
  214. package/dist/home.js +20 -0
  215. package/dist/index.d.ts +22 -0
  216. package/dist/index.js +22 -0
  217. package/dist/internal.d.ts +33 -0
  218. package/dist/internal.js +29 -0
  219. package/dist/llm/auth.d.ts +22 -0
  220. package/dist/llm/auth.js +112 -0
  221. package/dist/llm/capability.d.ts +13 -0
  222. package/dist/llm/capability.js +45 -0
  223. package/dist/llm/define-model.d.ts +110 -0
  224. package/dist/llm/define-model.js +252 -0
  225. package/dist/llm/errors.d.ts +33 -0
  226. package/dist/llm/errors.js +154 -0
  227. package/dist/llm/index.d.ts +14 -0
  228. package/dist/llm/index.js +8 -0
  229. package/dist/llm/model.d.ts +43 -0
  230. package/dist/llm/model.js +9 -0
  231. package/dist/llm/retry.d.ts +35 -0
  232. package/dist/llm/retry.js +160 -0
  233. package/dist/llm/runtime.d.ts +25 -0
  234. package/dist/llm/runtime.js +38 -0
  235. package/dist/logging/diagnostics.d.ts +21 -0
  236. package/dist/logging/diagnostics.js +46 -0
  237. package/dist/logging/index.d.ts +11 -0
  238. package/dist/logging/index.js +7 -0
  239. package/dist/logging/logger.d.ts +25 -0
  240. package/dist/logging/logger.js +54 -0
  241. package/dist/logging/paths.d.ts +11 -0
  242. package/dist/logging/paths.js +20 -0
  243. package/dist/logging/policy.d.ts +5 -0
  244. package/dist/logging/policy.js +19 -0
  245. package/dist/logging/redact.d.ts +10 -0
  246. package/dist/logging/redact.js +95 -0
  247. package/dist/logging/sinks.d.ts +67 -0
  248. package/dist/logging/sinks.js +117 -0
  249. package/dist/loop/context.d.ts +69 -0
  250. package/dist/loop/context.js +129 -0
  251. package/dist/loop/errors.d.ts +8 -0
  252. package/dist/loop/errors.js +27 -0
  253. package/dist/loop/events.d.ts +14 -0
  254. package/dist/loop/events.js +2 -0
  255. package/dist/loop/index.d.ts +10 -0
  256. package/dist/loop/index.js +7 -0
  257. package/dist/loop/interruption.d.ts +118 -0
  258. package/dist/loop/interruption.js +191 -0
  259. package/dist/loop/run-turn.d.ts +54 -0
  260. package/dist/loop/run-turn.js +203 -0
  261. package/dist/loop/scheduler.d.ts +18 -0
  262. package/dist/loop/scheduler.js +71 -0
  263. package/dist/loop/steer.d.ts +122 -0
  264. package/dist/loop/steer.js +209 -0
  265. package/dist/loop/tool-call.d.ts +41 -0
  266. package/dist/loop/tool-call.js +326 -0
  267. package/dist/loop/turn-step.d.ts +57 -0
  268. package/dist/loop/turn-step.js +298 -0
  269. package/dist/loop/types.d.ts +217 -0
  270. package/dist/loop/types.js +2 -0
  271. package/dist/loop/usage.d.ts +6 -0
  272. package/dist/loop/usage.js +44 -0
  273. package/dist/mcp/auth-tool.d.ts +12 -0
  274. package/dist/mcp/auth-tool.js +92 -0
  275. package/dist/mcp/capability.d.ts +7 -0
  276. package/dist/mcp/capability.js +91 -0
  277. package/dist/mcp/config-loader.d.ts +28 -0
  278. package/dist/mcp/config-loader.js +115 -0
  279. package/dist/mcp/filter.d.ts +18 -0
  280. package/dist/mcp/filter.js +35 -0
  281. package/dist/mcp/index.d.ts +23 -0
  282. package/dist/mcp/index.js +13 -0
  283. package/dist/mcp/manager.d.ts +51 -0
  284. package/dist/mcp/manager.js +412 -0
  285. package/dist/mcp/mock-transport.d.ts +40 -0
  286. package/dist/mcp/mock-transport.js +68 -0
  287. package/dist/mcp/oauth/callback-server.d.ts +14 -0
  288. package/dist/mcp/oauth/callback-server.js +122 -0
  289. package/dist/mcp/oauth/index.d.ts +9 -0
  290. package/dist/mcp/oauth/index.js +5 -0
  291. package/dist/mcp/oauth/provider.d.ts +39 -0
  292. package/dist/mcp/oauth/provider.js +121 -0
  293. package/dist/mcp/oauth/service.d.ts +34 -0
  294. package/dist/mcp/oauth/service.js +130 -0
  295. package/dist/mcp/oauth/store.d.ts +40 -0
  296. package/dist/mcp/oauth/store.js +134 -0
  297. package/dist/mcp/output.d.ts +12 -0
  298. package/dist/mcp/output.js +110 -0
  299. package/dist/mcp/provider.d.ts +7 -0
  300. package/dist/mcp/provider.js +56 -0
  301. package/dist/mcp/sdk-transport.d.ts +25 -0
  302. package/dist/mcp/sdk-transport.js +228 -0
  303. package/dist/mcp/server.d.ts +77 -0
  304. package/dist/mcp/server.js +120 -0
  305. package/dist/mcp/tool-naming.d.ts +4 -0
  306. package/dist/mcp/tool-naming.js +26 -0
  307. package/dist/mcp/types.d.ts +75 -0
  308. package/dist/mcp/types.js +2 -0
  309. package/dist/net/index.d.ts +3 -0
  310. package/dist/net/index.js +2 -0
  311. package/dist/net/proxy.d.ts +16 -0
  312. package/dist/net/proxy.js +42 -0
  313. package/dist/permission/auto-approver/index.d.ts +3 -0
  314. package/dist/permission/auto-approver/index.js +3 -0
  315. package/dist/permission/auto-approver/llm-auto-approver.d.ts +53 -0
  316. package/dist/permission/auto-approver/llm-auto-approver.js +122 -0
  317. package/dist/permission/auto-approver/prompts-data.d.ts +9 -0
  318. package/dist/permission/auto-approver/prompts-data.js +155 -0
  319. package/dist/permission/auto-approver/prompts.d.ts +18 -0
  320. package/dist/permission/auto-approver/prompts.js +40 -0
  321. package/dist/permission/auto-approver/transcript.d.ts +22 -0
  322. package/dist/permission/auto-approver/transcript.js +75 -0
  323. package/dist/permission/auto-approver/xml.d.ts +5 -0
  324. package/dist/permission/auto-approver/xml.js +25 -0
  325. package/dist/permission/index.d.ts +7 -0
  326. package/dist/permission/index.js +5 -0
  327. package/dist/permission/manager.d.ts +74 -0
  328. package/dist/permission/manager.js +162 -0
  329. package/dist/permission/matches-rule.d.ts +27 -0
  330. package/dist/permission/matches-rule.js +54 -0
  331. package/dist/permission/policies.d.ts +14 -0
  332. package/dist/permission/policies.js +233 -0
  333. package/dist/permission/types.d.ts +84 -0
  334. package/dist/permission/types.js +2 -0
  335. package/dist/plugins/archive.d.ts +3 -0
  336. package/dist/plugins/archive.js +58 -0
  337. package/dist/plugins/github-resolver.d.ts +13 -0
  338. package/dist/plugins/github-resolver.js +20 -0
  339. package/dist/plugins/hooks.d.ts +28 -0
  340. package/dist/plugins/hooks.js +296 -0
  341. package/dist/plugins/index.d.ts +23 -0
  342. package/dist/plugins/index.js +23 -0
  343. package/dist/plugins/injector.d.ts +11 -0
  344. package/dist/plugins/injector.js +32 -0
  345. package/dist/plugins/manager.d.ts +37 -0
  346. package/dist/plugins/manager.js +330 -0
  347. package/dist/plugins/manifest.d.ts +9 -0
  348. package/dist/plugins/manifest.js +234 -0
  349. package/dist/plugins/marketplace.d.ts +85 -0
  350. package/dist/plugins/marketplace.js +205 -0
  351. package/dist/plugins/source.d.ts +23 -0
  352. package/dist/plugins/source.js +87 -0
  353. package/dist/plugins/store.d.ts +20 -0
  354. package/dist/plugins/store.js +30 -0
  355. package/dist/plugins/types.d.ts +118 -0
  356. package/dist/plugins/types.js +5 -0
  357. package/dist/protocol/index.d.ts +4 -0
  358. package/dist/protocol/index.js +2 -0
  359. package/dist/protocol/tool-schema.d.ts +6 -0
  360. package/dist/protocol/tool-schema.js +2 -0
  361. package/dist/store/blob-store.d.ts +45 -0
  362. package/dist/store/blob-store.js +120 -0
  363. package/dist/store/catalog-store.d.ts +32 -0
  364. package/dist/store/catalog-store.js +73 -0
  365. package/dist/store/disk-store.d.ts +58 -0
  366. package/dist/store/disk-store.js +369 -0
  367. package/dist/store/index.d.ts +23 -0
  368. package/dist/store/index.js +15 -0
  369. package/dist/store/lock.d.ts +86 -0
  370. package/dist/store/lock.js +104 -0
  371. package/dist/store/log-store.d.ts +89 -0
  372. package/dist/store/log-store.js +296 -0
  373. package/dist/store/migrate.d.ts +26 -0
  374. package/dist/store/migrate.js +32 -0
  375. package/dist/store/origin.d.ts +89 -0
  376. package/dist/store/origin.js +16 -0
  377. package/dist/store/pg.d.ts +90 -0
  378. package/dist/store/pg.js +344 -0
  379. package/dist/store/redacting-store.d.ts +21 -0
  380. package/dist/store/redacting-store.js +46 -0
  381. package/dist/store/redis.d.ts +89 -0
  382. package/dist/store/redis.js +370 -0
  383. package/dist/store/repository.d.ts +150 -0
  384. package/dist/store/repository.js +508 -0
  385. package/dist/store/session-catalog.d.ts +32 -0
  386. package/dist/store/session-catalog.js +117 -0
  387. package/dist/store/storage.d.ts +27 -0
  388. package/dist/store/storage.js +54 -0
  389. package/dist/store/store.d.ts +262 -0
  390. package/dist/store/store.js +129 -0
  391. package/dist/store/workdir-key.d.ts +4 -0
  392. package/dist/store/workdir-key.js +28 -0
  393. package/dist/tool/access.d.ts +37 -0
  394. package/dist/tool/access.js +79 -0
  395. package/dist/tool/ask.d.ts +22 -0
  396. package/dist/tool/ask.js +38 -0
  397. package/dist/tool/background.d.ts +109 -0
  398. package/dist/tool/background.js +39 -0
  399. package/dist/tool/builtin/ask-user-question.d.ts +2 -0
  400. package/dist/tool/builtin/ask-user-question.js +175 -0
  401. package/dist/tool/builtin/bash.d.ts +2 -0
  402. package/dist/tool/builtin/bash.js +407 -0
  403. package/dist/tool/builtin/edit.d.ts +2 -0
  404. package/dist/tool/builtin/edit.js +202 -0
  405. package/dist/tool/builtin/glob.d.ts +3 -0
  406. package/dist/tool/builtin/glob.js +260 -0
  407. package/dist/tool/builtin/grep.d.ts +2 -0
  408. package/dist/tool/builtin/grep.js +574 -0
  409. package/dist/tool/builtin/line-endings.d.ts +10 -0
  410. package/dist/tool/builtin/line-endings.js +41 -0
  411. package/dist/tool/builtin/read.d.ts +28 -0
  412. package/dist/tool/builtin/read.js +498 -0
  413. package/dist/tool/builtin/write.d.ts +2 -0
  414. package/dist/tool/builtin/write.js +179 -0
  415. package/dist/tool/define.d.ts +46 -0
  416. package/dist/tool/define.js +45 -0
  417. package/dist/tool/file-freshness.d.ts +81 -0
  418. package/dist/tool/file-freshness.js +67 -0
  419. package/dist/tool/filesystem-tools.d.ts +16 -0
  420. package/dist/tool/filesystem-tools.js +19 -0
  421. package/dist/tool/git-context.d.ts +20 -0
  422. package/dist/tool/git-context.js +114 -0
  423. package/dist/tool/index.d.ts +37 -0
  424. package/dist/tool/index.js +34 -0
  425. package/dist/tool/machine-base.d.ts +138 -0
  426. package/dist/tool/machine-base.js +388 -0
  427. package/dist/tool/machine-local.d.ts +35 -0
  428. package/dist/tool/machine-local.js +316 -0
  429. package/dist/tool/machine-null.d.ts +36 -0
  430. package/dist/tool/machine-null.js +64 -0
  431. package/dist/tool/machine-ssh.d.ts +86 -0
  432. package/dist/tool/machine-ssh.js +576 -0
  433. package/dist/tool/machine.d.ts +333 -0
  434. package/dist/tool/machine.js +15 -0
  435. package/dist/tool/policies/path-access.d.ts +48 -0
  436. package/dist/tool/policies/path-access.js +186 -0
  437. package/dist/tool/policies/sensitive.d.ts +3 -0
  438. package/dist/tool/policies/sensitive.js +60 -0
  439. package/dist/tool/questions.d.ts +40 -0
  440. package/dist/tool/questions.js +8 -0
  441. package/dist/tool/search/activation.d.ts +13 -0
  442. package/dist/tool/search/activation.js +31 -0
  443. package/dist/tool/search/deferral.d.ts +37 -0
  444. package/dist/tool/search/deferral.js +128 -0
  445. package/dist/tool/search/search-tool.d.ts +9 -0
  446. package/dist/tool/search/search-tool.js +62 -0
  447. package/dist/tool/shell-env.d.ts +9 -0
  448. package/dist/tool/shell-env.js +34 -0
  449. package/dist/tool/support/bash-destructive.d.ts +24 -0
  450. package/dist/tool/support/bash-destructive.js +63 -0
  451. package/dist/tool/support/bash-paths.d.ts +7 -0
  452. package/dist/tool/support/bash-paths.js +247 -0
  453. package/dist/tool/support/bash-read-only.d.ts +8 -0
  454. package/dist/tool/support/bash-read-only.js +165 -0
  455. package/dist/tool/support/bash-rule-match.d.ts +20 -0
  456. package/dist/tool/support/bash-rule-match.js +191 -0
  457. package/dist/tool/support/file-type.d.ts +10 -0
  458. package/dist/tool/support/file-type.js +149 -0
  459. package/dist/tool/support/git-worktree.d.ts +10 -0
  460. package/dist/tool/support/git-worktree.js +63 -0
  461. package/dist/tool/support/image-compress.d.ts +69 -0
  462. package/dist/tool/support/image-compress.js +265 -0
  463. package/dist/tool/support/machine-ops.d.ts +34 -0
  464. package/dist/tool/support/machine-ops.js +34 -0
  465. package/dist/tool/support/path-glob-match.d.ts +12 -0
  466. package/dist/tool/support/path-glob-match.js +84 -0
  467. package/dist/tool/support/result-builder.d.ts +27 -0
  468. package/dist/tool/support/result-builder.js +108 -0
  469. package/dist/tool/support/rg-locator.d.ts +20 -0
  470. package/dist/tool/support/rg-locator.js +42 -0
  471. package/dist/tool/support/ripgrep-run.d.ts +65 -0
  472. package/dist/tool/support/ripgrep-run.js +40 -0
  473. package/dist/tool/support/rule-match.d.ts +6 -0
  474. package/dist/tool/support/rule-match.js +23 -0
  475. package/dist/tool/support/tool-path.d.ts +8 -0
  476. package/dist/tool/support/tool-path.js +28 -0
  477. package/dist/tool/support/workspace.d.ts +5 -0
  478. package/dist/tool/support/workspace.js +2 -0
  479. package/dist/tool/types.d.ts +131 -0
  480. package/dist/tool/types.js +2 -0
  481. package/dist/tool/web/fetch-url.d.ts +4 -0
  482. package/dist/tool/web/fetch-url.js +61 -0
  483. package/dist/tool/web/index.d.ts +11 -0
  484. package/dist/tool/web/index.js +7 -0
  485. package/dist/tool/web/providers/direct-fetch.d.ts +33 -0
  486. package/dist/tool/web/providers/direct-fetch.js +198 -0
  487. package/dist/tool/web/providers/firecrawl.d.ts +16 -0
  488. package/dist/tool/web/providers/firecrawl.js +59 -0
  489. package/dist/tool/web/providers/tavily.d.ts +14 -0
  490. package/dist/tool/web/providers/tavily.js +43 -0
  491. package/dist/tool/web/types.d.ts +41 -0
  492. package/dist/tool/web/types.js +7 -0
  493. package/dist/tool/web/web-search.d.ts +4 -0
  494. package/dist/tool/web/web-search.js +68 -0
  495. package/dist/tool/workspace-spec.d.ts +74 -0
  496. package/dist/tool/workspace-spec.js +177 -0
  497. package/dist/tracing/bridge.d.ts +7 -0
  498. package/dist/tracing/bridge.js +171 -0
  499. package/dist/tracing/index.d.ts +9 -0
  500. package/dist/tracing/index.js +5 -0
  501. package/dist/tracing/otel.d.ts +38 -0
  502. package/dist/tracing/otel.js +221 -0
  503. package/dist/tracing/processor.d.ts +47 -0
  504. package/dist/tracing/processor.js +94 -0
  505. package/dist/tracing/spans.d.ts +94 -0
  506. package/dist/tracing/spans.js +56 -0
  507. package/dist/ui/ai-sdk.d.ts +114 -0
  508. package/dist/ui/ai-sdk.js +175 -0
  509. package/dist/ui/index.d.ts +2 -0
  510. package/dist/ui/index.js +2 -0
  511. package/package.json +101 -0
@@ -0,0 +1,330 @@
1
+ import path from "node:path";
2
+ import { downloadZip, extractZip } from "./archive.js";
3
+ import { resolveGithubSource } from "./github-resolver.js";
4
+ import { parseManifest } from "./manifest.js";
5
+ import { readInstalled, writeInstalled } from "./store.js";
6
+ import { resolveInstallSource } from "./source.js";
7
+ import { normalizePluginId, } from "./types.js";
8
+ export class PluginManager {
9
+ machine;
10
+ homeDir;
11
+ now;
12
+ records = new Map();
13
+ constructor(options) {
14
+ this.machine = options.machine;
15
+ this.homeDir = options.homeDir;
16
+ this.now = options.now ?? Date.now;
17
+ }
18
+ async load() {
19
+ const file = await readInstalled(this.machine, this.homeDir);
20
+ const next = new Map();
21
+ for (const entry of file.plugins) {
22
+ try {
23
+ next.set(entry.id, await this.materialize(entry));
24
+ }
25
+ catch {
26
+ // A vanished/broken root surfaces as an error record below; never abort the load.
27
+ next.set(entry.id, errorRecord(entry));
28
+ }
29
+ }
30
+ this.records = next;
31
+ }
32
+ list() {
33
+ return [...this.records.values()].toSorted((a, b) => a.id.localeCompare(b.id));
34
+ }
35
+ get(id) {
36
+ return this.records.get(normalizePluginId(id));
37
+ }
38
+ async install(source) {
39
+ const resolved = resolveInstallSource(source);
40
+ let root;
41
+ let sourceType;
42
+ let originalSource;
43
+ let github;
44
+ if (resolved.kind === "local-path") {
45
+ root = resolved.path;
46
+ sourceType = "local-path";
47
+ originalSource = resolved.path;
48
+ }
49
+ else {
50
+ let zipUrl;
51
+ if (resolved.kind === "github") {
52
+ const res = await resolveGithubSource(resolved);
53
+ zipUrl = res.zipUrl;
54
+ sourceType = "github";
55
+ originalSource = source.trim();
56
+ github = { owner: resolved.owner, repo: resolved.repo, ref: res.ref };
57
+ }
58
+ else {
59
+ zipUrl = resolved.path;
60
+ sourceType = "zip-url";
61
+ originalSource = resolved.path;
62
+ }
63
+ const buffer = await downloadZip(zipUrl);
64
+ const staging = path.join(this.homeDir, "plugins", "managed", `_staging-${this.now()}`);
65
+ root = await extractZip(buffer, staging);
66
+ // Monorepo plugin (e.g. openai/plugins → plugins/<name>): descend into the subdirectory.
67
+ if (resolved.kind === "github" && resolved.subdir !== undefined) {
68
+ root = path.join(root, resolved.subdir);
69
+ }
70
+ }
71
+ const parsed = await parseManifest(this.machine, root);
72
+ if (parsed.manifest === undefined) {
73
+ const msg = parsed.diagnostics.find((d) => d.severity === "error")?.message ?? "no manifest";
74
+ throw new Error(`Cannot install plugin from ${originalSource}: ${msg}`);
75
+ }
76
+ const id = normalizePluginId(parsed.manifest.name);
77
+ const existing = this.records.get(id);
78
+ const stamp = new Date(this.now()).toISOString();
79
+ const record = recordFrom({
80
+ id,
81
+ root,
82
+ source: sourceType,
83
+ enabled: existing?.enabled ?? true,
84
+ installedAt: existing?.installedAt ?? stamp,
85
+ updatedAt: stamp,
86
+ originalSource,
87
+ capabilities: existing?.capabilities,
88
+ github,
89
+ parsed,
90
+ });
91
+ this.records.set(id, record);
92
+ await this.persist();
93
+ return record;
94
+ }
95
+ async setEnabled(id, enabled) {
96
+ const key = normalizePluginId(id);
97
+ const current = this.records.get(key);
98
+ if (current === undefined)
99
+ throw new Error(`Plugin "${id}" is not installed`);
100
+ if (current.enabled === enabled)
101
+ return;
102
+ this.records.set(key, { ...current, enabled, updatedAt: new Date(this.now()).toISOString() });
103
+ await this.persist();
104
+ }
105
+ async setMcpServerEnabled(id, server, enabled) {
106
+ const key = normalizePluginId(id);
107
+ const current = this.records.get(key);
108
+ if (current === undefined)
109
+ throw new Error(`Plugin "${id}" is not installed`);
110
+ if (current.manifest?.mcpServers?.[server] === undefined) {
111
+ throw new Error(`Plugin "${id}" does not declare MCP server "${server}"`);
112
+ }
113
+ const currentMcpServers = current.capabilities?.mcpServers ?? {};
114
+ const nextCapabilities = {
115
+ ...current.capabilities,
116
+ mcpServers: {
117
+ ...currentMcpServers,
118
+ [server]: { enabled },
119
+ },
120
+ };
121
+ this.records.set(key, {
122
+ ...current,
123
+ capabilities: nextCapabilities,
124
+ updatedAt: new Date(this.now()).toISOString(),
125
+ });
126
+ await this.persist();
127
+ }
128
+ async remove(id) {
129
+ if (!this.records.delete(normalizePluginId(id)))
130
+ throw new Error(`Plugin "${id}" is not installed`);
131
+ await this.persist();
132
+ }
133
+ async reload() {
134
+ const prevIds = new Set(this.records.keys());
135
+ const file = await readInstalled(this.machine, this.homeDir);
136
+ const next = new Map();
137
+ const errors = [];
138
+ for (const entry of file.plugins) {
139
+ try {
140
+ next.set(entry.id, await this.materialize(entry));
141
+ }
142
+ catch (error) {
143
+ errors.push({ id: entry.id, message: error.message });
144
+ next.set(entry.id, errorRecord(entry));
145
+ }
146
+ }
147
+ const added = [...next.keys()].filter((id) => !prevIds.has(id));
148
+ const removed = [...prevIds].filter((id) => !next.has(id));
149
+ this.records = next;
150
+ return { added, removed, errors };
151
+ }
152
+ skillRoots() {
153
+ const roots = [];
154
+ for (const record of this.enabledOk()) {
155
+ for (const dir of record.manifest.skills ?? []) {
156
+ roots.push({ path: dir, source: "extra", plugin: { id: record.id, instructions: record.skillInstructions } });
157
+ }
158
+ }
159
+ return roots;
160
+ }
161
+ mcpServerConfigs() {
162
+ const out = {};
163
+ for (const record of this.enabledOk()) {
164
+ for (const [name, config] of Object.entries(record.manifest.mcpServers ?? {})) {
165
+ if (!isMcpServerEnabled(record, name, config))
166
+ continue;
167
+ out[pluginMcpRuntimeName(record.id, name)] = { ...config, enabled: true };
168
+ }
169
+ }
170
+ return out;
171
+ }
172
+ sessionStarts() {
173
+ const out = [];
174
+ for (const record of this.enabledOk()) {
175
+ const skill = record.manifest.sessionStart?.skill;
176
+ if (skill !== undefined)
177
+ out.push({ pluginId: record.id, skillName: skill });
178
+ }
179
+ return out;
180
+ }
181
+ /**
182
+ * Shell hooks contributed by enabled plugins (PLUGIN_ROOT already expanded at parse time).
183
+ * Order is stable: plugins sorted by id, then hook declaration order within each plugin.
184
+ */
185
+ hookDefs() {
186
+ const out = [];
187
+ const records = this.enabledOk().toSorted((a, b) => a.id.localeCompare(b.id));
188
+ for (const record of records) {
189
+ for (const hook of record.manifest.hooks ?? [])
190
+ out.push(hook);
191
+ }
192
+ return out;
193
+ }
194
+ summaries() {
195
+ return this.list().map(recordToSummary);
196
+ }
197
+ info(id) {
198
+ const record = this.get(id);
199
+ return record === undefined ? undefined : recordToInfo(record);
200
+ }
201
+ enabledOk() {
202
+ return [...this.records.values()].filter((r) => r.enabled && r.state === "ok" && r.manifest !== undefined);
203
+ }
204
+ async persist() {
205
+ const installed = [...this.records.values()].map((r) => ({
206
+ id: r.id,
207
+ root: r.root,
208
+ source: r.source,
209
+ enabled: r.enabled,
210
+ installedAt: r.installedAt,
211
+ updatedAt: r.updatedAt,
212
+ originalSource: r.originalSource,
213
+ capabilities: r.capabilities,
214
+ github: r.github,
215
+ }));
216
+ await writeInstalled(this.machine, this.homeDir, { version: 1, plugins: installed });
217
+ }
218
+ async materialize(entry) {
219
+ const parsed = await parseManifest(this.machine, entry.root);
220
+ return recordFrom({
221
+ id: entry.id,
222
+ root: entry.root,
223
+ source: entry.source,
224
+ enabled: entry.enabled,
225
+ installedAt: entry.installedAt,
226
+ updatedAt: entry.updatedAt,
227
+ originalSource: entry.originalSource,
228
+ capabilities: entry.capabilities,
229
+ github: entry.github,
230
+ parsed,
231
+ });
232
+ }
233
+ }
234
+ function recordFrom(input) {
235
+ const { parsed } = input;
236
+ const hasError = parsed.diagnostics.some((d) => d.severity === "error") || parsed.manifest === undefined;
237
+ return {
238
+ id: input.id,
239
+ root: input.root,
240
+ source: input.source,
241
+ enabled: input.enabled,
242
+ state: hasError ? "error" : "ok",
243
+ installedAt: input.installedAt,
244
+ updatedAt: input.updatedAt,
245
+ originalSource: input.originalSource,
246
+ capabilities: input.capabilities,
247
+ github: input.github,
248
+ manifest: parsed.manifest,
249
+ manifestPath: parsed.manifestPath,
250
+ diagnostics: parsed.diagnostics,
251
+ skillInstructions: parsed.manifest?.skillInstructions,
252
+ };
253
+ }
254
+ function errorRecord(entry) {
255
+ return {
256
+ id: entry.id,
257
+ root: entry.root,
258
+ source: entry.source,
259
+ enabled: entry.enabled,
260
+ state: "error",
261
+ installedAt: entry.installedAt,
262
+ updatedAt: entry.updatedAt,
263
+ originalSource: entry.originalSource,
264
+ capabilities: entry.capabilities,
265
+ github: entry.github,
266
+ diagnostics: [{ severity: "error", message: `Plugin root unreadable: ${entry.root}` }],
267
+ };
268
+ }
269
+ function recordToSummary(record) {
270
+ return {
271
+ id: record.id,
272
+ displayName: record.manifest?.interface?.displayName ?? record.id,
273
+ version: record.manifest?.version,
274
+ enabled: record.enabled,
275
+ state: record.state,
276
+ skillCount: (record.manifest?.skills ?? []).length,
277
+ mcpServerCount: Object.keys(record.manifest?.mcpServers ?? {}).length,
278
+ enabledMcpServerCount: pluginMcpServersInfo(record).filter((server) => server.enabled).length,
279
+ hasErrors: record.diagnostics.some((d) => d.severity === "error"),
280
+ source: record.source,
281
+ originalSource: record.originalSource,
282
+ github: record.github,
283
+ };
284
+ }
285
+ function recordToInfo(record) {
286
+ return {
287
+ ...recordToSummary(record),
288
+ root: record.root,
289
+ installedAt: record.installedAt,
290
+ updatedAt: record.updatedAt,
291
+ manifestPath: record.manifestPath,
292
+ manifest: record.manifest,
293
+ mcpServers: pluginMcpServersInfo(record),
294
+ diagnostics: record.diagnostics,
295
+ };
296
+ }
297
+ function isMcpServerEnabled(record, name, config) {
298
+ return record.capabilities?.mcpServers?.[name]?.enabled ?? config.enabled !== false;
299
+ }
300
+ function pluginMcpServersInfo(record) {
301
+ return Object.entries(record.manifest?.mcpServers ?? {})
302
+ .map(([name, config]) => pluginMcpServerInfo(record, name, config))
303
+ .toSorted((a, b) => a.name.localeCompare(b.name));
304
+ }
305
+ function pluginMcpServerInfo(record, name, config) {
306
+ if (config.transport === "http") {
307
+ return {
308
+ name,
309
+ runtimeName: pluginMcpRuntimeName(record.id, name),
310
+ enabled: isMcpServerEnabled(record, name, config),
311
+ transport: "http",
312
+ ...(config.url !== undefined ? { url: config.url } : {}),
313
+ ...(config.headers !== undefined ? { headerKeys: Object.keys(config.headers).toSorted() } : {}),
314
+ };
315
+ }
316
+ return {
317
+ name,
318
+ runtimeName: pluginMcpRuntimeName(record.id, name),
319
+ enabled: isMcpServerEnabled(record, name, config),
320
+ transport: "stdio",
321
+ ...(config.command !== undefined ? { command: config.command } : {}),
322
+ ...(config.args !== undefined ? { args: config.args } : {}),
323
+ ...(config.cwd !== undefined ? { cwd: config.cwd } : {}),
324
+ ...(config.env !== undefined ? { envKeys: Object.keys(config.env).toSorted() } : {}),
325
+ };
326
+ }
327
+ function pluginMcpRuntimeName(pluginId, serverName) {
328
+ return `plugin-${pluginId}:${serverName}`;
329
+ }
330
+ //# sourceMappingURL=manager.js.map
@@ -0,0 +1,9 @@
1
+ import { type Machine } from "../index.ts";
2
+ import { type PluginDiagnostic, type PluginManifest } from "./types.ts";
3
+ export interface ParsedManifestResult {
4
+ readonly manifest?: PluginManifest;
5
+ readonly manifestPath?: string;
6
+ readonly diagnostics: readonly PluginDiagnostic[];
7
+ }
8
+ export declare function parseManifest(machine: Machine, pluginRoot: string): Promise<ParsedManifestResult>;
9
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1,234 @@
1
+ import path from "node:path";
2
+ import { McpServerConfigSchema } from "../index.js";
3
+ import { loadPluginHooks } from "./hooks.js";
4
+ import { PLUGIN_NAME_REGEX } from "./types.js";
5
+ import { readTextFile } from "../tool/support/machine-ops.js";
6
+ const PLUGIN_ROOT_MANIFEST = "agents.plugin.json";
7
+ const PLUGIN_DIR_MANIFEST = ".agents-plugin/plugin.json";
8
+ // Codex-format plugins (github.com/openai/plugins): same manifest shape, different filename, and
9
+ // `mcpServers` is a PATH to a `.mcp.json` rather than an inline object — handled in readMcpServers.
10
+ const CODEX_DIR_MANIFEST = ".codex-plugin/plugin.json";
11
+ // Runtime fields we still do not execute. `hooks` is supported (see loadPluginHooks).
12
+ const UNSUPPORTED_RUNTIME_FIELDS = ["tools", "commands", "apps", "inject", "configFile", "bootstrap"];
13
+ export async function parseManifest(machine, pluginRoot) {
14
+ const candidates = [PLUGIN_ROOT_MANIFEST, PLUGIN_DIR_MANIFEST, CODEX_DIR_MANIFEST];
15
+ let manifestPath;
16
+ for (const candidate of candidates) {
17
+ const candidatePath = path.join(pluginRoot, candidate);
18
+ if (await isFile(machine, candidatePath)) {
19
+ manifestPath = candidatePath;
20
+ break;
21
+ }
22
+ }
23
+ if (manifestPath === undefined) {
24
+ return { diagnostics: [{ severity: "error", message: `No manifest at ${candidates.join(", ")}` }] };
25
+ }
26
+ let raw;
27
+ try {
28
+ raw = JSON.parse(await readTextFile(machine, manifestPath));
29
+ }
30
+ catch (error) {
31
+ return { manifestPath, diagnostics: [{ severity: "error", message: `Failed to parse ${manifestPath}: ${error.message}` }] };
32
+ }
33
+ if (!isObject(raw)) {
34
+ return { manifestPath, diagnostics: [{ severity: "error", message: "manifest must be a JSON object" }] };
35
+ }
36
+ const diagnostics = [];
37
+ const name = typeof raw["name"] === "string" ? raw["name"].trim() : "";
38
+ if (name.length === 0) {
39
+ diagnostics.push({ severity: "error", message: '"name" is required' });
40
+ return { manifestPath, diagnostics };
41
+ }
42
+ if (!PLUGIN_NAME_REGEX.test(name)) {
43
+ diagnostics.push({ severity: "error", message: `"name" must match ${PLUGIN_NAME_REGEX} (got "${name}")` });
44
+ return { manifestPath, diagnostics };
45
+ }
46
+ let skills = await resolveSkillsField(machine, pluginRoot, raw["skills"], diagnostics);
47
+ if (raw["skills"] === undefined && (await isFile(machine, path.join(pluginRoot, "SKILL.md")))) {
48
+ skills = [pluginRoot];
49
+ }
50
+ for (const field of UNSUPPORTED_RUNTIME_FIELDS) {
51
+ if (raw[field] !== undefined)
52
+ diagnostics.push({ severity: "info", message: `"${field}" is present but not supported` });
53
+ }
54
+ const hooks = await loadPluginHooks(machine, pluginRoot, raw["hooks"], diagnostics);
55
+ const manifest = {
56
+ name,
57
+ version: stringField(raw, "version"),
58
+ description: stringField(raw, "description"),
59
+ keywords: stringArrayField(raw, "keywords"),
60
+ homepage: stringField(raw, "homepage"),
61
+ license: stringField(raw, "license"),
62
+ author: readAuthor(raw["author"]),
63
+ skills,
64
+ sessionStart: readSessionStart(raw["sessionStart"], diagnostics),
65
+ mcpServers: await readMcpServers(machine, pluginRoot, raw["mcpServers"], diagnostics),
66
+ ...(hooks.length > 0 ? { hooks } : {}),
67
+ interface: readInterface(raw["interface"]),
68
+ skillInstructions: typeof raw["skillInstructions"] === "string" ? raw["skillInstructions"] : undefined,
69
+ };
70
+ return { manifest, manifestPath, diagnostics };
71
+ }
72
+ async function resolveSkillsField(machine, pluginRoot, raw, diagnostics) {
73
+ if (raw === undefined)
74
+ return [];
75
+ const entries = [];
76
+ if (typeof raw === "string")
77
+ entries.push(raw);
78
+ else if (Array.isArray(raw) && raw.every((e) => typeof e === "string"))
79
+ entries.push(...raw);
80
+ else {
81
+ diagnostics.push({ severity: "error", message: '"skills" must be a string or string[]' });
82
+ return [];
83
+ }
84
+ const resolved = [];
85
+ for (const entry of entries) {
86
+ if (!entry.startsWith("./")) {
87
+ diagnostics.push({ severity: "error", message: `"skills" path must start with "./" (got "${entry}")` });
88
+ continue;
89
+ }
90
+ const absolute = path.resolve(pluginRoot, entry);
91
+ if (!isWithin(absolute, pluginRoot)) {
92
+ diagnostics.push({ severity: "error", message: `"skills" path resolves outside the plugin (${entry})` });
93
+ continue;
94
+ }
95
+ if (!(await isDir(machine, absolute))) {
96
+ diagnostics.push({ severity: "warn", message: `"skills" path is not a directory (${entry})` });
97
+ continue;
98
+ }
99
+ resolved.push(absolute);
100
+ }
101
+ return resolved;
102
+ }
103
+ function readSessionStart(raw, diagnostics) {
104
+ if (raw === undefined)
105
+ return undefined;
106
+ if (!isObject(raw)) {
107
+ diagnostics.push({ severity: "warn", message: '"sessionStart" must be an object' });
108
+ return undefined;
109
+ }
110
+ const skill = typeof raw["skill"] === "string" ? raw["skill"].trim() : "";
111
+ if (skill.length === 0) {
112
+ diagnostics.push({ severity: "warn", message: '"sessionStart.skill" is required when sessionStart is present' });
113
+ return undefined;
114
+ }
115
+ return { skill };
116
+ }
117
+ async function readMcpServers(machine, pluginRoot, raw, diagnostics) {
118
+ if (raw === undefined)
119
+ return undefined;
120
+ // Codex format: `mcpServers` is a path to a `.mcp.json` ({ "mcpServers": { … } }). Read it and
121
+ // treat its `mcpServers` object as the inline map. (`McpServerConfigSchema` already accepts the
122
+ // Codex `type` field and normalises it to `transport`.)
123
+ let servers = raw;
124
+ if (typeof raw === "string") {
125
+ if (!raw.startsWith("./")) {
126
+ diagnostics.push({ severity: "warn", message: `"mcpServers" path must start with "./" (got "${raw}")` });
127
+ return undefined;
128
+ }
129
+ const absolute = path.resolve(pluginRoot, raw);
130
+ if (!isWithin(absolute, pluginRoot)) {
131
+ diagnostics.push({ severity: "warn", message: `"mcpServers" path resolves outside the plugin (${raw})` });
132
+ return undefined;
133
+ }
134
+ try {
135
+ const parsed = JSON.parse(await readTextFile(machine, absolute));
136
+ servers = isObject(parsed) && isObject(parsed["mcpServers"]) ? parsed["mcpServers"] : parsed;
137
+ }
138
+ catch (error) {
139
+ diagnostics.push({ severity: "warn", message: `Failed to read MCP file ${raw}: ${error.message}` });
140
+ return undefined;
141
+ }
142
+ }
143
+ if (!isObject(servers)) {
144
+ diagnostics.push({ severity: "warn", message: '"mcpServers" must be an object or a path to a .mcp.json' });
145
+ return undefined;
146
+ }
147
+ const out = {};
148
+ for (const [name, value] of Object.entries(servers)) {
149
+ const trimmedName = name.trim();
150
+ if (trimmedName.length === 0) {
151
+ diagnostics.push({ severity: "warn", message: '"mcpServers" entries must have a non-empty name' });
152
+ continue;
153
+ }
154
+ const parsed = McpServerConfigSchema.safeParse(value);
155
+ if (!parsed.success) {
156
+ diagnostics.push({ severity: "warn", message: `Invalid MCP server "${trimmedName}": ${parsed.error.message}` });
157
+ continue;
158
+ }
159
+ out[trimmedName] = await normalizePluginMcpServer(machine, pluginRoot, trimmedName, parsed.data, diagnostics);
160
+ }
161
+ return Object.keys(out).length === 0 ? undefined : out;
162
+ }
163
+ async function normalizePluginMcpServer(machine, pluginRoot, name, config, diagnostics) {
164
+ // stdio `./command` resolves within the plugin root; bare names stay PATH commands.
165
+ if (config.transport === "stdio" && typeof config.command === "string" && config.command.startsWith("./")) {
166
+ const absolute = path.resolve(pluginRoot, config.command);
167
+ if (isWithin(absolute, pluginRoot)) {
168
+ if (!(await isFile(machine, absolute))) {
169
+ diagnostics.push({ severity: "warn", message: `"mcpServers.${name}.command" not found (${config.command})` });
170
+ }
171
+ return { ...config, command: absolute };
172
+ }
173
+ diagnostics.push({ severity: "warn", message: `"mcpServers.${name}.command" resolves outside the plugin` });
174
+ }
175
+ return config;
176
+ }
177
+ function readAuthor(raw) {
178
+ if (typeof raw === "string")
179
+ return { name: raw };
180
+ if (!isObject(raw))
181
+ return undefined;
182
+ const name = stringField(raw, "name");
183
+ const email = stringField(raw, "email");
184
+ if (name === undefined && email === undefined)
185
+ return undefined;
186
+ return { name, email };
187
+ }
188
+ function readInterface(raw) {
189
+ if (!isObject(raw))
190
+ return undefined;
191
+ const out = {
192
+ displayName: stringField(raw, "displayName"),
193
+ shortDescription: stringField(raw, "shortDescription"),
194
+ longDescription: stringField(raw, "longDescription"),
195
+ };
196
+ return Object.values(out).some((v) => v !== undefined) ? out : undefined;
197
+ }
198
+ function stringField(raw, key) {
199
+ const value = raw[key];
200
+ if (typeof value !== "string")
201
+ return undefined;
202
+ const trimmed = value.trim();
203
+ return trimmed.length === 0 ? undefined : trimmed;
204
+ }
205
+ function stringArrayField(raw, key) {
206
+ const value = raw[key];
207
+ if (!Array.isArray(value) || !value.every((e) => typeof e === "string"))
208
+ return undefined;
209
+ return value;
210
+ }
211
+ function isObject(value) {
212
+ return typeof value === "object" && value !== null && !Array.isArray(value);
213
+ }
214
+ function isWithin(child, parent) {
215
+ const relative = path.relative(parent, child);
216
+ return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
217
+ }
218
+ async function isFile(machine, p) {
219
+ try {
220
+ return (await machine.fileInfo(p)).kind === "file";
221
+ }
222
+ catch {
223
+ return false;
224
+ }
225
+ }
226
+ async function isDir(machine, p) {
227
+ try {
228
+ return (await machine.fileInfo(p)).kind === "dir";
229
+ }
230
+ catch {
231
+ return false;
232
+ }
233
+ }
234
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Plugin marketplace = a github plugin repo (Codex format, e.g. github.com/openai/plugins). The repo
3
+ * IS the registry: `.agents/plugins/marketplace.json` lists plugins, each living in a subdir with its
4
+ * own `.codex-plugin/plugin.json`. The repo is cached ONCE (see `materializeGithubRepo`) and then the
5
+ * index + plugins are read from the local copy — no per-plugin downloads, no raw fetches.
6
+ *
7
+ * This module is the neutral *mechanism*: it hardcodes NO repo, NO curation, renders no UI. Only the
8
+ * Codex schema is accepted — an entry's `source` is an object `{ source: "local"|"git-subdir"|"url",
9
+ * … }`. (The legacy operon string-source schema was removed: nobody published those.)
10
+ */
11
+ export interface MarketplaceEntry {
12
+ readonly id: string;
13
+ readonly displayName: string;
14
+ /** Install source — for a `local` Codex entry, an absolute path inside the cached repo. */
15
+ readonly source: string;
16
+ readonly tier?: string;
17
+ readonly version?: string;
18
+ readonly description?: string;
19
+ readonly homepage?: string;
20
+ readonly keywords?: readonly string[];
21
+ }
22
+ export interface Marketplace {
23
+ /** The source the registry was loaded from (the github repo ref). */
24
+ readonly source: string;
25
+ readonly version?: string;
26
+ readonly plugins: readonly MarketplaceEntry[];
27
+ }
28
+ export interface LoadMarketplaceOptions {
29
+ /** The marketplace github repo: `owner/repo[@ref]` shorthand or a github.com repo URL. */
30
+ readonly source: string;
31
+ /**
32
+ * Local directory the repo has been materialized (cached) into — see `materializeGithubRepo`. The
33
+ * index is read from `<repoDir>/.agents/plugins/marketplace.json` and each `local` entry resolves
34
+ * to an absolute path under `<repoDir>` (so installing it is a local copy, not a download).
35
+ */
36
+ readonly repoDir: string;
37
+ }
38
+ interface MarketplaceLocation {
39
+ readonly repoRoot: string;
40
+ readonly source: string;
41
+ }
42
+ /** Read + validate a marketplace registry from a cached github repo. */
43
+ export declare function loadMarketplace(options: LoadMarketplaceOptions): Promise<Marketplace>;
44
+ /**
45
+ * Download a github repo's ZIP archive (one request) and extract it into `destDir`, returning the
46
+ * extracted repo root. For a monorepo marketplace this is fetched ONCE and then both browsing and
47
+ * installing read from the local copy — instead of re-downloading the whole repo per plugin. The
48
+ * caller owns `destDir` (and any caching/refresh policy); pass a fresh/empty dir.
49
+ */
50
+ export declare function materializeGithubRepo(options: {
51
+ readonly owner: string;
52
+ readonly repo: string;
53
+ readonly ref?: string;
54
+ readonly destDir: string;
55
+ }): Promise<string>;
56
+ /** Parse + validate a marketplace registry string against a cached repo location. */
57
+ export declare function parseMarketplace(raw: string, location: MarketplaceLocation): Marketplace;
58
+ /**
59
+ * Recognise a github repo marketplace reference: `owner/repo[@ref]` shorthand or a github.com repo
60
+ * URL. Returns the repo coordinates (so a caller can cache the repo) or undefined for non-repo
61
+ * sources. Exported so embedders can validate config + cache the repo.
62
+ */
63
+ export declare function parseGithubMarketplaceSource(source: string): {
64
+ owner: string;
65
+ repo: string;
66
+ ref?: string;
67
+ } | undefined;
68
+ /** Rich, displayable metadata for a single marketplace entry, read from its plugin manifest. */
69
+ export interface MarketplaceEntryDetails {
70
+ readonly displayName?: string;
71
+ readonly description?: string;
72
+ /** Absolute https URL to the logo, if the manifest gives one directly. */
73
+ readonly logoUrl?: string;
74
+ /** Absolute local file path to the logo (cached repo) — the embedder serves this. */
75
+ readonly logoPath?: string;
76
+ readonly brandColor?: string;
77
+ }
78
+ /**
79
+ * Read displayable details (logo/description) for one marketplace entry from its plugin manifest in
80
+ * the cached repo. `source` is the entry's install source; only a local plugin dir is enrichable.
81
+ * Returns null when the source isn't local or no manifest/fields are found ("no extras").
82
+ */
83
+ export declare function loadMarketplaceEntryDetails(source: string): Promise<MarketplaceEntryDetails | null>;
84
+ export {};
85
+ //# sourceMappingURL=marketplace.d.ts.map