@remnic/plugin-claude-code 10.0.192 → 10.0.194

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "remnic",
3
3
  "description": "Universal memory for AI agents — automatic recall, observation, and cross-agent knowledge sharing",
4
- "version": "10.0.192",
4
+ "version": "10.0.194",
5
5
  "author": {
6
6
  "name": "Joshua Warren"
7
7
  },
@@ -78,7 +78,7 @@ function run(config) {
78
78
  // operator fixes the URL rather than debugging silent cross-store writes
79
79
  // (#1571 review).
80
80
  let DAEMON_CONFIG_ERROR = "";
81
- const DAEMON_URL = (function resolveDaemonUrl() {
81
+ let DAEMON_URL = (function resolveDaemonUrl() {
82
82
  if (RAW_DAEMON_URL) {
83
83
  try {
84
84
  const parsed = new URL(RAW_DAEMON_URL);
@@ -88,8 +88,19 @@ function run(config) {
88
88
  } catch {
89
89
  /* handled below */
90
90
  }
91
+ // RAW_DAEMON_URL can carry credentials or query tokens (a pasted URL
92
+ // with secrets); log protocol+hostname only, never the raw value — it
93
+ // reaches stderr AND the host model context via additionalContext.
94
+ let redacted = "<unparseable URL>";
95
+ try {
96
+ const rp = new URL(RAW_DAEMON_URL);
97
+ redacted = `${rp.protocol}//${rp.hostname}${rp.port ? ":" + rp.port : ""}`;
98
+ } catch {
99
+ const scheme = /^\s*([a-z][a-z0-9+.-]*):/i.exec(RAW_DAEMON_URL);
100
+ if (scheme) redacted = `${scheme[1]}://<unparseable>`;
101
+ }
91
102
  DAEMON_CONFIG_ERROR =
92
- 'REMNIC_DAEMON_URL="' + RAW_DAEMON_URL + '" is not a valid http(s) URL — ' +
103
+ 'REMNIC_DAEMON_URL=' + redacted + ' is not a valid http(s) URL — ' +
93
104
  "daemon disabled (recall/observe/flush will no-op). Set a valid " +
94
105
  "http(s):// URL or unset REMNIC_DAEMON_URL to use REMNIC_HOST/REMNIC_PORT.";
95
106
  if (process.env.REMNIC_HOOK_QUIET !== "1") {
@@ -110,27 +121,45 @@ function run(config) {
110
121
  // prefix silently dropped and requests hit the host root (#1571 review).
111
122
  // Trailing slashes are stripped so "/remnic/" + "/engram/v1/observe"
112
123
  // becomes "/remnic/engram/v1/observe"; a bare root ("/") yields "".
113
- const DAEMON_BASE_PATH = DAEMON_URL ? DAEMON_URL.pathname.replace(/\/+$/, "") : "";
124
+ let DAEMON_BASE_PATH = DAEMON_URL ? DAEMON_URL.pathname.replace(/\/+$/, "") : "";
114
125
 
115
126
  // URL.hostname keeps the brackets on IPv6 literals ("[::1]"); Node's
116
127
  // http(s).request options.hostname does not accept them, so strip them
117
128
  // once here for every request path below.
118
- const DAEMON_HOSTNAME = DAEMON_URL
129
+ let DAEMON_HOSTNAME = DAEMON_URL
119
130
  ? DAEMON_URL.hostname.replace(/^\[|\]$/g, "")
120
131
  : "";
121
132
 
122
- // Plain-http daemon URLs to non-loopback hosts send the bearer token
123
- // cleartext. Remote-daemon-over-http is a supported deployment shape
124
- // (trusted LAN/Tailscale), so this warns rather than refuses — but the
125
- // operator should see the exposure once per hook invocation batch.
133
+ // Plain-http daemon URLs to non-loopback hosts send the bearer token AND
134
+ // the observe/recall bodies cleartext. The MCP proxy refuses this outright
135
+ // unless REMNIC_MCP_ALLOW_CLEARTEXT_HTTP=1; the hook must not be the loose
136
+ // link, so it now fails closed the same way: daemon disabled (recall/
137
+ // observe/flush no-op) with the opt-in named, warn-and-proceed only when
138
+ // the opt-in is explicitly set. Migration: switch REMNIC_DAEMON_URL to
139
+ // https:// or a loopback address, or set REMNIC_MCP_ALLOW_CLEARTEXT_HTTP=1
140
+ // in the host session's environment on a trusted network.
126
141
  if (DAEMON_URL && DAEMON_URL.protocol === "http:" && !isLoopbackHost(DAEMON_HOSTNAME)) {
127
- if (process.env.REMNIC_HOOK_QUIET !== "1") {
128
- try {
129
- process.stderr.write(
130
- `[${PROG_NAME}] REMNIC_DAEMON_URL uses plain http:// to a non-loopback host; ` +
131
- "the bearer token will be sent cleartext — prefer https:// for remote daemons.\n",
132
- );
133
- } catch {}
142
+ if (process.env.REMNIC_MCP_ALLOW_CLEARTEXT_HTTP === "1") {
143
+ if (process.env.REMNIC_HOOK_QUIET !== "1") {
144
+ try {
145
+ process.stderr.write(
146
+ `[${PROG_NAME}] REMNIC_DAEMON_URL uses plain http:// to a non-loopback host; ` +
147
+ "the bearer token will be sent cleartext because REMNIC_MCP_ALLOW_CLEARTEXT_HTTP=1 is set.\n",
148
+ );
149
+ } catch {}
150
+ }
151
+ } else {
152
+ DAEMON_URL = null;
153
+ DAEMON_BASE_PATH = "";
154
+ DAEMON_HOSTNAME = "";
155
+ DAEMON_CONFIG_ERROR =
156
+ 'REMNIC_DAEMON_URL uses plain http:// to a non-loopback host — daemon disabled ' +
157
+ "(recall/observe/flush will no-op) because the bearer token would travel cleartext. " +
158
+ "Migration: use https:// or a loopback address (http://localhost / http://127.0.0.x), " +
159
+ "or set REMNIC_MCP_ALLOW_CLEARTEXT_HTTP=1 on a trusted network.";
160
+ if (process.env.REMNIC_HOOK_QUIET !== "1") {
161
+ try { process.stderr.write(`[${PROG_NAME}] ${DAEMON_CONFIG_ERROR}\n`); } catch {}
162
+ }
134
163
  }
135
164
  }
136
165
 
@@ -138,7 +167,22 @@ function run(config) {
138
167
  const h = (hostname || "").toLowerCase();
139
168
  if (h === "localhost") return true;
140
169
  if (h === "::1") return true;
141
- return /^127(?:\.\d{1,3}){3}$/.test(h);
170
+ // IPv4-mapped IPv6: Node's URL parser normalizes [::ffff:127.0.0.1] to
171
+ // [::ffff:7f00:1], so classify by the embedded IPv4 in either its dotted
172
+ // or hex form. "::" (unspecified) is deliberately NOT loopback — dialing
173
+ // it means "any interface", which can leave the host.
174
+ const mapped = /^::ffff:(.+)$/.exec(h);
175
+ if (mapped) return isIPv4LoopbackText(mapped[1]);
176
+ return isIPv4LoopbackText(h);
177
+ }
178
+
179
+ function isIPv4LoopbackText(s) {
180
+ if (/^127(?:\.\d{1,3}){3}$/.test(s)) return true;
181
+ // Hex pair form ("7f00:1"): the high 16-bit group carries the first two
182
+ // bytes of the embedded IPv4.
183
+ const hex = /^([0-9a-f]{1,4}):([0-9a-f]{1,4})$/.exec(s);
184
+ if (hex) return parseInt(hex[1], 16) >>> 8 === 127;
185
+ return false;
142
186
  }
143
187
 
144
188
  // Internal re-entrant mode: post-tool-observe spawns a detached copy of
@@ -991,6 +1035,21 @@ function run(config) {
991
1035
  }
992
1036
  }
993
1037
 
1038
+ // Policy-disabled or invalid daemon URL: starting a local daemon cannot
1039
+ // repair the configured (remote) URL, and the gate already told the
1040
+ // operator what to change. Surface the guidance instead of probing.
1041
+ if (DAEMON_CONFIG_ERROR) {
1042
+ log("daemon disabled by config; skipping health recovery");
1043
+ emit({
1044
+ continue: true,
1045
+ hookSpecificOutput: {
1046
+ hookEventName: "SessionStart",
1047
+ additionalContext: `[Remnic: daemon disabled — ${DAEMON_CONFIG_ERROR}]`,
1048
+ },
1049
+ });
1050
+ return;
1051
+ }
1052
+
994
1053
  // Health check — start daemon if not running.
995
1054
  if (!(await httpHealthy(2000, token))) {
996
1055
  log("daemon not responding, attempting start...");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remnic/plugin-claude-code",
3
- "version": "10.0.192",
3
+ "version": "10.0.194",
4
4
  "description": "Remnic memory plugin for Claude Code — hooks, skills, MCP integration",
5
5
  "type": "module",
6
6
  "license": "MIT",