@forgezero/agent 0.1.78 → 0.1.79

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.
@@ -750,7 +750,7 @@ async function postSignedNode(options, path, body) {
750
750
  }
751
751
 
752
752
  // src/version.ts
753
- var VERSION3 = "0.1.78";
753
+ var VERSION3 = "0.1.79";
754
754
 
755
755
  // src/agent-heartbeat.ts
756
756
  function readAgentHostMetrics() {
package/dist/bootstrap.js CHANGED
@@ -1416,7 +1416,7 @@ var UPDATE_RETRY_BASE_MS = 5 * 60000;
1416
1416
  var UPDATE_RETRY_MAX_MS = 24 * 60 * 60000;
1417
1417
 
1418
1418
  // src/version.ts
1419
- var VERSION = "0.1.78";
1419
+ var VERSION = "0.1.79";
1420
1420
 
1421
1421
  // src/software.ts
1422
1422
  var PINNED_BUN_VERSION = "1.3.14";
@@ -165,16 +165,38 @@ var runSoftwareCommand = async (argv, env = {}) => {
165
165
  return { exitCode, output: `${stdout}${stderr}` };
166
166
  };
167
167
  var run = runSoftwareCommand;
168
+ var softwareDownloadCommand = (url, destination, maximumBytes) => {
169
+ const source = new URL(url);
170
+ if (source.protocol !== "https:" || source.username || source.password)
171
+ throw new Error("software download must use credential-free HTTPS");
172
+ if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 1)
173
+ throw new Error("software download size bound is invalid");
174
+ return [
175
+ "/usr/bin/curl",
176
+ "--fail",
177
+ "--location",
178
+ "--silent",
179
+ "--show-error",
180
+ "--proto",
181
+ "=https",
182
+ "--tlsv1.2",
183
+ "--max-time",
184
+ "1800",
185
+ "--max-filesize",
186
+ String(maximumBytes),
187
+ "--output",
188
+ destination,
189
+ source.href
190
+ ];
191
+ };
168
192
  var download = async (url, destination, sha256, maximumBytes = 512 * 1024 * 1024) => {
169
- const response = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(30 * 60000) });
170
- if (!response.ok)
171
- throw new Error(`download failed with HTTP ${response.status}`);
172
- const declared = Number(response.headers.get("content-length") ?? 0);
173
- if (declared > maximumBytes)
174
- throw new Error("download exceeds reviewed size bound");
175
193
  if (existsSync(destination))
176
194
  throw new Error("download destination already exists");
177
- await Bun.write(destination, response);
195
+ const received = await run(softwareDownloadCommand(url, destination, maximumBytes));
196
+ if (received.exitCode !== 0) {
197
+ rmSync(destination, { force: true });
198
+ throw new Error(`software download failed (${received.exitCode}): ${received.output.trim()}`);
199
+ }
178
200
  chmodSync(destination, 384);
179
201
  if (statSync(destination).size > maximumBytes) {
180
202
  rmSync(destination, { force: true });
@@ -165,16 +165,38 @@ var runSoftwareCommand = async (argv, env = {}) => {
165
165
  return { exitCode, output: `${stdout}${stderr}` };
166
166
  };
167
167
  var run = runSoftwareCommand;
168
+ var softwareDownloadCommand = (url, destination, maximumBytes) => {
169
+ const source = new URL(url);
170
+ if (source.protocol !== "https:" || source.username || source.password)
171
+ throw new Error("software download must use credential-free HTTPS");
172
+ if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 1)
173
+ throw new Error("software download size bound is invalid");
174
+ return [
175
+ "/usr/bin/curl",
176
+ "--fail",
177
+ "--location",
178
+ "--silent",
179
+ "--show-error",
180
+ "--proto",
181
+ "=https",
182
+ "--tlsv1.2",
183
+ "--max-time",
184
+ "1800",
185
+ "--max-filesize",
186
+ String(maximumBytes),
187
+ "--output",
188
+ destination,
189
+ source.href
190
+ ];
191
+ };
168
192
  var download = async (url, destination, sha256, maximumBytes = 512 * 1024 * 1024) => {
169
- const response = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(30 * 60000) });
170
- if (!response.ok)
171
- throw new Error(`download failed with HTTP ${response.status}`);
172
- const declared = Number(response.headers.get("content-length") ?? 0);
173
- if (declared > maximumBytes)
174
- throw new Error("download exceeds reviewed size bound");
175
193
  if (existsSync(destination))
176
194
  throw new Error("download destination already exists");
177
- await Bun.write(destination, response);
195
+ const received = await run(softwareDownloadCommand(url, destination, maximumBytes));
196
+ if (received.exitCode !== 0) {
197
+ rmSync(destination, { force: true });
198
+ throw new Error(`software download failed (${received.exitCode}): ${received.output.trim()}`);
199
+ }
178
200
  chmodSync(destination, 384);
179
201
  if (statSync(destination).size > maximumBytes) {
180
202
  rmSync(destination, { force: true });
@@ -165,16 +165,38 @@ var runSoftwareCommand = async (argv, env = {}) => {
165
165
  return { exitCode, output: `${stdout}${stderr}` };
166
166
  };
167
167
  var run = runSoftwareCommand;
168
+ var softwareDownloadCommand = (url, destination, maximumBytes) => {
169
+ const source = new URL(url);
170
+ if (source.protocol !== "https:" || source.username || source.password)
171
+ throw new Error("software download must use credential-free HTTPS");
172
+ if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 1)
173
+ throw new Error("software download size bound is invalid");
174
+ return [
175
+ "/usr/bin/curl",
176
+ "--fail",
177
+ "--location",
178
+ "--silent",
179
+ "--show-error",
180
+ "--proto",
181
+ "=https",
182
+ "--tlsv1.2",
183
+ "--max-time",
184
+ "1800",
185
+ "--max-filesize",
186
+ String(maximumBytes),
187
+ "--output",
188
+ destination,
189
+ source.href
190
+ ];
191
+ };
168
192
  var download = async (url, destination, sha256, maximumBytes = 512 * 1024 * 1024) => {
169
- const response = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(30 * 60000) });
170
- if (!response.ok)
171
- throw new Error(`download failed with HTTP ${response.status}`);
172
- const declared = Number(response.headers.get("content-length") ?? 0);
173
- if (declared > maximumBytes)
174
- throw new Error("download exceeds reviewed size bound");
175
193
  if (existsSync(destination))
176
194
  throw new Error("download destination already exists");
177
- await Bun.write(destination, response);
195
+ const received = await run(softwareDownloadCommand(url, destination, maximumBytes));
196
+ if (received.exitCode !== 0) {
197
+ rmSync(destination, { force: true });
198
+ throw new Error(`software download failed (${received.exitCode}): ${received.output.trim()}`);
199
+ }
178
200
  chmodSync(destination, 384);
179
201
  if (statSync(destination).size > maximumBytes) {
180
202
  rmSync(destination, { force: true });
package/dist/fz-agent.js CHANGED
@@ -5114,16 +5114,38 @@ var runSoftwareCommand = async (argv, env = {}) => {
5114
5114
  return { exitCode, output: `${stdout}${stderr}` };
5115
5115
  };
5116
5116
  var run = runSoftwareCommand;
5117
+ var softwareDownloadCommand = (url, destination, maximumBytes) => {
5118
+ const source = new URL(url);
5119
+ if (source.protocol !== "https:" || source.username || source.password)
5120
+ throw new Error("software download must use credential-free HTTPS");
5121
+ if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 1)
5122
+ throw new Error("software download size bound is invalid");
5123
+ return [
5124
+ "/usr/bin/curl",
5125
+ "--fail",
5126
+ "--location",
5127
+ "--silent",
5128
+ "--show-error",
5129
+ "--proto",
5130
+ "=https",
5131
+ "--tlsv1.2",
5132
+ "--max-time",
5133
+ "1800",
5134
+ "--max-filesize",
5135
+ String(maximumBytes),
5136
+ "--output",
5137
+ destination,
5138
+ source.href
5139
+ ];
5140
+ };
5117
5141
  var download = async (url, destination, sha2562, maximumBytes = 512 * 1024 * 1024) => {
5118
- const response = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(30 * 60000) });
5119
- if (!response.ok)
5120
- throw new Error(`download failed with HTTP ${response.status}`);
5121
- const declared = Number(response.headers.get("content-length") ?? 0);
5122
- if (declared > maximumBytes)
5123
- throw new Error("download exceeds reviewed size bound");
5124
5142
  if (existsSync2(destination))
5125
5143
  throw new Error("download destination already exists");
5126
- await Bun.write(destination, response);
5144
+ const received = await run(softwareDownloadCommand(url, destination, maximumBytes));
5145
+ if (received.exitCode !== 0) {
5146
+ rmSync(destination, { force: true });
5147
+ throw new Error(`software download failed (${received.exitCode}): ${received.output.trim()}`);
5148
+ }
5127
5149
  chmodSync2(destination, 384);
5128
5150
  if (statSync(destination).size > maximumBytes) {
5129
5151
  rmSync(destination, { force: true });
@@ -9193,7 +9215,7 @@ async function writeAndCloseProcessInput(input, value) {
9193
9215
  }
9194
9216
 
9195
9217
  // src/version.ts
9196
- var VERSION2 = "0.1.78";
9218
+ var VERSION2 = "0.1.79";
9197
9219
 
9198
9220
  // src/ssh-bootstrap.ts
9199
9221
  class SshBootstrapError extends Error {
package/dist/fz.js CHANGED
@@ -4837,7 +4837,7 @@ var UPDATE_RETRY_BASE_MS = 5 * 60000;
4837
4837
  var UPDATE_RETRY_MAX_MS = 24 * 60 * 60000;
4838
4838
 
4839
4839
  // src/version.ts
4840
- var VERSION2 = "0.1.78";
4840
+ var VERSION2 = "0.1.79";
4841
4841
 
4842
4842
  // src/software.ts
4843
4843
  var PINNED_BUN_VERSION = "1.3.14";
@@ -354,7 +354,7 @@ function systemdAgentEgressDirectives(loopbackTcpPorts = []) {
354
354
  }
355
355
 
356
356
  // src/version.ts
357
- var VERSION = "0.1.78";
357
+ var VERSION = "0.1.79";
358
358
 
359
359
  // src/otel-collector.ts
360
360
  var FORGEZERO_OTEL_COLLECTOR_UNIT = "forgezero-otel-collector.service";
@@ -305,16 +305,38 @@ var runSoftwareCommand = async (argv, env = {}) => {
305
305
  return { exitCode, output: `${stdout}${stderr}` };
306
306
  };
307
307
  var run = runSoftwareCommand;
308
+ var softwareDownloadCommand = (url, destination, maximumBytes) => {
309
+ const source = new URL(url);
310
+ if (source.protocol !== "https:" || source.username || source.password)
311
+ throw new Error("software download must use credential-free HTTPS");
312
+ if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 1)
313
+ throw new Error("software download size bound is invalid");
314
+ return [
315
+ "/usr/bin/curl",
316
+ "--fail",
317
+ "--location",
318
+ "--silent",
319
+ "--show-error",
320
+ "--proto",
321
+ "=https",
322
+ "--tlsv1.2",
323
+ "--max-time",
324
+ "1800",
325
+ "--max-filesize",
326
+ String(maximumBytes),
327
+ "--output",
328
+ destination,
329
+ source.href
330
+ ];
331
+ };
308
332
  var download = async (url, destination, sha256, maximumBytes = 512 * 1024 * 1024) => {
309
- const response = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(30 * 60000) });
310
- if (!response.ok)
311
- throw new Error(`download failed with HTTP ${response.status}`);
312
- const declared = Number(response.headers.get("content-length") ?? 0);
313
- if (declared > maximumBytes)
314
- throw new Error("download exceeds reviewed size bound");
315
333
  if (existsSync(destination))
316
334
  throw new Error("download destination already exists");
317
- await Bun.write(destination, response);
335
+ const received = await run(softwareDownloadCommand(url, destination, maximumBytes));
336
+ if (received.exitCode !== 0) {
337
+ rmSync(destination, { force: true });
338
+ throw new Error(`software download failed (${received.exitCode}): ${received.output.trim()}`);
339
+ }
318
340
  chmodSync(destination, 384);
319
341
  if (statSync(destination).size > maximumBytes) {
320
342
  rmSync(destination, { force: true });
@@ -305,16 +305,38 @@ var runSoftwareCommand = async (argv, env = {}) => {
305
305
  return { exitCode, output: `${stdout}${stderr}` };
306
306
  };
307
307
  var run = runSoftwareCommand;
308
+ var softwareDownloadCommand = (url, destination, maximumBytes) => {
309
+ const source = new URL(url);
310
+ if (source.protocol !== "https:" || source.username || source.password)
311
+ throw new Error("software download must use credential-free HTTPS");
312
+ if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 1)
313
+ throw new Error("software download size bound is invalid");
314
+ return [
315
+ "/usr/bin/curl",
316
+ "--fail",
317
+ "--location",
318
+ "--silent",
319
+ "--show-error",
320
+ "--proto",
321
+ "=https",
322
+ "--tlsv1.2",
323
+ "--max-time",
324
+ "1800",
325
+ "--max-filesize",
326
+ String(maximumBytes),
327
+ "--output",
328
+ destination,
329
+ source.href
330
+ ];
331
+ };
308
332
  var download = async (url, destination, sha256, maximumBytes = 512 * 1024 * 1024) => {
309
- const response = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(30 * 60000) });
310
- if (!response.ok)
311
- throw new Error(`download failed with HTTP ${response.status}`);
312
- const declared = Number(response.headers.get("content-length") ?? 0);
313
- if (declared > maximumBytes)
314
- throw new Error("download exceeds reviewed size bound");
315
333
  if (existsSync(destination))
316
334
  throw new Error("download destination already exists");
317
- await Bun.write(destination, response);
335
+ const received = await run(softwareDownloadCommand(url, destination, maximumBytes));
336
+ if (received.exitCode !== 0) {
337
+ rmSync(destination, { force: true });
338
+ throw new Error(`software download failed (${received.exitCode}): ${received.output.trim()}`);
339
+ }
318
340
  chmodSync(destination, 384);
319
341
  if (statSync(destination).size > maximumBytes) {
320
342
  rmSync(destination, { force: true });
@@ -1416,7 +1416,7 @@ var UPDATE_RETRY_BASE_MS = 5 * 60000;
1416
1416
  var UPDATE_RETRY_MAX_MS = 24 * 60 * 60000;
1417
1417
 
1418
1418
  // src/version.ts
1419
- var VERSION = "0.1.78";
1419
+ var VERSION = "0.1.79";
1420
1420
 
1421
1421
  // src/software.ts
1422
1422
  var PINNED_BUN_VERSION = "1.3.14";
@@ -165,16 +165,38 @@ var runSoftwareCommand = async (argv, env = {}) => {
165
165
  return { exitCode, output: `${stdout}${stderr}` };
166
166
  };
167
167
  var run = runSoftwareCommand;
168
+ var softwareDownloadCommand = (url, destination, maximumBytes) => {
169
+ const source = new URL(url);
170
+ if (source.protocol !== "https:" || source.username || source.password)
171
+ throw new Error("software download must use credential-free HTTPS");
172
+ if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 1)
173
+ throw new Error("software download size bound is invalid");
174
+ return [
175
+ "/usr/bin/curl",
176
+ "--fail",
177
+ "--location",
178
+ "--silent",
179
+ "--show-error",
180
+ "--proto",
181
+ "=https",
182
+ "--tlsv1.2",
183
+ "--max-time",
184
+ "1800",
185
+ "--max-filesize",
186
+ String(maximumBytes),
187
+ "--output",
188
+ destination,
189
+ source.href
190
+ ];
191
+ };
168
192
  var download = async (url, destination, sha256, maximumBytes = 512 * 1024 * 1024) => {
169
- const response = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(30 * 60000) });
170
- if (!response.ok)
171
- throw new Error(`download failed with HTTP ${response.status}`);
172
- const declared = Number(response.headers.get("content-length") ?? 0);
173
- if (declared > maximumBytes)
174
- throw new Error("download exceeds reviewed size bound");
175
193
  if (existsSync(destination))
176
194
  throw new Error("download destination already exists");
177
- await Bun.write(destination, response);
195
+ const received = await run(softwareDownloadCommand(url, destination, maximumBytes));
196
+ if (received.exitCode !== 0) {
197
+ rmSync(destination, { force: true });
198
+ throw new Error(`software download failed (${received.exitCode}): ${received.output.trim()}`);
199
+ }
178
200
  chmodSync(destination, 384);
179
201
  if (statSync(destination).size > maximumBytes) {
180
202
  rmSync(destination, { force: true });
@@ -843,16 +843,38 @@ var runSoftwareCommand = async (argv, env = {}) => {
843
843
  return { exitCode, output: `${stdout}${stderr}` };
844
844
  };
845
845
  var run = runSoftwareCommand;
846
+ var softwareDownloadCommand = (url, destination, maximumBytes) => {
847
+ const source = new URL(url);
848
+ if (source.protocol !== "https:" || source.username || source.password)
849
+ throw new Error("software download must use credential-free HTTPS");
850
+ if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 1)
851
+ throw new Error("software download size bound is invalid");
852
+ return [
853
+ "/usr/bin/curl",
854
+ "--fail",
855
+ "--location",
856
+ "--silent",
857
+ "--show-error",
858
+ "--proto",
859
+ "=https",
860
+ "--tlsv1.2",
861
+ "--max-time",
862
+ "1800",
863
+ "--max-filesize",
864
+ String(maximumBytes),
865
+ "--output",
866
+ destination,
867
+ source.href
868
+ ];
869
+ };
846
870
  var download = async (url, destination, sha256, maximumBytes = 512 * 1024 * 1024) => {
847
- const response = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(30 * 60000) });
848
- if (!response.ok)
849
- throw new Error(`download failed with HTTP ${response.status}`);
850
- const declared = Number(response.headers.get("content-length") ?? 0);
851
- if (declared > maximumBytes)
852
- throw new Error("download exceeds reviewed size bound");
853
871
  if (existsSync3(destination))
854
872
  throw new Error("download destination already exists");
855
- await Bun.write(destination, response);
873
+ const received = await run(softwareDownloadCommand(url, destination, maximumBytes));
874
+ if (received.exitCode !== 0) {
875
+ rmSync3(destination, { force: true });
876
+ throw new Error(`software download failed (${received.exitCode}): ${received.output.trim()}`);
877
+ }
856
878
  chmodSync3(destination, 384);
857
879
  if (statSync(destination).size > maximumBytes) {
858
880
  rmSync3(destination, { force: true });
@@ -2498,7 +2520,7 @@ function requestSoftware(requirements, socketPath = DEFAULT_SOFTWARE_HELPER_SOCK
2498
2520
  }
2499
2521
 
2500
2522
  // src/version.ts
2501
- var VERSION3 = "0.1.78";
2523
+ var VERSION3 = "0.1.79";
2502
2524
 
2503
2525
  // src/egress-policy.ts
2504
2526
  import { realpathSync as realpathSync3 } from "node:fs";
@@ -165,16 +165,38 @@ var runSoftwareCommand = async (argv, env = {}) => {
165
165
  return { exitCode, output: `${stdout}${stderr}` };
166
166
  };
167
167
  var run = runSoftwareCommand;
168
+ var softwareDownloadCommand = (url, destination, maximumBytes) => {
169
+ const source = new URL(url);
170
+ if (source.protocol !== "https:" || source.username || source.password)
171
+ throw new Error("software download must use credential-free HTTPS");
172
+ if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 1)
173
+ throw new Error("software download size bound is invalid");
174
+ return [
175
+ "/usr/bin/curl",
176
+ "--fail",
177
+ "--location",
178
+ "--silent",
179
+ "--show-error",
180
+ "--proto",
181
+ "=https",
182
+ "--tlsv1.2",
183
+ "--max-time",
184
+ "1800",
185
+ "--max-filesize",
186
+ String(maximumBytes),
187
+ "--output",
188
+ destination,
189
+ source.href
190
+ ];
191
+ };
168
192
  var download = async (url, destination, sha256, maximumBytes = 512 * 1024 * 1024) => {
169
- const response = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(30 * 60000) });
170
- if (!response.ok)
171
- throw new Error(`download failed with HTTP ${response.status}`);
172
- const declared = Number(response.headers.get("content-length") ?? 0);
173
- if (declared > maximumBytes)
174
- throw new Error("download exceeds reviewed size bound");
175
193
  if (existsSync(destination))
176
194
  throw new Error("download destination already exists");
177
- await Bun.write(destination, response);
195
+ const received = await run(softwareDownloadCommand(url, destination, maximumBytes));
196
+ if (received.exitCode !== 0) {
197
+ rmSync(destination, { force: true });
198
+ throw new Error(`software download failed (${received.exitCode}): ${received.output.trim()}`);
199
+ }
178
200
  chmodSync(destination, 384);
179
201
  if (statSync(destination).size > maximumBytes) {
180
202
  rmSync(destination, { force: true });
package/dist/provision.js CHANGED
@@ -843,16 +843,38 @@ var runSoftwareCommand = async (argv, env = {}) => {
843
843
  return { exitCode, output: `${stdout}${stderr}` };
844
844
  };
845
845
  var run = runSoftwareCommand;
846
+ var softwareDownloadCommand = (url, destination, maximumBytes) => {
847
+ const source = new URL(url);
848
+ if (source.protocol !== "https:" || source.username || source.password)
849
+ throw new Error("software download must use credential-free HTTPS");
850
+ if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 1)
851
+ throw new Error("software download size bound is invalid");
852
+ return [
853
+ "/usr/bin/curl",
854
+ "--fail",
855
+ "--location",
856
+ "--silent",
857
+ "--show-error",
858
+ "--proto",
859
+ "=https",
860
+ "--tlsv1.2",
861
+ "--max-time",
862
+ "1800",
863
+ "--max-filesize",
864
+ String(maximumBytes),
865
+ "--output",
866
+ destination,
867
+ source.href
868
+ ];
869
+ };
846
870
  var download = async (url, destination, sha256, maximumBytes = 512 * 1024 * 1024) => {
847
- const response = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(30 * 60000) });
848
- if (!response.ok)
849
- throw new Error(`download failed with HTTP ${response.status}`);
850
- const declared = Number(response.headers.get("content-length") ?? 0);
851
- if (declared > maximumBytes)
852
- throw new Error("download exceeds reviewed size bound");
853
871
  if (existsSync3(destination))
854
872
  throw new Error("download destination already exists");
855
- await Bun.write(destination, response);
873
+ const received = await run(softwareDownloadCommand(url, destination, maximumBytes));
874
+ if (received.exitCode !== 0) {
875
+ rmSync3(destination, { force: true });
876
+ throw new Error(`software download failed (${received.exitCode}): ${received.output.trim()}`);
877
+ }
856
878
  chmodSync3(destination, 384);
857
879
  if (statSync(destination).size > maximumBytes) {
858
880
  rmSync3(destination, { force: true });
@@ -2498,7 +2520,7 @@ function requestSoftware(requirements, socketPath = DEFAULT_SOFTWARE_HELPER_SOCK
2498
2520
  }
2499
2521
 
2500
2522
  // src/version.ts
2501
- var VERSION3 = "0.1.78";
2523
+ var VERSION3 = "0.1.79";
2502
2524
 
2503
2525
  // src/egress-policy.ts
2504
2526
  import { realpathSync as realpathSync3 } from "node:fs";
@@ -165,16 +165,38 @@ var runSoftwareCommand = async (argv, env = {}) => {
165
165
  return { exitCode, output: `${stdout}${stderr}` };
166
166
  };
167
167
  var run = runSoftwareCommand;
168
+ var softwareDownloadCommand = (url, destination, maximumBytes) => {
169
+ const source = new URL(url);
170
+ if (source.protocol !== "https:" || source.username || source.password)
171
+ throw new Error("software download must use credential-free HTTPS");
172
+ if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 1)
173
+ throw new Error("software download size bound is invalid");
174
+ return [
175
+ "/usr/bin/curl",
176
+ "--fail",
177
+ "--location",
178
+ "--silent",
179
+ "--show-error",
180
+ "--proto",
181
+ "=https",
182
+ "--tlsv1.2",
183
+ "--max-time",
184
+ "1800",
185
+ "--max-filesize",
186
+ String(maximumBytes),
187
+ "--output",
188
+ destination,
189
+ source.href
190
+ ];
191
+ };
168
192
  var download = async (url, destination, sha256, maximumBytes = 512 * 1024 * 1024) => {
169
- const response = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(30 * 60000) });
170
- if (!response.ok)
171
- throw new Error(`download failed with HTTP ${response.status}`);
172
- const declared = Number(response.headers.get("content-length") ?? 0);
173
- if (declared > maximumBytes)
174
- throw new Error("download exceeds reviewed size bound");
175
193
  if (existsSync(destination))
176
194
  throw new Error("download destination already exists");
177
- await Bun.write(destination, response);
195
+ const received = await run(softwareDownloadCommand(url, destination, maximumBytes));
196
+ if (received.exitCode !== 0) {
197
+ rmSync(destination, { force: true });
198
+ throw new Error(`software download failed (${received.exitCode}): ${received.output.trim()}`);
199
+ }
178
200
  chmodSync(destination, 384);
179
201
  if (statSync(destination).size > maximumBytes) {
180
202
  rmSync(destination, { force: true });
@@ -57,6 +57,7 @@ export declare const OS_CATALOG: readonly OsCatalogEntry[];
57
57
  export declare const SOFTWARE_CATALOG: readonly SoftwareCatalogEntry[];
58
58
  export declare const softwareSpawnFailure: (cause: unknown, argv: readonly string[]) => SoftwareCommandResult | undefined;
59
59
  export declare const runSoftwareCommand: (argv: readonly string[], env?: Record<string, string>) => Promise<SoftwareCommandResult>;
60
+ export declare const softwareDownloadCommand: (url: string, destination: string, maximumBytes: number) => readonly string[];
60
61
  /** Closed, fixed-argv privileged strategy executor. No repository value becomes a command. */
61
62
  export declare function executeSoftwareOperation(operation: SoftwareOperation): Promise<SoftwareCommandResult>;
62
63
  export declare function observeSoftwareHost(osRelease?: string, architecture?: NodeJS.Architecture): SoftwareObservation;
package/dist/software.js CHANGED
@@ -165,16 +165,38 @@ var runSoftwareCommand = async (argv, env = {}) => {
165
165
  return { exitCode, output: `${stdout}${stderr}` };
166
166
  };
167
167
  var run = runSoftwareCommand;
168
+ var softwareDownloadCommand = (url, destination, maximumBytes) => {
169
+ const source = new URL(url);
170
+ if (source.protocol !== "https:" || source.username || source.password)
171
+ throw new Error("software download must use credential-free HTTPS");
172
+ if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 1)
173
+ throw new Error("software download size bound is invalid");
174
+ return [
175
+ "/usr/bin/curl",
176
+ "--fail",
177
+ "--location",
178
+ "--silent",
179
+ "--show-error",
180
+ "--proto",
181
+ "=https",
182
+ "--tlsv1.2",
183
+ "--max-time",
184
+ "1800",
185
+ "--max-filesize",
186
+ String(maximumBytes),
187
+ "--output",
188
+ destination,
189
+ source.href
190
+ ];
191
+ };
168
192
  var download = async (url, destination, sha256, maximumBytes = 512 * 1024 * 1024) => {
169
- const response = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(30 * 60000) });
170
- if (!response.ok)
171
- throw new Error(`download failed with HTTP ${response.status}`);
172
- const declared = Number(response.headers.get("content-length") ?? 0);
173
- if (declared > maximumBytes)
174
- throw new Error("download exceeds reviewed size bound");
175
193
  if (existsSync(destination))
176
194
  throw new Error("download destination already exists");
177
- await Bun.write(destination, response);
195
+ const received = await run(softwareDownloadCommand(url, destination, maximumBytes));
196
+ if (received.exitCode !== 0) {
197
+ rmSync(destination, { force: true });
198
+ throw new Error(`software download failed (${received.exitCode}): ${received.output.trim()}`);
199
+ }
178
200
  chmodSync(destination, 384);
179
201
  if (statSync(destination).size > maximumBytes) {
180
202
  rmSync(destination, { force: true });
@@ -518,6 +540,7 @@ async function ensureSoftwareRequirements(requirementsInput, options) {
518
540
  export {
519
541
  validateSoftwareRequirements,
520
542
  softwareSpawnFailure,
543
+ softwareDownloadCommand,
521
544
  runSoftwareCommand,
522
545
  observeSoftwareHost,
523
546
  executeSoftwareOperation,
package/dist/ubuntu.js CHANGED
@@ -165,16 +165,38 @@ var runSoftwareCommand = async (argv, env = {}) => {
165
165
  return { exitCode, output: `${stdout}${stderr}` };
166
166
  };
167
167
  var run = runSoftwareCommand;
168
+ var softwareDownloadCommand = (url, destination, maximumBytes) => {
169
+ const source = new URL(url);
170
+ if (source.protocol !== "https:" || source.username || source.password)
171
+ throw new Error("software download must use credential-free HTTPS");
172
+ if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 1)
173
+ throw new Error("software download size bound is invalid");
174
+ return [
175
+ "/usr/bin/curl",
176
+ "--fail",
177
+ "--location",
178
+ "--silent",
179
+ "--show-error",
180
+ "--proto",
181
+ "=https",
182
+ "--tlsv1.2",
183
+ "--max-time",
184
+ "1800",
185
+ "--max-filesize",
186
+ String(maximumBytes),
187
+ "--output",
188
+ destination,
189
+ source.href
190
+ ];
191
+ };
168
192
  var download = async (url, destination, sha256, maximumBytes = 512 * 1024 * 1024) => {
169
- const response = await fetch(url, { redirect: "follow", signal: AbortSignal.timeout(30 * 60000) });
170
- if (!response.ok)
171
- throw new Error(`download failed with HTTP ${response.status}`);
172
- const declared = Number(response.headers.get("content-length") ?? 0);
173
- if (declared > maximumBytes)
174
- throw new Error("download exceeds reviewed size bound");
175
193
  if (existsSync(destination))
176
194
  throw new Error("download destination already exists");
177
- await Bun.write(destination, response);
195
+ const received = await run(softwareDownloadCommand(url, destination, maximumBytes));
196
+ if (received.exitCode !== 0) {
197
+ rmSync(destination, { force: true });
198
+ throw new Error(`software download failed (${received.exitCode}): ${received.output.trim()}`);
199
+ }
178
200
  chmodSync(destination, 384);
179
201
  if (statSync(destination).size > maximumBytes) {
180
202
  rmSync(destination, { force: true });
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  /** One package version shared by both public binaries. Pinned to package.json by tests. */
2
- export declare const VERSION = "0.1.78";
2
+ export declare const VERSION = "0.1.79";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgezero/agent",
3
- "version": "0.1.78",
3
+ "version": "0.1.79",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "check": "tsc --noEmit",