@getmateo/cli 0.0.0-stage → 0.19.7

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 (304) hide show
  1. package/LICENSE +211 -0
  2. package/bin/mateo +3 -0
  3. package/dist/classify.d.ts +19 -0
  4. package/dist/classify.js +49 -0
  5. package/dist/cli.d.ts +3 -0
  6. package/dist/cli.js +143 -0
  7. package/dist/commands/agent/archive.d.ts +27 -0
  8. package/dist/commands/agent/archive.js +88 -0
  9. package/dist/commands/agent/attach.d.ts +8 -0
  10. package/dist/commands/agent/attach.js +160 -0
  11. package/dist/commands/agent/delete.d.ts +15 -0
  12. package/dist/commands/agent/delete.js +104 -0
  13. package/dist/commands/agent/detach.d.ts +16 -0
  14. package/dist/commands/agent/detach.js +44 -0
  15. package/dist/commands/agent/import.d.ts +14 -0
  16. package/dist/commands/agent/import.js +108 -0
  17. package/dist/commands/agent/index.d.ts +3 -0
  18. package/dist/commands/agent/index.js +56 -0
  19. package/dist/commands/agent/inspect.d.ts +15 -0
  20. package/dist/commands/agent/inspect.js +196 -0
  21. package/dist/commands/agent/logs.d.ts +39 -0
  22. package/dist/commands/agent/logs.js +369 -0
  23. package/dist/commands/agent/ls.d.ts +61 -0
  24. package/dist/commands/agent/ls.js +201 -0
  25. package/dist/commands/agent/mode.d.ts +18 -0
  26. package/dist/commands/agent/mode.js +100 -0
  27. package/dist/commands/agent/open.d.ts +11 -0
  28. package/dist/commands/agent/open.js +74 -0
  29. package/dist/commands/agent/reload.d.ts +25 -0
  30. package/dist/commands/agent/reload.js +64 -0
  31. package/dist/commands/agent/run.d.ts +77 -0
  32. package/dist/commands/agent/run.js +556 -0
  33. package/dist/commands/agent/send.d.ts +21 -0
  34. package/dist/commands/agent/send.js +187 -0
  35. package/dist/commands/agent/stop.d.ts +17 -0
  36. package/dist/commands/agent/stop.js +102 -0
  37. package/dist/commands/agent/update.d.ts +51 -0
  38. package/dist/commands/agent/update.js +173 -0
  39. package/dist/commands/agent/wait.d.ts +31 -0
  40. package/dist/commands/agent/wait.js +161 -0
  41. package/dist/commands/clone.d.ts +17 -0
  42. package/dist/commands/clone.js +59 -0
  43. package/dist/commands/daemon/config.d.ts +3 -0
  44. package/dist/commands/daemon/config.js +103 -0
  45. package/dist/commands/daemon/index.d.ts +3 -0
  46. package/dist/commands/daemon/index.js +28 -0
  47. package/dist/commands/daemon/local-daemon.d.ts +13 -0
  48. package/dist/commands/daemon/local-daemon.js +105 -0
  49. package/dist/commands/daemon/pair.d.ts +30 -0
  50. package/dist/commands/daemon/pair.js +145 -0
  51. package/dist/commands/daemon/reload.d.ts +12 -0
  52. package/dist/commands/daemon/reload.js +44 -0
  53. package/dist/commands/daemon/restart.d.ts +29 -0
  54. package/dist/commands/daemon/restart.js +169 -0
  55. package/dist/commands/daemon/runtime-toolchain.d.ts +6 -0
  56. package/dist/commands/daemon/runtime-toolchain.js +87 -0
  57. package/dist/commands/daemon/set-password.d.ts +17 -0
  58. package/dist/commands/daemon/set-password.js +89 -0
  59. package/dist/commands/daemon/start.d.ts +20 -0
  60. package/dist/commands/daemon/start.js +52 -0
  61. package/dist/commands/daemon/status.d.ts +13 -0
  62. package/dist/commands/daemon/status.js +119 -0
  63. package/dist/commands/daemon/stop.d.ts +20 -0
  64. package/dist/commands/daemon/stop.js +58 -0
  65. package/dist/commands/fleet/index.d.ts +4 -0
  66. package/dist/commands/fleet/index.js +57 -0
  67. package/dist/commands/heartbeat/index.d.ts +3 -0
  68. package/dist/commands/heartbeat/index.js +139 -0
  69. package/dist/commands/hooks.d.ts +19 -0
  70. package/dist/commands/hooks.js +89 -0
  71. package/dist/commands/hub/authority.d.ts +17 -0
  72. package/dist/commands/hub/authority.js +18 -0
  73. package/dist/commands/hub/connect.d.ts +24 -0
  74. package/dist/commands/hub/connect.js +44 -0
  75. package/dist/commands/hub/credentials.d.ts +21 -0
  76. package/dist/commands/hub/credentials.js +143 -0
  77. package/dist/commands/hub/daemon-client.d.ts +41 -0
  78. package/dist/commands/hub/daemon-client.js +14 -0
  79. package/dist/commands/hub/deploy-bundle.d.ts +16 -0
  80. package/dist/commands/hub/deploy-bundle.js +248 -0
  81. package/dist/commands/hub/deploy-triggers.d.ts +6 -0
  82. package/dist/commands/hub/deploy-triggers.js +116 -0
  83. package/dist/commands/hub/deploy.d.ts +50 -0
  84. package/dist/commands/hub/deploy.js +159 -0
  85. package/dist/commands/hub/disconnect.d.ts +17 -0
  86. package/dist/commands/hub/disconnect.js +24 -0
  87. package/dist/commands/hub/error.d.ts +6 -0
  88. package/dist/commands/hub/error.js +9 -0
  89. package/dist/commands/hub/export.d.ts +28 -0
  90. package/dist/commands/hub/export.js +80 -0
  91. package/dist/commands/hub/help.d.ts +3 -0
  92. package/dist/commands/hub/help.js +5 -0
  93. package/dist/commands/hub/hub-client/index.d.ts +22 -0
  94. package/dist/commands/hub/hub-client/index.js +135 -0
  95. package/dist/commands/hub/hub-client/internal/contracts.d.ts +126 -0
  96. package/dist/commands/hub/hub-client/internal/contracts.js +85 -0
  97. package/dist/commands/hub/hub-client/internal/problem.d.ts +3 -0
  98. package/dist/commands/hub/hub-client/internal/problem.js +85 -0
  99. package/dist/commands/hub/hub-client/internal/transport.d.ts +15 -0
  100. package/dist/commands/hub/hub-client/internal/transport.js +30 -0
  101. package/dist/commands/hub/index.d.ts +20 -0
  102. package/dist/commands/hub/index.js +94 -0
  103. package/dist/commands/hub/init-plan.d.ts +33 -0
  104. package/dist/commands/hub/init-plan.js +94 -0
  105. package/dist/commands/hub/init.d.ts +37 -0
  106. package/dist/commands/hub/init.js +525 -0
  107. package/dist/commands/hub/login-flow.d.ts +34 -0
  108. package/dist/commands/hub/login-flow.js +78 -0
  109. package/dist/commands/hub/login.d.ts +23 -0
  110. package/dist/commands/hub/login.js +40 -0
  111. package/dist/commands/hub/logout.d.ts +33 -0
  112. package/dist/commands/hub/logout.js +71 -0
  113. package/dist/commands/hub/origin.d.ts +2 -0
  114. package/dist/commands/hub/origin.js +27 -0
  115. package/dist/commands/hub/permissions.d.ts +22 -0
  116. package/dist/commands/hub/permissions.js +61 -0
  117. package/dist/commands/hub/projects.d.ts +24 -0
  118. package/dist/commands/hub/projects.js +49 -0
  119. package/dist/commands/hub/reporter.d.ts +10 -0
  120. package/dist/commands/hub/reporter.js +11 -0
  121. package/dist/commands/hub/starter-agent-runtime.d.ts +37 -0
  122. package/dist/commands/hub/starter-agent-runtime.js +49 -0
  123. package/dist/commands/hub/starter-trigger.d.ts +10 -0
  124. package/dist/commands/hub/starter-trigger.js +30 -0
  125. package/dist/commands/hub/status-output.d.ts +13 -0
  126. package/dist/commands/hub/status-output.js +30 -0
  127. package/dist/commands/onboard.d.ts +14 -0
  128. package/dist/commands/onboard.js +169 -0
  129. package/dist/commands/open.d.ts +4 -0
  130. package/dist/commands/open.js +91 -0
  131. package/dist/commands/permit/allow.d.ts +38 -0
  132. package/dist/commands/permit/allow.js +138 -0
  133. package/dist/commands/permit/deny.d.ts +13 -0
  134. package/dist/commands/permit/deny.js +100 -0
  135. package/dist/commands/permit/index.d.ts +3 -0
  136. package/dist/commands/permit/index.js +27 -0
  137. package/dist/commands/permit/ls.d.ts +21 -0
  138. package/dist/commands/permit/ls.js +54 -0
  139. package/dist/commands/plugin/index.d.ts +23 -0
  140. package/dist/commands/plugin/index.js +174 -0
  141. package/dist/commands/plugin/scaffold.d.ts +6 -0
  142. package/dist/commands/plugin/scaffold.js +212 -0
  143. package/dist/commands/plugin/shared.d.ts +7 -0
  144. package/dist/commands/plugin/shared.js +34 -0
  145. package/dist/commands/plugin/update.d.ts +37 -0
  146. package/dist/commands/plugin/update.js +58 -0
  147. package/dist/commands/project/create.d.ts +10 -0
  148. package/dist/commands/project/create.js +43 -0
  149. package/dist/commands/project/delete.d.ts +9 -0
  150. package/dist/commands/project/delete.js +35 -0
  151. package/dist/commands/project/index.d.ts +3 -0
  152. package/dist/commands/project/index.js +28 -0
  153. package/dist/commands/project/ls.d.ts +5 -0
  154. package/dist/commands/project/ls.js +19 -0
  155. package/dist/commands/project/rename.d.ts +15 -0
  156. package/dist/commands/project/rename.js +52 -0
  157. package/dist/commands/project/shared.d.ts +11 -0
  158. package/dist/commands/project/shared.js +18 -0
  159. package/dist/commands/provider/diagnostic.d.ts +12 -0
  160. package/dist/commands/provider/diagnostic.js +31 -0
  161. package/dist/commands/provider/index.d.ts +3 -0
  162. package/dist/commands/provider/index.js +21 -0
  163. package/dist/commands/provider/ls.d.ts +19 -0
  164. package/dist/commands/provider/ls.js +46 -0
  165. package/dist/commands/provider/models.d.ts +20 -0
  166. package/dist/commands/provider/models.js +53 -0
  167. package/dist/commands/schedule/create.d.ts +19 -0
  168. package/dist/commands/schedule/create.js +41 -0
  169. package/dist/commands/schedule/delete.d.ts +10 -0
  170. package/dist/commands/schedule/delete.js +32 -0
  171. package/dist/commands/schedule/index.d.ts +3 -0
  172. package/dist/commands/schedule/index.js +66 -0
  173. package/dist/commands/schedule/inspect.d.ts +6 -0
  174. package/dist/commands/schedule/inspect.js +27 -0
  175. package/dist/commands/schedule/logs.d.ts +6 -0
  176. package/dist/commands/schedule/logs.js +24 -0
  177. package/dist/commands/schedule/ls.d.ts +5 -0
  178. package/dist/commands/schedule/ls.js +25 -0
  179. package/dist/commands/schedule/pause.d.ts +5 -0
  180. package/dist/commands/schedule/pause.js +24 -0
  181. package/dist/commands/schedule/resume.d.ts +5 -0
  182. package/dist/commands/schedule/resume.js +24 -0
  183. package/dist/commands/schedule/run-once.d.ts +5 -0
  184. package/dist/commands/schedule/run-once.js +24 -0
  185. package/dist/commands/schedule/schema.d.ts +21 -0
  186. package/dist/commands/schedule/schema.js +67 -0
  187. package/dist/commands/schedule/shared.d.ts +61 -0
  188. package/dist/commands/schedule/shared.js +360 -0
  189. package/dist/commands/schedule/types.d.ts +165 -0
  190. package/dist/commands/schedule/types.js +2 -0
  191. package/dist/commands/schedule/update.d.ts +19 -0
  192. package/dist/commands/schedule/update.js +40 -0
  193. package/dist/commands/script/index.d.ts +3 -0
  194. package/dist/commands/script/index.js +19 -0
  195. package/dist/commands/script/ls.d.ts +6 -0
  196. package/dist/commands/script/ls.js +20 -0
  197. package/dist/commands/script/schema.d.ts +5 -0
  198. package/dist/commands/script/schema.js +13 -0
  199. package/dist/commands/script/shared.d.ts +12 -0
  200. package/dist/commands/script/shared.js +59 -0
  201. package/dist/commands/script/start.d.ts +6 -0
  202. package/dist/commands/script/start.js +23 -0
  203. package/dist/commands/script/stop.d.ts +6 -0
  204. package/dist/commands/script/stop.js +23 -0
  205. package/dist/commands/terminal/capture.d.ts +10 -0
  206. package/dist/commands/terminal/capture.js +67 -0
  207. package/dist/commands/terminal/create.d.ts +11 -0
  208. package/dist/commands/terminal/create.js +29 -0
  209. package/dist/commands/terminal/index.d.ts +3 -0
  210. package/dist/commands/terminal/index.js +51 -0
  211. package/dist/commands/terminal/kill.d.ts +6 -0
  212. package/dist/commands/terminal/kill.js +36 -0
  213. package/dist/commands/terminal/ls.d.ts +11 -0
  214. package/dist/commands/terminal/ls.js +21 -0
  215. package/dist/commands/terminal/schema.d.ts +10 -0
  216. package/dist/commands/terminal/schema.js +17 -0
  217. package/dist/commands/terminal/send-keys.d.ts +7 -0
  218. package/dist/commands/terminal/send-keys.js +44 -0
  219. package/dist/commands/terminal/shared.d.ts +13 -0
  220. package/dist/commands/terminal/shared.js +64 -0
  221. package/dist/commands/terminal/upgrade-hosts.d.ts +11 -0
  222. package/dist/commands/terminal/upgrade-hosts.js +46 -0
  223. package/dist/commands/usage/index.d.ts +29 -0
  224. package/dist/commands/usage/index.js +62 -0
  225. package/dist/commands/usage/presentation.d.ts +4 -0
  226. package/dist/commands/usage/presentation.js +146 -0
  227. package/dist/commands/workspace/archive.d.ts +13 -0
  228. package/dist/commands/workspace/archive.js +43 -0
  229. package/dist/commands/workspace/create.d.ts +50 -0
  230. package/dist/commands/workspace/create.js +132 -0
  231. package/dist/commands/workspace/index.d.ts +3 -0
  232. package/dist/commands/workspace/index.js +50 -0
  233. package/dist/commands/workspace/ls.d.ts +11 -0
  234. package/dist/commands/workspace/ls.js +33 -0
  235. package/dist/commands/workspace/rename.d.ts +23 -0
  236. package/dist/commands/workspace/rename.js +63 -0
  237. package/dist/commands/workspace/setup.d.ts +12 -0
  238. package/dist/commands/workspace/setup.js +41 -0
  239. package/dist/commands/workspace/shared.d.ts +15 -0
  240. package/dist/commands/workspace/shared.js +29 -0
  241. package/dist/commands/worktree/archive.d.ts +21 -0
  242. package/dist/commands/worktree/archive.js +108 -0
  243. package/dist/commands/worktree/create-input.d.ts +15 -0
  244. package/dist/commands/worktree/create-input.js +56 -0
  245. package/dist/commands/worktree/create.d.ts +11 -0
  246. package/dist/commands/worktree/create.js +50 -0
  247. package/dist/commands/worktree/index.d.ts +3 -0
  248. package/dist/commands/worktree/index.js +29 -0
  249. package/dist/commands/worktree/ls.d.ts +18 -0
  250. package/dist/commands/worktree/ls.js +73 -0
  251. package/dist/commands/worktree/repository-directory.d.ts +6 -0
  252. package/dist/commands/worktree/repository-directory.js +9 -0
  253. package/dist/index.d.ts +2 -0
  254. package/dist/index.js +6 -0
  255. package/dist/output/index.d.ts +45 -0
  256. package/dist/output/index.js +47 -0
  257. package/dist/output/json.d.ts +11 -0
  258. package/dist/output/json.js +37 -0
  259. package/dist/output/pairing.d.ts +9 -0
  260. package/dist/output/pairing.js +36 -0
  261. package/dist/output/quiet.d.ts +9 -0
  262. package/dist/output/quiet.js +22 -0
  263. package/dist/output/render.d.ts +15 -0
  264. package/dist/output/render.js +84 -0
  265. package/dist/output/table.d.ts +13 -0
  266. package/dist/output/table.js +135 -0
  267. package/dist/output/types.d.ts +73 -0
  268. package/dist/output/types.js +8 -0
  269. package/dist/output/with-output.d.ts +43 -0
  270. package/dist/output/with-output.js +85 -0
  271. package/dist/output/yaml.d.ts +11 -0
  272. package/dist/output/yaml.js +38 -0
  273. package/dist/run.d.ts +14 -0
  274. package/dist/run.js +62 -0
  275. package/dist/ssh/ssh-tunnel.d.ts +2 -0
  276. package/dist/ssh/ssh-tunnel.js +3 -0
  277. package/dist/utils/agent-directory.d.ts +31 -0
  278. package/dist/utils/agent-directory.js +48 -0
  279. package/dist/utils/caller-agent.d.ts +14 -0
  280. package/dist/utils/caller-agent.js +16 -0
  281. package/dist/utils/client-id.d.ts +2 -0
  282. package/dist/utils/client-id.js +31 -0
  283. package/dist/utils/client.d.ts +57 -0
  284. package/dist/utils/client.js +360 -0
  285. package/dist/utils/command-options.d.ts +8 -0
  286. package/dist/utils/command-options.js +49 -0
  287. package/dist/utils/daemon-target.d.ts +13 -0
  288. package/dist/utils/daemon-target.js +51 -0
  289. package/dist/utils/duration.d.ts +7 -0
  290. package/dist/utils/duration.js +39 -0
  291. package/dist/utils/errors.d.ts +5 -0
  292. package/dist/utils/errors.js +10 -0
  293. package/dist/utils/paths.d.ts +12 -0
  294. package/dist/utils/paths.js +22 -0
  295. package/dist/utils/provider-model.d.ts +11 -0
  296. package/dist/utils/provider-model.js +49 -0
  297. package/dist/utils/timeline.d.ts +12 -0
  298. package/dist/utils/timeline.js +16 -0
  299. package/dist/utils/wait-for-stop.d.ts +2 -0
  300. package/dist/utils/wait-for-stop.js +28 -0
  301. package/dist/version.d.ts +5 -0
  302. package/dist/version.js +24 -0
  303. package/package.json +58 -4
  304. package/README.md +0 -3
@@ -0,0 +1,20 @@
1
+ import { Command } from "commander";
2
+ import { HubHttpClient } from "./hub-client/index.js";
3
+ import { type HubCredentialStore } from "./credentials.js";
4
+ import { type HubDaemonConnection } from "./daemon-client.js";
5
+ import { type CliLoginFlow } from "./login-flow.js";
6
+ import { type HubReporter } from "./reporter.js";
7
+ interface HubCommandEnvironment {
8
+ env: Readonly<Record<string, string | undefined>>;
9
+ credentials: HubCredentialStore;
10
+ hub: HubHttpClient;
11
+ login: Pick<CliLoginFlow, "authorize">;
12
+ daemon: HubDaemonConnection;
13
+ isInteractive(): boolean;
14
+ confirmDisconnect(origin: string): Promise<boolean>;
15
+ reporter: HubReporter;
16
+ cwd(): string;
17
+ }
18
+ export declare function createHubCommand(overrides?: Partial<HubCommandEnvironment>): Command;
19
+ export {};
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,94 @@
1
+ import { Command } from "commander";
2
+ import { withOutput } from "../../output/index.js";
3
+ import { addJsonAndDaemonHostOptions } from "../../utils/command-options.js";
4
+ import { HubHttpClient } from "./hub-client/index.js";
5
+ import { addHubConnectCommand } from "./connect.js";
6
+ import { PrivateHubCredentialStore } from "./credentials.js";
7
+ import { productionHubDaemonConnection, withHubDaemon, } from "./daemon-client.js";
8
+ import { addHubDeployCommand } from "./deploy.js";
9
+ import { addHubDisconnectCommand } from "./disconnect.js";
10
+ import { createCliLoginFlow } from "./login-flow.js";
11
+ import { addHubLoginCommand } from "./login.js";
12
+ import { addHubLogoutCommand, productionLogoutPrompt } from "./logout.js";
13
+ import { addHubProjectsCommand } from "./projects.js";
14
+ import { addHubExportCommand } from "./export.js";
15
+ import { processHubReporter } from "./reporter.js";
16
+ import { hubStatusResult } from "./status-output.js";
17
+ import { addHubResolutionHelp } from "./help.js";
18
+ import { addHubInitCommand, continueHubGuidedSetup } from "./init.js";
19
+ import { addHubPermissionsCommand } from "./permissions.js";
20
+ function productionEnvironment() {
21
+ const env = process.env;
22
+ const hub = new HubHttpClient();
23
+ return {
24
+ env,
25
+ credentials: new PrivateHubCredentialStore(env),
26
+ hub,
27
+ login: createCliLoginFlow(hub),
28
+ daemon: productionHubDaemonConnection,
29
+ reporter: processHubReporter,
30
+ cwd: () => process.cwd(),
31
+ ...productionLogoutPrompt,
32
+ };
33
+ }
34
+ export function createHubCommand(overrides = {}) {
35
+ const environment = { ...productionEnvironment(), ...overrides };
36
+ const hub = addHubResolutionHelp(new Command("hub").description("Manage Mateo Hub"));
37
+ addHubLoginCommand(hub, {
38
+ env: environment.env,
39
+ credentials: environment.credentials,
40
+ flow: environment.login,
41
+ reporter: environment.reporter,
42
+ isInteractive: environment.isInteractive,
43
+ continueGuidedSetup: (origin, daemonTarget) => continueHubGuidedSetup(origin, { ...environment, daemonTarget }),
44
+ });
45
+ addHubInitCommand(hub, environment);
46
+ addHubConnectCommand(hub, {
47
+ env: environment.env,
48
+ credentials: environment.credentials,
49
+ hub: environment.hub,
50
+ daemon: environment.daemon,
51
+ reporter: environment.reporter,
52
+ });
53
+ addJsonAndDaemonHostOptions(hub.command("status")).action(withOutput(async (...args) => {
54
+ const options = args.at(-2);
55
+ return withHubDaemon(environment.daemon, options.daemonTarget, async (client) => hubStatusResult((await client.getHubStatus()).status));
56
+ }));
57
+ addHubDisconnectCommand(hub, {
58
+ daemon: environment.daemon,
59
+ reporter: environment.reporter,
60
+ });
61
+ addHubPermissionsCommand(hub, {
62
+ daemon: environment.daemon,
63
+ reporter: environment.reporter,
64
+ });
65
+ addHubProjectsCommand(hub, {
66
+ env: environment.env,
67
+ credentials: environment.credentials,
68
+ hub: environment.hub,
69
+ reporter: environment.reporter,
70
+ });
71
+ addHubExportCommand(hub, {
72
+ env: environment.env,
73
+ credentials: environment.credentials,
74
+ hub: environment.hub,
75
+ reporter: environment.reporter,
76
+ cwd: environment.cwd,
77
+ });
78
+ addHubDeployCommand(hub, {
79
+ env: environment.env,
80
+ credentials: environment.credentials,
81
+ hub: environment.hub,
82
+ reporter: environment.reporter,
83
+ cwd: environment.cwd,
84
+ });
85
+ addHubLogoutCommand(hub, {
86
+ credentials: environment.credentials,
87
+ daemon: environment.daemon,
88
+ isInteractive: environment.isInteractive,
89
+ confirmDisconnect: environment.confirmDisconnect,
90
+ reporter: environment.reporter,
91
+ });
92
+ return hub;
93
+ }
94
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,33 @@
1
+ import type { HubStatus } from "./daemon-client.js";
2
+ import type { HubStarterAgentRuntime } from "./starter-agent-runtime.js";
3
+ export type HubInitProvider = "github" | "slack" | "discord";
4
+ export type HubInitConnectionResolution = {
5
+ kind: "connected";
6
+ daemonId: string;
7
+ } | {
8
+ kind: "pending";
9
+ state: "connecting" | "reconnecting";
10
+ } | {
11
+ kind: "connect";
12
+ } | {
13
+ kind: "conflict";
14
+ origin: string;
15
+ };
16
+ export interface HubInitScaffoldInput {
17
+ cwd: string;
18
+ daemonSlug: string;
19
+ agent: HubStarterAgentRuntime & {
20
+ mode: string;
21
+ };
22
+ provider: HubInitProvider;
23
+ providerFilters: Readonly<Record<string, string>>;
24
+ }
25
+ export interface HubInitScaffold {
26
+ triggerPath: string;
27
+ trigger: string;
28
+ testAction: string;
29
+ }
30
+ export declare function hubLoginResumeCommand(step: "connect" | "init", origin: string): string;
31
+ export declare function resolveHubInitConnection(status: HubStatus, origin: string): HubInitConnectionResolution;
32
+ export declare function createHubInitScaffold(input: HubInitScaffoldInput): HubInitScaffold;
33
+ //# sourceMappingURL=init-plan.d.ts.map
@@ -0,0 +1,94 @@
1
+ import path from "node:path";
2
+ import YAML from "yaml";
3
+ export function hubLoginResumeCommand(step, origin) {
4
+ return step === "connect" ? `mateo hub connect ${origin}` : "mateo hub init";
5
+ }
6
+ export function resolveHubInitConnection(status, origin) {
7
+ if (status.state === "connected" && status.hubOrigin === origin && status.daemonId !== null) {
8
+ return { kind: "connected", daemonId: status.daemonId };
9
+ }
10
+ if ((status.state === "connecting" || status.state === "reconnecting") &&
11
+ status.hubOrigin === origin) {
12
+ return { kind: "pending", state: status.state };
13
+ }
14
+ if (status.hubOrigin !== null && status.state !== "not_connected" && status.state !== "revoked") {
15
+ return { kind: "conflict", origin: status.hubOrigin };
16
+ }
17
+ return { kind: "connect" };
18
+ }
19
+ export function createHubInitScaffold(input) {
20
+ const provider = providerScaffold(input.provider, input.providerFilters);
21
+ return {
22
+ triggerPath: `.mateo/triggers/${input.provider}-help.yml`,
23
+ trigger: YAML.stringify(triggerDocument({
24
+ ...provider,
25
+ target: { daemon: input.daemonSlug, cwd: path.resolve(input.cwd) },
26
+ agent: {
27
+ provider: input.agent.provider,
28
+ model: input.agent.model,
29
+ mode: input.agent.mode,
30
+ },
31
+ }), { lineWidth: 0 }),
32
+ testAction: provider.testAction,
33
+ };
34
+ }
35
+ function providerScaffold(provider, filters) {
36
+ const connection = requireFilter(filters, "connection");
37
+ if (provider === "github") {
38
+ const repo = requireFilter(filters, "repo");
39
+ const user = requireFilter(filters, "user");
40
+ return {
41
+ name: "github-help",
42
+ event: "github.issue_comment",
43
+ connection,
44
+ filters: { repo, contains: "@mateo", from_users: [user] },
45
+ testAction: `Comment \`@mateo have a look\` on ${repo}.`,
46
+ };
47
+ }
48
+ const user = requireFilter(filters, "user");
49
+ if (provider === "slack") {
50
+ return {
51
+ name: "slack-help",
52
+ event: "slack.mention",
53
+ connection,
54
+ filters: { from_users: [user] },
55
+ reply: "slack.reply",
56
+ testAction: "Mention `@Mateo have a look` in Slack.",
57
+ };
58
+ }
59
+ return {
60
+ name: "discord-help",
61
+ event: "discord.mention",
62
+ connection,
63
+ filters: { from_users: [user] },
64
+ reply: "discord.reply",
65
+ testAction: "Mention `@Mateo have a look` in Discord.",
66
+ };
67
+ }
68
+ function triggerDocument(input) {
69
+ const replyInstruction = input.reply === undefined ? "" : "Answer with hub.reply, then ";
70
+ return {
71
+ name: input.name,
72
+ enabled: true,
73
+ on: { [input.event]: { connection: input.connection, filters: input.filters } },
74
+ max_runtime: "2h",
75
+ run: {
76
+ target: input.target,
77
+ agent: input.agent,
78
+ continuation: { mode: "conversation" },
79
+ max_runtime: "90m",
80
+ idle_timeout: "10m",
81
+ prompt: `${replyInstruction}complete this request and call hub.finish_execution when done.\n\n<user-prompt>\n\${{ mateo.prompt }}\n</user-prompt>\n`,
82
+ ...(input.reply === undefined
83
+ ? {}
84
+ : { outputs: { [input.reply]: { max: 1, required: true } } }),
85
+ },
86
+ };
87
+ }
88
+ function requireFilter(filters, name) {
89
+ const value = filters[name]?.trim();
90
+ if (!value)
91
+ throw new Error(`${name} is required for this provider`);
92
+ return value;
93
+ }
94
+ //# sourceMappingURL=init-plan.js.map
@@ -0,0 +1,37 @@
1
+ import type { DaemonTarget } from "../../utils/daemon-target.js";
2
+ import { select, text } from "@clack/prompts";
3
+ import type { Command } from "commander";
4
+ import type { HubCredentialStore } from "./credentials.js";
5
+ import type { HubDaemonConnection } from "./daemon-client.js";
6
+ import type { HubHttpClient } from "./hub-client/index.js";
7
+ import type { CliLoginFlow } from "./login-flow.js";
8
+ import type { HubReporter } from "./reporter.js";
9
+ export interface HubGuidedSetupEnvironment {
10
+ daemonTarget: DaemonTarget;
11
+ env: Readonly<Record<string, string | undefined>>;
12
+ credentials: HubCredentialStore;
13
+ hub: HubHttpClient;
14
+ login: Pick<CliLoginFlow, "authorize">;
15
+ daemon: HubDaemonConnection;
16
+ reporter: HubReporter;
17
+ cwd(): string;
18
+ isInteractive?(): boolean;
19
+ prompts?: {
20
+ confirm(message: string, initialValue: boolean): Promise<boolean>;
21
+ select(options: Parameters<typeof select<string>>[0]): Promise<string>;
22
+ text(options: Parameters<typeof text>[0]): Promise<string>;
23
+ message(value: string): void;
24
+ };
25
+ }
26
+ interface HubGuidedSetupState {
27
+ origin?: string;
28
+ daemonId?: string;
29
+ deploy?: boolean;
30
+ }
31
+ export declare function addHubInitCommand(parent: Command, environment: Omit<HubGuidedSetupEnvironment, "daemonTarget">): void;
32
+ export declare function runHubInit(environment: HubGuidedSetupEnvironment): Promise<void>;
33
+ export declare function runHubGuidedSetup(environment: HubGuidedSetupEnvironment, state?: HubGuidedSetupState): Promise<void>;
34
+ export declare function continueHubGuidedSetup(origin: string, environment: HubGuidedSetupEnvironment): Promise<void>;
35
+ export declare function githubRepositoryFromRemote(remote: string): string | undefined;
36
+ export {};
37
+ //# sourceMappingURL=init.d.ts.map