approval-md 0.1.0 → 0.2.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 (266) hide show
  1. package/README.md +584 -553
  2. package/SPEC.md +42 -13
  3. package/dist/src/adapters/agentmail.d.ts +426 -0
  4. package/dist/src/adapters/agentmail.js +2 -2
  5. package/dist/src/adapters/conformance.d.ts +149 -0
  6. package/dist/src/adapters/contract.d.ts +628 -0
  7. package/dist/src/adapters/contract.js +110 -16
  8. package/dist/src/adapters/contract.js.map +1 -1
  9. package/dist/src/adapters/email.d.ts +324 -0
  10. package/dist/src/adapters/env-passphrase.d.ts +93 -0
  11. package/dist/src/adapters/public.d.ts +11 -0
  12. package/dist/src/adapters/public.js +11 -0
  13. package/dist/src/adapters/public.js.map +1 -0
  14. package/dist/src/adapters/registry.d.ts +59 -0
  15. package/dist/src/adapters/registry.js +2 -1
  16. package/dist/src/adapters/registry.js.map +1 -1
  17. package/dist/src/adapters/smtp.d.ts +213 -0
  18. package/dist/src/adapters/vault-provider.d.ts +114 -0
  19. package/dist/src/adapters/vault-provider.js +3 -3
  20. package/dist/src/adapters/zzz.d.ts +66 -0
  21. package/dist/src/adapters/zzz.js +299 -0
  22. package/dist/src/adapters/zzz.js.map +1 -0
  23. package/dist/src/channels/batch.d.ts +109 -0
  24. package/dist/src/channels/cli.d.ts +193 -0
  25. package/dist/src/channels/conformance.d.ts +92 -0
  26. package/dist/src/channels/contract.d.ts +623 -0
  27. package/dist/src/channels/payload-view.d.ts +35 -0
  28. package/dist/src/channels/render-queue.d.ts +149 -0
  29. package/dist/src/channels/tagging.d.ts +196 -0
  30. package/dist/src/channels/telegram.d.ts +1832 -0
  31. package/dist/src/channels/web.d.ts +341 -0
  32. package/dist/src/cli/adapter.d.ts +90 -0
  33. package/dist/src/cli/adapter.js +25 -15
  34. package/dist/src/cli/adapter.js.map +1 -1
  35. package/dist/src/cli/amend.d.ts +59 -0
  36. package/dist/src/cli/args.d.ts +43 -0
  37. package/dist/src/cli/attest.d.ts +41 -0
  38. package/dist/src/cli/audit-card.d.ts +62 -0
  39. package/dist/src/cli/audit.d.ts +59 -0
  40. package/dist/src/cli/channel-telegram.d.ts +806 -0
  41. package/dist/src/cli/channel-web.d.ts +131 -0
  42. package/dist/src/cli/channel.d.ts +71 -0
  43. package/dist/src/cli/checkpoint-tap.d.ts +169 -0
  44. package/dist/src/cli/codex.d.ts +2 -0
  45. package/dist/src/cli/codex.js +172 -0
  46. package/dist/src/cli/codex.js.map +1 -0
  47. package/dist/src/cli/coverage.d.ts +61 -0
  48. package/dist/src/cli/daemon.d.ts +120 -0
  49. package/dist/src/cli/doctor.d.ts +129 -0
  50. package/dist/src/cli/doctor.js +119 -5
  51. package/dist/src/cli/doctor.js.map +1 -1
  52. package/dist/src/cli/env.d.ts +65 -0
  53. package/dist/src/cli/execute.d.ts +202 -0
  54. package/dist/src/cli/exit-codes.d.ts +73 -0
  55. package/dist/src/cli/feedback.d.ts +60 -0
  56. package/dist/src/cli/gate-window.d.ts +40 -0
  57. package/dist/src/cli/gate.d.ts +68 -0
  58. package/dist/src/cli/git-scope.d.ts +190 -0
  59. package/dist/src/cli/gloss-attach.d.ts +85 -0
  60. package/dist/src/cli/gloss-codex-child.d.ts +9 -0
  61. package/dist/src/cli/gloss-codex.d.ts +24 -0
  62. package/dist/src/cli/gloss-options.d.ts +42 -0
  63. package/dist/src/cli/gloss.d.ts +265 -0
  64. package/dist/src/cli/help.d.ts +103 -0
  65. package/dist/src/cli/help.js +173 -51
  66. package/dist/src/cli/help.js.map +1 -1
  67. package/dist/src/cli/hook-codex.d.ts +78 -0
  68. package/dist/src/cli/hook-codex.js +167 -0
  69. package/dist/src/cli/hook-codex.js.map +1 -0
  70. package/dist/src/cli/hook.d.ts +331 -0
  71. package/dist/src/cli/hook.js +186 -80
  72. package/dist/src/cli/hook.js.map +1 -1
  73. package/dist/src/cli/import.d.ts +35 -0
  74. package/dist/src/cli/init.d.ts +84 -0
  75. package/dist/src/cli/init.js +2 -2
  76. package/dist/src/cli/init.js.map +1 -1
  77. package/dist/src/cli/instructions.d.ts +23 -0
  78. package/dist/src/cli/journal.d.ts +41 -0
  79. package/dist/src/cli/log-advance.d.ts +287 -0
  80. package/dist/src/cli/log-advance.js +102 -11
  81. package/dist/src/cli/log-advance.js.map +1 -1
  82. package/dist/src/cli/log-anchor.d.ts +176 -0
  83. package/dist/src/cli/log-checkpoint.d.ts +22 -0
  84. package/dist/src/cli/log-sync.d.ts +243 -0
  85. package/dist/src/cli/log-verbs.d.ts +16 -0
  86. package/dist/src/cli/log-verbs.js +7 -1
  87. package/dist/src/cli/log-verbs.js.map +1 -1
  88. package/dist/src/cli/long-help.d.ts +70 -0
  89. package/dist/src/cli/main.d.ts +77 -0
  90. package/dist/src/cli/main.js +155 -5
  91. package/dist/src/cli/main.js.map +1 -1
  92. package/dist/src/cli/mcp.d.ts +52 -0
  93. package/dist/src/cli/paths.d.ts +56 -0
  94. package/dist/src/cli/payload.d.ts +58 -0
  95. package/dist/src/cli/policy.d.ts +43 -0
  96. package/dist/src/cli/preflight.d.ts +363 -0
  97. package/dist/src/cli/preflight.js +294 -7
  98. package/dist/src/cli/preflight.js.map +1 -1
  99. package/dist/src/cli/progress.d.ts +78 -0
  100. package/dist/src/cli/prompt.d.ts +209 -0
  101. package/dist/src/cli/quickstart.d.ts +46 -0
  102. package/dist/src/cli/quickstart.js +297 -0
  103. package/dist/src/cli/quickstart.js.map +1 -0
  104. package/dist/src/cli/records.d.ts +34 -0
  105. package/dist/src/cli/render.d.ts +22 -0
  106. package/dist/src/cli/sandbox.d.ts +51 -0
  107. package/dist/src/cli/scaffold.d.ts +79 -0
  108. package/dist/src/cli/setup-adapter.d.ts +137 -0
  109. package/dist/src/cli/setup-adapter.js +38 -4
  110. package/dist/src/cli/setup-adapter.js.map +1 -1
  111. package/dist/src/cli/setup-channel.d.ts +117 -0
  112. package/dist/src/cli/setup-checkpoint.d.ts +57 -0
  113. package/dist/src/cli/setup-common.d.ts +275 -0
  114. package/dist/src/cli/setup-flow.d.ts +287 -0
  115. package/dist/src/cli/setup-service.d.ts +96 -0
  116. package/dist/src/cli/setup.d.ts +202 -0
  117. package/dist/src/cli/style.d.ts +320 -0
  118. package/dist/src/cli/token.d.ts +39 -0
  119. package/dist/src/cli/up.d.ts +155 -0
  120. package/dist/src/cli/up.js +4 -2
  121. package/dist/src/cli/up.js.map +1 -1
  122. package/dist/src/cli/usage.d.ts +37 -0
  123. package/dist/src/cli/values.d.ts +40 -0
  124. package/dist/src/cli/vault.d.ts +59 -0
  125. package/dist/src/cli/vault.js +2 -2
  126. package/dist/src/cli/vault.js.map +1 -1
  127. package/dist/src/cli/verb-registry.d.ts +76 -0
  128. package/dist/src/cli/verb-registry.js +176 -8
  129. package/dist/src/cli/verb-registry.js.map +1 -1
  130. package/dist/src/cli/wordmark.d.ts +31 -0
  131. package/dist/src/cli/wordmark.js +2 -2
  132. package/dist/src/codex/doctor.d.ts +13 -0
  133. package/dist/src/codex/doctor.js +41 -0
  134. package/dist/src/codex/doctor.js.map +1 -0
  135. package/dist/src/codex/manifest.d.ts +49 -0
  136. package/dist/src/codex/manifest.js +103 -0
  137. package/dist/src/codex/manifest.js.map +1 -0
  138. package/dist/src/codex/templates.d.ts +41 -0
  139. package/dist/src/codex/templates.js +319 -0
  140. package/dist/src/codex/templates.js.map +1 -0
  141. package/dist/src/codex/trust.d.ts +19 -0
  142. package/dist/src/codex/trust.js +183 -0
  143. package/dist/src/codex/trust.js.map +1 -0
  144. package/dist/src/codex/workspace-plan.d.ts +131 -0
  145. package/dist/src/codex/workspace-plan.js +561 -0
  146. package/dist/src/codex/workspace-plan.js.map +1 -0
  147. package/dist/src/core/actor.d.ts +2 -0
  148. package/dist/src/core/actor.js +5 -0
  149. package/dist/src/core/actor.js.map +1 -0
  150. package/dist/src/core/advance-cycle.d.ts +170 -0
  151. package/dist/src/core/agents-md.d.ts +276 -0
  152. package/dist/src/core/apply-patch.d.ts +49 -0
  153. package/dist/src/core/apply-patch.js +266 -0
  154. package/dist/src/core/apply-patch.js.map +1 -0
  155. package/dist/src/core/attest.d.ts +420 -0
  156. package/dist/src/core/attest.js +13 -1
  157. package/dist/src/core/attest.js.map +1 -1
  158. package/dist/src/core/audit.d.ts +492 -0
  159. package/dist/src/core/budgets.d.ts +238 -0
  160. package/dist/src/core/checkpoint.d.ts +500 -0
  161. package/dist/src/core/child-env.d.ts +88 -0
  162. package/dist/src/core/clock.d.ts +52 -0
  163. package/dist/src/core/command-class.d.ts +543 -0
  164. package/dist/src/core/command-class.js +43 -8
  165. package/dist/src/core/command-class.js.map +1 -1
  166. package/dist/src/core/coverage-sources/adapter.d.ts +40 -0
  167. package/dist/src/core/coverage-sources/gh.d.ts +48 -0
  168. package/dist/src/core/coverage-sources/git.d.ts +101 -0
  169. package/dist/src/core/coverage.d.ts +217 -0
  170. package/dist/src/core/credential-spec.d.ts +72 -0
  171. package/dist/src/core/dark-session.d.ts +331 -0
  172. package/dist/src/core/decision-refusal.d.ts +185 -0
  173. package/dist/src/core/env-file.d.ts +450 -0
  174. package/dist/src/core/execute.d.ts +858 -0
  175. package/dist/src/core/execute.js +44 -6
  176. package/dist/src/core/execute.js.map +1 -1
  177. package/dist/src/core/frontmatter.d.ts +78 -0
  178. package/dist/src/core/gate-window.d.ts +312 -0
  179. package/dist/src/core/gate.d.ts +1364 -0
  180. package/dist/src/core/gate.js +68 -13
  181. package/dist/src/core/gate.js.map +1 -1
  182. package/dist/src/core/git-run.d.ts +73 -0
  183. package/dist/src/core/harness-version.d.ts +157 -0
  184. package/dist/src/core/harness-version.js +2 -1
  185. package/dist/src/core/harness-version.js.map +1 -1
  186. package/dist/src/core/harness-wait.d.ts +55 -0
  187. package/dist/src/core/head-retry.d.ts +107 -0
  188. package/dist/src/core/instance.d.ts +253 -0
  189. package/dist/src/core/intake-limits.d.ts +247 -0
  190. package/dist/src/core/jcs.d.ts +52 -0
  191. package/dist/src/core/journal.d.ts +144 -0
  192. package/dist/src/core/live-draw.d.ts +436 -0
  193. package/dist/src/core/log-reconcile.d.ts +89 -0
  194. package/dist/src/core/log-subscribe.d.ts +36 -0
  195. package/dist/src/core/log-subscribe.js +162 -0
  196. package/dist/src/core/log-subscribe.js.map +1 -0
  197. package/dist/src/core/log.d.ts +278 -0
  198. package/dist/src/core/loop.d.ts +274 -0
  199. package/dist/src/core/loop.js +11 -0
  200. package/dist/src/core/loop.js.map +1 -1
  201. package/dist/src/core/md-fence.d.ts +41 -0
  202. package/dist/src/core/money.d.ts +147 -0
  203. package/dist/src/core/payload-census.d.ts +74 -0
  204. package/dist/src/core/payload-store.d.ts +175 -0
  205. package/dist/src/core/payload.d.ts +71 -0
  206. package/dist/src/core/policy-diff.d.ts +292 -0
  207. package/dist/src/core/policy-diff.js +27 -4
  208. package/dist/src/core/policy-diff.js.map +1 -1
  209. package/dist/src/core/policy-expectations.d.ts +199 -0
  210. package/dist/src/core/policy-explain.d.ts +150 -0
  211. package/dist/src/core/policy-explain.js +31 -3
  212. package/dist/src/core/policy-explain.js.map +1 -1
  213. package/dist/src/core/policy-load.d.ts +527 -0
  214. package/dist/src/core/policy-load.js +15 -3
  215. package/dist/src/core/policy-load.js.map +1 -1
  216. package/dist/src/core/policy-match.d.ts +281 -0
  217. package/dist/src/core/policy-match.js +20 -9
  218. package/dist/src/core/policy-match.js.map +1 -1
  219. package/dist/src/core/policy-proposal.d.ts +265 -0
  220. package/dist/src/core/prompt-layout.d.ts +221 -0
  221. package/dist/src/core/protected-path-guard.d.ts +453 -0
  222. package/dist/src/core/protected-path-guard.js +514 -35
  223. package/dist/src/core/protected-path-guard.js.map +1 -1
  224. package/dist/src/core/registration.d.ts +25 -0
  225. package/dist/src/core/reindex.d.ts +99 -0
  226. package/dist/src/core/sampler.d.ts +313 -0
  227. package/dist/src/core/sandbox.d.ts +290 -0
  228. package/dist/src/core/seal.d.ts +165 -0
  229. package/dist/src/core/state.d.ts +505 -0
  230. package/dist/src/core/task-file.d.ts +185 -0
  231. package/dist/src/core/telegram-config.d.ts +93 -0
  232. package/dist/src/core/token.d.ts +409 -0
  233. package/dist/src/core/token.js +21 -38
  234. package/dist/src/core/token.js.map +1 -1
  235. package/dist/src/core/validate.d.ts +138 -0
  236. package/dist/src/core/values.d.ts +137 -0
  237. package/dist/src/core/vault.d.ts +291 -0
  238. package/dist/src/core/verified-snapshot.d.ts +204 -0
  239. package/dist/src/core/verify.d.ts +336 -0
  240. package/dist/src/core/version.d.ts +8 -0
  241. package/dist/src/core/wysiwys.d.ts +370 -0
  242. package/dist/src/daemon/advance-child.d.ts +39 -0
  243. package/dist/src/daemon/advance.d.ts +466 -0
  244. package/dist/src/daemon/audit.d.ts +87 -0
  245. package/dist/src/daemon/daemon.d.ts +1180 -0
  246. package/dist/src/daemon/dark-session.d.ts +64 -0
  247. package/dist/src/daemon/draw-child.d.ts +36 -0
  248. package/dist/src/daemon/draw.d.ts +154 -0
  249. package/dist/src/daemon/git-evidence.d.ts +173 -0
  250. package/dist/src/daemon/git-evidence.js +1 -1
  251. package/dist/src/daemon/projection.d.ts +180 -0
  252. package/dist/src/daemon/prune.d.ts +207 -0
  253. package/dist/src/mcp/http.d.ts +113 -0
  254. package/dist/src/mcp/server.d.ts +265 -0
  255. package/dist/src/mcp/server.js +9 -1
  256. package/dist/src/mcp/server.js.map +1 -1
  257. package/docs/adapter-api.md +106 -0
  258. package/docs/cli-reference.md +389 -36
  259. package/docs/codex-enforced-session.md +30 -0
  260. package/package.json +12 -2
  261. package/schema/codex-instance.schema.json +82 -0
  262. package/schema/event.schema.json +2 -1
  263. package/schema/fixtures/codex-instance/invalid/unpinned-codex-version.json +40 -0
  264. package/schema/fixtures/codex-instance/valid/canonical.json +40 -0
  265. package/schema/policy.schema.json +21 -1
  266. package/templates/codex/README.md +9 -0
@@ -0,0 +1,275 @@
1
+ /**
2
+ * What every `approval setup` subcommand shares (SPEC.md §5.2, §10.1; APRV-79).
3
+ *
4
+ * `setup` began as one file with four subcommands in it. APRV-78 added
5
+ * `setup adapter <name>` in a file of its own, and it had to reach back into
6
+ * `cli/setup.ts` for the front matter — which made a cycle: `setup.ts` imports
7
+ * the adapter verb to dispatch it, and the adapter verb imports `front`,
8
+ * `requireHuman` and `SetupDeps` back. ESM tolerates that until the day an
9
+ * initialisation order changes and a `const` at module scope is `undefined` in
10
+ * one direction only. APRV-79 adds a THIRD such file (`setup-channel.ts`), so
11
+ * the cycle is broken by extraction rather than tolerated a second time.
12
+ *
13
+ * The rule this file exists to enforce, asserted in `tests/layering.test.ts`:
14
+ *
15
+ * ```
16
+ * setup.ts ──┬─> setup-adapter.ts ──┐
17
+ * └─> setup-channel.ts ──┴─> setup-common.ts (and no arrow back)
18
+ * ```
19
+ *
20
+ * What lives here is what more than one of those three needs: the dependency
21
+ * bag, the keystore seam, the flag table, the front matter (`--help`, the paths,
22
+ * the policy, the terminal check), the human-only gate, the `.approval/env`
23
+ * refusal mapping, the service names, and the plaintext-literal offer. What does
24
+ * NOT live here is anything one subcommand alone uses: the chat picker is
25
+ * `setup-channel.ts`'s, the manifest hint generator is `setup-adapter.ts`'s, and
26
+ * the generated-secret path (`storeGeneratedSecret`) stays with `vault` and
27
+ * `sampling` in `setup.ts`.
28
+ *
29
+ * The reasoning for each decision this file encodes — why the token is never
30
+ * handled by this process, why a generated value may reach an argv and an
31
+ * operator's own may not, why every subcommand refuses a non-terminal stdin —
32
+ * is in `cli/setup.ts`'s module doc, which is the family's front page. It is not
33
+ * repeated here; this file is the mechanism.
34
+ */
35
+ import { type EnvFileRefusal } from "../core/env-file.js";
36
+ import { type PolicyLoadResult } from "../core/policy-load.js";
37
+ import type { CredentialProvider } from "../adapters/contract.js";
38
+ import type { probeSmtp } from "../adapters/smtp.js";
39
+ import { type TelegramFetch } from "../channels/telegram.js";
40
+ import { type FlagKind } from "./args.js";
41
+ import type { Streams } from "./main.js";
42
+ import { type Prompter } from "./prompt.js";
43
+ /**
44
+ * The keystore item names, one per secret, SCOPED TO THIS INSTANCE (APRV-178).
45
+ *
46
+ * They were three fixed strings until a demo gate in another directory stored
47
+ * its bot token over the production gate's item, read the production token
48
+ * back, and had a human's approval tap consumed by the wrong listener. A
49
+ * keystore is machine-global and the filesystem scoping every other part of an
50
+ * instance has was simply missing here; `core/instance.ts` carries the whole
51
+ * reasoning and the shape of the suffix.
52
+ *
53
+ * Still not a flag. An operator reading `.approval/env` sees the service name
54
+ * in the file itself (`keychain:approval-tg-token-3f2a9c11`), so the name is
55
+ * discoverable, and a `--service-prefix` would add a way for two checkouts to
56
+ * disagree about which item is which — which is the bug, not the fix.
57
+ */
58
+ export interface ServiceNames {
59
+ telegramToken: string;
60
+ vaultPassphrase: string;
61
+ samplingSecret: string;
62
+ }
63
+ /** The three item names the instance owning `logPath` reads and writes. */
64
+ export declare function servicesFor(logPath: string): ServiceNames;
65
+ /**
66
+ * The variable a sampling secret goes into when the policy names none. The
67
+ * value is stored either way; what the operator is then told to do is add the
68
+ * `audit.sampling_secret_env` line, because until the POLICY names a variable
69
+ * the sampler stays off (SPEC.md §5.2) and no amount of environment fixes that.
70
+ */
71
+ export declare const DEFAULT_SAMPLING_ENV = "APPROVAL_SAMPLING_SECRET";
72
+ /** The long-poll `getUpdates` asks for, in seconds. */
73
+ export declare const POLL_TIMEOUT_SECONDS = 10;
74
+ /** doctor's probe timeout, for the calls that answer immediately. */
75
+ export declare const PROBE_TIMEOUT_MS = 10000;
76
+ /** The flags every subcommand accepts. One table, so none of them drifts. */
77
+ export declare const FLAGS: Record<string, FlagKind>;
78
+ /** Which credential store this machine has, as a closed set. */
79
+ export type KeystoreKind = "keychain" | "secret-service" | "none";
80
+ /** What a store attempt did. `viaArgv` is reported, never hidden. */
81
+ export type StoreOutcome = {
82
+ ok: true;
83
+ /**
84
+ * The value passed through the helper's argv rather than its stdin. True
85
+ * only on the generated-secret fallback path; see `cli/setup.ts`.
86
+ */
87
+ viaArgv: boolean;
88
+ } | {
89
+ ok: false;
90
+ message: string;
91
+ };
92
+ /**
93
+ * The keystore operations `setup` needs, injectable for exactly the reason
94
+ * {@link defaultSourceRunner}'s seam exists: no test in this repository may
95
+ * touch a real Keychain or a real secret service, and the way to guarantee that
96
+ * is for the tests to hand over a fake rather than for the runtime to grow a
97
+ * test-only flag.
98
+ */
99
+ export interface KeystoreRunner {
100
+ /** What is available here. Consulted once per run. */
101
+ kind(): KeystoreKind;
102
+ /**
103
+ * Store a value THIS PROCESS GENERATED. Prefers the helper's stdin; may fall
104
+ * back to its argv, and says which it did.
105
+ */
106
+ storeGenerated(service: string, value: string): StoreOutcome;
107
+ /**
108
+ * Have the HELPER'S OWN no-echo prompt collect the value from the terminal.
109
+ * The value never enters this process. macOS and `secret-tool` both support
110
+ * this; there is no such thing on a machine with neither.
111
+ */
112
+ storePrompted(service: string): StoreOutcome;
113
+ /** Read a stored value back. The value arrives on stdout, never in an argv. */
114
+ read(service: string): {
115
+ ok: true;
116
+ value: string;
117
+ } | {
118
+ ok: false;
119
+ message: string;
120
+ };
121
+ }
122
+ /** A thrown thing, as a sentence. */
123
+ export declare function detail(cause: unknown): string;
124
+ /** The real one. Nothing in the test suite constructs it. */
125
+ export declare const defaultKeystoreRunner: KeystoreRunner;
126
+ /** The `.approval/env` scheme a backend writes. */
127
+ export declare function schemeFor(kind: KeystoreKind, service: string): string | null;
128
+ /** The command an operator runs by hand to see that the item is really there. */
129
+ export declare function retrievalCommand(kind: KeystoreKind, service: string): string;
130
+ /** The command an operator runs by hand to STORE the item, with no value in it. */
131
+ export declare function storageCommand(kind: KeystoreKind, service: string): string;
132
+ /** Everything this verb reaches the world through. Defaults are the real ones. */
133
+ export interface SetupDeps {
134
+ prompter?: Prompter | null;
135
+ keystore?: KeystoreRunner;
136
+ fetch?: TelegramFetch;
137
+ apiBase?: string;
138
+ /** Overridable so a test can assert on a value it chose. */
139
+ generate?: () => string;
140
+ /**
141
+ * The `getUpdates` long poll, in seconds. Overridable for one reason: the
142
+ * "nobody messaged the bot" path polls three times, and a suite that spent
143
+ * thirty seconds proving a refusal is a suite people stop running. Not a
144
+ * flag — no operator has a reason to change it.
145
+ */
146
+ pollTimeoutSeconds?: number;
147
+ /**
148
+ * The environment the passphrase is read from. `process.env` by default.
149
+ *
150
+ * A seam and not a back door: it is read through `passphraseFrom`, which is
151
+ * the same function `approval vault set` uses, and it never resolves
152
+ * `.approval/env` (§11.1 invariant 7). Injectable so a test can prove both
153
+ * the unset refusal and the happy path without mutating the suite's own
154
+ * environment, which is shared by every other test in the process.
155
+ */
156
+ env?: NodeJS.ProcessEnv;
157
+ /**
158
+ * The SMTP probe `setup adapter email` verifies with. The real one by
159
+ * default; a test injects a wrapper so that the only TLS relaxation in this
160
+ * repository stays inside the test that needs it (`tests/smtp-mock.ts`'s
161
+ * self-signed fixture on 127.0.0.1).
162
+ */
163
+ probe?: typeof probeSmtp;
164
+ /**
165
+ * The vault read `setup adapter email` probes a partial re-run through
166
+ * (APRV-99). The real {@link vaultCredentialProvider} by default — the same
167
+ * provider `approval adapter email` hands to `act` — and injectable for one
168
+ * reason: the fallback for a vault that will not open is unreachable
169
+ * otherwise, because the flow proved the passphrase at its preflight and the
170
+ * writes have already landed by the time verification runs.
171
+ */
172
+ credentials?: CredentialProvider;
173
+ }
174
+ export declare function usageError(streams: Streams, json: boolean, message: string, helpText: string): number;
175
+ /**
176
+ * A refused PROMPT, as one line and no help page (APRV-90).
177
+ *
178
+ * The distinction this function exists to draw: {@link usageError} answers a
179
+ * mangled command line, so it names the shape that line should have had, which
180
+ * is the thing the operator got wrong. A prompt that was aborted or answered
181
+ * wrongly five times is not a command line at all — the operator was in a
182
+ * conversation, the question was on screen, and a usage block under it teaches
183
+ * nothing. Same exit code (the frozen table is unchanged), one line of output,
184
+ * and not even the `--help` pointer a usage error carries.
185
+ */
186
+ export declare function promptRefusal(streams: Streams, message: string): number;
187
+ export declare function absolute(value: string, cwd: string): string;
188
+ export declare function refusalExitCode(refusal: EnvFileRefusal): number;
189
+ export declare function emitRefusal(streams: Streams, refusal: EnvFileRefusal): number;
190
+ export interface Context {
191
+ flags: Record<string, string | boolean>;
192
+ positionals: string[];
193
+ prompter: Prompter;
194
+ keystore: KeystoreRunner;
195
+ /**
196
+ * Which keystore this machine has. Named `backend` rather than `kind` because
197
+ * the outcome union around this context already discriminates on `kind`.
198
+ */
199
+ backend: KeystoreKind;
200
+ load: PolicyLoadResult;
201
+ logPath: string;
202
+ envPath: string;
203
+ /** This instance's keystore item names (APRV-178). */
204
+ services: ServiceNames;
205
+ apiBase: string;
206
+ generate: () => string;
207
+ pollTimeoutSeconds: number;
208
+ }
209
+ export type FrontOutcome = {
210
+ kind: "handled";
211
+ code: number;
212
+ } | ({
213
+ kind: "run";
214
+ } & Context);
215
+ /**
216
+ * What a non-interactive hint needs: where the map lives, which keystore is
217
+ * present, and the variable NAMES the loaded policy resolves to. The hints
218
+ * must print the names the interactive path would write, or an operator on a
219
+ * renamed policy copies a line the runtime never reads.
220
+ */
221
+ export interface HintContext {
222
+ envPath: string;
223
+ kind: KeystoreKind;
224
+ /**
225
+ * The instance's item names. A hint that printed the unscoped legacy name
226
+ * would teach the operator to create by hand exactly the shared item
227
+ * APRV-178 exists to stop.
228
+ */
229
+ services: ServiceNames;
230
+ passphraseEnv: string;
231
+ samplingEnv: string;
232
+ tokenEnv: string;
233
+ chatEnv: string;
234
+ }
235
+ /** The policy's `audit.sampling_secret_env`, or `null`. */
236
+ export declare function samplingEnvName(load: PolicyLoadResult): string | null;
237
+ export declare function hintContextFor(load: PolicyLoadResult, envPath: string, kind: KeystoreKind, services: ServiceNames): HintContext;
238
+ /**
239
+ * `--help`, the paths, the policy, the terminal check.
240
+ *
241
+ * The terminal check has no `process.stdin.isTTY` in it, deliberately: the real
242
+ * prompter refuses to construct without one ({@link createPrompter}), so "there
243
+ * is no prompter" IS "there is no terminal", and a test that injects one has
244
+ * not bypassed a check that a CI job could also bypass — it has supplied the
245
+ * human's side of the conversation, which is the only thing a test can honestly
246
+ * do here.
247
+ */
248
+ export declare function front(subcommand: string, argv: string[], streams: Streams, cwd: string, deps: SetupDeps, helpText: string, nonInteractiveHint: (context: HintContext) => string,
249
+ /**
250
+ * Flags this subcommand accepts on top of the shared table (APRV-110).
251
+ *
252
+ * `setup service` is the first subcommand whose subject is not a credential,
253
+ * so it needs words the other four have no use for (a platform, a unit label,
254
+ * a log directory). They are passed in rather than added to {@link FLAGS},
255
+ * because a flag every subcommand silently accepts is a flag an operator will
256
+ * eventually pass to the one that ignores it.
257
+ */
258
+ extraFlags?: Record<string, FlagKind>): FrontOutcome;
259
+ /** The human-only rule, spelled exactly as `vault set` spells it. */
260
+ export declare function requireHuman(flags: Record<string, string | boolean>, streams: Streams, helpText: string, verb: string): {
261
+ ok: true;
262
+ actor: string;
263
+ } | {
264
+ ok: false;
265
+ code: number;
266
+ };
267
+ /**
268
+ * The plaintext-literal offer, for a machine with no keystore.
269
+ *
270
+ * An explicit typed `yes` — not `y`, not Enter — because the whole content of
271
+ * this question is that the operator understood it. The warning is worded to
272
+ * match what `approval env --check` will print at them on every run afterwards,
273
+ * so the two never read as different claims about the same file.
274
+ */
275
+ export declare function offerLiteral(streams: Streams, prompter: Prompter, envPath: string, what: string): boolean;
@@ -0,0 +1,287 @@
1
+ /**
2
+ * The credential-collection flow (SPEC.md §5.2, §10.1, §10.4; APRV-78).
3
+ *
4
+ * `setup identity|vault|sampling|telegram` each hand-rolled their own
5
+ * conversation, and that was right while there were four of them and each was
6
+ * different. `setup adapter <name>` was the first verb whose conversation is
7
+ * DERIVED — from a manifest of {@link CredentialSpec}s an adapter declares — so
8
+ * the conversation itself becomes a function, and this file is that function.
9
+ * APRV-79 made it the second caller's too: `setup channel telegram` runs this
10
+ * flow over the Telegram channel's manifest, into `.approval/env` instead of
11
+ * into the vault, which is what the destination seam was built for.
12
+ *
13
+ * It knows nothing about email, SMTP, Telegram, or the vault's file format. It
14
+ * is handed a list of specs, somewhere to put the values
15
+ * ({@link FlowDestination}), and up to four hooks, and it runs one fixed order:
16
+ *
17
+ * 1. the title and the prerequisite line;
18
+ * 2. **the checklist** — one line per spec, before a single question is asked,
19
+ * so an operator can see the whole shape of what is about to be demanded and
20
+ * where it will land, and abandon at zero cost if it is the wrong vault;
21
+ * 3. **the preflight** ({@link FlowDestination.present}), which for a vault
22
+ * means OPENING it. This is why it is step three and not step six: a wrong
23
+ * passphrase must refuse before the operator has typed a password, not
24
+ * after. The set it returns is also what step four reads;
25
+ * 4. **the replacement plan** ({@link planWrites}), asked up front for the same
26
+ * reason `setup`'s own does: a confirmation asked after the value had been
27
+ * replaced is a question whose "no" no longer means anything. A name the
28
+ * operator declines is never even asked for;
29
+ * 5. **collection**, in manifest order;
30
+ * 6. **the cross-field check** ({@link FlowHooks.check}), before any write, so
31
+ * a half-configured pair costs nothing;
32
+ * 7. **the writes**, in manifest order — which is why an adapter puts its
33
+ * secret last: a destination that refuses half way reports exactly which
34
+ * names landed and stops. **There is no rollback**, deliberately: deleting
35
+ * credentials in response to a write failure is a destructive act taken by a
36
+ * wizard on its own authority, over a store whose previous contents it
37
+ * cannot restore;
38
+ * 8. **verification** ({@link FlowHooks.verify}), after the write, because the
39
+ * thing being verified is the stored configuration; and
40
+ * 9. **the report** — where, how many, which names — and the next steps.
41
+ *
42
+ * **Values are held in this process and printed by nothing.** The flow must
43
+ * hold them: it collected them and it is about to write them. Every line it
44
+ * emits names a CREDENTIAL NAME, a kind, a count, or a path, and the suite in
45
+ * `tests/cli-setup.test.ts` sweeps every captured byte for the fixture secrets
46
+ * with no exemption on this path.
47
+ */
48
+ import type { CredentialSpec } from "../core/credential-spec.js";
49
+ import { envFilePathFor } from "../core/env-file.js";
50
+ import type { Streams } from "./main.js";
51
+ import { type Prompter } from "./prompt.js";
52
+ /**
53
+ * A refusal from a destination, already carrying its exit code.
54
+ *
55
+ * The code is decided by the destination and not by this file, because the
56
+ * frozen exit table's split (4 is a filesystem fact, 1 is the runtime deciding
57
+ * no) is a property of the STORE's vocabulary — `cli/vault.ts` and
58
+ * `cli/setup.ts` each already map their own refusals that way, and a flow that
59
+ * re-derived the mapping would be a third opinion about the same table.
60
+ */
61
+ export interface FlowRefusal {
62
+ code: string;
63
+ message: string;
64
+ exitCode: number;
65
+ }
66
+ /** Where a flow puts what it collected. Two implementations live below. */
67
+ export interface FlowDestination {
68
+ kind: "vault" | "env-file";
69
+ /** The path, for the checklist and the report. Never a value. */
70
+ where(): string;
71
+ /**
72
+ * Which of the names are ALREADY there — and, for a store that must be
73
+ * unlocked, the act of unlocking it. Called once, before anything is asked.
74
+ */
75
+ present(): {
76
+ ok: true;
77
+ names: ReadonlySet<string>;
78
+ } | ({
79
+ ok: false;
80
+ } & FlowRefusal);
81
+ /** Store one value. Called once per name, in manifest order. */
82
+ write(name: string, value: string): {
83
+ ok: true;
84
+ } | ({
85
+ ok: false;
86
+ } & FlowRefusal);
87
+ }
88
+ /**
89
+ * The encrypted credential store (SPEC.md §10.4).
90
+ *
91
+ * `present()` is where the passphrase is proved. A vault that does not exist
92
+ * yet holds nothing and refuses nothing: the first `write` creates it, which is
93
+ * what `approval vault set` does too. A vault that DOES exist is opened here
94
+ * and nowhere later, so a wrong passphrase costs the operator one line of
95
+ * output rather than five typed values.
96
+ */
97
+ export declare function vaultDestination(vaultPath: string, passphrase: string): FlowDestination;
98
+ /**
99
+ * The `.approval/env` source map (SPEC.md §5.2).
100
+ *
101
+ * Unused by `setup adapter` — an adapter's credentials go to the vault, never
102
+ * to this file — and used by `setup channel telegram`, which is what a channel's
103
+ * two values are: a source for the token and a literal chat id, both of them
104
+ * things that unlock the machine rather than things an adapter spends.
105
+ *
106
+ * The value written is whatever the caller collected, which on this path is a
107
+ * SOURCE (`keychain:<service>`), an identity, or a chat id. Nothing here decides
108
+ * that; {@link upsertEnvFileEntries} preserves every other line and comment.
109
+ */
110
+ export declare function envFileDestination(envPath: string): FlowDestination;
111
+ /** The env file for a log path, re-exported so a caller needs one import. */
112
+ export { envFilePathFor };
113
+ /** How a destination talks about what it already holds. */
114
+ export interface PlanPhrases {
115
+ /** `<name> already has a line in <path> (its value is not printed here).` */
116
+ present(name: string, where: string): string;
117
+ /** The confirm question. Defaults to no, like every other one in `setup`. */
118
+ replace(name: string): string;
119
+ /** The "left alone" report, or `null` when nothing was left alone. */
120
+ leftAlone(names: string[], where: string): string;
121
+ }
122
+ /**
123
+ * The two phrasings, kept as data.
124
+ *
125
+ * The env-file wording is BYTE-FOR-BYTE what `setup identity|vault|sampling|
126
+ * telegram` printed before this file existed, because those sentences are
127
+ * asserted on and, more to the point, an operator who has run `setup` before
128
+ * should not be told the same fact in new words for no reason.
129
+ */
130
+ export declare const PLAN_PHRASES: Record<FlowDestination["kind"], PlanPhrases>;
131
+ /**
132
+ * Which names to ask for, given which are already there.
133
+ *
134
+ * Asked BEFORE any work is done, and no previous VALUE is ever printed — not
135
+ * even one that is not a secret. A store may legitimately hold anything under
136
+ * any name, the operator put it there, and a verb that echoed "replacing
137
+ * smtp.user (you@example.net)?" would publish it into a terminal on their
138
+ * behalf.
139
+ */
140
+ export declare function planWrites(streams: Streams, prompter: Prompter, present: ReadonlySet<string>, where: string, names: readonly string[], phrases: PlanPhrases): {
141
+ write: string[];
142
+ skipped: string[];
143
+ };
144
+ /** Report what was left alone, so a re-run's "no" is visible in the output. */
145
+ export declare function reportLeftAlone(streams: Streams, where: string, skipped: readonly string[], phrases: PlanPhrases): void;
146
+ /**
147
+ * A numbered picker over a closed list.
148
+ *
149
+ * Extracted from the Telegram chat picker, which is the same conversation over
150
+ * different nouns: print the options with an index and read a number. Both
151
+ * callers use this one (APRV-79).
152
+ *
153
+ * **An unparseable answer is asked again** (APRV-90). It used to be a refusal,
154
+ * on the argument that a wizard which loops on one question and not the others
155
+ * is unpredictable — the answer to which turned out to be that every question
156
+ * loops, not that none of them does. The options are printed once; only the
157
+ * question repeats, under one line saying which number was not on the list.
158
+ * `ok: false` now means the human withdrew (Ctrl-D) or ran out of attempts, and
159
+ * the message says which.
160
+ */
161
+ export declare function pickOne<T>(streams: Streams, prompter: Prompter, options: {
162
+ heading: string;
163
+ items: readonly T[];
164
+ label(item: T): string;
165
+ prompt: string;
166
+ /** Index of the item an empty answer takes, or `null` for no default. */
167
+ defaultIndex: number | null;
168
+ }): {
169
+ ok: true;
170
+ item: T;
171
+ } | {
172
+ ok: false;
173
+ message: string;
174
+ };
175
+ /** What a verification attempt reports back. Never carries a value. */
176
+ export interface VerifyOutcome {
177
+ /** Did the far end accept the stored configuration? */
178
+ ok: boolean;
179
+ /** The operator declined to verify. `ok` is ignored when this is true. */
180
+ declined?: boolean;
181
+ /** Lines to print, already redacted by whoever built them. */
182
+ detail: string;
183
+ }
184
+ /** What the flow has done by the time {@link FlowHooks.verify} is called. */
185
+ export interface FlowProgress {
186
+ /** Names stored this run, in the order they landed. */
187
+ written: readonly string[];
188
+ /** Names the operator declined to replace, so this run never saw them. */
189
+ skipped: readonly string[];
190
+ }
191
+ /**
192
+ * What a {@link FlowHooks.collect} or {@link FlowHooks.discover} attempt did.
193
+ *
194
+ * `refused` carries an exit code and nothing else, because the hook has already
195
+ * printed its own sentences. A channel's refusals are specific to the far end
196
+ * it just talked to — an invalid bot token, a 409 from a running listener, no
197
+ * message reaching the bot after three attempts, each with its own repair and
198
+ * its own code from the frozen table — and a flow that re-derived them from a
199
+ * message string would be a second opinion about what went wrong.
200
+ */
201
+ export type HookOutcome = {
202
+ kind: "value";
203
+ value: string;
204
+ }
205
+ /** Nothing to store for this spec. A required spec may not do this. */
206
+ | {
207
+ kind: "skip";
208
+ } | {
209
+ kind: "refused";
210
+ code: number;
211
+ };
212
+ export interface FlowHooks {
213
+ /**
214
+ * Collect one value, overriding the built-in prompts.
215
+ *
216
+ * Async because a hook may need to prove what it collected before the flow
217
+ * writes anything: `setup channel telegram` calls `getMe` at the end of its
218
+ * token collection, so an invalid token refuses at step five and no line is
219
+ * ever written. Handed what has been collected so far, in manifest order.
220
+ */
221
+ collect?(spec: CredentialSpec, state: Readonly<Record<string, string>>): Promise<HookOutcome>;
222
+ /**
223
+ * The cross-field rule, run over everything collected, before any write.
224
+ * Returns the refusal sentence, or `null`. `kept` names the values already
225
+ * in the store that the operator declined to replace this run (APRV-98): the
226
+ * flow never reads a value back, so a rule that needs to know whether a
227
+ * kept name is PRESENT gets that from here rather than from `values`.
228
+ */
229
+ check?(values: Record<string, string>, kept: readonly string[]): string | null;
230
+ /**
231
+ * Prove the stored configuration against the far end. Runs after the write.
232
+ *
233
+ * It is handed what the run DID as well as what it collected, because
234
+ * "verify" and "verify what is in the store" are different questions on a
235
+ * re-run: a hook that only saw the values would probe a partial
236
+ * configuration and report a failure about a deployment that is fine. The
237
+ * flow will not read the store back to complete the picture, and neither
238
+ * should a hook — there is no verb in this CLI that reads a credential out.
239
+ */
240
+ verify?(values: Record<string, string>, progress: FlowProgress): Promise<VerifyOutcome>;
241
+ /**
242
+ * Ask the SERVICE what a value is, rather than asking the human to type it.
243
+ *
244
+ * Called for one spec at a time, and only when {@link FlowHooks.collect}
245
+ * skipped it (or there is no `collect` and the spec is optional and empty),
246
+ * so the two compose: a manifest can have some values typed and some
247
+ * discovered without the flow knowing which is which. It is handed what has
248
+ * been collected so far, because discovery generally needs it — Telegram's
249
+ * chat discovery cannot happen before the token it polls with.
250
+ *
251
+ * APRV-78 reserved this hook and called nothing; APRV-79 is the caller.
252
+ */
253
+ discover?(spec: CredentialSpec, state: Readonly<Record<string, string>>): Promise<HookOutcome>;
254
+ }
255
+ export interface FlowLabels {
256
+ /** The first line: what this verb is about to do. */
257
+ title: string;
258
+ /** The prerequisite sentence, printed under the title. */
259
+ prereq?: string;
260
+ /** Printed last, after the report. One line each. */
261
+ nextSteps?: readonly string[];
262
+ }
263
+ export interface FlowResult {
264
+ /** The exit code, from the frozen table. */
265
+ code: number;
266
+ /** Names actually stored, in the order they landed. */
267
+ written: string[];
268
+ /** Names the operator declined to replace. */
269
+ skipped: string[];
270
+ verified: "passed" | "failed" | "declined" | "not-attempted";
271
+ }
272
+ export interface CredentialFlow {
273
+ streams: Streams;
274
+ prompter: Prompter;
275
+ specs: readonly CredentialSpec[];
276
+ destination: FlowDestination;
277
+ labels: FlowLabels;
278
+ hooks?: FlowHooks;
279
+ }
280
+ /**
281
+ * Run one credential conversation, start to finish. Never throws.
282
+ *
283
+ * The caller has already done everything that is its own business: flags, the
284
+ * terminal check, the human-only gate, and resolving the passphrase out of the
285
+ * environment. What arrives here is a manifest and somewhere to put it.
286
+ */
287
+ export declare function runCredentialFlow(flow: CredentialFlow): Promise<FlowResult>;
@@ -0,0 +1,96 @@
1
+ /**
2
+ * `approval setup service` — the login service that runs the ambient runtime
3
+ * (SPEC.md §10.2, APRV-110).
4
+ *
5
+ * `approval up` is a foreground process. This verb writes the one file that
6
+ * makes it start at login and stay started: a launchd user agent on macOS, or a
7
+ * systemd user unit on Linux. It is the fifth member of the `setup` family and
8
+ * it obeys the family's rules — interactive by refusal, human-only, appending
9
+ * nothing to the log, editing no policy — with two of its own.
10
+ *
11
+ * ## It never copies a value
12
+ *
13
+ * A unit file is world-readable configuration that survives reboots and gets
14
+ * backed up. A bot token in one is a bot token in a backup. So the unit NAMES
15
+ * where the environment comes from and never carries it:
16
+ *
17
+ * - by default it runs a WRAPPER the human reads in the printed unit —
18
+ * `eval "$(approval env)"` and then `exec approval up` — so the keystore
19
+ * references stay in the keystore and `approval env` stays the only thing
20
+ * that resolves them (SPEC.md §11.1 invariant 7: nothing loads that file
21
+ * implicitly, and here it is a human's line in a file they approved);
22
+ * - or, with `--env-file`, it points at a file THE OPERATOR AUTHORED, which
23
+ * this verb neither writes nor reads.
24
+ *
25
+ * ## It prints the unit before it writes it, and it does not arm it
26
+ *
27
+ * The whole file goes to stdout first, and nothing is written until the operator
28
+ * confirms. Loading it is a separate act: this verb prints the exact
29
+ * `launchctl` or `systemctl` line and stops there. A login service is a standing
30
+ * capability on someone's machine — it will start a process that holds a
31
+ * credential and can put prompts on a phone — and a wizard that armed one as a
32
+ * side effect of writing a file would be making that decision on the operator's
33
+ * behalf. Printing the command costs one paste and buys an explicit act.
34
+ *
35
+ * ## Logs never go into `.approval/`
36
+ *
37
+ * The service's stdout and stderr go where the operator chooses, defaulting to
38
+ * the platform's own log home. A path inside the approval home is REFUSED:
39
+ * `.approval/` holds the log, the queue projection, the payload store, the
40
+ * vault and the environment source map, and a service that appended its console
41
+ * output beside them would put unverifiable text in the one directory whose
42
+ * contents are supposed to mean something.
43
+ */
44
+ import type { Streams } from "./main.js";
45
+ import { type SetupDeps } from "./setup-common.js";
46
+ /** The two service managers this verb writes for. */
47
+ export type ServicePlatform = "launchd" | "systemd";
48
+ /** The conventional names. `--label` overrides both. */
49
+ export declare const LAUNCHD_LABEL = "md.approval.up";
50
+ export declare const SYSTEMD_UNIT = "approval-up";
51
+ /** Which manager this machine has, or `null` when it has neither. */
52
+ export declare function platformFor(platform: NodeJS.Platform): ServicePlatform | null;
53
+ /** Where the unit file belongs, for a platform and a label. */
54
+ export declare function unitPathFor(platform: ServicePlatform, label: string, home: string): string;
55
+ /** Where the platform keeps a user's own logs. */
56
+ export declare function defaultLogsDir(platform: ServicePlatform, home: string): string;
57
+ /** The command that arms the written unit, printed and never run. */
58
+ export declare function armCommand(platform: ServicePlatform, label: string, path: string): string;
59
+ /**
60
+ * The command that disarms it, printed before the file is removed.
61
+ *
62
+ * Takes no path, unlike {@link armCommand}: launchd boots a service OUT by its
63
+ * label, and the plist it was booted in from may already be gone.
64
+ */
65
+ export declare function disarmCommand(platform: ServicePlatform, label: string): string;
66
+ /** Everything a unit is generated from, all of it already resolved. */
67
+ export interface ServicePlan {
68
+ platform: ServicePlatform;
69
+ label: string;
70
+ /** The unit file this would be written to. */
71
+ path: string;
72
+ /** The primary checkout the runtime is started in. */
73
+ workingDir: string;
74
+ /** The `approval` invocation, as argv words. */
75
+ exec: string[];
76
+ /** An operator-authored EnvironmentFile, or `null` for the `approval env` wrapper. */
77
+ envFile: string | null;
78
+ outLog: string;
79
+ errLog: string;
80
+ /** The variable NAMES the runtime will look for. Printed as a comment only. */
81
+ variables: string[];
82
+ }
83
+ /** One `sh -lc` script: the wrapper the operator reads inside the unit. */
84
+ export declare function wrapperScript(plan: ServicePlan): string;
85
+ /** The whole unit file, as the operator will read it and as it will be written. */
86
+ export declare function renderUnit(plan: ServicePlan): string;
87
+ /**
88
+ * The approval invocation this process was started as.
89
+ *
90
+ * `node dist/src/cli/main.js` and the installed `approval` bin are both
91
+ * legitimate, and a unit that named the wrong one would fail at login rather
92
+ * than here. `--exec` overrides for the case neither guess fits.
93
+ */
94
+ export declare function execWords(override: string | null, argv: readonly string[]): string[];
95
+ /** `approval setup service` — write the login unit. HUMAN-ONLY, INTERACTIVE. */
96
+ export declare function commandSetupService(argv: string[], streams: Streams, cwd: string, deps?: SetupDeps): number;