@neat.is/core 0.10.6 → 0.10.7-dev.20261011

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.
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/incidents-render.ts
21
+ var incidents_render_exports = {};
22
+ __export(incidents_render_exports, {
23
+ deployHintLines: () => deployHintLines
24
+ });
25
+ module.exports = __toCommonJS(incidents_render_exports);
26
+ function deployHintLines(ev) {
27
+ const a = ev.attributes;
28
+ if (!a) return [];
29
+ const s = (k) => typeof a[k] === "string" ? a[k] : void 0;
30
+ const n = (k) => typeof a[k] === "number" ? a[k] : void 0;
31
+ const arr = (k) => Array.isArray(a[k]) ? a[k].filter((x) => typeof x === "string") : [];
32
+ const fault = s("k8s.fault");
33
+ const env = arr("k8s.containerEnv");
34
+ const args = arr("k8s.containerArgs");
35
+ const log = s("k8s.processLog");
36
+ if (!fault && env.length === 0 && args.length === 0 && !log) return [];
37
+ const out = [];
38
+ if (fault) {
39
+ const bits = [fault];
40
+ const wr = s("k8s.waitingReason");
41
+ if (wr) bits.push(wr);
42
+ const rc = n("k8s.restartCount");
43
+ if (rc !== void 0) bits.push(`restarts=${rc}`);
44
+ const ec = n("k8s.exitCode");
45
+ if (ec !== void 0) bits.push(`exit=${ec}`);
46
+ const tr = s("k8s.terminatedReason");
47
+ if (tr) bits.push(tr);
48
+ out.push(`deploy: ${bits.join(" ")}`);
49
+ }
50
+ const cap = (xs, max) => {
51
+ const joined = xs.join(" ");
52
+ return joined.length > max ? `${joined.slice(0, max)}\u2026(+${xs.length} entries)` : joined;
53
+ };
54
+ if (env.length > 0) out.push(`env: ${cap(env, 700)}`);
55
+ if (args.length > 0) out.push(`args: ${cap(args, 300)}`);
56
+ if (log) {
57
+ const tail = log.split("\n").filter((l) => l.trim().length > 0).slice(-4);
58
+ if (tail.length > 0) out.push(`log: ${tail.join(" \u23CE ")}`);
59
+ }
60
+ return out;
61
+ }
62
+ // Annotate the CommonJS export names for ESM import in node:
63
+ 0 && (module.exports = {
64
+ deployHintLines
65
+ });
66
+ //# sourceMappingURL=incidents-render.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/incidents-render.ts"],"sourcesContent":["import type { ErrorEvent } from '@neat.is/types'\n\n// The OBSERVED deploy/process/config context an incident may carry (ADR-237/240):\n// the deploy fault, the faulted container's redacted env/args, and its boot-time\n// stdout tail. Rendered compactly so the incident surfaces the wrong host / bad\n// flag / crash traceback inline instead of leaving it to the card.\n//\n// One renderer, two readers: the CLI `neat incidents` output (cli-client.ts) and\n// the MCP get_incident_history tool (packages/mcp) both call this, so the two\n// never drift (core #1373 — atomic, no feature mirrors another's fields).\n// Returns [] for a non-k8s incident, so those lines read exactly as before.\nexport function deployHintLines(ev: ErrorEvent): string[] {\n const a = ev.attributes\n if (!a) return []\n const s = (k: string): string | undefined => (typeof a[k] === 'string' ? (a[k] as string) : undefined)\n const n = (k: string): number | undefined => (typeof a[k] === 'number' ? (a[k] as number) : undefined)\n const arr = (k: string): string[] => (Array.isArray(a[k]) ? (a[k] as unknown[]).filter((x) => typeof x === 'string') as string[] : [])\n const fault = s('k8s.fault')\n const env = arr('k8s.containerEnv')\n const args = arr('k8s.containerArgs')\n const log = s('k8s.processLog')\n if (!fault && env.length === 0 && args.length === 0 && !log) return []\n const out: string[] = []\n if (fault) {\n const bits = [fault]\n const wr = s('k8s.waitingReason'); if (wr) bits.push(wr)\n const rc = n('k8s.restartCount'); if (rc !== undefined) bits.push(`restarts=${rc}`)\n const ec = n('k8s.exitCode'); if (ec !== undefined) bits.push(`exit=${ec}`)\n const tr = s('k8s.terminatedReason'); if (tr) bits.push(tr)\n out.push(`deploy: ${bits.join(' ')}`)\n }\n const cap = (xs: string[], max: number): string => {\n const joined = xs.join(' ')\n return joined.length > max ? `${joined.slice(0, max)}…(+${xs.length} entries)` : joined\n }\n if (env.length > 0) out.push(`env: ${cap(env, 700)}`)\n if (args.length > 0) out.push(`args: ${cap(args, 300)}`)\n if (log) {\n const tail = log.split('\\n').filter((l) => l.trim().length > 0).slice(-4)\n if (tail.length > 0) out.push(`log: ${tail.join(' ⏎ ')}`)\n }\n return out\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,SAAS,gBAAgB,IAA0B;AACxD,QAAM,IAAI,GAAG;AACb,MAAI,CAAC,EAAG,QAAO,CAAC;AAChB,QAAM,IAAI,CAAC,MAAmC,OAAO,EAAE,CAAC,MAAM,WAAY,EAAE,CAAC,IAAe;AAC5F,QAAM,IAAI,CAAC,MAAmC,OAAO,EAAE,CAAC,MAAM,WAAY,EAAE,CAAC,IAAe;AAC5F,QAAM,MAAM,CAAC,MAAyB,MAAM,QAAQ,EAAE,CAAC,CAAC,IAAK,EAAE,CAAC,EAAgB,OAAO,CAAC,MAAM,OAAO,MAAM,QAAQ,IAAgB,CAAC;AACpI,QAAM,QAAQ,EAAE,WAAW;AAC3B,QAAM,MAAM,IAAI,kBAAkB;AAClC,QAAM,OAAO,IAAI,mBAAmB;AACpC,QAAM,MAAM,EAAE,gBAAgB;AAC9B,MAAI,CAAC,SAAS,IAAI,WAAW,KAAK,KAAK,WAAW,KAAK,CAAC,IAAK,QAAO,CAAC;AACrE,QAAM,MAAgB,CAAC;AACvB,MAAI,OAAO;AACT,UAAM,OAAO,CAAC,KAAK;AACnB,UAAM,KAAK,EAAE,mBAAmB;AAAG,QAAI,GAAI,MAAK,KAAK,EAAE;AACvD,UAAM,KAAK,EAAE,kBAAkB;AAAG,QAAI,OAAO,OAAW,MAAK,KAAK,YAAY,EAAE,EAAE;AAClF,UAAM,KAAK,EAAE,cAAc;AAAG,QAAI,OAAO,OAAW,MAAK,KAAK,QAAQ,EAAE,EAAE;AAC1E,UAAM,KAAK,EAAE,sBAAsB;AAAG,QAAI,GAAI,MAAK,KAAK,EAAE;AAC1D,QAAI,KAAK,WAAW,KAAK,KAAK,GAAG,CAAC,EAAE;AAAA,EACtC;AACA,QAAM,MAAM,CAAC,IAAc,QAAwB;AACjD,UAAM,SAAS,GAAG,KAAK,IAAI;AAC3B,WAAO,OAAO,SAAS,MAAM,GAAG,OAAO,MAAM,GAAG,GAAG,CAAC,WAAM,GAAG,MAAM,cAAc;AAAA,EACnF;AACA,MAAI,IAAI,SAAS,EAAG,KAAI,KAAK,QAAQ,IAAI,KAAK,GAAG,CAAC,EAAE;AACpD,MAAI,KAAK,SAAS,EAAG,KAAI,KAAK,SAAS,IAAI,MAAM,GAAG,CAAC,EAAE;AACvD,MAAI,KAAK;AACP,UAAM,OAAO,IAAI,MAAM,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE;AACxE,QAAI,KAAK,SAAS,EAAG,KAAI,KAAK,QAAQ,KAAK,KAAK,UAAK,CAAC,EAAE;AAAA,EAC1D;AACA,SAAO;AACT;","names":[]}
@@ -0,0 +1,5 @@
1
+ import { ErrorEvent } from '@neat.is/types';
2
+
3
+ declare function deployHintLines(ev: ErrorEvent): string[];
4
+
5
+ export { deployHintLines };
@@ -0,0 +1,5 @@
1
+ import { ErrorEvent } from '@neat.is/types';
2
+
3
+ declare function deployHintLines(ev: ErrorEvent): string[];
4
+
5
+ export { deployHintLines };
@@ -0,0 +1,8 @@
1
+ import {
2
+ deployHintLines
3
+ } from "./chunk-AEMLUMHC.js";
4
+ import "./chunk-MR64ICXX.js";
5
+ export {
6
+ deployHintLines
7
+ };
8
+ //# sourceMappingURL=incidents-render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.cjs CHANGED
@@ -18137,6 +18137,36 @@ var import_types62 = require("@neat.is/types");
18137
18137
  var CODE_FILEPATH_ATTR2 = "code.filepath";
18138
18138
  var CODE_LINENO_ATTR2 = "code.lineno";
18139
18139
  var BLAST_NEAREST_LIMIT = 5;
18140
+ function deployContextOf(ev) {
18141
+ const a = ev.attributes;
18142
+ if (!a) return void 0;
18143
+ const str = (k) => typeof a[k] === "string" ? a[k] : void 0;
18144
+ const int = (k) => typeof a[k] === "number" && Number.isFinite(a[k]) ? Math.trunc(a[k]) : void 0;
18145
+ const strs = (k) => {
18146
+ const v = a[k];
18147
+ return Array.isArray(v) && v.every((x) => typeof x === "string") && v.length > 0 ? v : void 0;
18148
+ };
18149
+ const ctx = {};
18150
+ const fault = str("k8s.fault");
18151
+ if (fault) ctx.fault = fault;
18152
+ const waiting = str("k8s.waitingReason");
18153
+ if (waiting) ctx.waitingReason = waiting;
18154
+ const image = str("k8s.image");
18155
+ if (image) ctx.image = image;
18156
+ const restarts = int("k8s.restartCount");
18157
+ if (restarts !== void 0) ctx.restartCount = restarts;
18158
+ const termReason = str("k8s.terminatedReason");
18159
+ if (termReason) ctx.terminatedReason = termReason;
18160
+ const exitCode = int("k8s.exitCode");
18161
+ if (exitCode !== void 0) ctx.exitCode = exitCode;
18162
+ const env = strs("k8s.containerEnv");
18163
+ if (env) ctx.containerEnv = env;
18164
+ const args = strs("k8s.containerArgs");
18165
+ if (args) ctx.containerArgs = args;
18166
+ const log = str("k8s.processLog");
18167
+ if (log) ctx.processLog = log;
18168
+ return Object.keys(ctx).length > 0 ? ctx : void 0;
18169
+ }
18140
18170
  function grainOf2(graph, nodeId) {
18141
18171
  if (graph.hasNode(nodeId)) {
18142
18172
  const t = graph.getNodeAttributes(nodeId).type;
@@ -18189,6 +18219,11 @@ function promoteCauseLocus(graph, causeNode, incidents) {
18189
18219
  return locusFromNode(graph, causeNode);
18190
18220
  }
18191
18221
  function divergenceSummary(d) {
18222
+ if (d.type === "observed-symbol-mismatch" || d.source === d.target) {
18223
+ const symbol = "symbol" in d && d.symbol ? d.symbol : d.source;
18224
+ const at = "location" in d && d.location ? ` at ${d.location}` : "";
18225
+ return `${symbol}${at}`;
18226
+ }
18192
18227
  const column = "column" in d && d.column ? `.${d.column}` : "";
18193
18228
  const label = "table" in d && d.table ? `${d.table}${column}` : `${d.source} \u2192 ${d.target}`;
18194
18229
  return label;
@@ -18279,6 +18314,10 @@ function buildIncidentCard(graph, errorEvent, incidents, policies) {
18279
18314
  ...nearest.length > 0 ? { blastRadius: { totalAffected: blast.totalAffected, nearest } } : {},
18280
18315
  ...policyCards.length > 0 ? { policies: policyCards } : {},
18281
18316
  ...divergences.length > 0 ? { divergence: divergences } : {},
18317
+ ...(() => {
18318
+ const dc = deployContextOf(errorEvent);
18319
+ return dc ? { deployContext: dc } : {};
18320
+ })(),
18282
18321
  headline: renderHeadline(graph, errorEvent, locus, rootCause?.node ?? null)
18283
18322
  };
18284
18323
  card.grade = gradeIncidentCard(card);
@@ -18633,6 +18672,15 @@ var TYPE_NOUNS = [
18633
18672
  ];
18634
18673
  var EMBED_MIN_SCORE = 0.35;
18635
18674
  async function resolveEntities(graph, question, searchIndex, maxNodes) {
18675
+ const verbatim = [];
18676
+ for (const word of question.split(/\s+/)) {
18677
+ const id = word.replace(/^["'`(<]+|["'`)>?!.,;]+$/g, "");
18678
+ if (!id || !graph.hasNode(id) || verbatim.some((m) => m.nodeId === id)) continue;
18679
+ const node = graph.getNodeAttributes(id);
18680
+ if (node.type === import_types63.NodeType.FrontierNode) continue;
18681
+ verbatim.push({ nodeId: id, label: nodeName(node), via: "id", score: 1 });
18682
+ }
18683
+ if (verbatim.length > 0) return { matched: verbatim.slice(0, maxNodes) };
18636
18684
  const qTokens = queryTokens(question);
18637
18685
  const normalized = question.toLowerCase();
18638
18686
  const best = /* @__PURE__ */ new Map();
@@ -25398,7 +25446,7 @@ function credentialRecord(provider, cred) {
25398
25446
  return { token: cred.accessToken };
25399
25447
  }
25400
25448
  }
25401
- function hostedOptions(provider, summary, serviceName, firebaseServiceMap) {
25449
+ function hostedOptions(provider, summary, serviceName, firebaseServiceMap, serviceMaps = {}) {
25402
25450
  switch (provider) {
25403
25451
  case "supabase": {
25404
25452
  const ref = summary.projectRef;
@@ -25417,9 +25465,12 @@ function hostedOptions(provider, summary, serviceName, firebaseServiceMap) {
25417
25465
  case "firebase": {
25418
25466
  return { inferServices: true, excludeCloudRun: true, ...firebaseServiceMap ?? {} };
25419
25467
  }
25468
+ // Same no-setup rule as Firebase: infer the owning service from the graph; an unknown one stays coarse.
25469
+ // NEAT_CLOUD_RUN_SERVICE_MAP / NEAT_GCP_LB_BACKEND_SERVICE_MAP are optional overrides whose entries win.
25420
25470
  case "cloud-run":
25471
+ return { inferServices: true, ...serviceMaps.cloudRun ? { serviceMap: serviceMaps.cloudRun } : {} };
25421
25472
  case "gcp-lb":
25422
- return { inferServices: true };
25473
+ return { inferServices: true, ...serviceMaps.gcpLb ? { backendServiceMap: serviceMaps.gcpLb } : {} };
25423
25474
  default:
25424
25475
  return null;
25425
25476
  }
@@ -25444,6 +25495,19 @@ function parseFirebaseServiceMap(raw) {
25444
25495
  return void 0;
25445
25496
  }
25446
25497
  }
25498
+ function parseServiceNameMap(raw) {
25499
+ if (!raw) return void 0;
25500
+ try {
25501
+ const parsed = JSON.parse(raw);
25502
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return void 0;
25503
+ const entries = Object.entries(parsed);
25504
+ if (entries.length === 0) return void 0;
25505
+ if (entries.some(([, v]) => typeof v !== "string" || v.length === 0)) return void 0;
25506
+ return Object.fromEntries(entries);
25507
+ } catch {
25508
+ return void 0;
25509
+ }
25510
+ }
25447
25511
  function pushHandlesPath(projectDir) {
25448
25512
  return (0, import_node_path79.join)(projectDir, "neat-out", "connectors-hosted.json");
25449
25513
  }
@@ -25565,7 +25629,10 @@ function startConnectionLoops(c, input, startLoop) {
25565
25629
  onSkip?.(name, "no project selected yet \u2014 not pullable");
25566
25630
  continue;
25567
25631
  }
25568
- const options = hostedOptions(name, c, project, input.firebaseServiceMap);
25632
+ const options = hostedOptions(name, c, project, input.firebaseServiceMap, {
25633
+ ...input.cloudRunServiceMap ? { cloudRun: input.cloudRunServiceMap } : {},
25634
+ ...input.gcpLbBackendServiceMap ? { gcpLb: input.gcpLbBackendServiceMap } : {}
25635
+ });
25569
25636
  if (!options) {
25570
25637
  onSkip?.(name, "no hosted option mapping for this provider");
25571
25638
  continue;
@@ -25675,6 +25742,8 @@ async function maybeStartHostedConnectors(input) {
25675
25742
  projectDir: input.projectDir,
25676
25743
  project: input.project,
25677
25744
  ...parseFirebaseServiceMap(env.NEAT_FIREBASE_SERVICE_MAP) ? { firebaseServiceMap: parseFirebaseServiceMap(env.NEAT_FIREBASE_SERVICE_MAP) } : {},
25745
+ ...parseServiceNameMap(env.NEAT_CLOUD_RUN_SERVICE_MAP) ? { cloudRunServiceMap: parseServiceNameMap(env.NEAT_CLOUD_RUN_SERVICE_MAP) } : {},
25746
+ ...parseServiceNameMap(env.NEAT_GCP_LB_BACKEND_SERVICE_MAP) ? { gcpLbBackendServiceMap: parseServiceNameMap(env.NEAT_GCP_LB_BACKEND_SERVICE_MAP) } : {},
25678
25747
  ...input.errorsPath ? { errorsPath: input.errorsPath } : {},
25679
25748
  ...input.onSkip ? { onSkip: input.onSkip } : {},
25680
25749
  ...input.intervalMs !== void 0 ? { intervalMs: input.intervalMs } : {}