@clawops/cli 2.0.0 → 2.0.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 (75) hide show
  1. package/README.md +98 -12
  2. package/dist/apply-KYFPWI5U.js +27 -0
  3. package/dist/automation-RMAIBNVC.js +44 -0
  4. package/dist/bedrock-XVASJX2K.js +61 -0
  5. package/dist/{bootstrap-DMRPWJGN.js → bootstrap-HNGKY6WW.js} +11 -8
  6. package/dist/{chunk-N44K3LHE.js → chunk-2I7KCMXZ.js} +6 -4
  7. package/dist/{chunk-3WYA2QDM.js → chunk-2Z7J3ERQ.js} +1 -1
  8. package/dist/chunk-3OLUJPCB.js +36 -0
  9. package/dist/chunk-5XT5IAJK.js +69 -0
  10. package/dist/chunk-AEEMRFZV.js +24 -0
  11. package/dist/{chunk-YR3O2I3S.js → chunk-BSLIYB5Q.js} +6 -1
  12. package/dist/{chunk-AHAAEXWC.js → chunk-E4NJSJ54.js} +16 -93
  13. package/dist/chunk-FEK7VJAY.js +16 -0
  14. package/dist/{chunk-6TIYVHPX.js → chunk-GIEVAGEK.js} +7 -33
  15. package/dist/chunk-HSPHXG6W.js +67 -0
  16. package/dist/{chunk-GYV4KNW7.js → chunk-IVWP4QUJ.js} +133 -40
  17. package/dist/{chunk-AX74VXTV.js → chunk-KC3GC3PE.js} +58 -49
  18. package/dist/{chunk-UFRO4H5W.js → chunk-LBE6COC4.js} +56 -40
  19. package/dist/chunk-LEVIW2PV.js +890 -0
  20. package/dist/chunk-MC5ATCXS.js +108 -0
  21. package/dist/chunk-N4WZLWJ4.js +16 -0
  22. package/dist/{chunk-SBLQH2TJ.js → chunk-NUL5F6YV.js} +1 -1
  23. package/dist/chunk-RHOWYIWT.js +52 -0
  24. package/dist/{chunk-WHJMKDV7.js → chunk-STLRHLLV.js} +65 -12
  25. package/dist/chunk-V25QRZRB.js +45 -0
  26. package/dist/chunk-VOEJYRIK.js +33 -0
  27. package/dist/{providers-2OABPW2E.js → chunk-VUFMZEIM.js} +3 -2
  28. package/dist/chunk-W3OLNNJW.js +51 -0
  29. package/dist/cli-WLD3EBEM.js +11 -0
  30. package/dist/cli-auth-GD5SK7JU.js +13 -0
  31. package/dist/cli.js +518 -206
  32. package/dist/context-7EVC6W45.js +20 -0
  33. package/dist/docker-3PDO4TS7.js +12 -0
  34. package/dist/{firewall-T3NTPZJD.js → firewall-5VKZ4WBH.js} +22 -1
  35. package/dist/generate-I6YQ5V2T.js +29 -0
  36. package/dist/{harden-PCDK3UQ5.js → harden-72JMRT4E.js} +8 -5
  37. package/dist/index.d.ts +56 -0
  38. package/dist/known-hosts-file-I3Q3NBYQ.js +22 -0
  39. package/dist/{logs-P7YCKVF4.js → logs-5A7YYA53.js} +1 -1
  40. package/dist/{mcp-wire-BFEY2Y6H.js → mcp-wire-3SWBM7D6.js} +25 -15
  41. package/dist/models-AGTQWYDL.js +32 -0
  42. package/dist/network-args-PYJRJBYO.js +64 -0
  43. package/dist/{package-3HUW57XH.js → package-5BCMEBTE.js} +10 -3
  44. package/dist/passphrase-MJBE45N7.js +15 -0
  45. package/dist/{pool-EX4ZTA5P.js → pool-PIIKJ4L2.js} +3 -2
  46. package/dist/preflight-EF52S3WW.js +162 -0
  47. package/dist/preflight-MWWM5JT3.js +181 -0
  48. package/dist/preflight-TFD4N5ZU.js +141 -0
  49. package/dist/providers-FW6H6OPF.js +11 -0
  50. package/dist/ready-KDNRBNSU.js +95 -0
  51. package/dist/{remote-config-Z6IIZR3D.js → remote-config-3HZLUWEA.js} +3 -2
  52. package/dist/{runtime-LZ7NA53V.js → runtime-X3KW5TCP.js} +4 -2
  53. package/dist/server-GBA7BJGK.js +46 -0
  54. package/dist/ssh-VAI5DU5M.js +11 -0
  55. package/dist/ssh-key-DUO6OKOI.js +7 -0
  56. package/dist/stack-config-R4SPSUQZ.js +12 -0
  57. package/dist/{validate-BOQRWX4F.js → validate-YVI3BJ55.js} +1 -1
  58. package/dist/wait-WO72TRRQ.js +79 -0
  59. package/package.json +10 -3
  60. package/spec/mcp-tools.yaml +21 -2
  61. package/spec/models.yaml +14 -3
  62. package/spec/providers.schema.json +163 -28
  63. package/dist/apply-AM5HERE7.js +0 -19
  64. package/dist/automation-RULUSJBW.js +0 -30
  65. package/dist/aws-AMON7DA7.js +0 -265
  66. package/dist/azure-T4G6OBJQ.js +0 -273
  67. package/dist/chunk-CKSPROD5.js +0 -129
  68. package/dist/chunk-LU2V3LXA.js +0 -114
  69. package/dist/context-KHKWJJMC.js +0 -10
  70. package/dist/gcp-2JBTD7ZM.js +0 -204
  71. package/dist/generate-2XV2GSP2.js +0 -15
  72. package/dist/local-DXBEVZ5C.js +0 -47
  73. package/dist/server-A5AB67GQ.js +0 -36
  74. package/dist/ssh-B3NZAU4I.js +0 -8
  75. package/dist/{version-guard-GPSTCPT7.js → version-guard-XVYW5WFJ.js} +1 -1
@@ -1,42 +1,50 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  applyPlan
4
- } from "./chunk-UFRO4H5W.js";
4
+ } from "./chunk-LBE6COC4.js";
5
+ import {
6
+ extractBaseOutputs
7
+ } from "./chunk-3QJBNAHW.js";
5
8
  import {
6
9
  atomicWriteConfig,
7
10
  readRemoteConfig,
8
11
  restartGateway
9
- } from "./chunk-N44K3LHE.js";
10
- import {
11
- extractBaseOutputs
12
- } from "./chunk-3QJBNAHW.js";
12
+ } from "./chunk-2I7KCMXZ.js";
13
13
  import {
14
14
  generatePlan
15
- } from "./chunk-WHJMKDV7.js";
15
+ } from "./chunk-STLRHLLV.js";
16
16
  import {
17
17
  validatePlan
18
- } from "./chunk-YR3O2I3S.js";
18
+ } from "./chunk-BSLIYB5Q.js";
19
19
  import {
20
20
  acquireSession,
21
21
  drainPool
22
- } from "./chunk-3WYA2QDM.js";
22
+ } from "./chunk-2Z7J3ERQ.js";
23
23
  import {
24
24
  buildContext
25
- } from "./chunk-LU2V3LXA.js";
25
+ } from "./chunk-5XT5IAJK.js";
26
26
  import {
27
27
  formatUptime,
28
28
  gatherSnapshot,
29
29
  runDiagnostics
30
- } from "./chunk-GYV4KNW7.js";
30
+ } from "./chunk-IVWP4QUJ.js";
31
31
  import {
32
32
  GATEWAY_LOGS_PROBE,
33
33
  chooseLogSource,
34
34
  containerLogsCommand,
35
35
  gatewayLogsCommand
36
- } from "./chunk-SBLQH2TJ.js";
36
+ } from "./chunk-NUL5F6YV.js";
37
37
  import {
38
38
  execPrivileged
39
39
  } from "./chunk-NUDIHZEH.js";
40
+ import {
41
+ STATE_DIR_HOST_LINUX,
42
+ gatewayRunCommand
43
+ } from "./chunk-GIEVAGEK.js";
44
+ import {
45
+ IMAGE_INSPECT_CMD,
46
+ imageForRestart
47
+ } from "./chunk-VOEJYRIK.js";
40
48
  import {
41
49
  getConfig,
42
50
  getConfigDir
@@ -45,12 +53,6 @@ import {
45
53
  StateError,
46
54
  UsageError
47
55
  } from "./chunk-KGXPLI7W.js";
48
- import {
49
- IMAGE_INSPECT_CMD,
50
- STATE_DIR_HOST_LINUX,
51
- gatewayRunCommand,
52
- imageForRestart
53
- } from "./chunk-6TIYVHPX.js";
54
56
 
55
57
  // src/mcp/server.ts
56
58
  import { createServer } from "http";
@@ -222,7 +224,10 @@ var clawops_upSchema = z.object({
222
224
  stackName: z.string().optional(),
223
225
  provider: z.enum(["aws", "gcp", "azure", "local"]).optional(),
224
226
  region: z.string().optional(),
225
- instanceType: z.enum(["micro", "small", "medium", "large", "gpu"]).optional().default("small"),
227
+ instanceType: z.string().optional().default("small"),
228
+ sshCidr: z.string().optional(),
229
+ gatewayCidr: z.string().optional(),
230
+ publishGateway: z.enum(["loopback", "all"]).optional(),
226
231
  openclawVersion: z.string().optional(),
227
232
  dryRun: z.boolean().optional().default(false)
228
233
  });
@@ -799,7 +804,6 @@ function makeProgressEmitter(server, progressToken) {
799
804
  }
800
805
 
801
806
  // src/mcp/tools/cli/up.ts
802
- var VALID_INSTANCE_TYPES = ["micro", "small", "medium", "large", "gpu"];
803
807
  async function handleUp(input, server) {
804
808
  if (!input.dryRun) {
805
809
  const elicit = await server.server.elicitInput({
@@ -824,7 +828,7 @@ async function handleUp(input, server) {
824
828
  );
825
829
  }
826
830
  const { localOpts } = stackConfig;
827
- const { localBootstrap } = await import("./bootstrap-DMRPWJGN.js");
831
+ const { localBootstrap } = await import("./bootstrap-HNGKY6WW.js");
828
832
  const ac = new AbortController();
829
833
  const state = await localBootstrap({
830
834
  host: localOpts.host,
@@ -839,10 +843,6 @@ async function handleUp(input, server) {
839
843
  });
840
844
  return okText(JSON.stringify({ stack: ctx.stackName, ...state }, null, 2));
841
845
  }
842
- const instanceAlias = input.instanceType ?? "small";
843
- if (!VALID_INSTANCE_TYPES.includes(instanceAlias)) {
844
- throw new UsageError(`Invalid instanceType: ${instanceAlias}`);
845
- }
846
846
  const validation = await ctx.adapter.validateConfig();
847
847
  if (!validation.ok) {
848
848
  return errText(`Provider config invalid: ${validation.errors.join("; ")}`);
@@ -851,38 +851,47 @@ async function handleUp(input, server) {
851
851
  const progressToken = void 0;
852
852
  const emit = makeProgressEmitter(server, progressToken);
853
853
  startTask(taskId, `clawops_up stack=${ctx.stackName}`);
854
- const stack = await ctx.getStack();
855
- const region = input.region ?? ctx.adapter.defaultRegion();
856
- const instanceType = ctx.adapter.normalizeInstanceType(instanceAlias);
857
- await stack.setConfig("region", { value: region });
858
- await stack.setConfig("instanceType", { value: instanceType });
859
- await stack.setConfig("openclawVersion", { value: openclawVersion });
860
- if (input.dryRun) {
861
- const lines = [];
862
- await stack.preview({ onOutput: (o) => {
863
- emit(o.trim());
864
- lines.push(o);
865
- } });
866
- const output = lines.join("");
867
- updateTask(taskId, "completed", output);
868
- const { content } = trimForMcp(output, ctx.stackName);
869
- return okText(content);
870
- }
854
+ const { generatePlan: generatePlan2 } = await import("./generate-I6YQ5V2T.js");
855
+ const { applyPlan: applyPlan2 } = await import("./apply-KYFPWI5U.js");
856
+ const { resolveNetworkFlags } = await import("./network-args-PYJRJBYO.js");
857
+ const { detectEgressIp } = await import("./firewall-5VKZ4WBH.js");
858
+ const network = await resolveNetworkFlags(
859
+ {
860
+ ...input.sshCidr ? { sshCidr: input.sshCidr } : {},
861
+ ...input.gatewayCidr ? { gatewayCidr: input.gatewayCidr } : {},
862
+ ...input.publishGateway ? { publishGateway: input.publishGateway } : {}
863
+ },
864
+ { detectEgressIp: () => detectEgressIp("https://ifconfig.me/ip") }
865
+ );
871
866
  try {
867
+ const plan = await generatePlan2({
868
+ stackName: ctx.stackName,
869
+ provider: ctx.adapter.name,
870
+ ...input.region ? { region: input.region } : {},
871
+ ...input.instanceType ? { instanceType: input.instanceType } : {},
872
+ openclawVersion,
873
+ network
874
+ });
875
+ if (input.dryRun) {
876
+ const summary2 = JSON.stringify(plan.diff ?? { totalChanges: 0 }, null, 2);
877
+ updateTask(taskId, "completed", summary2);
878
+ const { content } = trimForMcp(summary2, ctx.stackName);
879
+ return okText(content);
880
+ }
872
881
  const lines = [];
873
- const result = await stack.up({
882
+ const result = await applyPlan2(plan, {
874
883
  onOutput: (o) => {
875
884
  emit(o.trim());
876
885
  lines.push(o);
877
- }
886
+ },
887
+ onProgress: (o) => emit(o)
878
888
  });
879
889
  const summary = `Stack "${ctx.stackName}" deployed.
880
- ` + (result.outputs["publicIp"] ? `Public IP: ${result.outputs["publicIp"].value}
881
- ` : "") + (result.outputs["gatewayUrl"] ? `Gateway URL: ${result.outputs["gatewayUrl"].value}
890
+ ` + (result.outputs["publicIp"] ? `Public IP: ${String(result.outputs["publicIp"])}
891
+ ` : "") + (result.outputs["gatewayUrl"] ? `Gateway URL: ${String(result.outputs["gatewayUrl"])}
882
892
  ` : "");
883
893
  updateTask(taskId, "completed", summary);
884
- const fullOutput = lines.join("");
885
- trimForMcp(fullOutput, ctx.stackName);
894
+ trimForMcp(lines.join(""), ctx.stackName);
886
895
  return okText(summary);
887
896
  } catch (err) {
888
897
  const msg = err instanceof Error ? err.message : String(err);
@@ -1047,7 +1056,7 @@ async function handleTaskStatus(input, _server) {
1047
1056
 
1048
1057
  // src/mcp/tools/cli/monitor.ts
1049
1058
  async function handleMonitor(input, _server) {
1050
- const { acquireSession: acquireSession2, drainPool: drainPool2 } = await import("./pool-EX4ZTA5P.js");
1059
+ const { acquireSession: acquireSession2, drainPool: drainPool2 } = await import("./pool-PIIKJ4L2.js");
1051
1060
  const ctx = buildContext({ stack: input.stackName });
1052
1061
  const tailLines = input.tailLines ?? 5;
1053
1062
  let conn;
@@ -1523,7 +1532,7 @@ function bearerFrom(header) {
1523
1532
  return match?.[1]?.trim();
1524
1533
  }
1525
1534
  async function serveMcp(opts) {
1526
- const { version } = await import("./package-3HUW57XH.js");
1535
+ const { version } = await import("./package-5BCMEBTE.js");
1527
1536
  const makeServer = () => {
1528
1537
  const server = new McpServer({ name: "clawops", version });
1529
1538
  registerTools(server, opts);
@@ -1,30 +1,34 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ resolveSecrets
4
+ } from "./chunk-BOPSG2LI.js";
5
+ import {
6
+ saveOverlay
7
+ } from "./chunk-6ZFIFDBJ.js";
2
8
  import {
3
9
  atomicWriteConfig,
4
10
  deepMerge,
5
11
  readRemoteConfig,
6
12
  restartGateway
7
- } from "./chunk-N44K3LHE.js";
13
+ } from "./chunk-2I7KCMXZ.js";
8
14
  import {
9
- validatePlan
10
- } from "./chunk-YR3O2I3S.js";
15
+ writeStackConfig
16
+ } from "./chunk-HSPHXG6W.js";
11
17
  import {
12
- saveOverlay
13
- } from "./chunk-6ZFIFDBJ.js";
14
- import {
15
- resolveSecrets
16
- } from "./chunk-BOPSG2LI.js";
18
+ validatePlan
19
+ } from "./chunk-BSLIYB5Q.js";
17
20
  import {
18
21
  buildContext
19
- } from "./chunk-LU2V3LXA.js";
22
+ } from "./chunk-5XT5IAJK.js";
23
+ import {
24
+ GATEWAY_PORT
25
+ } from "./chunk-VOEJYRIK.js";
20
26
  import {
21
27
  UsageError
22
28
  } from "./chunk-KGXPLI7W.js";
23
- import {
24
- GATEWAY_PORT
25
- } from "./chunk-6TIYVHPX.js";
26
29
 
27
30
  // src/plan/apply.ts
31
+ import process from "process";
28
32
  async function applyPlan(plan, opts) {
29
33
  const validation = validatePlan(plan);
30
34
  if (!validation.ok) {
@@ -38,28 +42,14 @@ ${validation.errors.join("\n")}`
38
42
  "plan/apply is not supported for the local provider. Use `clawops up` directly."
39
43
  );
40
44
  }
41
- const { guardOpenclawVersion } = await import("./version-guard-GPSTCPT7.js");
45
+ const { guardOpenclawVersion } = await import("./version-guard-XVYW5WFJ.js");
42
46
  await guardOpenclawVersion(plan.spec.openclaw.version);
43
47
  const ctx = buildContext({
44
48
  stack: plan.spec.stackName,
45
49
  provider: plan.spec.provider
46
50
  });
47
51
  const stack = await ctx.getStack();
48
- await stack.setConfig("instanceType", { value: plan.spec.instanceType });
49
- if (plan.spec.region) {
50
- await stack.setConfig("region", { value: plan.spec.region });
51
- }
52
- await stack.setConfig("openclawVersion", { value: plan.spec.openclaw.version });
53
- await stack.setConfig("publishGateway", {
54
- value: plan.spec.network?.publishGateway ?? "loopback"
55
- });
56
- await stack.setConfig("gatewayPort", {
57
- value: String(plan.spec.network?.gatewayPort ?? GATEWAY_PORT)
58
- });
59
- const modelProvider = plan.spec.openclaw.config?.["models"]?.["provider"];
60
- if (modelProvider === "bedrock") {
61
- await stack.setConfig("bedrockEnabled", { value: "true" });
62
- }
52
+ await writeStackConfig(stack, plan);
63
53
  if (plan.metadata.stackVersion !== void 0) {
64
54
  const currentInfo = await stack.info();
65
55
  if (currentInfo !== void 0 && currentInfo.version !== plan.metadata.stackVersion) {
@@ -86,6 +76,25 @@ The diff you reviewed may no longer reflect what will be applied.
86
76
  changeSummary[op] = count;
87
77
  }
88
78
  }
79
+ const { waitForSsh } = await import("./wait-WO72TRRQ.js");
80
+ const conn = await connectionInfoFor(ctx, outputs);
81
+ if (opts?.skipReadiness) {
82
+ return { outputs, changeSummary, durationMs: Date.now() - start };
83
+ }
84
+ const readySession = await waitForSsh(conn, {
85
+ signal: opts?.signal,
86
+ onProgress: (line) => reportProgress(opts, line)
87
+ });
88
+ const { waitForGateway } = await import("./ready-KDNRBNSU.js");
89
+ try {
90
+ await waitForGateway(readySession, {
91
+ signal: opts?.signal,
92
+ port: plan.spec.network?.gatewayPort ?? GATEWAY_PORT,
93
+ onProgress: (line) => reportProgress(opts, line)
94
+ });
95
+ } finally {
96
+ readySession.close();
97
+ }
89
98
  const hasOverlay = plan.spec.openclaw.config !== void 0 || plan.spec.openclaw.channels !== void 0;
90
99
  if (hasOverlay) {
91
100
  await applyConfigOverlay(plan, outputs, ctx, opts?.signal);
@@ -96,17 +105,24 @@ The diff you reviewed may no longer reflect what will be applied.
96
105
  durationMs: Date.now() - start
97
106
  };
98
107
  }
99
- async function applyConfigOverlay(plan, outputs, ctx, signal) {
100
- const { connect } = await import("./ssh-B3NZAU4I.js");
101
- const connInfo = ctx.adapter.getConnectionInfo(outputs);
102
- const session = await connect({
103
- host: connInfo.host,
104
- port: connInfo.port,
105
- user: connInfo.user,
106
- privateKeyPath: connInfo.privateKeyPath,
107
- knownHostsPath: connInfo.knownHostsPath,
108
- signal
108
+ function reportProgress(opts, line) {
109
+ if (opts?.onProgress) opts.onProgress(line);
110
+ else opts?.onOutput?.(line);
111
+ }
112
+ async function connectionInfoFor(ctx, outputs) {
113
+ const { extractBaseOutputs } = await import("./outputs-DJHBY7EE.js");
114
+ return ctx.adapter.getConnectionInfo({
115
+ ...extractBaseOutputs(outputs),
116
+ privateKeyPath: expandHome(ctx.config.ssh.keyPath),
117
+ knownHostsPath: expandHome(ctx.config.ssh.knownHostsPath)
109
118
  });
119
+ }
120
+ function expandHome(p) {
121
+ return p.replace(/^~/, process.env["HOME"] ?? "~");
122
+ }
123
+ async function applyConfigOverlay(plan, outputs, ctx, signal) {
124
+ const { connect } = await import("./ssh-VAI5DU5M.js");
125
+ const session = await connect({ ...await connectionInfoFor(ctx, outputs), signal });
110
126
  try {
111
127
  const remote = await readRemoteConfig(session, signal);
112
128
  const configOverlay = plan.spec.openclaw.config ?? {};
@@ -134,7 +150,7 @@ async function applyConfigOverlay(plan, outputs, ctx, signal) {
134
150
  async function installProviderPlugins(session, cfg, openclawVersion, signal) {
135
151
  const [{ requiredPlugins, installCommand }, { STATE_DIR_HOST_LINUX }, yaml, { readFileSync }, { join }, { resolveSpecDir }] = await Promise.all([
136
152
  import("./plugins-DTST3OER.js"),
137
- import("./runtime-LZ7NA53V.js"),
153
+ import("./runtime-X3KW5TCP.js"),
138
154
  import("./js-yaml-PTEEG4FO.js"),
139
155
  import("fs"),
140
156
  import("path"),
@@ -189,7 +205,7 @@ async function loadChannelCatalog() {
189
205
  return yaml.load(readFileSync(join(resolveSpecDir(), "integrations.yaml"), "utf-8"));
190
206
  }
191
207
  async function installChannelPlugins(session, cfg, openclawVersion, signal) {
192
- const [{ requiredChannelPlugins, channelInstallCommand }, { STATE_DIR_HOST_LINUX }] = await Promise.all([import("./channels-KBUR42IU.js"), import("./runtime-LZ7NA53V.js")]);
208
+ const [{ requiredChannelPlugins, channelInstallCommand }, { STATE_DIR_HOST_LINUX }] = await Promise.all([import("./channels-KBUR42IU.js"), import("./runtime-X3KW5TCP.js")]);
193
209
  const needed = requiredChannelPlugins(cfg, await loadChannelCatalog());
194
210
  if (needed.length === 0) return;
195
211
  const { execPrivileged } = await import("./privileged-JFA6LLTV.js");