tokensafe 1.4.14 → 1.4.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokensafe",
3
- "version": "1.4.14",
3
+ "version": "1.4.15",
4
4
  "description": "Autonomous Zero-Loss Token Economy & Context Optimizer for AI Coding Agents",
5
5
  "main": "bin/tokensafe.js",
6
6
  "bin": {
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agy-token-optimizer",
3
3
  "displayName": "TokenSafe",
4
- "version": "1.4.14",
4
+ "version": "1.4.15",
5
5
  "description": "Zero-Loss Token Economy & Context Optimizer for AI Agents. Compresses prompts, slices AST/tool outputs, and prevents stuck loops.",
6
6
  "logo": "assets/logo.svg",
7
7
  "author": {
package/src/mcp_server.py CHANGED
@@ -35,7 +35,7 @@ from src.scoped_search import ScopedSearch
35
35
 
36
36
  SERVER_INFO = {
37
37
  "name": "tokensafe-mcp",
38
- "version": "1.4.14"
38
+ "version": "1.4.15"
39
39
  }
40
40
 
41
41
  TOOLS = [
@@ -249,7 +249,7 @@ class TelemetrySync:
249
249
  rollup_synced = bool(state.get("lifetime_rollup_synced", False))
250
250
  headers = {
251
251
  "Content-Type": "application/json",
252
- "User-Agent": "TokenSafe-Sync/1.4.14"
252
+ "User-Agent": "TokenSafe-Sync/1.4.15"
253
253
  }
254
254
  if active_key:
255
255
  headers["Authorization"] = f"Bearer {active_key}"
@@ -16,7 +16,7 @@ import urllib.request
16
16
  import urllib.error
17
17
  from typing import Dict, Any, Optional, Tuple
18
18
 
19
- CURRENT_VERSION = "1.4.14"
19
+ CURRENT_VERSION = "1.4.15"
20
20
  CACHE_TTL = 86400 # 24 hours
21
21
  # When the cloud is unreachable we must NOT cache the synthesized "up to date"
22
22
  # answer for a full day — otherwise an update released right after an outage
@@ -174,6 +174,11 @@ class VersionChecker:
174
174
 
175
175
  return None
176
176
 
177
+ @staticmethod
178
+ def _posix_single_quote(text: str) -> str:
179
+ """Quotes text for safe embedding inside a single-quoted shell string."""
180
+ return "'" + text.replace("'", "'\\''") + "'"
181
+
177
182
  @classmethod
178
183
  def show_os_dialog(
179
184
  cls,
@@ -189,16 +194,24 @@ class VersionChecker:
189
194
 
190
195
  if plat == "darwin":
191
196
  try:
192
- # TCC-safe: driving Terminal.app via AppleScript requires an
193
- # Automation permission prompt that background (hook-spawned)
194
- # processes can never satisfy, which made "Update Now" silently fail.
195
- # `do shell script` needs no such permission; prefer the explicit
196
- # ~/.local/bin path because non-interactive shells lack the user PATH.
197
- escaped_cmd = update_command.replace('"', '\\"')
197
+ # TCC-safe: driving Terminal.app via AppleScript requires an Automation
198
+ # permission prompt that background (hook-spawned) processes can never
199
+ # satisfy, which made "Update Now" silently fail. `do shell script` needs
200
+ # no such permission. The updater runs inside a LOGIN shell so that
201
+ # profile-managed PATH entries (nvm, homebrew, volta, ~/.local/bin…)
202
+ # resolve the `tokensafe` executable; a bare non-interactive shell
203
+ # would not see them and log "command not found".
204
+ inner_cmd = f"nohup {update_command} > /tmp/tokensafe-update.log 2>&1 &"
205
+ shell_cmd = (
206
+ 'SHELL_BIN=${SHELL:-/bin/zsh}; [ -x "$SHELL_BIN" ] || SHELL_BIN=/bin/zsh; '
207
+ f'nohup "$SHELL_BIN" -lc {cls._posix_single_quote(inner_cmd)} >/dev/null 2>&1 &'
208
+ )
209
+ # Escape the shell command for embedding inside an AppleScript string literal
210
+ escaped_shell = shell_cmd.replace("\\", "\\\\").replace('"', '\\"')
198
211
  apple_script = f'''
199
212
  set dialogResult to display dialog "A new version of TokenSafe (v{latest_version}) is available.\\n\\nCurrent version: v{current_version}\\nLatest version: v{latest_version}\\n\\nWould you like to update now?" with title "TokenSafe Update Available" buttons {{"Later", "Update Now"}} default button "Update Now" with icon note
200
213
  if button returned of dialogResult is "Update Now" then
201
- do shell script "if [ -x \\"$HOME/.local/bin/tokensafe\\" ]; then CMD=\\"$HOME/.local/bin/tokensafe\\"; else CMD=\\"{escaped_cmd}\\"; fi; nohup \\"$CMD\\" update > /tmp/tokensafe-update.log 2>&1 &"
214
+ do shell script "{escaped_shell}"
202
215
  end if
203
216
  '''
204
217
  subprocess.Popen(