@runlith/tagma 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (342) hide show
  1. package/adapter/claudeHooks.d.ts +10 -0
  2. package/adapter/claudeHooks.js +4 -0
  3. package/adapter/declaration.d.ts +14 -0
  4. package/adapter/declaration.js +2 -0
  5. package/adapter/harness.d.ts +454 -0
  6. package/adapter/harness.js +2 -0
  7. package/adapter/hook.d.ts +43 -0
  8. package/adapter/hook.js +2 -0
  9. package/adapter/hostModules.d.ts +19 -0
  10. package/adapter/hostModules.js +2 -0
  11. package/adapter/loader.d.ts +10 -0
  12. package/adapter/loader.js +2 -0
  13. package/adapter/metadata.d.ts +179 -0
  14. package/adapter/metadata.js +4 -0
  15. package/adapter/payload.d.ts +19 -0
  16. package/adapter/payload.js +3 -0
  17. package/adapter/provider.d.ts +209 -0
  18. package/adapter/provider.js +2 -0
  19. package/adapter/settings.d.ts +182 -0
  20. package/adapter/settings.js +2 -0
  21. package/adapter/speech.d.ts +4 -0
  22. package/adapter/speech.js +2 -0
  23. package/host.d.ts +61223 -0
  24. package/package.json +129 -3
  25. package/plugin/Held-6krt6ncs.js +6 -0
  26. package/plugin/accountKey-tdjj67f5.js +2 -0
  27. package/plugin/adapter-qdnpxs6n.js +1 -0
  28. package/plugin/anthropic-a4pdzrv2.js +2 -0
  29. package/plugin/anthropic-messages-7gtja121.js +2 -0
  30. package/plugin/anthropic-z9xqmm3q.js +2 -0
  31. package/plugin/auth-0w6kk39v.js +2 -0
  32. package/plugin/authStatus-a1g3eb9p.js +2 -0
  33. package/plugin/bundling.d.ts +30 -0
  34. package/plugin/bundling.js +2 -0
  35. package/plugin/cacheLifetime-c5mpw676.js +2 -0
  36. package/plugin/callback-server-0wrzmjfx.js +16 -0
  37. package/plugin/capabilities-n3vfpy41.js +2 -0
  38. package/plugin/claudeHooks-edpg1e46.js +3 -0
  39. package/plugin/cli.js +21 -0
  40. package/plugin/cliStore-9rhjxtht.js +2 -0
  41. package/plugin/clientSession-tmmxm39z.js +2 -0
  42. package/plugin/codec-aa8mxqyr.js +1 -0
  43. package/plugin/connect-vrdsw05j.js +2 -0
  44. package/plugin/contract-qn0z7r9c.js +1 -0
  45. package/plugin/credential-5sgapkh0.js +2 -0
  46. package/plugin/deepseek-fvdrmjr9.js +2 -0
  47. package/plugin/deepseek-v388d1wv.js +2 -0
  48. package/plugin/definition-s3xx207f.js +2 -0
  49. package/plugin/description-8xhxryaq.js +2 -0
  50. package/plugin/deviceGrant-vgbscpr4.js +2 -0
  51. package/plugin/devin-hy98d305.js +2 -0
  52. package/plugin/duplex-kpmftvf7.js +2 -0
  53. package/plugin/endpoint-kvf97tz7.js +2 -0
  54. package/plugin/errors-5t42p4q1.js +2 -0
  55. package/plugin/events-e8vv9hda.js +2 -0
  56. package/plugin/events-s95ybm4g.js +2 -0
  57. package/plugin/executor-q8kp5q8h.js +2 -0
  58. package/plugin/failure-vr32debc.js +2 -0
  59. package/plugin/framing-nktw5sts.js +2 -0
  60. package/plugin/grant-67b10nhx.js +2 -0
  61. package/plugin/harness-nrh78w4d.js +2 -0
  62. package/plugin/headers-ss3dzznj.js +2 -0
  63. package/plugin/hook-hjrk83m8.js +2 -0
  64. package/plugin/icon-044pa3y8.js +6 -0
  65. package/plugin/icon-j22svmgp.js +4 -0
  66. package/plugin/icon-ny6qbjvc.js +4 -0
  67. package/plugin/icon-pz54e8n3.js +4 -0
  68. package/plugin/icon-qy92jx2b.js +4 -0
  69. package/plugin/ids-n269hc5k.js +2 -0
  70. package/plugin/images-q80x3bt1.js +2 -0
  71. package/plugin/index-cyd7v366.js +2 -0
  72. package/plugin/index-jpmjpmkn.js +2 -0
  73. package/plugin/lifecycle-qf4fh5m8.js +2 -0
  74. package/plugin/manual-2mdscj84.js +2 -0
  75. package/plugin/messages-1szh3p3k.js +2 -0
  76. package/plugin/metadata-zm1v3ptf.js +4 -0
  77. package/plugin/muse-r16jp51z.js +2 -0
  78. package/plugin/muse-tfe6sph7.js +2 -0
  79. package/plugin/museToolSchema-tbe0f3wa.js +2 -0
  80. package/plugin/notes-6amdhm6h.js +2 -0
  81. package/plugin/object-9pjtdam7.js +2 -0
  82. package/plugin/open-browser-vqb7ckt1.js +2 -0
  83. package/plugin/openai-0z6fy497.js +2 -0
  84. package/plugin/openai-37dne8v0.js +2 -0
  85. package/plugin/openai-compatible-chat-tq9w69h4.js +2 -0
  86. package/plugin/openai-images-x1sj79qh.js +2 -0
  87. package/plugin/openai-responses-dka6k753.js +2 -0
  88. package/plugin/opencodeGo-173fz5c5.js +3 -0
  89. package/plugin/opencodeGo-qgw3pfg6.js +2 -0
  90. package/plugin/options-pxwjpfdk.js +2 -0
  91. package/plugin/payload-2gr4q9g8.js +2 -0
  92. package/plugin/pkce-nrpept7w.js +2 -0
  93. package/plugin/plugin-1n46me5n.js +6 -0
  94. package/plugin/plugin-1vpp5mqk.js +4 -0
  95. package/plugin/plugin-1x94cj6e.js +3 -0
  96. package/plugin/plugin-1xze8f5y.js +3 -0
  97. package/plugin/plugin-285exjxd.js +3 -0
  98. package/plugin/plugin-3b8x73y6.js +3 -0
  99. package/plugin/plugin-3pfrkxg1.js +3 -0
  100. package/plugin/plugin-3whwpedj.js +3 -0
  101. package/plugin/plugin-521srf94.js +3 -0
  102. package/plugin/plugin-55fbx586.js +3 -0
  103. package/plugin/plugin-5zq084fb.js +3 -0
  104. package/plugin/plugin-60bdzk1r.js +4 -0
  105. package/plugin/plugin-6a56xsx3.js +3 -0
  106. package/plugin/plugin-6xpcmvm3.js +36 -0
  107. package/plugin/plugin-72xxqm1t.js +3 -0
  108. package/plugin/plugin-7y7ndrk9.js +3 -0
  109. package/plugin/plugin-80gqwmjy.js +3 -0
  110. package/plugin/plugin-8230g28p.js +3 -0
  111. package/plugin/plugin-8jf7f360.js +3 -0
  112. package/plugin/plugin-92redty0.js +3 -0
  113. package/plugin/plugin-9gha9fx3.js +3 -0
  114. package/plugin/plugin-a4ng6krf.js +3 -0
  115. package/plugin/plugin-ak62rhwz.js +3 -0
  116. package/plugin/plugin-ay29ch70.js +3 -0
  117. package/plugin/plugin-ba1sv0th.js +3 -0
  118. package/plugin/plugin-ca4vf4j5.js +3 -0
  119. package/plugin/plugin-cydz2zhy.js +3 -0
  120. package/plugin/plugin-d6hbav22.js +3 -0
  121. package/plugin/plugin-e2y95zm5.js +3 -0
  122. package/plugin/plugin-ff38dxy1.js +3 -0
  123. package/plugin/plugin-ff9hx5a4.js +3 -0
  124. package/plugin/plugin-fhc5q7r3.js +3 -0
  125. package/plugin/plugin-frrvs5yc.js +3 -0
  126. package/plugin/plugin-g65b14k1.js +3 -0
  127. package/plugin/plugin-gh857xdd.js +3 -0
  128. package/plugin/plugin-gkgs7vfv.js +3 -0
  129. package/plugin/plugin-h66k1zhn.js +14 -0
  130. package/plugin/plugin-je5cfnqn.js +3 -0
  131. package/plugin/plugin-jjm52353.js +3 -0
  132. package/plugin/plugin-jxvmq18y.js +3 -0
  133. package/plugin/plugin-kc4z9msd.js +3 -0
  134. package/plugin/plugin-kjtzm2q6.js +3 -0
  135. package/plugin/plugin-krbbb4ts.js +3 -0
  136. package/plugin/plugin-me00x60n.js +3 -0
  137. package/plugin/plugin-mqr325kz.js +3 -0
  138. package/plugin/plugin-njh1f7b2.js +5 -0
  139. package/plugin/plugin-nkb5bb2q.js +3 -0
  140. package/plugin/plugin-nqmb78ez.js +4 -0
  141. package/plugin/plugin-nzacjxf9.js +3 -0
  142. package/plugin/plugin-p59gy5xd.js +3 -0
  143. package/plugin/plugin-pfj9nc2e.js +3 -0
  144. package/plugin/plugin-pkxw1pfs.js +3 -0
  145. package/plugin/plugin-q1n5kwx0.js +3 -0
  146. package/plugin/plugin-q1sqj2tc.js +3 -0
  147. package/plugin/plugin-q7rk75bs.js +3 -0
  148. package/plugin/plugin-qpda63gv.js +3 -0
  149. package/plugin/plugin-rrgyjesv.js +3 -0
  150. package/plugin/plugin-sfdxgkds.js +3 -0
  151. package/plugin/plugin-v7k9fx92.js +3 -0
  152. package/plugin/plugin-vfjhxng8.js +3 -0
  153. package/plugin/plugin-vv72e4ah.js +3 -0
  154. package/plugin/plugin-w8f977my.js +3 -0
  155. package/plugin/plugin-xbnw80pk.js +3 -0
  156. package/plugin/plugin-yxgg03s0.js +5 -0
  157. package/plugin/plugin-z6hkd9rw.js +3 -0
  158. package/plugin/plugin-zew2m18x.js +3 -0
  159. package/plugin/plugin-zphe2a5v.js +9 -0
  160. package/plugin/plugin-zvyk8bnr.js +3 -0
  161. package/plugin/plugin-zw3ywa4b.js +3 -0
  162. package/plugin/plugin-zxe49p72.js +3 -0
  163. package/plugin/plugin-zz7yc97m.js +3 -0
  164. package/plugin/plugin.d.ts +175 -0
  165. package/plugin/plugin.js +2 -0
  166. package/plugin/points.generated.d.ts +341 -0
  167. package/plugin/points.generated.js +2 -0
  168. package/plugin/process.d.ts +4 -0
  169. package/plugin/process.js +85 -0
  170. package/plugin/protocol-hwnfh4h1.js +2 -0
  171. package/plugin/protocol.d.ts +115 -0
  172. package/plugin/protocol.js +2 -0
  173. package/plugin/provider-0b7xxyhn.js +2 -0
  174. package/plugin/quota-vrrmfag6.js +2 -0
  175. package/plugin/quotaRead-vj6e90xc.js +2 -0
  176. package/plugin/reasoning-5nanktp2.js +2 -0
  177. package/plugin/record-1m3vvy60.js +2 -0
  178. package/plugin/requests-2zyr1g8e.js +1 -0
  179. package/plugin/responseFold-w4526gvb.js +2 -0
  180. package/plugin/settings-vdypzert.js +2 -0
  181. package/plugin/shared-a2yyy8ry.js +2 -0
  182. package/plugin/speech-067caz1a.js +2 -0
  183. package/plugin/stepfun-3en5g41d.js +2 -0
  184. package/plugin/stepfun-bwsz4nrd.js +2 -0
  185. package/plugin/stream-bt8etfpc.js +2 -0
  186. package/plugin/svelteProgram-73v9yajk.js +2 -0
  187. package/plugin/synthesisDuplex-m2j6pmyv.js +2 -0
  188. package/plugin/template.d.ts +14 -0
  189. package/plugin/template.js +2 -0
  190. package/plugin/testing.d.ts +85 -0
  191. package/plugin/testing.js +4 -0
  192. package/plugin/tool-content-b9jtprr7.js +2 -0
  193. package/plugin/tool-stream-gdajdxn0.js +2 -0
  194. package/plugin/transport-7hfp9sn4.js +2 -0
  195. package/plugin/ui.generated.d.ts +1044 -0
  196. package/plugin/value.d.ts +8 -0
  197. package/plugin/value.js +2 -0
  198. package/plugin/vendor-pn6b5a8f.js +2 -0
  199. package/plugin/vendorCall-6n5chrn0.js +2 -0
  200. package/plugin/vendorCall-hv01nwsp.js +2 -0
  201. package/plugin/vendorPayload-awxqr7t8.js +2 -0
  202. package/plugin/vendorWeb-vnf344r1.js +2 -0
  203. package/plugin/verbatim-mqt9x4aa.js +2 -0
  204. package/plugin/xai-e8sbtk6a.js +2 -0
  205. package/plugin/xai-z1ysta23.js +2 -0
  206. package/rules/effect.d.ts +55 -0
  207. package/rules/effect.js +11 -0
  208. package/rules/rules.d.ts +342 -0
  209. package/rules/rules.js +50 -0
  210. package/types/node/assert/strict.d.ts +12 -0
  211. package/types/node/assert.d.ts +76 -0
  212. package/types/node/async_hooks.d.ts +113 -0
  213. package/types/node/buffer.buffer.d.ts +29 -0
  214. package/types/node/buffer.d.ts +162 -0
  215. package/types/node/child_process.d.ts +337 -0
  216. package/types/node/cluster.d.ts +118 -0
  217. package/types/node/compatibility/iterators.d.ts +11 -0
  218. package/types/node/console.d.ts +48 -0
  219. package/types/node/constants.d.ts +8 -0
  220. package/types/node/crypto.d.ts +847 -0
  221. package/types/node/dgram.d.ts +88 -0
  222. package/types/node/diagnostics_channel.d.ts +61 -0
  223. package/types/node/dns/promises.d.ts +94 -0
  224. package/types/node/dns.d.ts +276 -0
  225. package/types/node/domain.d.ts +17 -0
  226. package/types/node/events.d.ts +138 -0
  227. package/types/node/fs/promises.d.ts +253 -0
  228. package/types/node/fs.d.ts +1038 -0
  229. package/types/node/globals.d.ts +73 -0
  230. package/types/node/globals.typedarray.d.ts +22 -0
  231. package/types/node/http.d.ts +530 -0
  232. package/types/node/http2.d.ts +794 -0
  233. package/types/node/https.d.ts +66 -0
  234. package/types/node/index.d.ts +84 -0
  235. package/types/node/inspector/promises.d.ts +13 -0
  236. package/types/node/inspector.d.ts +61 -0
  237. package/types/node/inspector.generated.d.ts +1624 -0
  238. package/types/node/module.d.ts +187 -0
  239. package/types/node/net.d.ts +266 -0
  240. package/types/node/os.d.ts +236 -0
  241. package/types/node/path/posix.d.ts +8 -0
  242. package/types/node/path/win32.d.ts +8 -0
  243. package/types/node/path.d.ts +40 -0
  244. package/types/node/perf_hooks.d.ts +236 -0
  245. package/types/node/process.d.ts +436 -0
  246. package/types/node/punycode.d.ts +15 -0
  247. package/types/node/querystring.d.ts +22 -0
  248. package/types/node/quic.d.ts +203 -0
  249. package/types/node/readline/promises.d.ts +28 -0
  250. package/types/node/readline.d.ts +94 -0
  251. package/types/node/repl.d.ts +104 -0
  252. package/types/node/sea.d.ts +11 -0
  253. package/types/node/sqlite.d.ts +183 -0
  254. package/types/node/stream/consumers.d.ts +13 -0
  255. package/types/node/stream/iter.d.ts +240 -0
  256. package/types/node/stream/promises.d.ts +37 -0
  257. package/types/node/stream/web.d.ts +297 -0
  258. package/types/node/stream.d.ts +378 -0
  259. package/types/node/string_decoder.d.ts +10 -0
  260. package/types/node/test/reporters.d.ts +66 -0
  261. package/types/node/test.d.ts +462 -0
  262. package/types/node/timers/promises.d.ts +16 -0
  263. package/types/node/timers.d.ts +43 -0
  264. package/types/node/tls.d.ts +279 -0
  265. package/types/node/trace_events.d.ts +16 -0
  266. package/types/node/ts5.6/buffer.buffer.d.ts +26 -0
  267. package/types/node/ts5.6/compatibility/float16array.d.ts +43 -0
  268. package/types/node/ts5.6/globals.typedarray.d.ts +22 -0
  269. package/types/node/ts5.6/index.d.ts +84 -0
  270. package/types/node/ts5.7/compatibility/float16array.d.ts +50 -0
  271. package/types/node/ts5.7/index.d.ts +84 -0
  272. package/types/node/tty.d.ts +61 -0
  273. package/types/node/url.d.ts +165 -0
  274. package/types/node/util/types.d.ts +49 -0
  275. package/types/node/util.d.ts +320 -0
  276. package/types/node/v8.d.ts +178 -0
  277. package/types/node/vm.d.ts +130 -0
  278. package/types/node/wasi.d.ts +26 -0
  279. package/types/node/web-globals/abortcontroller.d.ts +47 -0
  280. package/types/node/web-globals/blob.d.ts +34 -0
  281. package/types/node/web-globals/console.d.ts +7 -0
  282. package/types/node/web-globals/crypto.d.ts +46 -0
  283. package/types/node/web-globals/domexception.d.ts +74 -0
  284. package/types/node/web-globals/encoding.d.ts +16 -0
  285. package/types/node/web-globals/events.d.ts +111 -0
  286. package/types/node/web-globals/fetch.d.ts +121 -0
  287. package/types/node/web-globals/importmeta.d.ts +11 -0
  288. package/types/node/web-globals/messaging.d.ts +32 -0
  289. package/types/node/web-globals/navigator.d.ts +28 -0
  290. package/types/node/web-globals/performance.d.ts +71 -0
  291. package/types/node/web-globals/storage.d.ts +26 -0
  292. package/types/node/web-globals/streams.d.ts +162 -0
  293. package/types/node/web-globals/timers.d.ts +22 -0
  294. package/types/node/web-globals/url.d.ts +27 -0
  295. package/types/node/worker_threads.d.ts +199 -0
  296. package/types/node/zlib/iter.d.ts +49 -0
  297. package/types/node/zlib.d.ts +360 -0
  298. package/types/undici/agent.d.ts +24 -0
  299. package/types/undici/api.d.ts +19 -0
  300. package/types/undici/balanced-pool.d.ts +16 -0
  301. package/types/undici/cache-interceptor.d.ts +98 -0
  302. package/types/undici/cache.d.ts +30 -0
  303. package/types/undici/client-stats.d.ts +9 -0
  304. package/types/undici/client.d.ts +61 -0
  305. package/types/undici/connector.d.ts +37 -0
  306. package/types/undici/content-type.d.ts +9 -0
  307. package/types/undici/cookies.d.ts +22 -0
  308. package/types/undici/diagnostics-channel.d.ts +72 -0
  309. package/types/undici/dispatcher.d.ts +207 -0
  310. package/types/undici/env-http-proxy-agent.d.ts +15 -0
  311. package/types/undici/errors.d.ts +117 -0
  312. package/types/undici/eventsource.d.ts +39 -0
  313. package/types/undici/fetch.d.ts +122 -0
  314. package/types/undici/formdata.d.ts +24 -0
  315. package/types/undici/global-dispatcher.d.ts +4 -0
  316. package/types/undici/global-origin.d.ts +3 -0
  317. package/types/undici/h2c-client.d.ts +35 -0
  318. package/types/undici/handlers.d.ts +7 -0
  319. package/types/undici/header.d.ts +10 -0
  320. package/types/undici/index.d.ts +85 -0
  321. package/types/undici/interceptors.d.ts +70 -0
  322. package/types/undici/mock-agent.d.ts +43 -0
  323. package/types/undici/mock-call-history.d.ts +57 -0
  324. package/types/undici/mock-client.d.ts +17 -0
  325. package/types/undici/mock-errors.d.ts +9 -0
  326. package/types/undici/mock-interceptor.d.ts +60 -0
  327. package/types/undici/mock-pool.d.ts +17 -0
  328. package/types/undici/patch.d.ts +21 -0
  329. package/types/undici/pool-stats.d.ts +11 -0
  330. package/types/undici/pool.d.ts +25 -0
  331. package/types/undici/proxy-agent.d.ts +22 -0
  332. package/types/undici/readable.d.ts +24 -0
  333. package/types/undici/retry-agent.d.ts +6 -0
  334. package/types/undici/retry-handler.d.ts +41 -0
  335. package/types/undici/round-robin-pool.d.ts +25 -0
  336. package/types/undici/snapshot-agent.d.ts +98 -0
  337. package/types/undici/socks5-proxy-agent.d.ts +17 -0
  338. package/types/undici/util.d.ts +4 -0
  339. package/types/undici/utility.d.ts +2 -0
  340. package/types/undici/webidl.d.ts +121 -0
  341. package/types/undici/websocket.d.ts +130 -0
  342. package/README.md +0 -3
@@ -0,0 +1,10 @@
1
+ /// <reference path="../types/node/index.d.ts" />
2
+ /// <reference path="../host.d.ts" />
3
+ import type { FileEffect, HarnessCall, HarnessPrinted, HookEvents, HookOccasion } from "@runlith/tagma/adapter/harness";
4
+ import { type HookCodec } from "@runlith/tagma/adapter/hook";
5
+ export declare const claudeCodec: HookCodec;
6
+ export declare const CLAUDE_EVENTS: HookEvents;
7
+ export declare const claudeSubject: (event: Record<string, unknown>) => HarnessCall | null;
8
+ export declare const claudeFiles: (event: Record<string, unknown>) => readonly FileEffect[];
9
+ export declare const claudePrinted: (event: Record<string, unknown>) => HarnessPrinted | null;
10
+ export declare const claudeOccasion: HookOccasion;
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ var u=(o,e)=>({hooks:[{type:"command",command:o,...e===void 0?{}:{timeout:e}}]}),d=(o,e)=>JSON.stringify({hookSpecificOutput:{hookEventName:o,additionalContext:e}}),c=({allowed:o,words:e})=>JSON.stringify({decision:o?"approve":"deny",reason:e}),p=(o)=>(e)=>d(o,e),f=(o,e)=>(t,r)=>d(r==="before"?o:e,t);var w=(o)=>o===void 0?[]:[o];function n(o,e){let t=o[e];return typeof t==="string"&&t.trim().length>0?t.trim():null}function i(o,e){let t=o[e];return t!==null&&typeof t==="object"&&!Array.isArray(t)?t:{}}var _=(o)=>n(o,"session_id")??n(o,"sessionId"),S=()=>null,b=()=>null,R=()=>null,E=(o,e)=>e===null?null:n(o,e),C=()=>[],F=()=>null,h=[{mark:"*** Add File:",effect:"write"},{mark:"*** Update File:",effect:"write"},{mark:"*** Delete File:",effect:"delete"}],m="*** Move to:";function P(o){let e=[];for(let t of o.split(`
3
+ `)){let r=h.find((l)=>t.startsWith(l.mark));if(r!==void 0){let l=t.slice(r.mark.length).trim();if(l.length>0)e.push({effect:r.effect,path:l});continue}if(!t.startsWith(m))continue;let s=t.slice(m.length).trim(),a=e[e.length-1];if(s.length===0)continue;if(a?.effect==="write")e[e.length-1]={effect:"move",path:s,from:a.path};else e.push({effect:"write",path:s})}return e}var g=(o)=>["askuserquestion","ask_user_question","request_user_input"].includes(o?.toLowerCase()??""),O=(o,e=!1)=>(t)=>{let r=e?[o,"--session-id"]:[o];for(let s=1;s<t.length;s+=1){let a=t[s];if(a!==void 0&&r.includes(a))return t[s+1]??null}return null},T=(o,e=[])=>{if(!("model"in o))return null;let t=n(o,"model");if(t===null)return{read:"absent"};return{read:"value",value:t,claim:e.includes(t)?"configured":"serving"}},U=(o)=>{let e=n(o,"tool_name")??n(o,"toolName");if(e===null)return null;let t=i(o,"tool_input"),r=n(t,"command")??n(t,"cmd")??n(t,"file_path")??n(t,"notebook_path")??n(t,"path")??n(t,"url")??n(t,"query")??n(t,"pattern")??n(o,"tool_input")??JSON.stringify(o.tool_input??{});return{id:n(o,"tool_use_id")??n(o,"toolUseId"),tool:e,subject:r}},y=(o,e)=>{let t=e[(n(o,"tool_name")??n(o,"toolName")??"").toLowerCase()];if(t===void 0)return null;let r=i(o,"tool_input"),s=t==="bash"?n(r,"command"):n(r,"file_path");return s===null?null:{id:n(o,"tool_use_id")??n(o,"toolUseId"),tool:t,subject:s}};var M={file:{keys:{},events:["hooks"],holes:!1,trust:null,entry:u},permission:c,context:(o)=>o,tool:f("PreToolUse","PostToolUse"),prompt:p("UserPromptSubmit")},L={sessionStart:"SessionStart",preWrite:"PreToolUse",postWrite:"PostToolUse",postRead:"PostToolUse",stop:"Stop",permission:"PermissionRequest",prompt:"UserPromptSubmit",sessionEnd:"SessionEnd",toolFailure:"PostToolUseFailure",stopFailure:"StopFailure",notification:"Notification"},x={bash:"bash",exec:"bash",edit:"edit",multiedit:"edit",write:"write",read:"read"},j=(o)=>y(o,x),D=(o)=>{let e=n(i(o,"tool_input"),"file_path");if(e===null)return[];let t=n(o,"tool_name")??n(o,"toolName");return[{effect:t!==null&&t.toLowerCase()!=="read"?"write":"read",path:e}]},k=(o,e)=>{let t=o.tool_response;if(typeof t==="string")return t;let r=i(o,"tool_response");return e.flatMap((s)=>typeof r[s]==="string"?[r[s]]:[]).join(`
4
+ `)},V=(o)=>{let e=(n(o,"tool_name")??n(o,"toolName"))?.toLowerCase(),t=i(o,"tool_input");if(e==="bash"){let l=n(t,"command");return l===null?null:{_tag:"Shell",command:l,output:k(o,["stdout","stderr"])}}if(e!=="grep")return null;let r=i(o,"tool_response").filenames,s=n(t,"path");return{_tag:"Search",found:[...Array.isArray(r)?r.filter((l)=>typeof l==="string"):[],...s===null?[]:[s]],output:k(o,["content"])}},I=(o)=>{switch(o.name){case"SessionStart":return"session-start";case"UserPromptSubmit":return"turn-start";case"Stop":case"StopFailure":case"SessionEnd":return"turn-end";case"PermissionRequest":return"self-description";case"PreToolUse":return g(o.tool)?"wait":"activity";case"PostToolUse":case"PostToolUseFailure":return"activity";default:return"self-description"}};export{L as CLAUDE_EVENTS,M as claudeCodec,D as claudeFiles,I as claudeOccasion,V as claudePrinted,j as claudeSubject};
@@ -0,0 +1,14 @@
1
+ /// <reference path="../types/node/index.d.ts" />
2
+ /// <reference path="../host.d.ts" />
3
+ import type { AdapterHost, AdapterSettings, Provider } from "@runlith/tagma/adapter/provider";
4
+ export type Declaration = {
5
+ readonly providers: readonly Provider[];
6
+ readonly settings: AdapterSettings | undefined;
7
+ };
8
+ export type SectionClaim = {
9
+ readonly title: string;
10
+ readonly default: string;
11
+ readonly modes: ReadonlyMap<string, string>;
12
+ };
13
+ export declare const claimSections: (claims: ReadonlyMap<string, SectionClaim>, providers: readonly Provider[], holder: string) => ReadonlyMap<string, SectionClaim>;
14
+ export declare const declare: (models: unknown, host: AdapterHost, taken?: ReadonlyMap<string, string>, sections?: ReadonlyMap<string, SectionClaim>) => Declaration;
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Schema as c,SchemaGetter as P}from"effect";function A(e,r,n){if(r==="__proto__")Object.defineProperty(e,r,{value:n,enumerable:!0,writable:!0,configurable:!0});else e[r]=n}function T(e){return k(e,[])??null}function k(e,r){switch(typeof e){case"string":case"boolean":return e;case"number":return Number.isFinite(e)?e:null;case"bigint":return e.toString();case"object":return e===null?null:J(e,r);default:return}}function J(e,r){if(r.includes(e))return;r.push(e);let n=e.toJSON,i=typeof n==="function"?k(n.call(e),r):Array.isArray(e)?q(e,r):W(e,r);return r.pop(),i}function q(e,r){let n=null;for(let i=0;i<e.length;i+=1){let o=e[i],u=k(o,r)??null;if(n===null&&u!==o)n=e.slice(0,i);if(n!==null)n.push(u)}return n??e}function W(e,r){let n=Object.getPrototypeOf(e),i=n===Object.prototype||n===null,o=e instanceof Error?{...e,message:e.message}:e,u=Object.keys(o),p=i?null:{};for(let y=0;y<u.length;y+=1){let m=u[y],f=o[m],t=k(f,r);if(p===null&&(t!==f||t===void 0)){p={};for(let s of u.slice(0,y))A(p,s,o[s])}if(p!==null&&t!==void 0)A(p,m,t)}return p??e}var O=c.Unknown.pipe(c.encodeTo(c.Unknown,{encode:P.transform((e)=>T(e)),decode:P.passthrough()})),U=c.Record(c.String,O),ce=c.Record(c.String,U).annotate({identifier:"LLM.ProviderMetadata"}),pe=c.String,ye=c.String,ge=c.String.pipe(c.brand("LLM.ModelID")),fe=c.String.pipe(c.brand("LLM.ProviderID")),me=c.String,he=c.String,xe=c.String,E=["none","minimal","low","medium","high","xhigh","max"],Se=c.Literals(E),be=c.Literals(["low","medium","high"]),ke=c.Literals(["system","user","assistant","tool"]),Me=c.Literals(["stop","length","tool-calls","content-filter","error","unknown"]),we=c.Record(c.String,O);var L=new Set(["max"]);function R(e){let r=Object.entries(e.models).filter(([,o])=>o.operatorOnly===!0&&o.capabilities.includes("text"));if(r.length>0){let o=e.spawnTextModel;if(!o)return`Provider "${e.id}" has operator-only text model "${r[0]?.[0]}" but no spawnTextModel.`;let u=e.models[o];if(!u?.capabilities.includes("text"))return`Provider "${e.id}" spawnTextModel "${o}" is absent or not a text model.`;if(u.operatorOnly)return`Provider "${e.id}" spawnTextModel "${o}" is operator-only.`}let n=e.lightTextModel;if(n!==void 0){let o=e.models[n.model];if(!o?.capabilities.includes("text")||o.operatorOnly)return`Provider "${e.id}" lightTextModel "${n.model}" is absent, not a text model or operator-only.`;if(n.rung===null?o.reasoning.length>0:!o.reasoning.includes(n.rung))return`Provider "${e.id}" lightTextModel "${n.model}" offers no rung ${n.rung??"none"}.`}let i=Object.entries(e.models).find(([,o])=>o.capabilities.includes("text")&&!o.capacity);if(i!==void 0)return`Text model capacity is required for ${e.id}/${i[0]}.`;if(e.defaultTextModel===""&&!Object.values(e.models).some((o)=>o.capabilities.includes("text")))return null;if(!e.models[e.defaultTextModel]?.capabilities.includes("text"))return`Provider "${e.id}" defaultTextModel "${e.defaultTextModel}" is absent or not a text model.`;return null}function F(e){let r=new Map;for(let t of e){if(r.has(t.id))throw Error(`Provider "${t.id}" is registered twice.`);let s=R(t);if(s!==null)throw Error(s);r.set(t.id,t)}let n=e.flatMap((t)=>Object.entries(t.models).map(([s,l])=>({id:s,key:`${t.id}:${s}`,label:l.label,short:l.short??l.label,provider:t.id,providerLabel:t.label,capacity:l.capacity,cacheLifetime:t.cacheLifetime,requestLimits:t.requestLimits,capabilities:l.capabilities,toolChoice:l.toolChoice,reasoningOptions:l.reasoning.map((g)=>({id:g,label:z(g),short:B(g)})),defaultReasoning:l.defaultReasoning,switches:l.switches??[],supportsAdaptiveThinking:l.supportsAdaptiveThinking??!1,operatorOnly:l.operatorOnly??!1,compactionTrigger:l.compactionTrigger}))),i=(t)=>{let s=r.get(t);if(!s)throw Error(`Unknown model provider "${t}" \u2014 this catalog registers: ${e.map((l)=>l.id).join(", ")}.`);return s},o=(t)=>n.filter((s)=>s.capabilities.includes(t)),u=(t,s)=>o(s).filter((l)=>l.provider===t),p=(t,s)=>{let l=r.get(t);if(l===void 0)return;let g=s??l.defaultTextModel,b=u(l.id,"text");return b.find((w)=>w.id===g)??b.find((w)=>l.models[w.id]?.aliases?.includes(g))},y=(t,s)=>{let l=p(t,s);if(!l?.capacity){let g=i(t);throw Error(`Text model capacity is not configured for ${t}/${s??g.defaultTextModel}.`)}return l},m=(t,s)=>{let l=y(t,s);return l.operatorOnly?y(t,i(t).spawnTextModel):l},f=(t,s,l)=>{let g=Q(s,t);if(!g)return null;if(!L.has(g)||l&&!t.operatorOnly)return g;return t.reasoningOptions.filter((b)=>!L.has(b.id)).at(-1)?.id??null};return{providers:e,providerOptions:e.map((t)=>({id:t.id,label:t.label})),options:n,registered:(t)=>r.has(t),named:i,oauth:(t)=>i(t).auth==="oauth",providerLabel:(t)=>r.get(t)?.label??t,modelsOf:(t)=>n.filter((s)=>s.provider===t),modelsFor:u,modelsByCapability:o,defaultTextModelId:(t)=>i(t).defaultTextModel,findTextModel:p,resolveTextModel:y,spawnInherits:m,spawnReasoning:f,textModelCapacity:(t,s)=>{let l=y(t,s);if(!l.capacity)throw Error(`Text model capacity is not configured for ${l.key}.`);return l.capacity},namedSelection:(t,s)=>({provider:t,model:y(t,s).id}),supportsAdaptiveThinking:(t,s)=>y(t,s).supportsAdaptiveThinking,textModelIds:()=>{let t=[...new Set(o("text").map((s)=>s.id))];if(t.length===0)throw Error("Model catalog has no text models.");return t},reasoningLevelIds:()=>{let t=[...new Set(n.flatMap((s)=>s.reasoningOptions.map((l)=>l.id)))];if(t.length===0)throw Error("Model catalog has no reasoning levels.");return t}}}function Q(e,r){if(!r||r.reasoningOptions.length===0)return"";if(e&&r.reasoningOptions.some((n)=>n.id===e))return e;if(r.defaultReasoning&&r.reasoningOptions.some((n)=>n.id===r.defaultReasoning))return r.defaultReasoning;return r.reasoningOptions.find((n)=>n.id==="high")?.id??r.reasoningOptions[0]?.id??""}function z(e){switch(e){case"none":return"None";case"minimal":return"Minimal";case"low":return"Low";case"medium":return"Medium";case"high":return"High";case"xhigh":return"XHigh";case"max":return"Max";default:return e}}function B(e){switch(e){case"none":return"None";case"minimal":return"Min";case"low":return"Low";case"medium":return"Med";case"high":return"High";case"xhigh":return"XH";case"max":return"Max";default:return e}}import{Schema as v}from"effect";import{Schema as a}from"effect";var I=a.Struct({id:a.String,label:a.String}),x={id:a.String,label:a.String,hint:a.optional(a.String),required:a.optional(a.Literal(!0)),secret:a.optional(a.Literal(!0))},_=a.Union([a.Struct({...x,type:a.Literal("text"),placeholder:a.optional(a.String)}),a.Struct({...x,type:a.Literal("number"),min:a.optional(a.Number),unit:a.optional(a.String),placeholder:a.optional(a.String)}),a.Struct({...x,type:a.Literal("flag")}),a.Struct({...x,type:a.Literal("choice"),options:a.Array(I),default:a.optional(a.String)}),a.Struct({...x,type:a.Literal("set"),options:a.Array(I)})]),N=a.Union([_,a.Struct({...x,type:a.Literal("rows"),noun:a.String,fields:a.Array(_),discoverable:a.optional(a.Literal(!0))})]);import{Schema as d}from"effect";var X=200,G=160,V=d.String.check(d.isPattern(/^[a-z][a-z0-9-]*$/u),d.isMaxLength(64)),H=["tagma","lode"],Pe="tagma",Y=d.Literals(["configured","serving","last-recorded"]),Oe=d.Literals(["hook","vendor-record","transcript","session-store","terminal","protocol"]),Ee=d.Union([d.Struct({read:d.Literal("value"),value:d.String.check(d.isMaxLength(X)),claim:Y}),d.Struct({read:d.Literal("absent")}),d.Struct({read:d.Literal("unsupported")}),d.Struct({read:d.Literal("unreadable"),reason:d.String.check(d.isMaxLength(G))})]),Le=d.Struct({value:d.String,label:d.String,description:d.optional(d.String)}),Fe=d.Literals(["choice"]),Ie=d.Struct({id:d.NullOr(d.String.check(d.isMinLength(1))),tool:d.String.check(d.isMinLength(1)),subject:d.String.check(d.isMinLength(1))}),$e=["catalog","proxy"],Z=1e4,_e={chars:Z,basis:"unmeasured"},D="tagma";function Ne(e){let r=e[D];if(r===null)throw Error(`The harness cannot express permission stance ${D}.`);return r}function De(e,r){if(r===void 0)return[];let n=r.rung===null?r.model:`${r.model} at ${r.rung}`;if(e===null)throw Error(`The harness declares no model surface and cannot launch on ${n}.`);return e.argv(r)}var Ve={_tag:"char",char:"\x03"},je=()=>null,Ke=()=>null,Je=(e)=>(r,n)=>n.length===1?e(r,n[0]):null,qe=(e,r)=>{if(e.selected===null)return null;let n=e.options.findIndex((u)=>u.value===e.selected),i=e.options.findIndex((u)=>u.value===r);if(n<0||i<0)return null;let o=i>n?"down":"up";return[...Array.from({length:Math.abs(i-n)}).fill(o),"enter"]},We=(e,r)=>e.options.some((n)=>n.value===r)?[...r].map((n)=>({_tag:"char",char:n})):null,Ue=(e,r,n=e.findLastIndex((i)=>r(i)!==null))=>{if(n<0)return null;let i=[],o=[],u=n;for(;u>=0;u-=1){let p=r(e[u]);if(p===null)break;if(i.push({value:p.value,label:p.label}),p.selected)o.push(p.value)}return i.reverse(),{options:i,selected:o.length===1?o[0]:null,marked:o.length,above:u}},M={asksFrom:"never"},h={asksFrom:"review",timeout:"none"},Qe={names:"kind",byName:{bash:{kind:"execute",approval:h},read:{kind:"read",approval:M},ls:{kind:"read",approval:M},glob:{kind:"read",approval:M},grep:{kind:"read",approval:M},write:{kind:"write",approval:h},edit:{kind:"write",approval:h},delete:{kind:"write",approval:h},rename:{kind:"write",approval:h},webfetch:{kind:"network",approval:h},websearch:{kind:"network",approval:h}}};var ee=(e,r,n)=>{let i=new Map(e);for(let{accountMode:o}of r){if(o===void 0)continue;let u=i.get(o.section);i.set(o.section,{title:u?.title??o.title,default:u?.default??o.default,modes:new Map([...u?.modes??[],[o.id,n]])})}return i},ne=(e,r)=>{let n=r.accountMode,i=n===void 0?void 0:e.get(n.section);if(n===void 0||i===void 0)return null;let o=i.modes.get(n.id);if(o!==void 0)return`provider "${r.id}" declares mode "${n.id}" of section "${n.section}", already declared by ${o}`;if(i.title!==n.title||i.default!==n.default)return`provider "${r.id}" declares section "${n.section}" with another title or default mode than its other modes`;return null},C=(e)=>typeof e?.program!=="string"||!Array.isArray(e.args)||e.args.some((r)=>typeof r!=="string"),re=(e)=>typeof e.directory!=="string"||e.directory===""||C(e.login)||C(e.status)||typeof e.loggedIn!=="function"||e.renew!==void 0&&C(e.renew),j=(e)=>{if(e===void 0||e.credential==null||typeof e.key!=="function"||typeof e.label!=="function")return!0;if(!Array.isArray(e.signIns)||e.signIns.length===0)return!0;let r=new Set;for(let n of e.signIns){if(r.has(n.kind))return!0;switch(r.add(n.kind),n.kind){case"loopback":if(typeof n.run!=="function")return!0;break;case"device":if(n.vendor==null||typeof n.store!=="function")return!0;break;case"paste":if(typeof n.begin!=="function")return!0;break;case"key":if(typeof n.store!=="function")return!0;break;default:return!0}}return!1},te=v.is(V),oe=(e)=>{let{terminal:r,acp:n}=e;if(!te(e.id)||H.includes(e.id))return`harness provider "${e.id}" needs an id of up to 64 lowercase letters, digits and hyphens that starts with a letter and is none of ${H.join(", ")}`;if(r!==void 0&&(!S(r.binary)||!S(r.prefix)||typeof r.launch?.interactive!=="function"||typeof r.launch.resume!=="function"||typeof r.launch.root!=="function"))return`harness provider "${e.id}" declares a terminal surface without its binary, session prefix or launch`;if(n!==void 0&&(typeof n.argv!=="function"||typeof n.configure!=="function"))return`harness provider "${e.id}" declares an ACP surface without its argv or configure`;if(r!==void 0&&n!==void 0&&n.hosts===null&&n.argv(void 0)[0]!==r.binary)return`harness provider "${e.id}" launches its ACP agent with a program other than its terminal binary ${r.binary}`;if(r===void 0&&n!==void 0&&n.hosts!==null&&!S(n.program))return`harness provider "${e.id}" hosts its ACP agent without a terminal surface and names no program its runner drives`;return null};function ie(e){if(typeof e.id!=="string"||e.id==="")return"a provider declares no id";if(e.catalog!==void 0&&typeof e.catalog.read!=="function")return`provider "${e.id}" declares a malformed catalog reader`;if(e.dynamicCatalog===!0&&e.catalog===void 0)return`provider "${e.id}" declares a dynamic catalog without its reader`;let{id:r,accountMode:n}=e;if(n!==void 0&&[n.section,n.title,n.default,n.id,n.label,n.hint].some((i)=>typeof i!=="string"||i===""))return`provider "${e.id}" declares a malformed account mode`;if(n!==void 0&&e.accounts===void 0)return`provider "${e.id}" declares an account mode without accounts`;if(e.kind==="wire"){if(typeof e.profile?.model!=="function")return`provider "${e.id}" declares no request profile`;if(typeof e.quota?.read!=="function")return`provider "${e.id}" declares no quota`;if(e.auth==="cli")return`wire provider "${e.id}" signs in through a CLI`;if(e.auth==="oauth"&&j(e.accounts))return`provider "${e.id}" declares no subscription accounts`;if(Object.keys(e.imageModels??{}).length>0&&typeof e.images?.generate!=="function")return`provider "${e.id}" declares image models without an image profile`;return null}if(e.kind==="harness"){if(e.imageModels!==void 0)return`harness provider "${e.id}" declares image models`;let i=oe(e);if(i!==null)return i;if(typeof e.environment!=="function")return`provider "${e.id}" declares no account environment`;if(e.auth==="api-key")return j(e.accounts)?`provider "${e.id}" declares malformed key accounts`:null;if(e.accounts!==void 0&&re(e.accounts))return`provider "${e.id}" declares malformed accounts`;return e.auth==="cli"?null:`harness provider "${r}" declares no supported sign-in`}return`provider "${String(e.id)}" is neither a wire nor a harness provider`}var ae=v.is(v.Array(N)),S=(e)=>typeof e==="string"&&e!=="",K=(e)=>(e.type==="choice"||e.type==="set")&&e.options.length===0||e.type==="rows"&&(e.fields.length===0||e.fields.some(K)),se=(e)=>{if(e===void 0)return null;if(!S(e.title)||!S(e.instance)||!S(e.name))return"the adapter declares settings without a title, an instance name or a naming field";if(!ae(e.fields))return"the adapter declares settings fields the Providers screen cannot draw";if(new Set(e.fields.map((r)=>r.id)).size!==e.fields.length||e.fields.some(K))return"the adapter declares settings fields with repeated ids, or choices without options";if(e.fields.some((r)=>r.type==="rows"&&r.fields.some((n)=>n.id==="_source"||n.id==="_key")))return"row fields use reserved form metadata names";if(!e.fields.some((r)=>r.id===e.name&&r.type==="text"))return"the adapter declares settings without a text field that names an instance";if(e.validate!==void 0&&typeof e.validate!=="function"||e.discover!==void 0&&typeof e.discover!=="function")return"the adapter declares settings whose validate or discover is not a function";return null},Ze=(e,r,n=new Map,i=new Map)=>{if(typeof e!=="function")throw Error("models is not an adapter: make it with defineAdapter");let o=e,u=se(o.settings);if(u!==null)throw Error(u);let p=o(r);if(!Array.isArray(p))throw Error("the adapter does not answer a list of providers");let y=p.map((t)=>t.catalog===void 0?t:{...t,dynamicCatalog:!0}),m=new Set,f=i;for(let t of y){let s=ie(t)??R(t)??ne(f,t);if(s!==null)throw Error(s);let l=n.get(t.id)??(m.has(t.id)?"this adapter":void 0);if(l!==void 0)throw Error(`provider "${t.id}" is already declared by adapter ${l}`);m.add(t.id),f=ee(f,[t],"this adapter")}return F(y),{providers:y,settings:o.settings}};export{ee as claimSections,Ze as declare};
@@ -0,0 +1,454 @@
1
+ /// <reference path="../types/node/index.d.ts" />
2
+ /// <reference path="../host.d.ts" />
3
+ import { Schema, type Effect, type FileSystem, type PlatformError } from "effect";
4
+ import type { Approval, PermissionKind } from "@runlith/tagma/internal/packages/agent/src/permissions/vocabulary";
5
+ import type { TransportFailure } from "@runlith/tagma/internal/packages/agent/src/transcript/entries";
6
+ import type { TransportCapabilities, TransportWeb } from "@runlith/tagma/internal/packages/agent/src/thread/record";
7
+ import type { ModelSwitches } from "@runlith/llm/models/description";
8
+ import type { HookCodec } from "@runlith/tagma/adapter/hook";
9
+ import type { MetadataReader } from "@runlith/tagma/adapter/metadata";
10
+ export declare const HARNESS_ID_MAX = 200;
11
+ export declare const HARNESS_DETAIL_MAX = 160;
12
+ export declare const harnessNameSchema: Schema.String;
13
+ export declare const RESERVED_HARNESS_NAMES: readonly string[];
14
+ export declare const HOST_COMMAND = "tagma";
15
+ export declare const harnessClaimSchema: Schema.Literals<readonly [
16
+ "configured",
17
+ "serving",
18
+ "last-recorded"
19
+ ]>;
20
+ export type HarnessClaim = typeof harnessClaimSchema.Type;
21
+ export declare const harnessProvenanceSchema: Schema.Literals<readonly [
22
+ "hook",
23
+ "vendor-record",
24
+ "transcript",
25
+ "session-store",
26
+ "terminal",
27
+ "protocol"
28
+ ]>;
29
+ export type HarnessProvenance = typeof harnessProvenanceSchema.Type;
30
+ export declare const harnessModelReportSchema: Schema.Union<readonly [
31
+ Schema.Struct<{
32
+ readonly read: Schema.Literal<"value">;
33
+ readonly value: Schema.String;
34
+ readonly claim: Schema.Literals<readonly [
35
+ "configured",
36
+ "serving",
37
+ "last-recorded"
38
+ ]>;
39
+ }>,
40
+ Schema.Struct<{
41
+ readonly read: Schema.Literal<"absent">;
42
+ }>,
43
+ Schema.Struct<{
44
+ readonly read: Schema.Literal<"unsupported">;
45
+ }>,
46
+ Schema.Struct<{
47
+ readonly read: Schema.Literal<"unreadable">;
48
+ readonly reason: Schema.String;
49
+ }>
50
+ ]>;
51
+ export type HarnessModelReport = typeof harnessModelReportSchema.Type;
52
+ export declare const harnessQuestionOptionSchema: Schema.Struct<{
53
+ readonly value: Schema.String;
54
+ readonly label: Schema.String;
55
+ readonly description: Schema.optional<Schema.String>;
56
+ }>;
57
+ export type HarnessQuestionOption = typeof harnessQuestionOptionSchema.Type;
58
+ export declare const harnessQuestionKindSchema: Schema.Literals<readonly [
59
+ "choice"
60
+ ]>;
61
+ export type HarnessQuestionKind = typeof harnessQuestionKindSchema.Type;
62
+ export declare const harnessCallSchema: Schema.Struct<{
63
+ readonly id: Schema.NullOr<Schema.String>;
64
+ readonly tool: Schema.String;
65
+ readonly subject: Schema.String;
66
+ }>;
67
+ export type HarnessCall = typeof harnessCallSchema.Type;
68
+ export declare const MCP_TOOL_SHAPES: readonly [
69
+ "catalog",
70
+ "proxy"
71
+ ];
72
+ export type McpToolShape = (typeof MCP_TOOL_SHAPES)[number];
73
+ export type HookEvents = {
74
+ readonly sessionStart: string | null;
75
+ readonly preWrite: string | null;
76
+ readonly postWrite: string | null;
77
+ readonly postRead: string | null;
78
+ readonly stop: string | null;
79
+ readonly permission: string | null;
80
+ readonly agentResponse?: string;
81
+ readonly prompt?: string;
82
+ readonly sessionEnd?: string;
83
+ readonly toolFailure?: string;
84
+ readonly stopFailure?: string;
85
+ readonly notification?: string;
86
+ };
87
+ export type HookUserFile = {
88
+ readonly folder: readonly string[];
89
+ readonly file: string;
90
+ readonly homeEnv?: string;
91
+ };
92
+ export type HookAsset = {
93
+ readonly file: string;
94
+ readonly content: string;
95
+ };
96
+ export type HookContextLimit = {
97
+ readonly chars: number;
98
+ readonly basis: 'measured' | 'reported' | 'unmeasured';
99
+ };
100
+ export declare const HOOK_CONTEXT_CHARS = 10000;
101
+ export declare const UNMEASURED_HOOK_CONTEXT: HookContextLimit;
102
+ export type HookSurface = {
103
+ readonly file: string;
104
+ readonly assets?: readonly HookAsset[];
105
+ readonly codec: HookCodec;
106
+ readonly events: HookEvents;
107
+ readonly user: HookUserFile | null;
108
+ readonly context: HookContextLimit;
109
+ readonly promptContext?: boolean;
110
+ };
111
+ export type McpConfigFile = {
112
+ readonly _tag: 'Project';
113
+ readonly path: string;
114
+ } | {
115
+ readonly _tag: 'Home';
116
+ readonly folder: readonly string[];
117
+ readonly file: string;
118
+ readonly homeEnv?: string;
119
+ };
120
+ export type McpSurface = {
121
+ readonly file: McpConfigFile;
122
+ readonly format: 'json' | 'toml';
123
+ readonly servers: string | readonly string[];
124
+ readonly environment?: string;
125
+ readonly declaration?: (cli: readonly string[], environment: Readonly<Record<string, string>>) => Readonly<Record<string, unknown>>;
126
+ readonly fields?: Readonly<Record<string, string | boolean | number>>;
127
+ readonly approve?: (name: string) => readonly string[];
128
+ };
129
+ export type HarnessPrinted = {
130
+ readonly _tag: 'Shell';
131
+ readonly command: string;
132
+ readonly output: string;
133
+ } | {
134
+ readonly _tag: 'Search';
135
+ readonly found: readonly string[];
136
+ readonly output: string;
137
+ };
138
+ export type FileEffect = {
139
+ readonly effect: 'read';
140
+ readonly path: string;
141
+ } | {
142
+ readonly effect: 'write';
143
+ readonly path: string;
144
+ } | {
145
+ readonly effect: 'delete';
146
+ readonly path: string;
147
+ } | {
148
+ readonly effect: 'move';
149
+ readonly path: string;
150
+ readonly from: string;
151
+ };
152
+ export type HookOccasion = (event: {
153
+ readonly name: string;
154
+ readonly tool?: string;
155
+ readonly notification?: string;
156
+ }) => 'session-start' | 'turn-start' | 'activity' | 'wait' | 'turn-end' | 'self-description';
157
+ export type RpcRequest = {
158
+ readonly method: string;
159
+ readonly params: unknown;
160
+ };
161
+ export type PrepareAnswer = {
162
+ readonly _tag: 'Answered';
163
+ readonly value: unknown;
164
+ } | {
165
+ readonly _tag: 'VendorError';
166
+ readonly code: number;
167
+ readonly message: string;
168
+ };
169
+ export type PrepareJudgment<T> = {
170
+ readonly _tag: 'Accept';
171
+ readonly value: T;
172
+ } | {
173
+ readonly _tag: 'Refuse';
174
+ readonly reason: string;
175
+ };
176
+ export type PreparedRoot = {
177
+ readonly id: string;
178
+ readonly artifact: string;
179
+ };
180
+ export type HarnessPrepare = {
181
+ readonly server: (cwd: string) => {
182
+ readonly program: string;
183
+ readonly args: ReadonlyArray<string>;
184
+ };
185
+ readonly initialize: {
186
+ readonly request: (client: {
187
+ readonly name: string;
188
+ readonly version: string;
189
+ }) => RpcRequest;
190
+ readonly judge: (outcome: PrepareAnswer) => PrepareJudgment<void>;
191
+ };
192
+ readonly start: {
193
+ readonly request: (workspace: string) => RpcRequest;
194
+ readonly judge: (outcome: PrepareAnswer) => PrepareJudgment<PreparedRoot>;
195
+ };
196
+ readonly read: {
197
+ readonly request: (threadId: string) => RpcRequest;
198
+ readonly judge: (outcome: PrepareAnswer) => PrepareJudgment<void>;
199
+ };
200
+ };
201
+ export declare const ADOPTED_HARNESS_PERMISSION_STANCE: "tagma";
202
+ export type HarnessCutAsk = {
203
+ readonly root: string;
204
+ readonly address: string | null;
205
+ };
206
+ export type HarnessCutRows = 'copied' | 'unaddressed';
207
+ export type HarnessCutTurns = {
208
+ readonly request: (root: string) => RpcRequest;
209
+ readonly judge: (outcome: PrepareAnswer) => PrepareJudgment<readonly (string | null)[]>;
210
+ };
211
+ export type HarnessCutMaking = {
212
+ readonly _tag: 'Launch';
213
+ readonly argv: (ask: HarnessCutAsk, into: string, prompt?: string, choice?: HarnessModelChoice, permission?: readonly string[]) => string[];
214
+ readonly rows: HarnessCutRows;
215
+ } | {
216
+ readonly _tag: 'Prepare';
217
+ readonly server: (cwd: string) => {
218
+ readonly program: string;
219
+ readonly args: ReadonlyArray<string>;
220
+ };
221
+ readonly initialize: HarnessPrepare['initialize'];
222
+ readonly fork: {
223
+ readonly request: (ask: HarnessCutAsk, workspace: string) => RpcRequest;
224
+ readonly judge: (outcome: PrepareAnswer) => PrepareJudgment<PreparedRoot>;
225
+ };
226
+ readonly rows: HarnessCutRows | HarnessCutTurns;
227
+ };
228
+ export type HarnessCut = {
229
+ readonly whole: HarnessCutMaking | null;
230
+ readonly point: HarnessCutMaking | null;
231
+ };
232
+ export type HarnessCarry = {
233
+ readonly folder: string;
234
+ readonly session: (files: FileSystem.FileSystem, home: string, root: string) => Effect.Effect<readonly string[], PlatformError.PlatformError>;
235
+ };
236
+ export type HarnessRunSeen = {
237
+ readonly turn: string | null;
238
+ readonly before: string | null;
239
+ };
240
+ export type HarnessAddress = {
241
+ readonly reads: 'turn' | 'transcript';
242
+ readonly of: (seen: HarnessRunSeen) => string | null;
243
+ };
244
+ export type HarnessPermissionStance = typeof ADOPTED_HARNESS_PERMISSION_STANCE;
245
+ export type HarnessPermissionArgv = Readonly<Record<HarnessPermissionStance, readonly string[] | null>>;
246
+ export declare function adoptedPermissionArgv(declaration: HarnessPermissionArgv): readonly string[];
247
+ export type HarnessPermissionModes = {
248
+ readonly values: readonly string[];
249
+ readonly argv: (mode: string) => readonly string[];
250
+ };
251
+ export type HarnessModelChoice = {
252
+ readonly model: string;
253
+ readonly rung: string | null;
254
+ };
255
+ export type HarnessModelArgv = {
256
+ readonly provider: string;
257
+ readonly argv: (choice: HarnessModelChoice) => readonly string[];
258
+ } | null;
259
+ export declare function chosenModelArgv(declaration: HarnessModelArgv, choice: HarnessModelChoice | undefined): readonly string[];
260
+ export type HarnessLaunch = {
261
+ readonly permission: HarnessPermissionArgv;
262
+ readonly permissionModes?: HarnessPermissionModes;
263
+ readonly model: HarnessModelArgv;
264
+ readonly interactive: (prompt?: string, choice?: HarnessModelChoice, permission?: readonly string[]) => string[];
265
+ readonly resume: (key: string, prompt?: string, choice?: HarnessModelChoice, permission?: readonly string[]) => string[];
266
+ readonly assign?: (key: string, prompt?: string, choice?: HarnessModelChoice, permission?: readonly string[]) => string[];
267
+ readonly root: (argv: readonly string[]) => string | null;
268
+ readonly export?: (argv: readonly string[], path: string) => string[];
269
+ readonly witness?: (text: string) => string | null;
270
+ readonly prepare?: HarnessPrepare;
271
+ readonly cut?: HarnessCut;
272
+ readonly carry?: HarnessCarry;
273
+ readonly address?: HarnessAddress;
274
+ };
275
+ export type ScreenAskPicks = {
276
+ readonly checked: readonly string[];
277
+ };
278
+ export type ScreenAskTyped = {
279
+ readonly value: string;
280
+ readonly draft: string;
281
+ };
282
+ export type ScreenAsk = {
283
+ readonly kind: HarnessQuestionKind;
284
+ readonly prompt: string;
285
+ readonly header: string | null;
286
+ readonly subject: string | null;
287
+ readonly options: readonly HarnessQuestionOption[];
288
+ readonly selected: string | null;
289
+ readonly freeform?: ScreenAskTyped;
290
+ readonly picks?: ScreenAskPicks;
291
+ };
292
+ export type HarnessWidgetKey = 'up' | 'down' | 'enter' | 'esc' | {
293
+ readonly _tag: 'char';
294
+ readonly char: string;
295
+ } | {
296
+ readonly _tag: 'text';
297
+ readonly text: string;
298
+ };
299
+ export type HarnessScreenReader = (lines: readonly string[]) => ScreenAsk | null;
300
+ export type HarnessQuit = readonly (readonly HarnessWidgetKey[])[];
301
+ export declare const INTERRUPT_KEY: HarnessWidgetKey;
302
+ export declare const unmeasuredScreen: HarnessScreenReader;
303
+ export declare const unmeasuredKeys: () => null;
304
+ export declare const oneValue: (keys: (ask: ScreenAsk, value: string) => readonly HarnessWidgetKey[] | null) => (ask: ScreenAsk, values: readonly string[]) => readonly HarnessWidgetKey[] | null;
305
+ export declare const navigateChoice: (ask: ScreenAsk, value: string) => readonly HarnessWidgetKey[] | null;
306
+ export declare const typeChoice: (ask: ScreenAsk, value: string) => readonly HarnessWidgetKey[] | null;
307
+ export type ScreenChoice = {
308
+ readonly value: string;
309
+ readonly label: string;
310
+ readonly selected: boolean;
311
+ };
312
+ export type ScreenChoices = {
313
+ readonly options: readonly HarnessQuestionOption[];
314
+ readonly selected: string | null;
315
+ readonly marked: number;
316
+ readonly above: number;
317
+ };
318
+ export declare const screenChoices: (lines: readonly string[], match: (line: string) => ScreenChoice | null, end?: number) => ScreenChoices | null;
319
+ export type HarnessReturned = {
320
+ readonly clear: readonly HarnessWidgetKey[];
321
+ readonly counts: 'breaks' | 'lines';
322
+ };
323
+ export type HarnessComposer = {
324
+ readonly of: (lines: readonly string[]) => string | null;
325
+ readonly returns?: HarnessReturned;
326
+ readonly drafted?: readonly HarnessWidgetKey[];
327
+ };
328
+ export type HarnessExitArm = {
329
+ readonly key: HarnessWidgetKey;
330
+ readonly windowMs: number;
331
+ readonly banner: string;
332
+ readonly version: string;
333
+ };
334
+ export type HarnessEnds = {
335
+ readonly interrupt: 'screen' | 'record';
336
+ readonly idle: 'notification' | null;
337
+ readonly tail: 'final' | 'prompt';
338
+ };
339
+ export type HarnessSetup = {
340
+ readonly file: string;
341
+ readonly done: string;
342
+ };
343
+ export type InstructionSurface = {
344
+ readonly file: string;
345
+ readonly imports?: (text: string) => boolean;
346
+ };
347
+ export type SkillSurface = {
348
+ readonly project?: string;
349
+ readonly user: HookUserFile;
350
+ };
351
+ export type HarnessTool = {
352
+ readonly kind: PermissionKind;
353
+ readonly approval: Approval;
354
+ };
355
+ export type HarnessTools = {
356
+ readonly names: 'vendor' | 'kind';
357
+ readonly byName: Readonly<Record<string, HarnessTool>>;
358
+ };
359
+ export declare const ASKS_NEVER: Approval;
360
+ export declare const ASKS_IN_REVIEW: Approval;
361
+ export declare const LEGACY_TOOLS: HarnessTools;
362
+ export type TerminalSurface = {
363
+ readonly prefix: string;
364
+ readonly variable?: string;
365
+ readonly exports?: readonly string[];
366
+ readonly binary: string;
367
+ readonly installedIn?: (home: string) => readonly string[];
368
+ readonly install?: string;
369
+ readonly metadata?: MetadataReader;
370
+ readonly tools: HarnessTools;
371
+ readonly env?: Record<string, string>;
372
+ readonly hooks: HookSurface | null;
373
+ readonly setup?: HarnessSetup;
374
+ readonly instructions?: InstructionSurface;
375
+ readonly skill?: SkillSurface;
376
+ readonly mcpTools: McpToolShape;
377
+ readonly mcpCallMeta?: string;
378
+ readonly mcp: McpSurface | null;
379
+ readonly occasionOf: HookOccasion;
380
+ readonly sessionKeyOf: (event: Record<string, unknown>) => string | null;
381
+ readonly modelOf: (event: Record<string, unknown>) => HarnessModelReport | null;
382
+ readonly reportsModel: boolean;
383
+ readonly turnOf: (event: Record<string, unknown>) => string | null;
384
+ readonly answerKey: string | null;
385
+ readonly promptKey?: string;
386
+ readonly subjectOf: (event: Record<string, unknown>) => HarnessCall | null;
387
+ readonly filesOf: (event: Record<string, unknown>) => readonly FileEffect[];
388
+ readonly printedOf: (event: Record<string, unknown>) => HarnessPrinted | null;
389
+ readonly failureOf?: (event: Record<string, unknown>) => TransportFailure | null;
390
+ readonly eventKeys: readonly string[];
391
+ readonly screenAskOf: HarnessScreenReader;
392
+ readonly promptScreenOf?: (lines: readonly string[]) => boolean;
393
+ readonly composer?: HarnessComposer;
394
+ readonly keysOf: (ask: ScreenAsk, values: readonly string[]) => readonly HarnessWidgetKey[] | null;
395
+ readonly cancelKeysOf: (ask: ScreenAsk) => readonly HarnessWidgetKey[] | null;
396
+ readonly interrupt: readonly HarnessWidgetKey[] | null;
397
+ readonly exitArm?: HarnessExitArm;
398
+ readonly steer: 'step' | 'none';
399
+ readonly quit: HarnessQuit | null;
400
+ readonly callEnvelopeMs: number | null;
401
+ readonly ends: HarnessEnds;
402
+ readonly launch: HarnessLaunch;
403
+ };
404
+ export type ConfigChoice = {
405
+ readonly configId: string;
406
+ readonly value: string;
407
+ };
408
+ export type AcpProves = {
409
+ readonly law: NonNullable<TransportCapabilities['law']>;
410
+ readonly touch: NonNullable<TransportCapabilities['touch']>;
411
+ readonly authorship: NonNullable<TransportCapabilities['authorship']>;
412
+ readonly fork: boolean;
413
+ readonly rewind: boolean;
414
+ readonly compaction: boolean | 'foreign' | 'vendor';
415
+ readonly continue: boolean;
416
+ readonly usage: TransportCapabilities['usage'];
417
+ readonly aside: Exclude<TransportCapabilities['aside'], 'request'>;
418
+ };
419
+ export type AcpProfile = {
420
+ readonly argv: (choice: HarnessModelChoice | undefined) => readonly string[];
421
+ readonly untitled?: readonly string[];
422
+ readonly titles: boolean;
423
+ readonly configure: (choice: HarnessModelChoice | undefined, switches: ModelSwitches) => readonly ConfigChoice[];
424
+ readonly reportedModel: string | null;
425
+ readonly hosts: string | null;
426
+ readonly serves: string | null;
427
+ readonly program?: string;
428
+ readonly web: TransportWeb;
429
+ readonly mode: string;
430
+ readonly proves: AcpProves;
431
+ readonly toolCatalog?: TransportCapabilities['toolCatalog'];
432
+ readonly storage?: {
433
+ readonly environment: string;
434
+ readonly folder: string;
435
+ };
436
+ readonly graceMs: number;
437
+ readonly callEnvelopeMs: number | null;
438
+ readonly handshakeMs: number;
439
+ readonly login: {
440
+ readonly command: string;
441
+ readonly codes: readonly number[];
442
+ };
443
+ readonly lockedCode: number | null;
444
+ readonly otherMutates: boolean;
445
+ readonly midTurn: 'after-turn' | 'steer';
446
+ readonly sharedSessions: boolean;
447
+ readonly extensions: readonly string[];
448
+ };
449
+ export type HarnessSurfaces = {
450
+ readonly harnessLabel?: string;
451
+ readonly mark?: string;
452
+ readonly terminal?: TerminalSurface;
453
+ readonly acp?: AcpProfile;
454
+ };
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Schema as e}from"effect";var p=200,c=160,h=e.String.check(e.isPattern(/^[a-z][a-z0-9-]*$/u),e.isMaxLength(64)),f=["tagma","lode"],H="tagma",g=e.Literals(["configured","serving","last-recorded"]),x=e.Literals(["hook","vendor-record","transcript","session-store","terminal","protocol"]),S=e.Union([e.Struct({read:e.Literal("value"),value:e.String.check(e.isMaxLength(p)),claim:g}),e.Struct({read:e.Literal("absent")}),e.Struct({read:e.Literal("unsupported")}),e.Struct({read:e.Literal("unreadable"),reason:e.String.check(e.isMaxLength(c))})]),k=e.Struct({value:e.String,label:e.String,description:e.optional(e.String)}),v=e.Literals(["choice"]),C=e.Struct({id:e.NullOr(e.String.check(e.isMinLength(1))),tool:e.String.check(e.isMinLength(1)),subject:e.String.check(e.isMinLength(1))}),A=["catalog","proxy"],u=1e4,R={chars:u,basis:"unmeasured"},y="tagma";function b(n){let r=n[y];if(r===null)throw Error(`The harness cannot express permission stance ${y}.`);return r}function M(n,r){if(r===void 0)return[];let o=r.rung===null?r.model:`${r.model} at ${r.rung}`;if(n===null)throw Error(`The harness declares no model surface and cannot launch on ${o}.`);return n.argv(r)}var w={_tag:"char",char:"\x03"},P=()=>null,E=()=>null,T=(n)=>(r,o)=>o.length===1?n(r,o[0]):null,_=(n,r)=>{if(n.selected===null)return null;let o=n.options.findIndex((t)=>t.value===n.selected),a=n.options.findIndex((t)=>t.value===r);if(o<0||a<0)return null;let l=a>o?"down":"up";return[...Array.from({length:Math.abs(a-o)}).fill(l),"enter"]},O=(n,r)=>n.options.some((o)=>o.value===r)?[...r].map((o)=>({_tag:"char",char:o})):null,K=(n,r,o=n.findLastIndex((a)=>r(a)!==null))=>{if(o<0)return null;let a=[],l=[],t=o;for(;t>=0;t-=1){let d=r(n[t]);if(d===null)break;if(a.push({value:d.value,label:d.label}),d.selected)l.push(d.value)}return a.reverse(),{options:a,selected:l.length===1?l[0]:null,marked:l.length,above:t}},i={asksFrom:"never"},s={asksFrom:"review",timeout:"none"},N={names:"kind",byName:{bash:{kind:"execute",approval:s},read:{kind:"read",approval:i},ls:{kind:"read",approval:i},glob:{kind:"read",approval:i},grep:{kind:"read",approval:i},write:{kind:"write",approval:s},edit:{kind:"write",approval:s},delete:{kind:"write",approval:s},rename:{kind:"write",approval:s},webfetch:{kind:"network",approval:s},websearch:{kind:"network",approval:s}}};export{y as ADOPTED_HARNESS_PERMISSION_STANCE,s as ASKS_IN_REVIEW,i as ASKS_NEVER,c as HARNESS_DETAIL_MAX,p as HARNESS_ID_MAX,u as HOOK_CONTEXT_CHARS,H as HOST_COMMAND,w as INTERRUPT_KEY,N as LEGACY_TOOLS,A as MCP_TOOL_SHAPES,f as RESERVED_HARNESS_NAMES,R as UNMEASURED_HOOK_CONTEXT,b as adoptedPermissionArgv,M as chosenModelArgv,C as harnessCallSchema,g as harnessClaimSchema,S as harnessModelReportSchema,h as harnessNameSchema,x as harnessProvenanceSchema,v as harnessQuestionKindSchema,k as harnessQuestionOptionSchema,_ as navigateChoice,T as oneValue,K as screenChoices,O as typeChoice,E as unmeasuredKeys,P as unmeasuredScreen};
@@ -0,0 +1,43 @@
1
+ /// <reference path="../types/node/index.d.ts" />
2
+ /// <reference path="../host.d.ts" />
3
+ export type HookVerdict = {
4
+ readonly allowed: boolean;
5
+ readonly words: string;
6
+ };
7
+ export type HookMoment = 'before' | 'after';
8
+ export type HookTrust = {
9
+ readonly home: string;
10
+ readonly folder: string;
11
+ readonly file: string;
12
+ readonly table: string;
13
+ readonly key: (filePath: string, event: string, group: number, handler: number) => string;
14
+ };
15
+ export type HookCommand = {
16
+ readonly command: string;
17
+ readonly timeout?: number;
18
+ };
19
+ export type HookHandler = HookCommand & {
20
+ readonly type: 'command';
21
+ };
22
+ export type HookEntry = HookCommand | {
23
+ readonly hooks: readonly HookHandler[];
24
+ };
25
+ export type HookFileShape = {
26
+ readonly keys: Readonly<Record<string, unknown>>;
27
+ readonly events: readonly string[];
28
+ readonly holes: boolean;
29
+ readonly trust: HookTrust | null;
30
+ readonly entry: (command: string, timeout: number | undefined) => HookEntry;
31
+ };
32
+ export declare const commandGroup: (command: string, timeout: number | undefined) => HookEntry;
33
+ export declare const specificOutput: (hookEventName: string, additionalContext: string) => string;
34
+ export declare const approvePermission: ({ allowed, words }: HookVerdict) => string;
35
+ export declare const eventOutput: (event: string) => (text: string) => string;
36
+ export declare const toolOutput: (before: string, after: string) => (text: string, moment: HookMoment) => string;
37
+ export type HookCodec = {
38
+ readonly file: HookFileShape;
39
+ readonly permission: (verdict: HookVerdict) => string;
40
+ readonly context: (text: string) => string;
41
+ readonly tool: (text: string, moment: HookMoment) => string;
42
+ readonly prompt: ((text: string) => string) | null;
43
+ };
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ var i=(e,o)=>({hooks:[{type:"command",command:e,...o===void 0?{}:{timeout:o}}]}),n=(e,o)=>JSON.stringify({hookSpecificOutput:{hookEventName:e,additionalContext:o}}),s=({allowed:e,words:o})=>JSON.stringify({decision:e?"approve":"deny",reason:o}),d=(e)=>(o)=>n(e,o),a=(e,o)=>(t,r)=>n(r==="before"?e:o,t);export{s as approvePermission,i as commandGroup,d as eventOutput,n as specificOutput,a as toolOutput};
@@ -0,0 +1,19 @@
1
+ /// <reference path="../types/node/index.d.ts" />
2
+ /// <reference path="../host.d.ts" />
3
+ import { Schema } from "effect";
4
+ export declare const tagmaSection: Schema.Struct<{
5
+ readonly host: Schema.optional<Schema.$Array<Schema.String>>;
6
+ readonly build: Schema.optional<Schema.Literal<"developer">>;
7
+ readonly labels: Schema.optional<Schema.$Array<Schema.NonEmptyString>>;
8
+ }>;
9
+ export declare const hostSpecifiers: (manifests: readonly string[]) => readonly string[];
10
+ export type DeveloperMark = {
11
+ readonly manifest: string;
12
+ } | null;
13
+ export declare const developerMarks: () => ((path: string) => Promise<DeveloperMark>);
14
+ export type DeclaredLabels = {
15
+ readonly manifest: string;
16
+ readonly labels: readonly string[];
17
+ };
18
+ export declare const developerLabels: (manifests: readonly string[]) => Promise<readonly DeclaredLabels[]>;
19
+ export declare const workspaceManifests: (root: string) => Promise<readonly string[]>;
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{readdir as g,readFile as l}from"fs/promises";import{dirname as m,join as s}from"path";import{Schema as t}from"effect";var d=t.Struct({host:t.optional(t.Array(t.String)),build:t.optional(t.Literal("developer")),labels:t.optional(t.Array(t.NonEmptyString))}),f=t.Struct({name:t.String,tagma:t.optional(d)}),k=t.decodeUnknownSync(t.fromJsonString(f)),u=t.decodeUnknownSync(t.Struct({tagma:t.optional(d)})),v=(n)=>n.flatMap((o)=>{let e=k(o);return(e.tagma?.host??[]).map((a)=>a.startsWith("./")?`${e.name}${a.slice(1)}`:a)}).sort(),i=(n)=>{if(n.code==="ENOENT"||n.code==="ENOTDIR")return null;throw n},S=["module.json","package.json"],h=async(n)=>{for(let o of S){let e=s(n,o),a=await l(e,"utf8").catch(i);if(a===null)continue;let r=JSON.parse(a);if(u({tagma:r.tagma}).tagma?.build==="developer")return{manifest:e}}return null},w=()=>{let n=new Map,o=(e)=>{let a=n.get(e);if(a!==void 0)return a;let r=h(e).then((c)=>{if(c!==null)return c;let p=m(e);return p===e?null:o(p)});return n.set(e,r),r};return(e)=>o(m(e))},M=async(n)=>{let o=[];for(let e of n){let a=await l(e,"utf8").catch(i);if(a===null)continue;let r=u({tagma:JSON.parse(a).tagma}).tagma;if(r?.build==="developer"&&r.labels!==void 0)o.push({manifest:e,labels:r.labels})}return o},D=async(n)=>{let o=s(n,"packages"),e=await g(o);return(await Promise.all(e.map((r)=>l(s(o,r,"package.json"),"utf8").catch(i)))).filter((r)=>r!==null)};export{M as developerLabels,w as developerMarks,v as hostSpecifiers,d as tagmaSection,D as workspaceManifests};
@@ -0,0 +1,10 @@
1
+ /// <reference path="../types/node/index.d.ts" />
2
+ /// <reference path="../host.d.ts" />
3
+ import type { ProvidersDefinition } from "@runlith/tagma/plugin";
4
+ export type HostModule = () => Promise<object>;
5
+ export type HostModules = Readonly<Record<string, HostModule>>;
6
+ export type ImportedProviders = ProvidersDefinition & {
7
+ readonly id: string;
8
+ readonly version: string;
9
+ };
10
+ export declare const importProviders: (directory: string, host: HostModules, argv?: readonly string[]) => Promise<ImportedProviders>;
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{readFile as f,realpath as m}from"fs/promises";import{join as l}from"path";import{Schema as i}from"effect";var a="tagma-plugin.json";var w=i.Struct({id:i.String,version:i.String,providers:i.optional(i.Struct({entry:i.String}))}),h=i.decodeUnknownSync(i.fromJsonString(w)),y,v=(t)=>y??=(async()=>{let r=[];for(let[n,e]of Object.entries(t))r.push([n,await e().then((o)=>({exports:o}),(o)=>({unloadable:o}))]);Bun.plugin({name:"adapter-host",setup(n){for(let[e,o]of r)n.module(e,()=>{if("unloadable"in o)throw o.unloadable;return{exports:{...o.exports},loader:"object"}})}})})(),g=(t,r)=>{if(typeof t!=="object"||t===null)throw Error(`${r} exports no provider part as its default: write export default defineProviders({ models, speech })`);let{models:n,speech:e}=t;if(n!==void 0&&typeof n!=="function")throw Error(`${r}: models is not an adapter: make it with defineAdapter from @runlith/tagma/adapter/provider`);if(e!==void 0&&!Array.isArray(e))throw Error(`${r}: speech is not a list of speech providers`);if(n===void 0&&e===void 0)throw Error(`${r} declares neither models nor speech`);return t},x=async(t,r,n=process.execArgv)=>{if(!n.includes("--no-install"))throw Error("the server runs without --no-install, so an import outside the host modules would install a second copy instead of failing; start it with bun --no-install");let e=await m(t),o=l(e,a),{id:p,version:u,providers:s}=h(await f(o,"utf8"));if(s===void 0)throw Error(`${o} declares no provider part`);let d=l(e,s.entry);await v(r);let c=await import(d);return{id:p,version:u,...g(c.default,d)}};export{x as importProviders};