@xmarts/genius-setup 1.7.1 → 1.7.2

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.
@@ -63,7 +63,7 @@ def _inject(cfg, prompt):
63
63
  base = (cfg.get("base_url") or "https://beesmart.digital").rstrip("/")
64
64
  token = cfg.get("token")
65
65
  if not token or not prompt.strip():
66
- return ""
66
+ return "", None, None
67
67
  body = json.dumps({"jsonrpc": "2.0", "method": "call", "id": 1,
68
68
  "params": {"prompt": prompt[:4000], "limit": 4}}).encode()
69
69
  req = urllib.request.Request(base + "/xma/genius/v1/inject", data=body)
@@ -75,13 +75,34 @@ def _inject(cfg, prompt):
75
75
  resp = urllib.request.urlopen(req, timeout=TIMEOUT)
76
76
  data = json.loads(resp.read())
77
77
  result = data.get("result", data) or {}
78
- return (result.get("context", "") or ""), result.get("hook_force_epoch")
78
+ return ((result.get("context", "") or ""),
79
+ result.get("hook_force_epoch"),
80
+ result.get("hook_pin_version"))
79
81
  except Exception:
80
- return "", None
82
+ return "", None, None
81
83
 
82
84
 
83
- def _maybe_self_update(cfg, force_epoch=None):
84
- """Keep the consultant on the LATEST Genius package with ZERO action: at most
85
+ # M6 (Phase-0 integrity gate): NEVER resolve `@latest`. An unsigned `npx @latest`
86
+ # self-update is a standing fleet-wide RCE channel. We install an EXACT pinned
87
+ # version dictated by the server (xma_genius.hook_pin_version, returned in the
88
+ # inject response) and otherwise fall back to this bundled known-good pin — the
89
+ # client never resolves the mutable `@latest` tag.
90
+ PINNED_FALLBACK = "1.7.2"
91
+
92
+
93
+ def _pkg_spec(pin_version):
94
+ """Resolve the exact package spec to install. Accepts only a plain semver pin
95
+ from the server; anything else falls back to the bundled PINNED_FALLBACK.
96
+ Never returns an `@latest` spec."""
97
+ import re
98
+ v = (pin_version or "").strip()
99
+ if v and re.match(r"^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.]+)?$", v):
100
+ return "@xmarts/genius-setup@%s" % v
101
+ return "@xmarts/genius-setup@%s" % PINNED_FALLBACK
102
+
103
+
104
+ def _maybe_self_update(cfg, force_epoch=None, pin_version=None):
105
+ """Keep the consultant on the SERVER-PINNED Genius package with ZERO action: at most
85
106
  once/day, silently re-run the installer in the background. New hooks, MCP
86
107
  tools, settings and the CLAUDE.md protocol then flow automatically — the
87
108
  consultant never re-onboards. Detached + fully guarded; never blocks a turn.
@@ -124,15 +145,16 @@ def _maybe_self_update(cfg, force_epoch=None):
124
145
  env = dict(os.environ)
125
146
  env["GENIUS_TOKEN"] = token
126
147
  base = cfg.get("base_url")
148
+ spec = _pkg_spec(pin_version) # exact pinned version — never @latest
127
149
  devnull = open(os.devnull, "w")
128
150
  if os.name == "nt":
129
- cmd = "npx -y @xmarts/genius-setup@latest"
151
+ cmd = "npx -y %s" % spec
130
152
  if base:
131
153
  cmd += ' --base-url "%s"' % base
132
154
  subprocess.Popen(cmd, shell=True, env=env, stdout=devnull, stderr=devnull,
133
155
  stdin=subprocess.DEVNULL, creationflags=0x00000008) # DETACHED_PROCESS
134
156
  else:
135
- args = ["npx", "-y", "@xmarts/genius-setup@latest"]
157
+ args = ["npx", "-y", spec]
136
158
  if base:
137
159
  args += ["--base-url", base]
138
160
  subprocess.Popen(args, env=env, stdout=devnull, stderr=devnull,
@@ -152,10 +174,11 @@ def main():
152
174
  _maybe_self_update(cfg) # TTL-only on priming
153
175
  _emit("SessionStart", SESSION_PRIMER)
154
176
  else:
155
- context, force_epoch = _inject(cfg, event.get("prompt") or "")
177
+ context, force_epoch, pin_version = _inject(cfg, event.get("prompt") or "")
156
178
  # The inject call already round-tripped the server, so honour any
157
- # admin-pushed force-update epoch here (bypasses the daily TTL).
158
- _maybe_self_update(cfg, force_epoch)
179
+ # admin-pushed force-update epoch here (bypasses the daily TTL) and install
180
+ # the exact server-pinned version (never @latest).
181
+ _maybe_self_update(cfg, force_epoch, pin_version)
159
182
  _emit("UserPromptSubmit", context)
160
183
 
161
184
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmarts/genius-setup",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "One-command, self-updating onboarding for Xmarts Genius (Brain MCP + per-turn injection + automatic session/time capture + CLAUDE.md protocol). Secret-free onboarding via single-use setup-token exchange (no Bearer in the GET-able bootstrap). Installs once; self-updates daily so new tools/skills/features arrive with zero action.",
5
5
  "bin": {
6
6
  "genius-setup": "bin/genius-setup.js"