vagrant-claude-sandbox 0.3.0 → 0.3.1

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: 83aa818f90a8658daa51e1666f727910359e687032aa9e0c2686667ab82c5e57
4
+ data.tar.gz: a683a780d3770714c1be586f7066a3dfa102a858c5cc2bb123da9e936d2fb43a
5
5
  SHA512:
6
- metadata.gz: 74a5fed6820d91ec05a9a43e5b9dc744c492aeb636d3b9629a7bda4f1cea460188f0c1988520721af8fae4087b8bc87b2feea89fd27323dd0612364678a4937c
7
- data.tar.gz: 0cf7e8fabfb298c3af1c3595185bd21dcfe2247212ecc3363d4d2ef8f7b79369087cfae5643e99c43498dec9be163a88b778684e7faeb56cec45e54e15d37c09
6
+ metadata.gz: 45117ae9e15c7101215e393ce4bb7e70c05c0e5b37885b648f1c15253176ffd631b5638b8bcd5d860a9d52fadeb9e47ff2cde209c0028afd4f40571889b789d2
7
+ data.tar.gz: 8083c2e00adf8dbc09f6b758a53d64bf9db7527e2dca70d74df3520b8a3719fa0329e439a261dcd27b019ccc952366cc8be0a037c08eb9b0f996f9bfd34ddc75
@@ -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
@@ -108,7 +108,37 @@ module VagrantPlugins
108
108
  root_config.vm.network :forwarded_port, guest: 22, host: 2200, id: "ssh", auto_correct: true
109
109
 
110
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"
111
+ # Use auto_correct to handle port conflicts
112
+ root_config.vm.network :forwarded_port, guest: 29325, host: 29325, id: "notifications", host_ip: "127.0.0.1", auto_correct: true
113
+
114
+ # Write the actual notification port to a file after VM is up so scripts can read it
115
+ root_config.trigger.after :up do |trigger|
116
+ trigger.ruby do |env, machine|
117
+ # Get the actual forwarded port for notifications
118
+ ports = machine.provider.driver.read_forwarded_ports rescue []
119
+ notification_port = nil
120
+
121
+ # Find the notification port mapping
122
+ ports.each do |port_info|
123
+ # Format varies by provider, handle both
124
+ if port_info.is_a?(Array) && port_info.length >= 4
125
+ # VirtualBox format: [name, guest_port, host_port, host_ip]
126
+ notification_port = port_info[2] if port_info[1] == 29325
127
+ elsif port_info.is_a?(Hash)
128
+ notification_port = port_info[:host] if port_info[:guest] == 29325
129
+ end
130
+ end
131
+
132
+ # Default to 29325 if we couldn't detect
133
+ notification_port ||= 29325
134
+
135
+ # Write port to workspace config file
136
+ workspace = machine.config.claude_sandbox.workspace_path rescue "/agent-workspace"
137
+ port_file = File.join(Dir.pwd, ".vagrant-notification-port")
138
+ File.write(port_file, notification_port.to_s)
139
+ machine.ui.info("Notification server port: #{notification_port}")
140
+ end
141
+ end
112
142
  end
113
143
 
114
144
  def apply_virtualbox_config!(root_config)
@@ -253,7 +283,13 @@ module VagrantPlugins
253
283
 
254
284
  TITLE=""
255
285
  MESSAGE=""
256
- HOST_PORT=29325
286
+
287
+ # Read port from config file (written by vagrant trigger), default to 29325
288
+ if [ -f "/agent-workspace/.vagrant-notification-port" ]; then
289
+ HOST_PORT=$(cat /agent-workspace/.vagrant-notification-port)
290
+ else
291
+ HOST_PORT=29325
292
+ fi
257
293
 
258
294
  # Parse notify-send arguments (simplified)
259
295
  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.3.1"
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.3.1
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-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake