eminiar 0.13.4 → 0.13.5

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/dist/server.js CHANGED
@@ -7256,8 +7256,8 @@ var require_dist = __commonJS({
7256
7256
  return ajv;
7257
7257
  }
7258
7258
  const [formats, exportName] = opts.mode === "fast" ? [formats_1.fastFormats, fastName] : [formats_1.fullFormats, fullName];
7259
- const list2 = opts.formats || formats_1.formatNames;
7260
- addFormats(ajv, list2, formats, exportName);
7259
+ const list3 = opts.formats || formats_1.formatNames;
7260
+ addFormats(ajv, list3, formats, exportName);
7261
7261
  if (opts.keywords)
7262
7262
  (0, limit_1.default)(ajv);
7263
7263
  return ajv;
@@ -7269,11 +7269,11 @@ var require_dist = __commonJS({
7269
7269
  throw new Error(`Unknown format "${name}"`);
7270
7270
  return f;
7271
7271
  };
7272
- function addFormats(ajv, list2, fs, exportName) {
7272
+ function addFormats(ajv, list3, fs, exportName) {
7273
7273
  var _a3;
7274
7274
  var _b;
7275
7275
  (_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
7276
- for (const f of list2)
7276
+ for (const f of list3)
7277
7277
  ajv.addFormat(f, fs[f]);
7278
7278
  }
7279
7279
  module.exports = exports = formatsPlugin;
@@ -10441,9 +10441,9 @@ var require_micromatch = __commonJS({
10441
10441
  const index = v.indexOf("{");
10442
10442
  return index > -1 && v.indexOf("}", index) > -1;
10443
10443
  };
10444
- var micromatch2 = (list2, patterns, options) => {
10444
+ var micromatch2 = (list3, patterns, options) => {
10445
10445
  patterns = [].concat(patterns);
10446
- list2 = [].concat(list2);
10446
+ list3 = [].concat(list3);
10447
10447
  let omit2 = /* @__PURE__ */ new Set();
10448
10448
  let keep = /* @__PURE__ */ new Set();
10449
10449
  let items = /* @__PURE__ */ new Set();
@@ -10458,7 +10458,7 @@ var require_micromatch = __commonJS({
10458
10458
  let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true);
10459
10459
  let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
10460
10460
  if (negated) negatives++;
10461
- for (let item of list2) {
10461
+ for (let item of list3) {
10462
10462
  let matched = isMatch(item, true);
10463
10463
  let match = negated ? !matched.isMatch : matched.isMatch;
10464
10464
  if (!match) continue;
@@ -10486,7 +10486,7 @@ var require_micromatch = __commonJS({
10486
10486
  micromatch2.matcher = (pattern2, options) => picomatch(pattern2, options);
10487
10487
  micromatch2.isMatch = (str4, patterns, options) => picomatch(patterns, options)(str4);
10488
10488
  micromatch2.any = micromatch2.isMatch;
10489
- micromatch2.not = (list2, patterns, options = {}) => {
10489
+ micromatch2.not = (list3, patterns, options = {}) => {
10490
10490
  patterns = [].concat(patterns).map(String);
10491
10491
  let result = /* @__PURE__ */ new Set();
10492
10492
  let items = [];
@@ -10494,7 +10494,7 @@ var require_micromatch = __commonJS({
10494
10494
  if (options.onResult) options.onResult(state);
10495
10495
  items.push(state.output);
10496
10496
  };
10497
- let matches2 = new Set(micromatch2(list2, patterns, { ...options, onResult }));
10497
+ let matches2 = new Set(micromatch2(list3, patterns, { ...options, onResult }));
10498
10498
  for (let item of items) {
10499
10499
  if (!matches2.has(item)) {
10500
10500
  result.add(item);
@@ -10528,8 +10528,8 @@ var require_micromatch = __commonJS({
10528
10528
  for (let key of keys) res[key] = obj[key];
10529
10529
  return res;
10530
10530
  };
10531
- micromatch2.some = (list2, patterns, options) => {
10532
- let items = [].concat(list2);
10531
+ micromatch2.some = (list3, patterns, options) => {
10532
+ let items = [].concat(list3);
10533
10533
  for (let pattern2 of [].concat(patterns)) {
10534
10534
  let isMatch = picomatch(String(pattern2), options);
10535
10535
  if (items.some((item) => isMatch(item))) {
@@ -10538,8 +10538,8 @@ var require_micromatch = __commonJS({
10538
10538
  }
10539
10539
  return false;
10540
10540
  };
10541
- micromatch2.every = (list2, patterns, options) => {
10542
- let items = [].concat(list2);
10541
+ micromatch2.every = (list3, patterns, options) => {
10542
+ let items = [].concat(list3);
10543
10543
  for (let pattern2 of [].concat(patterns)) {
10544
10544
  let isMatch = picomatch(String(pattern2), options);
10545
10545
  if (!items.every((item) => isMatch(item))) {
@@ -15445,15 +15445,15 @@ var ZodObject = class _ZodObject extends ZodType {
15445
15445
  });
15446
15446
  }
15447
15447
  if (this._def.catchall instanceof ZodNever) {
15448
- const unknownKeys = this._def.unknownKeys;
15449
- if (unknownKeys === "passthrough") {
15448
+ const unknownKeys2 = this._def.unknownKeys;
15449
+ if (unknownKeys2 === "passthrough") {
15450
15450
  for (const key of extraKeys) {
15451
15451
  pairs.push({
15452
15452
  key: { status: "valid", value: key },
15453
15453
  value: { status: "valid", value: ctx.data[key] }
15454
15454
  });
15455
15455
  }
15456
- } else if (unknownKeys === "strict") {
15456
+ } else if (unknownKeys2 === "strict") {
15457
15457
  if (extraKeys.length > 0) {
15458
15458
  addIssueToContext(ctx, {
15459
15459
  code: ZodIssueCode.unrecognized_keys,
@@ -15461,7 +15461,7 @@ var ZodObject = class _ZodObject extends ZodType {
15461
15461
  });
15462
15462
  status.dirty();
15463
15463
  }
15464
- } else if (unknownKeys === "strip") {
15464
+ } else if (unknownKeys2 === "strip") {
15465
15465
  } else {
15466
15466
  throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
15467
15467
  }
@@ -33067,8 +33067,8 @@ var contributors = {
33067
33067
  function aggregateChecks(schema2) {
33068
33068
  const agg = {};
33069
33069
  const def = schema2._zod.def;
33070
- const list2 = schema2._zod.traits.has("$ZodCheck") ? [schema2, ...def.checks ?? []] : def.checks ?? [];
33071
- for (const ch of list2)
33070
+ const list3 = schema2._zod.traits.has("$ZodCheck") ? [schema2, ...def.checks ?? []] : def.checks ?? [];
33071
+ for (const ch of list3)
33072
33072
  contributors[ch._zod.def.check]?.(agg, ch._zod.def);
33073
33073
  const bag = schema2._zod.bag;
33074
33074
  if (bag.minimum !== void 0)
@@ -44222,8 +44222,8 @@ function parseRouteAnnotations(doc) {
44222
44222
  const body = m[1] ?? "";
44223
44223
  const path3 = /^\s*"([^"]*)"/.exec(body)?.[1] ?? /\bpath\s*=\s*"([^"]*)"/.exec(body)?.[1];
44224
44224
  if (path3 === void 0) continue;
44225
- const list2 = /\bmethods\s*=\s*(\{[^}]*\}|"[^"]*")/.exec(body)?.[1] ?? "";
44226
- const methods = [...list2.matchAll(/"([^"]+)"/g)].map((x) => httpMethod(x[1])).filter((x) => !!x);
44225
+ const list3 = /\bmethods\s*=\s*(\{[^}]*\}|"[^"]*")/.exec(body)?.[1] ?? "";
44226
+ const methods = [...list3.matchAll(/"([^"]+)"/g)].map((x) => httpMethod(x[1])).filter((x) => !!x);
44227
44227
  for (const method of methods.length ? methods : ["ALL"]) out.push({ method, path: path3 });
44228
44228
  }
44229
44229
  return out;
@@ -45037,16 +45037,16 @@ function phpString(n) {
45037
45037
  return literalText(n)?.replace(/\\(\\|')/g, "$1");
45038
45038
  }
45039
45039
  function argsOf(call) {
45040
- const list2 = call.childForFieldName("arguments") ?? call.childForFieldName("parameters");
45041
- return (list2?.namedChildren ?? []).filter((a) => a?.type === "argument").map((a) => a.namedChildren[a.namedChildren.length - 1]).filter((a) => !!a);
45040
+ const list3 = call.childForFieldName("arguments") ?? call.childForFieldName("parameters");
45041
+ return (list3?.namedChildren ?? []).filter((a) => a?.type === "argument").map((a) => a.namedChildren[a.namedChildren.length - 1]).filter((a) => !!a);
45042
45042
  }
45043
45043
  function positionalArgs(call) {
45044
- const list2 = call.childForFieldName("arguments") ?? call.childForFieldName("parameters");
45045
- return (list2?.namedChildren ?? []).filter((a) => a?.type === "argument" && !a.childForFieldName("name")).map((a) => a.namedChildren[0]).filter((a) => !!a);
45044
+ const list3 = call.childForFieldName("arguments") ?? call.childForFieldName("parameters");
45045
+ return (list3?.namedChildren ?? []).filter((a) => a?.type === "argument" && !a.childForFieldName("name")).map((a) => a.namedChildren[0]).filter((a) => !!a);
45046
45046
  }
45047
45047
  function namedArg(call, name) {
45048
- const list2 = call.childForFieldName("arguments") ?? call.childForFieldName("parameters");
45049
- for (const a of list2?.namedChildren ?? []) {
45048
+ const list3 = call.childForFieldName("arguments") ?? call.childForFieldName("parameters");
45049
+ for (const a of list3?.namedChildren ?? []) {
45050
45050
  if (a?.type === "argument" && a.childForFieldName("name")?.text === name)
45051
45051
  return a.namedChildren[a.namedChildren.length - 1] ?? void 0;
45052
45052
  }
@@ -48137,9 +48137,9 @@ function computeMetrics(db) {
48137
48137
  for (const s of symbols) {
48138
48138
  const f = s.path ? `file:${s.path}` : void 0;
48139
48139
  if (!f) continue;
48140
- const list2 = symbolsByFile.get(f) ?? [];
48141
- list2.push(s);
48142
- symbolsByFile.set(f, list2);
48140
+ const list3 = symbolsByFile.get(f) ?? [];
48141
+ list3.push(s);
48142
+ symbolsByFile.set(f, list3);
48143
48143
  }
48144
48144
  for (const f of files) {
48145
48145
  const m = meta3(f);
@@ -48192,9 +48192,9 @@ function computeMetrics(db) {
48192
48192
  const members2 = /* @__PURE__ */ new Map();
48193
48193
  for (const r of fileRows) {
48194
48194
  if (r.cluster === null) continue;
48195
- const list2 = members2.get(r.cluster) ?? [];
48196
- list2.push(r);
48197
- members2.set(r.cluster, list2);
48195
+ const list3 = members2.get(r.cluster) ?? [];
48196
+ list3.push(r);
48197
+ members2.set(r.cluster, list3);
48198
48198
  }
48199
48199
  const links = /* @__PURE__ */ new Map();
48200
48200
  for (const e of importEdges) {
@@ -55822,11 +55822,11 @@ function createOpenAIProvider(r, cfg, deps = {}) {
55822
55822
  };
55823
55823
  }
55824
55824
  function mapAnswers(reqs, items, raw, cat, askTool) {
55825
- const list2 = raw && typeof raw === "object" && Array.isArray(raw.items) ? raw.items : void 0;
55826
- if (!list2) throw new ProviderError("invalid", "the answer has no items array");
55825
+ const list3 = raw && typeof raw === "object" && Array.isArray(raw.items) ? raw.items : void 0;
55826
+ if (!list3) throw new ProviderError("invalid", "the answer has no items array");
55827
55827
  const Item = itemSchema(cat, askTool);
55828
55828
  const byId = /* @__PURE__ */ new Map();
55829
- for (const x of list2) {
55829
+ for (const x of list3) {
55830
55830
  const p2 = Item.safeParse(x);
55831
55831
  if (p2.success && !byId.has(p2.data.id)) byId.set(p2.data.id, p2.data);
55832
55832
  }
@@ -57175,8 +57175,8 @@ function pricedSavings(stats, calls, overrides, opts = {}) {
57175
57175
  };
57176
57176
  const bySession2 = /* @__PURE__ */ new Map();
57177
57177
  for (const c of calls) {
57178
- const list2 = bySession2.get(c.session_id);
57179
- if (list2) list2.push(c);
57178
+ const list3 = bySession2.get(c.session_id);
57179
+ if (list3) list3.push(c);
57180
57180
  else bySession2.set(c.session_id, [c]);
57181
57181
  }
57182
57182
  const sessionModel = /* @__PURE__ */ new Map();
@@ -57348,29 +57348,29 @@ function promptWindows(prompts, calls) {
57348
57348
  const bySession2 = /* @__PURE__ */ new Map();
57349
57349
  for (const p2 of prompts) {
57350
57350
  if (!p2.sessionId) continue;
57351
- const list2 = bySession2.get(p2.sessionId);
57352
- if (list2) list2.push(p2);
57351
+ const list3 = bySession2.get(p2.sessionId);
57352
+ if (list3) list3.push(p2);
57353
57353
  else bySession2.set(p2.sessionId, [p2]);
57354
57354
  }
57355
- for (const list2 of bySession2.values()) list2.sort((a, b) => a.ts - b.ts || a.id - b.id);
57355
+ for (const list3 of bySession2.values()) list3.sort((a, b) => a.ts - b.ts || a.id - b.id);
57356
57356
  const out = /* @__PURE__ */ new Map();
57357
57357
  for (const p2 of prompts) out.set(p2.id, []);
57358
57358
  for (const c of calls) {
57359
57359
  if (c.sidechain) continue;
57360
- const list2 = bySession2.get(c.session_id);
57361
- if (!list2) continue;
57360
+ const list3 = bySession2.get(c.session_id);
57361
+ if (!list3) continue;
57362
57362
  let lo = 0;
57363
- let hi = list2.length - 1;
57363
+ let hi = list3.length - 1;
57364
57364
  let at = -1;
57365
57365
  while (lo <= hi) {
57366
57366
  const mid = lo + hi >> 1;
57367
- if (list2[mid].ts <= c.ts) {
57367
+ if (list3[mid].ts <= c.ts) {
57368
57368
  at = mid;
57369
57369
  lo = mid + 1;
57370
57370
  } else hi = mid - 1;
57371
57371
  }
57372
57372
  if (at < 0) continue;
57373
- out.get(list2[at].id)?.push(c);
57373
+ out.get(list3[at].id)?.push(c);
57374
57374
  }
57375
57375
  return out;
57376
57376
  }
@@ -57719,8 +57719,8 @@ var Reconciler = class {
57719
57719
  const m = /* @__PURE__ */ new Map();
57720
57720
  for (const p2 of allRows(this.db, { surface: "prompt", since })) {
57721
57721
  if (!p2.sessionId) continue;
57722
- const list2 = m.get(p2.sessionId);
57723
- if (list2) list2.push(p2);
57722
+ const list3 = m.get(p2.sessionId);
57723
+ if (list3) list3.push(p2);
57724
57724
  else m.set(p2.sessionId, [p2]);
57725
57725
  }
57726
57726
  this.promptsBySession = m;
@@ -57746,8 +57746,8 @@ var Reconciler = class {
57746
57746
  const bySession2 = /* @__PURE__ */ new Map();
57747
57747
  for (const r of targets) {
57748
57748
  if (r.agentId || !r.sessionId) continue;
57749
- const list2 = bySession2.get(r.sessionId);
57750
- if (list2) list2.push(r);
57749
+ const list3 = bySession2.get(r.sessionId);
57750
+ if (list3) list3.push(r);
57751
57751
  else bySession2.set(r.sessionId, [r]);
57752
57752
  }
57753
57753
  if (!bySession2.size) return;
@@ -57765,8 +57765,8 @@ var Reconciler = class {
57765
57765
  const callsBy = /* @__PURE__ */ new Map();
57766
57766
  for (const c of this.calls(sessionId)) {
57767
57767
  if (!c.sidechain || !c.agent_id || this.taken.has(c.agent_id)) continue;
57768
- const list2 = callsBy.get(c.agent_id);
57769
- if (list2) list2.push(c);
57768
+ const list3 = callsBy.get(c.agent_id);
57769
+ if (list3) list3.push(c);
57770
57770
  else callsBy.set(c.agent_id, [c]);
57771
57771
  }
57772
57772
  const agents = [...callsBy].map(([id, cs]) => ({
@@ -58880,6 +58880,70 @@ function existingGenerated(dir) {
58880
58880
  }
58881
58881
  return out;
58882
58882
  }
58883
+ function ignoredWhere(ignored, config2, agentType) {
58884
+ const hit = config2.swarms.flatMap(
58885
+ (swarm) => swarm.roles.filter((r) => r.agentType === agentType).map((r) => ({ swarm, role: r }))
58886
+ )[0];
58887
+ if (!hit) return [];
58888
+ const out = [];
58889
+ for (const i of ignored) {
58890
+ const seg = i.path === "" ? [] : i.path.split(".");
58891
+ const name = /"(.+?)"/.exec(i.message)?.[1] ?? "?";
58892
+ const mine = seg[0] !== "swarms" || seg.length < 2 || seg[1] === hit.swarm.name && (seg.length < 4 || seg[2] !== "agents" || seg[3] === hit.role.role);
58893
+ if (mine) out.push(name);
58894
+ }
58895
+ return out;
58896
+ }
58897
+ var list2 = (v) => typeof v === "string" ? v.split(",").map((x) => x.trim()).filter(Boolean) : [];
58898
+ function frontmatterOf(raw) {
58899
+ const content = raw.replace(/\r\n/g, "\n");
58900
+ const end = content.indexOf("\n---\n", 3);
58901
+ if (!content.startsWith("---\n") || end === -1) return void 0;
58902
+ try {
58903
+ const v = yaml().parse(content.slice(4, end));
58904
+ return v && typeof v === "object" ? v : void 0;
58905
+ } catch {
58906
+ return void 0;
58907
+ }
58908
+ }
58909
+ var NEUTRAL_KEYS = /* @__PURE__ */ new Set(["name", "description", "skills", "color", "model", "effort"]);
58910
+ function tightens(oldRaw, newRaw) {
58911
+ const o = frontmatterOf(oldRaw);
58912
+ const n = frontmatterOf(newRaw);
58913
+ if (!o || !n) return false;
58914
+ let tighter = false;
58915
+ for (const k of Object.keys(o)) {
58916
+ if (NEUTRAL_KEYS.has(k)) continue;
58917
+ if (!(k in n)) return false;
58918
+ const a = o[k];
58919
+ const b = n[k];
58920
+ if (JSON.stringify(a) === JSON.stringify(b)) continue;
58921
+ if (k === "tools") {
58922
+ const ob = new Set(list2(a));
58923
+ const nb = list2(b);
58924
+ if (!nb.every((t) => ob.has(t))) return false;
58925
+ tighter = true;
58926
+ } else if (k === "disallowedTools") {
58927
+ const nb = new Set(list2(b));
58928
+ if (!list2(a).every((t) => nb.has(t))) return false;
58929
+ tighter = true;
58930
+ } else if (k === "hooks") {
58931
+ const oh = a ?? {};
58932
+ const nh = b ?? {};
58933
+ for (const [ev3, entries] of Object.entries(oh)) {
58934
+ const have = new Set((nh[ev3] ?? []).map((e) => JSON.stringify(e)));
58935
+ if (!Array.isArray(entries) || !entries.every((e) => have.has(JSON.stringify(e))))
58936
+ return false;
58937
+ }
58938
+ tighter = true;
58939
+ } else if (k === "maxTurns") {
58940
+ if (typeof a !== "number" || typeof b !== "number" || b > a) return false;
58941
+ tighter = true;
58942
+ } else return false;
58943
+ }
58944
+ for (const k of Object.keys(n)) if (!(k in o) && !NEUTRAL_KEYS.has(k)) tighter = true;
58945
+ return tighter;
58946
+ }
58883
58947
  function planAgentSync(root, config2, opts = {}) {
58884
58948
  const dir = agentsDir(root);
58885
58949
  const wantedRoles = config2?.enabled ? config2.swarms.flatMap((swarm) => swarm.roles.map((role) => ({ swarm, role }))) : [];
@@ -58947,6 +59011,24 @@ function planAgentSync(root, config2, opts = {}) {
58947
59011
  reason: config2?.enabled ? "no longer in the swarm file" : "swarms are disabled"
58948
59012
  }
58949
59013
  );
59014
+ const ignored = config2?.ignoredKeys ?? [];
59015
+ if (ignored.length && !opts.force) {
59016
+ const holds = (agentType) => ignoredWhere(ignored, config2, agentType);
59017
+ return actions.map((a) => {
59018
+ if (a.action !== "update") return a;
59019
+ const where = holds(a.agentType);
59020
+ if (!where.length) return a;
59021
+ const old = generated.get(a.agentType);
59022
+ if (old && tightens(old.content, a.content ?? "")) return a;
59023
+ return {
59024
+ agentType: a.agentType,
59025
+ path: a.path,
59026
+ action: "conflict",
59027
+ held: true,
59028
+ reason: `kept: ${config2.rel} has keys this eminiar version does not know (${where.slice(0, 3).join(", ")}${where.length > 3 ? ", ..." : ""}), and a newer one may have generated this file with them; update eminiar, or sync with --force`
59029
+ };
59030
+ });
59031
+ }
58950
59032
  return actions;
58951
59033
  }
58952
59034
  function syncAgents(root, config2, opts = {}) {
@@ -59188,8 +59270,8 @@ function manifest(dir) {
59188
59270
  }
59189
59271
  function agentPaths(dir) {
59190
59272
  const a = manifest(dir)?.agents;
59191
- const list2 = typeof a === "string" ? [a] : Array.isArray(a) ? a.filter((x) => typeof x === "string") : [];
59192
- return (list2.length ? list2 : ["./agents"]).map((p2) => resolve8(dir, p2));
59273
+ const list3 = typeof a === "string" ? [a] : Array.isArray(a) ? a.filter((x) => typeof x === "string") : [];
59274
+ return (list3.length ? list3 : ["./agents"]).map((p2) => resolve8(dir, p2));
59193
59275
  }
59194
59276
  function pluginDefs(segments, env, home) {
59195
59277
  const [plugin, ...rest] = segments;
@@ -59577,6 +59659,52 @@ import { existsSync as existsSync11, readFileSync as readFileSync13 } from "fs";
59577
59659
  import { createRequire as createRequire2 } from "module";
59578
59660
  import { join as join17 } from "path";
59579
59661
 
59662
+ // src/search/typo.ts
59663
+ init_esm_shims();
59664
+ function editDistance(a, b, max = 3) {
59665
+ if (Math.abs(a.length - b.length) > max) return max + 1;
59666
+ const prev2 = [];
59667
+ let prev = Array.from({ length: b.length + 1 }, (_, j) => j);
59668
+ let cur = new Array(b.length + 1).fill(0);
59669
+ for (let i = 1; i <= a.length; i++) {
59670
+ cur[0] = i;
59671
+ let rowMin = cur[0];
59672
+ for (let j = 1; j <= b.length; j++) {
59673
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
59674
+ let v = Math.min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + cost);
59675
+ if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
59676
+ v = Math.min(v, prev2[j - 2] + 1);
59677
+ }
59678
+ cur[j] = v;
59679
+ if (v < rowMin) rowMin = v;
59680
+ }
59681
+ if (rowMin > max) return max + 1;
59682
+ prev2.splice(0, prev2.length, ...prev);
59683
+ [prev, cur] = [cur, prev];
59684
+ }
59685
+ return prev[b.length];
59686
+ }
59687
+ function correctTerms(db, terms) {
59688
+ const corrections = [];
59689
+ const out = terms.map((term) => {
59690
+ if (term.length < 4 || /[^a-z0-9]/.test(term) || db.termExists(term)) return term;
59691
+ const max = term.length >= 7 ? 2 : 1;
59692
+ const candidates2 = db.vocabCandidates(term[0], 3e3);
59693
+ let best;
59694
+ for (const c of candidates2) {
59695
+ if (c.term.length < 3) continue;
59696
+ const d = editDistance(term, c.term, max);
59697
+ if (d > max) continue;
59698
+ if (!best || d < best.d || d === best.d && c.df > best.df)
59699
+ best = { term: c.term, d, df: c.df };
59700
+ }
59701
+ if (!best) return term;
59702
+ corrections.push({ from: term, to: best.term });
59703
+ return `${best.term}*`;
59704
+ });
59705
+ return { terms: out, corrections };
59706
+ }
59707
+
59580
59708
  // src/swarm/glob.ts
59581
59709
  init_esm_shims();
59582
59710
  var MAX_EXPANSIONS = 64;
@@ -59756,15 +59884,6 @@ var NAME_MSG = "use 1-32 characters: lowercase letters and digits in words joine
59756
59884
  var noFence = (s) => !s.includes("---");
59757
59885
  var FENCE_MSG = 'must not contain "---" (Claude Code would end the agent frontmatter there)';
59758
59886
  var MODEL_RE = /^(?:inherit|opusplan|(?:sonnet|opus|haiku|fable)(?:\[1m\])?|(?:[a-z0-9-]+\.)*claude-[a-z0-9.:@-]+(?:\[1m\])?)$/;
59759
- var TOP_KEYS = /* @__PURE__ */ new Set([
59760
- "version",
59761
- "enabled",
59762
- "sync",
59763
- "enforce",
59764
- "allowed_agents",
59765
- "defaults",
59766
- "swarms"
59767
- ]);
59768
59887
  var DEFAULT_CONTEXT = {
59769
59888
  memories: 4,
59770
59889
  docs: 2,
@@ -59793,7 +59912,7 @@ var SkillName = external_exports.string().regex(
59793
59912
  ).refine(noFence, FENCE_MSG);
59794
59913
  var Model = external_exports.string().max(100).regex(MODEL_RE, "a model alias (inherit, sonnet, opus, haiku, fable) or a Claude model id").refine(noFence, FENCE_MSG);
59795
59914
  var rank = (t) => TIERS.indexOf(t);
59796
- var RawModelRange = external_exports.strictObject({ floor: external_exports.enum(TIERS).optional(), ceiling: external_exports.enum(TIERS).optional() }).refine(
59915
+ var RawModelRange = external_exports.object({ floor: external_exports.enum(TIERS).optional(), ceiling: external_exports.enum(TIERS).optional() }).refine(
59797
59916
  (r) => !r.floor || !r.ceiling || rank(r.floor) <= rank(r.ceiling),
59798
59917
  `floor must not be above ceiling (${TIERS.join(" < ")})`
59799
59918
  );
@@ -59817,7 +59936,7 @@ var AgentName = external_exports.string().trim().regex(
59817
59936
  (n) => !n.startsWith("swarm-"),
59818
59937
  "swarm workers need no entry: they are allowed during a run of their swarm"
59819
59938
  );
59820
- var RawContext = external_exports.strictObject({
59939
+ var RawContext = external_exports.object({
59821
59940
  memories: external_exports.number().int().min(0).max(10).optional(),
59822
59941
  docs: external_exports.number().int().min(0).max(10).optional(),
59823
59942
  history: external_exports.boolean().optional(),
@@ -59826,12 +59945,12 @@ var RawContext = external_exports.strictObject({
59826
59945
  // SubagentStart context over 10,000 characters is moved to a file Claude may never read.
59827
59946
  max_chars: external_exports.number().int().min(500).max(9e3).optional()
59828
59947
  });
59829
- var RawHookCommand = external_exports.strictObject({
59948
+ var RawHookCommand = external_exports.object({
59830
59949
  type: external_exports.literal("command"),
59831
59950
  command: external_exports.string().trim().min(1).max(2e3).refine(noFence, FENCE_MSG),
59832
59951
  timeout: external_exports.number().int().positive().max(600).optional()
59833
59952
  });
59834
- var RawHookMatcher = external_exports.strictObject({
59953
+ var RawHookMatcher = external_exports.object({
59835
59954
  matcher: external_exports.string().max(200).refine(noFence, FENCE_MSG).refine((m) => {
59836
59955
  try {
59837
59956
  new RegExp(m);
@@ -59842,12 +59961,12 @@ var RawHookMatcher = external_exports.strictObject({
59842
59961
  }, "not a valid regular expression (Claude Code matches tool names with it)").optional(),
59843
59962
  hooks: external_exports.array(RawHookCommand).min(1).max(10)
59844
59963
  });
59845
- var RawHooks = external_exports.strictObject({
59964
+ var RawHooks = external_exports.object({
59846
59965
  PreToolUse: external_exports.array(RawHookMatcher).max(10).optional(),
59847
59966
  PostToolUse: external_exports.array(RawHookMatcher).max(10).optional(),
59848
59967
  Stop: external_exports.array(RawHookMatcher).max(10).optional()
59849
59968
  });
59850
- var RawAgent = external_exports.strictObject({
59969
+ var RawAgent = external_exports.object({
59851
59970
  description: external_exports.string().trim().min(1).max(500).refine(noFence, FENCE_MSG),
59852
59971
  prompt: external_exports.string().max(2e4).optional(),
59853
59972
  model: Model.optional(),
@@ -59865,7 +59984,7 @@ var RawAgent = external_exports.strictObject({
59865
59984
  color: external_exports.enum(AGENT_COLORS).optional(),
59866
59985
  context: RawContext.optional()
59867
59986
  });
59868
- var RawSwarm = external_exports.strictObject({
59987
+ var RawSwarm = external_exports.object({
59869
59988
  description: external_exports.string().trim().min(1).max(500),
59870
59989
  topology: external_exports.enum(TOPOLOGIES).optional(),
59871
59990
  max_agents: external_exports.number().int().min(1).max(16).optional(),
@@ -59881,7 +60000,7 @@ var RawFile = external_exports.looseObject({
59881
60000
  sync: external_exports.enum(["auto", "manual"]).optional(),
59882
60001
  enforce: external_exports.boolean().optional(),
59883
60002
  allowed_agents: external_exports.array(AgentName).max(50).optional(),
59884
- defaults: external_exports.strictObject({
60003
+ defaults: external_exports.object({
59885
60004
  model: Model.optional(),
59886
60005
  model_range: RawModelRange.optional(),
59887
60006
  skills: external_exports.array(SkillName).max(20).optional(),
@@ -59906,6 +60025,53 @@ function mergeContext(...layers) {
59906
60025
  return out;
59907
60026
  }
59908
60027
  var uniq = (xs) => [...new Set(xs)];
60028
+ function unknownKeys(v, s = RawFile, at = []) {
60029
+ if (s instanceof external_exports.ZodOptional) s = s.unwrap();
60030
+ if (Array.isArray(v))
60031
+ return s instanceof external_exports.ZodArray ? v.flatMap((x, i) => unknownKeys(x, s.element, [...at, String(i)])) : [];
60032
+ if (!v || typeof v !== "object") return [];
60033
+ const entries = Object.entries(v);
60034
+ if (s instanceof external_exports.ZodRecord)
60035
+ return entries.flatMap(([k, x]) => unknownKeys(x, s.valueType, [...at, k]));
60036
+ if (!(s instanceof external_exports.ZodObject)) return [];
60037
+ const known = Object.keys(s.shape);
60038
+ return entries.flatMap(
60039
+ ([k, x]) => Object.hasOwn(s.shape, k) ? unknownKeys(x, s.shape[k], [...at, k]) : at.length === 0 && (k.startsWith("x-") || k === "<<") ? [] : [{ at, key: k, known }]
60040
+ );
60041
+ }
60042
+ function schemaKeys(s = RawFile, out = /* @__PURE__ */ new Set()) {
60043
+ if (s instanceof external_exports.ZodOptional) s = s.unwrap();
60044
+ if (s instanceof external_exports.ZodArray) schemaKeys(s.element, out);
60045
+ else if (s instanceof external_exports.ZodRecord) schemaKeys(s.valueType, out);
60046
+ else if (s instanceof external_exports.ZodObject) {
60047
+ for (const [k, v] of Object.entries(s.shape))
60048
+ if (!out.has(k)) {
60049
+ out.add(k);
60050
+ schemaKeys(v, out);
60051
+ }
60052
+ }
60053
+ return out;
60054
+ }
60055
+ var RESTRICTION_KEY = /tool|scope|hook|allow|deny|permission|model|effort|count/i;
60056
+ function restrictionLike(key, known) {
60057
+ let best;
60058
+ for (const k of known) {
60059
+ if (!RESTRICTION_KEY.test(k)) continue;
60060
+ const d = editDistance(key.toLowerCase(), k.toLowerCase(), 2);
60061
+ if (d <= 2 && key.length >= 3 && (!best || d < best.d)) best = { k, d };
60062
+ }
60063
+ if (best) return best.k;
60064
+ return RESTRICTION_KEY.test(key) ? "" : void 0;
60065
+ }
60066
+ function typoOf(key, known) {
60067
+ const max = key.length >= 7 ? 2 : 1;
60068
+ let best;
60069
+ for (const k of known) {
60070
+ const d = editDistance(key.toLowerCase(), k.toLowerCase(), max);
60071
+ if (d <= max && (!best || d < best.d)) best = { k, d };
60072
+ }
60073
+ return best?.k;
60074
+ }
59909
60075
  function roleRange(defaults, a, at, issue2) {
59910
60076
  const spec = a.model_range ?? defaults?.model_range;
59911
60077
  if (!spec || !spec.floor && !spec.ceiling) return void 0;
@@ -60041,6 +60207,27 @@ function parseSwarmYaml(text2, file3, rel) {
60041
60207
  for (const role of Object.keys(agents))
60042
60208
  checkName(["swarms", name, "agents", role], role, "agent");
60043
60209
  }
60210
+ const ignoredKeys = [];
60211
+ const allKeys = schemaKeys();
60212
+ for (const u of unknownKeys(js)) {
60213
+ const near = typoOf(u.key, u.known);
60214
+ const found = { path: u.at.join("."), line: lineOf([...u.at, u.key]) };
60215
+ if (allKeys.has(u.key))
60216
+ issues.push({ ...found, message: `unknown key "${u.key}": not allowed here` });
60217
+ else if (near)
60218
+ issues.push({ ...found, message: `unknown key "${u.key}" (did you mean "${near}"?)` });
60219
+ else if (u.at.length === 4 && u.at[0] === "swarms" && u.at[2] === "agents" && restrictionLike(u.key, u.known) !== void 0) {
60220
+ const like = restrictionLike(u.key, u.known);
60221
+ issues.push({
60222
+ ...found,
60223
+ message: `unknown key "${u.key}" looks like a restriction${like ? ` (did you mean "${like}"?)` : ""}: ignoring it would silently drop a limit`
60224
+ });
60225
+ } else
60226
+ ignoredKeys.push({
60227
+ ...found,
60228
+ message: `unknown key "${u.key}" ignored: not a setting in this eminiar version`
60229
+ });
60230
+ }
60044
60231
  const parsed = RawFile.safeParse(js);
60045
60232
  if (!parsed.success) {
60046
60233
  return {
@@ -60058,15 +60245,9 @@ function parseSwarmYaml(text2, file3, rel) {
60058
60245
  ]
60059
60246
  };
60060
60247
  }
60061
- for (const k of Object.keys(js))
60062
- if (!TOP_KEYS.has(k) && !k.startsWith("x-") && k !== "<<")
60063
- issue2(
60064
- [k],
60065
- `unknown key "${k}" (top-level keys: ${[...TOP_KEYS].join(", ")}; x-* keys may hold YAML anchors)`
60066
- );
60067
60248
  const config2 = resolve9(parsed.data, file3, rel, issue2);
60068
60249
  if (issues.length) return { state: "invalid", file: file3, rel, enforce, issues };
60069
- return { state: "ok", config: config2 };
60250
+ return { state: "ok", config: { ...config2, ignoredKeys } };
60070
60251
  }
60071
60252
  function resolve9(raw, file3, rel, issue2) {
60072
60253
  const swarms = [];
@@ -60796,6 +60977,7 @@ function formatSwarmList(config2, plan, active, opts = {}) {
60796
60977
  const lines = [
60797
60978
  `eminiar swarms \xB7 ${config2.rel} \xB7 sync ${config2.sync}${enforceNote(config2)} \xB7 agent files: ${fileSummary || "none"}`
60798
60979
  ];
60980
+ if (config2.ignoredKeys.length) lines.push(formatIssues(config2.rel, config2.ignoredKeys));
60799
60981
  if (opts.swarm && !swarms.length)
60800
60982
  lines.push(
60801
60983
  `No swarm "${opts.swarm}"; ${config2.rel} defines: ${config2.swarms.map((s) => s.name).join(", ")}`
@@ -60861,6 +61043,11 @@ function formatSync(result, opts = {}) {
60861
61043
  ` ${SYNC_VERB[a.action].mark} ${word(a.action)} ${a.path}${a.reason ? `: ${a.reason}` : ""}`
60862
61044
  );
60863
61045
  }
61046
+ const held = result.actions.filter((a) => a.held).length;
61047
+ if (held)
61048
+ lines.push(
61049
+ `${held} update(s) held: the swarm file has keys this eminiar version does not know, so those agent files were not rewritten (an update that only tightens a file still applies). Update eminiar, or run \`eminiar swarm sync --force\`.`
61050
+ );
60864
61051
  if (!opts.dryRun && result.actions.some((a) => a.action === "create"))
60865
61052
  lines.push(
60866
61053
  "Claude Code reads agent files when a session starts: if a new worker type is not available yet, open /agents or restart the session."
@@ -61308,8 +61495,8 @@ function groupBy(calls, keyFn) {
61308
61495
  if (!isRealCall(c)) continue;
61309
61496
  const k = keyFn(c);
61310
61497
  if (k == null) continue;
61311
- const list2 = buckets.get(k);
61312
- if (list2) list2.push(c);
61498
+ const list3 = buckets.get(k);
61499
+ if (list3) list3.push(c);
61313
61500
  else buckets.set(k, [c]);
61314
61501
  }
61315
61502
  return [...buckets.entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, rows]) => ({ key, totals: totals(rows) }));
@@ -62006,18 +62193,18 @@ function threads(calls) {
62006
62193
  const out = /* @__PURE__ */ new Map();
62007
62194
  for (const c of calls) {
62008
62195
  const key = `${c.session_id}\0${c.sidechain ? c.agent_id ?? "sidechain" : ""}`;
62009
- const list2 = out.get(key);
62010
- if (list2) list2.push(c);
62196
+ const list3 = out.get(key);
62197
+ if (list3) list3.push(c);
62011
62198
  else out.set(key, [c]);
62012
62199
  }
62013
- for (const list2 of out.values()) list2.sort((a, b) => a.ts - b.ts);
62200
+ for (const list3 of out.values()) list3.sort((a, b) => a.ts - b.ts);
62014
62201
  return out;
62015
62202
  }
62016
62203
  function groupBySession(rows) {
62017
62204
  const out = /* @__PURE__ */ new Map();
62018
62205
  for (const r of rows) {
62019
- const list2 = out.get(r.session_id);
62020
- if (list2) list2.push(r);
62206
+ const list3 = out.get(r.session_id);
62207
+ if (list3) list3.push(r);
62021
62208
  else out.set(r.session_id, [r]);
62022
62209
  }
62023
62210
  return out;
@@ -62049,9 +62236,9 @@ function withScope(base, sessionIds) {
62049
62236
  }
62050
62237
  var SEVERITY_RANK = { high: 0, warn: 1, info: 2 };
62051
62238
  function hasCompactionBetween(ctx, sessionId, from, to) {
62052
- const list2 = ctx.compactionsBySession.get(sessionId);
62053
- if (!list2) return false;
62054
- return list2.some((t) => t > from && t <= to);
62239
+ const list3 = ctx.compactionsBySession.get(sessionId);
62240
+ if (!list3) return false;
62241
+ return list3.some((t) => t > from && t <= to);
62055
62242
  }
62056
62243
  function detectCacheThrash(ctx) {
62057
62244
  let runs = 0;
@@ -62059,7 +62246,7 @@ function detectCacheThrash(ctx) {
62059
62246
  let rewritten = 0;
62060
62247
  let savings = 0;
62061
62248
  const sessions = /* @__PURE__ */ new Set();
62062
- for (const list2 of ctx.threads.values()) {
62249
+ for (const list3 of ctx.threads.values()) {
62063
62250
  let run = [];
62064
62251
  const flush = () => {
62065
62252
  if (run.length >= THRASH_RUN) {
@@ -62075,12 +62262,12 @@ function detectCacheThrash(ctx) {
62075
62262
  }
62076
62263
  run = [];
62077
62264
  };
62078
- for (let i = 1; i < list2.length; i++) {
62079
- const c = list2[i];
62080
- const prev = list2[i - 1];
62265
+ for (let i = 1; i < list3.length; i++) {
62266
+ const c = list3[i];
62267
+ const prev = list3[i - 1];
62081
62268
  const ctxTokens = contextOf(c);
62082
62269
  const heavy = ctxTokens > 0 && writesOf(c) / ctxTokens >= THRASH_WRITE_SHARE;
62083
- const broken = hasCompactionBetween(ctx, c.session_id, prev.ts, c.ts) || c.ts - prev.ts > ttlFor(list2);
62270
+ const broken = hasCompactionBetween(ctx, c.session_id, prev.ts, c.ts) || c.ts - prev.ts > ttlFor(list3);
62084
62271
  if (!heavy || broken) {
62085
62272
  flush();
62086
62273
  continue;
@@ -62103,10 +62290,10 @@ function detectCacheThrash(ctx) {
62103
62290
  sessions
62104
62291
  );
62105
62292
  }
62106
- function ttlFor(list2) {
62293
+ function ttlFor(list3) {
62107
62294
  let w5 = 0;
62108
62295
  let w1 = 0;
62109
- for (const c of list2) {
62296
+ for (const c of list3) {
62110
62297
  w5 += num4(c.cache_create_5m);
62111
62298
  w1 += num4(c.cache_create_1h);
62112
62299
  }
@@ -62118,11 +62305,11 @@ function detectCacheCold(ctx) {
62118
62305
  let savings = 0;
62119
62306
  let longestGap = 0;
62120
62307
  const sessions = /* @__PURE__ */ new Set();
62121
- for (const list2 of ctx.threads.values()) {
62122
- const ttl = ttlFor(list2);
62123
- for (let i = 1; i < list2.length; i++) {
62124
- const c = list2[i];
62125
- const prev = list2[i - 1];
62308
+ for (const list3 of ctx.threads.values()) {
62309
+ const ttl = ttlFor(list3);
62310
+ for (let i = 1; i < list3.length; i++) {
62311
+ const c = list3[i];
62312
+ const prev = list3[i - 1];
62126
62313
  const gap = c.ts - prev.ts;
62127
62314
  if (gap <= ttl) continue;
62128
62315
  if (hasCompactionBetween(ctx, c.session_id, prev.ts, c.ts)) continue;
@@ -62398,15 +62585,15 @@ function detectErrorLoop(ctx) {
62398
62585
  const byThread = /* @__PURE__ */ new Map();
62399
62586
  for (const u of ctx.toolUses) {
62400
62587
  const key = `${u.session_id}\0${u.agent_id ?? ""}`;
62401
- const list2 = byThread.get(key);
62402
- if (list2) list2.push(u);
62588
+ const list3 = byThread.get(key);
62589
+ if (list3) list3.push(u);
62403
62590
  else byThread.set(key, [u]);
62404
62591
  }
62405
- for (const list2 of byThread.values()) {
62406
- list2.sort((a, b) => a.ts - b.ts);
62592
+ for (const list3 of byThread.values()) {
62593
+ list3.sort((a, b) => a.ts - b.ts);
62407
62594
  let run = 0;
62408
62595
  let tool = "";
62409
- for (const u of list2) {
62596
+ for (const u of list3) {
62410
62597
  if (u.is_error && u.tool === tool) run += 1;
62411
62598
  else {
62412
62599
  run = u.is_error ? 1 : 0;
@@ -62644,11 +62831,11 @@ function detectInsights(input2) {
62644
62831
  const calls = input2.calls.filter(isRealCall);
62645
62832
  const compactionsBySession = /* @__PURE__ */ new Map();
62646
62833
  for (const e of input2.contextEvents) {
62647
- const list2 = compactionsBySession.get(e.session_id);
62648
- if (list2) list2.push(e.ts);
62834
+ const list3 = compactionsBySession.get(e.session_id);
62835
+ if (list3) list3.push(e.ts);
62649
62836
  else compactionsBySession.set(e.session_id, [e.ts]);
62650
62837
  }
62651
- for (const list2 of compactionsBySession.values()) list2.sort((a, b) => a - b);
62838
+ for (const list3 of compactionsBySession.values()) list3.sort((a, b) => a - b);
62652
62839
  const callTs = /* @__PURE__ */ new Map();
62653
62840
  for (const [sid, rows] of groupBySession(calls))
62654
62841
  callTs.set(
@@ -62835,8 +63022,8 @@ function periods(calls, keyFn) {
62835
63022
  const buckets = /* @__PURE__ */ new Map();
62836
63023
  for (const c of calls) {
62837
63024
  const k = keyFn(c.ts);
62838
- const list2 = buckets.get(k);
62839
- if (list2) list2.push(c);
63025
+ const list3 = buckets.get(k);
63026
+ if (list3) list3.push(c);
62840
63027
  else buckets.set(k, [c]);
62841
63028
  }
62842
63029
  return [...buckets.entries()].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([key, rows]) => ({ key, totals: totals(rows), models: modelSlices(rows) }));
@@ -62867,8 +63054,8 @@ function insightsFor(ctx, data) {
62867
63054
  return { insights: r.insights, scores: r.scores };
62868
63055
  }
62869
63056
  var SEVERITY_RANK2 = { high: 0, warn: 1, info: 2 };
62870
- function sortInsights(list2) {
62871
- return list2.slice().sort(
63057
+ function sortInsights(list3) {
63058
+ return list3.slice().sort(
62872
63059
  (a, b) => SEVERITY_RANK2[a.severity] - SEVERITY_RANK2[b.severity] || (b.estimatedSavingsUsd ?? 0) - (a.estimatedSavingsUsd ?? 0)
62873
63060
  );
62874
63061
  }
@@ -63603,10 +63790,10 @@ function impact(db, ref, opts = {}) {
63603
63790
  add3(e.dst, e.weight, 1, `co-changed ${meta4.count ?? "?"}\xD7 (${Math.round(e.weight * 100)}%)`);
63604
63791
  }
63605
63792
  }
63606
- const list2 = [...hits.values()].sort((a, b) => b.score - a.score);
63607
- const nodes = new Map(db.graphGetNodes(list2.map((h) => h.id)).map((n) => [n.id, n]));
63608
- for (const h of list2) h.node = nodes.get(h.id);
63609
- return { root, hits: list2 };
63793
+ const list3 = [...hits.values()].sort((a, b) => b.score - a.score);
63794
+ const nodes = new Map(db.graphGetNodes(list3.map((h) => h.id)).map((n) => [n.id, n]));
63795
+ for (const h of list3) h.node = nodes.get(h.id);
63796
+ return { root, hits: list3 };
63610
63797
  }
63611
63798
  function dependencies(db, ref, depth = 1) {
63612
63799
  const root = resolveNode(db, ref);
@@ -63633,10 +63820,10 @@ function dependencies(db, ref, depth = 1) {
63633
63820
  frontier = next;
63634
63821
  if (!frontier.length) break;
63635
63822
  }
63636
- const list2 = [...hits.values()].sort((a, b) => b.score - a.score);
63637
- const nodes = new Map(db.graphGetNodes(list2.map((h) => h.id)).map((n) => [n.id, n]));
63638
- for (const h of list2) h.node = nodes.get(h.id);
63639
- return { root, hits: list2 };
63823
+ const list3 = [...hits.values()].sort((a, b) => b.score - a.score);
63824
+ const nodes = new Map(db.graphGetNodes(list3.map((h) => h.id)).map((n) => [n.id, n]));
63825
+ for (const h of list3) h.node = nodes.get(h.id);
63826
+ return { root, hits: list3 };
63640
63827
  }
63641
63828
  function neighbors(db, ref, depth = 1, kinds) {
63642
63829
  const root = resolveNode(db, ref);
@@ -64447,10 +64634,10 @@ function loadPermissionRules(root, extraDeny = []) {
64447
64634
  const hit = cache5.get(key);
64448
64635
  if (hit?.stamps.every((s, i) => s === stamps[i])) return hit.rules;
64449
64636
  const out = { allow: [], deny: [], ask: [], root };
64450
- const push = (list2, raws) => {
64637
+ const push = (list3, raws) => {
64451
64638
  for (const raw of raws ?? []) {
64452
64639
  const r = parseRule(raw);
64453
- if (r) list2.push(r);
64640
+ if (r) list3.push(r);
64454
64641
  }
64455
64642
  };
64456
64643
  for (const f of files) {
@@ -65541,19 +65728,19 @@ function mergedCatalog(extra) {
65541
65728
  function catalogLookup(kind, key, catalog = CATALOG) {
65542
65729
  const k = key.trim();
65543
65730
  for (const e of catalog) {
65544
- const list2 = kind === "api" ? e.hosts : e[kind];
65545
- if (!list2) continue;
65731
+ const list3 = kind === "api" ? e.hosts : e[kind];
65732
+ if (!list3) continue;
65546
65733
  if (kind === "env") {
65547
- if (list2.some((p2) => envMatches(p2, k))) return e;
65734
+ if (list3.some((p2) => envMatches(p2, k))) return e;
65548
65735
  } else if (kind === "api") {
65549
65736
  const host = k.toLowerCase();
65550
- if (list2.some((h) => host === h || host.endsWith(`.${h}`))) return e;
65737
+ if (list3.some((h) => host === h || host.endsWith(`.${h}`))) return e;
65551
65738
  } else if (kind === "image") {
65552
65739
  const bare = k.split(":")[0].replace(/^docker\.io\/(library\/)?/, "");
65553
- if (list2.some((p2) => matches(p2, bare))) return e;
65740
+ if (list3.some((p2) => matches(p2, bare))) return e;
65554
65741
  } else if (kind === "go") {
65555
- if (list2.some((p2) => k === p2 || k.startsWith(p2))) return e;
65556
- } else if (list2.some((p2) => matches(p2, k))) return e;
65742
+ if (list3.some((p2) => k === p2 || k.startsWith(p2))) return e;
65743
+ } else if (list3.some((p2) => matches(p2, k))) return e;
65557
65744
  }
65558
65745
  return void 0;
65559
65746
  }
@@ -65935,9 +66122,9 @@ function schemaSummary(doc, schema2, depth = 0) {
65935
66122
  if (Array.isArray(s.enum))
65936
66123
  return `enum(${s.enum.slice(0, 8).map(String).join(", ")}${s.enum.length > 8 ? ", \u2026" : ""})`;
65937
66124
  for (const k of ["oneOf", "anyOf", "allOf"]) {
65938
- const list2 = s[k];
65939
- if (Array.isArray(list2))
65940
- return `${k}<${list2.slice(0, 4).map((x) => schemaSummary(doc, x, depth + 1)).join(" | ")}>`;
66125
+ const list3 = s[k];
66126
+ if (Array.isArray(list3))
66127
+ return `${k}<${list3.slice(0, 4).map((x) => schemaSummary(doc, x, depth + 1)).join(" | ")}>`;
65941
66128
  }
65942
66129
  if (type === "array" || s.items) return `${schemaSummary(doc, s.items, depth + 1) || "any"}[]`;
65943
66130
  if (type === "object" || isObj2(s.properties)) {
@@ -66100,9 +66287,9 @@ function postmanBody(body) {
66100
66287
  const lang = isObj2(body.options) && isObj2(body.options.raw) ? String(body.options.raw.language ?? "json") : "json";
66101
66288
  return raw.length > 2e3 ? [`Body (${lang}): ${raw.slice(0, 2e3)}\u2026`] : ["Body:", "", `\`\`\`${lang}`, raw, "```"];
66102
66289
  }
66103
- const list2 = body[mode];
66104
- if (Array.isArray(list2)) {
66105
- const keys = list2.filter(isObj2).map(
66290
+ const list3 = body[mode];
66291
+ if (Array.isArray(list3)) {
66292
+ const keys = list3.filter(isObj2).map(
66106
66293
  (e) => `${String(e.key)}${e.type && e.type !== "text" ? ` (${String(e.type)})` : ""}${e.description ? ` \u2014 ${clip4(e.description, 100)}` : ""}`
66107
66294
  );
66108
66295
  return keys.length ? [`Body (${mode}): ${keys.join(", ")}`] : [];
@@ -67467,52 +67654,6 @@ function snippet(body, terms, opts = {}) {
67467
67654
  }).join("\n\u22EF\n");
67468
67655
  }
67469
67656
 
67470
- // src/search/typo.ts
67471
- init_esm_shims();
67472
- function editDistance(a, b, max = 3) {
67473
- if (Math.abs(a.length - b.length) > max) return max + 1;
67474
- const prev2 = [];
67475
- let prev = Array.from({ length: b.length + 1 }, (_, j) => j);
67476
- let cur = new Array(b.length + 1).fill(0);
67477
- for (let i = 1; i <= a.length; i++) {
67478
- cur[0] = i;
67479
- let rowMin = cur[0];
67480
- for (let j = 1; j <= b.length; j++) {
67481
- const cost = a[i - 1] === b[j - 1] ? 0 : 1;
67482
- let v = Math.min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + cost);
67483
- if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
67484
- v = Math.min(v, prev2[j - 2] + 1);
67485
- }
67486
- cur[j] = v;
67487
- if (v < rowMin) rowMin = v;
67488
- }
67489
- if (rowMin > max) return max + 1;
67490
- prev2.splice(0, prev2.length, ...prev);
67491
- [prev, cur] = [cur, prev];
67492
- }
67493
- return prev[b.length];
67494
- }
67495
- function correctTerms(db, terms) {
67496
- const corrections = [];
67497
- const out = terms.map((term) => {
67498
- if (term.length < 4 || /[^a-z0-9]/.test(term) || db.termExists(term)) return term;
67499
- const max = term.length >= 7 ? 2 : 1;
67500
- const candidates2 = db.vocabCandidates(term[0], 3e3);
67501
- let best;
67502
- for (const c of candidates2) {
67503
- if (c.term.length < 3) continue;
67504
- const d = editDistance(term, c.term, max);
67505
- if (d > max) continue;
67506
- if (!best || d < best.d || d === best.d && c.df > best.df)
67507
- best = { term: c.term, d, df: c.df };
67508
- }
67509
- if (!best) return term;
67510
- corrections.push({ from: term, to: best.term });
67511
- return `${best.term}*`;
67512
- });
67513
- return { terms: out, corrections };
67514
- }
67515
-
67516
67657
  // src/search/pipeline.ts
67517
67658
  var WEIGHTS = { porter: 1, trigram: 0.7, vector: 1 };
67518
67659
  function lexical(db, terms, phrases, filters, n) {
@@ -68107,9 +68248,9 @@ function envSignals(dir, project, catalog) {
68107
68248
  }
68108
68249
  const token = name.split("_")[0];
68109
68250
  if (token.length < 3 || GENERIC_ENV.has(token)) continue;
68110
- const list2 = unknownPrefixes.get(token) ?? [];
68111
- if (!list2.includes(name)) list2.push(name);
68112
- unknownPrefixes.set(token, list2);
68251
+ const list3 = unknownPrefixes.get(token) ?? [];
68252
+ if (!list3.includes(name)) list3.push(name);
68253
+ unknownPrefixes.set(token, list3);
68113
68254
  }
68114
68255
  }
68115
68256
  return { signals, unknownPrefixes };
@@ -68561,15 +68702,15 @@ function discoverDocs(ctx, opts = {}) {
68561
68702
  );
68562
68703
  for (const hit of api.hits.values()) {
68563
68704
  if (inSubproject(hit.samples)) continue;
68564
- const list2 = apiHits.get(hit.host) ?? [];
68565
- list2.push(hit);
68566
- apiHits.set(hit.host, list2);
68705
+ const list3 = apiHits.get(hit.host) ?? [];
68706
+ list3.push(hit);
68707
+ apiHits.set(hit.host, list3);
68567
68708
  }
68568
68709
  for (const link of api.docLinks.values()) {
68569
68710
  if (inSubproject(link.samples)) continue;
68570
- const list2 = docLinks.get(link.host) ?? [];
68571
- list2.push(link);
68572
- docLinks.set(link.host, list2);
68711
+ const list3 = docLinks.get(link.host) ?? [];
68712
+ list3.push(link);
68713
+ docLinks.set(link.host, list3);
68573
68714
  }
68574
68715
  const env = envSignals(dir, project, catalog);
68575
68716
  signals.push(...env.signals);
@@ -68659,12 +68800,12 @@ function discoverDocs(ctx, opts = {}) {
68659
68800
  evidence: `${info.vars.slice(0, 4).join(", ")}${info.vars.length > 4 ? ", \u2026" : ""}`
68660
68801
  });
68661
68802
  }
68662
- for (const [host, list2] of apiHits) {
68663
- const calls = list2.reduce((n, h) => n + h.calls, 0);
68803
+ for (const [host, list3] of apiHits) {
68804
+ const calls = list3.reduce((n, h) => n + h.calls, 0);
68664
68805
  if (!calls) continue;
68665
68806
  const entry = catalogLookup("api", host, catalog);
68666
- const specUrls = [...new Set(list2.flatMap((h) => h.specUrls))];
68667
- for (const h of list2) {
68807
+ const specUrls = [...new Set(list3.flatMap((h) => h.specUrls))];
68808
+ for (const h of list3) {
68668
68809
  if (!h.calls) continue;
68669
68810
  const evidence = `api:${host} (${h.samples.slice(0, 2).join(", ")})${specUrls.length ? ` \xB7 spec ${specUrls[0]}` : ""}`;
68670
68811
  if (entry) {
@@ -68697,10 +68838,10 @@ function discoverDocs(ctx, opts = {}) {
68697
68838
  }
68698
68839
  }
68699
68840
  }
68700
- for (const [host, list2] of docLinks) {
68701
- const urls = [...new Set(list2.flatMap((l) => l.urls))].slice(0, 3);
68841
+ for (const [host, list3] of docLinks) {
68842
+ const urls = [...new Set(list3.flatMap((l) => l.urls))].slice(0, 3);
68702
68843
  const entry = catalogLookup("api", host, catalog);
68703
- for (const l of list2) {
68844
+ for (const l of list3) {
68704
68845
  const evidence = `link:${host} (${l.samples.slice(0, 2).join(", ")})`;
68705
68846
  if (entry) {
68706
68847
  add3({
@@ -68875,7 +69016,7 @@ function rootOf(host) {
68875
69016
  function docGuesses(host) {
68876
69017
  const h = host.toLowerCase();
68877
69018
  const root = rootOf(h);
68878
- const list2 = [
69019
+ const list3 = [
68879
69020
  `https://docs.${root}/`,
68880
69021
  `https://developer.${root}/`,
68881
69022
  `https://developers.${root}/`,
@@ -68893,7 +69034,7 @@ function docGuesses(host) {
68893
69034
  `https://${h}/openapi.json`,
68894
69035
  `https://${h}/swagger.json`
68895
69036
  ];
68896
- return [...new Set(list2)];
69037
+ return [...new Set(list3)];
68897
69038
  }
68898
69039
  async function probe2(url2, opts) {
68899
69040
  const f = opts.fetchImpl ?? fetch;
@@ -69288,16 +69429,16 @@ function formatDiscovery(d, max = 40) {
69288
69429
  ]
69289
69430
  ];
69290
69431
  for (const [conf, title, note, wants] of groups) {
69291
- const list2 = d.providers.filter(wants);
69292
- if (!list2.length) continue;
69293
- lines.push("", `${title} (${list2.length}; ${note}):`);
69294
- for (const p2 of list2.slice(0, max)) {
69432
+ const list3 = d.providers.filter(wants);
69433
+ if (!list3.length) continue;
69434
+ lines.push("", `${title} (${list3.length}; ${note}):`);
69435
+ for (const p2 of list3.slice(0, max)) {
69295
69436
  const used = p2.usedBy.length > 1 ? ` \xB7 used by ${p2.usedBy.length} projects` : p2.usedBy[0] && p2.usedBy[0] !== "." ? ` \xB7 ${p2.usedBy[0]}` : "";
69296
69437
  const where = p2.urls[0] ? ` \xB7 ${p2.urls[0]}` : "";
69297
69438
  const ev3 = conf === "probe" || conf === "unknown" ? ` \xB7 ${p2.evidence[0]}` : "";
69298
69439
  lines.push(`- ${p2.name} \u2190 ${p2.provider}${used}${where}${ev3}${reg(p2.registered)}`);
69299
69440
  }
69300
- if (list2.length > max) lines.push(` \u2026 ${list2.length - max} more`);
69441
+ if (list3.length > max) lines.push(` \u2026 ${list3.length - max} more`);
69301
69442
  }
69302
69443
  const rec = d.local.filter((c) => !c.registered).length + d.providers.filter(
69303
69444
  (p2) => !p2.registered && (p2.confidence === "probe" || p2.confidence === "catalog" && (p2.tier ?? "library") === "service")
@@ -70303,21 +70444,21 @@ function detectChanges(db, root, opts = {}) {
70303
70444
  }
70304
70445
  const byFile = /* @__PURE__ */ new Map();
70305
70446
  for (const h of hunks) {
70306
- const list2 = byFile.get(h.path) ?? [];
70307
- list2.push(h);
70308
- byFile.set(h.path, list2);
70447
+ const list3 = byFile.get(h.path) ?? [];
70448
+ list3.push(h);
70449
+ byFile.set(h.path, list3);
70309
70450
  }
70310
70451
  const symbols = /* @__PURE__ */ new Map();
70311
70452
  const files = [];
70312
70453
  const unindexed = [];
70313
- for (const [path3, list2] of byFile) {
70454
+ for (const [path3, list3] of byFile) {
70314
70455
  const indexed = !!db.graphGetNode(fileId(path3));
70315
- files.push({ path: path3, hunks: list2.length, indexed });
70456
+ files.push({ path: path3, hunks: list3.length, indexed });
70316
70457
  if (!indexed) {
70317
70458
  unindexed.push(path3);
70318
70459
  continue;
70319
70460
  }
70320
- for (const [id, s] of symbolsAt(db, path3, list2)) symbols.set(id, s);
70461
+ for (const [id, s] of symbolsAt(db, path3, list3)) symbols.set(id, s);
70321
70462
  }
70322
70463
  const ids = [...symbols.keys()];
70323
70464
  const metrics = new Map(db.metricsGet(ids).map((m) => [m.node_id, m]));
@@ -72444,7 +72585,9 @@ var schema = {
72444
72585
  remember: external_exports.boolean().optional().describe("finish: keep the outcome as an eminiar memory"),
72445
72586
  agent: external_exports.string().optional().describe("release: worker agent id (a prefix is enough)"),
72446
72587
  role: external_exports.string().optional().describe("release: every running worker of this role"),
72447
- force: external_exports.boolean().optional().describe("sync: also overwrite generated agent files that were edited by hand"),
72588
+ force: external_exports.boolean().optional().describe(
72589
+ "sync: also overwrite generated agent files that were edited by hand, and write them while the swarm file has keys this eminiar does not know"
72590
+ ),
72448
72591
  caller_kind: external_exports.string().optional().describe(HOOK_FIELD),
72449
72592
  caller_agent_id: external_exports.string().optional().describe(HOOK_FIELD),
72450
72593
  caller_agent_type: external_exports.string().optional().describe(HOOK_FIELD),
@@ -72633,9 +72776,9 @@ async function dispatch(args, callerCtx) {
72633
72776
  case "list": {
72634
72777
  const plan = planAgentSync(ctx.root, config2);
72635
72778
  const active = listItems(db, db.swarm.runs({ status: "active", limit: 10 }));
72636
- const list2 = formatSwarmList(config2, plan, active, { swarm: args.swarm, sessionId });
72779
+ const list3 = formatSwarmList(config2, plan, active, { swarm: args.swarm, sessionId });
72637
72780
  return who.unverified !== void 0 ? `${unstampedNote(who.unverified)}
72638
- ${list2}` : list2;
72781
+ ${list3}` : list3;
72639
72782
  }
72640
72783
  case "start": {
72641
72784
  if (!args.swarm)
@@ -72692,7 +72835,7 @@ ${list2}` : list2;
72692
72835
  if (ctx.config.adjudicator?.enabled && ctx.config.adjudicator.surfaces.plan) {
72693
72836
  const unavailable = "Adjudicator advice unavailable for this plan (the tasks are planned).";
72694
72837
  try {
72695
- const list2 = await adjudicatePlan(ctx, db, run, swarm, rows, {
72838
+ const list3 = await adjudicatePlan(ctx, db, run, swarm, rows, {
72696
72839
  sessionId,
72697
72840
  log: (line) => process.stderr.write(`eminiar: ${line}
72698
72841
  `),
@@ -72700,8 +72843,8 @@ ${list2}` : list2;
72700
72843
  adviceNote = unavailable;
72701
72844
  }
72702
72845
  });
72703
- advice = planAdviceBlock(list2);
72704
- adviceHint = planNextHint(list2);
72846
+ advice = planAdviceBlock(list3);
72847
+ adviceHint = planNextHint(list3);
72705
72848
  } catch (err) {
72706
72849
  process.stderr.write(
72707
72850
  `eminiar: adjudicator plan advice skipped: ${err?.message ?? String(err)}