vagrant-claude-sandbox 0.3.0 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd25462c61f73d33a49b8fd802b504c5897b608ca75e6e0f12effe9aa3b422c2
4
- data.tar.gz: 00f414e7a5c127399a931a91422d2464d031e80539972e6a147b2abe00aa4a8d
3
+ metadata.gz: f9e5e9348ad0a469e4a9502475d9457acb1c2aea50d1305de63c40dae03538cf
4
+ data.tar.gz: d76ae60d37fda90d9dc56bc1c07faacf33cf69199c95733ddf068466fc7254d8
5
5
  SHA512:
6
- metadata.gz: 74a5fed6820d91ec05a9a43e5b9dc744c492aeb636d3b9629a7bda4f1cea460188f0c1988520721af8fae4087b8bc87b2feea89fd27323dd0612364678a4937c
7
- data.tar.gz: 0cf7e8fabfb298c3af1c3595185bd21dcfe2247212ecc3363d4d2ef8f7b79369087cfae5643e99c43498dec9be163a88b778684e7faeb56cec45e54e15d37c09
6
+ metadata.gz: 27adfa12ead112c7454bb95c2b613db1d54bc592c26d19eec941f88bc8a2c0a9e933d9f7bf01b0c0e9999c203a9b9cb8b5eec8455e9ced09562ad6065618811e
7
+ data.tar.gz: d7d684c8b575989260513d4e726e0d8a5daa3b44e65361b6ffc2476a480ca6e5524e84bbef916ee72b4e64e82fe57d53e44e41d5774df53d621a1a36cce74420
data/README.md CHANGED
@@ -127,11 +127,33 @@ end
127
127
 
128
128
  ## Notifications
129
129
 
130
- Vagrant uses the `vagrant-notify-server` gem to provide desktop notifications from Claude.
131
- To display notifications on your OS, [install `terminal-notifier` on MacOS](https://formulae.brew.sh/formula/terminal-notifier) or `libnotify-bin` on Linux (untested).
130
+ The plugin automatically starts a notification server when you run `vagrant up`, enabling desktop notifications from Claude running in the sandbox.
132
131
 
133
- By default notifications appear when Claude completes tasks or needs input.
134
- To customize notification behavior: Copy lib/vagrant-claude-sandbox/notification_config.yml.example to ~/.vagrant-claude-sandbox/notification_config.yml to configure which notifications appear.
132
+ **Setup:**
133
+
134
+ 1. Install notification support on your OS:
135
+ - **macOS**: `brew install terminal-notifier`
136
+ - **Linux**: `apt install libnotify-bin` (untested)
137
+
138
+ 2. The notification server starts automatically with `vagrant up` and stops with `vagrant halt` or `vagrant destroy`.
139
+
140
+ **Customization:**
141
+
142
+ By default, notifications appear when Claude completes tasks, needs input, or encounters errors/warnings.
143
+
144
+ To customize notification behavior, copy the example config:
145
+ ```bash
146
+ cp lib/vagrant-claude-sandbox/notification_config.yml.example ~/.vagrant-claude-sandbox/notification_config.yml
147
+ ```
148
+
149
+ Then edit `~/.vagrant-claude-sandbox/notification_config.yml` to configure which notification types to show, timeouts, sounds, etc.
150
+
151
+ **Manual Control:**
152
+
153
+ If needed, you can manually run the notification server:
154
+ ```bash
155
+ bundle exec bin/vagrant-notify-server
156
+ ```
135
157
 
136
158
  ## Development and Testing
137
159
 
@@ -5,6 +5,8 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
5
5
 
6
6
  require 'vagrant-claude-sandbox/notification_server'
7
7
 
8
- port = ARGV[0] ? ARGV[0].to_i : VagrantPlugins::ClaudeSandbox::NotificationServer::DEFAULT_PORT
8
+ # If port specified on command line, use it. Otherwise, let auto-detection work
9
+ # (reads from .vagrant-notification-port if present, otherwise uses default)
10
+ port = ARGV[0] ? ARGV[0].to_i : nil
9
11
  server = VagrantPlugins::ClaudeSandbox::NotificationServer.new(port)
10
12
  server.start
@@ -107,8 +107,76 @@ module VagrantPlugins
107
107
  # Configure SSH port with auto-correction for conflicts
108
108
  root_config.vm.network :forwarded_port, guest: 22, host: 2200, id: "ssh", auto_correct: true
109
109
 
110
- # Forward notification port from host to guest (guest can send notifications to host)
111
- root_config.vm.network :forwarded_port, guest: 29325, host: 29325, id: "notifications", host_ip: "127.0.0.1"
110
+ # Note: No port forwarding needed for notifications.
111
+ # The guest connects OUT to the host notification server:
112
+ # - Docker: via host.docker.internal:29325
113
+ # - VirtualBox: via 10.0.2.2:29325 (NAT gateway)
114
+ # Port forwarding is for host->guest, but notifications are guest->host.
115
+
116
+ # Write the notification port to a file so scripts can read it
117
+ root_config.trigger.after :up do |trigger|
118
+ trigger.ruby do |env, machine|
119
+ notification_port = 29325
120
+ port_file = File.join(Dir.pwd, ".vagrant-notification-port")
121
+ File.write(port_file, notification_port.to_s)
122
+ machine.ui.info("Notification server port: #{notification_port}")
123
+
124
+ # Auto-start notification server if not already running
125
+ unless system("lsof -i :#{notification_port} > /dev/null 2>&1")
126
+ # Find the gem's bin directory
127
+ gem_dir = File.expand_path("../..", __dir__)
128
+ server_bin = File.join(gem_dir, "bin", "vagrant-notify-server")
129
+ gemfile = File.join(gem_dir, "Gemfile")
130
+
131
+ if File.exist?(server_bin)
132
+ machine.ui.info("Starting notification server...")
133
+
134
+ # Use bundle exec in development mode, plain ruby when installed as gem
135
+ cmd = if File.exist?(gemfile)
136
+ ["bundle", "exec", "ruby", server_bin, notification_port.to_s]
137
+ else
138
+ ["ruby", server_bin, notification_port.to_s]
139
+ end
140
+
141
+ # Start server in background
142
+ pid = spawn(
143
+ *cmd,
144
+ chdir: gem_dir,
145
+ out: File.join(Dir.pwd, ".vagrant-notify-server.log"),
146
+ err: File.join(Dir.pwd, ".vagrant-notify-server.log")
147
+ )
148
+ Process.detach(pid)
149
+
150
+ # Save PID for cleanup
151
+ File.write(File.join(Dir.pwd, ".vagrant-notify-server-pid"), pid.to_s)
152
+ machine.ui.success("Notification server started (PID: #{pid})")
153
+ else
154
+ machine.ui.warn("Notification server not found at: #{server_bin}")
155
+ machine.ui.warn("Run manually: bundle exec bin/vagrant-notify-server")
156
+ end
157
+ else
158
+ machine.ui.info("Notification server already running on port #{notification_port}")
159
+ end
160
+ end
161
+ end
162
+
163
+ # Stop notification server on halt/destroy
164
+ root_config.trigger.after [:halt, :destroy] do |trigger|
165
+ trigger.ruby do |env, machine|
166
+ pid_file = File.join(Dir.pwd, ".vagrant-notify-server-pid")
167
+ if File.exist?(pid_file)
168
+ pid = File.read(pid_file).strip.to_i
169
+ begin
170
+ Process.kill("INT", pid)
171
+ machine.ui.info("Stopped notification server (PID: #{pid})")
172
+ rescue Errno::ESRCH
173
+ # Process already stopped
174
+ ensure
175
+ File.delete(pid_file)
176
+ end
177
+ end
178
+ end
179
+ end
112
180
  end
113
181
 
114
182
  def apply_virtualbox_config!(root_config)
@@ -253,7 +321,13 @@ module VagrantPlugins
253
321
 
254
322
  TITLE=""
255
323
  MESSAGE=""
256
- HOST_PORT=29325
324
+
325
+ # Read port from config file (written by vagrant trigger), default to 29325
326
+ if [ -f "/agent-workspace/.vagrant-notification-port" ]; then
327
+ HOST_PORT=$(cat /agent-workspace/.vagrant-notification-port)
328
+ else
329
+ HOST_PORT=29325
330
+ fi
257
331
 
258
332
  # Parse notify-send arguments (simplified)
259
333
  while [[ $# -gt 0 ]]; do
@@ -6,6 +6,7 @@ module VagrantPlugins
6
6
  module ClaudeSandbox
7
7
  class NotificationServer
8
8
  DEFAULT_PORT = 29325
9
+ PORT_FILE = ".vagrant-notification-port"
9
10
  DEFAULT_CONFIG = {
10
11
  'show_types' => ['task_complete', 'needs_input', 'error', 'warning'],
11
12
  'default_timeout' => 0,
@@ -22,12 +23,21 @@ module VagrantPlugins
22
23
  'require_url' => false
23
24
  }
24
25
 
25
- def initialize(port = DEFAULT_PORT)
26
- @port = port
26
+ def initialize(port = nil)
27
+ @port = port || detect_port
27
28
  @server = nil
28
29
  @config = load_config
29
30
  end
30
31
 
32
+ def detect_port
33
+ # Check for port file in current directory (written by vagrant trigger)
34
+ if File.exist?(PORT_FILE)
35
+ port = File.read(PORT_FILE).strip.to_i
36
+ return port if port > 0
37
+ end
38
+ DEFAULT_PORT
39
+ end
40
+
31
41
  def load_config
32
42
  config_path = File.expand_path('~/.vagrant-claude-sandbox/notification_config.yml')
33
43
  if File.exist?(config_path)
@@ -6,7 +6,12 @@
6
6
  set +e
7
7
 
8
8
  # Configuration
9
- HOST_PORT=29325
9
+ # Read port from config file (written by vagrant trigger), default to 29325
10
+ if [ -f "/agent-workspace/.vagrant-notification-port" ]; then
11
+ HOST_PORT=$(cat /agent-workspace/.vagrant-notification-port)
12
+ else
13
+ HOST_PORT=29325
14
+ fi
10
15
  NOTIFICATION_TIMEOUT=1
11
16
 
12
17
  # Colors for terminal output
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module ClaudeSandbox
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-claude-sandbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-27 00:00:00.000000000 Z
11
+ date: 2026-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake