@inerrata-corporation/errata 2.0.22-dev.4071 → 2.0.22-dev.4121

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/errata.mjs CHANGED
@@ -33350,8 +33350,7 @@ async function embedNodesByLabels(store, labels, opts = {}) {
33350
33350
  versionsSeen: {}
33351
33351
  };
33352
33352
  const hashOnly = opts.mode === "hash";
33353
- const currentVersion = hashOnly ? EMBEDDING_VERSION : (await embedBatchWithModelOrHash(["probe"]))[0]?.version ?? "unknown";
33354
- const todo = [];
33353
+ const candidates = [];
33355
33354
  for (const label of labels) {
33356
33355
  for (const node2 of store.selectNodes({
33357
33356
  labels: [label],
@@ -33370,15 +33369,24 @@ async function embedNodesByLabels(store, labels, opts = {}) {
33370
33369
  report.skippedFresh++;
33371
33370
  continue;
33372
33371
  }
33373
- if (!opts.force && existingVersion === currentVersion && node2.embeddingDim > 0) {
33374
- report.skippedFresh++;
33375
- continue;
33376
- }
33377
- const text = buildText(store, node2);
33378
- if (!text) continue;
33379
- const embedding = node2.embeddingDim > 0 ? store.getNode(node2.id).embedding : [];
33380
- todo.push(embeddingSnapshot({ ...node2, embedding }, text));
33372
+ candidates.push({ node: node2, existingVersion });
33373
+ }
33374
+ }
33375
+ if (candidates.length === 0) {
33376
+ report.durationMs = Date.now() - started2;
33377
+ return report;
33378
+ }
33379
+ const currentVersion = hashOnly ? EMBEDDING_VERSION : (await embedBatchWithModelOrHash(["probe"]))[0]?.version ?? "unknown";
33380
+ const todo = [];
33381
+ for (const { node: node2, existingVersion } of candidates) {
33382
+ if (!opts.force && existingVersion === currentVersion && node2.embeddingDim > 0) {
33383
+ report.skippedFresh++;
33384
+ continue;
33381
33385
  }
33386
+ const text = buildText(store, node2);
33387
+ if (!text) continue;
33388
+ const embedding = node2.embeddingDim > 0 ? store.getNode(node2.id).embedding : [];
33389
+ todo.push(embeddingSnapshot({ ...node2, embedding }, text));
33382
33390
  }
33383
33391
  for (let i2 = 0; i2 < todo.length; i2 += BATCH_SIZE) {
33384
33392
  const batch = todo.slice(i2, i2 + BATCH_SIZE);
@@ -85045,7 +85053,7 @@ function createWatchBreaker(deps) {
85045
85053
  }
85046
85054
 
85047
85055
  // src/engine.ts
85048
- var DAEMON_VERSION = true ? "2.0.22-dev.4071" : "2.0.0-alpha.0";
85056
+ var DAEMON_VERSION = true ? "2.0.22-dev.4121" : "2.0.0-alpha.0";
85049
85057
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
85050
85058
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
85051
85059
  var GIT_OP_MUTE_MS = 4e3;
@@ -87715,6 +87723,39 @@ B: ${b}`,
87715
87723
  };
87716
87724
  }
87717
87725
 
87726
+ // src/loopback-guard.ts
87727
+ var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "[::1]"]);
87728
+ function isLoopbackHost(host) {
87729
+ const h = host.trim().toLowerCase();
87730
+ const m = /^(\[[^\]]+\]|[^:]+)(?::(\d+))?$/.exec(h);
87731
+ return !!m && LOOPBACK_HOSTNAMES.has(m[1]);
87732
+ }
87733
+ function isLoopbackOrigin(origin) {
87734
+ try {
87735
+ const u = new URL(origin);
87736
+ return u.protocol === "http:" && LOOPBACK_HOSTNAMES.has(u.hostname);
87737
+ } catch {
87738
+ return false;
87739
+ }
87740
+ }
87741
+ function loopbackRefusal(headers) {
87742
+ const host = headers.get("host");
87743
+ if (host !== null && host !== "" && !isLoopbackHost(host)) return "non-loopback Host";
87744
+ const origin = headers.get("origin");
87745
+ if (origin !== null && !isLoopbackOrigin(origin)) return "non-loopback Origin";
87746
+ return null;
87747
+ }
87748
+ function withLoopbackGuard(fetchFn) {
87749
+ return (req) => {
87750
+ const refusal = loopbackRefusal(req.headers);
87751
+ if (refusal) return new Response(JSON.stringify({ error: "forbidden", reason: refusal }), {
87752
+ status: 403,
87753
+ headers: { "content-type": "application/json" }
87754
+ });
87755
+ return fetchFn(req);
87756
+ };
87757
+ }
87758
+
87718
87759
  // src/daemon.ts
87719
87760
  async function startDaemon(opts) {
87720
87761
  const processStartedAt = Date.now();
@@ -87796,7 +87837,7 @@ async function startDaemon(opts) {
87796
87837
  }
87797
87838
  async function listenServer(fetchFn, port) {
87798
87839
  return new Promise((resolve10, reject) => {
87799
- const server = serve({ fetch: fetchFn, hostname: "127.0.0.1", port }, (info2) => {
87840
+ const server = serve({ fetch: withLoopbackGuard(fetchFn), hostname: "127.0.0.1", port }, (info2) => {
87800
87841
  resolve10({ server, port: info2.port });
87801
87842
  });
87802
87843
  server.once(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.22-dev.4071",
3
+ "version": "2.0.22-dev.4121",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "errata-context",
3
- "version": "2.0.22-dev.4071",
3
+ "version": "2.0.22-dev.4121",
4
4
  "description": "A minimal 3D view of loaded Errata priors and recent graph bursts.",
5
5
  "author": {
6
6
  "name": "inErrata"
@@ -1,4 +1,4 @@
1
- 2a7469f40a64a12ef74c4313dce84feb8ecccca9e841502b5b2e159fa098636f .codex-plugin/plugin.json
1
+ 9f7ae426e110baef3bb27e68785897f745b77ef23fd2ee4e73188e8e6047890d .codex-plugin/plugin.json
2
2
  a7bebae9fb01c838d6c75fc784129e28be571233fa66ff5ee8039b574f35ccf7 assets/icon.png
3
3
  fc38b64e4df1e0b72c35764bef6c4c05430d97c9009ad0ecc8a9e75b4deab232 configure-local.mjs
4
4
  73dc6028b3b070257c7c31f252d11e55a9e096f4aed0f187f10cb21716e1e6d7 dist/client.js