openship 0.6.6 → 0.6.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 (58) hide show
  1. package/dist/bare-7QD623QV.js +29 -0
  2. package/dist/{chunk-Q7WGTQQ5.js → chunk-2ANV5ZQ5.js} +1 -1
  3. package/dist/{chunk-UJ6JZM65.js → chunk-2VSW6Q6C.js} +601 -382
  4. package/dist/{chunk-PCPVTH6M.js → chunk-5T4UVOM3.js} +6 -4
  5. package/dist/{chunk-YMMQRE5J.js → chunk-BLEXTYRK.js} +1 -1
  6. package/dist/{chunk-OBPKYXQL.js → chunk-CIJV43LH.js} +71 -32
  7. package/dist/{chunk-NK5N5LXN.js → chunk-DDFUESPJ.js} +24 -9
  8. package/dist/{chunk-6FH4AXVY.js → chunk-E2X26PXR.js} +1 -1
  9. package/dist/{chunk-HKRQXPTI.js → chunk-FYPFEDPZ.js} +1 -1
  10. package/dist/{chunk-UVNMQM7W.js → chunk-FZ6QCF6B.js} +8 -6
  11. package/dist/{chunk-MLYSEZQB.js → chunk-GGIAIGUL.js} +15 -66
  12. package/dist/{chunk-2YM3NI2E.js → chunk-GIPJNNI5.js} +38 -44
  13. package/dist/{chunk-ZFJXPCQP.js → chunk-H3WT3A6R.js} +4 -3
  14. package/dist/chunk-H4FS5BED.js +936 -0
  15. package/dist/{chunk-CBLD2HS5.js → chunk-J2XM3QSP.js} +8 -5
  16. package/dist/{chunk-FE7ZZQSE.js → chunk-J3K6XABC.js} +3 -3
  17. package/dist/{chunk-77QDF6UD.js → chunk-LHFXSC36.js} +428 -93
  18. package/dist/{chunk-YIMOCZBZ.js → chunk-MEE6OZFP.js} +3 -3
  19. package/dist/chunk-N5YZMO33.js +111 -0
  20. package/dist/{chunk-QVW76WDL.js → chunk-NRTJRNAE.js} +58 -16
  21. package/dist/{chunk-WVAML4H6.js → chunk-PPEBIY5F.js} +247 -61
  22. package/dist/{chunk-4I2BM2DT.js → chunk-PVP4RGWT.js} +3 -3
  23. package/dist/{chunk-RSR7PFIQ.js → chunk-QHMDCYZ3.js} +4 -4
  24. package/dist/chunk-R4VDPFLS.js +106 -0
  25. package/dist/{chunk-VTGPEC6B.js → chunk-RDXT4BQB.js} +6 -4
  26. package/dist/{chunk-LFE5KQ7Y.js → chunk-S6B2Z3OO.js} +142 -57
  27. package/dist/chunk-UWEV6XTS.js +249 -0
  28. package/dist/{chunk-5DMWSTOM.js → chunk-VQM6JHJB.js} +940 -224
  29. package/dist/{chunk-SM26HDS2.js → chunk-VSTFHUCV.js} +44 -50
  30. package/dist/chunk-WU54BXFE.js +70 -0
  31. package/dist/{chunk-LUKYPVJ4.js → chunk-XWHWTHEL.js} +313 -469
  32. package/dist/{chunk-A4GXYE4L.js → chunk-ZPJ74LXE.js} +22 -20
  33. package/dist/cloud-KNNABE3O.js +40 -0
  34. package/dist/{detect-OIE5V3VZ.js → detect-G4DR3U2N.js} +9 -6
  35. package/dist/{docker-VTR2GK5Y.js → docker-YOVPCIB4.js} +11 -8
  36. package/dist/{docker-edge-executor-22IBXNYJ.js → docker-edge-executor-QFXD3337.js} +8 -6
  37. package/dist/edge-import-CRFVSR6P.js +56 -0
  38. package/dist/{edge-preflight-GBNCPNVU.js → edge-preflight-MXERVAMG.js} +15 -12
  39. package/dist/{ensure-container-edge-KPI2CVXJ.js → ensure-container-edge-F4JUNQIK.js} +13 -10
  40. package/dist/{executor-7LXXZPBR.js → executor-CVPAYYHR.js} +8 -6
  41. package/dist/host-channel-preflight-QTDNGLCK.js +54 -0
  42. package/dist/index.js +84 -48
  43. package/dist/{local-executor-WOFZD72X.js → local-executor-ODC6RANU.js} +3 -2
  44. package/dist/{nginx-KUFMLMAC.js → nginx-KLFF43TC.js} +11 -8
  45. package/dist/{openresty-lua-ATTH35BE.js → openresty-lua-VKWUV4GB.js} +6 -5
  46. package/dist/{privilege-I4W3ZNZK.js → privilege-7D3SSOL3.js} +6 -5
  47. package/dist/server/index.js +8813 -5232
  48. package/dist/setup-I5AJC6NJ.js +25 -0
  49. package/dist/{ssh-client-JBMA7SN4.js → ssh-client-625VWGKP.js} +3 -2
  50. package/dist/up-QXTOOVXC.js +61 -0
  51. package/package.json +1 -1
  52. package/dist/bare-OXJVW3AK.js +0 -25
  53. package/dist/chunk-LH2PLRQO.js +0 -434
  54. package/dist/cloud-75VIT4KV.js +0 -37
  55. package/dist/edge-import-WJUB4M7F.js +0 -52
  56. package/dist/host-channel-preflight-KE6OONYK.js +0 -50
  57. package/dist/setup-XGLGUUFW.js +0 -22
  58. package/dist/up-K4BV7466.js +0 -57
@@ -6,13 +6,13 @@ import {
6
6
  detectBuildKillHint,
7
7
  runBuildPipeline,
8
8
  transferLocalDirectory
9
- } from "./chunk-LH2PLRQO.js";
9
+ } from "./chunk-H4FS5BED.js";
10
10
  import {
11
11
  LocalExecutor
12
- } from "./chunk-6FH4AXVY.js";
12
+ } from "./chunk-E2X26PXR.js";
13
13
  import {
14
14
  wrapLocalBuildCommand
15
- } from "./chunk-ZFJXPCQP.js";
15
+ } from "./chunk-H3WT3A6R.js";
16
16
 
17
17
  // ../../packages/adapters/src/runtime/local-build.ts
18
18
  var LOCAL_BUILD_DIR = "/tmp/openship/.builds";
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env sh
2
+ ":" //# ; exec "$(command -v node || command -v bun)" "$0" "$@"
3
+ import { createRequire as __ospCreateRequire } from "node:module";
4
+ const require = __ospCreateRequire(import.meta.url);
5
+
6
+ // ../../packages/adapters/src/system/errors.ts
7
+ var SSH_AUTH_ERROR_PATTERNS = [
8
+ "All configured authentication methods failed"
9
+ ];
10
+ var RETRYABLE_CONNECTION_ERROR_PATTERNS = [
11
+ "ECONNRESET",
12
+ "ECONNREFUSED",
13
+ "ETIMEDOUT",
14
+ "EHOSTUNREACH",
15
+ "ENETUNREACH",
16
+ "Timed out",
17
+ "Not connected",
18
+ "Connection lost",
19
+ "read ECONNRESET",
20
+ "Handshake failed",
21
+ "keepalive timeout",
22
+ "SSH connection closed before ready",
23
+ // ssh2 emits "Channel open failure: open failed" / "Channel open failure: …"
24
+ // when the SSH SERVER refuses a new channel - typically because the cached
25
+ // connection has gone half-dead (peer-side LOGOUT, network blip,
26
+ // remote sshd MaxSessions). The inner SshExecutor retries `exec`/
27
+ // `streamExec` on this, but `pipeLocal`, `transferIn`, and any other
28
+ // channel-bearing op bubble it up. Listing it here lets `withExecutor`
29
+ // drop the dead connection and retry transparently - fixes the
30
+ // "first redeploy fails, second click works" pattern.
31
+ "Channel open failure",
32
+ "open failed"
33
+ // NOT "socket hang up": it is what an HTTP client reports for ANY far end that vanished
34
+ // mid-request, including a permission-denied Docker socket and a wedged channel, neither
35
+ // of which a fresh connection fixes. A match here makes `withExecutor` replay its whole
36
+ // callback — and those callbacks install mail, create mailboxes and ensure the edge, so a
37
+ // non-retryable cause becomes a repeated mutation. `core/connectivity.ts` labels it
38
+ // without retrying, `api/lib/remote-state.ts` still maps it to a 503, and the bridge's
39
+ // 502 carries the real reason — so leaving it out here costs no diagnosis.
40
+ ];
41
+ var SshDisconnectedError = class extends Error {
42
+ constructor(message = "SSH connection lost") {
43
+ super(message);
44
+ this.name = "SshDisconnectedError";
45
+ }
46
+ };
47
+ function isSshDisconnectedError(err) {
48
+ return err instanceof SshDisconnectedError || err instanceof Error && err.name === "SshDisconnectedError";
49
+ }
50
+ function isSshAuthError(err) {
51
+ if (!(err instanceof Error)) return false;
52
+ return SSH_AUTH_ERROR_PATTERNS.some((pattern) => err.message.includes(pattern));
53
+ }
54
+ var HostChannelUnavailableError = class extends Error {
55
+ code;
56
+ constructor(code, message) {
57
+ super(message);
58
+ this.name = "HostChannelUnavailableError";
59
+ this.code = code;
60
+ }
61
+ };
62
+ function isRetryableRemoteConnectionError(err) {
63
+ if (isSshDisconnectedError(err)) return true;
64
+ if (!(err instanceof Error)) return false;
65
+ return RETRYABLE_CONNECTION_ERROR_PATTERNS.some(
66
+ (pattern) => err.message.includes(pattern)
67
+ );
68
+ }
69
+ function isRemoteConnectionError(err) {
70
+ return isSshAuthError(err) || isRetryableRemoteConnectionError(err);
71
+ }
72
+ var MAX_COMMAND_CHARS = 120;
73
+ function commandForError(command) {
74
+ const oneLine = command.trim().replace(/\s+/g, " ");
75
+ return oneLine.length > MAX_COMMAND_CHARS ? `${oneLine.slice(0, MAX_COMMAND_CHARS)}\u2026 (${command.length} chars)` : oneLine;
76
+ }
77
+ function isRuntimeNotFoundError(err) {
78
+ if (!err || typeof err !== "object") return false;
79
+ const e = err;
80
+ if (e.statusCode === 404) return true;
81
+ return typeof e.message === "string" && /no such (container|image|volume|network)/i.test(e.message);
82
+ }
83
+
84
+ // ../../packages/adapters/src/system/debug.ts
85
+ function isTruthy(value) {
86
+ if (!value) return false;
87
+ return ["1", "true", "yes", "on", "debug"].includes(value.toLowerCase());
88
+ }
89
+ function isSystemDebugEnabled() {
90
+ return isTruthy(process.env.SYSTEM_DEBUG_LOGS);
91
+ }
92
+ function systemDebug(scope, message) {
93
+ if (!isSystemDebugEnabled()) return;
94
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
95
+ console.log(`[system-debug] ${timestamp} [${scope}] ${message}`);
96
+ }
97
+ function formatDuration(startMs) {
98
+ return `${Date.now() - startMs}ms`;
99
+ }
100
+
101
+ export {
102
+ SshDisconnectedError,
103
+ isSshAuthError,
104
+ HostChannelUnavailableError,
105
+ isRetryableRemoteConnectionError,
106
+ isRemoteConnectionError,
107
+ commandForError,
108
+ isRuntimeNotFoundError,
109
+ systemDebug,
110
+ formatDuration
111
+ };
@@ -18,25 +18,28 @@ import {
18
18
  edgeChallengeVhostConf,
19
19
  isCloudFrontedHost,
20
20
  luaSourceAvailable
21
- } from "./chunk-RSR7PFIQ.js";
21
+ } from "./chunk-QHMDCYZ3.js";
22
22
  import {
23
23
  edgeDownExplanation,
24
24
  explainEdgeDown,
25
25
  isEdgeDownFailure
26
26
  } from "./chunk-I3DPMTSF.js";
27
+ import {
28
+ probeHostedHttp
29
+ } from "./chunk-R4VDPFLS.js";
27
30
  import {
28
31
  EXECUTOR_DELEGATE
29
- } from "./chunk-UVNMQM7W.js";
32
+ } from "./chunk-FZ6QCF6B.js";
30
33
  import {
31
34
  logEntry,
32
35
  sq
33
- } from "./chunk-ZFJXPCQP.js";
36
+ } from "./chunk-H3WT3A6R.js";
34
37
  import {
35
38
  edgeFailureReason
36
- } from "./chunk-2YM3NI2E.js";
39
+ } from "./chunk-GIPJNNI5.js";
37
40
  import {
38
41
  probeListeningPort
39
- } from "./chunk-SM26HDS2.js";
42
+ } from "./chunk-VSTFHUCV.js";
40
43
  import {
41
44
  PROXY_DIRECTIVES,
42
45
  parseProxyValue,
@@ -44,7 +47,7 @@ import {
44
47
  resolveRedirectStatus,
45
48
  safeErrorMessage,
46
49
  sanitizeProxySettings
47
- } from "./chunk-UJ6JZM65.js";
50
+ } from "./chunk-2VSW6Q6C.js";
48
51
 
49
52
  // ../../packages/adapters/src/infra/nginx.ts
50
53
  import {
@@ -294,21 +297,49 @@ async function readDeclaredPair(exec, certPath, keyPath, container) {
294
297
  }
295
298
 
296
299
  // ../../packages/adapters/src/system/output-exists.ts
297
- function buildCommand(servedPath) {
300
+ var SAFE_HOST = /^[A-Za-z0-9][A-Za-z0-9.-]{0,252}$/;
301
+ var SAFE_PATH = /^\/[A-Za-z0-9._~/-]*$/;
302
+ function safeRequestPath(path) {
303
+ return SAFE_PATH.test(path) && !path.split("/").includes("..");
304
+ }
305
+ function buildCommand(servedPath, opts) {
298
306
  const p = servedPath.replace(/'/g, "'\\''");
299
- return [
307
+ const parts = [
300
308
  `if [ -e '${p}' ]; then echo FOUND; fi`,
301
- `if [ -f '${p}' ] || [ -f '${p}/index.html' ]; then echo INDEX; fi`,
302
- "true"
303
- ].join("; ");
309
+ `if [ -f '${p}' ] || [ -f '${p}/index.html' ]; then echo INDEX; fi`
310
+ ];
311
+ const host = opts?.hostname;
312
+ const path = opts?.requestPath ?? "/";
313
+ if (host && SAFE_HOST.test(host) && safeRequestPath(path)) {
314
+ const port = opts?.edgePort ?? 80;
315
+ const maxTime = opts?.timeoutSeconds ?? 3;
316
+ parts.push(
317
+ `if command -v curl >/dev/null 2>&1; then echo "HTTP $(curl -sS -o /dev/null -w '%{http_code} %{num_connects}' --max-time ${maxTime} -H 'Host: ${host}' -H 'X-Forwarded-Proto: https' 'http://127.0.0.1:${port}${path}' 2>/dev/null)"; fi`
318
+ );
319
+ }
320
+ parts.push("true");
321
+ return parts.join("; ");
304
322
  }
305
- async function probeStaticOutput(executor, servedPath) {
323
+ function statusIsServed(status) {
324
+ if (status >= 200 && status < 400) return true;
325
+ return status === 401 || status === 403;
326
+ }
327
+ function parseHttp(out) {
328
+ const match = /(^|\n)HTTP (\d+) (\d+)(\r?\n|$)/.exec(out);
329
+ if (!match) return {};
330
+ const status = Number(match[2]);
331
+ const connects = Number(match[3]);
332
+ if (!Number.isFinite(status) || status === 0 || connects === 0) return {};
333
+ return { status, served: statusIsServed(status) };
334
+ }
335
+ async function probeStaticOutput(executor, servedPath, opts) {
306
336
  try {
307
- const out = await executor.exec(buildCommand(servedPath), { timeout: 5e3 });
337
+ const out = await executor.exec(buildCommand(servedPath, opts), { timeout: 8e3 });
308
338
  return {
309
339
  found: /(^|\n)FOUND(\r?\n|$)/.test(out),
310
340
  hasIndex: /(^|\n)INDEX(\r?\n|$)/.test(out),
311
- checked: true
341
+ checked: true,
342
+ ...parseHttp(out)
312
343
  };
313
344
  } catch {
314
345
  return { found: false, hasIndex: false, checked: false };
@@ -979,8 +1010,19 @@ var NginxProvider = class {
979
1010
  *
980
1011
  * Advisory: never throws.
981
1012
  */
982
- async probeStaticRoot(servedPath) {
983
- if (this.executor) return probeStaticOutput(this.executor, servedPath);
1013
+ async probeStaticRoot(servedPath, opts) {
1014
+ if (this.executor) return probeStaticOutput(this.executor, servedPath, opts);
1015
+ const fs = await this.probeStaticRootViaFs(servedPath);
1016
+ if (!opts?.hostname) return fs;
1017
+ const http = await probeHostedHttp({
1018
+ hostname: opts.hostname,
1019
+ path: opts.requestPath ?? "/",
1020
+ port: opts.edgePort ?? 80,
1021
+ timeoutMs: (opts.timeoutSeconds ?? 3) * 1e3
1022
+ });
1023
+ return http ? { ...fs, status: http.status, served: http.served } : fs;
1024
+ }
1025
+ async probeStaticRootViaFs(servedPath) {
984
1026
  const found = await this._exists(servedPath);
985
1027
  if (!found) return { found: false, hasIndex: false, checked: true };
986
1028
  const isFile = await fsStat(servedPath).then((s) => s.isFile()).catch(() => false);