openship 0.6.0 → 0.6.5

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 (63) hide show
  1. package/README.md +7 -2
  2. package/dist/{bare-FSUAM5V5.js → bare-XQIPDO4R.js} +10 -9
  3. package/dist/{chunk-PSZSKEPA.js → chunk-3ZAGC5NT.js} +64 -17
  4. package/dist/{chunk-6ODUBKUB.js → chunk-5OUWIPOB.js} +69 -7
  5. package/dist/chunk-6HOA5JT7.js +124 -0
  6. package/dist/{chunk-TWJCLD4W.js → chunk-6JELW75A.js} +4 -4
  7. package/dist/{chunk-GUQ3QCJ7.js → chunk-7334NSJL.js} +399 -369
  8. package/dist/chunk-7S4USQYF.js +1753 -0
  9. package/dist/{chunk-3LDWWY7U.js → chunk-A7EWM2KA.js} +41 -7
  10. package/dist/chunk-ELGRMZOW.js +25 -0
  11. package/dist/chunk-EZPPTWJQ.js +292 -0
  12. package/dist/{chunk-IXM5245F.js → chunk-GRTXMUHA.js} +553 -538
  13. package/dist/chunk-HPXP6LXZ.js +428 -0
  14. package/dist/{chunk-OTLSJYAC.js → chunk-LEYSL46B.js} +2135 -85
  15. package/dist/{chunk-EMXI4UCU.js → chunk-LFCSC4IU.js} +29 -10
  16. package/dist/{chunk-JIMUYEKN.js → chunk-MSZUCNPV.js} +1 -1
  17. package/dist/{chunk-OGY63DGD.js → chunk-PZRRL5PC.js} +71 -28
  18. package/dist/{chunk-VE2YOK4I.js → chunk-QLX7NBEA.js} +1218 -588
  19. package/dist/chunk-RFWJE7ZN.js +68 -0
  20. package/dist/{chunk-VDDMADOF.js → chunk-TM2IQPYU.js} +16 -2
  21. package/dist/{chunk-3FYIXVX5.js → chunk-VDESJSG6.js} +451 -106
  22. package/dist/{chunk-B3CE2OMR.js → chunk-VHMOQL5Y.js} +276 -50
  23. package/dist/{chunk-QEH4QUBX.js → chunk-VLQ3UIVO.js} +393 -53
  24. package/dist/{chunk-VZ2ZHPS2.js → chunk-WE7BXW6L.js} +3 -9
  25. package/dist/chunk-WFRXYWK2.js +444 -0
  26. package/dist/chunk-XRNRT37W.js +316 -0
  27. package/dist/{chunk-EP2TNALB.js → chunk-XVOBL7BC.js} +31 -8
  28. package/dist/cloud-3DODOWTR.js +36 -0
  29. package/dist/{detect-ALF4GXRX.js → detect-P4CIQBRH.js} +3 -3
  30. package/dist/{docker-QECQJ5P4.js → docker-3K2NEBD6.js} +15 -8
  31. package/dist/{docker-edge-executor-62N64MGS.js → docker-edge-executor-YZZ6P7IC.js} +5 -5
  32. package/dist/{edge-import-CQWHN2Q3.js → edge-import-MCJNVTZ2.js} +26 -23
  33. package/dist/edge-preflight-ES6FH4JK.js +42 -0
  34. package/dist/{ensure-container-edge-MJVXJQG5.js → ensure-container-edge-YPITNH45.js} +9 -8
  35. package/dist/{executor-JELARVKC.js → executor-DZGX55K2.js} +12 -5
  36. package/dist/host-channel-preflight-MUXE3KZU.js +49 -0
  37. package/dist/index.js +3668 -4063
  38. package/dist/{nginx-AXGNWRKZ.js → nginx-NSAHWGJV.js} +11 -5
  39. package/dist/node-bootstrap.js +241 -0
  40. package/dist/node-entry.js +52 -1
  41. package/dist/{openresty-lua-IE4P5YQX.js → openresty-lua-DR4D3EZ6.js} +6 -2
  42. package/dist/privilege-YTVI4SKF.js +19 -0
  43. package/dist/server/engine/samples/fail2ban/jail.d/sshd.local +4 -1
  44. package/dist/server/index.js +21501 -13137
  45. package/dist/server/lua/geo_country.lua +4 -3
  46. package/dist/server/lua/pipe_stream.lua +52 -39
  47. package/dist/server/lua/site_logger.lua +22 -24
  48. package/dist/server/migrations/0098_instance_product_mode.sql +12 -0
  49. package/dist/server/migrations/0099_mail_webmail_project.sql +24 -0
  50. package/dist/server/migrations/0100_server_ssh_private_key.sql +11 -0
  51. package/dist/server/migrations/0101_mail_resume_step.sql +12 -0
  52. package/dist/server/migrations/0102_project_workload_axes.sql +19 -0
  53. package/dist/server/migrations/0103_dns_credential.sql +41 -0
  54. package/dist/server/migrations/0104_instance_host_control.sql +15 -0
  55. package/dist/server/migrations/meta/_journal.json +49 -0
  56. package/dist/{setup-FA4PW4NU.js → setup-WUUZURHS.js} +10 -9
  57. package/dist/up-XEO3SR6Z.js +58 -0
  58. package/package.json +4 -2
  59. package/dist/chunk-IW2UKBVF.js +0 -144
  60. package/dist/chunk-ZCFVHA25.js +0 -89
  61. package/dist/cloud-E5M6VMCG.js +0 -31
  62. package/dist/server/lua/pipe_log.lua +0 -77
  63. /package/dist/{dist-es-JGBPABJI.js → dist-es-ZP5QDSJ3.js} +0 -0
@@ -1,144 +0,0 @@
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
- import {
6
- formatDuration,
7
- isRemoteConnectionError,
8
- systemDebug
9
- } from "./chunk-ZCFVHA25.js";
10
- import {
11
- safeErrorMessage
12
- } from "./chunk-OTLSJYAC.js";
13
-
14
- // ../../packages/adapters/src/system/environment.ts
15
- var profileCache = /* @__PURE__ */ new WeakMap();
16
- async function execSafe(executor, command, timeout = 5e3) {
17
- const startedAt = Date.now();
18
- systemDebug("environment", `exec:start ${command}`);
19
- try {
20
- const result = await executor.exec(command, { timeout });
21
- systemDebug(
22
- "environment",
23
- `exec:ok ${command} (${formatDuration(startedAt)})`
24
- );
25
- return result;
26
- } catch (err) {
27
- if (isRemoteConnectionError(err)) {
28
- systemDebug(
29
- "environment",
30
- `exec:abort ${command} (${formatDuration(startedAt)}) ${safeErrorMessage(err)}`
31
- );
32
- throw err;
33
- }
34
- const msg = safeErrorMessage(err);
35
- systemDebug(
36
- "environment",
37
- `exec:fail ${command} (${formatDuration(startedAt)}) ${msg}`
38
- );
39
- return null;
40
- }
41
- }
42
- function parseOs(uname) {
43
- const value = uname?.trim().toLowerCase();
44
- if (value === "linux") return "linux";
45
- if (value === "darwin") return "darwin";
46
- return "unknown";
47
- }
48
- function parseArch(uname) {
49
- const value = uname?.trim().toLowerCase() ?? "";
50
- if (["x86_64", "amd64"].includes(value)) return "amd64";
51
- if (["aarch64", "arm64"].includes(value)) return "arm64";
52
- return "unknown";
53
- }
54
- function parseDistro(osRelease) {
55
- if (!osRelease) return null;
56
- const lower = osRelease.toLowerCase();
57
- const match = lower.match(/^id=(.+)$/m);
58
- const id = match?.[1]?.replaceAll('"', "").trim();
59
- switch (id) {
60
- case "ubuntu":
61
- return "ubuntu";
62
- case "debian":
63
- return "debian";
64
- case "fedora":
65
- return "fedora";
66
- case "rhel":
67
- case "rhel server":
68
- return "rhel";
69
- case "centos":
70
- return "centos";
71
- case "alpine":
72
- return "alpine";
73
- default:
74
- return "unknown";
75
- }
76
- }
77
- async function detectPackageManager(executor) {
78
- const checks = [
79
- ["apt", "command -v apt-get"],
80
- ["dnf", "command -v dnf"],
81
- ["yum", "command -v yum"],
82
- ["apk", "command -v apk"],
83
- ["brew", "command -v brew"]
84
- ];
85
- for (const [pm, command] of checks) {
86
- if (await execSafe(executor, command)) return pm;
87
- }
88
- return "none";
89
- }
90
- async function detectServiceManager(executor) {
91
- if (await execSafe(executor, "command -v systemctl")) return "systemd";
92
- if (await execSafe(executor, "command -v launchctl")) return "launchd";
93
- return "none";
94
- }
95
- async function detectPrivilege(executor) {
96
- const uid = await execSafe(executor, "id -u");
97
- const isRoot = uid?.trim() === "0";
98
- if (isRoot) return { isRoot: true, canSudo: false };
99
- const sudo = await execSafe(
100
- executor,
101
- "sudo -n true 2>/dev/null && echo yes || echo no"
102
- );
103
- return { isRoot: false, canSudo: sudo?.trim() === "yes" };
104
- }
105
- async function detectProfile(executor) {
106
- const startedAt = Date.now();
107
- systemDebug("environment", "detect:start");
108
- const unameOs = await execSafe(executor, "uname -s");
109
- const unameArch = await execSafe(executor, "uname -m");
110
- const osRelease = await execSafe(executor, "cat /etc/os-release");
111
- const packageManager = await detectPackageManager(executor);
112
- const serviceManager = await detectServiceManager(executor);
113
- const { isRoot, canSudo } = await detectPrivilege(executor);
114
- const os = parseOs(unameOs);
115
- const profile = {
116
- os,
117
- arch: parseArch(unameArch),
118
- distro: os === "linux" ? parseDistro(osRelease) : null,
119
- packageManager,
120
- serviceManager,
121
- isRoot,
122
- canSudo
123
- };
124
- systemDebug(
125
- "environment",
126
- `detect:done (${formatDuration(startedAt)}) ${JSON.stringify(profile)}`
127
- );
128
- return profile;
129
- }
130
- async function resolveEnvironment(executor) {
131
- let promise = profileCache.get(executor);
132
- if (!promise) {
133
- systemDebug("environment", "cache:miss");
134
- promise = detectProfile(executor);
135
- profileCache.set(executor, promise);
136
- } else {
137
- systemDebug("environment", "cache:hit");
138
- }
139
- return promise;
140
- }
141
-
142
- export {
143
- resolveEnvironment
144
- };
@@ -1,89 +0,0 @@
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
- ];
34
- var SshDisconnectedError = class extends Error {
35
- constructor(message = "SSH connection lost") {
36
- super(message);
37
- this.name = "SshDisconnectedError";
38
- }
39
- };
40
- function isSshDisconnectedError(err) {
41
- return err instanceof SshDisconnectedError || err instanceof Error && err.name === "SshDisconnectedError";
42
- }
43
- function isSshAuthError(err) {
44
- if (!(err instanceof Error)) return false;
45
- return SSH_AUTH_ERROR_PATTERNS.some((pattern) => err.message.includes(pattern));
46
- }
47
- function isRetryableRemoteConnectionError(err) {
48
- if (isSshDisconnectedError(err)) return true;
49
- if (!(err instanceof Error)) return false;
50
- return RETRYABLE_CONNECTION_ERROR_PATTERNS.some(
51
- (pattern) => err.message.includes(pattern)
52
- );
53
- }
54
- function isRemoteConnectionError(err) {
55
- return isSshAuthError(err) || isRetryableRemoteConnectionError(err);
56
- }
57
- function isRuntimeNotFoundError(err) {
58
- if (!err || typeof err !== "object") return false;
59
- const e = err;
60
- if (e.statusCode === 404) return true;
61
- return typeof e.message === "string" && /no such (container|image|volume|network)/i.test(e.message);
62
- }
63
-
64
- // ../../packages/adapters/src/system/debug.ts
65
- function isTruthy(value) {
66
- if (!value) return false;
67
- return ["1", "true", "yes", "on", "debug"].includes(value.toLowerCase());
68
- }
69
- function isSystemDebugEnabled() {
70
- return isTruthy(process.env.SYSTEM_DEBUG_LOGS);
71
- }
72
- function systemDebug(scope, message) {
73
- if (!isSystemDebugEnabled()) return;
74
- const timestamp = (/* @__PURE__ */ new Date()).toISOString();
75
- console.log(`[system-debug] ${timestamp} [${scope}] ${message}`);
76
- }
77
- function formatDuration(startMs) {
78
- return `${Date.now() - startMs}ms`;
79
- }
80
-
81
- export {
82
- SshDisconnectedError,
83
- isSshAuthError,
84
- isRetryableRemoteConnectionError,
85
- isRemoteConnectionError,
86
- isRuntimeNotFoundError,
87
- systemDebug,
88
- formatDuration
89
- };
@@ -1,31 +0,0 @@
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
- import {
6
- CloudRuntime,
7
- PAGE_CONTAINER_PREFIX,
8
- provisionCloudWorkspace
9
- } from "./chunk-PSZSKEPA.js";
10
- import "./chunk-GUQ3QCJ7.js";
11
- import "./chunk-EMXI4UCU.js";
12
- import "./chunk-JIMUYEKN.js";
13
- import "./chunk-IW2UKBVF.js";
14
- import "./chunk-VDDMADOF.js";
15
- import "./chunk-B3CE2OMR.js";
16
- import "./chunk-6ODUBKUB.js";
17
- import "./chunk-ZCFVHA25.js";
18
- import "./chunk-6FH4AXVY.js";
19
- import "./chunk-QEH4QUBX.js";
20
- import "./chunk-I3DPMTSF.js";
21
- import "./chunk-VZ2ZHPS2.js";
22
- import "./chunk-3LDWWY7U.js";
23
- import "./chunk-OGY63DGD.js";
24
- import "./chunk-ZFJXPCQP.js";
25
- import "./chunk-OTLSJYAC.js";
26
- import "./chunk-PXKCZB2I.js";
27
- export {
28
- CloudRuntime,
29
- PAGE_CONTAINER_PREFIX,
30
- provisionCloudWorkspace
31
- };
@@ -1,77 +0,0 @@
1
- -- pipe_log.lua
2
- -- Push request log into shared dict queue log_pipe:q:{host} for /stream SSE.
3
- -- Payload shape matches requestLogger.js (id, ip, country when known,
4
- -- timestamp, date, uri, method, status, userAgent, requestSize, responseSize,
5
- -- responseTime).
6
- --
7
- -- Called via ngx.timer.at from site_logger (premature is first arg).
8
-
9
- local cjson = require "cjson.safe"
10
-
11
- local SUB_PREFIX = "log_pipe:sub:"
12
- local QUEUE_PREFIX = "log_pipe:q:"
13
- local QUEUE_MAX_LEN = 2000
14
-
15
- -- SAFE LOAD: GeoIP (per-worker, cached by require)
16
- local geo_ok, geo = pcall(require, "openship.geo_country")
17
- if not geo_ok then geo = nil end
18
-
19
- -- Reused payload table per worker (cleared after encode to avoid GC pressure)
20
- local payload = {}
21
-
22
- -- `cc` is the country site_logger already resolved for this request. Passed in rather
23
- -- than looked up again: one mmdb hit per request, and the live frame can never disagree
24
- -- with the rollup or the ring buffer about where a hit came from.
25
- local function pipe_request_log(premature, host, ip, ts, ua, uri,
26
- req_len, bytes, rt, method, status, cc)
27
- if premature then return end
28
-
29
- local sh = ngx.shared.request_data
30
- if not sh then return end
31
-
32
- -- Double-check subscriber is still active (guard against race)
33
- if not sh:get(SUB_PREFIX .. host) then return end
34
-
35
- pcall(function()
36
- -- Falls back to its own lookup only if the caller passed nothing, which happens
37
- -- when a box is mid-deploy and still has the previous site_logger.
38
- local country = cc
39
- if (not country or country == "") and geo and geo.get_country_code then
40
- local ok_cc, res = pcall(geo.get_country_code, ip)
41
- if ok_cc then country = res end
42
- end
43
-
44
- payload.id = string.format("%.3f-%d", ts, math.random(10000, 99999))
45
- payload.host = host
46
- payload.ip = ip
47
- if country and type(country) == "string" and country ~= "" then
48
- payload.country = country
49
- end
50
- payload.timestamp = ts
51
- payload.date = os.date("!%Y-%m-%d %H:%M:%S", ts)
52
- payload.uri = uri
53
- payload.method = method or "GET"
54
- payload.status = tonumber(status) or 0
55
- payload.userAgent = ua or ""
56
- payload.requestSize = tonumber(req_len) or 0
57
- payload.responseSize = tonumber(bytes) or 0
58
- payload.responseTime = tonumber(rt) or 0
59
-
60
- local body = cjson.encode(payload)
61
-
62
- -- Clear payload table for next reuse
63
- for k in pairs(payload) do payload[k] = nil end
64
-
65
- if not body then return end
66
-
67
- local qkey = QUEUE_PREFIX .. host
68
- sh:lpush(qkey, body)
69
- if sh:llen(qkey) > QUEUE_MAX_LEN then
70
- sh:rpop(qkey)
71
- end
72
- end)
73
- end
74
-
75
- return {
76
- pipe_request_log = pipe_request_log,
77
- }