@dual-os/cli 0.0.0-stage → 0.11.0-next.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 (254) hide show
  1. package/LICENSE +4 -0
  2. package/README.md +15 -2
  3. package/dist/_virtual/_rolldown/runtime.js +13 -0
  4. package/dist/auth/credentials.d.ts +17 -0
  5. package/dist/auth/credentials.d.ts.map +1 -0
  6. package/dist/auth/credentials.js +57 -0
  7. package/dist/auth/credentials.js.map +1 -0
  8. package/dist/auth/destination.d.ts +22 -0
  9. package/dist/auth/destination.d.ts.map +1 -0
  10. package/dist/auth/destination.js +49 -0
  11. package/dist/auth/destination.js.map +1 -0
  12. package/dist/auth/http.d.ts +12 -0
  13. package/dist/auth/http.d.ts.map +1 -0
  14. package/dist/auth/http.js +34 -0
  15. package/dist/auth/http.js.map +1 -0
  16. package/dist/auth/login.d.ts +22 -0
  17. package/dist/auth/login.d.ts.map +1 -0
  18. package/dist/auth/login.js +98 -0
  19. package/dist/auth/login.js.map +1 -0
  20. package/dist/auth/protocol.d.ts +26 -0
  21. package/dist/auth/protocol.d.ts.map +1 -0
  22. package/dist/auth/protocol.js +31 -0
  23. package/dist/auth/protocol.js.map +1 -0
  24. package/dist/baseline.d.ts +18 -0
  25. package/dist/baseline.d.ts.map +1 -0
  26. package/dist/baseline.js +22 -0
  27. package/dist/baseline.js.map +1 -0
  28. package/dist/bin.d.ts +1 -0
  29. package/dist/bin.js +7 -0
  30. package/dist/bin.js.map +1 -0
  31. package/dist/cli.d.ts +19 -0
  32. package/dist/cli.d.ts.map +1 -0
  33. package/dist/cli.js +492 -0
  34. package/dist/cli.js.map +1 -0
  35. package/dist/create/choices.d.ts +58 -0
  36. package/dist/create/choices.d.ts.map +1 -0
  37. package/dist/create/choices.js +121 -0
  38. package/dist/create/choices.js.map +1 -0
  39. package/dist/create/deployment.d.ts +48 -0
  40. package/dist/create/deployment.d.ts.map +1 -0
  41. package/dist/create/deployment.js +66 -0
  42. package/dist/create/deployment.js.map +1 -0
  43. package/dist/create/scaffold.d.ts +57 -0
  44. package/dist/create/scaffold.d.ts.map +1 -0
  45. package/dist/create/scaffold.js +198 -0
  46. package/dist/create/scaffold.js.map +1 -0
  47. package/dist/create/source-reference.d.ts +39 -0
  48. package/dist/create/source-reference.d.ts.map +1 -0
  49. package/dist/create/source-reference.js +185 -0
  50. package/dist/create/source-reference.js.map +1 -0
  51. package/dist/create/template.d.ts +116 -0
  52. package/dist/create/template.d.ts.map +1 -0
  53. package/dist/create/template.js +211 -0
  54. package/dist/create/template.js.map +1 -0
  55. package/dist/diagnostics.d.ts +6 -0
  56. package/dist/diagnostics.d.ts.map +1 -0
  57. package/dist/diagnostics.js +18 -0
  58. package/dist/diagnostics.js.map +1 -0
  59. package/dist/help.d.ts +16 -0
  60. package/dist/help.d.ts.map +1 -0
  61. package/dist/help.js +73 -0
  62. package/dist/help.js.map +1 -0
  63. package/dist/openapi/bundle.d.ts +18 -0
  64. package/dist/openapi/bundle.d.ts.map +1 -0
  65. package/dist/openapi/bundle.js +201 -0
  66. package/dist/openapi/bundle.js.map +1 -0
  67. package/dist/openapi/discovery.d.ts +30 -0
  68. package/dist/openapi/discovery.d.ts.map +1 -0
  69. package/dist/openapi/discovery.js +325 -0
  70. package/dist/openapi/discovery.js.map +1 -0
  71. package/dist/openapi/emit.d.ts +52 -0
  72. package/dist/openapi/emit.d.ts.map +1 -0
  73. package/dist/openapi/emit.js +596 -0
  74. package/dist/openapi/emit.js.map +1 -0
  75. package/dist/openapi/graphql.d.ts +102 -0
  76. package/dist/openapi/graphql.d.ts.map +1 -0
  77. package/dist/openapi/graphql.js +294 -0
  78. package/dist/openapi/graphql.js.map +1 -0
  79. package/dist/openapi/identity.d.ts +88 -0
  80. package/dist/openapi/identity.d.ts.map +1 -0
  81. package/dist/openapi/identity.js +98 -0
  82. package/dist/openapi/identity.js.map +1 -0
  83. package/dist/openapi/mcp.d.ts +21 -0
  84. package/dist/openapi/mcp.d.ts.map +1 -0
  85. package/dist/openapi/mcp.js +133 -0
  86. package/dist/openapi/mcp.js.map +1 -0
  87. package/dist/openapi/operations.d.ts +165 -0
  88. package/dist/openapi/operations.d.ts.map +1 -0
  89. package/dist/openapi/operations.js +361 -0
  90. package/dist/openapi/operations.js.map +1 -0
  91. package/dist/openapi/overlay.d.ts +23 -0
  92. package/dist/openapi/overlay.d.ts.map +1 -0
  93. package/dist/openapi/overlay.js +115 -0
  94. package/dist/openapi/overlay.js.map +1 -0
  95. package/dist/openapi/plugin.d.ts +83 -0
  96. package/dist/openapi/plugin.d.ts.map +1 -0
  97. package/dist/openapi/plugin.js +468 -0
  98. package/dist/openapi/plugin.js.map +1 -0
  99. package/dist/openapi/polymorphism.d.ts +21 -0
  100. package/dist/openapi/polymorphism.d.ts.map +1 -0
  101. package/dist/openapi/polymorphism.js +96 -0
  102. package/dist/openapi/polymorphism.js.map +1 -0
  103. package/dist/openapi/postman.d.ts +21 -0
  104. package/dist/openapi/postman.d.ts.map +1 -0
  105. package/dist/openapi/postman.js +286 -0
  106. package/dist/openapi/postman.js.map +1 -0
  107. package/dist/openapi/schema.d.ts +178 -0
  108. package/dist/openapi/schema.d.ts.map +1 -0
  109. package/dist/openapi/schema.js +1234 -0
  110. package/dist/openapi/schema.js.map +1 -0
  111. package/dist/openapi/select.d.ts +22 -0
  112. package/dist/openapi/select.d.ts.map +1 -0
  113. package/dist/openapi/select.js +79 -0
  114. package/dist/openapi/select.js.map +1 -0
  115. package/dist/openapi/spec.d.ts +147 -0
  116. package/dist/openapi/spec.d.ts.map +1 -0
  117. package/dist/openapi/spec.js +263 -0
  118. package/dist/openapi/spec.js.map +1 -0
  119. package/dist/openapi/swagger.d.ts +166 -0
  120. package/dist/openapi/swagger.d.ts.map +1 -0
  121. package/dist/openapi/swagger.js +298 -0
  122. package/dist/openapi/swagger.js.map +1 -0
  123. package/dist/openapi/versions.d.ts +52 -0
  124. package/dist/openapi/versions.d.ts.map +1 -0
  125. package/dist/openapi/versions.js +120 -0
  126. package/dist/openapi/versions.js.map +1 -0
  127. package/dist/plugin/archive.d.ts +27 -0
  128. package/dist/plugin/archive.d.ts.map +1 -0
  129. package/dist/plugin/archive.js +170 -0
  130. package/dist/plugin/archive.js.map +1 -0
  131. package/dist/plugin/bundle.d.ts +27 -0
  132. package/dist/plugin/bundle.d.ts.map +1 -0
  133. package/dist/plugin/bundle.js +328 -0
  134. package/dist/plugin/bundle.js.map +1 -0
  135. package/dist/plugin/init.d.ts +18 -0
  136. package/dist/plugin/init.d.ts.map +1 -0
  137. package/dist/plugin/init.js +121 -0
  138. package/dist/plugin/init.js.map +1 -0
  139. package/dist/plugin/inspection.d.ts +24 -0
  140. package/dist/plugin/inspection.d.ts.map +1 -0
  141. package/dist/plugin/inspection.js +24 -0
  142. package/dist/plugin/inspection.js.map +1 -0
  143. package/dist/plugin/package.d.ts +26 -0
  144. package/dist/plugin/package.d.ts.map +1 -0
  145. package/dist/plugin/package.js +73 -0
  146. package/dist/plugin/package.js.map +1 -0
  147. package/dist/plugin/publication.d.ts +29 -0
  148. package/dist/plugin/publication.d.ts.map +1 -0
  149. package/dist/plugin/publication.js +65 -0
  150. package/dist/plugin/publication.js.map +1 -0
  151. package/dist/plugin/validation.d.ts +15 -0
  152. package/dist/plugin/validation.d.ts.map +1 -0
  153. package/dist/plugin/validation.js +119 -0
  154. package/dist/plugin/validation.js.map +1 -0
  155. package/dist/release/archives.d.ts +33 -0
  156. package/dist/release/archives.d.ts.map +1 -0
  157. package/dist/release/archives.js +81 -0
  158. package/dist/release/archives.js.map +1 -0
  159. package/dist/release/release-manifest.d.ts +182 -0
  160. package/dist/release/release-manifest.d.ts.map +1 -0
  161. package/dist/release/release-manifest.js +79 -0
  162. package/dist/release/release-manifest.js.map +1 -0
  163. package/dist/release/releases.d.ts +36 -0
  164. package/dist/release/releases.d.ts.map +1 -0
  165. package/dist/release/releases.js +122 -0
  166. package/dist/release/releases.js.map +1 -0
  167. package/dist/skills.d.ts +35 -0
  168. package/dist/skills.d.ts.map +1 -0
  169. package/dist/skills.js +257 -0
  170. package/dist/skills.js.map +1 -0
  171. package/package.json +73 -4
  172. package/skills/dual-fde/SKILL.md +38 -0
  173. package/skills/dual-fde/references/access.md +62 -0
  174. package/skills/dual-fde/references/author-plugins.md +54 -0
  175. package/skills/dual-fde/references/cli.md +97 -0
  176. package/skills/dual-fde/references/manage-plugins.md +78 -0
  177. package/skills/dual-fde/references/migrations-deployment.md +84 -0
  178. package/skills/dual-fde/references/openapi-plugins.md +47 -0
  179. package/skills/dual-fde/references/sdk-docs.md +56 -0
  180. package/skills/dual-fde/references/upgrades.md +115 -0
  181. package/skills/dual-fde/references/working-context.md +69 -0
  182. package/src/auth/credentials.ts +84 -0
  183. package/src/auth/destination.ts +83 -0
  184. package/src/auth/http.ts +39 -0
  185. package/src/auth/login.ts +177 -0
  186. package/src/auth/protocol.ts +37 -0
  187. package/src/baseline.ts +15 -0
  188. package/src/bin.ts +4 -0
  189. package/src/cli.ts +969 -0
  190. package/src/create/choices.ts +177 -0
  191. package/src/create/deployment.ts +96 -0
  192. package/src/create/scaffold.ts +334 -0
  193. package/src/create/source-reference.ts +212 -0
  194. package/src/create/template.ts +300 -0
  195. package/src/diagnostics.ts +8 -0
  196. package/src/help.ts +142 -0
  197. package/src/openapi/bundle.ts +290 -0
  198. package/src/openapi/discovery.ts +438 -0
  199. package/src/openapi/emit.ts +1031 -0
  200. package/src/openapi/graphql.ts +375 -0
  201. package/src/openapi/identity.ts +153 -0
  202. package/src/openapi/mcp.ts +165 -0
  203. package/src/openapi/operations.ts +781 -0
  204. package/src/openapi/overlay.ts +195 -0
  205. package/src/openapi/plugin.ts +856 -0
  206. package/src/openapi/polymorphism.ts +207 -0
  207. package/src/openapi/postman.ts +403 -0
  208. package/src/openapi/schema.ts +2138 -0
  209. package/src/openapi/select.ts +113 -0
  210. package/src/openapi/spec.ts +401 -0
  211. package/src/openapi/swagger.ts +422 -0
  212. package/src/openapi/versions.ts +174 -0
  213. package/src/plugin/archive.ts +244 -0
  214. package/src/plugin/bundle.ts +572 -0
  215. package/src/plugin/init.ts +178 -0
  216. package/src/plugin/inspection.ts +19 -0
  217. package/src/plugin/package.ts +140 -0
  218. package/src/plugin/publication.ts +128 -0
  219. package/src/plugin/validation.ts +213 -0
  220. package/src/release/archives.ts +133 -0
  221. package/src/release/release-manifest.ts +79 -0
  222. package/src/release/releases.ts +210 -0
  223. package/src/skills.ts +434 -0
  224. package/templates/compose/.env.compose.example.hbs +3 -0
  225. package/templates/compose/.env.host.example.hbs +4 -0
  226. package/templates/compose/Dockerfile.hbs +12 -0
  227. package/templates/compose/OPERATIONS.md.hbs +159 -0
  228. package/templates/compose/_dockerignore +14 -0
  229. package/templates/compose/compose.external.yaml +7 -0
  230. package/templates/compose/compose.host-linux.yaml +5 -0
  231. package/templates/compose/compose.host.yaml.hbs +15 -0
  232. package/templates/compose/compose.yaml.hbs +85 -0
  233. package/templates/compose/release.env.hbs +2 -0
  234. package/templates/default/.env.example.hbs +79 -0
  235. package/templates/default/README.md.hbs +150 -0
  236. package/templates/default/_gitignore +11 -0
  237. package/templates/default/packages/customer-plugin/src/Customer.ts.hbs +17 -0
  238. package/templates/default/packages/customer-plugin/tsconfig.json +15 -0
  239. package/templates/default/packages/execution-layer/src/App.ts.hbs +7 -0
  240. package/templates/default/packages/execution-layer/src/Host.ts.hbs +31 -0
  241. package/templates/default/packages/execution-layer/src/Telemetry.ts.hbs +23 -0
  242. package/templates/default/packages/execution-layer/src/api.ts.hbs +21 -0
  243. package/templates/default/packages/execution-layer/src/bootstrap.ts +22 -0
  244. package/templates/default/packages/execution-layer/src/migrate.ts +11 -0
  245. package/templates/default/packages/execution-layer/src/registry-check.ts +29 -0
  246. package/templates/default/packages/execution-layer/src/registry-sync.ts +14 -0
  247. package/templates/default/packages/execution-layer/src/worker.ts.hbs +16 -0
  248. package/templates/default/packages/execution-layer/test/app.host-test.ts.hbs +58 -0
  249. package/templates/default/packages/execution-layer/test/app.test.ts.hbs +16 -0
  250. package/templates/default/tsconfig.json +5 -0
  251. package/templates/default/vitest.config.ts +5 -0
  252. package/templates/default/vitest.host.config.ts +6 -0
  253. package/templates/opensandbox/OPEN-SANDBOX.md +25 -0
  254. package/templates/opensandbox/docker/agent-sandbox.Dockerfile +41 -0
package/LICENSE ADDED
@@ -0,0 +1,4 @@
1
+ All rights reserved.
2
+
3
+ This package is proprietary and is not licensed for public use or redistribution.
4
+ Use and distribution require permission from the rights holder under a separate agreement.
package/README.md CHANGED
@@ -1,3 +1,16 @@
1
- # Temporary Holding Version
1
+ # @dual-os/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Create and maintain customer-owned Dual hosts.
4
+
5
+ ```sh
6
+ dual --help
7
+ dual create --help
8
+ ```
9
+
10
+ - **Access.** [FDE setup](../../FDE-SETUP.md); use an approved exact CLI version, not a mutable tag as release evidence.
11
+ - **Creation and replay.** [CLI guide](skills/dual-fde/references/cli.md).
12
+ - **Plugins.** [Existing plugins](skills/dual-fde/references/manage-plugins.md), [new plugins](skills/dual-fde/references/author-plugins.md), [generated API plugins](skills/dual-fde/references/openapi-plugins.md).
13
+ - **Upgrades.** [Upgrade guide](skills/dual-fde/references/upgrades.md); [migration and deployment](skills/dual-fde/references/migrations-deployment.md).
14
+ - **SDK documentation.** [Find version-matched guides](skills/dual-fde/references/sdk-docs.md).
15
+
16
+ Generation is not deployment. Credentials stay in external user configuration or the environment, never replay records or generated source.
@@ -0,0 +1,13 @@
1
+ import "node:module";
2
+ // \0rolldown/runtime.js
3
+ var __defProp = Object.defineProperty;
4
+ var __exportAll = (all, no_symbols) => {
5
+ let target = {};
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
11
+ return target;
12
+ };
13
+ export { __exportAll };
@@ -0,0 +1,17 @@
1
+ import { AuthError, Credential } from "./protocol.js";
2
+ import "./credentials.js";
3
+ import { Config, Context, Effect, FileSystem, Layer, Path, Redacted } from "effect";
4
+ import { Digest } from "effect/crypto";
5
+ declare namespace credentials_d_exports {
6
+ export { credentials_d_exports as CliCredentials, Interface, Service, layer };
7
+ }
8
+ export type Interface = {
9
+ readonly get: (deployment: string) => Effect.Effect<Redacted.Redacted<Credential>, AuthError>;
10
+ readonly set: (deployment: string, credential: Redacted.Redacted<Credential>) => Effect.Effect<void, AuthError>;
11
+ readonly remove: (deployment: string) => Effect.Effect<void, AuthError>;
12
+ };
13
+ declare const Service_base: Context.ServiceClass<Service, "@dual-os/cli/auth/credentials/Service", Interface>;
14
+ export declare class Service extends Service_base {}
15
+ export declare const layer: Layer.Layer<Service, Config.ConfigError, Digest.Digest | FileSystem.FileSystem | Path.Path>;
16
+ export { credentials_d_exports as CliCredentials };
17
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","names":["AuthProtocol.Credential","AuthProtocol.AuthError"],"sources":["../../src/auth/credentials.ts"],"mappings":";;;;;;;YASY;WACD,MACP,uBACG,OAAO,OAAO,SAAS,SAASA,aAA0BC;WACtD,MACP,oBACA,YAAY,SAAS,SAASD,gBAC3B,OAAO,aAAaC;WAChB,SAAS,uBAAuB,OAAO,aAAaA;;;qBAElD,gBAAgB;qBAGhB,OAAK,MAAA,MAAA,SAAA,OAAA,aAAA,OAAA,SAAA,WAAA,aAAA,KAAA"}
@@ -0,0 +1,57 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { AuthError, Credential, DeploymentUrl } from "./protocol.js";
3
+ import "./credentials.js";
4
+ import { Config, Context, Effect, FileSystem, Layer, Path, Redacted, Schema, pipe } from "effect";
5
+ import { homedir } from "node:os";
6
+ import { Digest } from "effect/crypto";
7
+ import { Base64Url } from "effect/encoding";
8
+ // src/auth/credentials.ts
9
+ var credentials_exports = /* @__PURE__ */ __exportAll({
10
+ CliCredentials: () => credentials_exports,
11
+ Service: () => Service,
12
+ layer: () => layer
13
+ });
14
+ var Service = class extends Context.Service()("@dual-os/cli/auth/credentials/Service") {};
15
+ const layer = Layer.effect(Service, Effect.gen(function* () {
16
+ const fs = yield* FileSystem.FileSystem;
17
+ const path = yield* Path.Path;
18
+ const crypto = yield* Digest.Digest;
19
+ const directory = path.join(yield* pipe(Config.String("HOME"), Config.withDefault(homedir())), ".config", "dual", "credentials");
20
+ const location = Effect.fnUntraced(function* (deployment) {
21
+ const origin = new URL(yield* Schema.decodeEffect(DeploymentUrl)(deployment)).origin;
22
+ return path.join(directory, `${Base64Url.encode(yield* crypto.digest(Digest.sha256, new TextEncoder().encode(origin)))}.json`);
23
+ });
24
+ const mapError = Effect.mapError((cause) => AuthError.make({
25
+ cause: Redacted.make(cause),
26
+ message: "Cannot access the saved CLI credential. Check file permissions or run dual login --web again."
27
+ }));
28
+ return Service.of({
29
+ get: Effect.fn("CliCredentials.get")(function* (deployment) {
30
+ return Redacted.make(yield* Schema.decodeEffect(Schema.fromJsonString(Credential))(yield* fs.readFileString(yield* location(deployment))));
31
+ }, mapError),
32
+ remove: Effect.fn("CliCredentials.remove")(function* (deployment) {
33
+ yield* fs.remove(yield* location(deployment));
34
+ }, mapError),
35
+ set: Effect.fn("CliCredentials.set")(function* (deployment, credential) {
36
+ const file = yield* location(deployment);
37
+ const value = yield* Schema.encodeEffect(Schema.fromJsonString(Credential, { space: 2 }))(Redacted.value(credential));
38
+ yield* fs.makeDirectory(directory, {
39
+ mode: 448,
40
+ recursive: true
41
+ });
42
+ yield* fs.chmod(directory, 448);
43
+ const temporary = path.join(yield* fs.makeTempDirectoryScoped({
44
+ directory,
45
+ prefix: ".login-"
46
+ }), "credential.json");
47
+ yield* fs.writeFileString(temporary, `${value}\n`, {
48
+ flag: "wx",
49
+ mode: 384
50
+ });
51
+ yield* fs.rename(temporary, file);
52
+ }, Effect.uninterruptible, Effect.scoped, mapError)
53
+ });
54
+ }));
55
+ export { credentials_exports as CliCredentials, Service, layer };
56
+
57
+ //# sourceMappingURL=credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.js","names":["AuthProtocol.DeploymentUrl","AuthProtocol.Credential"],"sources":["../../src/auth/credentials.ts"],"sourcesContent":["import { homedir } from \"node:os\";\n\nimport { Config, Context, Effect, FileSystem, Layer, Path, Redacted, Schema, pipe } from \"effect\";\n\nimport { Digest } from \"effect/crypto\";\nimport { Base64Url } from \"effect/encoding\";\n\nimport { AuthProtocol } from \"./protocol.ts\";\n\nexport type Interface = {\n readonly get: (\n deployment: string,\n ) => Effect.Effect<Redacted.Redacted<AuthProtocol.Credential>, AuthProtocol.AuthError>;\n readonly set: (\n deployment: string,\n credential: Redacted.Redacted<AuthProtocol.Credential>,\n ) => Effect.Effect<void, AuthProtocol.AuthError>;\n readonly remove: (deployment: string) => Effect.Effect<void, AuthProtocol.AuthError>;\n};\nexport class Service extends Context.Service<Service, Interface>()(\n \"@dual-os/cli/auth/credentials/Service\",\n) {}\nexport const layer = Layer.effect(\n Service,\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const crypto = yield* Digest.Digest;\n const directory = path.join(\n yield* pipe(Config.String(\"HOME\"), Config.withDefault(homedir())),\n \".config\",\n \"dual\",\n \"credentials\",\n );\n const location = Effect.fnUntraced(function* (deployment: string) {\n const origin = new URL(yield* Schema.decodeEffect(AuthProtocol.DeploymentUrl)(deployment))\n .origin;\n return path.join(\n directory,\n `${Base64Url.encode(yield* crypto.digest(Digest.sha256, new TextEncoder().encode(origin)))}.json`,\n );\n });\n const mapError = Effect.mapError(cause =>\n AuthProtocol.AuthError.make({\n cause: Redacted.make(cause),\n message:\n \"Cannot access the saved CLI credential. Check file permissions or run dual login --web again.\",\n }),\n );\n return Service.of({\n get: Effect.fn(\"CliCredentials.get\")(function* (deployment) {\n return Redacted.make(\n yield* Schema.decodeEffect(Schema.fromJsonString(AuthProtocol.Credential))(\n yield* fs.readFileString(yield* location(deployment)),\n ),\n );\n }, mapError),\n remove: Effect.fn(\"CliCredentials.remove\")(function* (deployment) {\n yield* fs.remove(yield* location(deployment));\n }, mapError),\n set: Effect.fn(\"CliCredentials.set\")(\n function* (deployment, credential) {\n const file = yield* location(deployment);\n const value = yield* Schema.encodeEffect(\n Schema.fromJsonString(AuthProtocol.Credential, { space: 2 }),\n )(Redacted.value(credential));\n yield* fs.makeDirectory(directory, { mode: 0o700, recursive: true });\n yield* fs.chmod(directory, 0o700);\n // A private sibling keeps interrupted writes from corrupting an existing login.\n const temporary = path.join(\n yield* fs.makeTempDirectoryScoped({ directory, prefix: \".login-\" }),\n \"credential.json\",\n );\n yield* fs.writeFileString(temporary, `${value}\\n`, { flag: \"wx\", mode: 0o600 });\n yield* fs.rename(temporary, file);\n },\n Effect.uninterruptible,\n Effect.scoped,\n mapError,\n ),\n });\n }),\n);\nexport * as CliCredentials from \"./credentials.ts\";\n"],"mappings":";;;;;;;;;;;;;AAmBA,IAAa,UAAb,cAA6B,QAAQ,QAA4B,CAAC,CAChE,uCACF,CAAC,CAAC,CAAC;AACH,MAAa,QAAQ,MAAM,OACzB,SACA,OAAO,IAAI,aAAa;CACtB,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,SAAS,OAAO,OAAO;CAC7B,MAAM,YAAY,KAAK,KACrB,OAAO,KAAK,OAAO,OAAO,MAAM,GAAG,OAAO,YAAY,QAAQ,CAAC,CAAC,GAChE,WACA,QACA,aACF;CACA,MAAM,WAAW,OAAO,WAAW,WAAW,YAAoB;EAChE,MAAM,SAAS,IAAI,IAAI,OAAO,OAAO,aAAaA,aAA0B,CAAC,CAAC,UAAU,CAAC,CAAC,CACvF;EACH,OAAO,KAAK,KACV,WACA,GAAG,UAAU,OAAO,OAAO,OAAO,OAAO,OAAO,QAAQ,IAAI,YAAY,CAAC,CAAC,OAAO,MAAM,CAAC,CAAC,EAAE,MAC7F;CACF,CAAC;CACD,MAAM,WAAW,OAAO,UAAS,UAAA,UACR,KAAK;EAC1B,OAAO,SAAS,KAAK,KAAK;EAC1B,SACE;CACJ,CAAC,CACH;CACA,OAAO,QAAQ,GAAG;EAChB,KAAK,OAAO,GAAG,oBAAoB,CAAC,CAAC,WAAW,YAAY;GAC1D,OAAO,SAAS,KACd,OAAO,OAAO,aAAa,OAAO,eAAeC,UAAuB,CAAC,CAAC,CACxE,OAAO,GAAG,eAAe,OAAO,SAAS,UAAU,CAAC,CACtD,CACF;EACF,GAAG,QAAQ;EACX,QAAQ,OAAO,GAAG,uBAAuB,CAAC,CAAC,WAAW,YAAY;GAChE,OAAO,GAAG,OAAO,OAAO,SAAS,UAAU,CAAC;EAC9C,GAAG,QAAQ;EACX,KAAK,OAAO,GAAG,oBAAoB,CAAC,CAClC,WAAW,YAAY,YAAY;GACjC,MAAM,OAAO,OAAO,SAAS,UAAU;GACvC,MAAM,QAAQ,OAAO,OAAO,aAC1B,OAAO,eAAeA,YAAyB,EAAE,OAAO,EAAE,CAAC,CAC7D,CAAC,CAAC,SAAS,MAAM,UAAU,CAAC;GAC5B,OAAO,GAAG,cAAc,WAAW;IAAE,MAAM;IAAO,WAAW;GAAK,CAAC;GACnE,OAAO,GAAG,MAAM,WAAW,GAAK;GAEhC,MAAM,YAAY,KAAK,KACrB,OAAO,GAAG,wBAAwB;IAAE;IAAW,QAAQ;GAAU,CAAC,GAClE,iBACF;GACA,OAAO,GAAG,gBAAgB,WAAW,GAAG,MAAM,KAAK;IAAE,MAAM;IAAM,MAAM;GAAM,CAAC;GAC9E,OAAO,GAAG,OAAO,WAAW,IAAI;EAClC,GACA,OAAO,iBACP,OAAO,QACP,QACF;CACF,CAAC;AACH,CAAC,CACH"}
@@ -0,0 +1,22 @@
1
+ import { AuthError } from "./protocol.js";
2
+ import "./destination.js";
3
+ import { Config, Context, Effect, FileSystem, Layer, Option, Path, Schema } from "effect";
4
+ declare namespace destination_d_exports {
5
+ export { destination_d_exports as CliDestination, Interface, Service, Target, layer };
6
+ }
7
+ export type Target = typeof Target.Type;
8
+ export declare const Target: Schema.Struct<{
9
+ readonly deployment: Schema.String;
10
+ readonly organizationId: Schema.NonEmptyString;
11
+ }>;
12
+ export type Interface = {
13
+ readonly defaultDeployment: Effect.Effect<Option.Option<string>, AuthError>;
14
+ readonly saveDefault: (deployment: string) => Effect.Effect<void, AuthError>;
15
+ readonly read: (directory: string) => Effect.Effect<Option.Option<Target>, AuthError>;
16
+ readonly save: (directory: string, target: Target) => Effect.Effect<void, AuthError>;
17
+ };
18
+ declare const Service_base: Context.ServiceClass<Service, "@dual-os/cli/auth/destination/Service", Interface>;
19
+ export declare class Service extends Service_base {}
20
+ export declare const layer: Layer.Layer<Service, Config.ConfigError, FileSystem.FileSystem | Path.Path>;
21
+ export { destination_d_exports as CliDestination };
22
+ //# sourceMappingURL=destination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destination.d.ts","names":["AuthProtocol.AuthError"],"sources":["../../src/auth/destination.ts"],"mappings":";;;;;;YAMY,gBAAgB,OAAO;qBACtB,QAAM,OAAA;;;;YAIP;WACD,mBAAmB,OAAO,OAAO,OAAO,gBAAgBA;WACxD,cAAc,uBAAuB,OAAO,aAAaA;WACzD,OACP,sBACG,OAAO,OAAO,OAAO,OAAO,SAASA;WACjC,OAAO,mBAAmB,QAAQ,WAAW,OAAO,aAAaA;;;qBAE/D,gBAAgB;qBAGhB,OAAK,MAAA,MAAA,SAAA,OAAA,aAAA,WAAA,aAAA,KAAA"}
@@ -0,0 +1,49 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { AuthError, DeploymentUrl } from "./protocol.js";
3
+ import "./destination.js";
4
+ import { Config, Context, Effect, FileSystem, Layer, Option, Path, Schema, pipe } from "effect";
5
+ import { homedir } from "node:os";
6
+ // src/auth/destination.ts
7
+ var destination_exports = /* @__PURE__ */ __exportAll({
8
+ CliDestination: () => destination_exports,
9
+ Service: () => Service,
10
+ Target: () => Target,
11
+ layer: () => layer
12
+ });
13
+ const Target = Schema.Struct({
14
+ deployment: DeploymentUrl,
15
+ organizationId: Schema.NonEmptyString
16
+ });
17
+ var Service = class extends Context.Service()("@dual-os/cli/auth/destination/Service") {};
18
+ const layer = Layer.effect(Service, Effect.gen(function* () {
19
+ const fs = yield* FileSystem.FileSystem;
20
+ const path = yield* Path.Path;
21
+ const file = path.join(yield* pipe(Config.String("HOME"), Config.withDefault(homedir())), ".config", "dual", "cli.json");
22
+ function projectFile(directory) {
23
+ return path.join(path.resolve(directory), ".dual", "publication.json");
24
+ }
25
+ const mapError = Effect.mapError(() => AuthError.make({ message: "Cannot read or save the CLI destination. Check its JSON and file permissions." }));
26
+ return Service.of({
27
+ defaultDeployment: pipe(Effect.gen(function* () {
28
+ if (!(yield* fs.exists(file))) return Option.none();
29
+ return Option.some((yield* Schema.decodeEffect(Schema.fromJsonString(Schema.Struct({ deployment: DeploymentUrl })))(yield* fs.readFileString(file))).deployment);
30
+ }), mapError),
31
+ read: Effect.fn("CliDestination.read")(function* (directory) {
32
+ const location = projectFile(directory);
33
+ if (!(yield* fs.exists(location))) return Option.none();
34
+ return Option.some(yield* Schema.decodeEffect(Schema.fromJsonString(Target))(yield* fs.readFileString(location)));
35
+ }, mapError),
36
+ save: Effect.fn("CliDestination.save")(function* (directory, target) {
37
+ const location = projectFile(directory);
38
+ yield* fs.makeDirectory(path.dirname(location), { recursive: true });
39
+ yield* fs.writeFileString(location, yield* Schema.encodeEffect(Schema.fromJsonString(Target))(target));
40
+ }, mapError),
41
+ saveDefault: Effect.fn("CliDestination.saveDefault")(function* (deployment) {
42
+ yield* fs.makeDirectory(path.dirname(file), { recursive: true });
43
+ yield* fs.writeFileString(file, yield* Schema.encodeEffect(Schema.fromJsonString(Schema.Struct({ deployment: DeploymentUrl })))({ deployment }));
44
+ }, mapError)
45
+ });
46
+ }));
47
+ export { destination_exports as CliDestination, Service, Target, layer };
48
+
49
+ //# sourceMappingURL=destination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destination.js","names":["AuthProtocol.DeploymentUrl"],"sources":["../../src/auth/destination.ts"],"sourcesContent":["import { homedir } from \"node:os\";\n\nimport { Config, Context, Effect, FileSystem, Layer, Option, Path, Schema, pipe } from \"effect\";\n\nimport { AuthProtocol } from \"./protocol.ts\";\n\nexport type Target = typeof Target.Type;\nexport const Target = Schema.Struct({\n deployment: AuthProtocol.DeploymentUrl,\n organizationId: Schema.NonEmptyString,\n});\nexport type Interface = {\n readonly defaultDeployment: Effect.Effect<Option.Option<string>, AuthProtocol.AuthError>;\n readonly saveDefault: (deployment: string) => Effect.Effect<void, AuthProtocol.AuthError>;\n readonly read: (\n directory: string,\n ) => Effect.Effect<Option.Option<Target>, AuthProtocol.AuthError>;\n readonly save: (directory: string, target: Target) => Effect.Effect<void, AuthProtocol.AuthError>;\n};\nexport class Service extends Context.Service<Service, Interface>()(\n \"@dual-os/cli/auth/destination/Service\",\n) {}\nexport const layer = Layer.effect(\n Service,\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const file = path.join(\n yield* pipe(Config.String(\"HOME\"), Config.withDefault(homedir())),\n \".config\",\n \"dual\",\n \"cli.json\",\n );\n function projectFile(directory: string) {\n return path.join(path.resolve(directory), \".dual\", \"publication.json\");\n }\n const mapError = Effect.mapError(() =>\n AuthProtocol.AuthError.make({\n message: \"Cannot read or save the CLI destination. Check its JSON and file permissions.\",\n }),\n );\n return Service.of({\n defaultDeployment: pipe(\n Effect.gen(function* () {\n if (!(yield* fs.exists(file))) return Option.none();\n return Option.some(\n (yield* Schema.decodeEffect(\n Schema.fromJsonString(Schema.Struct({ deployment: AuthProtocol.DeploymentUrl })),\n )(yield* fs.readFileString(file))).deployment,\n );\n }),\n mapError,\n ),\n read: Effect.fn(\"CliDestination.read\")(function* (directory) {\n const location = projectFile(directory);\n if (!(yield* fs.exists(location))) return Option.none();\n return Option.some(\n yield* Schema.decodeEffect(Schema.fromJsonString(Target))(\n yield* fs.readFileString(location),\n ),\n );\n }, mapError),\n save: Effect.fn(\"CliDestination.save\")(function* (directory, target) {\n const location = projectFile(directory);\n yield* fs.makeDirectory(path.dirname(location), { recursive: true });\n yield* fs.writeFileString(\n location,\n yield* Schema.encodeEffect(Schema.fromJsonString(Target))(target),\n );\n }, mapError),\n saveDefault: Effect.fn(\"CliDestination.saveDefault\")(function* (deployment) {\n yield* fs.makeDirectory(path.dirname(file), { recursive: true });\n yield* fs.writeFileString(\n file,\n yield* Schema.encodeEffect(\n Schema.fromJsonString(Schema.Struct({ deployment: AuthProtocol.DeploymentUrl })),\n )({ deployment }),\n );\n }, mapError),\n });\n }),\n);\nexport * as CliDestination from \"./destination.ts\";\n"],"mappings":";;;;;;;;;;;;AAOA,MAAa,SAAS,OAAO,OAAO;CAClC,YAAYA;CACZ,gBAAgB,OAAO;AACzB,CAAC;AASD,IAAa,UAAb,cAA6B,QAAQ,QAA4B,CAAC,CAChE,uCACF,CAAC,CAAC,CAAC;AACH,MAAa,QAAQ,MAAM,OACzB,SACA,OAAO,IAAI,aAAa;CACtB,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,OAAO,KAAK,KAChB,OAAO,KAAK,OAAO,OAAO,MAAM,GAAG,OAAO,YAAY,QAAQ,CAAC,CAAC,GAChE,WACA,QACA,UACF;CACA,SAAS,YAAY,WAAmB;EACtC,OAAO,KAAK,KAAK,KAAK,QAAQ,SAAS,GAAG,SAAS,kBAAkB;CACvE;CACA,MAAM,WAAW,OAAO,eAAA,UACC,KAAK,EAC1B,SAAS,gFACX,CAAC,CACH;CACA,OAAO,QAAQ,GAAG;EAChB,mBAAmB,KACjB,OAAO,IAAI,aAAa;GACtB,IAAI,EAAE,OAAO,GAAG,OAAO,IAAI,IAAI,OAAO,OAAO,KAAK;GAClD,OAAO,OAAO,MACX,OAAO,OAAO,aACb,OAAO,eAAe,OAAO,OAAO,EAAE,YAAYA,cAA2B,CAAC,CAAC,CACjF,CAAC,CAAC,OAAO,GAAG,eAAe,IAAI,CAAC,EAAA,CAAG,UACrC;EACF,CAAC,GACD,QACF;EACA,MAAM,OAAO,GAAG,qBAAqB,CAAC,CAAC,WAAW,WAAW;GAC3D,MAAM,WAAW,YAAY,SAAS;GACtC,IAAI,EAAE,OAAO,GAAG,OAAO,QAAQ,IAAI,OAAO,OAAO,KAAK;GACtD,OAAO,OAAO,KACZ,OAAO,OAAO,aAAa,OAAO,eAAe,MAAM,CAAC,CAAC,CACvD,OAAO,GAAG,eAAe,QAAQ,CACnC,CACF;EACF,GAAG,QAAQ;EACX,MAAM,OAAO,GAAG,qBAAqB,CAAC,CAAC,WAAW,WAAW,QAAQ;GACnE,MAAM,WAAW,YAAY,SAAS;GACtC,OAAO,GAAG,cAAc,KAAK,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;GACnE,OAAO,GAAG,gBACR,UACA,OAAO,OAAO,aAAa,OAAO,eAAe,MAAM,CAAC,CAAC,CAAC,MAAM,CAClE;EACF,GAAG,QAAQ;EACX,aAAa,OAAO,GAAG,4BAA4B,CAAC,CAAC,WAAW,YAAY;GAC1E,OAAO,GAAG,cAAc,KAAK,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;GAC/D,OAAO,GAAG,gBACR,MACA,OAAO,OAAO,aACZ,OAAO,eAAe,OAAO,OAAO,EAAE,YAAYA,cAA2B,CAAC,CAAC,CACjF,CAAC,CAAC,EAAE,WAAW,CAAC,CAClB;EACF,GAAG,QAAQ;CACb,CAAC;AACH,CAAC,CACH"}
@@ -0,0 +1,12 @@
1
+ import { AuthError } from "./protocol.js";
2
+ import "./http.js";
3
+ import { Effect } from "effect";
4
+ import { HttpClient, HttpClientError, HttpClientResponse } from "effect/http";
5
+ declare namespace http_d_exports {
6
+ export { http_d_exports as CliHttp, fromCause, requireStatus, withErrors };
7
+ }
8
+ export declare function fromCause(error: HttpClientError.HttpClientError): AuthError;
9
+ export declare function withErrors(client: HttpClient.HttpClient): HttpClient.HttpClient.With<AuthError, never>;
10
+ export declare const requireStatus: (response: HttpClientResponse.HttpClientResponse, accepted: number[]) => Effect.Effect<undefined, AuthError, never>;
11
+ export { http_d_exports as CliHttp };
12
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","names":["AuthProtocol.AuthError"],"sources":["../../src/auth/http.ts"],"mappings":";;;;;;;wBASgB,UAAU,OAAO,gBAAgB,kBAAeA;wBAOhD,WAAW,QAAQ,WAAW,aAAU,WAAA,WAAA,KAAAA;qBAI3C,gBAAa,UAAA,mBAAA,oBAAA,uBAAA,OAAA,kBAAAA"}
@@ -0,0 +1,34 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { AuthError } from "./protocol.js";
3
+ import "./http.js";
4
+ import { Array, Effect, Option, Redacted, String, pipe } from "effect";
5
+ import { HttpClient } from "effect/http";
6
+ import { Diagnostics } from "#diagnostics";
7
+ // src/auth/http.ts
8
+ var http_exports = /* @__PURE__ */ __exportAll({
9
+ CliHttp: () => http_exports,
10
+ fromCause: () => fromCause,
11
+ requireStatus: () => requireStatus,
12
+ withErrors: () => withErrors
13
+ });
14
+ function fromCause(error) {
15
+ return AuthError.make({
16
+ cause: Redacted.make(error),
17
+ message: Diagnostics.format({
18
+ cause: error.cause,
19
+ message: error.message
20
+ })
21
+ });
22
+ }
23
+ function withErrors(client) {
24
+ return HttpClient.transformResponse(client, Effect.mapError(fromCause));
25
+ }
26
+ const requireStatus = Effect.fn("CliHttp.requireStatus")(function* (response, accepted) {
27
+ if (Array.contains(accepted, response.status)) return;
28
+ const body = yield* pipe(response.text, Effect.orElseSucceed(() => ""));
29
+ const details = pipe(body, String.trim, Option.liftPredicate(String.isNonEmpty), Option.getOrElse(() => "No error details returned by Dual."));
30
+ return yield* AuthError.make({ message: `HTTP ${response.status}: ${details}` });
31
+ });
32
+ export { http_exports as CliHttp, fromCause, requireStatus, withErrors };
33
+
34
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","names":[],"sources":["../../src/auth/http.ts"],"sourcesContent":["import { Array, Effect, Option, Redacted, String, pipe } from \"effect\";\n\nimport { HttpClient } from \"effect/http\";\nimport type { HttpClientError, HttpClientResponse } from \"effect/http\";\n\nimport { Diagnostics } from \"#diagnostics\";\n\nimport { AuthProtocol } from \"./protocol.ts\";\n\nexport function fromCause(error: HttpClientError.HttpClientError) {\n return AuthProtocol.AuthError.make({\n cause: Redacted.make(error),\n message: Diagnostics.format({ cause: error.cause, message: error.message }),\n });\n}\n\nexport function withErrors(client: HttpClient.HttpClient) {\n return HttpClient.transformResponse(client, Effect.mapError(fromCause));\n}\n\nexport const requireStatus = Effect.fn(\"CliHttp.requireStatus\")(function* (\n response: HttpClientResponse.HttpClientResponse,\n accepted: number[],\n) {\n if (Array.contains(accepted, response.status)) return;\n const body = yield* pipe(\n response.text,\n Effect.orElseSucceed(() => \"\"),\n );\n const details = pipe(\n body,\n String.trim,\n Option.liftPredicate(String.isNonEmpty),\n Option.getOrElse(() => \"No error details returned by Dual.\"),\n );\n return yield* AuthProtocol.AuthError.make({ message: `HTTP ${response.status}: ${details}` });\n});\n\nexport * as CliHttp from \"./http.ts\";\n"],"mappings":";;;;;;;;;;;;;AASA,SAAgB,UAAU,OAAwC;CAChE,OAAA,UAA8B,KAAK;EACjC,OAAO,SAAS,KAAK,KAAK;EAC1B,SAAS,YAAY,OAAO;GAAE,OAAO,MAAM;GAAO,SAAS,MAAM;EAAQ,CAAC;CAC5E,CAAC;AACH;AAEA,SAAgB,WAAW,QAA+B;CACxD,OAAO,WAAW,kBAAkB,QAAQ,OAAO,SAAS,SAAS,CAAC;AACxE;AAEA,MAAa,gBAAgB,OAAO,GAAG,uBAAuB,CAAC,CAAC,WAC9D,UACA,UACA;CACA,IAAI,MAAM,SAAS,UAAU,SAAS,MAAM,GAAG;CAC/C,MAAM,OAAO,OAAO,KAClB,SAAS,MACT,OAAO,oBAAoB,EAAE,CAC/B;CACA,MAAM,UAAU,KACd,MACA,OAAO,MACP,OAAO,cAAc,OAAO,UAAU,GACtC,OAAO,gBAAgB,oCAAoC,CAC7D;CACA,OAAO,OAAA,UAA8B,KAAK,EAAE,SAAS,QAAQ,SAAS,OAAO,IAAI,UAAU,CAAC;AAC9F,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { AuthError } from "./protocol.js";
2
+ import { Service as Service$1 } from "./credentials.js";
3
+ import "./login.js";
4
+ import { Context, Effect, Layer } from "effect";
5
+ import { HttpClient } from "effect/http";
6
+ import { Digest, SecureRandom } from "effect/crypto";
7
+ import { ChildProcessSpawner } from "effect/process";
8
+ declare namespace login_d_exports {
9
+ export { login_d_exports as CliLogin, Interface, Service, layer };
10
+ }
11
+ export type Interface = {
12
+ readonly login: (deployment: string) => Effect.Effect<{
13
+ deployment: string;
14
+ expiresAt: string;
15
+ }, AuthError>;
16
+ readonly logout: (deployment: string) => Effect.Effect<void, AuthError>;
17
+ };
18
+ declare const Service_base: Context.ServiceClass<Service, "@dual-os/cli/auth/login/Service", Interface>;
19
+ export declare class Service extends Service_base {}
20
+ export declare const layer: Layer.Layer<Service, never, ChildProcessSpawner.ChildProcessSpawner | Digest.Digest | HttpClient.HttpClient | SecureRandom.SecureRandom | Service$1>;
21
+ export { login_d_exports as CliLogin };
22
+ //# sourceMappingURL=login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.d.ts","names":["AuthProtocol.AuthError","CliCredentials.Service"],"sources":["../../src/auth/login.ts"],"mappings":";;;;;;;;;;YAsBY;WACD,QACP,uBACG,OAAO;IAAS;IAAoB;KAAqBA;WACrD,SAAS,uBAAuB,OAAO,aAAaA;;;qBAElD,gBAAgB;qBAGhB,OAAK,MAAA,MAAA,gBAAA,oBAAA,sBAAA,OAAA,SAAA,WAAA,aAAA,aAAA,eAAAC"}
@@ -0,0 +1,98 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { AuthError, Credential, DeploymentUrl } from "./protocol.js";
3
+ import { Service as Service$1 } from "./credentials.js";
4
+ import { fromCause, requireStatus, withErrors } from "./http.js";
5
+ import "./login.js";
6
+ import { Context, Deferred, Effect, Layer, Match, Redacted, Schema, pipe } from "effect";
7
+ import { HttpClient, HttpClientRequest, HttpRouter, HttpServer, HttpServerRequest, HttpServerResponse } from "effect/http";
8
+ import { Digest, SecureRandom } from "effect/crypto";
9
+ import { Base64Url } from "effect/encoding";
10
+ import { createServer } from "node:http";
11
+ import * as NodeHttpServer from "@effect/platform-node/NodeHttpServer";
12
+ import { ChildProcess, ChildProcessSpawner } from "effect/process";
13
+ // src/auth/login.ts
14
+ var login_exports = /* @__PURE__ */ __exportAll({
15
+ CliLogin: () => login_exports,
16
+ Service: () => Service,
17
+ layer: () => layer
18
+ });
19
+ var Service = class extends Context.Service()("@dual-os/cli/auth/login/Service") {};
20
+ const layer = Layer.effect(Service, Effect.gen(function* () {
21
+ const random = yield* SecureRandom.SecureRandom;
22
+ const digest = yield* Digest.Digest;
23
+ const client = withErrors(yield* HttpClient.HttpClient);
24
+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
25
+ const credentials = yield* Service$1;
26
+ return Service.of({
27
+ login: Effect.fn("CliLogin.login")(function* (deployment) {
28
+ const url = new URL(yield* Schema.decodeEffect(DeploymentUrl)(deployment)).origin;
29
+ const verifier = Base64Url.encode(yield* random.randomBytes(32));
30
+ const state = Base64Url.encode(yield* random.randomBytes(32));
31
+ const codeChallenge = Base64Url.encode(yield* digest.digest(Digest.sha256, new TextEncoder().encode(verifier)));
32
+ const callback = yield* Deferred.make();
33
+ const server = yield* NodeHttpServer.make(() => createServer(), {
34
+ host: "127.0.0.1",
35
+ port: 0
36
+ });
37
+ const redirectUri = `${HttpServer.formatAddress(server.address)}/callback`;
38
+ yield* Layer.build(pipe(HttpRouter.add("GET", "/callback", Effect.gen(function* () {
39
+ const search = new URL((yield* HttpServerRequest.HttpServerRequest).url, redirectUri).searchParams;
40
+ if (search.get("state") !== state) return HttpServerResponse.text("Invalid login state.", { status: 400 });
41
+ if (search.get("error") === "access_denied") {
42
+ yield* Deferred.fail(callback, AuthError.make({ message: "CLI login was declined." }));
43
+ return HttpServerResponse.text("CLI access was declined. Return to your terminal.");
44
+ }
45
+ const code = search.get("code");
46
+ if (!Schema.is(Schema.NonEmptyString)(code)) return HttpServerResponse.text("Invalid authorization code.", { status: 400 });
47
+ yield* Deferred.succeed(callback, code);
48
+ return HttpServerResponse.text("CLI approval received. Return to your terminal to confirm login.", { headers: {
49
+ "cache-control": "no-store",
50
+ "referrer-policy": "no-referrer"
51
+ } });
52
+ })), (routes) => HttpRouter.serve(routes, {
53
+ disableListenLog: true,
54
+ disableLogger: true
55
+ }), Layer.provide(Layer.succeed(HttpServer.HttpServer, server)), Layer.provide(NodeHttpServer.layerHttpServices)));
56
+ const browser = new URL("/api/cli-auth/authorize", url);
57
+ browser.search = new URLSearchParams({
58
+ codeChallenge,
59
+ redirectUri,
60
+ state
61
+ }).toString();
62
+ if ((yield* spawner.exitCode(ChildProcess.make(pipe(Match.value(process.platform), Match.when("darwin", () => "/usr/bin/open"), Match.when("win32", () => "rundll32.exe"), Match.orElse(() => "xdg-open")), process.platform === "win32" ? ["url.dll,FileProtocolHandler", browser.href] : [browser.href], {
63
+ stderr: "ignore",
64
+ stdin: "ignore",
65
+ stdout: "ignore"
66
+ }))) !== 0) return yield* AuthError.make({ message: "Cannot open the browser for CLI login." });
67
+ const code = yield* Deferred.await(callback);
68
+ const response = yield* client.execute(yield* HttpClientRequest.bodyJson(HttpClientRequest.post(new URL("/api/cli-auth/token", url).href), {
69
+ code,
70
+ redirectUri,
71
+ verifier
72
+ }));
73
+ yield* requireStatus(response, [200]);
74
+ const credential = yield* Schema.decodeUnknownEffect(Credential)(yield* pipe(response.json, Effect.mapError(fromCause)));
75
+ yield* pipe(credentials.set(url, Redacted.make(credential)), Effect.tapError(() => client.execute(pipe(HttpClientRequest.delete(new URL("/api/cli-auth/session", url).href), HttpClientRequest.bearerToken(credential.token)))));
76
+ return {
77
+ deployment: url,
78
+ expiresAt: credential.expiresAt
79
+ };
80
+ }, Effect.timeout("5 minutes"), Effect.scoped, Effect.mapError((cause) => Schema.is(AuthError)(cause) ? cause : AuthError.make({
81
+ cause: Redacted.make(cause),
82
+ message: "CLI login failed or timed out. Run dual login --web again."
83
+ }))),
84
+ logout: Effect.fn("CliLogin.logout")(function* (deployment) {
85
+ const url = new URL(yield* Schema.decodeEffect(DeploymentUrl)(deployment)).origin;
86
+ const credential = Redacted.value(yield* credentials.get(url));
87
+ const response = yield* client.execute(pipe(HttpClientRequest.delete(new URL("/api/cli-auth/session", url).href), HttpClientRequest.bearerToken(credential.token)));
88
+ yield* requireStatus(response, [200]);
89
+ yield* credentials.remove(url);
90
+ }, Effect.scoped, Effect.mapError((cause) => Schema.is(AuthError)(cause) ? cause : AuthError.make({
91
+ cause: Redacted.make(cause),
92
+ message: "CLI logout failed. Retry to revoke and remove the credential."
93
+ })))
94
+ });
95
+ }));
96
+ export { login_exports as CliLogin, Service, layer };
97
+
98
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","names":["CliHttp.withErrors","CliCredentials.Service","AuthProtocol.DeploymentUrl","CliHttp.requireStatus","AuthProtocol.Credential","CliHttp.fromCause","AuthProtocol.AuthError"],"sources":["../../src/auth/login.ts"],"sourcesContent":["import { createServer } from \"node:http\";\n\nimport * as NodeHttpServer from \"@effect/platform-node/NodeHttpServer\";\n\nimport { Context, Deferred, Effect, Layer, Match, Redacted, Schema, pipe } from \"effect\";\n\nimport { Digest, SecureRandom } from \"effect/crypto\";\nimport { Base64Url } from \"effect/encoding\";\nimport {\n HttpClient,\n HttpClientRequest,\n HttpRouter,\n HttpServer,\n HttpServerRequest,\n HttpServerResponse,\n} from \"effect/http\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\n\nimport { CliCredentials } from \"./credentials.ts\";\nimport { CliHttp } from \"./http.ts\";\nimport { AuthProtocol } from \"./protocol.ts\";\n\nexport type Interface = {\n readonly login: (\n deployment: string,\n ) => Effect.Effect<{ deployment: string; expiresAt: string }, AuthProtocol.AuthError>;\n readonly logout: (deployment: string) => Effect.Effect<void, AuthProtocol.AuthError>;\n};\nexport class Service extends Context.Service<Service, Interface>()(\n \"@dual-os/cli/auth/login/Service\",\n) {}\nexport const layer = Layer.effect(\n Service,\n Effect.gen(function* () {\n const random = yield* SecureRandom.SecureRandom;\n const digest = yield* Digest.Digest;\n const client = CliHttp.withErrors(yield* HttpClient.HttpClient);\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const credentials = yield* CliCredentials.Service;\n return Service.of({\n login: Effect.fn(\"CliLogin.login\")(\n function* (deployment: string) {\n const url = new URL(yield* Schema.decodeEffect(AuthProtocol.DeploymentUrl)(deployment))\n .origin;\n const verifier = Base64Url.encode(yield* random.randomBytes(32));\n const state = Base64Url.encode(yield* random.randomBytes(32));\n const codeChallenge = Base64Url.encode(\n yield* digest.digest(Digest.sha256, new TextEncoder().encode(verifier)),\n );\n const callback = yield* Deferred.make<string, AuthProtocol.AuthError>();\n const server = yield* NodeHttpServer.make(() => createServer(), {\n host: \"127.0.0.1\",\n port: 0,\n });\n const redirectUri = `${HttpServer.formatAddress(server.address)}/callback`;\n yield* Layer.build(\n pipe(\n HttpRouter.add(\n \"GET\",\n \"/callback\",\n Effect.gen(function* () {\n const search = new URL(\n (yield* HttpServerRequest.HttpServerRequest).url,\n redirectUri,\n ).searchParams;\n if (search.get(\"state\") !== state) {\n return HttpServerResponse.text(\"Invalid login state.\", { status: 400 });\n }\n if (search.get(\"error\") === \"access_denied\") {\n yield* Deferred.fail(\n callback,\n AuthProtocol.AuthError.make({ message: \"CLI login was declined.\" }),\n );\n return HttpServerResponse.text(\n \"CLI access was declined. Return to your terminal.\",\n );\n }\n const code = search.get(\"code\");\n if (!Schema.is(Schema.NonEmptyString)(code)) {\n return HttpServerResponse.text(\"Invalid authorization code.\", { status: 400 });\n }\n yield* Deferred.succeed(callback, code);\n return HttpServerResponse.text(\n \"CLI approval received. Return to your terminal to confirm login.\",\n { headers: { \"cache-control\": \"no-store\", \"referrer-policy\": \"no-referrer\" } },\n );\n }),\n ),\n routes => HttpRouter.serve(routes, { disableListenLog: true, disableLogger: true }),\n Layer.provide(Layer.succeed(HttpServer.HttpServer, server)),\n Layer.provide(NodeHttpServer.layerHttpServices),\n ),\n );\n const browser = new URL(\"/api/cli-auth/authorize\", url);\n browser.search = new URLSearchParams({ codeChallenge, redirectUri, state }).toString();\n const opened = yield* spawner.exitCode(\n ChildProcess.make(\n pipe(\n Match.value(process.platform),\n Match.when(\"darwin\", () => \"/usr/bin/open\"),\n Match.when(\"win32\", () => \"rundll32.exe\"),\n Match.orElse(() => \"xdg-open\"),\n ),\n process.platform === \"win32\"\n ? [\"url.dll,FileProtocolHandler\", browser.href]\n : [browser.href],\n { stderr: \"ignore\", stdin: \"ignore\", stdout: \"ignore\" },\n ),\n );\n if (opened !== 0) {\n return yield* AuthProtocol.AuthError.make({\n message: \"Cannot open the browser for CLI login.\",\n });\n }\n const code = yield* Deferred.await(callback);\n const response = yield* client.execute(\n yield* HttpClientRequest.bodyJson(\n HttpClientRequest.post(new URL(\"/api/cli-auth/token\", url).href),\n { code, redirectUri, verifier },\n ),\n );\n yield* CliHttp.requireStatus(response, [200]);\n const credential = yield* Schema.decodeUnknownEffect(AuthProtocol.Credential)(\n yield* pipe(response.json, Effect.mapError(CliHttp.fromCause)),\n );\n yield* pipe(\n credentials.set(url, Redacted.make(credential)),\n Effect.tapError(() =>\n client.execute(\n pipe(\n HttpClientRequest.delete(new URL(\"/api/cli-auth/session\", url).href),\n HttpClientRequest.bearerToken(credential.token),\n ),\n ),\n ),\n );\n return { deployment: url, expiresAt: credential.expiresAt };\n },\n Effect.timeout(\"5 minutes\"),\n Effect.scoped,\n Effect.mapError(cause =>\n Schema.is(AuthProtocol.AuthError)(cause)\n ? cause\n : AuthProtocol.AuthError.make({\n cause: Redacted.make(cause),\n message: \"CLI login failed or timed out. Run dual login --web again.\",\n }),\n ),\n ),\n logout: Effect.fn(\"CliLogin.logout\")(\n function* (deployment: string) {\n const url = new URL(yield* Schema.decodeEffect(AuthProtocol.DeploymentUrl)(deployment))\n .origin;\n const credential = Redacted.value(yield* credentials.get(url));\n const response = yield* client.execute(\n pipe(\n HttpClientRequest.delete(new URL(\"/api/cli-auth/session\", url).href),\n HttpClientRequest.bearerToken(credential.token),\n ),\n );\n yield* CliHttp.requireStatus(response, [200]);\n yield* credentials.remove(url);\n },\n Effect.scoped,\n Effect.mapError(cause =>\n Schema.is(AuthProtocol.AuthError)(cause)\n ? cause\n : AuthProtocol.AuthError.make({\n cause: Redacted.make(cause),\n message: \"CLI logout failed. Retry to revoke and remove the credential.\",\n }),\n ),\n ),\n });\n }),\n);\nexport * as CliLogin from \"./login.ts\";\n"],"mappings":"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"}
@@ -0,0 +1,26 @@
1
+ import "./protocol.js";
2
+ import { Schema } from "effect";
3
+ declare namespace protocol_d_exports {
4
+ export { AuthError, protocol_d_exports as AuthProtocol, Credential, DeploymentUrl, Organizations };
5
+ }
6
+ export type DeploymentUrl = typeof DeploymentUrl.Type;
7
+ export declare const DeploymentUrl: Schema.String;
8
+ export type Credential = typeof Credential.Type;
9
+ export declare const Credential: Schema.Struct<{
10
+ readonly expiresAt: Schema.String;
11
+ readonly token: Schema.String;
12
+ }>;
13
+ export type Organizations = typeof Organizations.Type;
14
+ export declare const Organizations: Schema.Struct<{
15
+ readonly organizations: Schema.$Array<Schema.Struct<{
16
+ readonly id: Schema.NonEmptyString;
17
+ readonly name: Schema.String;
18
+ }>>;
19
+ }>;
20
+ declare const AuthError_base: Schema.Class<AuthError, Schema.TaggedStruct<"CliAuthError", {
21
+ readonly cause: Schema.optionalKey<Schema.Redacted<Schema.Defect>>;
22
+ readonly message: Schema.String;
23
+ }>, import("effect/Cause").YieldableError>;
24
+ export declare class AuthError extends AuthError_base {}
25
+ export { protocol_d_exports as AuthProtocol };
26
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","names":[],"sources":["../../src/auth/protocol.ts"],"mappings":";;;;;YAEY,uBAAuB,cAAc;qBACpC,eAAa,OAAA;YAiBd,oBAAoB,WAAW;qBAC9B,YAAU,OAAA;;;;YAMX,uBAAuB,cAAc;qBACpC,eAAa,OAAA;;;;;;;;;;qBAGb,kBAAkB"}
@@ -0,0 +1,31 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import "./protocol.js";
3
+ import { Schema, String } from "effect";
4
+ // src/auth/protocol.ts
5
+ var protocol_exports = /* @__PURE__ */ __exportAll({
6
+ AuthError: () => AuthError,
7
+ AuthProtocol: () => protocol_exports,
8
+ Credential: () => Credential,
9
+ DeploymentUrl: () => DeploymentUrl,
10
+ Organizations: () => Organizations
11
+ });
12
+ const DeploymentUrl = Schema.String.check(Schema.makeFilter((value) => {
13
+ if (!URL.canParse(value)) return false;
14
+ const url = new URL(value);
15
+ return !String.includes("'")(url.origin) && url.username === "" && url.password === "" && url.search === "" && url.hash === "" && (url.pathname === "/" || url.pathname === "") && (url.protocol === "https:" || url.protocol === "http:" && (url.hostname === "localhost" || url.hostname === "127.0.0.1"));
16
+ }));
17
+ const Credential = Schema.Struct({
18
+ expiresAt: Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u)),
19
+ token: Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_-]{32,256}$/u))
20
+ });
21
+ const Organizations = Schema.Struct({ organizations: Schema.Array(Schema.Struct({
22
+ id: Schema.NonEmptyString,
23
+ name: Schema.String
24
+ })) });
25
+ var AuthError = class extends Schema.TaggedError()("CliAuthError", {
26
+ cause: Schema.optionalKey(Schema.Redacted(Schema.Defect())),
27
+ message: Schema.String
28
+ }) {};
29
+ export { AuthError, protocol_exports as AuthProtocol, Credential, DeploymentUrl, Organizations };
30
+
31
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","names":[],"sources":["../../src/auth/protocol.ts"],"sourcesContent":["import { Schema, String } from \"effect\";\n\nexport type DeploymentUrl = typeof DeploymentUrl.Type;\nexport const DeploymentUrl = Schema.String.check(\n Schema.makeFilter(value => {\n if (!URL.canParse(value)) return false;\n const url = new URL(value);\n return (\n !String.includes(\"'\")(url.origin) &&\n url.username === \"\" &&\n url.password === \"\" &&\n url.search === \"\" &&\n url.hash === \"\" &&\n (url.pathname === \"/\" || url.pathname === \"\") &&\n (url.protocol === \"https:\" ||\n (url.protocol === \"http:\" &&\n (url.hostname === \"localhost\" || url.hostname === \"127.0.0.1\")))\n );\n }),\n);\nexport type Credential = typeof Credential.Type;\nexport const Credential = Schema.Struct({\n expiresAt: Schema.String.check(\n Schema.isPattern(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$/u),\n ),\n token: Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_-]{32,256}$/u)),\n});\nexport type Organizations = typeof Organizations.Type;\nexport const Organizations = Schema.Struct({\n organizations: Schema.Array(Schema.Struct({ id: Schema.NonEmptyString, name: Schema.String })),\n});\nexport class AuthError extends Schema.TaggedError<AuthError>()(\"CliAuthError\", {\n cause: Schema.optionalKey(Schema.Redacted(Schema.Defect())),\n message: Schema.String,\n}) {}\n\nexport * as AuthProtocol from \"./protocol.ts\";\n"],"mappings":";;;;;;;;;;;AAGA,MAAa,gBAAgB,OAAO,OAAO,MACzC,OAAO,YAAW,UAAS;CACzB,IAAI,CAAC,IAAI,SAAS,KAAK,GAAG,OAAO;CACjC,MAAM,MAAM,IAAI,IAAI,KAAK;CACzB,OACE,CAAC,OAAO,SAAS,GAAG,CAAC,CAAC,IAAI,MAAM,KAChC,IAAI,aAAa,MACjB,IAAI,aAAa,MACjB,IAAI,WAAW,MACf,IAAI,SAAS,OACZ,IAAI,aAAa,OAAO,IAAI,aAAa,QACzC,IAAI,aAAa,YACf,IAAI,aAAa,YACf,IAAI,aAAa,eAAe,IAAI,aAAa;AAE1D,CAAC,CACH;AAEA,MAAa,aAAa,OAAO,OAAO;CACtC,WAAW,OAAO,OAAO,MACvB,OAAO,UAAU,gDAAgD,CACnE;CACA,OAAO,OAAO,OAAO,MAAM,OAAO,UAAU,0BAA0B,CAAC;AACzE,CAAC;AAED,MAAa,gBAAgB,OAAO,OAAO,EACzC,eAAe,OAAO,MAAM,OAAO,OAAO;CAAE,IAAI,OAAO;CAAgB,MAAM,OAAO;AAAO,CAAC,CAAC,EAC/F,CAAC;AACD,IAAa,YAAb,cAA+B,OAAO,YAAuB,CAAC,CAAC,gBAAgB;CAC7E,OAAO,OAAO,YAAY,OAAO,SAAS,OAAO,OAAO,CAAC,CAAC;CAC1D,SAAS,OAAO;AAClB,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,18 @@
1
+ declare namespace baseline_d_exports {
2
+ export { baseline_d_exports as Baseline, versions };
3
+ }
4
+ /** Explicit legacy/offline inspection fallback only; never an approved online release. */
5
+ export declare const versions: {
6
+ readonly "@deslop/coding-standards": "0.1.1222";
7
+ readonly "@dual/core": "0.0.1";
8
+ readonly "@dual/dualspec": "0.0.0";
9
+ readonly "@dual-os/sdk": "0.0.0";
10
+ readonly "@effect/platform-node": "4.1.2";
11
+ readonly "@effect/vitest": "4.1.2";
12
+ readonly "bun-types": "1.4.2";
13
+ readonly effect: "4.1.2";
14
+ readonly typescript: "7.0.2";
15
+ readonly vitest: "5.0.3";
16
+ };
17
+ export { baseline_d_exports as Baseline };
18
+ //# sourceMappingURL=baseline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseline.d.ts","names":[],"sources":["../src/baseline.ts"],"mappings":";;;;qBACa;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA"}
@@ -0,0 +1,22 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
+ // src/baseline.ts
3
+ var baseline_exports = /* @__PURE__ */ __exportAll({
4
+ Baseline: () => baseline_exports,
5
+ versions: () => versions
6
+ });
7
+ /** Explicit legacy/offline inspection fallback only; never an approved online release. */
8
+ const versions = {
9
+ "@deslop/coding-standards": "0.1.1222",
10
+ "@dual/core": "0.0.1",
11
+ "@dual/dualspec": "0.0.0",
12
+ "@dual-os/sdk": "0.0.0",
13
+ "@effect/platform-node": "4.1.2",
14
+ "@effect/vitest": "4.1.2",
15
+ "bun-types": "1.4.2",
16
+ effect: "4.1.2",
17
+ typescript: "7.0.2",
18
+ vitest: "5.0.3"
19
+ };
20
+ export { baseline_exports as Baseline, versions };
21
+
22
+ //# sourceMappingURL=baseline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseline.js","names":[],"sources":["../src/baseline.ts"],"sourcesContent":["/** Explicit legacy/offline inspection fallback only; never an approved online release. */\nexport const versions = {\n \"@deslop/coding-standards\": \"0.1.1222\",\n \"@dual/core\": \"0.0.1\",\n \"@dual/dualspec\": \"0.0.0\",\n \"@dual-os/sdk\": \"0.0.0\",\n \"@effect/platform-node\": \"4.1.2\",\n \"@effect/vitest\": \"4.1.2\",\n \"bun-types\": \"1.4.2\",\n effect: \"4.1.2\",\n typescript: \"7.0.2\",\n vitest: \"5.0.3\",\n} as const;\n\nexport * as Baseline from \"./baseline.ts\";\n"],"mappings":";;;;;;;AACA,MAAa,WAAW;CACtB,4BAA4B;CAC5B,cAAc;CACd,kBAAkB;CAClB,gBAAgB;CAChB,yBAAyB;CACzB,kBAAkB;CAClB,aAAa;CACb,QAAQ;CACR,YAAY;CACZ,QAAQ;AACV"}
package/dist/bin.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {}
package/dist/bin.js ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import { run } from "./cli.js";
3
+ // src/bin.ts
4
+ run();
5
+ export {};
6
+
7
+ //# sourceMappingURL=bin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin.js","names":["Cli.run"],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Cli } from \"./cli.ts\";\n\nCli.run();\n"],"mappings":";;;AAGAA,IAAQ"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { Service } from "./release/releases.js";
2
+ import { Service as Service$1 } from "./create/scaffold.js";
3
+ import { Service as Service$2 } from "./skills.js";
4
+ import "./cli.js";
5
+ import * as NodeServices from "@effect/platform-node/NodeServices";
6
+ import { Effect, Layer, Stdio } from "effect";
7
+ declare namespace cli_d_exports {
8
+ export { cli_d_exports as Cli, execute, layer, run };
9
+ }
10
+ /** Node services for executing commands, including real scaffold and skill adapters. */
11
+ export declare const layer: Layer.Layer<Service | Service$1 | Service$2 | NodeServices.NodeServices, never, never>;
12
+ /** Execute CLI arguments (without the executable), returning the diagnostic exit code.
13
+ * Interruption and defects still propagate; only run() owns the Node process exit status.
14
+ */
15
+ export declare const execute: (args: readonly string[]) => Effect.Effect<number, never, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | import("effect/FileSystem").FileSystem | import("effect/Path").Path | Service | Service$1 | Service$2 | Stdio.Stdio | import("effect/Terminal").Terminal>;
16
+ /** Node-compatible entrypoint with the production adapters and help formatter. */
17
+ export declare const run: () => void;
18
+ export { cli_d_exports as Cli };
19
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","names":["Releases.Service","Scaffold.Service","Skills.Service"],"sources":["../src/cli.ts"],"mappings":";;;;;;;;;;qBAmKa,OAAK,MAAA,MAAAA,UAAAC,YAAAC,YAAA,aAAA;;;;qBA6BL,UAAO,4BAAA,OAAA,mEAAA,kDAAA,mCAAA,OAAAF,UAAAC,YAAAC,YAAA,MAAA,kCAAA;;qBAqvBP"}