@graftland/plugin-remote 0.3.3 → 0.4.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 (323) hide show
  1. package/README.md +18 -54
  2. package/README.zh-CN.md +17 -51
  3. package/README.zh-TW.md +17 -51
  4. package/dist/Auth.d.ts.map +1 -1
  5. package/dist/Auth.js.map +1 -1
  6. package/dist/Config.d.ts +1151 -0
  7. package/dist/Config.d.ts.map +1 -0
  8. package/dist/Config.js +183 -0
  9. package/dist/Config.js.map +1 -0
  10. package/dist/Contract.d.ts +1 -1
  11. package/dist/Contract.d.ts.map +1 -1
  12. package/dist/Contract.js +32 -1
  13. package/dist/Contract.js.map +1 -1
  14. package/dist/Instance.d.ts.map +1 -1
  15. package/dist/Instance.js.map +1 -1
  16. package/dist/Testing.d.ts +1 -1
  17. package/dist/Testing.d.ts.map +1 -1
  18. package/dist/Testing.js.map +1 -1
  19. package/dist/Transport.d.ts +1 -1
  20. package/dist/Transport.d.ts.map +1 -1
  21. package/dist/Transport.js.map +1 -1
  22. package/dist/cli.d.ts +4 -0
  23. package/dist/cli.d.ts.map +1 -0
  24. package/dist/cli.js +25 -0
  25. package/dist/cli.js.map +1 -0
  26. package/dist/host/auth/bearer.d.ts.map +1 -1
  27. package/dist/host/auth/bearer.js +4 -2
  28. package/dist/host/auth/bearer.js.map +1 -1
  29. package/dist/host/auth/jwt.d.ts.map +1 -1
  30. package/dist/host/auth/jwt.js +4 -2
  31. package/dist/host/auth/jwt.js.map +1 -1
  32. package/dist/host/auth/mtls.d.ts +3 -7
  33. package/dist/host/auth/mtls.d.ts.map +1 -1
  34. package/dist/host/auth/mtls.js +13 -14
  35. package/dist/host/auth/mtls.js.map +1 -1
  36. package/dist/host/auth/none.d.ts +1 -1
  37. package/dist/host/auth/none.js +7 -5
  38. package/dist/host/auth/none.js.map +1 -1
  39. package/dist/host/command.d.ts +1 -1
  40. package/dist/host/command.d.ts.map +1 -1
  41. package/dist/host/command.js +11 -9
  42. package/dist/host/command.js.map +1 -1
  43. package/dist/host/local.d.ts.map +1 -1
  44. package/dist/host/local.js +9 -30
  45. package/dist/host/local.js.map +1 -1
  46. package/dist/host/unix.d.ts +1 -1
  47. package/dist/host/unix.d.ts.map +1 -1
  48. package/dist/host/unix.js +13 -9
  49. package/dist/host/unix.js.map +1 -1
  50. package/dist/host/websocket.d.ts +1 -1
  51. package/dist/host/websocket.d.ts.map +1 -1
  52. package/dist/host/websocket.js +11 -8
  53. package/dist/host/websocket.js.map +1 -1
  54. package/dist/host/worker.d.ts +1 -1
  55. package/dist/host/worker.d.ts.map +1 -1
  56. package/dist/host/worker.js +13 -9
  57. package/dist/host/worker.js.map +1 -1
  58. package/dist/index.d.ts +6 -8
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +30 -64
  61. package/dist/index.js.map +1 -1
  62. package/dist/internal/Certificates.js.map +1 -1
  63. package/dist/internal/FailureGroup.js +6 -6
  64. package/dist/internal/FailureGroup.js.map +1 -1
  65. package/dist/internal/Peer.js.map +1 -1
  66. package/dist/internal/{ServeLifecycle.js → RunnerLifecycle.js} +6 -6
  67. package/dist/internal/RunnerLifecycle.js.map +1 -0
  68. package/dist/internal/Supervisor.js.map +1 -1
  69. package/dist/internal/assembly.d.ts +3 -3
  70. package/dist/internal/assembly.js +8 -8
  71. package/dist/internal/assembly.js.map +1 -1
  72. package/dist/internal/auth/config.d.ts +27 -0
  73. package/dist/internal/auth/config.d.ts.map +1 -0
  74. package/dist/internal/auth/config.js +29 -0
  75. package/dist/internal/auth/config.js.map +1 -0
  76. package/dist/internal/auth/mtls.js.map +1 -1
  77. package/dist/internal/auth/token.js.map +1 -1
  78. package/dist/internal/auth/tokenCredentials.d.ts +1 -1
  79. package/dist/internal/auth/tokenCredentials.d.ts.map +1 -1
  80. package/dist/internal/auth/tokenCredentials.js +1 -1
  81. package/dist/internal/auth/tokenCredentials.js.map +1 -1
  82. package/dist/internal/child.js +3 -3
  83. package/dist/internal/child.js.map +1 -1
  84. package/dist/internal/childMain.js +47 -0
  85. package/dist/internal/childMain.js.map +1 -0
  86. package/dist/internal/childRuntime.js +8 -8
  87. package/dist/internal/childRuntime.js.map +1 -1
  88. package/dist/internal/cleanup.js +3 -3
  89. package/dist/internal/cleanup.js.map +1 -1
  90. package/dist/internal/contract.js.map +1 -1
  91. package/dist/internal/credentials.d.ts +3 -2
  92. package/dist/internal/credentials.d.ts.map +1 -1
  93. package/dist/internal/credentials.js +1 -1
  94. package/dist/internal/credentials.js.map +1 -1
  95. package/dist/internal/directTransport.js.map +1 -1
  96. package/dist/internal/entry.d.ts +104 -26
  97. package/dist/internal/entry.d.ts.map +1 -1
  98. package/dist/internal/entry.js +22 -9
  99. package/dist/internal/entry.js.map +1 -1
  100. package/dist/internal/entryConfig.d.ts +2 -202
  101. package/dist/internal/entryConfig.js +2 -136
  102. package/dist/internal/entryConfig.js.map +1 -1
  103. package/dist/internal/execution.d.ts +4 -4
  104. package/dist/internal/execution.js +11 -11
  105. package/dist/internal/execution.js.map +1 -1
  106. package/dist/internal/follow.js +1 -1
  107. package/dist/internal/follow.js.map +1 -1
  108. package/dist/internal/forkTree.js.map +1 -1
  109. package/dist/internal/host/local.js.map +1 -1
  110. package/dist/internal/host/runner.js +4 -4
  111. package/dist/internal/host/runner.js.map +1 -1
  112. package/dist/internal/host.js +2 -2
  113. package/dist/internal/host.js.map +1 -1
  114. package/dist/internal/importer.js +1 -1
  115. package/dist/internal/importer.js.map +1 -1
  116. package/dist/internal/listenerStartup.js +1 -1
  117. package/dist/internal/listenerStartup.js.map +1 -1
  118. package/dist/internal/loadModule.js.map +1 -1
  119. package/dist/internal/platform.js +1 -9
  120. package/dist/internal/port.d.ts +1 -1
  121. package/dist/internal/port.js +2 -2
  122. package/dist/internal/port.js.map +1 -1
  123. package/dist/internal/runner/Bootstrap.js.map +1 -1
  124. package/dist/internal/runner/Connection.d.ts +3 -2
  125. package/dist/internal/runner/Connection.js +6 -6
  126. package/dist/internal/runner/Connection.js.map +1 -1
  127. package/dist/internal/runner/Execution.js +6 -6
  128. package/dist/internal/runner/Execution.js.map +1 -1
  129. package/dist/internal/runner/Local.js +1 -1
  130. package/dist/internal/runner/Local.js.map +1 -1
  131. package/dist/internal/runner/Lock.js.map +1 -1
  132. package/dist/internal/runner/Multiplex.js.map +1 -1
  133. package/dist/internal/runner/Packages.js.map +1 -1
  134. package/dist/internal/runner/ProcessObservation.js.map +1 -1
  135. package/dist/internal/runner/Processes.js.map +1 -1
  136. package/dist/internal/runner/Retention.js.map +1 -1
  137. package/dist/internal/runner/Store.js.map +1 -1
  138. package/dist/internal/runner/Supervisor.js +5 -5
  139. package/dist/internal/runner/Supervisor.js.map +1 -1
  140. package/dist/internal/runner/Watchdog.js.map +1 -1
  141. package/dist/internal/runner/Wire.d.ts +1 -1
  142. package/dist/internal/runner/Wire.js.map +1 -1
  143. package/dist/internal/runner/accept.js +2 -2
  144. package/dist/internal/runner/accept.js.map +1 -1
  145. package/dist/internal/runner/command.js +1 -1
  146. package/dist/internal/runner/command.js.map +1 -1
  147. package/dist/internal/runner/connectionEnded.js +1 -1
  148. package/dist/internal/runner/connectionEnded.js.map +1 -1
  149. package/dist/internal/runner/model.d.ts.map +1 -1
  150. package/dist/internal/runner/model.js.map +1 -1
  151. package/dist/internal/services.d.ts.map +1 -1
  152. package/dist/internal/services.js +1 -1
  153. package/dist/internal/services.js.map +1 -1
  154. package/dist/internal/socketChannel.js.map +1 -1
  155. package/dist/internal/stdioChannel.js.map +1 -1
  156. package/dist/internal/supervisorPlugin.js +48 -1
  157. package/dist/internal/supervisorPlugin.js.map +1 -1
  158. package/dist/internal/transportOptions.d.ts.map +1 -1
  159. package/dist/internal/watchdogMain.js +5 -3
  160. package/dist/internal/watchdogMain.js.map +1 -1
  161. package/dist/internal/websocket.js.map +1 -1
  162. package/dist/internal/websocketServer.js +1 -1
  163. package/dist/internal/websocketServer.js.map +1 -1
  164. package/dist/internal/workerChannel.js.map +1 -1
  165. package/dist/internal/workerMain.js +13 -6
  166. package/dist/internal/workerMain.js.map +1 -1
  167. package/dist/runner/auth/bearer.d.ts +3 -5
  168. package/dist/runner/auth/bearer.d.ts.map +1 -1
  169. package/dist/runner/auth/bearer.js +13 -11
  170. package/dist/runner/auth/bearer.js.map +1 -1
  171. package/dist/runner/auth/jwt.d.ts +4 -18
  172. package/dist/runner/auth/jwt.d.ts.map +1 -1
  173. package/dist/runner/auth/jwt.js +16 -28
  174. package/dist/runner/auth/jwt.js.map +1 -1
  175. package/dist/runner/auth/mtls.d.ts +3 -6
  176. package/dist/runner/auth/mtls.d.ts.map +1 -1
  177. package/dist/runner/auth/mtls.js +13 -29
  178. package/dist/runner/auth/mtls.js.map +1 -1
  179. package/dist/runner/auth/none.d.ts +1 -1
  180. package/dist/runner/auth/none.js +7 -5
  181. package/dist/runner/auth/none.js.map +1 -1
  182. package/dist/runner/index.d.ts +3 -308
  183. package/dist/runner/index.d.ts.map +1 -1
  184. package/dist/runner/index.js +62 -30
  185. package/dist/runner/index.js.map +1 -1
  186. package/dist/runner/stdio.d.ts +1 -1
  187. package/dist/runner/stdio.d.ts.map +1 -1
  188. package/dist/runner/stdio.js +11 -9
  189. package/dist/runner/stdio.js.map +1 -1
  190. package/dist/runner/unix.d.ts +1 -1
  191. package/dist/runner/unix.d.ts.map +1 -1
  192. package/dist/runner/unix.js +10 -8
  193. package/dist/runner/unix.js.map +1 -1
  194. package/dist/runner/websocket.d.ts +1 -1
  195. package/dist/runner/websocket.d.ts.map +1 -1
  196. package/dist/runner/websocket.js +12 -10
  197. package/dist/runner/websocket.js.map +1 -1
  198. package/package.json +14 -12
  199. package/schema.json +2269 -0
  200. package/src/Auth.ts +8 -2
  201. package/src/Config.ts +196 -0
  202. package/src/Contract.ts +12 -3
  203. package/src/Instance.ts +1 -0
  204. package/src/Testing.ts +6 -4
  205. package/src/Transport.ts +12 -3
  206. package/src/cli.ts +60 -0
  207. package/src/host/auth/bearer.ts +1 -0
  208. package/src/host/auth/jwt.ts +1 -0
  209. package/src/host/auth/mtls.ts +7 -12
  210. package/src/host/auth/none.ts +3 -1
  211. package/src/host/command.ts +8 -5
  212. package/src/host/local.ts +4 -2
  213. package/src/host/unix.ts +11 -7
  214. package/src/host/websocket.ts +10 -7
  215. package/src/host/worker.ts +8 -5
  216. package/src/index.ts +36 -23
  217. package/src/internal/Certificates.ts +1 -0
  218. package/src/internal/FailureGroup.ts +5 -3
  219. package/src/internal/Peer.ts +1 -0
  220. package/src/internal/{ServeLifecycle.ts → RunnerLifecycle.ts} +7 -5
  221. package/src/internal/Supervisor.ts +5 -4
  222. package/src/internal/assembly.ts +11 -9
  223. package/src/internal/auth/config.ts +44 -0
  224. package/src/internal/auth/mtls.ts +1 -0
  225. package/src/internal/auth/token.ts +1 -0
  226. package/src/internal/auth/tokenCredentials.ts +4 -2
  227. package/src/internal/child.ts +8 -6
  228. package/src/{bin.ts → internal/childMain.ts} +16 -61
  229. package/src/internal/childRuntime.ts +12 -10
  230. package/src/internal/cleanup.ts +3 -2
  231. package/src/internal/contract.ts +1 -0
  232. package/src/internal/credentials.ts +3 -1
  233. package/src/internal/directTransport.ts +9 -2
  234. package/src/internal/entry.ts +53 -16
  235. package/src/internal/entryConfig.ts +10 -132
  236. package/src/internal/execution.ts +17 -15
  237. package/src/internal/follow.ts +2 -1
  238. package/src/internal/forkTree.ts +2 -1
  239. package/src/internal/host/local.ts +1 -0
  240. package/src/internal/host/runner.ts +7 -5
  241. package/src/internal/host.ts +9 -8
  242. package/src/internal/importer.ts +3 -2
  243. package/src/internal/listenerStartup.ts +4 -2
  244. package/src/internal/loadModule.ts +1 -0
  245. package/src/internal/platform.ts +1 -12
  246. package/src/internal/port.ts +11 -6
  247. package/src/internal/runner/Bootstrap.ts +1 -0
  248. package/src/internal/runner/Connection.ts +13 -11
  249. package/src/internal/runner/Execution.ts +14 -13
  250. package/src/internal/runner/Local.ts +3 -2
  251. package/src/internal/runner/Lock.ts +1 -0
  252. package/src/internal/runner/Multiplex.ts +2 -1
  253. package/src/internal/runner/Packages.ts +7 -5
  254. package/src/internal/runner/ProcessObservation.ts +2 -1
  255. package/src/internal/runner/Processes.ts +3 -1
  256. package/src/internal/runner/Retention.ts +1 -0
  257. package/src/internal/runner/Store.ts +3 -2
  258. package/src/internal/runner/Supervisor.ts +22 -20
  259. package/src/internal/runner/Watchdog.ts +3 -1
  260. package/src/internal/runner/Wire.ts +13 -12
  261. package/src/internal/runner/accept.ts +6 -5
  262. package/src/internal/runner/command.ts +3 -2
  263. package/src/internal/runner/connectionEnded.ts +2 -1
  264. package/src/internal/runner/model.ts +5 -3
  265. package/src/internal/services.ts +9 -2
  266. package/src/internal/socketChannel.ts +2 -1
  267. package/src/internal/stdioChannel.ts +4 -2
  268. package/src/internal/supervisorPlugin.ts +10 -8
  269. package/src/internal/transportOptions.ts +1 -0
  270. package/src/internal/watchdogMain.ts +5 -3
  271. package/src/internal/websocket.ts +5 -2
  272. package/src/internal/websocketServer.ts +6 -4
  273. package/src/internal/workerChannel.ts +1 -0
  274. package/src/internal/workerMain.ts +21 -5
  275. package/src/runner/auth/bearer.ts +10 -6
  276. package/src/runner/auth/jwt.ts +10 -41
  277. package/src/runner/auth/mtls.ts +6 -3
  278. package/src/runner/auth/none.ts +3 -1
  279. package/src/runner/index.ts +102 -11
  280. package/src/runner/stdio.ts +15 -10
  281. package/src/runner/unix.ts +7 -4
  282. package/src/runner/websocket.ts +9 -7
  283. package/dist/Auth-BElTC9_X.js +0 -6
  284. package/dist/Bootstrap-H9gDsgsC.js +0 -9
  285. package/dist/ConfigDirectory-BCC6q2R4.js +0 -5
  286. package/dist/Contract-DsJtisvL.js +0 -83
  287. package/dist/Errors-DYhsGZcZ.js +0 -58
  288. package/dist/FailureGroup-BgT73AaR.js +0 -63
  289. package/dist/Framing-G9eSaeLb.js +0 -61
  290. package/dist/Graft-B71CPA2Y.js +0 -996
  291. package/dist/Packages-AgoCGotL.js +0 -108
  292. package/dist/Peer-DXeVrGBh.js +0 -342
  293. package/dist/ProcessObservation-gLgGirYv.js +0 -38
  294. package/dist/ServeLifecycle-Bd1FPJ6e.js +0 -24
  295. package/dist/Transport-DULzpsgR.js +0 -6
  296. package/dist/WatchdogProtocol-BZmVxrBP.js +0 -17
  297. package/dist/bin.js +0 -28276
  298. package/dist/bin.js.map +0 -1
  299. package/dist/childRuntime-Bm3iSg_N.js +0 -192
  300. package/dist/command-9zrHdbwT.js +0 -7
  301. package/dist/connectionEnded-BwcxQ7W8.js +0 -54
  302. package/dist/directTransport-DrexuPSm.js +0 -5
  303. package/dist/entry-psOpX3Bj.js +0 -736
  304. package/dist/importer-Cvf88eAY.js +0 -344
  305. package/dist/internal/ServeLifecycle.js.map +0 -1
  306. package/dist/internal/entryConfig.d.ts.map +0 -1
  307. package/dist/internal/platform.js.map +0 -1
  308. package/dist/internal/release.js +0 -25
  309. package/dist/internal/release.js.map +0 -1
  310. package/dist/internal/serve.js +0 -60
  311. package/dist/internal/serve.js.map +0 -1
  312. package/dist/port--3x2zJ4D.js +0 -285
  313. package/dist/release-DfZPuIcK.js +0 -23
  314. package/dist/rolldown-runtime-DYf_mQCB.js +0 -34
  315. package/dist/socketChannel-CJvL2DiB.js +0 -3658
  316. package/dist/supervisorPlugin-t6Z6PrhD.js +0 -733
  317. package/dist/token-CYBNNlhS.js +0 -17
  318. package/dist/tokenCredentials-CbCuk-Rt.js +0 -31
  319. package/dist/websocketServer-NQhODlEt.js +0 -60
  320. package/dist/workerChannel-C8hhBJzA.js +0 -27
  321. package/src/internal/release.ts +0 -72
  322. package/src/internal/serve.ts +0 -119
  323. /package/dist/{bin.d.ts → internal/childMain.d.ts} +0 -0
@@ -1,18 +1,19 @@
1
1
  import { fromModule } from "../Contract.js";
2
2
  import { MissingInstance, RemoteEntryError } from "../Errors.js";
3
- import { LocalTransport, WorkerTransport } from "./directTransport.js";
4
- import { Host, authentication, hostTransport } from "./entryConfig.js";
5
3
  import { CapabilityFailed, host as host$1 } from "./assembly.js";
4
+ import { children } from "./cleanup.js";
5
+ import { LocalTransport, WorkerTransport } from "./directTransport.js";
6
+ import { authentication, hostTransport } from "./entryConfig.js";
7
+ import { Host } from "../Config.js";
6
8
  import { executionPlugin } from "./execution.js";
7
9
  import { follow } from "./follow.js";
8
- import { children } from "./cleanup.js";
9
- import { resolveEntry } from "./runner/Packages.js";
10
10
  import { make } from "./importer.js";
11
- import { Graft, Plugin } from "@graftland/graft";
12
- import { ConfigDirectory, Entry, ModuleResolver } from "@graftland/loader";
11
+ import { resolveEntry } from "./runner/Packages.js";
13
12
  import { Effect, Option, Path, References, Schema, Scope, String } from "effect";
14
13
  import { SecureRandom } from "effect/crypto";
15
14
  import { ChildProcessSpawner } from "effect/process";
15
+ import { Graft, Plugin } from "@graftland/graft";
16
+ import { ConfigDirectory, Entry, ModuleResolver } from "@graftland/loader";
16
17
  // src/internal/entry.ts
17
18
  const boundary = Effect.fnUntraced(function* (field) {
18
19
  const entry = yield* Entry.CurrentId;
@@ -59,7 +60,8 @@ const direct = (provider, consumer, input, key) => Graft.plugin(Plugin.make({
59
60
  apply: Effect.fnUntraced(function* () {
60
61
  const capability = yield* Graft.plugin(provider);
61
62
  yield* follow(capability, (cause) => Effect.fail(CapabilityFailed.make({ cause })));
62
- const execution = yield* Graft.plugin(consumer, input);
63
+ const definition = yield* consumer;
64
+ const execution = yield* Graft.plugin(definition, input);
63
65
  yield* follow(execution, (cause) => Effect.fail(CapabilityFailed.make({ cause })));
64
66
  })
65
67
  }), void 0, { isolate: [key] });
@@ -69,10 +71,21 @@ const directTarget = Effect.fnUntraced(function* (contract, input, selected, ann
69
71
  const directory = path.resolve(Option.getOrElse(source, () => "."));
70
72
  const module = String.startsWith("file:")(input.contract) ? input.contract : yield* resolveEntry(directory, input.contract);
71
73
  const capability = yield* resolve({ name: selected._tag === "Local" ? "@graftland/plugin-remote/host/local" : "@graftland/plugin-remote/host/worker" }, "connect");
72
- return yield* direct(capability.plugin, executionPlugin(contract, {
74
+ const watch = yield* ModuleResolver.Watch;
75
+ const resolver = yield* Effect.serviceOption(ModuleResolver.ModuleResolver);
76
+ const loaded = yield* Option.isSome(watch) && Option.isSome(resolver) ? resolver.value.importModule(module).pipe(Effect.flatMap((namespace) => Effect.fromOption(fromModule(namespace), () => ModuleResolver.ModuleInvalid.make({
77
+ specifier: module,
78
+ cause: "Expected a remote contract"
79
+ })))) : Effect.succeed(contract);
80
+ const consumer = Effect.succeed(executionPlugin(loaded, {
73
81
  ...options,
74
82
  contractModule: module
75
- }, selected, annotations), input.config, selected._tag === "Local" ? LocalTransport : WorkerTransport);
83
+ }, selected, annotations));
84
+ if (Option.isSome(watch)) {
85
+ const implementation = String.startsWith("file:")(loaded.module) ? loaded.module : yield* resolveEntry(directory, loaded.module);
86
+ yield* ModuleResolver.observe([module, implementation]);
87
+ }
88
+ return yield* direct(capability.plugin, consumer, input.config, selected._tag === "Local" ? LocalTransport : WorkerTransport);
76
89
  });
77
90
  const runnerTarget = Effect.fnUntraced(function* (contract, input, target, annotations, options, authOverride) {
78
91
  const instance = target.instance === void 0 ? yield* Entry.CurrentId : Option.some(target.instance);
@@ -1 +1 @@
1
- {"version":3,"file":"entry.js","names":["EntryError","Importer.make","Contract.fromModule","Configuration.hostTransport","Configuration.authentication","Assembly.host","Configuration.Host"],"sources":["../../src/internal/entry.ts"],"sourcesContent":["import { Graft, Plugin, type Fork } from \"@graftland/graft\"\nimport { ConfigDirectory, Entry, ModuleResolver } from \"@graftland/loader\"\nimport {\n\tCause,\n\tEffect,\n\tOption,\n\tPath,\n\tSchema,\n\tReferences,\n\tScope,\n\tString,\n} from \"effect\"\nimport { ChildProcessSpawner } from \"effect/process\"\nimport * as Contract from \"../Contract\"\nimport { MissingInstance, RemoteEntryError as EntryError } from \"../Errors\"\nimport { LocalTransport, WorkerTransport } from \"./directTransport\"\nimport * as Configuration from \"./entryConfig\"\nimport * as Assembly from \"./assembly\"\nimport { executionPlugin } from \"./execution\"\nimport { follow } from \"./follow\"\nimport { children } from \"./cleanup\"\nimport { resolveEntry } from \"./runner/Packages\"\nimport type { LocalTarget, WorkerTarget } from \"./runner/Connection\"\nimport type { ExecutionOptions } from \"./execution\"\nimport * as Importer from \"./importer\"\nimport { SecureRandom } from \"effect/crypto\"\n\nexport const boundary = Effect.fnUntraced(function* (field: string) {\n\tconst entry = yield* Entry.CurrentId\n\tconst directory = yield* ConfigDirectory\n\treturn (cause: Cause.Cause<unknown>) =>\n\t\tEffect.fail(EntryError.make({ entry, directory, field, cause }))\n})\nexport const resolve = Effect.fnUntraced(function* (\n\treference: Configuration.Reference,\n\tfield: string,\n) {\n\tconst existing = yield* Effect.serviceOption(ModuleResolver.ModuleResolver)\n\tconst path = yield* Path.Path\n\tconst source = yield* ConfigDirectory\n\tconst directory = path.resolve(Option.getOrElse(source, () => \".\"))\n\tconst resolver = yield* Option.match(existing, {\n\t\tonSome: Effect.succeed,\n\t\tonNone: Effect.fnUntraced(function* () {\n\t\t\tconst importer = yield* Importer.make(directory)\n\t\t\treturn yield* ModuleResolver.make({\n\t\t\t\tbase: directory,\n\t\t\t\timporter: (specifier) =>\n\t\t\t\t\tString.startsWith(\"@graftland/plugin-remote/\")(specifier)\n\t\t\t\t\t\t? import(specifier)\n\t\t\t\t\t\t: importer(specifier),\n\t\t\t})\n\t\t}),\n\t})\n\tconst fail = yield* boundary(field)\n\tconst plugin = yield* resolver\n\t\t.resolve(reference.name)\n\t\t.pipe(Effect.catchCause(fail))\n\treturn { plugin, config: reference.config }\n})\nexport const loadContract = Effect.fnUntraced(function* (specifier: string) {\n\tconst resolver = yield* ModuleResolver.ModuleResolver\n\tconst fail = yield* boundary(\"contract\")\n\treturn yield* resolver.importModule(specifier).pipe(\n\t\tEffect.flatMap((module) =>\n\t\t\tEffect.fromOption(Contract.fromModule(module), () =>\n\t\t\t\tModuleResolver.ModuleInvalid.make({\n\t\t\t\t\tspecifier,\n\t\t\t\t\tcause: \"Expected a default or named remote contract\",\n\t\t\t\t}),\n\t\t\t),\n\t\t),\n\t\tEffect.catchCause(fail),\n\t)\n})\n\n/** Direct execution installs only its execution capability in a private realm. */\nexport const direct = (\n\tprovider: Plugin.Plugin,\n\tconsumer: Plugin.Plugin,\n\tinput: Schema.Json,\n\tkey: typeof LocalTransport | typeof WorkerTransport,\n): Effect.Effect<Fork.Fork<never, unknown>, never, Graft.Graft | Scope.Scope> =>\n\tGraft.plugin(\n\t\tPlugin.make({\n\t\t\tname: \"remote-direct\",\n\t\t\tapply: Effect.fnUntraced(function* () {\n\t\t\t\tconst capability = yield* Graft.plugin(provider)\n\t\t\t\tyield* follow(capability, (cause) =>\n\t\t\t\t\tEffect.fail(Assembly.CapabilityFailed.make({ cause })),\n\t\t\t\t)\n\t\t\t\tconst execution = yield* Graft.plugin(consumer, input)\n\t\t\t\tyield* follow(execution, (cause) =>\n\t\t\t\t\tEffect.fail(Assembly.CapabilityFailed.make({ cause })),\n\t\t\t\t)\n\t\t\t}),\n\t\t}),\n\t\tundefined,\n\t\t{ isolate: [key] },\n\t)\n\ntype Annotations = Readonly<Record<string, unknown>>\nconst directTarget = Effect.fnUntraced(function* <\n\tS extends Schema.Top & {\n\t\treadonly Encoded: Schema.Json\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n\tE extends Schema.Top & {\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n>(\n\tcontract: Contract.Contract<S, E>,\n\tinput: typeof Configuration.Host.Type,\n\tselected: LocalTarget | WorkerTarget,\n\tannotations: Annotations,\n\toptions: ExecutionOptions,\n) {\n\tconst path = yield* Path.Path\n\tconst source = yield* ConfigDirectory\n\tconst directory = path.resolve(Option.getOrElse(source, () => \".\"))\n\tconst module = String.startsWith(\"file:\")(input.contract)\n\t\t? input.contract\n\t\t: yield* resolveEntry(directory, input.contract)\n\tconst capability = yield* resolve(\n\t\t{\n\t\t\tname:\n\t\t\t\tselected._tag === \"Local\"\n\t\t\t\t\t? \"@graftland/plugin-remote/host/local\"\n\t\t\t\t\t: \"@graftland/plugin-remote/host/worker\",\n\t\t},\n\t\t\"connect\",\n\t)\n\treturn yield* direct(\n\t\tcapability.plugin,\n\t\texecutionPlugin(\n\t\t\tcontract,\n\t\t\t{ ...options, contractModule: module },\n\t\t\tselected,\n\t\t\tannotations,\n\t\t),\n\t\tinput.config,\n\t\tselected._tag === \"Local\" ? LocalTransport : WorkerTransport,\n\t)\n})\nconst runnerTarget = Effect.fnUntraced(function* <\n\tS extends Schema.Top & {\n\t\treadonly Encoded: Schema.Json\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n\tE extends Schema.Top & {\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n>(\n\tcontract: Contract.Contract<S, E>,\n\tinput: typeof Configuration.Host.Type,\n\ttarget: Exclude<\n\t\tConfiguration.Connect,\n\t\t{ readonly local: object } | { readonly worker: object }\n\t>,\n\tannotations: Annotations,\n\toptions: ExecutionOptions,\n\tauthOverride: typeof Assembly.Invocation.Type | undefined,\n) {\n\tconst instance =\n\t\ttarget.instance === undefined\n\t\t\t? yield* Entry.CurrentId\n\t\t\t: Option.some(target.instance)\n\tif (Option.isNone(instance)) return yield* MissingInstance.make({})\n\tconst transport = yield* resolve(\n\t\tConfiguration.hostTransport(target),\n\t\t\"connect.transport\",\n\t)\n\tconst auth =\n\t\tauthOverride ??\n\t\t(yield* resolve(\n\t\t\tConfiguration.authentication(\"host\", target.auth),\n\t\t\t\"connect.auth\",\n\t\t))\n\tconst consumer = executionPlugin(\n\t\tcontract,\n\t\toptions,\n\t\t{\n\t\t\t_tag: \"Connector\",\n\t\t\texplicitAuth: target.auth !== undefined,\n\t\t\tinstance: instance.value,\n\t\t\t...(target.lease === undefined ? {} : { lease: target.lease }),\n\t\t\t...(target.margin === undefined ? {} : { margin: target.margin }),\n\t\t\t...(target.expect === undefined ? {} : { expect: target.expect }),\n\t\t},\n\t\tannotations,\n\t)\n\treturn yield* Assembly.host({\n\t\ttransport,\n\t\tauth,\n\t\tconsumer,\n\t\tinput: input.config,\n\t})\n})\n\nexport const launch = Effect.fnUntraced(function* <\n\tS extends Schema.Top & {\n\t\treadonly Encoded: Schema.Json\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n\tE extends Schema.Top & {\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n>(\n\tcontract: Contract.Contract<S, E>,\n\tinput: typeof Configuration.Host.Type,\n\toptions: ExecutionOptions,\n\tauthOverride?: typeof Assembly.Invocation.Type,\n) {\n\tconst annotations = yield* References.CurrentLogAnnotations\n\tconst connect = input.connect\n\tconst scope = yield* children\n\treturn yield* Effect.gen(function* () {\n\t\tif (connect.local !== undefined)\n\t\t\treturn yield* directTarget(\n\t\t\t\tcontract,\n\t\t\t\tinput,\n\t\t\t\t{ _tag: \"Local\", ...connect.local },\n\t\t\t\tannotations,\n\t\t\t\toptions,\n\t\t\t)\n\t\tif (connect.worker !== undefined)\n\t\t\treturn yield* directTarget(\n\t\t\t\tcontract,\n\t\t\t\tinput,\n\t\t\t\t{ _tag: \"Worker\", ...connect.worker },\n\t\t\t\tannotations,\n\t\t\t\toptions,\n\t\t\t)\n\t\treturn yield* runnerTarget(\n\t\t\tcontract,\n\t\t\tinput,\n\t\t\tconnect,\n\t\t\tannotations,\n\t\t\toptions,\n\t\t\tauthOverride,\n\t\t)\n\t}).pipe(Scope.provide(scope))\n})\nconst load = Effect.fnUntraced(function* (\n\tinput: typeof Configuration.Host.Type,\n) {\n\tconst contract = yield* loadContract(input.contract)\n\tconst failConfig = yield* boundary(\"config\")\n\tyield* Schema.decodeEffect(contract.config)(input.config).pipe(\n\t\tEffect.catchCause(failConfig),\n\t)\n\tconst failConnect = yield* boundary(\"connect\")\n\tconst fork = yield* launch(contract, input, {\n\t\tcontractModule: input.contract,\n\t}).pipe(Effect.catchCause(failConnect))\n\tyield* follow(fork, failConnect)\n})\nexport const host = Plugin.make({\n\tname: \"remote\",\n\tconfig: Configuration.Host,\n\tin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AO,OAAO,aAAa,SAAS,MAAM,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,KACzD,OAAO,WAAW,UAAU,CAC7B;CACA,MAAM,cAAc,OAAO,SAAS,SAAS;CAC7C,MAAM,OAAO,OAAO,OAAO,UAAU,OAAO,EAC3C,gBAAgB,MAAM,SACvB,CAAC,CAAC,CAAC,KAAK,OAAO,WAAW,WAAW,CAAC;CACtC,OAAO,OAAO,MAAM,WAAW;AAChC,CAAC;AACD,MAAa,OAAO,OAAO,KAAK;CAC/B,MAAM;CACN,QAAQC;CACR,QAAQ;EACP,aAAa;EACb,eAAe;EACf,KAAK;EACL,oBAAoB;CACrB;CACA,OAAO;AACR,CAAC"}
1
+ {"version":3,"file":"entry.js","names":["EntryError","Importer.make","Contract.fromModule","Configuration.hostTransport","Configuration.authentication","Assembly.host","Configuration.Host"],"sources":["../../src/internal/entry.ts"],"sourcesContent":["import {\n\tCause,\n\tEffect,\n\tOption,\n\tPath,\n\tReferences,\n\tSchema,\n\tScope,\n\tString,\n} from \"effect\"\nimport { SecureRandom } from \"effect/crypto\"\nimport { ChildProcessSpawner } from \"effect/process\"\n\nimport { Graft, Plugin, type Fork } from \"@graftland/graft\"\nimport { ConfigDirectory, Entry, ModuleResolver } from \"@graftland/loader\"\n\nimport * as Contract from \"../Contract\"\nimport { RemoteEntryError as EntryError, MissingInstance } from \"../Errors\"\nimport * as Assembly from \"./assembly\"\nimport { children } from \"./cleanup\"\nimport { LocalTransport, WorkerTransport } from \"./directTransport\"\nimport * as Configuration from \"./entryConfig\"\nimport { executionPlugin, type ExecutionOptions } from \"./execution\"\nimport { follow } from \"./follow\"\nimport * as Importer from \"./importer\"\nimport type { LocalTarget, WorkerTarget } from \"./runner/Connection\"\nimport { resolveEntry } from \"./runner/Packages\"\n\nexport const boundary = Effect.fnUntraced(function* (field: string) {\n\tconst entry = yield* Entry.CurrentId\n\tconst directory = yield* ConfigDirectory\n\treturn (cause: Cause.Cause<unknown>) =>\n\t\tEffect.fail(EntryError.make({ entry, directory, field, cause }))\n})\nexport const resolve = Effect.fnUntraced(function* (\n\treference: Configuration.Reference,\n\tfield: string,\n) {\n\tconst existing = yield* Effect.serviceOption(ModuleResolver.ModuleResolver)\n\tconst path = yield* Path.Path\n\tconst source = yield* ConfigDirectory\n\tconst directory = path.resolve(Option.getOrElse(source, () => \".\"))\n\tconst resolver = yield* Option.match(existing, {\n\t\tonSome: Effect.succeed,\n\t\tonNone: Effect.fnUntraced(function* () {\n\t\t\tconst importer = yield* Importer.make(directory)\n\t\t\treturn yield* ModuleResolver.make({\n\t\t\t\tbase: directory,\n\t\t\t\timporter: (specifier) =>\n\t\t\t\t\tString.startsWith(\"@graftland/plugin-remote/\")(specifier)\n\t\t\t\t\t\t? import(specifier)\n\t\t\t\t\t\t: importer(specifier),\n\t\t\t})\n\t\t}),\n\t})\n\tconst fail = yield* boundary(field)\n\tconst plugin = yield* resolver\n\t\t.resolve(reference.name)\n\t\t.pipe(Effect.catchCause(fail))\n\treturn { plugin, config: reference.config }\n})\nexport const loadContract = Effect.fnUntraced(function* (specifier: string) {\n\tconst resolver = yield* ModuleResolver.ModuleResolver\n\tconst fail = yield* boundary(\"contract\")\n\treturn yield* resolver.importModule(specifier).pipe(\n\t\tEffect.flatMap((module) =>\n\t\t\tEffect.fromOption(Contract.fromModule(module), () =>\n\t\t\t\tModuleResolver.ModuleInvalid.make({\n\t\t\t\t\tspecifier,\n\t\t\t\t\tcause: \"Expected a default or named remote contract\",\n\t\t\t\t}),\n\t\t\t),\n\t\t),\n\t\tEffect.catchCause(fail),\n\t)\n})\n\n/** Direct execution installs only its execution capability in a private realm. */\nexport const direct = (\n\tprovider: Plugin.Plugin,\n\tconsumer: Effect.Effect<\n\t\tPlugin.Plugin,\n\t\tModuleResolver.ModuleInvalid,\n\t\tScope.Scope\n\t>,\n\tinput: Schema.Json,\n\tkey: typeof LocalTransport | typeof WorkerTransport,\n): Effect.Effect<Fork.Fork<never, unknown>, never, Graft.Graft | Scope.Scope> =>\n\tGraft.plugin(\n\t\tPlugin.make({\n\t\t\tname: \"remote-direct\",\n\t\t\tapply: Effect.fnUntraced(function* () {\n\t\t\t\tconst capability = yield* Graft.plugin(provider)\n\t\t\t\tyield* follow(capability, (cause) =>\n\t\t\t\t\tEffect.fail(Assembly.CapabilityFailed.make({ cause })),\n\t\t\t\t)\n\t\t\t\tconst definition = yield* consumer\n\t\t\t\tconst execution = yield* Graft.plugin(definition, input)\n\t\t\t\tyield* follow(execution, (cause) =>\n\t\t\t\t\tEffect.fail(Assembly.CapabilityFailed.make({ cause })),\n\t\t\t\t)\n\t\t\t}),\n\t\t}),\n\t\tundefined,\n\t\t{ isolate: [key] },\n\t)\n\ntype Annotations = Readonly<Record<string, unknown>>\nconst directTarget = Effect.fnUntraced(function* <\n\tS extends Schema.Top & {\n\t\treadonly Encoded: Schema.Json\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n\tE extends Schema.Top & {\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n>(\n\tcontract: Contract.Contract<S, E>,\n\tinput: typeof Configuration.Host.Type,\n\tselected: LocalTarget | WorkerTarget,\n\tannotations: Annotations,\n\toptions: ExecutionOptions,\n) {\n\tconst path = yield* Path.Path\n\tconst source = yield* ConfigDirectory\n\tconst directory = path.resolve(Option.getOrElse(source, () => \".\"))\n\tconst module = String.startsWith(\"file:\")(input.contract)\n\t\t? input.contract\n\t\t: yield* resolveEntry(directory, input.contract)\n\tconst capability = yield* resolve(\n\t\t{\n\t\t\tname:\n\t\t\t\tselected._tag === \"Local\"\n\t\t\t\t\t? \"@graftland/plugin-remote/host/local\"\n\t\t\t\t\t: \"@graftland/plugin-remote/host/worker\",\n\t\t},\n\t\t\"connect\",\n\t)\n\n\tconst watch = yield* ModuleResolver.Watch\n\tconst resolver = yield* Effect.serviceOption(ModuleResolver.ModuleResolver)\n\tconst current: Effect.Effect<\n\t\tContract.Contract<Contract.ConfigSchema, Contract.ErrorSchema>,\n\t\tModuleResolver.ModuleInvalid,\n\t\tScope.Scope\n\t> = Option.isSome(watch) && Option.isSome(resolver)\n\t\t? resolver.value.importModule(module).pipe(\n\t\t\t\tEffect.flatMap((namespace) =>\n\t\t\t\t\tEffect.fromOption(Contract.fromModule(namespace), () =>\n\t\t\t\t\t\tModuleResolver.ModuleInvalid.make({\n\t\t\t\t\t\t\tspecifier: module,\n\t\t\t\t\t\t\tcause: \"Expected a remote contract\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t)\n\t\t: Effect.succeed(contract)\n\tconst loaded = yield* current\n\tconst consumer = Effect.succeed(\n\t\texecutionPlugin(\n\t\t\tloaded,\n\t\t\t{ ...options, contractModule: module },\n\t\t\tselected,\n\t\t\tannotations,\n\t\t),\n\t)\n\tif (Option.isSome(watch)) {\n\t\tconst implementation = String.startsWith(\"file:\")(loaded.module)\n\t\t\t? loaded.module\n\t\t\t: yield* resolveEntry(directory, loaded.module)\n\t\tyield* ModuleResolver.observe([module, implementation])\n\t}\n\tconst fork = yield* direct(\n\t\tcapability.plugin,\n\t\tconsumer,\n\t\tinput.config,\n\t\tselected._tag === \"Local\" ? LocalTransport : WorkerTransport,\n\t)\n\n\treturn fork\n})\nconst runnerTarget = Effect.fnUntraced(function* <\n\tS extends Schema.Top & {\n\t\treadonly Encoded: Schema.Json\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n\tE extends Schema.Top & {\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n>(\n\tcontract: Contract.Contract<S, E>,\n\tinput: typeof Configuration.Host.Type,\n\ttarget: Exclude<\n\t\tConfiguration.Connect,\n\t\t{ readonly local: object } | { readonly worker: object }\n\t>,\n\tannotations: Annotations,\n\toptions: ExecutionOptions,\n\tauthOverride: typeof Assembly.Invocation.Type | undefined,\n) {\n\tconst instance =\n\t\ttarget.instance === undefined\n\t\t\t? yield* Entry.CurrentId\n\t\t\t: Option.some(target.instance)\n\tif (Option.isNone(instance)) return yield* MissingInstance.make({})\n\tconst transport = yield* resolve(\n\t\tConfiguration.hostTransport(target),\n\t\t\"connect.transport\",\n\t)\n\tconst auth =\n\t\tauthOverride ??\n\t\t(yield* resolve(\n\t\t\tConfiguration.authentication(\"host\", target.auth),\n\t\t\t\"connect.auth\",\n\t\t))\n\tconst consumer = executionPlugin(\n\t\tcontract,\n\t\toptions,\n\t\t{\n\t\t\t_tag: \"Connector\",\n\t\t\texplicitAuth: target.auth !== undefined,\n\t\t\tinstance: instance.value,\n\t\t\t...(target.lease === undefined ? {} : { lease: target.lease }),\n\t\t\t...(target.margin === undefined ? {} : { margin: target.margin }),\n\t\t\t...(target.expect === undefined ? {} : { expect: target.expect }),\n\t\t},\n\t\tannotations,\n\t)\n\treturn yield* Assembly.host({\n\t\ttransport,\n\t\tauth,\n\t\tconsumer,\n\t\tinput: input.config,\n\t})\n})\n\nexport const launch = Effect.fnUntraced(function* <\n\tS extends Schema.Top & {\n\t\treadonly Encoded: Schema.Json\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n\tE extends Schema.Top & {\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n>(\n\tcontract: Contract.Contract<S, E>,\n\tinput: typeof Configuration.Host.Type,\n\toptions: ExecutionOptions,\n\tauthOverride?: typeof Assembly.Invocation.Type,\n) {\n\tconst annotations = yield* References.CurrentLogAnnotations\n\tconst connect = input.connect\n\tconst scope = yield* children\n\treturn yield* Effect.gen(function* () {\n\t\tif (connect.local !== undefined)\n\t\t\treturn yield* directTarget(\n\t\t\t\tcontract,\n\t\t\t\tinput,\n\t\t\t\t{ _tag: \"Local\", ...connect.local },\n\t\t\t\tannotations,\n\t\t\t\toptions,\n\t\t\t)\n\t\tif (connect.worker !== undefined)\n\t\t\treturn yield* directTarget(\n\t\t\t\tcontract,\n\t\t\t\tinput,\n\t\t\t\t{ _tag: \"Worker\", ...connect.worker },\n\t\t\t\tannotations,\n\t\t\t\toptions,\n\t\t\t)\n\t\treturn yield* runnerTarget(\n\t\t\tcontract,\n\t\t\tinput,\n\t\t\tconnect,\n\t\t\tannotations,\n\t\t\toptions,\n\t\t\tauthOverride,\n\t\t)\n\t}).pipe(Scope.provide(scope))\n})\nconst load = Effect.fnUntraced(function* (\n\tinput: typeof Configuration.Host.Type,\n) {\n\tconst contract = yield* loadContract(input.contract)\n\tconst failConfig = yield* boundary(\"config\")\n\tyield* Schema.decodeEffect(contract.config)(input.config).pipe(\n\t\tEffect.catchCause(failConfig),\n\t)\n\tconst failConnect = yield* boundary(\"connect\")\n\tconst fork = yield* launch(contract, input, {\n\t\tcontractModule: input.contract,\n\t}).pipe(Effect.catchCause(failConnect))\n\tyield* follow(fork, failConnect)\n})\nexport const host = Plugin.make({\n\tname: \"remote\",\n\tconfig: Configuration.Host,\n\tinject: [\n\t\tSecureRandom.SecureRandom,\n\t\tModuleResolver.ModuleResolver,\n\t\tPath.Path,\n\t\tChildProcessSpawner.ChildProcessSpawner,\n\t],\n\tapply: load,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,MAAa,WAAW,OAAO,WAAW,WAAW,OAAe;CACnE,MAAM,QAAQ,OAAO,MAAM;CAC3B,MAAM,YAAY,OAAO;CACzB,QAAQ,UACP,OAAO,KAAKA,iBAAW,KAAK;EAAE;EAAO;EAAW;EAAO;CAAM,CAAC,CAAC;AACjE,CAAC;AACD,MAAa,UAAU,OAAO,WAAW,WACxC,WACA,OACC;CACD,MAAM,WAAW,OAAO,OAAO,cAAc,eAAe,cAAc;CAC1E,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,SAAS,OAAO;CACtB,MAAM,YAAY,KAAK,QAAQ,OAAO,UAAU,cAAc,GAAG,CAAC;CAClE,MAAM,WAAW,OAAO,OAAO,MAAM,UAAU;EAC9C,QAAQ,OAAO;EACf,QAAQ,OAAO,WAAW,aAAa;GACtC,MAAM,WAAW,OAAOC,KAAc,SAAS;GAC/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UAAU,CAC7B;CACA,MAAM,cAAc,OAAO,SAAS,SAAS;CAC7C,MAAM,OAAO,OAAO,OAAO,UAAU,OAAO,EAC3C,gBAAgB,MAAM,SACvB,CAAC,CAAC,CAAC,KAAK,OAAO,WAAW,WAAW,CAAC;CACtC,OAAO,OAAO,MAAM,WAAW;AAChC,CAAC;AACD,MAAa,OAAO,OAAO,KAAK;CAC/B,MAAM;CACN,QAAQC;CACR,QAAQ;EACP,aAAa;EACb,eAAe;EACf,KAAK;EACL,oBAAoB;CACrB;CACA,OAAO;AACR,CAAC"}
@@ -1,202 +1,2 @@
1
- import { Schema } from "effect";
2
- export declare const Connect: Schema.Union<readonly [Schema.Struct<{
3
- unix: Schema.optionalKey<Schema.Never>;
4
- command: Schema.optionalKey<Schema.Never>;
5
- stdio: Schema.optionalKey<Schema.Never>;
6
- local: Schema.optionalKey<Schema.Never>;
7
- worker: Schema.optionalKey<Schema.Never>;
8
- transport: Schema.optionalKey<Schema.Never>;
9
- instance: Schema.optionalKey<Schema.String>;
10
- lease: Schema.optionalKey<Schema.DurationFromString>;
11
- margin: Schema.optionalKey<Schema.DurationFromString>;
12
- expect: Schema.optionalKey<Schema.Struct<{
13
- readonly version: Schema.optionalKey<Schema.String>;
14
- readonly digest: Schema.optionalKey<Schema.String>;
15
- }>>;
16
- auth: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
17
- readonly mtls: Schema.optionalKey<Schema.Never>;
18
- readonly bearer: Schema.optionalKey<Schema.Never>;
19
- readonly jwt: Schema.optionalKey<Schema.Never>;
20
- readonly none: Schema.optionalKey<Schema.Never>;
21
- readonly name: Schema.String;
22
- readonly config: Schema.optionalKey<Schema.Unknown>;
23
- }>, Schema.Struct<{
24
- readonly name: Schema.optionalKey<Schema.Never>;
25
- readonly config: Schema.optionalKey<Schema.Never>;
26
- readonly bearer: Schema.optionalKey<Schema.Never>;
27
- readonly jwt: Schema.optionalKey<Schema.Never>;
28
- readonly none: Schema.optionalKey<Schema.Never>;
29
- readonly mtls: Schema.Unknown;
30
- }>, Schema.Struct<{
31
- readonly name: Schema.optionalKey<Schema.Never>;
32
- readonly config: Schema.optionalKey<Schema.Never>;
33
- readonly mtls: Schema.optionalKey<Schema.Never>;
34
- readonly jwt: Schema.optionalKey<Schema.Never>;
35
- readonly none: Schema.optionalKey<Schema.Never>;
36
- readonly bearer: Schema.Unknown;
37
- }>, Schema.Struct<{
38
- readonly name: Schema.optionalKey<Schema.Never>;
39
- readonly config: Schema.optionalKey<Schema.Never>;
40
- readonly mtls: Schema.optionalKey<Schema.Never>;
41
- readonly bearer: Schema.optionalKey<Schema.Never>;
42
- readonly none: Schema.optionalKey<Schema.Never>;
43
- readonly jwt: Schema.Unknown;
44
- }>, Schema.Struct<{
45
- readonly name: Schema.optionalKey<Schema.Never>;
46
- readonly config: Schema.optionalKey<Schema.Never>;
47
- readonly mtls: Schema.optionalKey<Schema.Never>;
48
- readonly bearer: Schema.optionalKey<Schema.Never>;
49
- readonly jwt: Schema.optionalKey<Schema.Never>;
50
- readonly none: Schema.Unknown;
51
- }>]>>;
52
- url: Schema.String;
53
- ca: Schema.optionalKey<Schema.String>;
54
- servername: Schema.optionalKey<Schema.String>;
55
- }>, Schema.Struct<{
56
- readonly url: Schema.optionalKey<Schema.Never>;
57
- readonly command: Schema.optionalKey<Schema.Never>;
58
- readonly stdio: Schema.optionalKey<Schema.Never>;
59
- readonly local: Schema.optionalKey<Schema.Never>;
60
- readonly worker: Schema.optionalKey<Schema.Never>;
61
- readonly transport: Schema.optionalKey<Schema.Never>;
62
- readonly instance: Schema.optionalKey<Schema.String>;
63
- readonly lease: Schema.optionalKey<Schema.DurationFromString>;
64
- readonly margin: Schema.optionalKey<Schema.DurationFromString>;
65
- readonly expect: Schema.optionalKey<Schema.Struct<{
66
- readonly version: Schema.optionalKey<Schema.String>;
67
- readonly digest: Schema.optionalKey<Schema.String>;
68
- }>>;
69
- readonly auth: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
70
- readonly mtls: Schema.optionalKey<Schema.Never>;
71
- readonly bearer: Schema.optionalKey<Schema.Never>;
72
- readonly jwt: Schema.optionalKey<Schema.Never>;
73
- readonly none: Schema.optionalKey<Schema.Never>;
74
- readonly name: Schema.String;
75
- readonly config: Schema.optionalKey<Schema.Unknown>;
76
- }>, Schema.Struct<{
77
- readonly name: Schema.optionalKey<Schema.Never>;
78
- readonly config: Schema.optionalKey<Schema.Never>;
79
- readonly bearer: Schema.optionalKey<Schema.Never>;
80
- readonly jwt: Schema.optionalKey<Schema.Never>;
81
- readonly none: Schema.optionalKey<Schema.Never>;
82
- readonly mtls: Schema.Unknown;
83
- }>, Schema.Struct<{
84
- readonly name: Schema.optionalKey<Schema.Never>;
85
- readonly config: Schema.optionalKey<Schema.Never>;
86
- readonly mtls: Schema.optionalKey<Schema.Never>;
87
- readonly jwt: Schema.optionalKey<Schema.Never>;
88
- readonly none: Schema.optionalKey<Schema.Never>;
89
- readonly bearer: Schema.Unknown;
90
- }>, Schema.Struct<{
91
- readonly name: Schema.optionalKey<Schema.Never>;
92
- readonly config: Schema.optionalKey<Schema.Never>;
93
- readonly mtls: Schema.optionalKey<Schema.Never>;
94
- readonly bearer: Schema.optionalKey<Schema.Never>;
95
- readonly none: Schema.optionalKey<Schema.Never>;
96
- readonly jwt: Schema.Unknown;
97
- }>, Schema.Struct<{
98
- readonly name: Schema.optionalKey<Schema.Never>;
99
- readonly config: Schema.optionalKey<Schema.Never>;
100
- readonly mtls: Schema.optionalKey<Schema.Never>;
101
- readonly bearer: Schema.optionalKey<Schema.Never>;
102
- readonly jwt: Schema.optionalKey<Schema.Never>;
103
- readonly none: Schema.Unknown;
104
- }>]>>;
105
- readonly unix: Schema.String;
106
- }>, Schema.Struct<{
107
- readonly url: Schema.optionalKey<Schema.Never>;
108
- readonly unix: Schema.optionalKey<Schema.Never>;
109
- readonly stdio: Schema.optionalKey<Schema.Never>;
110
- readonly local: Schema.optionalKey<Schema.Never>;
111
- readonly worker: Schema.optionalKey<Schema.Never>;
112
- readonly transport: Schema.optionalKey<Schema.Never>;
113
- readonly instance: Schema.optionalKey<Schema.String>;
114
- readonly lease: Schema.optionalKey<Schema.DurationFromString>;
115
- readonly margin: Schema.optionalKey<Schema.DurationFromString>;
116
- readonly expect: Schema.optionalKey<Schema.Struct<{
117
- readonly version: Schema.optionalKey<Schema.String>;
118
- readonly digest: Schema.optionalKey<Schema.String>;
119
- }>>;
120
- readonly command: Schema.NonEmptyArray<Schema.String>;
121
- readonly auth: Schema.optionalKey<Schema.Never>;
122
- readonly cwd: Schema.optionalKey<Schema.String>;
123
- readonly env: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
124
- }>, Schema.Struct<{
125
- readonly url: Schema.optionalKey<Schema.Never>;
126
- readonly unix: Schema.optionalKey<Schema.Never>;
127
- readonly command: Schema.optionalKey<Schema.Never>;
128
- readonly stdio: Schema.optionalKey<Schema.Never>;
129
- readonly worker: Schema.optionalKey<Schema.Never>;
130
- readonly transport: Schema.optionalKey<Schema.Never>;
131
- readonly auth: Schema.optionalKey<Schema.Never>;
132
- readonly local: Schema.Struct<{
133
- readonly command: Schema.optionalKey<Schema.NonEmptyArray<Schema.String>>;
134
- }>;
135
- }>, Schema.Struct<{
136
- readonly url: Schema.optionalKey<Schema.Never>;
137
- readonly unix: Schema.optionalKey<Schema.Never>;
138
- readonly command: Schema.optionalKey<Schema.Never>;
139
- readonly stdio: Schema.optionalKey<Schema.Never>;
140
- readonly local: Schema.optionalKey<Schema.Never>;
141
- readonly transport: Schema.optionalKey<Schema.Never>;
142
- readonly auth: Schema.optionalKey<Schema.Never>;
143
- readonly worker: Schema.Struct<{
144
- readonly execArgv: Schema.optionalKey<Schema.$Array<Schema.String>>;
145
- }>;
146
- }>, Schema.Struct<{
147
- readonly url: Schema.optionalKey<Schema.Never>;
148
- readonly unix: Schema.optionalKey<Schema.Never>;
149
- readonly command: Schema.optionalKey<Schema.Never>;
150
- readonly stdio: Schema.optionalKey<Schema.Never>;
151
- readonly local: Schema.optionalKey<Schema.Never>;
152
- readonly worker: Schema.optionalKey<Schema.Never>;
153
- readonly instance: Schema.optionalKey<Schema.String>;
154
- readonly lease: Schema.optionalKey<Schema.DurationFromString>;
155
- readonly margin: Schema.optionalKey<Schema.DurationFromString>;
156
- readonly expect: Schema.optionalKey<Schema.Struct<{
157
- readonly version: Schema.optionalKey<Schema.String>;
158
- readonly digest: Schema.optionalKey<Schema.String>;
159
- }>>;
160
- readonly auth: Schema.optionalKey<Schema.Union<readonly [Schema.Struct<{
161
- readonly mtls: Schema.optionalKey<Schema.Never>;
162
- readonly bearer: Schema.optionalKey<Schema.Never>;
163
- readonly jwt: Schema.optionalKey<Schema.Never>;
164
- readonly none: Schema.optionalKey<Schema.Never>;
165
- readonly name: Schema.String;
166
- readonly config: Schema.optionalKey<Schema.Unknown>;
167
- }>, Schema.Struct<{
168
- readonly name: Schema.optionalKey<Schema.Never>;
169
- readonly config: Schema.optionalKey<Schema.Never>;
170
- readonly bearer: Schema.optionalKey<Schema.Never>;
171
- readonly jwt: Schema.optionalKey<Schema.Never>;
172
- readonly none: Schema.optionalKey<Schema.Never>;
173
- readonly mtls: Schema.Unknown;
174
- }>, Schema.Struct<{
175
- readonly name: Schema.optionalKey<Schema.Never>;
176
- readonly config: Schema.optionalKey<Schema.Never>;
177
- readonly mtls: Schema.optionalKey<Schema.Never>;
178
- readonly jwt: Schema.optionalKey<Schema.Never>;
179
- readonly none: Schema.optionalKey<Schema.Never>;
180
- readonly bearer: Schema.Unknown;
181
- }>, Schema.Struct<{
182
- readonly name: Schema.optionalKey<Schema.Never>;
183
- readonly config: Schema.optionalKey<Schema.Never>;
184
- readonly mtls: Schema.optionalKey<Schema.Never>;
185
- readonly bearer: Schema.optionalKey<Schema.Never>;
186
- readonly none: Schema.optionalKey<Schema.Never>;
187
- readonly jwt: Schema.Unknown;
188
- }>, Schema.Struct<{
189
- readonly name: Schema.optionalKey<Schema.Never>;
190
- readonly config: Schema.optionalKey<Schema.Never>;
191
- readonly mtls: Schema.optionalKey<Schema.Never>;
192
- readonly bearer: Schema.optionalKey<Schema.Never>;
193
- readonly jwt: Schema.optionalKey<Schema.Never>;
194
- readonly none: Schema.Unknown;
195
- }>]>>;
196
- readonly transport: Schema.Struct<{
197
- readonly name: Schema.String;
198
- readonly config: Schema.optionalKey<Schema.Unknown>;
199
- }>;
200
- }>]>;
201
- export type Connect = typeof Connect.Type;
202
- //# sourceMappingURL=entryConfig.d.ts.map
1
+ import { Authentication, Cli, Connect, Host, Listen, Reference, Runner, RunnerAuthentication, entries } from "../Config.js";
2
+ export { Authentication, Cli, Connect, Host, Listen, Reference, Runner, RunnerAuthentication, entries };
@@ -1,127 +1,5 @@
1
- import { PositiveDuration } from "./config.js";
2
- import { Effect, Schema } from "effect";
1
+ import { Authentication, Cli, Connect, Host, Listen, Reference, Runner, RunnerAuthentication, entries } from "../Config.js";
3
2
  // src/internal/entryConfig.ts
4
- const Reference = Schema.Struct({
5
- name: Schema.String,
6
- config: Schema.optionalKey(Schema.Unknown)
7
- });
8
- const absent = Schema.optionalKey(Schema.Never);
9
- const authFields = {
10
- name: absent,
11
- config: absent,
12
- mtls: absent,
13
- bearer: absent,
14
- jwt: absent,
15
- none: absent
16
- };
17
- const Authentication = Schema.Union([
18
- Schema.Struct({
19
- ...authFields,
20
- name: Schema.String,
21
- config: Schema.optionalKey(Schema.Unknown)
22
- }),
23
- Schema.Struct({
24
- ...authFields,
25
- mtls: Schema.Unknown
26
- }),
27
- Schema.Struct({
28
- ...authFields,
29
- bearer: Schema.Unknown
30
- }),
31
- Schema.Struct({
32
- ...authFields,
33
- jwt: Schema.Unknown
34
- }),
35
- Schema.Struct({
36
- ...authFields,
37
- none: Schema.Unknown
38
- })
39
- ]);
40
- const transportFields = {
41
- url: absent,
42
- unix: absent,
43
- command: absent,
44
- stdio: absent,
45
- local: absent,
46
- worker: absent,
47
- transport: absent
48
- };
49
- const auth = Schema.optionalKey(Authentication);
50
- const common = {
51
- instance: Schema.optionalKey(Schema.String),
52
- lease: Schema.optionalKey(PositiveDuration),
53
- margin: Schema.optionalKey(PositiveDuration),
54
- expect: Schema.optionalKey(Schema.Struct({
55
- version: Schema.optionalKey(Schema.String),
56
- digest: Schema.optionalKey(Schema.String)
57
- }))
58
- };
59
- const network = {
60
- ...transportFields,
61
- ...common,
62
- auth,
63
- url: Schema.String,
64
- ca: Schema.optionalKey(Schema.String),
65
- servername: Schema.optionalKey(Schema.String)
66
- };
67
- const Connect = Schema.Union([
68
- Schema.Struct(network),
69
- Schema.Struct({
70
- ...transportFields,
71
- ...common,
72
- auth,
73
- unix: Schema.String
74
- }),
75
- Schema.Struct({
76
- ...transportFields,
77
- ...common,
78
- command: Schema.NonEmptyArray(Schema.String),
79
- auth: Schema.optionalKey(Schema.Never.annotate({ message: "Direct and stdio transports do not accept auth" })),
80
- cwd: Schema.optionalKey(Schema.String),
81
- env: Schema.optionalKey(Schema.Record(Schema.String, Schema.String))
82
- }),
83
- Schema.Struct({
84
- ...transportFields,
85
- auth: Schema.optionalKey(Schema.Never.annotate({ message: "Direct and stdio transports do not accept auth" })),
86
- local: Schema.Struct({ command: Schema.optionalKey(Schema.NonEmptyArray(Schema.String)) })
87
- }),
88
- Schema.Struct({
89
- ...transportFields,
90
- auth: Schema.optionalKey(Schema.Never.annotate({ message: "Direct and stdio transports do not accept auth" })),
91
- worker: Schema.Struct({ execArgv: Schema.optionalKey(Schema.Array(Schema.String)) })
92
- }),
93
- Schema.Struct({
94
- ...transportFields,
95
- ...common,
96
- auth,
97
- transport: Reference
98
- })
99
- ]);
100
- const Listen = Schema.Union([
101
- Schema.Struct({
102
- ...transportFields,
103
- auth,
104
- url: Schema.String,
105
- cert: Schema.optionalKey(Schema.String),
106
- key: Schema.optionalKey(Schema.String)
107
- }),
108
- Schema.Struct({
109
- ...transportFields,
110
- auth,
111
- unix: Schema.String
112
- }),
113
- Schema.Struct({
114
- ...transportFields,
115
- stdio: Schema.Literal(true),
116
- auth: Schema.optionalKey(Schema.Never.annotate({ message: "Direct and stdio transports do not accept auth" })),
117
- identity: Schema.optionalKey(Schema.String)
118
- }),
119
- Schema.Struct({
120
- ...transportFields,
121
- auth,
122
- transport: Reference
123
- })
124
- ]);
125
3
  const capability = (side, name, config) => ({
126
4
  name: `@graftland/plugin-remote/${side}/${name}`,
127
5
  config
@@ -158,19 +36,7 @@ const runnerTransport = (input) => {
158
36
  if (input.unix !== void 0) return capability("runner", "unix", { path: input.unix });
159
37
  return capability("runner", "stdio", {});
160
38
  };
161
- const Host = Schema.Struct({
162
- contract: Schema.String,
163
- connect: Connect,
164
- config: Schema.Json.pipe(Schema.withDecodingDefaultKey(Effect.succeed({})))
165
- });
166
- const Runner = Schema.Struct({
167
- root: Schema.String,
168
- state: Schema.String,
169
- lease: Schema.optionalKey(PositiveDuration),
170
- grace: Schema.optionalKey(PositiveDuration),
171
- listen: Schema.Array(Listen)
172
- });
173
39
  const runnerAuthentication = (input) => input.stdio !== void 0 ? capability("runner", "auth/none", { identity: input.identity ?? "anonymous" }) : authentication("runner", input.auth);
174
- export { Authentication, Connect, Host, Listen, Reference, Runner, authentication, hostTransport, runnerAuthentication, runnerTransport };
40
+ export { Authentication, Cli, Connect, Host, Listen, Reference, Runner, RunnerAuthentication, authentication, entries, hostTransport, runnerAuthentication, runnerTransport };
175
41
 
176
42
  //# sourceMappingURL=entryConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"entryConfig.js","names":[],"sources":["../../src/internal/entryConfig.ts"],"sourcesContent":["import { Effect, Schema } from \"effect\"\nimport { PositiveDuration } from \"./config\"\n\nexport const Reference = Schema.Struct({\n\tname: Schema.String,\n\tconfig: Schema.optionalKey(Schema.Unknown),\n})\nexport type Reference = typeof Reference.Type\nconst absent = Schema.optionalKey(Schema.Never)\nconst authFields = {\n\tname: absent,\n\tconfig: absent,\n\tmtls: absent,\n\tbearer: absent,\n\tjwt: absent,\n\tnone: absent,\n}\nexport const Authentication = Schema.Union([\n\tSchema.Struct({\n\t\t...authFields,\n\t\tname: Schema.String,\n\t\tconfig: Schema.optionalKey(Schema.Unknown),\n\t}),\n\tSchema.Struct({ ...authFields, mtls: Schema.Unknown }),\n\tSchema.Struct({ ...authFields, bearer: Schema.Unknown }),\n\tSchema.Struct({ ...authFields, jwt: Schema.Unknown }),\n\tSchema.Struct({ ...authFields, none: Schema.Unknown }),\n])\nconst transportFields = {\n\turl: absent,\n\tunix: absent,\n\tcommand: absent,\n\tstdio: absent,\n\tlocal: absent,\n\tworker: absent,\n\ttransport: absent,\n}\nconst auth = Schema.optionalKey(Authentication)\nconst common = {\n\tinstance: Schema.optionalKey(Schema.String),\n\tlease: Schema.optionalKey(PositiveDuration),\n\tmargin: Schema.optionalKey(PositiveDuration),\n\texpect: Schema.optionalKey(\n\t\tSchema.Struct({\n\t\t\tversion: Schema.optionalKey(Schema.String),\n\t\t\tdigest: Schema.optionalKey(Schema.String),\n\t\t}),\n\t),\n}\nconst network = {\n\t...transportFields,\n\t...common,\n\tauth,\n\turl: Schema.String,\n\tca: Schema.optionalKey(Schema.String),\n\tservername: Schema.optionalKey(Schema.String),\n}\nexport const Connect = Schema.Union([\n\tSchema.Struct(network),\n\tSchema.Struct({ ...transportFields, ...common, auth, unix: Schema.String }),\n\tSchema.Struct({\n\t\t...transportFields,\n\t\t...common,\n\t\tcommand: Schema.NonEmptyArray(Schema.String),\n\t\tauth: Schema.optionalKey(\n\t\t\tSchema.Never.annotate({\n\t\t\t\tmessage: \"Direct and stdio transports do not accept auth\",\n\t\t\t}),\n\t\t),\n\t\tcwd: Schema.optionalKey(Schema.String),\n\t\tenv: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),\n\t}),\n\tSchema.Struct({\n\t\t...transportFields,\n\t\tauth: Schema.optionalKey(\n\t\t\tSchema.Never.annotate({\n\t\t\t\tmessage: \"Direct and stdio transports do not accept auth\",\n\t\t\t}),\n\t\t),\n\t\tlocal: Schema.Struct({\n\t\t\tcommand: Schema.optionalKey(Schema.NonEmptyArray(Schema.String)),\n\t\t}),\n\t}),\n\tSchema.Struct({\n\t\t...transportFields,\n\t\tauth: Schema.optionalKey(\n\t\t\tSchema.Never.annotate({\n\t\t\t\tmessage: \"Direct and stdio transports do not accept auth\",\n\t\t\t}),\n\t\t),\n\t\tworker: Schema.Struct({\n\t\t\texecArgv: Schema.optionalKey(Schema.Array(Schema.String)),\n\t\t}),\n\t}),\n\tSchema.Struct({ ...transportFields, ...common, auth, transport: Reference }),\n])\nexport type Connect = typeof Connect.Type\nexport const Listen = Schema.Union([\n\tSchema.Struct({\n\t\t...transportFields,\n\t\tauth,\n\t\turl: Schema.String,\n\t\tcert: Schema.optionalKey(Schema.String),\n\t\tkey: Schema.optionalKey(Schema.String),\n\t}),\n\tSchema.Struct({ ...transportFields, auth, unix: Schema.String }),\n\tSchema.Struct({\n\t\t...transportFields,\n\t\tstdio: Schema.Literal(true),\n\t\tauth: Schema.optionalKey(\n\t\t\tSchema.Never.annotate({\n\t\t\t\tmessage: \"Direct and stdio transports do not accept auth\",\n\t\t\t}),\n\t\t),\n\t\tidentity: Schema.optionalKey(Schema.String),\n\t}),\n\tSchema.Struct({ ...transportFields, auth, transport: Reference }),\n])\nexport type Listen = typeof Listen.Type\nconst capability = (\n\tside: \"host\" | \"runner\",\n\tname: string,\n\tconfig: unknown,\n): Reference => ({ name: `@graftland/plugin-remote/${side}/${name}`, config })\nexport const authentication = (\n\tside: \"host\" | \"runner\",\n\tinput: typeof Authentication.Type | undefined,\n): Reference => {\n\tif (input === undefined) return capability(side, \"auth/none\", {})\n\tif (input.name !== undefined) return input\n\tif (input.mtls !== undefined) return capability(side, \"auth/mtls\", input.mtls)\n\tif (input.bearer !== undefined)\n\t\treturn capability(side, \"auth/bearer\", input.bearer)\n\tif (input.jwt !== undefined) return capability(side, \"auth/jwt\", input.jwt)\n\treturn capability(side, \"auth/none\", input.none)\n}\nexport const hostTransport = (\n\tinput: Exclude<\n\t\tConnect,\n\t\t{ readonly local: object } | { readonly worker: object }\n\t>,\n): Reference => {\n\tif (input.transport !== undefined) return input.transport\n\tif (input.url !== undefined)\n\t\treturn capability(\"host\", \"websocket\", {\n\t\t\turl: input.url,\n\t\t\t...(input.ca === undefined ? {} : { ca: input.ca }),\n\t\t\t...(input.servername === undefined\n\t\t\t\t? {}\n\t\t\t\t: { servername: input.servername }),\n\t\t})\n\tif (input.unix !== undefined)\n\t\treturn capability(\"host\", \"unix\", { path: input.unix })\n\treturn capability(\"host\", \"command\", {\n\t\targv: input.command,\n\t\t...(\"cwd\" in input && input.cwd !== undefined ? { cwd: input.cwd } : {}),\n\t\t...(\"env\" in input && input.env !== undefined ? { env: input.env } : {}),\n\t})\n}\nexport const runnerTransport = (input: Listen): Reference => {\n\tif (input.transport !== undefined) return input.transport\n\tif (input.url !== undefined)\n\t\treturn capability(\"runner\", \"websocket\", {\n\t\t\turl: input.url,\n\t\t\t...(input.cert === undefined ? {} : { cert: input.cert }),\n\t\t\t...(input.key === undefined ? {} : { key: input.key }),\n\t\t})\n\tif (input.unix !== undefined)\n\t\treturn capability(\"runner\", \"unix\", { path: input.unix })\n\treturn capability(\"runner\", \"stdio\", {})\n}\nexport const Host = Schema.Struct({\n\tcontract: Schema.String,\n\tconnect: Connect,\n\tconfig: Schema.Json.pipe(Schema.withDecodingDefaultKey(Effect.succeed({}))),\n})\nexport const Runner = Schema.Struct({\n\troot: Schema.String,\n\tstate: Schema.String,\n\tlease: Schema.optionalKey(PositiveDuration),\n\tgrace: Schema.optionalKey(PositiveDuration),\n\tlisten: Schema.Array(Listen),\n})\n\nexport const runnerAuthentication = (input: Listen): Reference =>\n\tinput.stdio !== undefined\n\t\t? capability(\"runner\", \"auth/none\", {\n\t\t\t\tidentity: input.identity ?? \"anonymous\",\n\t\t\t})\n\t\t: authentication(\"runner\", input.auth)\n"],"mappings":";;;AAGA,MAAa,YAAY,OAAO,OAAO;CACtC,MAAM,OAAO;CACb,QAAQ,OAAO,YAAY,OAAO,OAAO;AAC1C,CAAC;AAED,MAAM,SAAS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IAAY,CAAC,IAAI,EAAE,MAAM,MAAM,KAAK;EACvD,GAAI,MAAM,QAAQ,KAAA,IAAY,CAAC,IAAI,EAAE,KAAK,MAAM,IAAI;CACrD,CAAC;CACF,IAAI,MAAM,SAAS,KAAA,GAClB,OAAO,WAAW,UAAU,QAAQ,EAAE,MAAM,MAAM,KAAK,CAAC;CACzD,OAAO,WAAW,UAAU,SAAS,CAAC,CAAC;AACxC;AACA,MAAa,OAAO,OAAO,OAAO;CACjC,UAAU,OAAO;CACjB,SAAS;CACT,QAAQ,OAAO,KAAK,KAAK,OAAO,uBAAuB,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;AAC3E,CAAC;AACD,MAAa,SAAS,OAAO,OAAO;CACnC,MAAM,OAAO;CACb,OAAO,OAAO;CACd,OAAO,OAAO,YAAY,gBAAgB;CAC1C,OAAO,OAAO,YAAY,gBAAgB;CAC1C,QAAQ,OAAO,MAAM,MAAM;AAC5B,CAAC;AAED,MAAa,wBAAwB,UACpC,MAAM,UAAU,KAAA,IACb,WAAW,UAAU,aAAa,EAClC,UAAU,MAAM,YAAY,YAC7B,CAAC,IACA,eAAe,UAAU,MAAM,IAAI"}
1
+ {"version":3,"file":"entryConfig.js","names":[],"sources":["../../src/internal/entryConfig.ts"],"sourcesContent":["import {\n\tReference,\n\tRunnerAuthentication,\n\ttype Authentication,\n\ttype Connect,\n\ttype Listen,\n} from \"../Config\"\n\nexport * from \"../Config\"\nconst capability = (\n\tside: \"host\" | \"runner\",\n\tname: string,\n\tconfig: unknown,\n): Reference => ({ name: `@graftland/plugin-remote/${side}/${name}`, config })\nexport const authentication = (\n\tside: \"host\" | \"runner\",\n\tinput:\n\t\ttypeof Authentication.Type | typeof RunnerAuthentication.Type | undefined,\n): Reference => {\n\tif (input === undefined) return capability(side, \"auth/none\", {})\n\tif (input.name !== undefined) return input\n\tif (input.mtls !== undefined) return capability(side, \"auth/mtls\", input.mtls)\n\tif (input.bearer !== undefined)\n\t\treturn capability(side, \"auth/bearer\", input.bearer)\n\tif (input.jwt !== undefined) return capability(side, \"auth/jwt\", input.jwt)\n\treturn capability(side, \"auth/none\", input.none)\n}\nexport const hostTransport = (\n\tinput: Exclude<\n\t\tConnect,\n\t\t{ readonly local: object } | { readonly worker: object }\n\t>,\n): Reference => {\n\tif (input.transport !== undefined) return input.transport\n\tif (input.url !== undefined)\n\t\treturn capability(\"host\", \"websocket\", {\n\t\t\turl: input.url,\n\t\t\t...(input.ca === undefined ? {} : { ca: input.ca }),\n\t\t\t...(input.servername === undefined\n\t\t\t\t? {}\n\t\t\t\t: { servername: input.servername }),\n\t\t})\n\tif (input.unix !== undefined)\n\t\treturn capability(\"host\", \"unix\", { path: input.unix })\n\treturn capability(\"host\", \"command\", {\n\t\targv: input.command,\n\t\t...(\"cwd\" in input && input.cwd !== undefined ? { cwd: input.cwd } : {}),\n\t\t...(\"env\" in input && input.env !== undefined ? { env: input.env } : {}),\n\t})\n}\nexport const runnerTransport = (input: Listen): Reference => {\n\tif (input.transport !== undefined) return input.transport\n\tif (input.url !== undefined)\n\t\treturn capability(\"runner\", \"websocket\", {\n\t\t\turl: input.url,\n\t\t\t...(input.cert === undefined ? {} : { cert: input.cert }),\n\t\t\t...(input.key === undefined ? {} : { key: input.key }),\n\t\t})\n\tif (input.unix !== undefined)\n\t\treturn capability(\"runner\", \"unix\", { path: input.unix })\n\treturn capability(\"runner\", \"stdio\", {})\n}\nexport const runnerAuthentication = (input: Listen): Reference =>\n\tinput.stdio !== undefined\n\t\t? capability(\"runner\", \"auth/none\", {\n\t\t\t\tidentity: input.identity ?? \"anonymous\",\n\t\t\t})\n\t\t: authentication(\"runner\", input.auth)\n"],"mappings":";;AASA,MAAM,cACL,MACA,MACA,YACgB;CAAE,MAAM,4BAA4B,KAAK,GAAG;CAAQ;AAAO;AAC5E,MAAa,kBACZ,MACA,UAEe;CACf,IAAI,UAAU,KAAA,GAAW,OAAO,WAAW,MAAM,aAAa,CAAC,CAAC;CAChE,IAAI,MAAM,S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AAC;CACF,IAAI,MAAM,SAAS,KAAA,GAClB,OAAO,WAAW,UAAU,QAAQ,EAAE,MAAM,MAAM,KAAK,CAAC;CACzD,OAAO,WAAW,UAAU,SAAS,CAAC,CAAC;AACxC;AACA,MAAa,wBAAwB,UACpC,MAAM,UAAU,KAAA,IACb,WAAW,UAAU,aAAa,EAClC,UAAU,MAAM,YAAY,YAC7B,CAAC,IACA,eAAe,UAAU,MAAM,IAAI"}
@@ -1,5 +1,5 @@
1
- import "./runner/Connection.js";
2
- import "../Errors.js";
3
1
  import "../Contract.js";
4
- import { Plugin } from "@graftland/graft";
5
- import { Duration, Schema } from "effect";
2
+ import "../Errors.js";
3
+ import "./runner/Connection.js";
4
+ import { Duration, Schema } from "effect";
5
+ import { Plugin } from "@graftland/graft";
@@ -1,21 +1,21 @@
1
- import { Connector } from "../Transport.js";
2
- import { LocalTransport, WorkerTransport } from "./directTransport.js";
3
1
  import { Credentials } from "../Auth.js";
4
- import { acquire } from "./runner/Connection.js";
5
- import { endpoints } from "./services.js";
6
- import { dispose, initialize, load } from "./host.js";
2
+ import { UndeclaredFailure } from "../Contract.js";
7
3
  import { AuthenticationFailed, CredentialsError, LocalTerminationTimeout, MissingInstance, ProcessExited, RemoteEntryError, RemoteError, RemoteWithdrawn, TransportError } from "../Errors.js";
8
- import { ActivationFailed, AlreadyLoaded, ContractNotFound, ModuleImportFailed } from "./childErrors.js";
4
+ import { Connector } from "../Transport.js";
9
5
  import { errors } from "./assembly.js";
10
- import { ExecutionError, LeaseExpired, PackageError, RemoteTerminationUnconfirmed, RunnerClosing, SessionAccessDenied, SessionConflict, SessionStopped, StaleSession, StateDirectoryLocked, StateStorageError, TerminationUnconfirmed } from "./runner/model.js";
11
- import { ReleaseInterrupted } from "./release.js";
12
- import { UndeclaredFailure } from "../Contract.js";
13
- import { endpoint } from "./control.js";
6
+ import { ActivationFailed, AlreadyLoaded, ContractNotFound, ModuleImportFailed } from "./childErrors.js";
14
7
  import { prepare } from "./contract.js";
15
- import { Plugin } from "@graftland/graft";
8
+ import { endpoint } from "./control.js";
9
+ import { LocalTransport, WorkerTransport } from "./directTransport.js";
10
+ import { dispose, initialize, load } from "./host.js";
11
+ import { acquire } from "./runner/Connection.js";
12
+ import { ExecutionError, LeaseExpired, PackageError, RemoteTerminationUnconfirmed, RunnerClosing, SessionAccessDenied, SessionConflict, SessionStopped, StaleSession, StateDirectoryLocked, StateStorageError, TerminationUnconfirmed } from "./runner/model.js";
13
+ import { endpoints } from "./services.js";
16
14
  import { Array, Cause, Effect, Fiber, PlatformError, Schema, Scope } from "effect";
17
15
  import { SecureRandom } from "effect/crypto";
16
+ import { Plugin } from "@graftland/graft";
18
17
  import { RpcClientError } from "effect/rpc";
18
+ import { ReleaseInterrupted } from "@graftland/graft/Release";
19
19
  // src/internal/execution.ts
20
20
  const dependencies = (target) => target._tag === "Connector" ? [Connector, Credentials] : target._tag === "Local" ? [LocalTransport] : [WorkerTransport];
21
21
  /** One owned execution per activation, with explicitly mapped services. */
@@ -1 +1 @@
1
- {"version":3,"file":"execution.js","names":["Connection.acquire","Services.endpoints","Control.endpoint","Host.initialize","Host.dispose","Host.load","Errors.ProcessExited","Errors.TransportError","Errors.LocalTerminationTimeout","Errors.CredentialsError","Errors.AuthenticationFailed","Errors.RemoteEntryError","ChildErrors.AlreadyLoaded","ChildErrors.ContractNotFound","ChildErrors.ModuleImportFailed","ChildErrors.ActivationFailed","Model.PackageError","Model.SessionAccessDenied","Model.StaleSession","Model.LeaseExpired","Model.SessionStopped","Model.SessionConflict","Model.StateStorageError","Model.ExecutionError","Model.TerminationUnconfirmed","Model.RunnerClosing","Model.StateDirectoryLocked","Model.RemoteTerminationUnconfirmed","Assembly.errors","Contract.UndeclaredFailure"],"sources":["../../src/internal/execution.ts"],"sourcesContent":["import { Plugin } from \"@graftland/graft\"\nimport {\n\tArray,\n\tCause,\n\tEffect,\n\tFiber,\n\tPlatformError,\n\tSchema,\n\tScope,\n} from \"effect\"\nimport { SecureRandom } from \"effect/crypto\"\nimport { RpcClientError } from \"effect/rpc\"\nimport type {\n\tLocalTarget as Local,\n\tWorkerTarget as Worker,\n} from \"./runner/Connection\"\nimport { Connector } from \"../Transport\"\nimport { LocalTransport, WorkerTransport } from \"./directTransport\"\nimport { Credentials } from \"../Auth\"\nimport type { Duration } from \"effect\"\nimport * as Connection from \"./runner/Connection\"\nimport * as Services from \"./services\"\nimport * as Host from \"./host\"\nimport * as Errors from \"../Errors\"\nimport { RemoteWithdrawn, RemoteError, MissingInstance } from \"../Errors\"\nimport * as ChildErrors from \"./childErrors\"\nimport * as Assembly from \"./assembly\"\nimport * as Model from \"./runner/model\"\nimport { ReleaseInterrupted } from \"./release\"\nimport * as Contract from \"../Contract\"\nimport * as Control from \"./control\"\nimport { prepare } from \"./contract\"\n\nexport interface ExecutionOptions {\n\treadonly contractModule: string\n\treadonly shutdownTimeout?: Duration.Input | undefined\n}\n\nconst dependencies = (\n\ttarget: Local | Worker | Connection.ConfiguredRunner,\n): ReadonlyArray<Plugin.Dependency> =>\n\ttarget._tag === \"Connector\"\n\t\t? [Connector, Credentials]\n\t\t: target._tag === \"Local\"\n\t\t\t? [LocalTransport]\n\t\t\t: [WorkerTransport]\n\n/** One owned execution per activation, with explicitly mapped services. */\nexport const executionPlugin = <\n\tS extends Schema.Top & {\n\t\treadonly Encoded: Schema.Json\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n\tE extends Schema.Top & {\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n>(\n\tcontract: Contract.Contract<S, E>,\n\toptions: ExecutionOptions,\n\tconfigured: Local | Worker | Connection.ConfiguredRunner,\n\tannotations: Readonly<Record<string, unknown>> = {},\n): Plugin.Plugin<\n\tS[\"Encoded\"],\n\tS[\"Encoded\"],\n\t| E[\"Type\"]\n\t| Contract.UndeclaredFailure\n\t| RemoteError\n\t| RemoteWithdrawn\n\t| MissingInstance\n> =>\n\tPlugin.make({\n\t\tname: contract.name,\n\t\tinject: [\n\t\t\tSecureRandom.SecureRandom,\n\t\t\t...dependencies(configured),\n\t\t\t...Array.map(contract.inject, (service) => service.key),\n\t\t],\n\t\tconfig: Schema.toEncoded(contract.config),\n\t\tapply: Effect.fnUntraced(\n\t\t\tfunction* (input: Schema.Json) {\n\t\t\t\tconst prepared = prepare(contract)\n\t\t\t\tconst random = yield* SecureRandom.SecureRandom\n\t\t\t\tconst session = yield* random.uuidV4()\n\t\t\t\tconst active = yield* Connection.acquire(\n\t\t\t\t\tconfigured,\n\t\t\t\t\toptions.contractModule,\n\t\t\t\t\t{\n\t\t\t\t\t\tsession,\n\t\t\t\t\t\tserve: Services.endpoints(contract.inject),\n\t\t\t\t\t\tcall: {\n\t\t\t\t\t\t\t...Services.endpoints(contract.provides),\n\t\t\t\t\t\t\t[Control.endpoint]: prepared.control,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tHost.initialize(prepared),\n\t\t\t\t\tHost.dispose,\n\t\t\t\t\toptions.shutdownTimeout ?? \"5 seconds\",\n\t\t\t\t)\n\t\t\t\tyield* Host.load(active, input)\n\t\t\t\tfor (const service of contract.provides)\n\t\t\t\t\tyield* service\n\t\t\t\t\t\t.publish(active.connection.transport)\n\t\t\t\t\t\t.pipe(Scope.provide(active.connection.resources))\n\t\t\t\tyield* Plugin.fork(\n\t\t\t\t\tEffect.raceFirst(\n\t\t\t\t\t\tFiber.join(active.events),\n\t\t\t\t\t\tactive.remoteFailure.await,\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tEffect.mapError((error) => publicError(contract.error, error)),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\treturn () => Effect.succeed(false)\n\t\t\t},\n\t\t\tEffect.annotateLogs(annotations),\n\t\t\tEffect.mapError((error) => publicError(contract.error, error)),\n\t\t),\n\t})\n\n/** Failures raised by the host machinery; a permissive declared schema must not claim them. */\nconst internalErrors: ReadonlyArray<abstract new (...args: never) => unknown> =\n\t[\n\t\tErrors.ProcessExited,\n\t\tErrors.TransportError,\n\t\tErrors.LocalTerminationTimeout,\n\t\tErrors.CredentialsError,\n\t\tErrors.AuthenticationFailed,\n\t\tErrors.RemoteEntryError,\n\t\tChildErrors.AlreadyLoaded,\n\t\tChildErrors.ContractNotFound,\n\t\tChildErrors.ModuleImportFailed,\n\t\tChildErrors.ActivationFailed,\n\t\tModel.PackageError,\n\t\tModel.SessionAccessDenied,\n\t\tModel.StaleSession,\n\t\tModel.LeaseExpired,\n\t\tModel.SessionStopped,\n\t\tModel.SessionConflict,\n\t\tModel.StateStorageError,\n\t\tModel.ExecutionError,\n\t\tModel.TerminationUnconfirmed,\n\t\tModel.RunnerClosing,\n\t\tModel.StateDirectoryLocked,\n\t\tModel.RemoteTerminationUnconfirmed,\n\t\tReleaseInterrupted,\n\t\tRpcClientError.RpcClientError,\n\t\t...Assembly.errors,\n\t]\nconst isInternal = (error: unknown) =>\n\tSchema.isSchemaError(error) ||\n\tPlatformError.isPlatformError(error) ||\n\tArray.some(internalErrors, (Class) => error instanceof Class)\nconst isPublic = (\n\terror: unknown,\n): error is\n\t| Contract.UndeclaredFailure\n\t| RemoteWithdrawn\n\t| RemoteError\n\t| MissingInstance =>\n\tSchema.is(Contract.UndeclaredFailure)(error) ||\n\tSchema.is(RemoteWithdrawn)(error) ||\n\tSchema.is(RemoteError)(error) ||\n\tSchema.is(MissingInstance)(error)\n\nexport const publicError = <E extends Schema.Top>(\n\tdeclared: E,\n\terror: unknown,\n):\n\t| E[\"Type\"]\n\t| Contract.UndeclaredFailure\n\t| RemoteWithdrawn\n\t| RemoteError\n\t| MissingInstance =>\n\tisPublic(error)\n\t\t? error\n\t\t: // Classify host failures before the declared schema, which may be structural.\n\t\t\t!isInternal(error) && Schema.is(declared)(error)\n\t\t\t? error\n\t\t\t: RemoteError.make({ cause: Cause.fail(error) })\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsCA,MAAM,gBACL,WAEA,OAAO,SAAS,cACb,CAAC,WAAW,WAAW,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CACA,eAAe;CACf,GAAGC;AACJ;AACD,MAAM,cAAc,UACnB,OAAO,cAAc,KAAK,KAC1B,cAAc,gBAAgB,KAAK,KACnC,MAAM,KAAK,iBAAiB,UAAU,iBAAiB,KAAK;AAC7D,MAAM,YACL,UAMA,OAAO,GAAGC,iBAA0B,CAAC,CAAC,KAAK,KAC3C,OAAO,GAAG,eAAe,CAAC,CAAC,KAAK,KAChC,OAAO,GAAG,WAAW,CAAC,CAAC,KAAK,KAC5B,OAAO,GAAG,eAAe,CAAC,CAAC,KAAK;AAEjC,MAAa,eACZ,UACA,UAOA,SAAS,KAAK,IACX,QAED,CAAC,WAAW,KAAK,KAAK,OAAO,GAAG,QAAQ,CAAC,CAAC,KAAK,IAC7C,QACA,YAAY,KAAK,EAAE,OAAO,MAAM,KAAK,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"execution.js","names":["Connection.acquire","Services.endpoints","Control.endpoint","Host.initialize","Host.dispose","Host.load","Errors.ProcessExited","Errors.TransportError","Errors.LocalTerminationTimeout","Errors.CredentialsError","Errors.AuthenticationFailed","Errors.RemoteEntryError","ChildErrors.AlreadyLoaded","ChildErrors.ContractNotFound","ChildErrors.ModuleImportFailed","ChildErrors.ActivationFailed","Model.PackageError","Model.SessionAccessDenied","Model.StaleSession","Model.LeaseExpired","Model.SessionStopped","Model.SessionConflict","Model.StateStorageError","Model.ExecutionError","Model.TerminationUnconfirmed","Model.RunnerClosing","Model.StateDirectoryLocked","Model.RemoteTerminationUnconfirmed","Assembly.errors","Contract.UndeclaredFailure"],"sources":["../../src/internal/execution.ts"],"sourcesContent":["import {\n\tArray,\n\tCause,\n\tEffect,\n\tFiber,\n\tPlatformError,\n\tSchema,\n\tScope,\n\ttype Duration,\n} from \"effect\"\nimport { SecureRandom } from \"effect/crypto\"\nimport { RpcClientError } from \"effect/rpc\"\n\nimport { Plugin } from \"@graftland/graft\"\nimport { ReleaseInterrupted } from \"@graftland/graft/Release\"\n\nimport { Credentials } from \"../Auth\"\nimport * as Contract from \"../Contract\"\nimport * as Errors from \"../Errors\"\nimport { MissingInstance, RemoteError, RemoteWithdrawn } from \"../Errors\"\nimport { Connector } from \"../Transport\"\nimport * as Assembly from \"./assembly\"\nimport * as ChildErrors from \"./childErrors\"\nimport { prepare } from \"./contract\"\nimport * as Control from \"./control\"\nimport { LocalTransport, WorkerTransport } from \"./directTransport\"\nimport * as Host from \"./host\"\nimport type {\n\tLocalTarget as Local,\n\tWorkerTarget as Worker,\n} from \"./runner/Connection\"\nimport * as Connection from \"./runner/Connection\"\nimport * as Model from \"./runner/model\"\nimport * as Services from \"./services\"\n\nexport interface ExecutionOptions {\n\treadonly contractModule: string\n\treadonly shutdownTimeout?: Duration.Input | undefined\n}\n\nconst dependencies = (\n\ttarget: Local | Worker | Connection.ConfiguredRunner,\n): ReadonlyArray<Plugin.Dependency> =>\n\ttarget._tag === \"Connector\"\n\t\t? [Connector, Credentials]\n\t\t: target._tag === \"Local\"\n\t\t\t? [LocalTransport]\n\t\t\t: [WorkerTransport]\n\n/** One owned execution per activation, with explicitly mapped services. */\nexport const executionPlugin = <\n\tS extends Schema.Top & {\n\t\treadonly Encoded: Schema.Json\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n\tE extends Schema.Top & {\n\t\treadonly DecodingServices: never\n\t\treadonly EncodingServices: never\n\t},\n>(\n\tcontract: Contract.Contract<S, E>,\n\toptions: ExecutionOptions,\n\tconfigured: Local | Worker | Connection.ConfiguredRunner,\n\tannotations: Readonly<Record<string, unknown>> = {},\n): Plugin.Plugin<\n\tS[\"Encoded\"],\n\tS[\"Encoded\"],\n\t| E[\"Type\"]\n\t| Contract.UndeclaredFailure\n\t| RemoteError\n\t| RemoteWithdrawn\n\t| MissingInstance\n> =>\n\tPlugin.make({\n\t\tname: contract.name,\n\t\tinject: [\n\t\t\tSecureRandom.SecureRandom,\n\t\t\t...dependencies(configured),\n\t\t\t...Array.map(contract.inject, (service) => service.key),\n\t\t],\n\t\tconfig: Schema.toEncoded(contract.config),\n\t\tapply: Effect.fnUntraced(\n\t\t\tfunction* (input: Schema.Json) {\n\t\t\t\tconst prepared = prepare(contract)\n\t\t\t\tconst random = yield* SecureRandom.SecureRandom\n\t\t\t\tconst session = yield* random.uuidV4()\n\t\t\t\tconst active = yield* Connection.acquire(\n\t\t\t\t\tconfigured,\n\t\t\t\t\toptions.contractModule,\n\t\t\t\t\t{\n\t\t\t\t\t\tsession,\n\t\t\t\t\t\tserve: Services.endpoints(contract.inject),\n\t\t\t\t\t\tcall: {\n\t\t\t\t\t\t\t...Services.endpoints(contract.provides),\n\t\t\t\t\t\t\t[Control.endpoint]: prepared.control,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tHost.initialize(prepared),\n\t\t\t\t\tHost.dispose,\n\t\t\t\t\toptions.shutdownTimeout ?? \"5 seconds\",\n\t\t\t\t)\n\t\t\t\tyield* Host.load(active, input)\n\t\t\t\tfor (const service of contract.provides)\n\t\t\t\t\tyield* service\n\t\t\t\t\t\t.publish(active.connection.transport)\n\t\t\t\t\t\t.pipe(Scope.provide(active.connection.resources))\n\t\t\t\tyield* Plugin.fork(\n\t\t\t\t\tEffect.raceFirst(\n\t\t\t\t\t\tFiber.join(active.events),\n\t\t\t\t\t\tactive.remoteFailure.await,\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tEffect.mapError((error) => publicError(contract.error, error)),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\treturn () => Effect.succeed(false)\n\t\t\t},\n\t\t\tEffect.annotateLogs(annotations),\n\t\t\tEffect.mapError((error) => publicError(contract.error, error)),\n\t\t),\n\t})\n\n/** Failures raised by the host machinery; a permissive declared schema must not claim them. */\nconst internalErrors: ReadonlyArray<abstract new (...args: never) => unknown> =\n\t[\n\t\tErrors.ProcessExited,\n\t\tErrors.TransportError,\n\t\tErrors.LocalTerminationTimeout,\n\t\tErrors.CredentialsError,\n\t\tErrors.AuthenticationFailed,\n\t\tErrors.RemoteEntryError,\n\t\tChildErrors.AlreadyLoaded,\n\t\tChildErrors.ContractNotFound,\n\t\tChildErrors.ModuleImportFailed,\n\t\tChildErrors.ActivationFailed,\n\t\tModel.PackageError,\n\t\tModel.SessionAccessDenied,\n\t\tModel.StaleSession,\n\t\tModel.LeaseExpired,\n\t\tModel.SessionStopped,\n\t\tModel.SessionConflict,\n\t\tModel.StateStorageError,\n\t\tModel.ExecutionError,\n\t\tModel.TerminationUnconfirmed,\n\t\tModel.RunnerClosing,\n\t\tModel.StateDirectoryLocked,\n\t\tModel.RemoteTerminationUnconfirmed,\n\t\tReleaseInterrupted,\n\t\tRpcClientError.RpcClientError,\n\t\t...Assembly.errors,\n\t]\nconst isInternal = (error: unknown) =>\n\tSchema.isSchemaError(error) ||\n\tPlatformError.isPlatformError(error) ||\n\tArray.some(internalErrors, (Class) => error instanceof Class)\nconst isPublic = (\n\terror: unknown,\n): error is\n\t| Contract.UndeclaredFailure\n\t| RemoteWithdrawn\n\t| RemoteError\n\t| MissingInstance =>\n\tSchema.is(Contract.UndeclaredFailure)(error) ||\n\tSchema.is(RemoteWithdrawn)(error) ||\n\tSchema.is(RemoteError)(error) ||\n\tSchema.is(MissingInstance)(error)\n\nexport const publicError = <E extends Schema.Top>(\n\tdeclared: E,\n\terror: unknown,\n):\n\t| E[\"Type\"]\n\t| Contract.UndeclaredFailure\n\t| RemoteWithdrawn\n\t| RemoteError\n\t| MissingInstance =>\n\tisPublic(error)\n\t\t? error\n\t\t: // Classify host failures before the declared schema, which may be structural.\n\t\t\t!isInternal(error) && Schema.is(declared)(error)\n\t\t\t? error\n\t\t\t: RemoteError.make({ cause: Cause.fail(error) })\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,MAAM,gBACL,WAEA,OAAO,SAAS,cACb,CAAC,WAAW,WAAW,IACvB,OAAO,SAAS,UACf,CAAC,cAAc,IACf,CAAC,eAAe;;AAGrB,MAAa,mBAWZ,UACA,SACA,YACA,cAAiD,CAAC,MAUlD,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KAAK,iBAAiB,UAAU,iBAAiB,KAAK;AAC7D,MAAM,YACL,UAMA,OAAO,GAAGC,iBAA0B,CAAC,CAAC,KAAK,KAC3C,OAAO,GAAG,eAAe,CAAC,CAAC,KAAK,KAChC,OAAO,GAAG,WAAW,CAAC,CAAC,KAAK,KAC5B,OAAO,GAAG,eAAe,CAAC,CAAC,KAAK;AAEjC,MAAa,eACZ,UACA,UAOA,SAAS,KAAK,IACX,QAED,CAAC,WAAW,KAAK,KAAK,OAAO,GAAG,QAAQ,CAAC,CAAC,KAAK,IAC7C,QACA,YAAY,KAAK,EAAE,OAAO,MAAM,KAAK,KAAK,EAAE,CAAC"}
@@ -1,5 +1,5 @@
1
- import { Plugin } from "@graftland/graft";
2
1
  import { Effect, Stream } from "effect";
2
+ import { Plugin } from "@graftland/graft";
3
3
  // src/internal/follow.ts
4
4
  /** Follow startup and later failures without changing the caller's error boundary. */
5
5
  const follow = Effect.fnUntraced(function* (fork, fail) {
@@ -1 +1 @@
1
- {"version":3,"file":"follow.js","names":[],"sources":["../../src/internal/follow.ts"],"sourcesContent":["import { Plugin, type Fork, type Graft } from \"@graftland/graft\"\nimport { Effect, Stream, type Cause, type Schema } from \"effect\"\n\n/** Follow startup and later failures without changing the caller's error boundary. */\nexport const follow = Effect.fnUntraced(function* <I, E, F>(\n\tfork: Fork.Fork<I, E>,\n\tfail: (cause: Cause.Cause<E | Schema.SchemaError>) => Effect.Effect<never, F>,\n): Effect.fn.Return<void, F, Graft.Graft | Plugin.Tasks<F>> {\n\tyield* fork.await.pipe(Effect.catchCause(fail))\n\tyield* Plugin.fork(\n\t\tfork.state.pipe(\n\t\t\tStream.runForEach((state) =>\n\t\t\t\tstate._tag === \"Failed\" ? fail(state.cause) : Effect.void,\n\t\t\t),\n\t\t),\n\t)\n})\n"],"mappings":";;;;AAIA,MAAa,SAAS,OAAO,WAAW,WACvC,MACA,MAC2D;CAC3D,OAAO,KAAK,MAAM,KAAK,OAAO,WAAW,IAAI,CAAC;CAC9C,OAAO,OAAO,KACb,KAAK,MAAM,KACV,OAAO,YAAY,UAClB,MAAM,SAAS,WAAW,KAAK,MAAM,KAAK,IAAI,OAAO,IACtD,CACD,CACD;AACD,CAAC"}
1
+ {"version":3,"file":"follow.js","names":[],"sources":["../../src/internal/follow.ts"],"sourcesContent":["import { Effect, Stream, type Cause, type Schema } from \"effect\"\n\nimport { Plugin, type Fork, type Graft } from \"@graftland/graft\"\n\n/** Follow startup and later failures without changing the caller's error boundary. */\nexport const follow = Effect.fnUntraced(function* <I, E, F>(\n\tfork: Fork.Fork<I, E>,\n\tfail: (cause: Cause.Cause<E | Schema.SchemaError>) => Effect.Effect<never, F>,\n): Effect.fn.Return<void, F, Graft.Graft | Plugin.Tasks<F>> {\n\tyield* fork.await.pipe(Effect.catchCause(fail))\n\tyield* Plugin.fork(\n\t\tfork.state.pipe(\n\t\t\tStream.runForEach((state) =>\n\t\t\t\tstate._tag === \"Failed\" ? fail(state.cause) : Effect.void,\n\t\t\t),\n\t\t),\n\t)\n})\n"],"mappings":";;;;AAKA,MAAa,SAAS,OAAO,WAAW,WACvC,MACA,MAC2D;CAC3D,OAAO,KAAK,MAAM,KAAK,OAAO,WAAW,IAAI,CAAC;CAC9C,OAAO,OAAO,KACb,KAAK,MAAM,KACV,OAAO,YAAY,UAClB,MAAM,SAAS,WAAW,KAAK,MAAM,KAAK,IAAI,OAAO,IACtD,CACD,CACD;AACD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"forkTree.js","names":[],"sources":["../../src/internal/forkTree.ts"],"sourcesContent":["import type { Fork } from \"@graftland/graft\"\nimport { Array, Option } from \"effect\"\n\nexport const findSubtree = (\n\ttrees: ReadonlyArray<Fork.ForkTree>,\n\tid: number,\n): Option.Option<Fork.ForkTree> =>\n\tArray.findFirst(trees, (tree) =>\n\t\ttree.id === id ? Option.some(tree) : findSubtree(tree.children, id),\n\t)\n\nexport const isSubtreeActive = (tree: Fork.ForkTree): boolean =>\n\ttree.state._tag === \"Active\" && Array.every(tree.children, isSubtreeActive)\n"],"mappings":";;AAGA,MAAa,eACZ,OACA,OAEA,MAAM,UAAU,QAAQ,SACvB,KAAK,OAAO,KAAK,OAAO,KAAK,IAAI,IAAI,YAAY,KAAK,UAAU,EAAE,CACnE;AAED,MAAa,mBAAmB,SAC/B,KAAK,MAAM,SAAS,YAAY,MAAM,MAAM,KAAK,UAAU,eAAe"}
1
+ {"version":3,"file":"forkTree.js","names":[],"sources":["../../src/internal/forkTree.ts"],"sourcesContent":["import { Array, Option } from \"effect\"\n\nimport type { Fork } from \"@graftland/graft\"\n\nexport const findSubtree = (\n\ttrees: ReadonlyArray<Fork.ForkTree>,\n\tid: number,\n): Option.Option<Fork.ForkTree> =>\n\tArray.findFirst(trees, (tree) =>\n\t\ttree.id === id ? Option.some(tree) : findSubtree(tree.children, id),\n\t)\n\nexport const isSubtreeActive = (tree: Fork.ForkTree): boolean =>\n\ttree.state._tag === \"Active\" && Array.every(tree.children, isSubtreeActive)\n"],"mappings":";;AAIA,MAAa,eACZ,OACA,OAEA,MAAM,UAAU,QAAQ,SACvB,KAAK,OAAO,KAAK,OAAO,KAAK,IAAI,IAAI,YAAY,KAAK,UAAU,EAAE,CACnE;AAED,MAAa,mBAAmB,SAC/B,KAAK,MAAM,SAAS,YAAY,MAAM,MAAM,KAAK,UAAU,eAAe"}