@camerontaylor/paseo-cli 0.8.0-fork.1

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 (288) hide show
  1. package/bin/paseo +3 -0
  2. package/dist/classify.d.ts +19 -0
  3. package/dist/classify.js +49 -0
  4. package/dist/cli.d.ts +3 -0
  5. package/dist/cli.js +135 -0
  6. package/dist/commands/agent/archive.d.ts +18 -0
  7. package/dist/commands/agent/archive.js +102 -0
  8. package/dist/commands/agent/attach.d.ts +11 -0
  9. package/dist/commands/agent/attach.js +161 -0
  10. package/dist/commands/agent/delete.d.ts +15 -0
  11. package/dist/commands/agent/delete.js +107 -0
  12. package/dist/commands/agent/detach.d.ts +9 -0
  13. package/dist/commands/agent/detach.js +38 -0
  14. package/dist/commands/agent/import.d.ts +14 -0
  15. package/dist/commands/agent/import.js +122 -0
  16. package/dist/commands/agent/index.d.ts +3 -0
  17. package/dist/commands/agent/index.js +56 -0
  18. package/dist/commands/agent/inspect.d.ts +15 -0
  19. package/dist/commands/agent/inspect.js +209 -0
  20. package/dist/commands/agent/logs.d.ts +19 -0
  21. package/dist/commands/agent/logs.js +180 -0
  22. package/dist/commands/agent/ls.d.ts +44 -0
  23. package/dist/commands/agent/ls.js +212 -0
  24. package/dist/commands/agent/mode.d.ts +18 -0
  25. package/dist/commands/agent/mode.js +100 -0
  26. package/dist/commands/agent/open.d.ts +11 -0
  27. package/dist/commands/agent/open.js +61 -0
  28. package/dist/commands/agent/reload.d.ts +15 -0
  29. package/dist/commands/agent/reload.js +75 -0
  30. package/dist/commands/agent/run.d.ts +78 -0
  31. package/dist/commands/agent/run.js +554 -0
  32. package/dist/commands/agent/send.d.ts +19 -0
  33. package/dist/commands/agent/send.js +187 -0
  34. package/dist/commands/agent/stop.d.ts +17 -0
  35. package/dist/commands/agent/stop.js +115 -0
  36. package/dist/commands/agent/update.d.ts +51 -0
  37. package/dist/commands/agent/update.js +186 -0
  38. package/dist/commands/agent/wait.d.ts +17 -0
  39. package/dist/commands/agent/wait.js +158 -0
  40. package/dist/commands/clone.d.ts +17 -0
  41. package/dist/commands/clone.js +65 -0
  42. package/dist/commands/daemon/index.d.ts +3 -0
  43. package/dist/commands/daemon/index.js +60 -0
  44. package/dist/commands/daemon/local-daemon.d.ts +78 -0
  45. package/dist/commands/daemon/local-daemon.js +547 -0
  46. package/dist/commands/daemon/pair.d.ts +35 -0
  47. package/dist/commands/daemon/pair.js +167 -0
  48. package/dist/commands/daemon/reload.d.ts +10 -0
  49. package/dist/commands/daemon/reload.js +36 -0
  50. package/dist/commands/daemon/restart.d.ts +12 -0
  51. package/dist/commands/daemon/restart.js +99 -0
  52. package/dist/commands/daemon/runtime-toolchain.d.ts +6 -0
  53. package/dist/commands/daemon/runtime-toolchain.js +87 -0
  54. package/dist/commands/daemon/set-password.d.ts +17 -0
  55. package/dist/commands/daemon/set-password.js +82 -0
  56. package/dist/commands/daemon/start.d.ts +6 -0
  57. package/dist/commands/daemon/start.js +57 -0
  58. package/dist/commands/daemon/status.d.ts +21 -0
  59. package/dist/commands/daemon/status.js +363 -0
  60. package/dist/commands/daemon/stop.d.ts +15 -0
  61. package/dist/commands/daemon/stop.js +60 -0
  62. package/dist/commands/heartbeat/index.d.ts +3 -0
  63. package/dist/commands/heartbeat/index.js +139 -0
  64. package/dist/commands/hooks.d.ts +19 -0
  65. package/dist/commands/hooks.js +89 -0
  66. package/dist/commands/hub/authority.d.ts +17 -0
  67. package/dist/commands/hub/authority.js +18 -0
  68. package/dist/commands/hub/connect.d.ts +23 -0
  69. package/dist/commands/hub/connect.js +44 -0
  70. package/dist/commands/hub/credentials.d.ts +21 -0
  71. package/dist/commands/hub/credentials.js +143 -0
  72. package/dist/commands/hub/daemon-client.d.ts +40 -0
  73. package/dist/commands/hub/daemon-client.js +14 -0
  74. package/dist/commands/hub/deploy-bundle.d.ts +16 -0
  75. package/dist/commands/hub/deploy-bundle.js +248 -0
  76. package/dist/commands/hub/deploy-triggers.d.ts +6 -0
  77. package/dist/commands/hub/deploy-triggers.js +116 -0
  78. package/dist/commands/hub/deploy.d.ts +50 -0
  79. package/dist/commands/hub/deploy.js +159 -0
  80. package/dist/commands/hub/disconnect.d.ts +16 -0
  81. package/dist/commands/hub/disconnect.js +24 -0
  82. package/dist/commands/hub/error.d.ts +6 -0
  83. package/dist/commands/hub/error.js +9 -0
  84. package/dist/commands/hub/export.d.ts +28 -0
  85. package/dist/commands/hub/export.js +80 -0
  86. package/dist/commands/hub/help.d.ts +3 -0
  87. package/dist/commands/hub/help.js +5 -0
  88. package/dist/commands/hub/hub-client/index.d.ts +22 -0
  89. package/dist/commands/hub/hub-client/index.js +135 -0
  90. package/dist/commands/hub/hub-client/internal/contracts.d.ts +126 -0
  91. package/dist/commands/hub/hub-client/internal/contracts.js +85 -0
  92. package/dist/commands/hub/hub-client/internal/problem.d.ts +3 -0
  93. package/dist/commands/hub/hub-client/internal/problem.js +85 -0
  94. package/dist/commands/hub/hub-client/internal/transport.d.ts +15 -0
  95. package/dist/commands/hub/hub-client/internal/transport.js +30 -0
  96. package/dist/commands/hub/index.d.ts +20 -0
  97. package/dist/commands/hub/index.js +94 -0
  98. package/dist/commands/hub/init-plan.d.ts +33 -0
  99. package/dist/commands/hub/init-plan.js +94 -0
  100. package/dist/commands/hub/init.d.ts +35 -0
  101. package/dist/commands/hub/init.js +524 -0
  102. package/dist/commands/hub/login-flow.d.ts +34 -0
  103. package/dist/commands/hub/login-flow.js +78 -0
  104. package/dist/commands/hub/login.d.ts +23 -0
  105. package/dist/commands/hub/login.js +40 -0
  106. package/dist/commands/hub/logout.d.ts +32 -0
  107. package/dist/commands/hub/logout.js +71 -0
  108. package/dist/commands/hub/origin.d.ts +2 -0
  109. package/dist/commands/hub/origin.js +27 -0
  110. package/dist/commands/hub/permissions.d.ts +21 -0
  111. package/dist/commands/hub/permissions.js +61 -0
  112. package/dist/commands/hub/projects.d.ts +24 -0
  113. package/dist/commands/hub/projects.js +49 -0
  114. package/dist/commands/hub/reporter.d.ts +10 -0
  115. package/dist/commands/hub/reporter.js +11 -0
  116. package/dist/commands/hub/starter-agent-runtime.d.ts +37 -0
  117. package/dist/commands/hub/starter-agent-runtime.js +49 -0
  118. package/dist/commands/hub/starter-trigger.d.ts +10 -0
  119. package/dist/commands/hub/starter-trigger.js +30 -0
  120. package/dist/commands/hub/status-output.d.ts +13 -0
  121. package/dist/commands/hub/status-output.js +30 -0
  122. package/dist/commands/onboard.d.ts +10 -0
  123. package/dist/commands/onboard.js +400 -0
  124. package/dist/commands/open.d.ts +4 -0
  125. package/dist/commands/open.js +89 -0
  126. package/dist/commands/permit/allow.d.ts +20 -0
  127. package/dist/commands/permit/allow.js +133 -0
  128. package/dist/commands/permit/deny.d.ts +12 -0
  129. package/dist/commands/permit/deny.js +105 -0
  130. package/dist/commands/permit/index.d.ts +3 -0
  131. package/dist/commands/permit/index.js +27 -0
  132. package/dist/commands/permit/ls.d.ts +18 -0
  133. package/dist/commands/permit/ls.js +66 -0
  134. package/dist/commands/plugin/index.d.ts +17 -0
  135. package/dist/commands/plugin/index.js +138 -0
  136. package/dist/commands/plugin/scaffold.d.ts +6 -0
  137. package/dist/commands/plugin/scaffold.js +162 -0
  138. package/dist/commands/plugin/shared.d.ts +5 -0
  139. package/dist/commands/plugin/shared.js +30 -0
  140. package/dist/commands/project/create.d.ts +10 -0
  141. package/dist/commands/project/create.js +41 -0
  142. package/dist/commands/project/delete.d.ts +9 -0
  143. package/dist/commands/project/delete.js +33 -0
  144. package/dist/commands/project/index.d.ts +3 -0
  145. package/dist/commands/project/index.js +28 -0
  146. package/dist/commands/project/ls.d.ts +5 -0
  147. package/dist/commands/project/ls.js +19 -0
  148. package/dist/commands/project/rename.d.ts +15 -0
  149. package/dist/commands/project/rename.js +50 -0
  150. package/dist/commands/project/shared.d.ts +11 -0
  151. package/dist/commands/project/shared.js +18 -0
  152. package/dist/commands/provider/add.d.ts +30 -0
  153. package/dist/commands/provider/add.js +123 -0
  154. package/dist/commands/provider/diagnostic.d.ts +12 -0
  155. package/dist/commands/provider/diagnostic.js +31 -0
  156. package/dist/commands/provider/index.d.ts +3 -0
  157. package/dist/commands/provider/index.js +38 -0
  158. package/dist/commands/provider/ls.d.ts +20 -0
  159. package/dist/commands/provider/ls.js +76 -0
  160. package/dist/commands/provider/models.d.ts +20 -0
  161. package/dist/commands/provider/models.js +53 -0
  162. package/dist/commands/provider/rm.d.ts +10 -0
  163. package/dist/commands/provider/rm.js +45 -0
  164. package/dist/commands/provider/shared.d.ts +7 -0
  165. package/dist/commands/provider/shared.js +10 -0
  166. package/dist/commands/schedule/create.d.ts +19 -0
  167. package/dist/commands/schedule/create.js +41 -0
  168. package/dist/commands/schedule/delete.d.ts +10 -0
  169. package/dist/commands/schedule/delete.js +32 -0
  170. package/dist/commands/schedule/index.d.ts +3 -0
  171. package/dist/commands/schedule/index.js +66 -0
  172. package/dist/commands/schedule/inspect.d.ts +6 -0
  173. package/dist/commands/schedule/inspect.js +27 -0
  174. package/dist/commands/schedule/logs.d.ts +6 -0
  175. package/dist/commands/schedule/logs.js +24 -0
  176. package/dist/commands/schedule/ls.d.ts +5 -0
  177. package/dist/commands/schedule/ls.js +25 -0
  178. package/dist/commands/schedule/pause.d.ts +5 -0
  179. package/dist/commands/schedule/pause.js +24 -0
  180. package/dist/commands/schedule/resume.d.ts +5 -0
  181. package/dist/commands/schedule/resume.js +24 -0
  182. package/dist/commands/schedule/run-once.d.ts +5 -0
  183. package/dist/commands/schedule/run-once.js +24 -0
  184. package/dist/commands/schedule/schema.d.ts +21 -0
  185. package/dist/commands/schedule/schema.js +67 -0
  186. package/dist/commands/schedule/shared.d.ts +59 -0
  187. package/dist/commands/schedule/shared.js +358 -0
  188. package/dist/commands/schedule/types.d.ts +165 -0
  189. package/dist/commands/schedule/types.js +2 -0
  190. package/dist/commands/schedule/update.d.ts +21 -0
  191. package/dist/commands/schedule/update.js +40 -0
  192. package/dist/commands/script/index.d.ts +3 -0
  193. package/dist/commands/script/index.js +19 -0
  194. package/dist/commands/script/ls.d.ts +6 -0
  195. package/dist/commands/script/ls.js +20 -0
  196. package/dist/commands/script/schema.d.ts +5 -0
  197. package/dist/commands/script/schema.js +13 -0
  198. package/dist/commands/script/shared.d.ts +11 -0
  199. package/dist/commands/script/shared.js +59 -0
  200. package/dist/commands/script/start.d.ts +6 -0
  201. package/dist/commands/script/start.js +23 -0
  202. package/dist/commands/script/stop.d.ts +6 -0
  203. package/dist/commands/script/stop.js +23 -0
  204. package/dist/commands/speech/index.d.ts +3 -0
  205. package/dist/commands/speech/index.js +5 -0
  206. package/dist/commands/terminal/capture.d.ts +10 -0
  207. package/dist/commands/terminal/capture.js +68 -0
  208. package/dist/commands/terminal/create.d.ts +11 -0
  209. package/dist/commands/terminal/create.js +29 -0
  210. package/dist/commands/terminal/index.d.ts +3 -0
  211. package/dist/commands/terminal/index.js +45 -0
  212. package/dist/commands/terminal/kill.d.ts +6 -0
  213. package/dist/commands/terminal/kill.js +36 -0
  214. package/dist/commands/terminal/ls.d.ts +11 -0
  215. package/dist/commands/terminal/ls.js +21 -0
  216. package/dist/commands/terminal/schema.d.ts +10 -0
  217. package/dist/commands/terminal/schema.js +17 -0
  218. package/dist/commands/terminal/send-keys.d.ts +7 -0
  219. package/dist/commands/terminal/send-keys.js +45 -0
  220. package/dist/commands/terminal/shared.d.ts +12 -0
  221. package/dist/commands/terminal/shared.js +62 -0
  222. package/dist/commands/workspace/archive.d.ts +12 -0
  223. package/dist/commands/workspace/archive.js +41 -0
  224. package/dist/commands/workspace/create.d.ts +49 -0
  225. package/dist/commands/workspace/create.js +114 -0
  226. package/dist/commands/workspace/index.d.ts +3 -0
  227. package/dist/commands/workspace/index.js +45 -0
  228. package/dist/commands/workspace/ls.d.ts +7 -0
  229. package/dist/commands/workspace/ls.js +28 -0
  230. package/dist/commands/workspace/rename.d.ts +22 -0
  231. package/dist/commands/workspace/rename.js +61 -0
  232. package/dist/commands/workspace/setup.d.ts +11 -0
  233. package/dist/commands/workspace/setup.js +41 -0
  234. package/dist/commands/workspace/shared.d.ts +12 -0
  235. package/dist/commands/workspace/shared.js +20 -0
  236. package/dist/commands/worktree/archive.d.ts +20 -0
  237. package/dist/commands/worktree/archive.js +104 -0
  238. package/dist/commands/worktree/create-input.d.ts +15 -0
  239. package/dist/commands/worktree/create-input.js +56 -0
  240. package/dist/commands/worktree/create.d.ts +11 -0
  241. package/dist/commands/worktree/create.js +58 -0
  242. package/dist/commands/worktree/index.d.ts +3 -0
  243. package/dist/commands/worktree/index.js +25 -0
  244. package/dist/commands/worktree/ls.d.ts +19 -0
  245. package/dist/commands/worktree/ls.js +97 -0
  246. package/dist/index.d.ts +2 -0
  247. package/dist/index.js +6 -0
  248. package/dist/output/index.d.ts +45 -0
  249. package/dist/output/index.js +47 -0
  250. package/dist/output/json.d.ts +11 -0
  251. package/dist/output/json.js +37 -0
  252. package/dist/output/pairing.d.ts +8 -0
  253. package/dist/output/pairing.js +24 -0
  254. package/dist/output/quiet.d.ts +9 -0
  255. package/dist/output/quiet.js +22 -0
  256. package/dist/output/render.d.ts +15 -0
  257. package/dist/output/render.js +84 -0
  258. package/dist/output/table.d.ts +13 -0
  259. package/dist/output/table.js +135 -0
  260. package/dist/output/types.d.ts +73 -0
  261. package/dist/output/types.js +8 -0
  262. package/dist/output/with-output.d.ts +41 -0
  263. package/dist/output/with-output.js +85 -0
  264. package/dist/output/yaml.d.ts +11 -0
  265. package/dist/output/yaml.js +38 -0
  266. package/dist/run.d.ts +14 -0
  267. package/dist/run.js +40 -0
  268. package/dist/ssh/ssh-tunnel.d.ts +9 -0
  269. package/dist/ssh/ssh-tunnel.js +79 -0
  270. package/dist/utils/client-id.d.ts +2 -0
  271. package/dist/utils/client-id.js +37 -0
  272. package/dist/utils/client.d.ts +54 -0
  273. package/dist/utils/client.js +363 -0
  274. package/dist/utils/command-options.d.ts +7 -0
  275. package/dist/utils/command-options.js +25 -0
  276. package/dist/utils/duration.d.ts +7 -0
  277. package/dist/utils/duration.js +39 -0
  278. package/dist/utils/errors.d.ts +5 -0
  279. package/dist/utils/errors.js +10 -0
  280. package/dist/utils/paths.d.ts +12 -0
  281. package/dist/utils/paths.js +22 -0
  282. package/dist/utils/provider-model.d.ts +11 -0
  283. package/dist/utils/provider-model.js +49 -0
  284. package/dist/utils/timeline.d.ts +11 -0
  285. package/dist/utils/timeline.js +11 -0
  286. package/dist/version.d.ts +2 -0
  287. package/dist/version.js +10 -0
  288. package/package.json +50 -0
@@ -0,0 +1,116 @@
1
+ import { lstat, readFile, readdir } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { HubCommandError } from "./error.js";
4
+ const TRIGGER_DIRECTORY = ".paseo/triggers";
5
+ export async function discoverHubTriggers(cwd) {
6
+ const root = path.resolve(cwd);
7
+ const directory = path.join(root, TRIGGER_DIRECTORY);
8
+ const paseoDirectory = await readStats(path.join(root, ".paseo"), {
9
+ code: "HUB_TRIGGER_DIRECTORY_MISSING",
10
+ message: `${TRIGGER_DIRECTORY} does not exist. Run this command from the project root.`,
11
+ });
12
+ if (paseoDirectory.isSymbolicLink())
13
+ throw unsafeTriggerPath(TRIGGER_DIRECTORY);
14
+ const directoryStats = await readTriggerDirectoryStats(root, directory);
15
+ if (directoryStats.isSymbolicLink())
16
+ throw unsafeTriggerPath(TRIGGER_DIRECTORY);
17
+ if (!directoryStats.isDirectory()) {
18
+ throw new HubCommandError("HUB_TRIGGER_DIRECTORY_INVALID", `${TRIGGER_DIRECTORY} must be a directory.`);
19
+ }
20
+ let entries;
21
+ try {
22
+ entries = await readdir(directory, { withFileTypes: true });
23
+ }
24
+ catch (error) {
25
+ if (!isExpectedReadError(error))
26
+ throw error;
27
+ throw unreadableTriggerPath(TRIGGER_DIRECTORY);
28
+ }
29
+ const triggers = [];
30
+ for (const entry of entries.toSorted((left, right) => left.name.localeCompare(right.name))) {
31
+ const triggerPath = `${TRIGGER_DIRECTORY}/${entry.name}`;
32
+ if (entry.isSymbolicLink())
33
+ throw unsafeTriggerPath(triggerPath);
34
+ if (!entry.isFile() || !entry.name.endsWith(".yml")) {
35
+ throw new HubCommandError("HUB_TRIGGER_PATH_UNSUPPORTED", `${triggerPath} must be a direct-child .yml trigger.`);
36
+ }
37
+ try {
38
+ triggers.push({
39
+ path: triggerPath,
40
+ yaml: await readFile(path.join(root, triggerPath), "utf8"),
41
+ });
42
+ }
43
+ catch (error) {
44
+ if (!isExpectedReadError(error))
45
+ throw error;
46
+ throw unreadableTriggerPath(triggerPath);
47
+ }
48
+ }
49
+ if (triggers.length === 0) {
50
+ throw new HubCommandError("HUB_TRIGGER_MISSING", `${TRIGGER_DIRECTORY} must contain at least one direct-child .yml trigger.`);
51
+ }
52
+ return triggers;
53
+ }
54
+ async function readTriggerDirectoryStats(root, directory) {
55
+ try {
56
+ return await lstat(directory);
57
+ }
58
+ catch (error) {
59
+ if (errorCode(error) !== "ENOENT") {
60
+ if (!isExpectedReadError(error))
61
+ throw error;
62
+ throw unreadableTriggerPath(TRIGGER_DIRECTORY);
63
+ }
64
+ if (await legacyBundleExists(root)) {
65
+ throw new HubCommandError("HUB_PROJECT_REQUIRED", "This directory contains a legacy .paseo/hub.yml bundle. Pass --project <slug> to deploy it.");
66
+ }
67
+ throw new HubCommandError("HUB_TRIGGER_DIRECTORY_MISSING", `${TRIGGER_DIRECTORY} does not exist. Run this command from the project root.`);
68
+ }
69
+ }
70
+ async function legacyBundleExists(root) {
71
+ try {
72
+ await lstat(path.join(root, ".paseo/hub.yml"));
73
+ return true;
74
+ }
75
+ catch (error) {
76
+ if (errorCode(error) === "ENOENT")
77
+ return false;
78
+ if (!isExpectedReadError(error))
79
+ throw error;
80
+ throw unreadableTriggerPath(".paseo/hub.yml");
81
+ }
82
+ }
83
+ async function readStats(target, missing) {
84
+ try {
85
+ return await lstat(target);
86
+ }
87
+ catch (error) {
88
+ if (errorCode(error) === "ENOENT")
89
+ throw new HubCommandError(missing.code, missing.message);
90
+ if (!isExpectedReadError(error))
91
+ throw error;
92
+ throw unreadableTriggerPath(TRIGGER_DIRECTORY);
93
+ }
94
+ }
95
+ function unsafeTriggerPath(triggerPath) {
96
+ return new HubCommandError("HUB_TRIGGER_UNSAFE_PATH", `${triggerPath} must not use a symlink.`);
97
+ }
98
+ function unreadableTriggerPath(triggerPath) {
99
+ return new HubCommandError("HUB_TRIGGER_UNREADABLE", `Could not read ${triggerPath}. Check the file and permissions.`);
100
+ }
101
+ function errorCode(error) {
102
+ if (typeof error !== "object" || error === null)
103
+ return undefined;
104
+ const code = Reflect.get(error, "code");
105
+ return typeof code === "string" ? code : undefined;
106
+ }
107
+ function isExpectedReadError(error) {
108
+ const code = errorCode(error);
109
+ return (code === "EACCES" ||
110
+ code === "EPERM" ||
111
+ code === "ENOENT" ||
112
+ code === "ENOTDIR" ||
113
+ code === "ELOOP" ||
114
+ code === "EISDIR");
115
+ }
116
+ //# sourceMappingURL=deploy-triggers.js.map
@@ -0,0 +1,50 @@
1
+ import type { Command } from "commander";
2
+ import { type ListResult, type SingleResult } from "../../output/index.js";
3
+ import { HubHttpClient, type HubInstallResult, type HubTriggerInstallationResult, type HubTriggerValidationResult, type HubValidationResult } from "./hub-client/index.js";
4
+ import { type HubCredentialStore } from "./credentials.js";
5
+ import { type HubDeployBundle } from "./deploy-bundle.js";
6
+ import { type HubDeployTrigger } from "./deploy-triggers.js";
7
+ import { type HubReporter } from "./reporter.js";
8
+ export interface HubDeployOptions {
9
+ project?: string;
10
+ hub?: string;
11
+ apiKey?: string;
12
+ dryRun?: boolean;
13
+ json?: boolean;
14
+ }
15
+ export interface HubDeployEnvironment {
16
+ cwd: string;
17
+ env: Readonly<Record<string, string | undefined>>;
18
+ credentials?: HubCredentialStore;
19
+ hub?: Pick<HubHttpClient, "installConfiguration" | "validateConfiguration" | "installTrigger" | "validateTrigger">;
20
+ reporter?: HubReporter;
21
+ }
22
+ export interface HubDeployCommandDependencies {
23
+ env: Readonly<Record<string, string | undefined>>;
24
+ credentials: HubCredentialStore;
25
+ hub: Pick<HubHttpClient, "installConfiguration" | "validateConfiguration" | "installTrigger" | "validateTrigger">;
26
+ reporter: HubReporter;
27
+ cwd(): string;
28
+ }
29
+ interface HubDeployResult extends HubInstallResult {
30
+ origin: string;
31
+ workflows: number;
32
+ }
33
+ interface HubDryRunResult extends HubValidationResult {
34
+ origin: string;
35
+ workflows: number;
36
+ }
37
+ interface HubTriggerDeployResult extends HubTriggerInstallationResult {
38
+ origin: string;
39
+ path: string;
40
+ }
41
+ interface HubTriggerDryRunResult extends HubTriggerValidationResult {
42
+ origin: string;
43
+ path: string;
44
+ }
45
+ export declare function runHubDeploy(options: HubDeployOptions, environment?: HubDeployEnvironment): Promise<SingleResult<HubDeployResult> | SingleResult<HubDryRunResult> | ListResult<HubTriggerDeployResult> | ListResult<HubTriggerDryRunResult>>;
46
+ export declare function runHubDeployTriggers(options: HubDeployOptions, triggers: readonly HubDeployTrigger[], environment: HubDeployEnvironment): Promise<ListResult<HubTriggerDeployResult> | ListResult<HubTriggerDryRunResult>>;
47
+ export declare function runHubDeployBundle(options: HubDeployOptions, deployInput: HubDeployBundle, environment: HubDeployEnvironment): Promise<SingleResult<HubDeployResult> | SingleResult<HubDryRunResult>>;
48
+ export declare function addHubDeployCommand(hub: Command, dependencies: HubDeployCommandDependencies): void;
49
+ export {};
50
+ //# sourceMappingURL=deploy.d.ts.map
@@ -0,0 +1,159 @@
1
+ import { withOutput, } from "../../output/index.js";
2
+ import { addJsonOption } from "../../utils/command-options.js";
3
+ import { resolveHubCredential, resolveHubOrigin } from "./authority.js";
4
+ import { HubHttpClient, } from "./hub-client/index.js";
5
+ import { PrivateHubCredentialStore } from "./credentials.js";
6
+ import { discoverHubBundle } from "./deploy-bundle.js";
7
+ import { discoverHubTriggers } from "./deploy-triggers.js";
8
+ import { HubCommandError } from "./error.js";
9
+ import { processHubReporter, reportHubProgress } from "./reporter.js";
10
+ import { addHubResolutionHelp } from "./help.js";
11
+ const resultSchema = {
12
+ idField: "versionId",
13
+ columns: [
14
+ { header: "PROJECT", field: "projectSlug" },
15
+ { header: "VERSION", field: "version" },
16
+ { header: "VERSION ID", field: "versionId" },
17
+ { header: "ACTIVE", field: "active" },
18
+ { header: "WORKFLOWS", field: "workflows" },
19
+ { header: "HUB", field: "origin" },
20
+ ],
21
+ };
22
+ const validationSchema = {
23
+ idField: "projectSlug",
24
+ columns: [
25
+ { header: "PROJECT", field: "projectSlug" },
26
+ { header: "VALID", field: "valid" },
27
+ { header: "WORKFLOWS", field: "workflows" },
28
+ { header: "HUB", field: "origin" },
29
+ ],
30
+ };
31
+ const triggerResultSchema = {
32
+ idField: "triggerId",
33
+ columns: [
34
+ { header: "TRIGGER", field: "name" },
35
+ { header: "VERSION", field: "version" },
36
+ { header: "REVISION ID", field: "revisionId" },
37
+ { header: "ACTIVE", field: "active" },
38
+ { header: "PATH", field: "path" },
39
+ { header: "HUB", field: "origin" },
40
+ ],
41
+ };
42
+ const triggerValidationSchema = {
43
+ idField: "name",
44
+ columns: [
45
+ { header: "TRIGGER", field: "name" },
46
+ { header: "VALID", field: "valid" },
47
+ { header: "PATH", field: "path" },
48
+ { header: "HUB", field: "origin" },
49
+ ],
50
+ };
51
+ export async function runHubDeploy(options, environment = {
52
+ cwd: process.cwd(),
53
+ env: process.env,
54
+ credentials: new PrivateHubCredentialStore(),
55
+ hub: new HubHttpClient(),
56
+ }) {
57
+ if (options.project === undefined) {
58
+ return runHubDeployTriggers(options, await discoverHubTriggers(environment.cwd), environment);
59
+ }
60
+ const deployInput = await discoverHubBundle({
61
+ cwd: environment.cwd,
62
+ project: options.project,
63
+ });
64
+ return runHubDeployBundle(options, deployInput, environment);
65
+ }
66
+ export async function runHubDeployTriggers(options, triggers, environment) {
67
+ const credentials = environment.credentials ?? new PrivateHubCredentialStore(environment.env);
68
+ const resolution = {
69
+ options: { origin: options.hub, apiKey: options.apiKey },
70
+ env: environment.env,
71
+ credentials,
72
+ };
73
+ const origin = resolveHubOrigin(resolution);
74
+ const credential = resolveHubCredential({ ...resolution, origin });
75
+ const action = options.dryRun === true ? "Validating" : "Deploying";
76
+ reportHubProgress(environment.reporter ?? processHubReporter, options, `${action} ${String(triggers.length)} trigger${triggers.length === 1 ? "" : "s"} ${options.dryRun === true ? "against" : "to"} ${origin}`);
77
+ const hub = environment.hub ?? new HubHttpClient();
78
+ if (options.dryRun === true) {
79
+ const data = await Promise.all(triggers.map(async (trigger) => ({
80
+ ...(await hub.validateTrigger(origin, credential, trigger.yaml)),
81
+ origin,
82
+ path: trigger.path,
83
+ })));
84
+ return { type: "list", data, schema: triggerValidationSchema };
85
+ }
86
+ await Promise.all(triggers.map((trigger) => hub.validateTrigger(origin, credential, trigger.yaml)));
87
+ const data = [];
88
+ for (const trigger of triggers) {
89
+ try {
90
+ data.push({
91
+ ...(await hub.installTrigger(origin, credential, trigger.yaml)),
92
+ origin,
93
+ path: trigger.path,
94
+ });
95
+ }
96
+ catch (error) {
97
+ if (data.length === 0)
98
+ throw error;
99
+ throw new HubCommandError("HUB_TRIGGER_DEPLOY_PARTIAL", `Could not deploy ${trigger.path} after ${String(data.length)} trigger${data.length === 1 ? "" : "s"} had been installed.`, `${errorMessage(error)}\nInstalled before the failure:\n${data.map(({ path: installedPath }) => `- ${installedPath}`).join("\n")}`);
100
+ }
101
+ }
102
+ return { type: "list", data, schema: triggerResultSchema };
103
+ }
104
+ function errorMessage(error) {
105
+ if (error instanceof HubCommandError) {
106
+ return error.details === undefined ? error.message : `${error.message}\n${error.details}`;
107
+ }
108
+ return error instanceof Error ? error.message : String(error);
109
+ }
110
+ export async function runHubDeployBundle(options, deployInput, environment) {
111
+ const credentials = environment.credentials ?? new PrivateHubCredentialStore(environment.env);
112
+ const resolution = {
113
+ options: { origin: options.hub, apiKey: options.apiKey },
114
+ env: environment.env,
115
+ credentials,
116
+ };
117
+ const origin = resolveHubOrigin(resolution);
118
+ const action = options.dryRun === true ? "Validating" : "Deploying";
119
+ reportHubProgress(environment.reporter ?? processHubReporter, options, `${action} ${deployInput.projectSlug} ${options.dryRun === true ? "against" : "to"} ${origin}`);
120
+ const credential = resolveHubCredential({ ...resolution, origin });
121
+ const request = {
122
+ origin,
123
+ apiKey: credential,
124
+ ...deployInput,
125
+ };
126
+ if (options.dryRun === true) {
127
+ const validated = await (environment.hub ?? new HubHttpClient()).validateConfiguration(request);
128
+ return {
129
+ type: "single",
130
+ data: { ...validated, workflows: deployInput.workflowCount, origin },
131
+ schema: validationSchema,
132
+ };
133
+ }
134
+ const deployed = await (environment.hub ?? new HubHttpClient()).installConfiguration(request);
135
+ return {
136
+ type: "single",
137
+ data: { ...deployed, workflows: deployInput.workflowCount, origin },
138
+ schema: resultSchema,
139
+ };
140
+ }
141
+ export function addHubDeployCommand(hub, dependencies) {
142
+ addJsonOption(addHubResolutionHelp(hub
143
+ .command("deploy")
144
+ .description("Deploy .paseo organization triggers or a legacy project bundle")
145
+ .option("-p, --project <slug>", "Deploy a legacy bundle to this project slug")
146
+ .option("--hub <origin>", "Paseo Hub origin")
147
+ .option("--api-key <secret>", "Organization API key")
148
+ .option("--dry-run", "Validate without installing or activating"))).action(withOutput(async (...args) => {
149
+ const options = args.at(-2);
150
+ return runHubDeploy(options, {
151
+ cwd: dependencies.cwd(),
152
+ env: dependencies.env,
153
+ credentials: dependencies.credentials,
154
+ hub: dependencies.hub,
155
+ reporter: dependencies.reporter,
156
+ });
157
+ }));
158
+ }
159
+ //# sourceMappingURL=deploy.js.map
@@ -0,0 +1,16 @@
1
+ import type { Command } from "commander";
2
+ import type { HubDaemonConnection } from "./daemon-client.js";
3
+ import { type HubReporter } from "./reporter.js";
4
+ interface HubDisconnectOptions {
5
+ force?: boolean;
6
+ host?: string;
7
+ json?: boolean;
8
+ }
9
+ interface HubDisconnectDependencies {
10
+ daemon: HubDaemonConnection;
11
+ reporter: HubReporter;
12
+ }
13
+ export declare function runHubDisconnect(options: HubDisconnectOptions, dependencies: HubDisconnectDependencies): Promise<import("../../output/types.js").ListResult<import("./status-output.js").HubRow>>;
14
+ export declare function addHubDisconnectCommand(parent: Command, dependencies: HubDisconnectDependencies): void;
15
+ export {};
16
+ //# sourceMappingURL=disconnect.d.ts.map
@@ -0,0 +1,24 @@
1
+ import { withOutput } from "../../output/index.js";
2
+ import { addJsonAndDaemonHostOptions } from "../../utils/command-options.js";
3
+ import { withHubDaemon } from "./daemon-client.js";
4
+ import { reportHubProgress } from "./reporter.js";
5
+ import { hubStatusResult } from "./status-output.js";
6
+ export function runHubDisconnect(options, dependencies) {
7
+ return withHubDaemon(dependencies.daemon, options.host, async (client) => {
8
+ const current = (await client.getHubStatus()).status;
9
+ if (current.hubOrigin !== null) {
10
+ reportHubProgress(dependencies.reporter, options, `Disconnecting this daemon from ${current.hubOrigin}`);
11
+ }
12
+ const response = await client.disconnectHub(options.force ?? false);
13
+ return hubStatusResult(response.status, response.warning);
14
+ });
15
+ }
16
+ export function addHubDisconnectCommand(parent, dependencies) {
17
+ addJsonAndDaemonHostOptions(parent
18
+ .command("disconnect")
19
+ .option("--force", "Remove local authority without notifying the Hub")).action(withOutput(async (...args) => {
20
+ const options = args.at(-2);
21
+ return runHubDisconnect(options, dependencies);
22
+ }));
23
+ }
24
+ //# sourceMappingURL=disconnect.js.map
@@ -0,0 +1,6 @@
1
+ export declare class HubCommandError extends Error {
2
+ readonly code: string;
3
+ readonly details?: string | undefined;
4
+ constructor(code: string, message: string, details?: string | undefined);
5
+ }
6
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1,9 @@
1
+ export class HubCommandError extends Error {
2
+ constructor(code, message, details) {
3
+ super(message);
4
+ this.code = code;
5
+ this.details = details;
6
+ this.name = "HubCommandError";
7
+ }
8
+ }
9
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1,28 @@
1
+ import type { Command } from "commander";
2
+ import { type SingleResult } from "../../output/index.js";
3
+ import type { HubCredentialStore } from "./credentials.js";
4
+ import type { HubHttpClient } from "./hub-client/index.js";
5
+ import { type HubReporter } from "./reporter.js";
6
+ interface HubExportResult {
7
+ origin: string;
8
+ directory: string;
9
+ exported: number;
10
+ unchanged: number;
11
+ }
12
+ export interface HubExportOptions {
13
+ hub?: string;
14
+ apiKey?: string;
15
+ force?: boolean;
16
+ json?: boolean;
17
+ }
18
+ interface HubExportDependencies {
19
+ env: Readonly<Record<string, string | undefined>>;
20
+ credentials: HubCredentialStore;
21
+ hub: Pick<HubHttpClient, "listTriggers">;
22
+ reporter: HubReporter;
23
+ cwd(): string;
24
+ }
25
+ export declare function runHubExport(directoryInput: string | undefined, options: HubExportOptions, dependencies: HubExportDependencies): Promise<SingleResult<HubExportResult>>;
26
+ export declare function addHubExportCommand(parent: Command, dependencies: HubExportDependencies): void;
27
+ export {};
28
+ //# sourceMappingURL=export.d.ts.map
@@ -0,0 +1,80 @@
1
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { withOutput } from "../../output/index.js";
4
+ import { addJsonOption } from "../../utils/command-options.js";
5
+ import { resolveHubCredential, resolveHubOrigin } from "./authority.js";
6
+ import { HubCommandError } from "./error.js";
7
+ import { addHubResolutionHelp } from "./help.js";
8
+ import { reportHubProgress } from "./reporter.js";
9
+ const schema = {
10
+ idField: "directory",
11
+ columns: [
12
+ { header: "DIRECTORY", field: "directory" },
13
+ { header: "EXPORTED", field: "exported" },
14
+ { header: "UNCHANGED", field: "unchanged" },
15
+ { header: "HUB", field: "origin" },
16
+ ],
17
+ };
18
+ export async function runHubExport(directoryInput, options, dependencies) {
19
+ const resolution = {
20
+ options: { origin: options.hub, apiKey: options.apiKey },
21
+ env: dependencies.env,
22
+ credentials: dependencies.credentials,
23
+ };
24
+ const origin = resolveHubOrigin(resolution);
25
+ const credential = resolveHubCredential({ ...resolution, origin });
26
+ const directory = path.resolve(dependencies.cwd(), directoryInput ?? ".paseo/triggers");
27
+ reportHubProgress(dependencies.reporter, options, `Exporting triggers from ${origin}`);
28
+ const triggers = await dependencies.hub.listTriggers(origin, credential);
29
+ await mkdir(directory, { recursive: true });
30
+ const files = await Promise.all(triggers.map(async (trigger) => {
31
+ const destination = path.join(directory, `${trigger.name}.yml`);
32
+ return { destination, trigger, existing: await readOptionalFile(destination) };
33
+ }));
34
+ const conflict = files.find(({ existing, trigger }) => existing !== undefined && existing !== trigger.yaml && options.force !== true);
35
+ if (conflict !== undefined) {
36
+ throw new HubCommandError("HUB_EXPORT_CONFLICT", `${conflict.destination} already exists with different contents. Pass --force to replace it.`);
37
+ }
38
+ for (const file of files) {
39
+ if (file.existing === file.trigger.yaml)
40
+ continue;
41
+ await writeFile(file.destination, file.trigger.yaml, file.existing === undefined ? { flag: "wx" } : undefined);
42
+ }
43
+ return {
44
+ type: "single",
45
+ data: {
46
+ origin,
47
+ directory,
48
+ exported: files.filter(({ existing, trigger }) => existing !== trigger.yaml).length,
49
+ unchanged: files.filter(({ existing, trigger }) => existing === trigger.yaml).length,
50
+ },
51
+ schema,
52
+ };
53
+ }
54
+ export function addHubExportCommand(parent, dependencies) {
55
+ addJsonOption(addHubResolutionHelp(parent
56
+ .command("export")
57
+ .description("Export active Hub triggers as one YAML file per trigger")
58
+ .argument("[directory]", "Destination directory", ".paseo/triggers")
59
+ .option("--hub <origin>", "Paseo Hub origin")
60
+ .option("--api-key <secret>", "Organization API key")
61
+ .option("--force", "Replace trigger files with different contents"))).action(withOutput(async (...args) => {
62
+ const directory = args[0];
63
+ const options = args.at(-2);
64
+ return runHubExport(directory, options, dependencies);
65
+ }));
66
+ }
67
+ async function readOptionalFile(filePath) {
68
+ try {
69
+ return await readFile(filePath, "utf8");
70
+ }
71
+ catch (error) {
72
+ if (isMissingFile(error))
73
+ return undefined;
74
+ throw error;
75
+ }
76
+ }
77
+ function isMissingFile(error) {
78
+ return error instanceof Error && "code" in error && error.code === "ENOENT";
79
+ }
80
+ //# sourceMappingURL=export.js.map
@@ -0,0 +1,3 @@
1
+ import type { Command } from "commander";
2
+ export declare function addHubResolutionHelp(command: Command): Command;
3
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1,5 @@
1
+ const resolutionHelp = "\nHub origin precedence: command origin/--hub, PASEO_HUB_URL, active stored login, then https://hub.paseo.sh.\nCredential precedence: --api-key, PASEO_HUB_API_KEY, then a stored login for the exact resolved origin.\n";
2
+ export function addHubResolutionHelp(command) {
3
+ return command.addHelpText("after", resolutionHelp);
4
+ }
5
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1,22 @@
1
+ import type { HubBundleFile } from "../deploy-bundle.js";
2
+ import { type CliAuthorization, type CliAuthorizationPoll, type HubInstallResult, type HubConfigurationResources, type HubProject, type HubTrigger, type HubTriggerInstallationResult, type HubTriggerValidationResult, type HubValidationResult } from "./internal/contracts.js";
3
+ export type { CliAuthorization, CliAuthorizationPoll, HubInstallResult, HubConfigurationResources, HubProject, HubTrigger, HubTriggerInstallationResult, HubTriggerValidationResult, HubValidationResult, } from "./internal/contracts.js";
4
+ interface HubConfigurationInput {
5
+ origin: string;
6
+ apiKey: string;
7
+ projectSlug: string;
8
+ files: readonly HubBundleFile[];
9
+ }
10
+ export declare class HubHttpClient {
11
+ startCliAuthorization(origin: string): Promise<CliAuthorization>;
12
+ pollCliAuthorization(origin: string, deviceCode: string, timeoutMilliseconds: number): Promise<CliAuthorizationPoll>;
13
+ listProjects(origin: string, apiKey: string): Promise<HubProject[]>;
14
+ listTriggers(origin: string, apiKey: string): Promise<HubTrigger[]>;
15
+ validateTrigger(origin: string, apiKey: string, yaml: string): Promise<HubTriggerValidationResult>;
16
+ installTrigger(origin: string, apiKey: string, yaml: string): Promise<HubTriggerInstallationResult>;
17
+ listConfigurationResources(origin: string, apiKey: string): Promise<HubConfigurationResources>;
18
+ installConfiguration(input: HubConfigurationInput): Promise<HubInstallResult>;
19
+ validateConfiguration(input: HubConfigurationInput): Promise<HubValidationResult>;
20
+ issueEnrollmentToken(origin: string, apiKey: string): Promise<string>;
21
+ }
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,135 @@
1
+ import { HubCommandError } from "../error.js";
2
+ import { authorizationPollSchema, authorizationSchema, configurationResourcesSchema, enrollmentTokenSchema, installResponseSchema, projectsResponseSchema, triggersResponseSchema, triggerInstallationResponseSchema, triggerValidationResponseSchema, validationResponseSchema, } from "./internal/contracts.js";
3
+ import { requestHub } from "./internal/transport.js";
4
+ export class HubHttpClient {
5
+ startCliAuthorization(origin) {
6
+ return requestHub({
7
+ origin,
8
+ path: "/api/v1/cli-authorizations",
9
+ method: "POST",
10
+ body: {},
11
+ successStatus: 201,
12
+ schema: authorizationSchema,
13
+ failureMessage: "Hub CLI login could not be started",
14
+ });
15
+ }
16
+ async pollCliAuthorization(origin, deviceCode, timeoutMilliseconds) {
17
+ try {
18
+ return await requestHub({
19
+ origin,
20
+ path: "/api/v1/cli-authorizations/poll",
21
+ method: "POST",
22
+ body: { deviceCode },
23
+ successStatus: 200,
24
+ schema: authorizationPollSchema,
25
+ timeoutMilliseconds,
26
+ failureMessage: "Hub CLI login polling failed",
27
+ });
28
+ }
29
+ catch (error) {
30
+ if (error instanceof HubCommandError && error.code === "HUB_NETWORK_ERROR") {
31
+ return { status: "retry_later" };
32
+ }
33
+ throw error;
34
+ }
35
+ }
36
+ async listProjects(origin, apiKey) {
37
+ const response = await requestHub({
38
+ origin,
39
+ path: "/api/v1/projects",
40
+ method: "GET",
41
+ apiKey,
42
+ successStatus: 200,
43
+ schema: projectsResponseSchema,
44
+ failureMessage: "Hub project listing failed",
45
+ });
46
+ return response.projects;
47
+ }
48
+ async listTriggers(origin, apiKey) {
49
+ const response = await requestHub({
50
+ origin,
51
+ path: "/api/v1/triggers",
52
+ method: "GET",
53
+ apiKey,
54
+ successStatus: 200,
55
+ schema: triggersResponseSchema,
56
+ failureMessage: "Hub trigger export failed",
57
+ });
58
+ return response.triggers;
59
+ }
60
+ validateTrigger(origin, apiKey, yaml) {
61
+ return requestHub({
62
+ origin,
63
+ path: "/api/v1/triggers/validate",
64
+ method: "POST",
65
+ apiKey,
66
+ body: { yaml },
67
+ successStatus: 200,
68
+ schema: triggerValidationResponseSchema,
69
+ failureMessage: "Hub trigger validation failed",
70
+ });
71
+ }
72
+ installTrigger(origin, apiKey, yaml) {
73
+ return requestHub({
74
+ origin,
75
+ path: "/api/v1/triggers/install",
76
+ method: "POST",
77
+ apiKey,
78
+ body: { yaml },
79
+ successStatus: 201,
80
+ schema: triggerInstallationResponseSchema,
81
+ failureMessage: "Hub trigger deployment failed",
82
+ });
83
+ }
84
+ listConfigurationResources(origin, apiKey) {
85
+ return requestHub({
86
+ origin,
87
+ path: "/api/v1/configuration-resources",
88
+ method: "GET",
89
+ apiKey,
90
+ successStatus: 200,
91
+ schema: configurationResourcesSchema,
92
+ failureMessage: "Hub configuration resource listing failed",
93
+ });
94
+ }
95
+ installConfiguration(input) {
96
+ return requestHub({
97
+ origin: input.origin,
98
+ path: "/api/v1/configurations/install",
99
+ method: "POST",
100
+ apiKey: input.apiKey,
101
+ body: configurationBody(input),
102
+ successStatus: 201,
103
+ schema: installResponseSchema,
104
+ failureMessage: "Hub deployment failed",
105
+ });
106
+ }
107
+ validateConfiguration(input) {
108
+ return requestHub({
109
+ origin: input.origin,
110
+ path: "/api/v1/configurations/validate",
111
+ method: "POST",
112
+ apiKey: input.apiKey,
113
+ body: configurationBody(input),
114
+ successStatus: 200,
115
+ schema: validationResponseSchema,
116
+ failureMessage: "Hub configuration validation failed",
117
+ });
118
+ }
119
+ async issueEnrollmentToken(origin, apiKey) {
120
+ const response = await requestHub({
121
+ origin,
122
+ path: "/api/v1/daemons/enrollment-tokens",
123
+ method: "POST",
124
+ apiKey,
125
+ successStatus: 201,
126
+ schema: enrollmentTokenSchema,
127
+ failureMessage: "Hub daemon enrollment authorization failed",
128
+ });
129
+ return response.token;
130
+ }
131
+ }
132
+ function configurationBody(input) {
133
+ return { projectSlug: input.projectSlug, files: input.files };
134
+ }
135
+ //# sourceMappingURL=index.js.map