@opencode-cloud/core 16.0.0 → 18.0.0

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.
package/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "opencode-cloud-core"
3
- version = "16.0.0"
3
+ version = "18.0.0"
4
4
  edition = "2024"
5
5
  rust-version = "1.89"
6
6
  license = "MIT"
package/README.md CHANGED
@@ -192,7 +192,7 @@ occ start --port 8080
192
192
  # Start and open browser
193
193
  occ start --open
194
194
 
195
- # Check service status
195
+ # Check service status (includes broker health: Healthy/Degraded/Unhealthy)
196
196
  occ status
197
197
 
198
198
  # View logs
@@ -204,7 +204,7 @@ occ logs -f
204
204
  # View opencode-broker logs (systemd/journald required)
205
205
  occ logs --broker
206
206
 
207
- # Dump opencode-broker logs (no follow)
207
+ # Troubleshoot broker health issues reported by `occ status`
208
208
  occ logs --broker --no-follow
209
209
 
210
210
  # Note: Broker logs require systemd/journald. This is enabled by default on supported Linux
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencode-cloud/core",
3
- "version": "16.0.0",
3
+ "version": "18.0.0",
4
4
  "description": "Core NAPI bindings for opencode-cloud (internal package)",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,6 +1,12 @@
1
1
  # =============================================================================
2
2
  # opencode-cloud Container Image
3
3
  # =============================================================================
4
+ # IMPORTANT:
5
+ # Keep scripts/service/config assets in `packages/core/src/docker/files/`
6
+ # and COPY them into the image instead of embedding large inline shell blocks.
7
+ # When adding files, also update `packages/core/src/docker/image.rs`
8
+ # (`create_build_context`) so CLI-driven Docker builds include them.
9
+ #
4
10
  # A comprehensive development environment for AI-assisted coding with opencode.
5
11
  #
6
12
  # Features:
@@ -578,13 +584,17 @@ RUN chmod +x /usr/local/bin/entrypoint.sh
578
584
  # Note: Don't set USER here - entrypoint needs root to use runuser
579
585
  # The tini mode drops privileges to opencode user via runuser
580
586
 
587
+ # Healthcheck script asset
588
+ COPY packages/core/src/docker/files/healthcheck.sh /usr/local/bin/healthcheck.sh
589
+ RUN chmod +x /usr/local/bin/healthcheck.sh
590
+
581
591
  # -----------------------------------------------------------------------------
582
592
  # Health Check
583
593
  # -----------------------------------------------------------------------------
584
- # Check that opencode main page responds
594
+ # Check broker readiness (process + socket) and opencode web response
585
595
  # Works for both tini and systemd modes
586
596
  HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
587
- CMD ["sh", "-c", "OPENCODE_PORT=\"${OPENCODE_PORT:-${PORT:-3000}}\"; curl -f -H \"Accept: text/html\" \"http://localhost:${OPENCODE_PORT}/\" || exit 1"]
597
+ CMD ["/usr/local/bin/healthcheck.sh"]
588
598
 
589
599
  # -----------------------------------------------------------------------------
590
600
  # opencode Artifacts
@@ -5,10 +5,44 @@ log() {
5
5
  echo "[opencode-cloud] $*"
6
6
  }
7
7
 
8
+ read_opencode_cloud_version() {
9
+ local version_file="/etc/opencode-cloud-version"
10
+ local version
11
+
12
+ if [ -r "${version_file}" ]; then
13
+ version="$(head -n 1 "${version_file}" 2>/dev/null | tr -d "\r\n")"
14
+ else
15
+ version=""
16
+ fi
17
+
18
+ if [ -z "${version}" ]; then
19
+ printf "dev"
20
+ else
21
+ printf "%s" "${version}"
22
+ fi
23
+ }
24
+
25
+ print_welcome_banner() {
26
+ local version
27
+ version="$(read_opencode_cloud_version)"
28
+
29
+ log "----------------------------------------------------------------------"
30
+ log "Welcome to opencode-cloud-sandbox"
31
+ log "You are running opencode-cloud v${version}"
32
+ log "For questions, problems, and feature requests, file an issue:"
33
+ log " https://github.com/pRizz/opencode-cloud/issues"
34
+ log "opencode-cloud runs opencode in a Docker sandbox; use occ/opencode-cloud CLI to manage users, mounts, and updates."
35
+ log "Quick start: occ user add <username> | occ status | occ logs -f"
36
+ log "Docs: https://github.com/pRizz/opencode-cloud#readme"
37
+ log "----------------------------------------------------------------------"
38
+ }
39
+
8
40
  OPENCODE_PORT="${OPENCODE_PORT:-${PORT:-3000}}"
9
41
  OPENCODE_HOST="${OPENCODE_HOST:-0.0.0.0}"
10
42
  export OPENCODE_PORT OPENCODE_HOST
11
43
 
44
+ print_welcome_banner
45
+
12
46
  detect_droplet() {
13
47
  local hint="${OPENCODE_CLOUD_ENV:-}"
14
48
  if [ -n "${hint}" ]; then
@@ -63,13 +97,6 @@ if [ -n "${non_persistent_paths}" ]; then
63
97
  log "================================================================="
64
98
  fi
65
99
 
66
- log "----------------------------------------------------------------------"
67
- log "If you created this container via opencode-cloud CLI, add users with:"
68
- log " occ user add (or: opencode-cloud user add)"
69
- log "Learn more: occ --help (or: opencode-cloud --help)"
70
- log "Docs: https://github.com/pRizz/opencode-cloud#readme"
71
- log "----------------------------------------------------------------------"
72
-
73
100
  if [ "${USE_SYSTEMD:-}" = "1" ]; then
74
101
  exec /sbin/init
75
102
  else
@@ -0,0 +1,13 @@
1
+ #!/bin/sh
2
+ set -eu
3
+
4
+ opencode_port="${OPENCODE_PORT:-${PORT:-3000}}"
5
+
6
+ if [ -d /run/systemd/system ]; then
7
+ systemctl is-active --quiet opencode-broker.service
8
+ else
9
+ pgrep -x opencode-broker >/dev/null
10
+ fi
11
+
12
+ test -S /run/opencode/auth.sock
13
+ curl -fsS -H "Accept: text/html" "http://localhost:${opencode_port}/" >/dev/null
@@ -895,6 +895,12 @@ fn create_build_context() -> Result<Vec<u8>, std::io::Error> {
895
895
  include_bytes!("files/entrypoint.sh"),
896
896
  0o644,
897
897
  )?;
898
+ append_bytes(
899
+ &mut tar,
900
+ "packages/core/src/docker/files/healthcheck.sh",
901
+ include_bytes!("files/healthcheck.sh"),
902
+ 0o644,
903
+ )?;
898
904
  append_bytes(
899
905
  &mut tar,
900
906
  "packages/core/src/docker/files/opencode-broker.service",
@@ -1006,18 +1012,31 @@ mod tests {
1006
1012
  let cursor = Cursor::new(context);
1007
1013
  let decoder = GzDecoder::new(cursor);
1008
1014
  let mut archive = Archive::new(decoder);
1009
- let mut found = false;
1015
+ let mut found_entrypoint = false;
1016
+ let mut found_healthcheck = false;
1010
1017
 
1011
1018
  for entry in archive.entries().expect("should read archive entries") {
1012
1019
  let entry = entry.expect("should read entry");
1013
1020
  let path = entry.path().expect("should read entry path");
1014
1021
  if path == std::path::Path::new("packages/core/src/docker/files/entrypoint.sh") {
1015
- found = true;
1022
+ found_entrypoint = true;
1023
+ }
1024
+ if path == std::path::Path::new("packages/core/src/docker/files/healthcheck.sh") {
1025
+ found_healthcheck = true;
1026
+ }
1027
+ if found_entrypoint && found_healthcheck {
1016
1028
  break;
1017
1029
  }
1018
1030
  }
1019
1031
 
1020
- assert!(found, "entrypoint asset should be in the build context");
1032
+ assert!(
1033
+ found_entrypoint,
1034
+ "entrypoint asset should be in the build context"
1035
+ );
1036
+ assert!(
1037
+ found_healthcheck,
1038
+ "healthcheck asset should be in the build context"
1039
+ );
1021
1040
  }
1022
1041
 
1023
1042
  #[test]